beanbagdb-components 0.2.7 → 0.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beanbagdb-components",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "main": "./dist/main.umd.js",
6
6
  "module": "./dist/main.es.js",
package/dist/app.js DELETED
@@ -1,134 +0,0 @@
1
- /**
2
- * This method can be used in local html apps for initialization based on the params provided in the url.
3
- * Accepted params: db, doc
4
- * Each has a specific format
5
- *
6
- * @param {*} params
7
- * @returns
8
- */
9
-
10
- const initPage = async (page_name,params) => {
11
-
12
- const urlParams = new URLSearchParams(params || window.location.search);
13
- let dbParam = urlParams.get("db");
14
- const docParam = urlParams.get("doc");
15
-
16
- let parsedDocCriteria = null;
17
- let dbName = null;
18
- if (dbParam) {
19
- dbName = dbParam;
20
- } else if (docParam) {
21
- /**
22
- * the doc parameter has a fixed format db_name.identifier1.value1.identifier2.value2...
23
- */
24
- const parts = docParam.split(".");
25
-
26
- if (parts.length < 3 || parts.length % 2 === 0) {
27
- throw new Error(
28
- 'Invalid "doc" parameter format. Expected: db_name.identifier1.value1.identifier2.value2...',
29
- );
30
- }
31
-
32
- dbName = parts[0];
33
- parsedDocCriteria = {}
34
- // Parse identifier-value pairs
35
- for (let i = 1; i < parts.length; i += 2) {
36
- const identifier = parts[i];
37
- const value = parts[i + 1];
38
- parsedDocCriteria[identifier] = value;
39
- }
40
- } else {
41
- throw new Error(
42
- "No identifier params provided. Either specify db (database name) or doc (dbname.id1.val1) like test1._id.12345 or test1.link.12345 ",
43
- );
44
- }
45
-
46
- // console.log(parsedDocCriteria)
47
- // console.log(dbName)
48
-
49
- // Now check if dbParam exists (either from URL or from doc)
50
- if (!dbName) {
51
- throw new Error("Required database name is not provided");
52
- }
53
-
54
- // 2. Get the bbdb-db-list array from localStorage
55
- const dbListJson = localStorage.getItem("bbdb-db-list");
56
- if (!dbListJson) {
57
- throw new Error('No databases found in localStorage "bbdb-db-list"');
58
- }
59
-
60
- const dbList = JSON.parse(dbListJson); // [{name: ""}, {}]
61
-
62
- // 3. Find matching db object by name
63
- const dbObj = dbList.find((db) => db.name === dbName);
64
- if (!dbObj) {
65
- throw new Error(`Database "${dbParam}" not found in bbdb-db-list`);
66
- }
67
-
68
- let result = { dbObj, parsedDocCriteria }
69
- if(page_name=="doc"){
70
- //for the document page, if db is provided show search bar, if doc provided do not show the search bar
71
- result["single_record"] = !(parsedDocCriteria==null)
72
- result["new_record"] = parsedDocCriteria==null
73
- }
74
- return result;
75
- };
76
-
77
- const showMessage = (type, message) => {
78
- let messageEl = document.querySelector("#show-message");
79
-
80
- // Bootstrap 5 alert type mapping
81
- const alertTypes = {
82
- error: "alert-danger",
83
- success: "alert-success",
84
- warning: "alert-warning",
85
- info: "alert-info",
86
- };
87
-
88
- const alertType = alertTypes[type] || "alert-secondary";
89
-
90
- if (messageEl) {
91
- // Update existing alert
92
- messageEl.className = `alert ${alertType} alert-dismissible fade show position-fixed top-0 start-50 translate-middle-x`;
93
- messageEl.innerHTML = `<strong>${message}</strong> <button type="button" class="btn-close" onclick="this.parentElement.remove()" aria-label="Close"></button>`;
94
- } else {
95
- // Create new Bootstrap alert
96
- messageEl = document.createElement("div");
97
- messageEl.id = "show-message";
98
- messageEl.className = `alert ${alertType} alert-dismissible fade show position-fixed top-0 start-50 translate-middle-x`;
99
- messageEl.innerHTML = `<strong>${message}</strong> <button type="button" class="btn-close" onclick="this.parentElement.remove()" aria-label="Close"></button>`;
100
- document.body.prepend(messageEl);
101
- }
102
-
103
- // Position and size styling
104
- Object.assign(messageEl.style, {
105
- zIndex: "9999",
106
- width: "90%",
107
- maxWidth: "500px",
108
- marginTop: "20px",
109
- });
110
- };
111
-
112
-
113
-
114
- const handle_bbdb_action = (action_data)=>{
115
- //console.log(action_data)
116
- let action = action_data.detail
117
- //console.log(action)
118
- if(!action.name){
119
- showMessage("error","No actions name provided")
120
- }
121
- const all_actions = {
122
- "message":()=>{
123
- showMessage(action.type,action.message)
124
- },
125
- "message_link":()=>{
126
- let message = `${action.message} Doc Link : <a href='doc.html?doc=${action.link}' target='_blank'>View</a>`
127
- showMessage(action.type,message)
128
- },
129
- "open_link":()=>{
130
- window.open(`doc.html?doc=${action.link}`, '_blank');
131
- }
132
- }
133
- all_actions[action.name]()
134
- }
@@ -1,51 +0,0 @@
1
- .gutter {
2
- background-color: #eee;
3
-
4
- background-repeat: no-repeat;
5
- background-position: 50%;
6
- }
7
-
8
- .gutter.gutter-vertical {
9
- background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFAQMAAABo7865AAAABlBMVEVHcEzMzMzyAv2sAAAAAXRSTlMAQObYZgAAABBJREFUeF5jOAMEEAIEEFwAn3kMwcB6I2AAAAAASUVORK5CYII=');
10
- }
11
-
12
- .gutter.gutter-horizontal {
13
- background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==');
14
- }
15
-
16
-
17
- html, body {
18
- height: 100vh;
19
- margin: 0;
20
- padding: 0;
21
- /* overflow: hidden; */
22
- }
23
-
24
- #app {
25
- height: 100vh;
26
- padding-bottom: 0;
27
- }
28
-
29
-
30
-
31
- .tabulator {
32
- height: 100% !important;
33
- min-height: 400px;
34
- }
35
-
36
- .gutter {
37
- background-color: #444;
38
- cursor: col-resize;
39
- }
40
-
41
- .gutter.gutter-hover {
42
- background-color: #666;
43
- }
44
-
45
- .navbar-brand{
46
- font-size: 16px;
47
- }
48
-
49
- .accordion-header{
50
- font-size: 12px;
51
- }