@lobb-js/studio 0.39.0 → 0.41.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.
@@ -1,7 +1,8 @@
1
1
  interface Props {
2
2
  filter: Record<string, any>;
3
3
  collectionName: string;
4
+ isEmpty?: boolean;
4
5
  }
5
- declare const Filter: import("svelte").Component<Props, {}, "filter">;
6
+ declare const Filter: import("svelte").Component<Props, {}, "filter" | "isEmpty">;
6
7
  type Filter = ReturnType<typeof Filter>;
7
8
  export default Filter;
@@ -16,13 +16,25 @@
16
16
  collectionName,
17
17
  }: Props = $props();
18
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 {
19
+ // Tracks whether the filter has any rules applied. Filter pushes
20
+ // this back up so we can shrink the popover when empty — the
21
+ // loaded width feels hollow against the empty-state icon.
22
+ let filterIsEmpty = $state(true);
23
+
24
+ // Count rules across the whole filter tree. A single field with two
25
+ // operators ({age: {$gte, $lte}}) is two rules. Nested $and / $or
26
+ // arrays (groups) recurse into their children so a group with three
27
+ // rules contributes three, not one.
28
+ function countRules(f: any): number {
29
+ if (f == null || typeof f !== "object") return 0;
23
30
  let n = 0;
24
- for (const [key, value] of Object.entries(f ?? {})) {
25
- if (key.startsWith("$")) { n += 1; continue; }
31
+ for (const [key, value] of Object.entries(f)) {
32
+ if (key === "$and" || key === "$or") {
33
+ if (Array.isArray(value)) {
34
+ for (const child of value) n += countRules(child);
35
+ }
36
+ continue;
37
+ }
26
38
  if (value && typeof value === "object" && !Array.isArray(value)) {
27
39
  n += Object.keys(value).length;
28
40
  } else {
@@ -51,7 +63,13 @@
51
63
  {/if}
52
64
  {/if}
53
65
  </Popover.Trigger>
54
- <Popover.Content class="w-screen max-w-[36rem] p-0">
55
- <Filter bind:filter {collectionName} />
66
+ <Popover.Content
67
+ class="
68
+ w-screen p-0
69
+ transition-[max-width] duration-150
70
+ {filterIsEmpty ? 'max-w-xs' : 'max-w-[36rem]'}
71
+ "
72
+ >
73
+ <Filter bind:filter {collectionName} bind:isEmpty={filterIsEmpty} />
56
74
  </Popover.Content>
57
75
  </Popover.Root>
@@ -4,7 +4,7 @@
4
4
  import * as Popover from "../ui/popover/index.js";
5
5
  import * as Select from "../ui/select/index.js";
6
6
  import { GripVertical, Plus, X } from "lucide-svelte";
7
- import Button, { buttonVariants } from "../ui/button/button.svelte";
7
+ import Button from "../ui/button/button.svelte";
8
8
  import { getStudioContext } from "../../context";
9
9
  import { getFieldIcon } from "./utils";
10
10
  import { dndzone } from "svelte-dnd-action";
@@ -205,17 +205,13 @@
205
205
  </div>
206
206
  {/if}
207
207
  </div>
208
- <div class="flex justify-between border-t p-2">
208
+ <div class="flex justify-between px-3 pb-3">
209
209
  {#if getFieldNames().length}
210
210
  <Popover.Root bind:open={popoverOpen}>
211
211
  <Popover.Trigger
212
- class={buttonVariants({
213
- variant: "ghost",
214
- size: "sm",
215
- class: "text-muted-foreground",
216
- })}
212
+ class="inline-flex w-fit items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground hover:text-foreground"
217
213
  >
218
- <Plus />
214
+ <Plus size="14" />
219
215
  Add a sort rule
220
216
  </Popover.Trigger>
221
217
  <Popover.Content class="w-64 p-2">
@@ -231,7 +227,7 @@
231
227
  </Popover.Content>
232
228
  </Popover.Root>
233
229
  {:else}
234
- <div class="flex items-center text-xs text-muted-foreground">
230
+ <div class="px-2 py-1 text-xs text-muted-foreground">
235
231
  All columns have been added
236
232
  </div>
237
233
  {/if}
@@ -22,7 +22,6 @@
22
22
 
23
23
  function pick(fieldName: string) {
24
24
  sort = { ...sort, [fieldName]: "asc" };
25
- popoverOpen = false;
26
25
  }
27
26
  </script>
28
27
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lobb-js/studio",
3
3
  "license": "UNLICENSED",
4
- "version": "0.39.0",
4
+ "version": "0.41.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"