@gandalan/weblibs 1.5.7 → 1.5.9

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/index.js CHANGED
@@ -8,3 +8,52 @@ export { createAuthManager, fluentIdasAuthManager } from "./api/fluentAuthManage
8
8
  export { fetchEnvConfig } from "./api/fluentEnvUtils";
9
9
  export { restClient } from "./api/fluentRestClient";
10
10
 
11
+ // re-export all modules from the ui folder as named exports
12
+ export * from "./ui/index.js";
13
+
14
+ /**
15
+ * @typedef {Object} NeherApp3Module
16
+ * @property {string} moduleName
17
+ * @property {(app: NeherApp3) => void} setup
18
+ * @property {(node : HTMLElement, props : NeherApp3Props) => function} mount Must return an unmount function
19
+ * @property {string?} embedUrl
20
+ */
21
+
22
+ /**
23
+ * @typedef {Object} NeherApp3
24
+ * @property {(menuItem : NeherApp3MenuItem) => void} addMenuItem
25
+ * @property {(appModule: NeherApp3Module) => void} addApp
26
+ * @property {(message: string, type? : number, cb? : function) => void} notify - Shows a notification. Type defaults to 0 (info). Callback is optional.
27
+ * @property {function} getArtikelStamm
28
+ * @property {function} getWarenGruppen
29
+ * @property {function} getArtikelByGuid
30
+ * @property {function} getWertelisten
31
+ * @property {function} getScripts
32
+ * @property {function} getVarianten
33
+ */
34
+
35
+ /**
36
+ * @typedef {Object} NeherApp3MenuItem
37
+ * @property {string} [id] - Unique identifier for the menu item (auto-generated if not provided)
38
+ * @property {boolean} [selected] - Indicates if the menu item is currently selected (managed by the menu system)
39
+ * @property {string} [icon] - URL to an icon
40
+ * @property {string} url - Relative URL to use for routes
41
+ * @property {string} text - Display text
42
+ * @property {string} [parent] - Parent menu item (optional). If not set, the item will be added to the top level menu.
43
+ * @property {boolean} [hidden] - If true, the menu item will not be displayed
44
+ */
45
+
46
+ /**
47
+ * Global NeherApp3 instance
48
+ * @type {NeherApp3}
49
+ * @global
50
+ */
51
+ globalThis.neherapp3 = globalThis.neherapp3 || {};
52
+
53
+ /**
54
+ * @typedef {Object} NeherApp3Props
55
+ * @property {import("./api/fluentApi").FluentApi} api
56
+ * @property {import("./api/fluentAuthManager").FluentAuthManager} authManager
57
+ * @property {import("./api/fluentApi").FluentApi} idas
58
+ */
59
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "description": "WebLibs for Gandalan JS/TS projects",
5
5
  "keywords": [
6
6
  "gandalan"
package/ui/Grid.svelte ADDED
@@ -0,0 +1,44 @@
1
+ <script>
2
+ let {
3
+ data,
4
+ hideCols = [],
5
+ onclick=(row, col) => {},
6
+ dataCell = defaultDataCell,
7
+ headerCell = defaultHeaderCell
8
+ } = $props();
9
+ </script>
10
+
11
+ {#if data.length}
12
+ <table class="w-full">
13
+ <thead>
14
+ <tr>
15
+ {#each Object.keys(data[0]) as key}
16
+ {#if hideCols.indexOf(key) === -1}
17
+ <th>{@render headerCell(key)}</th>
18
+ {/if}
19
+ {/each}
20
+ </tr>
21
+ </thead>
22
+ <tbody class="overflow-auto">
23
+ {#each data as row}
24
+ <tr class="hover:bg-gray-300" class:cursor-pointer={onclick}>
25
+ {#each Object.keys(data[0]) as key}
26
+ {#if hideCols.indexOf(key) === -1}
27
+ <td onclick={(e) => { e.preventDefault(); onclick(row, key); }}>{@render dataCell(row[key])}</td>
28
+ {/if}
29
+ {/each}
30
+ </tr>
31
+ {/each}
32
+ </tbody>
33
+ </table>
34
+ {:else}
35
+ <progress>Loading</progress>
36
+ {/if}
37
+
38
+ {#snippet defaultHeaderCell(content)}
39
+ <b>{content}</b>
40
+ {/snippet}
41
+
42
+ {#snippet defaultDataCell(content)}
43
+ {content}
44
+ {/snippet}
package/ui/css/app.css ADDED
@@ -0,0 +1,9 @@
1
+ @import "tailwindcss";
2
+
3
+ h1 { @apply text-2xl font-bold flex items-center; }
4
+ h1 img { @apply pr-3 h-6; }
5
+ button { @apply bg-gray-200 border border-gray-300 text-black px-2 py-2 rounded-md hover:bg-white; }
6
+ input { @apply border border-gray-300 text-black px-2 py-2 rounded-md; }
7
+ table { @apply w-full; }
8
+ th { @apply border border-gray-300 p-1 text-left bg-[#868686] text-white font-normal sticky top-0; }
9
+ td { @apply border border-gray-300 text-black p-1; }
package/ui/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import Grid from "./Grid.svelte";
2
+
3
+ export { Grid };
package/jsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "allowJs": true,
4
- /**
5
- * Typecheck JS in `.svelte` and `.js` files by default.
6
- * Disable this if you'd like to use dynamic types.
7
- */
8
- "checkJs": false, // Default: true
9
- "esModuleInterop": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "resolveJsonModule": true,
12
- "skipLibCheck": true,
13
- "lib": [ "ES6" ],
14
- /**
15
- * To have warnings / errors of the Svelte compiler at the
16
- * correct position, enable source maps by default.
17
- */
18
- "sourceMap": true,
19
- "strict": true
20
- }
21
- }