@lobb-js/studio 0.29.1 → 0.30.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 CHANGED
@@ -11,7 +11,16 @@ export interface OpenDataTableDrawerProps {
11
11
  position?: "side" | "bottom";
12
12
  tabs?: CollectionTab[];
13
13
  }
14
+ export interface OpenDataTablePopupProps {
15
+ collectionName: string;
16
+ filter?: Record<string, any>;
17
+ title?: string;
18
+ showHeader?: boolean;
19
+ showFooter?: boolean;
20
+ tabs?: CollectionTab[];
21
+ }
14
22
  export declare function showDialog(title: string, description: string): Promise<boolean>;
15
23
  export declare function openCreateDetailView(studioContext: StudioContext, props: CreateDetailViewProp): void;
16
24
  export declare function openUpdateDetailView(studioContext: StudioContext, props: UpdateDetailViewProp): Promise<void>;
17
25
  export declare function openDataTableDrawer(studioContext: StudioContext, props: OpenDataTableDrawerProps): void;
26
+ export declare function openDataTablePopup(studioContext: StudioContext, props: OpenDataTablePopupProps): void;
package/dist/actions.js CHANGED
@@ -3,6 +3,7 @@ import ConfirmationDialog from "./components/confirmationDialog/confirmationDial
3
3
  import CreateDetailView from "./components/detailView/create/createDetailView.svelte";
4
4
  import UpdateDetailView from "./components/detailView/update/updateDetailView.svelte";
5
5
  import DataTableDrawer from "./components/dataTableDrawer/dataTableDrawer.svelte";
6
+ import DataTablePopup from "./components/dataTablePopup/dataTablePopup.svelte";
6
7
  import { createStudioContextMap } from "./context";
7
8
  import { getCollectionParamsFields } from "./components/dataTable/utils";
8
9
  export function showDialog(title, description) {
@@ -80,3 +81,18 @@ export function openDataTableDrawer(studioContext, props) {
80
81
  },
81
82
  });
82
83
  }
84
+ export function openDataTablePopup(studioContext, props) {
85
+ const targetElement = document.querySelector("main");
86
+ if (!targetElement)
87
+ throw new Error("main html element doesn't exist");
88
+ const mounted = mount(DataTablePopup, {
89
+ target: targetElement,
90
+ context: createStudioContextMap(studioContext),
91
+ props: {
92
+ ...props,
93
+ onClose: async () => {
94
+ await unmount(mounted, { outro: true });
95
+ },
96
+ },
97
+ });
98
+ }
@@ -0,0 +1,67 @@
1
+ <script lang="ts">
2
+ import { X } from "lucide-svelte";
3
+ import { fade, scale } from "svelte/transition";
4
+ import { cubicOut } from "svelte/easing";
5
+ import Portal from "svelte-portal";
6
+ import Button from "../ui/button/button.svelte";
7
+ import DataTable from "../dataTable/dataTable.svelte";
8
+ import type { TableProps } from "../dataTable/table.svelte";
9
+ import type { CollectionTab } from "../../store.types";
10
+
11
+ interface Props {
12
+ collectionName: string;
13
+ filter?: Record<string, any>;
14
+ title?: string;
15
+ showHeader?: boolean;
16
+ showFooter?: boolean;
17
+ tableProps?: Partial<TableProps>;
18
+ tabs?: CollectionTab[];
19
+ onClose?: () => void;
20
+ }
21
+
22
+ let {
23
+ collectionName,
24
+ filter,
25
+ title,
26
+ showHeader = true,
27
+ showFooter = true,
28
+ tableProps,
29
+ tabs,
30
+ onClose,
31
+ }: Props = $props();
32
+ </script>
33
+
34
+ <Portal target="body">
35
+ <button
36
+ transition:fade={{ duration: 200 }}
37
+ onclick={() => onClose?.()}
38
+ class="fixed left-0 top-0 z-40 h-screen w-screen bg-black/50 cursor-default"
39
+ aria-label="background used to close the popup"
40
+ ></button>
41
+
42
+ <div
43
+ transition:scale={{ duration: 200, easing: cubicOut, start: 0.95 }}
44
+ class="fixed left-1/2 top-1/2 z-40 flex h-[85vh] w-[95vw] max-w-7xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-lg border bg-background shadow-2xl"
45
+ >
46
+ <div class="flex h-12 shrink-0 items-center justify-between gap-4 border-b px-4">
47
+ <div class="text-sm font-medium">{title ?? collectionName}</div>
48
+ <Button
49
+ variant="ghost"
50
+ size="icon"
51
+ onclick={() => onClose?.()}
52
+ class="h-8 w-8 rounded-full text-muted-foreground"
53
+ Icon={X}
54
+ />
55
+ </div>
56
+ <div class="min-h-0 flex-1 overflow-auto">
57
+ <DataTable
58
+ {collectionName}
59
+ {filter}
60
+ {showHeader}
61
+ {showFooter}
62
+ {tableProps}
63
+ {tabs}
64
+ />
65
+ </div>
66
+ </div>
67
+ </Portal>
@@ -0,0 +1,15 @@
1
+ import type { TableProps } from "../dataTable/table.svelte";
2
+ import type { CollectionTab } from "../../store.types";
3
+ interface Props {
4
+ collectionName: string;
5
+ filter?: Record<string, any>;
6
+ title?: string;
7
+ showHeader?: boolean;
8
+ showFooter?: boolean;
9
+ tableProps?: Partial<TableProps>;
10
+ tabs?: CollectionTab[];
11
+ onClose?: () => void;
12
+ }
13
+ declare const DataTablePopup: import("svelte").Component<Props, {}, "">;
14
+ type DataTablePopup = ReturnType<typeof DataTablePopup>;
15
+ export default DataTablePopup;
@@ -23,7 +23,7 @@ import * as Icons from "lucide-svelte";
23
23
  import { ContextMenu } from "bits-ui";
24
24
  import * as Tooltip from "../components/ui/tooltip";
25
25
  import * as Breadcrumb from "../components/ui/breadcrumb";
26
- import { showDialog, type OpenDataTableDrawerProps } from "../actions";
26
+ import { showDialog, type OpenDataTableDrawerProps, type OpenDataTablePopupProps } from "../actions";
27
27
  import { toast } from "svelte-sonner";
28
28
  import { Switch } from "../components/ui/switch";
29
29
  export interface Components {
@@ -67,6 +67,7 @@ export interface ExtensionUtils {
67
67
  toast: typeof toast;
68
68
  showDialog: typeof showDialog;
69
69
  openDataTableDrawer: (props: OpenDataTableDrawerProps) => void;
70
+ openDataTablePopup: (props: OpenDataTablePopupProps) => void;
70
71
  emitEvent: (eventName: string, input: any) => Promise<any>;
71
72
  components: Components;
72
73
  mediaQueries: typeof mediaQueries;
@@ -1,5 +1,5 @@
1
1
  import { toast } from "svelte-sonner";
2
- import { showDialog, openDataTableDrawer } from "../actions";
2
+ import { showDialog, openDataTableDrawer, openDataTablePopup } from "../actions";
3
3
  import { emitEvent } from "../eventSystem";
4
4
  import { Button } from "../components/ui/button";
5
5
  import { Input } from "../components/ui/input";
@@ -58,6 +58,7 @@ export function getExtensionUtils(lobb, ctx) {
58
58
  toast: toast,
59
59
  showDialog: showDialog,
60
60
  openDataTableDrawer: (props) => openDataTableDrawer({ lobb, ctx }, props),
61
+ openDataTablePopup: (props) => openDataTablePopup({ lobb, ctx }, props),
61
62
  emitEvent: (eventName, input) => emitEvent({ lobb, ctx }, eventName, input),
62
63
  components: getComponents(),
63
64
  mediaQueries: mediaQueries,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lobb-js/studio",
3
3
  "license": "UNLICENSED",
4
- "version": "0.29.1",
4
+ "version": "0.30.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -3,6 +3,7 @@ import ConfirmationDialog from "./components/confirmationDialog/confirmationDial
3
3
  import CreateDetailView from "./components/detailView/create/createDetailView.svelte";
4
4
  import UpdateDetailView from "./components/detailView/update/updateDetailView.svelte";
5
5
  import DataTableDrawer from "./components/dataTableDrawer/dataTableDrawer.svelte";
6
+ import DataTablePopup from "./components/dataTablePopup/dataTablePopup.svelte";
6
7
  import type { CreateDetailViewProp } from "./components/detailView/create/createDetailView.svelte";
7
8
  import type { UpdateDetailViewProp } from "./components/detailView/update/updateDetailView.svelte";
8
9
  import type { StudioContext } from "./context";
@@ -20,6 +21,15 @@ export interface OpenDataTableDrawerProps {
20
21
  tabs?: CollectionTab[];
21
22
  }
22
23
 
24
+ export interface OpenDataTablePopupProps {
25
+ collectionName: string;
26
+ filter?: Record<string, any>;
27
+ title?: string;
28
+ showHeader?: boolean;
29
+ showFooter?: boolean;
30
+ tabs?: CollectionTab[];
31
+ }
32
+
23
33
  export function showDialog(title: string, description: string): Promise<boolean> {
24
34
  return new Promise((resolve) => {
25
35
  const targetElement = document.querySelector("main");
@@ -99,3 +109,19 @@ export function openDataTableDrawer(studioContext: StudioContext, props: OpenDat
99
109
  },
100
110
  });
101
111
  }
112
+
113
+ export function openDataTablePopup(studioContext: StudioContext, props: OpenDataTablePopupProps) {
114
+ const targetElement = document.querySelector("main");
115
+ if (!targetElement) throw new Error("main html element doesn't exist");
116
+
117
+ const mounted = mount(DataTablePopup, {
118
+ target: targetElement,
119
+ context: createStudioContextMap(studioContext),
120
+ props: {
121
+ ...props,
122
+ onClose: async () => {
123
+ await unmount(mounted, { outro: true });
124
+ },
125
+ },
126
+ });
127
+ }
@@ -0,0 +1,67 @@
1
+ <script lang="ts">
2
+ import { X } from "lucide-svelte";
3
+ import { fade, scale } from "svelte/transition";
4
+ import { cubicOut } from "svelte/easing";
5
+ import Portal from "svelte-portal";
6
+ import Button from "../ui/button/button.svelte";
7
+ import DataTable from "../dataTable/dataTable.svelte";
8
+ import type { TableProps } from "../dataTable/table.svelte";
9
+ import type { CollectionTab } from "../../store.types";
10
+
11
+ interface Props {
12
+ collectionName: string;
13
+ filter?: Record<string, any>;
14
+ title?: string;
15
+ showHeader?: boolean;
16
+ showFooter?: boolean;
17
+ tableProps?: Partial<TableProps>;
18
+ tabs?: CollectionTab[];
19
+ onClose?: () => void;
20
+ }
21
+
22
+ let {
23
+ collectionName,
24
+ filter,
25
+ title,
26
+ showHeader = true,
27
+ showFooter = true,
28
+ tableProps,
29
+ tabs,
30
+ onClose,
31
+ }: Props = $props();
32
+ </script>
33
+
34
+ <Portal target="body">
35
+ <button
36
+ transition:fade={{ duration: 200 }}
37
+ onclick={() => onClose?.()}
38
+ class="fixed left-0 top-0 z-40 h-screen w-screen bg-black/50 cursor-default"
39
+ aria-label="background used to close the popup"
40
+ ></button>
41
+
42
+ <div
43
+ transition:scale={{ duration: 200, easing: cubicOut, start: 0.95 }}
44
+ class="fixed left-1/2 top-1/2 z-40 flex h-[85vh] w-[95vw] max-w-7xl -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-lg border bg-background shadow-2xl"
45
+ >
46
+ <div class="flex h-12 shrink-0 items-center justify-between gap-4 border-b px-4">
47
+ <div class="text-sm font-medium">{title ?? collectionName}</div>
48
+ <Button
49
+ variant="ghost"
50
+ size="icon"
51
+ onclick={() => onClose?.()}
52
+ class="h-8 w-8 rounded-full text-muted-foreground"
53
+ Icon={X}
54
+ />
55
+ </div>
56
+ <div class="min-h-0 flex-1 overflow-auto">
57
+ <DataTable
58
+ {collectionName}
59
+ {filter}
60
+ {showHeader}
61
+ {showFooter}
62
+ {tableProps}
63
+ {tabs}
64
+ />
65
+ </div>
66
+ </div>
67
+ </Portal>
@@ -23,7 +23,7 @@ import * as Icons from "lucide-svelte"
23
23
  import { ContextMenu } from "bits-ui";
24
24
  import * as Tooltip from "../components/ui/tooltip";
25
25
  import * as Breadcrumb from "../components/ui/breadcrumb";
26
- import { showDialog, type OpenDataTableDrawerProps } from "../actions";
26
+ import { showDialog, type OpenDataTableDrawerProps, type OpenDataTablePopupProps } from "../actions";
27
27
  import { toast } from "svelte-sonner";
28
28
  import type Drawer from "../components/drawer.svelte";
29
29
  import { Switch } from "../components/ui/switch";
@@ -71,6 +71,7 @@ export interface ExtensionUtils {
71
71
  toast: typeof toast;
72
72
  showDialog: typeof showDialog;
73
73
  openDataTableDrawer: (props: OpenDataTableDrawerProps) => void;
74
+ openDataTablePopup: (props: OpenDataTablePopupProps) => void;
74
75
  emitEvent: (eventName: string, input: any) => Promise<any>;
75
76
  components: Components;
76
77
  mediaQueries: typeof mediaQueries;
@@ -7,7 +7,7 @@ import type {
7
7
  import type { LobbClient } from "@lobb-js/sdk";
8
8
  import type { CTX } from "../store.types";
9
9
  import { toast } from "svelte-sonner";
10
- import { showDialog, openDataTableDrawer } from "../actions";
10
+ import { showDialog, openDataTableDrawer, openDataTablePopup } from "../actions";
11
11
  import { emitEvent } from "../eventSystem";
12
12
  import { Button } from "../components/ui/button";
13
13
  import { Input } from "../components/ui/input";
@@ -68,6 +68,7 @@ export function getExtensionUtils(lobb: LobbClient, ctx: CTX): ExtensionUtils {
68
68
  toast: toast,
69
69
  showDialog: showDialog,
70
70
  openDataTableDrawer: (props) => openDataTableDrawer({ lobb, ctx }, props),
71
+ openDataTablePopup: (props) => openDataTablePopup({ lobb, ctx }, props),
71
72
  emitEvent: (eventName, input) => emitEvent({ lobb, ctx }, eventName, input),
72
73
  components: getComponents(),
73
74
  mediaQueries: mediaQueries,