@lobb-js/studio 0.38.0 → 0.39.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.
- package/dist/actions.d.ts +1 -0
- package/dist/components/dataTable/dataTable.svelte +3 -0
- package/dist/components/dataTable/dataTable.svelte.d.ts +1 -0
- package/dist/components/dataTable/filter.svelte +469 -238
- package/dist/components/dataTable/filter.svelte.d.ts +1 -4
- package/dist/components/dataTable/filterButton.svelte +21 -4
- package/dist/components/dataTable/header.svelte +9 -31
- package/dist/components/dataTable/header.svelte.d.ts +1 -0
- package/dist/components/dataTablePopup/dataTablePopup.svelte +7 -0
- package/dist/components/dataTablePopup/dataTablePopup.svelte.d.ts +1 -0
- package/package.json +1 -1
- package/src/lib/actions.ts +1 -0
- package/src/lib/components/dataTable/dataTable.svelte +3 -0
- package/src/lib/components/dataTable/filter.svelte +469 -238
- package/src/lib/components/dataTable/filterButton.svelte +21 -4
- package/src/lib/components/dataTable/header.svelte +9 -31
- package/src/lib/components/dataTablePopup/dataTablePopup.svelte +7 -0
|
@@ -15,6 +15,22 @@
|
|
|
15
15
|
showText = true,
|
|
16
16
|
collectionName,
|
|
17
17
|
}: Props = $props();
|
|
18
|
+
|
|
19
|
+
// Count rules, not top-level fields: a single field with two
|
|
20
|
+
// operators ({age: {$gte, $lte}}) is two rules, not one. Unmanaged
|
|
21
|
+
// $and / $or carriers count as one rule each (legacy filter shape).
|
|
22
|
+
function countRules(f: Record<string, any>): number {
|
|
23
|
+
let n = 0;
|
|
24
|
+
for (const [key, value] of Object.entries(f ?? {})) {
|
|
25
|
+
if (key.startsWith("$")) { n += 1; continue; }
|
|
26
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
27
|
+
n += Object.keys(value).length;
|
|
28
|
+
} else {
|
|
29
|
+
n += 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return n;
|
|
33
|
+
}
|
|
18
34
|
</script>
|
|
19
35
|
|
|
20
36
|
<Popover.Root>
|
|
@@ -27,14 +43,15 @@
|
|
|
27
43
|
>
|
|
28
44
|
<Settings2 />
|
|
29
45
|
{#if showText}
|
|
30
|
-
{
|
|
31
|
-
|
|
46
|
+
{@const n = countRules(filter)}
|
|
47
|
+
{#if n}
|
|
48
|
+
Filtered by {n} {n === 1 ? "rule" : "rules"}
|
|
32
49
|
{:else}
|
|
33
50
|
Filter
|
|
34
51
|
{/if}
|
|
35
52
|
{/if}
|
|
36
53
|
</Popover.Trigger>
|
|
37
|
-
<Popover.Content class="w-screen max-w-
|
|
38
|
-
<Filter bind:filter {collectionName}
|
|
54
|
+
<Popover.Content class="w-screen max-w-[36rem] p-0">
|
|
55
|
+
<Filter bind:filter {collectionName} />
|
|
39
56
|
</Popover.Content>
|
|
40
57
|
</Popover.Root>
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import type { ParentContext } from "./dataTable.svelte";
|
|
5
5
|
import CanAccess from "../canAccess.svelte";
|
|
6
6
|
import { Download, ListRestart, LoaderCircle, Plus, Trash, Link } from "lucide-svelte";
|
|
7
|
-
import LlmButton from "../LlmButton.svelte";
|
|
8
7
|
import FilterButton from "./filterButton.svelte";
|
|
9
8
|
import SortButton from "./sortButton.svelte";
|
|
10
9
|
import Button from "../ui/button/button.svelte";
|
|
@@ -26,6 +25,7 @@
|
|
|
26
25
|
onLink?: (record: any) => void;
|
|
27
26
|
onCreate?: (changes: Changes) => void;
|
|
28
27
|
showImport?: boolean;
|
|
28
|
+
showFilter?: boolean;
|
|
29
29
|
loading?: boolean;
|
|
30
30
|
left?: Snippet<[]>;
|
|
31
31
|
}
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
onLink,
|
|
39
39
|
onCreate,
|
|
40
40
|
showImport = true,
|
|
41
|
+
showFilter = true,
|
|
41
42
|
loading = false,
|
|
42
43
|
left
|
|
43
44
|
}: Props = $props();
|
|
@@ -122,41 +123,18 @@
|
|
|
122
123
|
{selectedRecords.length > 1 ? "records" : "record"}
|
|
123
124
|
</Button>
|
|
124
125
|
{:else}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
{#if showFilter}
|
|
127
|
+
<FilterButton
|
|
128
|
+
bind:filter={params.filter}
|
|
129
|
+
showText={!headerIsSmall}
|
|
130
|
+
{collectionName}
|
|
131
|
+
/>
|
|
132
|
+
{/if}
|
|
130
133
|
<SortButton
|
|
131
134
|
{collectionName}
|
|
132
135
|
bind:sort={params.sort}
|
|
133
136
|
showText={!headerIsSmall}
|
|
134
137
|
/>
|
|
135
|
-
<LlmButton
|
|
136
|
-
variant="outline"
|
|
137
|
-
title="Filter table with AI"
|
|
138
|
-
description="Tell the AI how do you want to filter the table"
|
|
139
|
-
size="sm"
|
|
140
|
-
format={{
|
|
141
|
-
type: "json_object",
|
|
142
|
-
}}
|
|
143
|
-
messages={[
|
|
144
|
-
{
|
|
145
|
-
role: "system",
|
|
146
|
-
content: [
|
|
147
|
-
"You will receive natural language queries from a user describing how they want to filter a table list view.",
|
|
148
|
-
"Your task is to generate a filter object based on the user's prompt.",
|
|
149
|
-
`This is the schema of the filter json: ${JSON.stringify(ctx.meta.filter.filter_schema)}`,
|
|
150
|
-
`This is the schema of the current collection: ${JSON.stringify(ctx.meta.collections[collectionName])}`,
|
|
151
|
-
].join(" "),
|
|
152
|
-
},
|
|
153
|
-
]}
|
|
154
|
-
onApiResponseComplete={async (res) => {
|
|
155
|
-
params.filter = JSON.parse(res);
|
|
156
|
-
}}
|
|
157
|
-
>
|
|
158
|
-
{headerIsSmall ? "" : "Filter with AI"}
|
|
159
|
-
</LlmButton>
|
|
160
138
|
{/if}
|
|
161
139
|
</div>
|
|
162
140
|
<div>
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
title?: string;
|
|
18
18
|
showHeader?: boolean;
|
|
19
19
|
showFooter?: boolean;
|
|
20
|
+
// Popups are usually opened from chart drill-downs with a
|
|
21
|
+
// preset filter — re-filtering inside the popup almost never
|
|
22
|
+
// makes sense, so the filter button is hidden by default here.
|
|
23
|
+
// Pass showFilter={true} to surface it.
|
|
24
|
+
showFilter?: boolean;
|
|
20
25
|
tableProps?: Partial<TableProps>;
|
|
21
26
|
tabs?: CollectionTab[];
|
|
22
27
|
view?: { id: string; [key: string]: any };
|
|
@@ -31,6 +36,7 @@
|
|
|
31
36
|
title,
|
|
32
37
|
showHeader = true,
|
|
33
38
|
showFooter = true,
|
|
39
|
+
showFilter = false,
|
|
34
40
|
tableProps,
|
|
35
41
|
tabs,
|
|
36
42
|
view,
|
|
@@ -78,6 +84,7 @@
|
|
|
78
84
|
{searchParams}
|
|
79
85
|
{showHeader}
|
|
80
86
|
{showFooter}
|
|
87
|
+
{showFilter}
|
|
81
88
|
{tableProps}
|
|
82
89
|
{tabs}
|
|
83
90
|
{view}
|