@bexis2/bexis2-core-ui 0.4.9 → 0.4.10

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.
@@ -80,6 +80,12 @@ export interface Column {
80
80
  export interface Columns {
81
81
  [key: string]: Column;
82
82
  }
83
+ export type ServerConfig = {
84
+ baseUrl?: string;
85
+ sendModel: Send;
86
+ entityId?: number;
87
+ versionId?: number;
88
+ };
83
89
  export interface TableConfig<T> {
84
90
  id: string;
85
91
  data: Writable<T[]>;
@@ -94,12 +100,7 @@ export interface TableConfig<T> {
94
100
  pageSizes?: number[];
95
101
  defaultPageSize?: number;
96
102
  optionsComponent?: typeof SvelteComponent;
97
- serverSide?: boolean;
98
- URL?: string;
99
- token?: string;
100
- sendModel?: Send;
101
- entityId?: number;
102
- versionId?: number;
103
+ server?: ServerConfig;
103
104
  }
104
105
  export interface keyValuePairType {
105
106
  id: number;
@@ -150,6 +151,13 @@ export type Filter = {
150
151
  filterBy: FilterOptionsEnum;
151
152
  value: string | number | Date | boolean;
152
153
  };
154
+ export type FacetOption = {
155
+ value: string;
156
+ count?: number;
157
+ };
158
+ export type FacetGroup = {
159
+ [key: string]: FacetOption[];
160
+ };
153
161
  export declare class Send {
154
162
  id: number;
155
163
  limit: number;
package/package.json CHANGED
@@ -1,114 +1,114 @@
1
- {
2
- "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.4.9",
4
- "private": false,
5
- "scripts": {
6
- "dev": "vite dev",
7
- "build": "vite build",
8
- "build package": "svelte-kit sync && svelte-package --watch",
9
- "preview": "vite preview",
10
- "test": "playwright test",
11
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
12
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
13
- "test:unit": "vitest",
14
- "lint": "prettier --plugin-search-dir . --check . && eslint .",
15
- "format": "prettier --plugin-search-dir . --write .",
16
- "check outdated": "npm outdated",
17
- "upgrade all": "ncu --upgrade",
18
- "1.npm - update package infos": "npm init --scope bexis2",
19
- "2.npm - package": "svelte-package",
20
- "3.npm - publish": "npm publish --access public"
21
- },
22
- "devDependencies": {
23
- "@playwright/test": "^1.45.3",
24
- "@skeletonlabs/skeleton": "^2.10.2",
25
- "@skeletonlabs/tw-plugin": "^0.4.0",
26
- "@sveltejs/adapter-auto": "^3.2.2",
27
- "@sveltejs/adapter-static": "^3.0.2",
28
- "@sveltejs/package": "^2.3.2",
29
- "@tailwindcss/forms": "^0.5.7",
30
- "@tailwindcss/typography": "^0.5.13",
31
- "@types/node": "^22.0.2",
32
- "@typescript-eslint/eslint-plugin": "^8.0.0",
33
- "@typescript-eslint/parser": "^8.0.0",
34
- "autoprefixer": "^10.4.19",
35
- "eslint": "^9.8.0",
36
- "eslint-config-prettier": "^9.1.0",
37
- "postcss": "^8.4.40",
38
- "prettier": "^3.3.3",
39
- "prettier-plugin-svelte": "^3.2.6",
40
- "raw-loader": "^4.0.2",
41
- "svelte": "^4.2.18",
42
- "svelte-check": "^3.8.5",
43
- "tailwindcss": "^3.4.7",
44
- "tslib": "^2.6.3",
45
- "typescript": "^5.5.4",
46
- "vite": "^5.3.5",
47
- "vitest": "^2.0.5"
48
- },
49
- "type": "module",
50
- "module": "./src/lib/index.ts",
51
- "types": "./src/lib/index.d.ts",
52
- "description": "Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).",
53
- "main": "./src/lib/index.d.ts",
54
- "directories": {
55
- "test": "tests"
56
- },
57
- "files": [
58
- "dist",
59
- "src/lib"
60
- ],
61
- "dependencies": {
62
- "@codemirror/lang-html": "^6.4.9",
63
- "@codemirror/lang-javascript": "^6.2.2",
64
- "@codemirror/lang-json": "^6.0.1",
65
- "@codemirror/lint": "^6.8.1",
66
- "@codemirror/theme-one-dark": "^6.1.2",
67
- "@floating-ui/dom": "^1.6.8",
68
- "@fortawesome/fontawesome-free": "^6.6.0",
69
- "@fortawesome/fontawesome-svg-core": "^6.6.0",
70
- "@fortawesome/free-regular-svg-icons": "^6.6.0",
71
- "@fortawesome/free-solid-svg-icons": "^6.6.0",
72
- "@sveltejs/kit": "^2.5.19",
73
- "@sveltejs/vite-plugin-svelte": "^3.1.1",
74
- "axios": "^1.7.3",
75
- "codemirror": "^6.0.1",
76
- "dateformat": "^5.0.3",
77
- "delay": "^6.0.0",
78
- "dotenv": "^16.4.5",
79
- "eslint4b-prebuilt": "^6.7.2",
80
- "highlight.js": "^11.10.0",
81
- "highlightjs-svelte": "^1.0.6",
82
- "svelte": "^4.2.18",
83
- "svelte-codemirror-editor": "^1.4.0",
84
- "svelte-fa": "^4.0.2",
85
- "svelte-file-dropzone": "^2.0.7",
86
- "svelte-headless-table": "^0.18.2",
87
- "svelte-select": "5.8.3",
88
- "vest": "^5.4.0"
89
- },
90
- "author": "David Schöne",
91
- "license": "ISC",
92
- "repository": {
93
- "type": "git",
94
- "url": "git+https://github.com/BEXIS2/bexis2-core-ui.git"
95
- },
96
- "bugs": {
97
- "url": "https://github.com/BEXIS2/bexis2-core-ui/issues"
98
- },
99
- "homepage": "https://github.com/BEXIS2/bexis2-core-ui#readme",
100
- "keywords": [
101
- "bexis2",
102
- "libary"
103
- ],
104
- "exports": {
105
- ".": {
106
- "types": "./dist/index.d.ts",
107
- "svelte": "./dist/index.js"
108
- },
109
- "./dist/index.css": {
110
- "import": "./dist/index.css",
111
- "require": "./dist/index.css"
112
- }
113
- }
114
- }
1
+ {
2
+ "name": "@bexis2/bexis2-core-ui",
3
+ "version": "0.4.10",
4
+ "private": false,
5
+ "scripts": {
6
+ "dev": "vite dev",
7
+ "build": "vite build",
8
+ "build package": "svelte-kit sync && svelte-package --watch",
9
+ "preview": "vite preview",
10
+ "test": "playwright test",
11
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
12
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
13
+ "test:unit": "vitest",
14
+ "lint": "prettier --plugin-search-dir . --check . && eslint .",
15
+ "format": "prettier --plugin-search-dir . --write .",
16
+ "check outdated": "npm outdated",
17
+ "upgrade all": "ncu --upgrade",
18
+ "1.npm - update package infos": "npm init --scope bexis2",
19
+ "2.npm - package": "svelte-package",
20
+ "3.npm - publish": "npm publish --access public"
21
+ },
22
+ "devDependencies": {
23
+ "@playwright/test": "^1.45.3",
24
+ "@skeletonlabs/skeleton": "^2.10.2",
25
+ "@skeletonlabs/tw-plugin": "^0.4.0",
26
+ "@sveltejs/adapter-auto": "^3.2.2",
27
+ "@sveltejs/adapter-static": "^3.0.2",
28
+ "@sveltejs/package": "^2.3.2",
29
+ "@tailwindcss/forms": "^0.5.7",
30
+ "@tailwindcss/typography": "^0.5.13",
31
+ "@types/node": "^22.0.2",
32
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
33
+ "@typescript-eslint/parser": "^8.0.0",
34
+ "autoprefixer": "^10.4.19",
35
+ "eslint": "^9.8.0",
36
+ "eslint-config-prettier": "^9.1.0",
37
+ "postcss": "^8.4.40",
38
+ "prettier": "^3.3.3",
39
+ "prettier-plugin-svelte": "^3.2.6",
40
+ "raw-loader": "^4.0.2",
41
+ "svelte": "^4.2.18",
42
+ "svelte-check": "^3.8.5",
43
+ "tailwindcss": "^3.4.7",
44
+ "tslib": "^2.6.3",
45
+ "typescript": "^5.5.4",
46
+ "vite": "^5.3.5",
47
+ "vitest": "^2.0.5"
48
+ },
49
+ "type": "module",
50
+ "module": "./src/lib/index.ts",
51
+ "types": "./src/lib/index.d.ts",
52
+ "description": "Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).",
53
+ "main": "./src/lib/index.d.ts",
54
+ "directories": {
55
+ "test": "tests"
56
+ },
57
+ "files": [
58
+ "dist",
59
+ "src/lib"
60
+ ],
61
+ "dependencies": {
62
+ "@codemirror/lang-html": "^6.4.9",
63
+ "@codemirror/lang-javascript": "^6.2.2",
64
+ "@codemirror/lang-json": "^6.0.1",
65
+ "@codemirror/lint": "^6.8.1",
66
+ "@codemirror/theme-one-dark": "^6.1.2",
67
+ "@floating-ui/dom": "^1.6.8",
68
+ "@fortawesome/fontawesome-free": "^6.6.0",
69
+ "@fortawesome/fontawesome-svg-core": "^6.6.0",
70
+ "@fortawesome/free-regular-svg-icons": "^6.6.0",
71
+ "@fortawesome/free-solid-svg-icons": "^6.6.0",
72
+ "@sveltejs/kit": "^2.5.19",
73
+ "@sveltejs/vite-plugin-svelte": "^3.1.1",
74
+ "axios": "^1.7.3",
75
+ "codemirror": "^6.0.1",
76
+ "dateformat": "^5.0.3",
77
+ "delay": "^6.0.0",
78
+ "dotenv": "^16.4.5",
79
+ "eslint4b-prebuilt": "^6.7.2",
80
+ "highlight.js": "^11.10.0",
81
+ "highlightjs-svelte": "^1.0.6",
82
+ "svelte": "^4.2.18",
83
+ "svelte-codemirror-editor": "^1.4.0",
84
+ "svelte-fa": "^4.0.2",
85
+ "svelte-file-dropzone": "^2.0.7",
86
+ "svelte-headless-table": "^0.18.2",
87
+ "svelte-select": "5.8.3",
88
+ "vest": "^5.4.0"
89
+ },
90
+ "author": "David Schöne",
91
+ "license": "ISC",
92
+ "repository": {
93
+ "type": "git",
94
+ "url": "git+https://github.com/BEXIS2/bexis2-core-ui.git"
95
+ },
96
+ "bugs": {
97
+ "url": "https://github.com/BEXIS2/bexis2-core-ui/issues"
98
+ },
99
+ "homepage": "https://github.com/BEXIS2/bexis2-core-ui#readme",
100
+ "keywords": [
101
+ "bexis2",
102
+ "libary"
103
+ ],
104
+ "exports": {
105
+ ".": {
106
+ "types": "./dist/index.d.ts",
107
+ "svelte": "./dist/index.js"
108
+ },
109
+ "./dist/index.css": {
110
+ "import": "./dist/index.css",
111
+ "require": "./dist/index.css"
112
+ }
113
+ }
114
+ }
@@ -0,0 +1,120 @@
1
+ <script lang="ts">
2
+ import { getModalStore, Modal, TreeView, TreeViewItem } from '@skeletonlabs/skeleton';
3
+
4
+ import ShowMore from './ShowMore.svelte';
5
+ import type { FacetOption, FacetGroup } from '$models/Models';
6
+
7
+ export let groupSelection = false;
8
+ export let groups: FacetGroup;
9
+ export let selected: FacetGroup;
10
+ export let selectedGroups: { [key: string]: boolean } = {};
11
+ export let showAll = false;
12
+ export let open = false;
13
+
14
+ const modalStore = getModalStore();
15
+ const showMore = (group: string) => {
16
+ modalStore.trigger({
17
+ type: 'component',
18
+ title: `${group}`,
19
+ component: {
20
+ ref: ShowMore,
21
+ props: {
22
+ group,
23
+ handleSave,
24
+ handleCancel,
25
+ selected: selected[group],
26
+ items: groups[group].sort((a, b) => a.value.localeCompare(b.value))
27
+ }
28
+ }
29
+ });
30
+ };
31
+
32
+ const handleSave = (group: string, selectedItems: FacetOption[]) => {
33
+ selected[group] = selectedItems;
34
+ modalStore.close();
35
+ };
36
+
37
+ const handleCancel = () => {
38
+ modalStore.close();
39
+ };
40
+
41
+ const sortOptions = () => {
42
+ // Sort facets in a descending order if count exits, or sort alphabetically
43
+ Object.keys(groups).forEach((group) => {
44
+ groups[group] = [
45
+ ...selected[group].sort((a, b) => {
46
+ if (a.count != undefined && b.count != undefined) {
47
+ return b.count - a.count;
48
+ }
49
+ return a.value.localeCompare(b.value);
50
+ }),
51
+ ...groups[group]
52
+ .filter((item) => !selected[group].includes(item))
53
+ .sort((a, b) => {
54
+ if (a.count != undefined && b.count != undefined) {
55
+ return b.count - a.count;
56
+ }
57
+ return a.value.localeCompare(b.value);
58
+ })
59
+ ];
60
+ });
61
+ };
62
+
63
+ $: selected, sortOptions();
64
+ </script>
65
+
66
+ <TreeView selection={groupSelection} multiple={groupSelection} padding="p-1" hover="">
67
+ {#each Object.keys(groups) as group}
68
+ <TreeViewItem
69
+ name="groups"
70
+ value={group}
71
+ {open}
72
+ hyphenOpacity="opacity-0"
73
+ bind:group={selectedGroups}
74
+ bind:checked={selectedGroups[group]}
75
+ >
76
+ <p class="font-semibold">{group}</p>
77
+
78
+ <svelte:fragment slot="children">
79
+ <!-- If more than 5 choices, show the remaining in the Modal -->
80
+ {#if !showAll}
81
+ {#each groups[group].slice(0, 5) as item}
82
+ <TreeViewItem
83
+ bind:group={selected[group]}
84
+ name={group}
85
+ value={item}
86
+ hyphenOpacity="opacity-0"
87
+ spacing="space-x-3"
88
+ selection
89
+ multiple
90
+ >
91
+ <p>{item.value} ({item.count})</p>
92
+ </TreeViewItem>
93
+ {/each}
94
+ <!-- Trigger for the Modal to view all options -->
95
+ {#if groups[group].length > 5}
96
+ <TreeViewItem hyphenOpacity="opacity-0">
97
+ <button class="anchor" on:click={() => showMore(group)}>more</button></TreeViewItem
98
+ >
99
+ {/if}
100
+ {:else}
101
+ {#each groups[group] as item}
102
+ <TreeViewItem
103
+ bind:group={selected[group]}
104
+ name={group}
105
+ value={item}
106
+ hyphenOpacity="opacity-0"
107
+ spacing="space-x-3"
108
+ selection
109
+ multiple
110
+ >
111
+ <p>{item.value} ({item.count})</p>
112
+ </TreeViewItem>
113
+ {/each}
114
+ {/if}
115
+ </svelte:fragment>
116
+ </TreeViewItem>
117
+ {/each}
118
+ </TreeView>
119
+
120
+ <Modal />
@@ -0,0 +1,87 @@
1
+ <script lang="ts">
2
+ import type { FacetOption } from '$models/Models';
3
+
4
+ export let group: string; // Group name
5
+ export let items: FacetOption[]; // All possible choices
6
+ export let selected: FacetOption[]; // Initially selected items
7
+ export let handleSave: (group: string, selectedItems: FacetOption[]) => {};
8
+ export let handleCancel: () => {};
9
+
10
+ // This local variable is needed for resetting the Modal when the user cancels selection.
11
+ let selectedItems = selected; // Selected items in the Modal.
12
+
13
+ const handleCheck = (e, index: number) => {
14
+ const target = e.target as HTMLInputElement;
15
+ if (target.checked) {
16
+ selectedItems = [...selectedItems, items[index]];
17
+ } else {
18
+ selectedItems = selectedItems.filter((item) => item !== items[index]);
19
+ }
20
+ };
21
+
22
+ const selectAll = () => {
23
+ selectedItems = items;
24
+ };
25
+
26
+ const selectNone = () => {
27
+ selectedItems = [];
28
+ };
29
+
30
+ const onSave = () => {
31
+ handleSave(group, selectedItems);
32
+ };
33
+
34
+ const onCancel = () => {
35
+ selectedItems = selected;
36
+ handleCancel();
37
+ };
38
+
39
+ const gridClass = (items: FacetOption[]) => {
40
+ if (items.length >= 50) {
41
+ return 'grid-cols-5';
42
+ } else if (items.length >= 30) {
43
+ return 'grid-cols-4';
44
+ } else if (items.length >= 20) {
45
+ return 'grid-cols-3';
46
+ }
47
+
48
+ return 'grid-cols-2';
49
+ };
50
+ </script>
51
+
52
+ <div class="p-5 rounded-md bg-surface-50 dark:bg-surface-800 border-primary-500 border-2">
53
+ <!-- Header -->
54
+ <h2 class="text-xl font-semibold">{group}</h2>
55
+
56
+ <!-- Items -->
57
+ <div
58
+ class="grid {gridClass(
59
+ items
60
+ )} !gap-x-20 gap-y-2 py-10 px-2 max-h-[1000px] overflow-x-auto max-w-6xl"
61
+ >
62
+ {#each items as item, index}
63
+ <label class="flex gap-3 items-center">
64
+ <input
65
+ type="checkbox"
66
+ class="checkbox"
67
+ value={item.value}
68
+ on:click={(e) => handleCheck(e, index)}
69
+ checked={selectedItems.includes(item)}
70
+ />
71
+ <span class="whitespace-nowrap break-before-avoid break-after-avoid">{item.value}</span>
72
+ </label>
73
+ {/each}
74
+ </div>
75
+
76
+ <!-- Footer -->
77
+ <div class="flex w-full justify-between gap-5">
78
+ <div class="flex gap-3">
79
+ <button class="btn btn-sm variant-filled-tertiary" on:click={selectNone}>None</button>
80
+ <button class="btn btn-sm variant-filled-tertiary" on:click={selectAll}>All</button>
81
+ </div>
82
+ <div class="flex gap-3">
83
+ <button class="btn btn-sm variant-filled-primary" on:click={onSave}>Save</button>
84
+ <button class="btn btn-sm variant-filled-secondary" on:click={onCancel}>Cancel</button>
85
+ </div>
86
+ </div>
87
+ </div>
@@ -0,0 +1,37 @@
1
+ <script lang="ts">
2
+ import { popup } from '@skeletonlabs/skeleton';
3
+ import type { PopupSettings } from '@skeletonlabs/skeleton';
4
+
5
+ export let columns: { id: string; label: string; visible: boolean }[] = [];
6
+ export let tableId: string;
7
+
8
+ const popupCombobox: PopupSettings = {
9
+ event: 'click',
10
+ target: `${tableId}-columns-menu`,
11
+ placement: 'bottom'
12
+ };
13
+ </script>
14
+
15
+ <button
16
+ type="button"
17
+ class="btn btn-sm variant-filled-primary rounded-full order-last"
18
+ use:popup={popupCombobox}>Columns</button
19
+ >
20
+
21
+ <div
22
+ class="bg-white dark:bg-surface-500 p-4 rounded-md shadow-md z-10"
23
+ data-popup="{tableId}-columns-menu"
24
+ >
25
+ {#each columns as column}
26
+ <div class="flex gap-3 items-center">
27
+ <input
28
+ type="checkbox"
29
+ bind:checked={column.visible}
30
+ disabled={columns.filter((c) => c.visible).length === 1 && column.visible}
31
+ />
32
+ <span>{column.label}</span>
33
+ </div>
34
+ {/each}
35
+
36
+ <div class="arrow bg-white dark:bg-surface-500" />
37
+ </div>