@lobb-js/studio 0.18.1 → 0.19.1
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 +14 -0
- package/dist/{components/detailView/store.svelte.js → actions.js} +64 -17
- package/dist/components/dataTable/dataTable.svelte +1 -1
- package/dist/components/dataTable/header.svelte +1 -1
- package/dist/components/dataTableDrawer/dataTableDrawer.svelte +49 -0
- package/dist/components/dataTableDrawer/dataTableDrawer.svelte.d.ts +13 -0
- package/dist/components/routes/workflows/workflows.svelte +1 -1
- package/dist/components/ui/checkbox/checkbox.svelte.d.ts +1 -1
- package/dist/components/ui/input/input.svelte.d.ts +1 -1
- package/dist/components/ui/range-calendar/range-calendar.svelte.d.ts +1 -1
- package/dist/components/ui/switch/switch.svelte.d.ts +1 -1
- package/dist/eventSystem.js +1 -1
- package/dist/extensions/extension.types.d.ts +9 -2
- package/dist/extensions/extensionUtils.js +2 -1
- package/package.json +1 -1
- package/src/lib/actions.ts +98 -0
- package/src/lib/components/dataTable/dataTable.svelte +1 -1
- package/src/lib/components/dataTable/header.svelte +1 -1
- package/src/lib/components/dataTableDrawer/dataTableDrawer.svelte +49 -0
- package/src/lib/components/routes/workflows/workflows.svelte +1 -1
- package/src/lib/eventSystem.ts +1 -1
- package/src/lib/extensions/extension.types.ts +4 -2
- package/src/lib/extensions/extensionUtils.ts +2 -1
- package/dist/components/confirmationDialog/store.svelte.d.ts +0 -1
- package/dist/components/confirmationDialog/store.svelte.js +0 -69
- package/dist/components/detailView/store.svelte.d.ts +0 -5
- package/src/lib/components/confirmationDialog/store.svelte.ts +0 -28
- package/src/lib/components/detailView/store.svelte.ts +0 -59
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CreateDetailViewProp } from "./components/detailView/create/createDetailView.svelte";
|
|
2
|
+
import type { UpdateDetailViewProp } from "./components/detailView/update/updateDetailView.svelte";
|
|
3
|
+
import type { StudioContext } from "./context";
|
|
4
|
+
export interface OpenDataTableDrawerProps {
|
|
5
|
+
collectionName: string;
|
|
6
|
+
filter?: Record<string, any>;
|
|
7
|
+
title?: string;
|
|
8
|
+
showHeader?: boolean;
|
|
9
|
+
showFooter?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function showDialog(title: string, description: string): Promise<boolean>;
|
|
12
|
+
export declare function openCreateDetailView(studioContext: StudioContext, props: CreateDetailViewProp): void;
|
|
13
|
+
export declare function openUpdateDetailView(studioContext: StudioContext, props: UpdateDetailViewProp): Promise<void>;
|
|
14
|
+
export declare function openDataTableDrawer(studioContext: StudioContext, props: OpenDataTableDrawerProps): void;
|
|
@@ -45,18 +45,46 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
import CreateDetailView from "./create/createDetailView.svelte";
|
|
49
|
-
import UpdateDetailView from "./update/updateDetailView.svelte";
|
|
50
|
-
import { getCollectionParamsFields } from "../dataTable/utils";
|
|
51
|
-
import { createStudioContextMap } from "../../context";
|
|
52
48
|
import { mount, unmount } from "svelte";
|
|
49
|
+
import ConfirmationDialog from "./components/confirmationDialog/confirmationDialog.svelte";
|
|
50
|
+
import CreateDetailView from "./components/detailView/create/createDetailView.svelte";
|
|
51
|
+
import UpdateDetailView from "./components/detailView/update/updateDetailView.svelte";
|
|
52
|
+
import DataTableDrawer from "./components/dataTableDrawer/dataTableDrawer.svelte";
|
|
53
|
+
import { createStudioContextMap } from "./context";
|
|
54
|
+
import { getCollectionParamsFields } from "./components/dataTable/utils";
|
|
55
|
+
export function showDialog(title, description) {
|
|
56
|
+
var _this = this;
|
|
57
|
+
return new Promise(function (resolve) {
|
|
58
|
+
var targetElement = document.querySelector("main");
|
|
59
|
+
if (!targetElement)
|
|
60
|
+
throw new Error("main html element doesn't exist");
|
|
61
|
+
var mounted = mount(ConfirmationDialog, {
|
|
62
|
+
target: targetElement,
|
|
63
|
+
props: {
|
|
64
|
+
title: title,
|
|
65
|
+
description: description,
|
|
66
|
+
onDecision: function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0:
|
|
70
|
+
resolve(result);
|
|
71
|
+
return [4 /*yield*/, unmount(mounted, { outro: true })];
|
|
72
|
+
case 1:
|
|
73
|
+
_a.sent();
|
|
74
|
+
return [2 /*return*/];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}); },
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
53
82
|
export function openCreateDetailView(studioContext, props) {
|
|
54
83
|
var _this = this;
|
|
55
|
-
var targetElement = document.querySelector(
|
|
56
|
-
if (!targetElement)
|
|
57
|
-
throw new Error("main html element doesn't exist
|
|
58
|
-
|
|
59
|
-
var mountedCreateDetailView = mount(CreateDetailView, {
|
|
84
|
+
var targetElement = document.querySelector("main");
|
|
85
|
+
if (!targetElement)
|
|
86
|
+
throw new Error("main html element doesn't exist");
|
|
87
|
+
var mounted = mount(CreateDetailView, {
|
|
60
88
|
target: targetElement,
|
|
61
89
|
context: createStudioContextMap(studioContext),
|
|
62
90
|
props: __assign(__assign({}, props), { onCancel: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -65,7 +93,7 @@ export function openCreateDetailView(studioContext, props) {
|
|
|
65
93
|
switch (_b.label) {
|
|
66
94
|
case 0:
|
|
67
95
|
(_a = props.onCancel) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
68
|
-
return [4 /*yield*/, unmount(
|
|
96
|
+
return [4 /*yield*/, unmount(mounted, { outro: true })];
|
|
69
97
|
case 1:
|
|
70
98
|
_b.sent();
|
|
71
99
|
return [2 /*return*/];
|
|
@@ -76,7 +104,7 @@ export function openCreateDetailView(studioContext, props) {
|
|
|
76
104
|
}
|
|
77
105
|
export function openUpdateDetailView(studioContext, props) {
|
|
78
106
|
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var lobb, ctx, params, response, result, entry, targetElement,
|
|
107
|
+
var lobb, ctx, params, response, result, entry, targetElement, mounted;
|
|
80
108
|
var _this = this;
|
|
81
109
|
return __generator(this, function (_a) {
|
|
82
110
|
switch (_a.label) {
|
|
@@ -94,11 +122,10 @@ export function openUpdateDetailView(studioContext, props) {
|
|
|
94
122
|
case 2:
|
|
95
123
|
result = _a.sent();
|
|
96
124
|
entry = result.data[0];
|
|
97
|
-
targetElement = document.querySelector(
|
|
98
|
-
if (!targetElement)
|
|
99
|
-
throw new Error("main html element doesn't exist
|
|
100
|
-
|
|
101
|
-
mountedUpdateDetailView = mount(UpdateDetailView, {
|
|
125
|
+
targetElement = document.querySelector("main");
|
|
126
|
+
if (!targetElement)
|
|
127
|
+
throw new Error("main html element doesn't exist");
|
|
128
|
+
mounted = mount(UpdateDetailView, {
|
|
102
129
|
target: targetElement,
|
|
103
130
|
context: createStudioContextMap(studioContext),
|
|
104
131
|
props: __assign(__assign({}, props), { onCancel: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -107,7 +134,7 @@ export function openUpdateDetailView(studioContext, props) {
|
|
|
107
134
|
switch (_b.label) {
|
|
108
135
|
case 0:
|
|
109
136
|
(_a = props.onCancel) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
110
|
-
return [4 /*yield*/, unmount(
|
|
137
|
+
return [4 /*yield*/, unmount(mounted, { outro: true })];
|
|
111
138
|
case 1:
|
|
112
139
|
_b.sent();
|
|
113
140
|
return [2 /*return*/];
|
|
@@ -120,3 +147,23 @@ export function openUpdateDetailView(studioContext, props) {
|
|
|
120
147
|
});
|
|
121
148
|
});
|
|
122
149
|
}
|
|
150
|
+
export function openDataTableDrawer(studioContext, props) {
|
|
151
|
+
var _this = this;
|
|
152
|
+
var targetElement = document.querySelector("main");
|
|
153
|
+
if (!targetElement)
|
|
154
|
+
throw new Error("main html element doesn't exist");
|
|
155
|
+
var mounted = mount(DataTableDrawer, {
|
|
156
|
+
target: targetElement,
|
|
157
|
+
context: createStudioContextMap(studioContext),
|
|
158
|
+
props: __assign(__assign({}, props), { onClose: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
switch (_a.label) {
|
|
161
|
+
case 0: return [4 /*yield*/, unmount(mounted, { outro: true })];
|
|
162
|
+
case 1:
|
|
163
|
+
_a.sent();
|
|
164
|
+
return [2 /*return*/];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}); } }),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import FieldCell from "./fieldCell.svelte";
|
|
12
12
|
import Skeleton from "../ui/skeleton/skeleton.svelte";
|
|
13
13
|
import Button from "../ui/button/button.svelte";
|
|
14
|
-
import { showDialog } from "
|
|
14
|
+
import { showDialog } from "../../actions";
|
|
15
15
|
import UpdateDetailViewButton from "../detailView/update/updateDetailViewButton.svelte";
|
|
16
16
|
import { emitEvent } from "../../eventSystem";
|
|
17
17
|
import type { Snippet } from "svelte";
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import SortButton from "./sortButton.svelte";
|
|
10
10
|
import Button from "../ui/button/button.svelte";
|
|
11
11
|
import ImportButton from "../importButton.svelte";
|
|
12
|
-
import { showDialog } from "
|
|
12
|
+
import { showDialog } from "../../actions";
|
|
13
13
|
import CreateDetailViewButton from "../detailView/create/createDetailViewButton.svelte";
|
|
14
14
|
import ExtensionsComponents from "../extensionsComponents.svelte";
|
|
15
15
|
import { getExtensionUtils } from "../../extensions/extensionUtils";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ArrowLeft } from "lucide-svelte";
|
|
3
|
+
import Button from "../ui/button/button.svelte";
|
|
4
|
+
import DataTable from "../dataTable/dataTable.svelte";
|
|
5
|
+
import Drawer from "../drawer.svelte";
|
|
6
|
+
import type { TableProps } from "../dataTable/table.svelte";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
collectionName: string;
|
|
10
|
+
filter?: Record<string, any>;
|
|
11
|
+
title?: string;
|
|
12
|
+
showHeader?: boolean;
|
|
13
|
+
showFooter?: boolean;
|
|
14
|
+
tableProps?: Partial<TableProps>;
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
collectionName,
|
|
20
|
+
filter,
|
|
21
|
+
title,
|
|
22
|
+
showHeader = true,
|
|
23
|
+
showFooter = true,
|
|
24
|
+
tableProps,
|
|
25
|
+
onClose,
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<Drawer onHide={async () => onClose?.()}>
|
|
30
|
+
<div class="flex h-12 shrink-0 items-center gap-4 border-b px-4">
|
|
31
|
+
<Button
|
|
32
|
+
variant="outline"
|
|
33
|
+
onclick={() => onClose?.()}
|
|
34
|
+
class="h-8 w-8 rounded-full text-xs font-normal"
|
|
35
|
+
Icon={ArrowLeft}
|
|
36
|
+
/>
|
|
37
|
+
<div class="text-sm font-medium">{title ?? collectionName}</div>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="min-h-0 flex-1 overflow-auto">
|
|
40
|
+
<DataTable
|
|
41
|
+
{collectionName}
|
|
42
|
+
{filter}
|
|
43
|
+
{showHeader}
|
|
44
|
+
{showFooter}
|
|
45
|
+
{tableProps}
|
|
46
|
+
unifiedBgColor="bg-background"
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
</Drawer>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TableProps } from "../dataTable/table.svelte";
|
|
2
|
+
interface Props {
|
|
3
|
+
collectionName: string;
|
|
4
|
+
filter?: Record<string, any>;
|
|
5
|
+
title?: string;
|
|
6
|
+
showHeader?: boolean;
|
|
7
|
+
showFooter?: boolean;
|
|
8
|
+
tableProps?: Partial<TableProps>;
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
}
|
|
11
|
+
declare const DataTableDrawer: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type DataTableDrawer = ReturnType<typeof DataTableDrawer>;
|
|
13
|
+
export default DataTableDrawer;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { location } from "@wjfe/n-savant";
|
|
12
12
|
import { CircleSlash2, Plus, Trash2 } from "lucide-svelte";
|
|
13
13
|
import { onMount } from "svelte";
|
|
14
|
-
import { showDialog } from "../../../
|
|
14
|
+
import { showDialog } from "../../../actions";
|
|
15
15
|
import SidebarTrigger from "../../../components/sidebar/sidebarTrigger.svelte";
|
|
16
16
|
|
|
17
17
|
let { workflowName } = $props();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Checkbox as CheckboxPrimitive } from "bits-ui";
|
|
2
|
-
declare const Checkbox: import("svelte").Component<Omit<Omit<CheckboxPrimitive.RootProps, "child">, "children">, {}, "
|
|
2
|
+
declare const Checkbox: import("svelte").Component<Omit<Omit<CheckboxPrimitive.RootProps, "child">, "children">, {}, "ref" | "checked" | "indeterminate">;
|
|
3
3
|
type Checkbox = ReturnType<typeof Checkbox>;
|
|
4
4
|
export default Checkbox;
|
|
@@ -8,6 +8,6 @@ type Props = WithElementRef<Omit<HTMLInputAttributes, "type"> & ({
|
|
|
8
8
|
type?: InputType;
|
|
9
9
|
files?: undefined;
|
|
10
10
|
})>;
|
|
11
|
-
declare const Input: import("svelte").Component<Props, {}, "value" | "
|
|
11
|
+
declare const Input: import("svelte").Component<Props, {}, "value" | "ref" | "files">;
|
|
12
12
|
type Input = ReturnType<typeof Input>;
|
|
13
13
|
export default Input;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
|
|
2
2
|
import * as RangeCalendar from "./index.js";
|
|
3
|
-
declare const RangeCalendar: import("svelte").Component<Omit<Omit<RangeCalendarPrimitive.RootProps, "child">, "children">, {}, "value" | "
|
|
3
|
+
declare const RangeCalendar: import("svelte").Component<Omit<Omit<RangeCalendarPrimitive.RootProps, "child">, "children">, {}, "value" | "ref" | "placeholder">;
|
|
4
4
|
type RangeCalendar = ReturnType<typeof RangeCalendar>;
|
|
5
5
|
export default RangeCalendar;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Switch as SwitchPrimitive } from "bits-ui";
|
|
2
|
-
declare const Switch: import("svelte").Component<Omit<Omit<SwitchPrimitive.RootProps, "child">, "children">, {}, "
|
|
2
|
+
declare const Switch: import("svelte").Component<Omit<Omit<SwitchPrimitive.RootProps, "child">, "children">, {}, "ref" | "checked">;
|
|
3
3
|
type Switch = ReturnType<typeof Switch>;
|
|
4
4
|
export default Switch;
|
package/dist/eventSystem.js
CHANGED
|
@@ -35,7 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import { toast } from "svelte-sonner";
|
|
38
|
-
import { openCreateDetailView, openUpdateDetailView } from "./
|
|
38
|
+
import { openCreateDetailView, openUpdateDetailView } from "./actions";
|
|
39
39
|
export function emitEvent(studioContext, eventName, input) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function () {
|
|
41
41
|
var ctx, workflows, index, workflow, localOutput, _a, _b, _c, error_1;
|
|
@@ -22,7 +22,7 @@ import * as Icons from "lucide-svelte";
|
|
|
22
22
|
import { ContextMenu } from "bits-ui";
|
|
23
23
|
import * as Tooltip from "../components/ui/tooltip";
|
|
24
24
|
import * as Breadcrumb from "../components/ui/breadcrumb";
|
|
25
|
-
import { showDialog } from "../
|
|
25
|
+
import { showDialog } from "../actions";
|
|
26
26
|
import { toast } from "svelte-sonner";
|
|
27
27
|
import { Switch } from "../components/ui/switch";
|
|
28
28
|
export interface Components {
|
|
@@ -53,6 +53,13 @@ export interface ExtensionUtils {
|
|
|
53
53
|
location: Location;
|
|
54
54
|
toast: typeof toast;
|
|
55
55
|
showDialog: typeof showDialog;
|
|
56
|
+
openDataTableDrawer: (props: {
|
|
57
|
+
collectionName: string;
|
|
58
|
+
filter?: Record<string, any>;
|
|
59
|
+
title?: string;
|
|
60
|
+
showHeader?: boolean;
|
|
61
|
+
showFooter?: boolean;
|
|
62
|
+
}) => void;
|
|
56
63
|
components: Components;
|
|
57
64
|
mediaQueries: typeof mediaQueries;
|
|
58
65
|
intlDate: typeof intlDate;
|
|
@@ -73,7 +80,7 @@ export interface ExtensionProps {
|
|
|
73
80
|
utils: ExtensionUtils;
|
|
74
81
|
[key: string]: any;
|
|
75
82
|
}
|
|
76
|
-
export type ExtensionComponentKey = `pages.${string}` | "studio.listView" | `dvFields.topRight.${string}.${string}` | `detailView.update.subRecords.${string}` | `detailView.create.subRecords.${string}` | `detailView.fields.topRight.${string}.${string}` | `detailView.fields.foreignKey.${string}` | `listView.entry.children.${string}` | `listView.entry.actions` | `listView.header.actions
|
|
83
|
+
export type ExtensionComponentKey = `pages.${string}` | "studio.listView" | `dvFields.topRight.${string}.${string}` | `detailView.update.subRecords.${string}` | `detailView.create.subRecords.${string}` | `detailView.fields.topRight.${string}.${string}` | `detailView.fields.foreignKey.${string}` | `listView.entry.children.${string}` | `listView.entry.actions` | `listView.header.actions` | (string & {});
|
|
77
84
|
export type ExtensionComponent = any | {
|
|
78
85
|
component: any;
|
|
79
86
|
when: (props: Record<string, any>) => boolean;
|
|
@@ -44,7 +44,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
44
44
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
45
|
};
|
|
46
46
|
import { toast } from "svelte-sonner";
|
|
47
|
-
import { showDialog } from "../
|
|
47
|
+
import { showDialog, openDataTableDrawer } from "../actions";
|
|
48
48
|
import { Button } from "../components/ui/button";
|
|
49
49
|
import { Input } from "../components/ui/input";
|
|
50
50
|
import { Separator } from "../components/ui/separator";
|
|
@@ -99,6 +99,7 @@ export function getExtensionUtils(lobb, ctx) {
|
|
|
99
99
|
location: location,
|
|
100
100
|
toast: toast,
|
|
101
101
|
showDialog: showDialog,
|
|
102
|
+
openDataTableDrawer: function (props) { return openDataTableDrawer({ lobb: lobb, ctx: ctx }, props); },
|
|
102
103
|
components: getComponents(),
|
|
103
104
|
mediaQueries: mediaQueries,
|
|
104
105
|
intlDate: intlDate,
|
package/package.json
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { mount, unmount } from "svelte";
|
|
2
|
+
import ConfirmationDialog from "./components/confirmationDialog/confirmationDialog.svelte";
|
|
3
|
+
import CreateDetailView from "./components/detailView/create/createDetailView.svelte";
|
|
4
|
+
import UpdateDetailView from "./components/detailView/update/updateDetailView.svelte";
|
|
5
|
+
import DataTableDrawer from "./components/dataTableDrawer/dataTableDrawer.svelte";
|
|
6
|
+
import type { CreateDetailViewProp } from "./components/detailView/create/createDetailView.svelte";
|
|
7
|
+
import type { UpdateDetailViewProp } from "./components/detailView/update/updateDetailView.svelte";
|
|
8
|
+
import type { StudioContext } from "./context";
|
|
9
|
+
import { createStudioContextMap } from "./context";
|
|
10
|
+
import { getCollectionParamsFields } from "./components/dataTable/utils";
|
|
11
|
+
|
|
12
|
+
export interface OpenDataTableDrawerProps {
|
|
13
|
+
collectionName: string;
|
|
14
|
+
filter?: Record<string, any>;
|
|
15
|
+
title?: string;
|
|
16
|
+
showHeader?: boolean;
|
|
17
|
+
showFooter?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function showDialog(title: string, description: string): Promise<boolean> {
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
const targetElement = document.querySelector("main");
|
|
23
|
+
if (!targetElement) throw new Error("main html element doesn't exist");
|
|
24
|
+
|
|
25
|
+
const mounted = mount(ConfirmationDialog, {
|
|
26
|
+
target: targetElement,
|
|
27
|
+
props: {
|
|
28
|
+
title,
|
|
29
|
+
description,
|
|
30
|
+
onDecision: async (result: boolean) => {
|
|
31
|
+
resolve(result);
|
|
32
|
+
await unmount(mounted, { outro: true });
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function openCreateDetailView(studioContext: StudioContext, props: CreateDetailViewProp) {
|
|
40
|
+
const targetElement = document.querySelector("main");
|
|
41
|
+
if (!targetElement) throw new Error("main html element doesn't exist");
|
|
42
|
+
|
|
43
|
+
const mounted = mount(CreateDetailView, {
|
|
44
|
+
target: targetElement,
|
|
45
|
+
context: createStudioContextMap(studioContext),
|
|
46
|
+
props: {
|
|
47
|
+
...props,
|
|
48
|
+
onCancel: async () => {
|
|
49
|
+
props.onCancel?.();
|
|
50
|
+
await unmount(mounted, { outro: true });
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function openUpdateDetailView(studioContext: StudioContext, props: UpdateDetailViewProp) {
|
|
57
|
+
const { lobb, ctx } = studioContext;
|
|
58
|
+
const params = {
|
|
59
|
+
fields: getCollectionParamsFields(ctx, props.collectionName, true),
|
|
60
|
+
filter: { id: props.recordId },
|
|
61
|
+
limit: 1,
|
|
62
|
+
};
|
|
63
|
+
const response = await lobb.findAll(props.collectionName, params);
|
|
64
|
+
const result = await response.json();
|
|
65
|
+
const entry = result.data[0];
|
|
66
|
+
|
|
67
|
+
const targetElement = document.querySelector("main");
|
|
68
|
+
if (!targetElement) throw new Error("main html element doesn't exist");
|
|
69
|
+
|
|
70
|
+
const mounted = mount(UpdateDetailView, {
|
|
71
|
+
target: targetElement,
|
|
72
|
+
context: createStudioContextMap(studioContext),
|
|
73
|
+
props: {
|
|
74
|
+
...props,
|
|
75
|
+
onCancel: async () => {
|
|
76
|
+
props.onCancel?.();
|
|
77
|
+
await unmount(mounted, { outro: true });
|
|
78
|
+
},
|
|
79
|
+
values: entry,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function openDataTableDrawer(studioContext: StudioContext, props: OpenDataTableDrawerProps) {
|
|
85
|
+
const targetElement = document.querySelector("main");
|
|
86
|
+
if (!targetElement) throw new Error("main html element doesn't exist");
|
|
87
|
+
|
|
88
|
+
const mounted = mount(DataTableDrawer, {
|
|
89
|
+
target: targetElement,
|
|
90
|
+
context: createStudioContextMap(studioContext),
|
|
91
|
+
props: {
|
|
92
|
+
...props,
|
|
93
|
+
onClose: async () => {
|
|
94
|
+
await unmount(mounted, { outro: true });
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import FieldCell from "./fieldCell.svelte";
|
|
12
12
|
import Skeleton from "../ui/skeleton/skeleton.svelte";
|
|
13
13
|
import Button from "../ui/button/button.svelte";
|
|
14
|
-
import { showDialog } from "
|
|
14
|
+
import { showDialog } from "../../actions";
|
|
15
15
|
import UpdateDetailViewButton from "../detailView/update/updateDetailViewButton.svelte";
|
|
16
16
|
import { emitEvent } from "../../eventSystem";
|
|
17
17
|
import type { Snippet } from "svelte";
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import SortButton from "./sortButton.svelte";
|
|
10
10
|
import Button from "../ui/button/button.svelte";
|
|
11
11
|
import ImportButton from "../importButton.svelte";
|
|
12
|
-
import { showDialog } from "
|
|
12
|
+
import { showDialog } from "../../actions";
|
|
13
13
|
import CreateDetailViewButton from "../detailView/create/createDetailViewButton.svelte";
|
|
14
14
|
import ExtensionsComponents from "../extensionsComponents.svelte";
|
|
15
15
|
import { getExtensionUtils } from "../../extensions/extensionUtils";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ArrowLeft } from "lucide-svelte";
|
|
3
|
+
import Button from "../ui/button/button.svelte";
|
|
4
|
+
import DataTable from "../dataTable/dataTable.svelte";
|
|
5
|
+
import Drawer from "../drawer.svelte";
|
|
6
|
+
import type { TableProps } from "../dataTable/table.svelte";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
collectionName: string;
|
|
10
|
+
filter?: Record<string, any>;
|
|
11
|
+
title?: string;
|
|
12
|
+
showHeader?: boolean;
|
|
13
|
+
showFooter?: boolean;
|
|
14
|
+
tableProps?: Partial<TableProps>;
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
collectionName,
|
|
20
|
+
filter,
|
|
21
|
+
title,
|
|
22
|
+
showHeader = true,
|
|
23
|
+
showFooter = true,
|
|
24
|
+
tableProps,
|
|
25
|
+
onClose,
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<Drawer onHide={async () => onClose?.()}>
|
|
30
|
+
<div class="flex h-12 shrink-0 items-center gap-4 border-b px-4">
|
|
31
|
+
<Button
|
|
32
|
+
variant="outline"
|
|
33
|
+
onclick={() => onClose?.()}
|
|
34
|
+
class="h-8 w-8 rounded-full text-xs font-normal"
|
|
35
|
+
Icon={ArrowLeft}
|
|
36
|
+
/>
|
|
37
|
+
<div class="text-sm font-medium">{title ?? collectionName}</div>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="min-h-0 flex-1 overflow-auto">
|
|
40
|
+
<DataTable
|
|
41
|
+
{collectionName}
|
|
42
|
+
{filter}
|
|
43
|
+
{showHeader}
|
|
44
|
+
{showFooter}
|
|
45
|
+
{tableProps}
|
|
46
|
+
unifiedBgColor="bg-background"
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
</Drawer>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { location } from "@wjfe/n-savant";
|
|
12
12
|
import { CircleSlash2, Plus, Trash2 } from "lucide-svelte";
|
|
13
13
|
import { onMount } from "svelte";
|
|
14
|
-
import { showDialog } from "../../../
|
|
14
|
+
import { showDialog } from "../../../actions";
|
|
15
15
|
import SidebarTrigger from "../../../components/sidebar/sidebarTrigger.svelte";
|
|
16
16
|
|
|
17
17
|
let { workflowName } = $props();
|
package/src/lib/eventSystem.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toast } from "svelte-sonner";
|
|
2
2
|
import type { StudioContext } from "./context";
|
|
3
|
-
import { openCreateDetailView, openUpdateDetailView } from "./
|
|
3
|
+
import { openCreateDetailView, openUpdateDetailView } from "./actions";
|
|
4
4
|
import type { UpdateDetailViewProp } from "./components/detailView/update/updateDetailView.svelte";
|
|
5
5
|
|
|
6
6
|
export async function emitEvent(studioContext: StudioContext, eventName: string, input: Record<string, any>) {
|
|
@@ -22,7 +22,7 @@ import * as Icons from "lucide-svelte"
|
|
|
22
22
|
import { ContextMenu } from "bits-ui";
|
|
23
23
|
import * as Tooltip from "../components/ui/tooltip";
|
|
24
24
|
import * as Breadcrumb from "../components/ui/breadcrumb";
|
|
25
|
-
import { showDialog } from "../
|
|
25
|
+
import { showDialog } from "../actions";
|
|
26
26
|
import { toast } from "svelte-sonner";
|
|
27
27
|
import type Drawer from "../components/drawer.svelte";
|
|
28
28
|
import { Switch } from "../components/ui/switch";
|
|
@@ -57,6 +57,7 @@ export interface ExtensionUtils {
|
|
|
57
57
|
location: Location;
|
|
58
58
|
toast: typeof toast;
|
|
59
59
|
showDialog: typeof showDialog;
|
|
60
|
+
openDataTableDrawer: (props: { collectionName: string; filter?: Record<string, any>; title?: string; showHeader?: boolean; showFooter?: boolean }) => void;
|
|
60
61
|
components: Components;
|
|
61
62
|
mediaQueries: typeof mediaQueries;
|
|
62
63
|
intlDate: typeof intlDate;
|
|
@@ -94,7 +95,8 @@ export type ExtensionComponentKey =
|
|
|
94
95
|
| `detailView.fields.foreignKey.${string}`
|
|
95
96
|
| `listView.entry.children.${string}`
|
|
96
97
|
| `listView.entry.actions`
|
|
97
|
-
| `listView.header.actions
|
|
98
|
+
| `listView.header.actions`
|
|
99
|
+
| (string & {});
|
|
98
100
|
|
|
99
101
|
export type ExtensionComponent =
|
|
100
102
|
| any
|
|
@@ -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 } from "../
|
|
10
|
+
import { showDialog, openDataTableDrawer } from "../actions";
|
|
11
11
|
import { Button } from "../components/ui/button";
|
|
12
12
|
import { Input } from "../components/ui/input";
|
|
13
13
|
import { Separator } from "../components/ui/separator";
|
|
@@ -64,6 +64,7 @@ export function getExtensionUtils(lobb: LobbClient, ctx: CTX): ExtensionUtils {
|
|
|
64
64
|
location: location,
|
|
65
65
|
toast: toast,
|
|
66
66
|
showDialog: showDialog,
|
|
67
|
+
openDataTableDrawer: (props) => openDataTableDrawer({ lobb, ctx }, props),
|
|
67
68
|
components: getComponents(),
|
|
68
69
|
mediaQueries: mediaQueries,
|
|
69
70
|
intlDate: intlDate,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function showDialog(title: string, description: string): Promise<boolean>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { mount, unmount } from "svelte";
|
|
38
|
-
import ConfirmationDialog from "./confirmationDialog.svelte";
|
|
39
|
-
export function showDialog(title, description) {
|
|
40
|
-
var _this = this;
|
|
41
|
-
return new Promise(function (resolve) {
|
|
42
|
-
var targetElement = document.querySelector('main');
|
|
43
|
-
if (!targetElement) {
|
|
44
|
-
throw new Error("main html element doesn't exist for some reason");
|
|
45
|
-
}
|
|
46
|
-
var mountedElement = mount(ConfirmationDialog, {
|
|
47
|
-
target: targetElement,
|
|
48
|
-
props: {
|
|
49
|
-
title: title,
|
|
50
|
-
description: description,
|
|
51
|
-
onDecision: function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
52
|
-
return __generator(this, function (_a) {
|
|
53
|
-
switch (_a.label) {
|
|
54
|
-
case 0:
|
|
55
|
-
resolve(result);
|
|
56
|
-
return [4 /*yield*/, unmount(mountedElement, {
|
|
57
|
-
outro: true
|
|
58
|
-
})];
|
|
59
|
-
case 1:
|
|
60
|
-
_a.sent();
|
|
61
|
-
return [2 /*return*/];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}); }
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
console.log("the dialog is mounted man");
|
|
68
|
-
});
|
|
69
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CreateDetailViewProp } from "./create/createDetailView.svelte";
|
|
2
|
-
import type { UpdateDetailViewProp } from "./update/updateDetailView.svelte";
|
|
3
|
-
import type { StudioContext } from "../../context";
|
|
4
|
-
export declare function openCreateDetailView(studioContext: StudioContext, props: CreateDetailViewProp): void;
|
|
5
|
-
export declare function openUpdateDetailView(studioContext: StudioContext, props: UpdateDetailViewProp): Promise<void>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { mount, unmount } from "svelte";
|
|
2
|
-
import ConfirmationDialog from "./confirmationDialog.svelte";
|
|
3
|
-
|
|
4
|
-
export function showDialog(title: string, description: string): Promise<boolean> {
|
|
5
|
-
return new Promise((resolve) => {
|
|
6
|
-
const targetElement = document.querySelector('main');
|
|
7
|
-
|
|
8
|
-
if (!targetElement) {
|
|
9
|
-
throw new Error("main html element doesn't exist for some reason");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const mountedElement = mount(ConfirmationDialog, {
|
|
13
|
-
target: targetElement,
|
|
14
|
-
props: {
|
|
15
|
-
title,
|
|
16
|
-
description,
|
|
17
|
-
onDecision: async (result: boolean) => {
|
|
18
|
-
resolve(result);
|
|
19
|
-
await unmount(mountedElement, {
|
|
20
|
-
outro: true
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
console.log("the dialog is mounted man")
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { CreateDetailViewProp } from "./create/createDetailView.svelte";
|
|
2
|
-
import type { UpdateDetailViewProp } from "./update/updateDetailView.svelte";
|
|
3
|
-
import CreateDetailView from "./create/createDetailView.svelte";
|
|
4
|
-
import UpdateDetailView from "./update/updateDetailView.svelte";
|
|
5
|
-
import type { StudioContext } from "../../context";
|
|
6
|
-
import { getCollectionParamsFields } from "../dataTable/utils";
|
|
7
|
-
import { createStudioContextMap } from "../../context";
|
|
8
|
-
import { mount, unmount } from "svelte";
|
|
9
|
-
|
|
10
|
-
export function openCreateDetailView(studioContext: StudioContext, props: CreateDetailViewProp) {
|
|
11
|
-
const targetElement = document.querySelector('main');
|
|
12
|
-
|
|
13
|
-
if (!targetElement) {
|
|
14
|
-
throw new Error("main html element doesn't exist for some reason")
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const mountedCreateDetailView = mount(CreateDetailView, {
|
|
18
|
-
target: targetElement,
|
|
19
|
-
context: createStudioContextMap(studioContext),
|
|
20
|
-
props: {
|
|
21
|
-
...props,
|
|
22
|
-
onCancel: async () => {
|
|
23
|
-
props.onCancel?.()
|
|
24
|
-
await unmount(mountedCreateDetailView, { outro: true });
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function openUpdateDetailView(studioContext: StudioContext, props: UpdateDetailViewProp) {
|
|
31
|
-
const { lobb, ctx } = studioContext;
|
|
32
|
-
const params = {
|
|
33
|
-
fields: getCollectionParamsFields(ctx, props.collectionName, true),
|
|
34
|
-
filter: { id: props.recordId },
|
|
35
|
-
limit: 1,
|
|
36
|
-
};
|
|
37
|
-
const response = await lobb.findAll(props.collectionName, params);
|
|
38
|
-
const result = await response.json();
|
|
39
|
-
const entry = result.data[0];
|
|
40
|
-
|
|
41
|
-
const targetElement = document.querySelector('main');
|
|
42
|
-
|
|
43
|
-
if (!targetElement) {
|
|
44
|
-
throw new Error("main html element doesn't exist for some reason")
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const mountedUpdateDetailView = mount(UpdateDetailView, {
|
|
48
|
-
target: targetElement,
|
|
49
|
-
context: createStudioContextMap(studioContext),
|
|
50
|
-
props: {
|
|
51
|
-
...props,
|
|
52
|
-
onCancel: async () => {
|
|
53
|
-
props.onCancel?.()
|
|
54
|
-
await unmount(mountedUpdateDetailView, { outro: true });
|
|
55
|
-
},
|
|
56
|
-
values: entry,
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
}
|