@lobb-js/studio 0.28.3 → 0.28.4
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.js +50 -137
- package/dist/components/dataTable/footer.svelte.d.ts +1 -1
- package/dist/components/dataTable/header.svelte.d.ts +1 -1
- package/dist/components/dataTable/utils.js +25 -29
- package/dist/components/detailView/utils.js +19 -21
- package/dist/components/landing.svelte.d.ts +1 -1
- package/dist/components/routes/data_model/utils.js +19 -23
- package/dist/components/ui/accordion/index.d.ts +1 -1
- package/dist/components/ui/accordion/index.js +1 -1
- package/dist/components/ui/alert-dialog/index.js +3 -3
- package/dist/components/ui/command/command-dialog.svelte.d.ts +1 -1
- package/dist/components/ui/command/command-input.svelte.d.ts +1 -1
- package/dist/components/ui/command/command.svelte.d.ts +1 -1
- package/dist/components/ui/command/index.js +1 -1
- package/dist/components/ui/dialog/index.js +4 -4
- package/dist/components/ui/input/input.svelte.d.ts +1 -1
- package/dist/components/ui/popover/index.js +3 -3
- package/dist/components/ui/range-calendar/range-calendar-day.svelte.d.ts +1 -1
- package/dist/components/ui/range-calendar/range-calendar.svelte.d.ts +1 -1
- package/dist/components/ui/select/index.d.ts +1 -1
- package/dist/components/ui/select/index.js +2 -2
- package/dist/components/ui/textarea/textarea.svelte.d.ts +1 -1
- package/dist/components/ui/tooltip/index.js +3 -3
- package/dist/context.js +1 -1
- package/dist/eventSystem.js +24 -84
- package/dist/extensions/extension.types.js +9 -1
- package/dist/extensions/extensionUtils.js +42 -112
- package/dist/relations.d.ts +1 -1
- package/dist/relations.js +9 -10
- package/dist/store.svelte.d.ts +2 -1
- package/dist/store.svelte.js +7 -53
- package/dist/utils.js +8 -13
- package/package.json +8 -5
- package/src/app.d.ts +19 -0
- package/src/app.html +13 -0
- package/src/routes/+page.svelte +6 -0
- package/src/App.svelte +0 -5
- package/src/main.ts +0 -18
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Tooltip as TooltipPrimitive } from "bits-ui";
|
|
2
2
|
import Content from "./tooltip-content.svelte";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const Root = TooltipPrimitive.Root;
|
|
4
|
+
const Trigger = TooltipPrimitive.Trigger;
|
|
5
|
+
const Provider = TooltipPrimitive.Provider;
|
|
6
6
|
export { Root, Trigger, Content, Provider,
|
|
7
7
|
//
|
|
8
8
|
Root as Tooltip, Content as TooltipContent, Trigger as TooltipTrigger, Provider as TooltipProvider, };
|
package/dist/context.js
CHANGED
package/dist/eventSystem.js
CHANGED
|
@@ -1,89 +1,29 @@
|
|
|
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
1
|
import { toast } from "svelte-sonner";
|
|
38
2
|
import { openCreateDetailView, openUpdateDetailView } from "./actions";
|
|
39
|
-
export function emitEvent(studioContext, eventName, input) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return
|
|
43
|
-
switch (_d.label) {
|
|
44
|
-
case 0:
|
|
45
|
-
ctx = studioContext.ctx;
|
|
46
|
-
workflows = ctx.meta.studio_workflows.filter(function (workflow) {
|
|
47
|
-
return eventName.startsWith(workflow.eventName);
|
|
48
|
-
});
|
|
49
|
-
index = 0;
|
|
50
|
-
_d.label = 1;
|
|
51
|
-
case 1:
|
|
52
|
-
if (!(index < workflows.length)) return [3 /*break*/, 7];
|
|
53
|
-
workflow = workflows[index];
|
|
54
|
-
_d.label = 2;
|
|
55
|
-
case 2:
|
|
56
|
-
_d.trys.push([2, 5, , 6]);
|
|
57
|
-
_b = (_a = workflow).handler;
|
|
58
|
-
_c = [input];
|
|
59
|
-
return [4 /*yield*/, getEventContext(studioContext)];
|
|
60
|
-
case 3: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
61
|
-
case 4:
|
|
62
|
-
localOutput = _d.sent();
|
|
63
|
-
if (localOutput) {
|
|
64
|
-
input = localOutput;
|
|
65
|
-
}
|
|
66
|
-
return [3 /*break*/, 6];
|
|
67
|
-
case 5:
|
|
68
|
-
error_1 = _d.sent();
|
|
69
|
-
toast.error(error_1.message);
|
|
70
|
-
throw error_1;
|
|
71
|
-
case 6:
|
|
72
|
-
index++;
|
|
73
|
-
return [3 /*break*/, 1];
|
|
74
|
-
case 7: return [2 /*return*/, input];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
3
|
+
export async function emitEvent(studioContext, eventName, input) {
|
|
4
|
+
const { ctx } = studioContext;
|
|
5
|
+
const workflows = ctx.meta.studio_workflows.filter((workflow) => {
|
|
6
|
+
return eventName.startsWith(workflow.eventName);
|
|
77
7
|
});
|
|
8
|
+
for (let index = 0; index < workflows.length; index++) {
|
|
9
|
+
const workflow = workflows[index];
|
|
10
|
+
try {
|
|
11
|
+
const localOutput = await workflow.handler(input, await getEventContext(studioContext));
|
|
12
|
+
if (localOutput) {
|
|
13
|
+
input = localOutput;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
toast.error(error.message);
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return input;
|
|
78
22
|
}
|
|
79
|
-
function getEventContext(studioContext) {
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
openUpdateDetailView: function (props) { return openUpdateDetailView(studioContext, props); },
|
|
86
|
-
}];
|
|
87
|
-
});
|
|
88
|
-
});
|
|
23
|
+
async function getEventContext(studioContext) {
|
|
24
|
+
return {
|
|
25
|
+
toast,
|
|
26
|
+
openCreateDetailView: (props) => openCreateDetailView(studioContext, props),
|
|
27
|
+
openUpdateDetailView: (props) => openUpdateDetailView(studioContext, props),
|
|
28
|
+
};
|
|
89
29
|
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Popover from "../components/ui/popover";
|
|
2
|
+
import * as intlDate from "@internationalized/date";
|
|
3
|
+
import * as Icons from "lucide-svelte";
|
|
4
|
+
import { ContextMenu } from "bits-ui";
|
|
5
|
+
import * as Tooltip from "../components/ui/tooltip";
|
|
6
|
+
import * as Breadcrumb from "../components/ui/breadcrumb";
|
|
7
|
+
import { showDialog } from "../actions";
|
|
8
|
+
import { toast } from "svelte-sonner";
|
|
9
|
+
import { Switch } from "../components/ui/switch";
|
|
@@ -1,48 +1,3 @@
|
|
|
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
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
-
if (ar || !(i in from)) {
|
|
40
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
-
ar[i] = from[i];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
-
};
|
|
46
1
|
import { toast } from "svelte-sonner";
|
|
47
2
|
import { showDialog, openDataTableDrawer } from "../actions";
|
|
48
3
|
import { emitEvent } from "../eventSystem";
|
|
@@ -100,39 +55,31 @@ export function getExtensionUtils(lobb, ctx) {
|
|
|
100
55
|
location: location,
|
|
101
56
|
toast: toast,
|
|
102
57
|
showDialog: showDialog,
|
|
103
|
-
openDataTableDrawer:
|
|
104
|
-
emitEvent:
|
|
58
|
+
openDataTableDrawer: (props) => openDataTableDrawer({ lobb, ctx }, props),
|
|
59
|
+
emitEvent: (eventName, input) => emitEvent({ lobb, ctx }, eventName, input),
|
|
105
60
|
components: getComponents(),
|
|
106
61
|
mediaQueries: mediaQueries,
|
|
107
62
|
intlDate: intlDate,
|
|
108
63
|
};
|
|
109
64
|
}
|
|
110
|
-
export function loadExtensions(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
studioExtension = extensionMap[extensionName](getExtensionUtils(lobb, ctx));
|
|
120
|
-
extensions[studioExtension.name] = studioExtension;
|
|
121
|
-
}
|
|
122
|
-
return [2 /*return*/, extensions];
|
|
123
|
-
});
|
|
124
|
-
});
|
|
65
|
+
export async function loadExtensions(lobb, ctx, extensionMap = {}) {
|
|
66
|
+
const extensions = {};
|
|
67
|
+
const extensionNames = Object.keys(extensionMap).filter(name => ctx.meta.extensions[name] != null);
|
|
68
|
+
for (let index = 0; index < extensionNames.length; index++) {
|
|
69
|
+
const extensionName = extensionNames[index];
|
|
70
|
+
const studioExtension = extensionMap[extensionName](getExtensionUtils(lobb, ctx));
|
|
71
|
+
extensions[studioExtension.name] = studioExtension;
|
|
72
|
+
}
|
|
73
|
+
return extensions;
|
|
125
74
|
}
|
|
126
75
|
export function loadExtensionComponents(ctx, name, filterByExtensions, props) {
|
|
127
|
-
|
|
128
|
-
for (
|
|
129
|
-
var _b = _a[_i], extensionName = _b[0], extensionValue = _b[1];
|
|
76
|
+
const components = [];
|
|
77
|
+
for (const [extensionName, extensionValue] of Object.entries(ctx.extensions)) {
|
|
130
78
|
if (filterByExtensions && !filterByExtensions.includes(extensionName)) {
|
|
131
79
|
continue;
|
|
132
80
|
}
|
|
133
81
|
if (extensionValue.components) {
|
|
134
|
-
for (
|
|
135
|
-
var _e = _d[_c], componentName = _e[0], componentValue = _e[1];
|
|
82
|
+
for (const [componentName, componentValue] of Object.entries(extensionValue.components)) {
|
|
136
83
|
if (name.startsWith(componentName)) {
|
|
137
84
|
if (componentValue && typeof componentValue === "object" && "component" in componentValue && "when" in componentValue) {
|
|
138
85
|
if (!props || componentValue.when(props)) {
|
|
@@ -149,76 +96,59 @@ export function loadExtensionComponents(ctx, name, filterByExtensions, props) {
|
|
|
149
96
|
return components;
|
|
150
97
|
}
|
|
151
98
|
export function loadExtensionWorkflows(ctx) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (extension === null || extension === void 0 ? void 0 : extension.workflows) {
|
|
158
|
-
(_a = ctx.meta.studio_workflows).push.apply(_a, extension.workflows);
|
|
99
|
+
const extensionNames = Object.keys(ctx.extensions);
|
|
100
|
+
for (const extensionName of extensionNames) {
|
|
101
|
+
const extension = ctx.extensions[extensionName];
|
|
102
|
+
if (extension?.workflows) {
|
|
103
|
+
ctx.meta.studio_workflows.push(...extension.workflows);
|
|
159
104
|
}
|
|
160
105
|
}
|
|
161
106
|
}
|
|
162
|
-
export function executeExtensionsOnStartup(lobb, ctx) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
_a.label = 1;
|
|
171
|
-
case 1:
|
|
172
|
-
if (!(index < extensionNames.length)) return [3 /*break*/, 4];
|
|
173
|
-
extensionName = extensionNames[index];
|
|
174
|
-
extension = ctx.extensions[extensionName];
|
|
175
|
-
if (!extension) return [3 /*break*/, 3];
|
|
176
|
-
if (!extension.onStartup) return [3 /*break*/, 3];
|
|
177
|
-
return [4 /*yield*/, extension.onStartup(getExtensionUtils(lobb, ctx))];
|
|
178
|
-
case 2:
|
|
179
|
-
_a.sent();
|
|
180
|
-
_a.label = 3;
|
|
181
|
-
case 3:
|
|
182
|
-
index++;
|
|
183
|
-
return [3 /*break*/, 1];
|
|
184
|
-
case 4: return [2 /*return*/];
|
|
107
|
+
export async function executeExtensionsOnStartup(lobb, ctx) {
|
|
108
|
+
const extensionNames = Object.keys(ctx.extensions);
|
|
109
|
+
for (let index = 0; index < extensionNames.length; index++) {
|
|
110
|
+
const extensionName = extensionNames[index];
|
|
111
|
+
const extension = ctx.extensions[extensionName];
|
|
112
|
+
if (extension) {
|
|
113
|
+
if (extension.onStartup) {
|
|
114
|
+
await extension.onStartup(getExtensionUtils(lobb, ctx));
|
|
185
115
|
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
188
118
|
}
|
|
189
119
|
export function executeExtensionsOnRouteChange(lobb, ctx, path) {
|
|
190
|
-
|
|
191
|
-
for (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (extension
|
|
120
|
+
const extensionNames = Object.keys(ctx.extensions);
|
|
121
|
+
for (let index = 0; index < extensionNames.length; index++) {
|
|
122
|
+
const extensionName = extensionNames[index];
|
|
123
|
+
const extension = ctx.extensions[extensionName];
|
|
124
|
+
if (extension?.onRouteChange) {
|
|
195
125
|
extension.onRouteChange(getExtensionUtils(lobb, ctx), path);
|
|
196
126
|
}
|
|
197
127
|
}
|
|
198
128
|
}
|
|
199
129
|
export function getDashboardNavs(ctx) {
|
|
200
|
-
|
|
130
|
+
let navs = {
|
|
201
131
|
top: [],
|
|
202
132
|
middle: [],
|
|
203
133
|
bottom: [],
|
|
204
134
|
};
|
|
205
|
-
|
|
206
|
-
for (
|
|
207
|
-
|
|
208
|
-
|
|
135
|
+
const extensionNames = Object.keys(ctx.extensions);
|
|
136
|
+
for (let index = 0; index < extensionNames.length; index++) {
|
|
137
|
+
const extensionName = extensionNames[index];
|
|
138
|
+
const extension = ctx.extensions[extensionName];
|
|
209
139
|
if (extension) {
|
|
210
140
|
if (extension.dashboardNavs && extension.dashboardNavs.top && navs.top) {
|
|
211
|
-
navs.top =
|
|
141
|
+
navs.top = [...navs.top, ...extension.dashboardNavs.top];
|
|
212
142
|
}
|
|
213
143
|
if (extension.dashboardNavs &&
|
|
214
144
|
extension.dashboardNavs.middle &&
|
|
215
145
|
navs.middle) {
|
|
216
|
-
navs.middle =
|
|
146
|
+
navs.middle = [...navs.middle, ...extension.dashboardNavs.middle];
|
|
217
147
|
}
|
|
218
148
|
if (extension.dashboardNavs &&
|
|
219
149
|
extension.dashboardNavs.bottom &&
|
|
220
150
|
navs.bottom) {
|
|
221
|
-
navs.bottom =
|
|
151
|
+
navs.bottom = [...navs.bottom, ...extension.dashboardNavs.bottom];
|
|
222
152
|
}
|
|
223
153
|
}
|
|
224
154
|
}
|
package/dist/relations.d.ts
CHANGED
package/dist/relations.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function getFieldRelation(ctx, collectionName, fieldName) {
|
|
2
|
-
|
|
3
|
-
for (
|
|
4
|
-
|
|
2
|
+
const relations = ctx.meta.relations;
|
|
3
|
+
for (let index = 0; index < relations.length; index++) {
|
|
4
|
+
const relation = relations[index];
|
|
5
5
|
if (relation.type === "polymorphic")
|
|
6
6
|
continue;
|
|
7
7
|
if (relation.from.collection === collectionName && relation.from.field === fieldName) {
|
|
@@ -16,14 +16,13 @@ export function isRelationField(ctx, collectionName, fieldName) {
|
|
|
16
16
|
}
|
|
17
17
|
;
|
|
18
18
|
export function getFieldRelationTarget(ctx, collectionName, fieldName) {
|
|
19
|
-
|
|
20
|
-
return (_b = (_a = getFieldRelation(ctx, collectionName, fieldName)) === null || _a === void 0 ? void 0 : _a.to.collection) !== null && _b !== void 0 ? _b : null;
|
|
19
|
+
return getFieldRelation(ctx, collectionName, fieldName)?.to.collection ?? null;
|
|
21
20
|
}
|
|
22
21
|
;
|
|
23
22
|
export function getPolymorphicRelation(ctx, collectionName, fieldName) {
|
|
24
|
-
|
|
25
|
-
for (
|
|
26
|
-
|
|
23
|
+
const relations = ctx.meta.relations;
|
|
24
|
+
for (let index = 0; index < relations.length; index++) {
|
|
25
|
+
const relation = relations[index];
|
|
27
26
|
if (relation.type === "polymorphic" &&
|
|
28
27
|
relation.from.collection === collectionName &&
|
|
29
28
|
relation.from.virtual_field === fieldName) {
|
|
@@ -34,8 +33,8 @@ export function getPolymorphicRelation(ctx, collectionName, fieldName) {
|
|
|
34
33
|
}
|
|
35
34
|
;
|
|
36
35
|
export function recordHasChildrean(ctx, collectionName) {
|
|
37
|
-
for (
|
|
38
|
-
|
|
36
|
+
for (let index = 0; index < ctx.meta.relations.length; index++) {
|
|
37
|
+
const relation = ctx.meta.relations[index];
|
|
39
38
|
if (relation.type === "polymorphic")
|
|
40
39
|
continue;
|
|
41
40
|
if (relation.to.collection === collectionName) {
|
package/dist/store.svelte.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { LobbClient } from '@lobb-js/sdk';
|
|
2
|
+
export declare function createLobb(url: string): LobbClient;
|
package/dist/store.svelte.js
CHANGED
|
@@ -1,58 +1,12 @@
|
|
|
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
1
|
import { LobbClient } from '@lobb-js/sdk';
|
|
38
2
|
import { toast } from 'svelte-sonner';
|
|
39
3
|
export function createLobb(url) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!(response.status >= 400)) return [3 /*break*/, 2];
|
|
48
|
-
return [4 /*yield*/, response.json()];
|
|
49
|
-
case 1:
|
|
50
|
-
body = _a.sent();
|
|
51
|
-
toast.error(body.message);
|
|
52
|
-
_a.label = 2;
|
|
53
|
-
case 2: return [2 /*return*/];
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}); });
|
|
4
|
+
const client = new LobbClient(url);
|
|
5
|
+
client.onResponse(async (response) => {
|
|
6
|
+
if (response.status >= 400) {
|
|
7
|
+
const body = await response.json();
|
|
8
|
+
toast.error(body.message);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
57
11
|
return client;
|
|
58
12
|
}
|
package/dist/utils.js
CHANGED
|
@@ -2,14 +2,10 @@ import { clsx } from "clsx";
|
|
|
2
2
|
import { twMerge } from "tailwind-merge";
|
|
3
3
|
import { isEqual } from "lodash-es";
|
|
4
4
|
import { MediaQuery } from 'svelte/reactivity';
|
|
5
|
-
export function cn() {
|
|
6
|
-
var inputs = [];
|
|
7
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8
|
-
inputs[_i] = arguments[_i];
|
|
9
|
-
}
|
|
5
|
+
export function cn(...inputs) {
|
|
10
6
|
return twMerge(clsx(inputs));
|
|
11
7
|
}
|
|
12
|
-
export
|
|
8
|
+
export const mediaQueries = {
|
|
13
9
|
sm: new MediaQuery('min-width: 640px'),
|
|
14
10
|
md: new MediaQuery('min-width: 768px'),
|
|
15
11
|
lg: new MediaQuery('min-width: 1024px'),
|
|
@@ -17,16 +13,15 @@ export var mediaQueries = {
|
|
|
17
13
|
'2xl': new MediaQuery('min-width: 1536px'),
|
|
18
14
|
};
|
|
19
15
|
export function calculateDrawerWidth() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const backgroundDrawerButtons = document.querySelectorAll(".backgroundDrawerButton");
|
|
17
|
+
const drawersCount = Array.from(backgroundDrawerButtons).length;
|
|
18
|
+
const width = 672 - (30 * drawersCount);
|
|
23
19
|
return width;
|
|
24
20
|
}
|
|
25
21
|
;
|
|
26
22
|
export function getChangedProperties(oldObj, newObj) {
|
|
27
|
-
|
|
28
|
-
for (
|
|
29
|
-
var key = _a[_i];
|
|
23
|
+
const changes = {};
|
|
24
|
+
for (const key of Object.keys(newObj)) {
|
|
30
25
|
if (!isEqual(oldObj[key], newObj[key])) {
|
|
31
26
|
changes[key] = newObj[key];
|
|
32
27
|
}
|
|
@@ -34,7 +29,7 @@ export function getChangedProperties(oldObj, newObj) {
|
|
|
34
29
|
return changes;
|
|
35
30
|
}
|
|
36
31
|
export function parseFunction(functionString) {
|
|
37
|
-
|
|
32
|
+
const functionObj = new Function("return " + functionString)();
|
|
38
33
|
return functionObj;
|
|
39
34
|
}
|
|
40
35
|
;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobb-js/studio",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "0.28.
|
|
4
|
+
"version": "0.28.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -28,10 +28,12 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"dev": "vite",
|
|
32
|
-
"
|
|
31
|
+
"dev": "vite dev",
|
|
32
|
+
"build": "vite build && bun run package",
|
|
33
|
+
"package": "svelte-kit sync && svelte-package --input src/lib",
|
|
33
34
|
"preview": "vite preview",
|
|
34
|
-
"
|
|
35
|
+
"prepare": "svelte-kit sync || echo ''",
|
|
36
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
35
37
|
"storybook": "storybook dev -p 6006",
|
|
36
38
|
"build-storybook": "storybook build",
|
|
37
39
|
"test": "vitest",
|
|
@@ -47,8 +49,9 @@
|
|
|
47
49
|
"@storybook/addon-svelte-csf": "^5.0.10",
|
|
48
50
|
"@storybook/addon-vitest": "^10.0.1",
|
|
49
51
|
"@storybook/svelte-vite": "^10.0.1",
|
|
52
|
+
"@sveltejs/adapter-node": "^5.5.4",
|
|
53
|
+
"@sveltejs/kit": "^2.60.1",
|
|
50
54
|
"@sveltejs/package": "^2.5.7",
|
|
51
|
-
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
52
55
|
"@tsconfig/svelte": "^5.0.6",
|
|
53
56
|
"@types/mustache": "^4.2.6",
|
|
54
57
|
"@types/node": "^24.10.1",
|
package/src/app.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// See https://svelte.dev/docs/kit/types#app.d.ts
|
|
2
|
+
// for information about these interfaces
|
|
3
|
+
declare global {
|
|
4
|
+
namespace App {
|
|
5
|
+
// interface Error {}
|
|
6
|
+
// interface Locals {}
|
|
7
|
+
// interface PageData {}
|
|
8
|
+
// interface PageState {}
|
|
9
|
+
// interface Platform {}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface Window {
|
|
13
|
+
APP_ENV: {
|
|
14
|
+
LOBB_URL: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {};
|
package/src/app.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%sveltekit.assets%/lobb.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<title>Lobb Studio</title>
|
|
8
|
+
%sveltekit.head%
|
|
9
|
+
</head>
|
|
10
|
+
<body data-sveltekit-preload-data="hover">
|
|
11
|
+
<div style="display: contents">%sveltekit.body%</div>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/src/App.svelte
DELETED
package/src/main.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import "./app.css";
|
|
2
|
-
|
|
3
|
-
import { mount } from 'svelte'
|
|
4
|
-
import App from './App.svelte'
|
|
5
|
-
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
APP_ENV: {
|
|
9
|
-
LOBB_URL: string
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const app = mount(App, {
|
|
15
|
-
target: document.getElementById('app')!,
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
export default app
|