@lobb-js/studio 0.4.0 → 0.6.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.
Files changed (68) hide show
  1. package/dist/components/LlmButton.svelte +3 -1
  2. package/dist/components/Studio.svelte +78 -98
  3. package/dist/components/Studio.svelte.d.ts +1 -0
  4. package/dist/components/breadCrumbs.svelte +0 -1
  5. package/dist/components/combobox.svelte +3 -3
  6. package/dist/components/confirmationDialog/confirmationDialog.svelte +1 -1
  7. package/dist/components/createManyButton.svelte +3 -1
  8. package/dist/components/dataTable/childRecords.svelte +4 -2
  9. package/dist/components/dataTable/dataTable.svelte +6 -3
  10. package/dist/components/dataTable/fieldCell.svelte +6 -3
  11. package/dist/components/dataTable/filter.svelte +4 -2
  12. package/dist/components/dataTable/filterButton.svelte +1 -1
  13. package/dist/components/dataTable/header.svelte +3 -1
  14. package/dist/components/dataTable/sort.svelte +5 -3
  15. package/dist/components/dataTable/sortButton.svelte +2 -2
  16. package/dist/components/dataTable/utils.d.ts +7 -6
  17. package/dist/components/dataTable/utils.js +11 -12
  18. package/dist/components/detailView/create/children.svelte +5 -3
  19. package/dist/components/detailView/create/createDetailView.svelte +14 -10
  20. package/dist/components/detailView/create/createDetailViewButton.svelte +15 -10
  21. package/dist/components/detailView/create/createDetailViewButton.svelte.d.ts +1 -1
  22. package/dist/components/detailView/create/createManyView.svelte +8 -6
  23. package/dist/components/detailView/create/subRecords.svelte +3 -1
  24. package/dist/components/detailView/fieldInput.svelte +7 -5
  25. package/dist/components/detailView/fieldInputReplacement.svelte +1 -1
  26. package/dist/components/detailView/store.svelte.d.ts +3 -2
  27. package/dist/components/detailView/store.svelte.js +11 -14
  28. package/dist/components/detailView/update/children.svelte +6 -4
  29. package/dist/components/detailView/update/updateDetailView.svelte +11 -9
  30. package/dist/components/detailView/update/updateDetailViewButton.svelte +35 -11
  31. package/dist/components/detailView/update/updateDetailViewButton.svelte.d.ts +1 -1
  32. package/dist/components/detailView/utils.d.ts +6 -5
  33. package/dist/components/detailView/utils.js +9 -10
  34. package/dist/components/extensionsComponents.svelte +4 -1
  35. package/dist/components/miniSidebar.svelte +9 -21
  36. package/dist/components/rangeCalendarButton.svelte +3 -3
  37. package/dist/components/richTextEditor.svelte +1 -1
  38. package/dist/components/routes/collections/collection.svelte +8 -6
  39. package/dist/components/routes/collections/collections.svelte +5 -3
  40. package/dist/components/routes/data_model/dataModel.svelte +2 -2
  41. package/dist/components/routes/data_model/flow.svelte +3 -1
  42. package/dist/components/routes/data_model/syncManager.svelte +7 -5
  43. package/dist/components/routes/extensions/extension.svelte +5 -2
  44. package/dist/components/routes/home.svelte +4 -2
  45. package/dist/components/routes/workflows/workflows.svelte +9 -7
  46. package/dist/components/selectRecord.svelte +5 -1
  47. package/dist/components/setServerPage.svelte +4 -2
  48. package/dist/components/singletone.svelte +4 -2
  49. package/dist/components/ui/alert-dialog/alert-dialog-action.svelte +1 -1
  50. package/dist/components/ui/alert-dialog/alert-dialog-cancel.svelte +1 -1
  51. package/dist/components/ui/command/command-dialog.svelte +1 -1
  52. package/dist/components/ui/range-calendar/range-calendar-day.svelte +1 -1
  53. package/dist/components/ui/range-calendar/range-calendar-day.svelte.d.ts +1 -1
  54. package/dist/components/ui/range-calendar/range-calendar-next-button.svelte +1 -1
  55. package/dist/components/ui/range-calendar/range-calendar-prev-button.svelte +1 -1
  56. package/dist/components/ui/select/select-separator.svelte +1 -1
  57. package/dist/components/workflowEditor.svelte +6 -4
  58. package/dist/context.d.ts +10 -0
  59. package/dist/context.js +11 -0
  60. package/dist/eventSystem.d.ts +2 -1
  61. package/dist/eventSystem.js +7 -7
  62. package/dist/extensions/extensionUtils.d.ts +8 -6
  63. package/dist/extensions/extensionUtils.js +10 -11
  64. package/dist/store.svelte.d.ts +1 -3
  65. package/dist/store.svelte.js +19 -36
  66. package/dist/utils.d.ts +3 -2
  67. package/dist/utils.js +2 -3
  68. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
2
  import type { CreateDetailViewProp } from "./createDetailView.svelte";
3
- import type { ButtonProps } from "../../ui/button/button.svelte";
4
- import Button from "../../ui/button/button.svelte";
5
- import { openCreateDetailView } from "../store.svelte";
3
+ import type { ButtonProps } from "../../../components/ui/button/button.svelte";
4
+ import Button from "../../../components/ui/button/button.svelte";
5
+ import CreateDetailView from "./createDetailView.svelte";
6
6
 
7
7
  interface LocalProp extends CreateDetailViewProp {
8
8
  variant?: ButtonProps["variant"];
@@ -12,21 +12,26 @@
12
12
  }
13
13
 
14
14
  let props: LocalProp = $props();
15
- let entry: Record<string, any> | undefined = $state();
15
+ let open = $state(false);
16
16
  </script>
17
17
 
18
18
  <Button
19
19
  variant={props.variant}
20
20
  class={props.class}
21
21
  Icon={props.Icon}
22
- onclick={() => {
23
- openCreateDetailView({
24
- values: entry,
25
- ...props
26
- });
27
- }}
22
+ onclick={() => { open = true; }}
28
23
  >
29
24
  {#if props.children}
30
25
  {@render props.children()}
31
26
  {/if}
32
27
  </Button>
28
+
29
+ {#if open}
30
+ <CreateDetailView
31
+ {...props}
32
+ onCancel={async () => {
33
+ open = false;
34
+ await props.onCancel?.();
35
+ }}
36
+ />
37
+ {/if}
@@ -1,5 +1,5 @@
1
1
  import type { CreateDetailViewProp } from "./createDetailView.svelte";
2
- import type { ButtonProps } from "../../ui/button/button.svelte";
2
+ import type { ButtonProps } from "../../../components/ui/button/button.svelte";
3
3
  interface LocalProp extends CreateDetailViewProp {
4
4
  variant?: ButtonProps["variant"];
5
5
  class?: ButtonProps["class"];
@@ -11,12 +11,14 @@
11
11
  import Table, { type TableProps } from "../../dataTable/table.svelte";
12
12
  import Button from "../../ui/button/button.svelte";
13
13
  import CreateDetailViewButton from "./createDetailViewButton.svelte";
14
- import { getCollectionColumns } from "../../dataTable/utils";
15
- import SelectRecord from "../../selectRecord.svelte";
16
- import FieldCell from "../../dataTable/fieldCell.svelte";
14
+ import { getCollectionColumns } from "../../../components/dataTable/utils";
15
+ import SelectRecord from "../../../components/selectRecord.svelte";
16
+ import FieldCell from "../../../components/dataTable/fieldCell.svelte";
17
17
  import SubRecords from "./subRecords.svelte";
18
- import ChildRecords from "../../dataTable/childRecords.svelte";
19
- import { ctx } from "../../../store.svelte";
18
+ import ChildRecords from "../../../components/dataTable/childRecords.svelte";
19
+ import { getStudioContext } from "../../../context";
20
+
21
+ const { ctx } = getStudioContext();
20
22
 
21
23
  interface ParentRecord {
22
24
  id: string;
@@ -47,7 +49,7 @@
47
49
  (relation) => relation.to.collection === collectionName,
48
50
  ),
49
51
  );
50
- const columns: TableProps["columns"] = getCollectionColumns(collectionName);
52
+ const columns: TableProps["columns"] = getCollectionColumns(ctx, collectionName);
51
53
  const refrenceFieldName = ctx.meta.relations.find(
52
54
  (relation) =>
53
55
  relation.from.collection === collectionName &&
@@ -1,7 +1,9 @@
1
1
  <script lang="ts">
2
- import { ctx } from "../../../store.svelte";
2
+ import { getStudioContext } from "../../../context";
3
3
  import CreateManyView from "./createManyView.svelte";
4
4
 
5
+ const { ctx } = getStudioContext();
6
+
5
7
  interface Props {
6
8
  collectionName: string;
7
9
  parentEntry: any;
@@ -1,17 +1,19 @@
1
1
  <script lang="ts">
2
- import { ctx } from "../../store.svelte";
2
+ import { getStudioContext } from "../../context";
3
3
  import { getFieldRelation } from "../../utils";
4
4
  import { Ban, Check, CircleAlert, X } from "lucide-svelte";
5
5
  import { getField } from "../dataTable/utils";
6
6
  import Button from "../ui/button/button.svelte";
7
7
  import FieldCustomInput from "./fieldCustomInput.svelte";
8
8
  import Input from "../ui/input/input.svelte";
9
- import * as Select from "../ui/select/index";
9
+ import * as Select from "../../components/ui/select/index";
10
10
  import Textarea from "../ui/textarea/textarea.svelte";
11
11
  import ForeingKeyInput from "../foreingKeyInput.svelte";
12
12
  import ExtensionsComponents from "../extensionsComponents.svelte";
13
13
  import { getExtensionUtils } from "../../extensions/extensionUtils";
14
14
 
15
+ const { ctx, lobb } = getStudioContext();
16
+
15
17
  interface Props {
16
18
  collectionName: string;
17
19
  fieldName: string;
@@ -32,8 +34,8 @@
32
34
  ctx.meta.collections[collectionName].fields[fieldName].ui?.input;
33
35
  const ui =
34
36
  ctx.meta.collections[collectionName].fields[fieldName].ui;
35
- const field = getField(fieldName, collectionName);
36
- const fieldRelation = getFieldRelation(collectionName, fieldName);
37
+ const field = getField(ctx, fieldName, collectionName);
38
+ const fieldRelation = getFieldRelation(ctx, collectionName, fieldName);
37
39
  const isDisabled = field.key === 'id' || Boolean(ui?.disabled)
38
40
  const disabledClasses = "pointer-events-none opacity-50";
39
41
  const destructive: boolean = $derived(Boolean(errorMessages.length));
@@ -72,7 +74,7 @@
72
74
  {:else if fieldRelation && entry}
73
75
  <ExtensionsComponents
74
76
  name="detailView.fields.foreignKey.{fieldRelation.to.collection}"
75
- utils={getExtensionUtils()}
77
+ utils={getExtensionUtils(lobb, ctx)}
76
78
  parentCollectionName={collectionName}
77
79
  collectionName={fieldRelation.to.collection}
78
80
  bind:value
@@ -2,7 +2,7 @@
2
2
  import { Ban, Check, CircleAlert, X } from "lucide-svelte";
3
3
  import Button from "../ui/button/button.svelte";
4
4
  import Input from "../ui/input/input.svelte";
5
- import * as Select from "../ui/select/index";
5
+ import * as Select from "../../components/ui/select/index";
6
6
  import Textarea from "../ui/textarea/textarea.svelte";
7
7
  import type { EntryField } from "./detailViewForm.svelte";
8
8
  import type { Snippet } from "svelte";
@@ -1,4 +1,5 @@
1
1
  import type { CreateDetailViewProp } from "./create/createDetailView.svelte";
2
2
  import type { UpdateDetailViewProp } from "./update/updateDetailView.svelte";
3
- export declare function openCreateDetailView(props: CreateDetailViewProp): void;
4
- export declare function openUpdateDetailView(props: UpdateDetailViewProp): Promise<void>;
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>;
@@ -47,10 +47,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  import CreateDetailView from "./create/createDetailView.svelte";
49
49
  import UpdateDetailView from "./update/updateDetailView.svelte";
50
- import { lobb } from "../../store.svelte";
51
50
  import { getCollectionParamsFields } from "../dataTable/utils";
51
+ import { createStudioContextMap } from "../../context";
52
52
  import { mount, unmount } from "svelte";
53
- export function openCreateDetailView(props) {
53
+ export function openCreateDetailView(studioContext, props) {
54
54
  var _this = this;
55
55
  var targetElement = document.querySelector('main');
56
56
  if (!targetElement) {
@@ -58,15 +58,14 @@ export function openCreateDetailView(props) {
58
58
  }
59
59
  var mountedCreateDetailView = mount(CreateDetailView, {
60
60
  target: targetElement,
61
+ context: createStudioContextMap(studioContext),
61
62
  props: __assign(__assign({}, props), { onCancel: function () { return __awaiter(_this, void 0, void 0, function () {
62
63
  var _a;
63
64
  return __generator(this, function (_b) {
64
65
  switch (_b.label) {
65
66
  case 0:
66
67
  (_a = props.onCancel) === null || _a === void 0 ? void 0 : _a.call(props);
67
- return [4 /*yield*/, unmount(mountedCreateDetailView, {
68
- outro: true
69
- })];
68
+ return [4 /*yield*/, unmount(mountedCreateDetailView, { outro: true })];
70
69
  case 1:
71
70
  _b.sent();
72
71
  return [2 /*return*/];
@@ -75,18 +74,17 @@ export function openCreateDetailView(props) {
75
74
  }); } }),
76
75
  });
77
76
  }
78
- export function openUpdateDetailView(props) {
77
+ export function openUpdateDetailView(studioContext, props) {
79
78
  return __awaiter(this, void 0, void 0, function () {
80
- var params, response, result, entry, targetElement, mountedUpdateDetailView;
79
+ var lobb, ctx, params, response, result, entry, targetElement, mountedUpdateDetailView;
81
80
  var _this = this;
82
81
  return __generator(this, function (_a) {
83
82
  switch (_a.label) {
84
83
  case 0:
84
+ lobb = studioContext.lobb, ctx = studioContext.ctx;
85
85
  params = {
86
- fields: getCollectionParamsFields(props.collectionName, true),
87
- filter: {
88
- id: props.recordId,
89
- },
86
+ fields: getCollectionParamsFields(ctx, props.collectionName, true),
87
+ filter: { id: props.recordId },
90
88
  limit: 1,
91
89
  };
92
90
  return [4 /*yield*/, lobb.findAll(props.collectionName, params)];
@@ -102,15 +100,14 @@ export function openUpdateDetailView(props) {
102
100
  }
103
101
  mountedUpdateDetailView = mount(UpdateDetailView, {
104
102
  target: targetElement,
103
+ context: createStudioContextMap(studioContext),
105
104
  props: __assign(__assign({}, props), { onCancel: function () { return __awaiter(_this, void 0, void 0, function () {
106
105
  var _a;
107
106
  return __generator(this, function (_b) {
108
107
  switch (_b.label) {
109
108
  case 0:
110
109
  (_a = props.onCancel) === null || _a === void 0 ? void 0 : _a.call(props);
111
- return [4 /*yield*/, unmount(mountedUpdateDetailView, {
112
- outro: true
113
- })];
110
+ return [4 /*yield*/, unmount(mountedUpdateDetailView, { outro: true })];
114
111
  case 1:
115
112
  _b.sent();
116
113
  return [2 /*return*/];
@@ -1,11 +1,13 @@
1
1
  <script lang="ts">
2
- import DataTable from "../../dataTable/dataTable.svelte";
3
- import { ctx } from "../../../store.svelte";
2
+ import DataTable from "../../../components/dataTable/dataTable.svelte";
3
+ import { getStudioContext } from "../../../context";
4
4
  import { Link, Plus, TableIcon } from "lucide-svelte";
5
5
  import CreateDetailViewButton from "../create/createDetailViewButton.svelte";
6
- import ExtensionsComponents from "../../extensionsComponents.svelte";
6
+ import ExtensionsComponents from "../../../components/extensionsComponents.svelte";
7
7
  import { getExtensionUtils } from "../../../extensions/extensionUtils";
8
8
 
9
+ const { ctx, lobb } = getStudioContext();
10
+
9
11
  interface LocalProp {
10
12
  collectionName: string;
11
13
  entry: any;
@@ -33,7 +35,7 @@
33
35
  {@const childField = relation.from.field}
34
36
  <ExtensionsComponents
35
37
  name="detailView.update.subRecords.{childCollection}"
36
- utils={getExtensionUtils()}
38
+ utils={getExtensionUtils(lobb, ctx)}
37
39
  collectionName={childCollection}
38
40
  filter={{
39
41
  [childField]: entry.id,
@@ -19,19 +19,21 @@
19
19
 
20
20
  <script lang="ts">
21
21
  import { ArrowLeft, Pencil, X } from "lucide-svelte";
22
- import Button from "../../ui/button/button.svelte";
22
+ import Button from "../../../components/ui/button/button.svelte";
23
23
  import { fade, fly } from "svelte/transition";
24
- import { lobb, ctx } from "../../../store.svelte";
24
+ import { getStudioContext } from "../../../context";
25
25
  import { toast } from "svelte-sonner";
26
26
  import ExtensionsComponents from "../../extensionsComponents.svelte";
27
27
  import { getExtensionUtils } from "../../../extensions/extensionUtils";
28
+
29
+ const { lobb, ctx } = getStudioContext();
28
30
  import { calculateDrawerWidth, getChangedProperties } from "../../../utils";
29
31
  import { getField, getFieldIcon } from "../../dataTable/utils";
30
32
  import Children from "../update/children.svelte";
31
33
  import type { Snippet } from "svelte";
32
34
  import { getDefaultEntry, parseDetailViewValues, serializeEntry } from "../utils";
33
35
  import FieldInput from "../fieldInput.svelte";
34
- import Drawer from "../../drawer.svelte";
36
+ import Drawer from "../../../components/drawer.svelte";
35
37
 
36
38
  let {
37
39
  collectionName,
@@ -44,11 +46,11 @@
44
46
  recordId,
45
47
  }: UpdateDetailViewProp = $props();
46
48
 
47
- parseDetailViewValues(collectionName, values)
49
+ parseDetailViewValues(ctx, collectionName, values)
48
50
 
49
51
  const fieldNames = Object.keys(ctx.meta.collections[collectionName].fields);
50
52
  let entry: Record<string, any> = $state(
51
- getDefaultEntry(fieldNames, collectionName, values),
53
+ getDefaultEntry(ctx, fieldNames, collectionName, values),
52
54
  );
53
55
  const initialEntry = $state.snapshot(entry);
54
56
  let localEntry = $derived(
@@ -58,7 +60,7 @@
58
60
 
59
61
  async function handleSave() {
60
62
  delete localEntry.id;
61
- localEntry = serializeEntry(collectionName, localEntry);
63
+ localEntry = serializeEntry(ctx, collectionName, localEntry);
62
64
 
63
65
  const response = await lobb.updateOne(
64
66
  collectionName,
@@ -111,8 +113,8 @@
111
113
  <div class="flex-1 overflow-y-auto">
112
114
  <div class="flex flex-col gap-4 p-4">
113
115
  {#each fieldNames as fieldName}
114
- {@const field = getField(fieldName, collectionName)}
115
- {@const FieldIcon = getFieldIcon(fieldName, collectionName)}
116
+ {@const field = getField(ctx, fieldName, collectionName)}
117
+ {@const FieldIcon = getFieldIcon(ctx, fieldName, collectionName)}
116
118
  <div
117
119
  class="flex flex-col gap-2"
118
120
  >
@@ -131,7 +133,7 @@
131
133
  <div>
132
134
  <ExtensionsComponents
133
135
  name="dvFields.topRight.{collectionName}.{fieldName}"
134
- utils={getExtensionUtils()}
136
+ utils={getExtensionUtils(lobb, ctx)}
135
137
  bind:value={entry[fieldName]}
136
138
  />
137
139
  </div>
@@ -1,8 +1,10 @@
1
1
  <script lang="ts">
2
2
  import type { UpdateDetailViewProp } from "./updateDetailView.svelte";
3
- import type { ButtonProps } from "../../ui/button/button.svelte";
4
- import Button from "../../ui/button/button.svelte";
5
- import { openUpdateDetailView } from "../store.svelte";
3
+ import type { ButtonProps } from "../../../components/ui/button/button.svelte";
4
+ import Button from "../../../components/ui/button/button.svelte";
5
+ import UpdateDetailView from "./updateDetailView.svelte";
6
+ import { getStudioContext } from "../../../context";
7
+ import { getCollectionParamsFields } from "../../dataTable/utils";
6
8
 
7
9
  interface LocalProp extends UpdateDetailViewProp {
8
10
  variant?: ButtonProps["variant"];
@@ -12,21 +14,43 @@
12
14
  }
13
15
 
14
16
  let props: LocalProp = $props();
15
- let entry: Record<string, any> | undefined = $state();
17
+ let open = $state(false);
18
+ let values: Record<string, any> | undefined = $state(undefined);
19
+
20
+ const { lobb, ctx } = getStudioContext();
21
+
22
+ async function openView() {
23
+ const params = {
24
+ fields: getCollectionParamsFields(ctx, props.collectionName, true),
25
+ filter: { id: props.recordId },
26
+ limit: 1,
27
+ };
28
+ const response = await lobb.findAll(props.collectionName, params);
29
+ const result = await response.json();
30
+ values = result.data[0];
31
+ open = true;
32
+ }
16
33
  </script>
17
34
 
18
35
  <Button
19
36
  variant={props.variant}
20
37
  class={props.class}
21
38
  Icon={props.Icon}
22
- onclick={() => {
23
- openUpdateDetailView({
24
- values: entry,
25
- ...props
26
- });
27
- }}
39
+ onclick={openView}
28
40
  >
29
41
  {#if props.children}
30
42
  {@render props.children()}
31
43
  {/if}
32
- </Button>
44
+ </Button>
45
+
46
+ {#if open && values}
47
+ <UpdateDetailView
48
+ {...props}
49
+ {values}
50
+ onCancel={async () => {
51
+ open = false;
52
+ values = undefined;
53
+ await props.onCancel?.();
54
+ }}
55
+ />
56
+ {/if}
@@ -1,5 +1,5 @@
1
1
  import type { UpdateDetailViewProp } from "./updateDetailView.svelte";
2
- import type { ButtonProps } from "../../ui/button/button.svelte";
2
+ import type { ButtonProps } from "../../../components/ui/button/button.svelte";
3
3
  interface LocalProp extends UpdateDetailViewProp {
4
4
  variant?: ButtonProps["variant"];
5
5
  class?: ButtonProps["class"];
@@ -1,8 +1,9 @@
1
+ import type { CTX } from "../../store.types";
1
2
  import type { DetailFormField } from "./detailViewForm.svelte";
2
- export declare function getDefaultEntry(fieldNames: string[], collectionName: string, values?: Record<string, any>): {
3
+ export declare function getDefaultEntry(ctx: CTX, fieldNames: string[], collectionName: string, values?: Record<string, any>): {
3
4
  [k: string]: any;
4
5
  };
5
- export declare function serializeEntry(collectionName: string, entry: Record<string, any>, rollback?: boolean): Record<string, any>;
6
- export declare function generateTransactionBody(collectionName: string, entry: Record<string, any>): any[];
7
- export declare function parseDetailViewValues(collectionName: string, values: Record<string, any>): void;
8
- export declare function getCollectionFields(collectionName: string): DetailFormField[];
6
+ export declare function serializeEntry(ctx: CTX, collectionName: string, entry: Record<string, any>, rollback?: boolean): Record<string, any>;
7
+ export declare function generateTransactionBody(ctx: CTX, collectionName: string, entry: Record<string, any>): any[];
8
+ export declare function parseDetailViewValues(ctx: CTX, collectionName: string, values: Record<string, any>): void;
9
+ export declare function getCollectionFields(ctx: CTX, collectionName: string): DetailFormField[];
@@ -10,14 +10,13 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import Mustache from "mustache";
13
- import { ctx } from "../../store.svelte";
14
13
  import { getFieldRelation } from "../../utils";
15
14
  import { getField } from "../dataTable/utils";
16
- export function getDefaultEntry(fieldNames, collectionName, values) {
15
+ export function getDefaultEntry(ctx, fieldNames, collectionName, values) {
17
16
  return Object.fromEntries(fieldNames.map(function (fieldName) {
18
17
  var _a;
19
18
  var value = null;
20
- var field = getField(fieldName, collectionName);
19
+ var field = getField(ctx, fieldName, collectionName);
21
20
  if (values && values[fieldName] !== undefined) {
22
21
  value = values[fieldName];
23
22
  }
@@ -35,14 +34,14 @@ export function getDefaultEntry(fieldNames, collectionName, values) {
35
34
  return [fieldName, value];
36
35
  }));
37
36
  }
38
- export function serializeEntry(collectionName, entry, rollback) {
37
+ export function serializeEntry(ctx, collectionName, entry, rollback) {
39
38
  if (rollback === void 0) { rollback = false; }
40
39
  // deep clone the object
41
40
  entry = __assign({}, entry);
42
41
  // serialize the foreign key field's value
43
42
  for (var _i = 0, _a = Object.entries(entry); _i < _a.length; _i++) {
44
43
  var _b = _a[_i], fieldName = _b[0], fieldValue = _b[1];
45
- var isRefrenceField = Boolean(getFieldRelation(collectionName, fieldName));
44
+ var isRefrenceField = Boolean(getFieldRelation(ctx, collectionName, fieldName));
46
45
  if (isRefrenceField && fieldValue !== null && fieldValue.id !== undefined) {
47
46
  entry[fieldName] = fieldValue.id;
48
47
  }
@@ -56,14 +55,14 @@ export function serializeEntry(collectionName, entry, rollback) {
56
55
  var childrenEntries = entry[childrenCollectionName];
57
56
  if (childrenEntries) {
58
57
  for (var index_1 = 0; index_1 < childrenEntries.length; index_1++) {
59
- childrenEntries[index_1] = serializeEntry(childrenCollectionName, childrenEntries[index_1]);
58
+ childrenEntries[index_1] = serializeEntry(ctx, childrenCollectionName, childrenEntries[index_1]);
60
59
  }
61
60
  }
62
61
  }
63
62
  }
64
63
  return entry;
65
64
  }
66
- export function generateTransactionBody(collectionName, entry) {
65
+ export function generateTransactionBody(ctx, collectionName, entry) {
67
66
  entry = __assign({}, entry);
68
67
  function handleEntryRecursive(transactionBody, collectionName, entry, parentTransactionIndex) {
69
68
  var _a;
@@ -118,7 +117,7 @@ export function generateTransactionBody(collectionName, entry) {
118
117
  handleEntryRecursive(transactionBody, collectionName, entry);
119
118
  return transactionBody;
120
119
  }
121
- export function parseDetailViewValues(collectionName, values) {
120
+ export function parseDetailViewValues(ctx, collectionName, values) {
122
121
  var forignFieldNames = ctx.meta.relations
123
122
  .filter(function (relation) { return relation.from.collection === collectionName; })
124
123
  .map(function (relation) { return relation.from.field; });
@@ -136,12 +135,12 @@ export function parseDetailViewValues(collectionName, values) {
136
135
  }
137
136
  else if (childCollectionNames.includes(key)) {
138
137
  for (var index = 0; index < values[key].length; index++) {
139
- parseDetailViewValues(key, values[key][index]);
138
+ parseDetailViewValues(ctx, key, values[key][index]);
140
139
  }
141
140
  }
142
141
  }
143
142
  }
144
- export function getCollectionFields(collectionName) {
143
+ export function getCollectionFields(ctx, collectionName) {
145
144
  var returnedData = [];
146
145
  var collectionFields = ctx.meta.collections[collectionName].fields;
147
146
  var isSingleton = ctx.meta.collections[collectionName].singleton;
@@ -1,6 +1,9 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from "svelte";
3
3
  import { loadExtensionComponents } from "../extensions/extensionUtils";
4
+ import { getStudioContext } from "../context";
5
+
6
+ const { ctx } = getStudioContext();
4
7
 
5
8
  interface Props {
6
9
  name: string;
@@ -18,7 +21,7 @@
18
21
  ...props
19
22
  }: Props = $props();
20
23
 
21
- const Components = loadExtensionComponents(name, filterByExtensions);
24
+ const Components = loadExtensionComponents(ctx, name, filterByExtensions);
22
25
  </script>
23
26
 
24
27
  {#if Components.length}
@@ -11,14 +11,16 @@
11
11
  </script>
12
12
 
13
13
  <script lang="ts">
14
- import { House, Layers, Library, LogOut, Workflow, X } from "lucide-svelte";
15
- import Button from "./ui/button/button.svelte";
16
- import Separator from "./ui/separator/separator.svelte";
17
- import * as Tooltip from "./ui/tooltip";
18
- import * as Accordion from "./ui/accordion/index.js";
14
+ import { House, Layers, Library, Workflow, X } from "lucide-svelte";
15
+ import Button from "../components/ui/button/button.svelte";
16
+ import Separator from "../components/ui/separator/separator.svelte";
17
+ import * as Tooltip from "../components/ui/tooltip";
18
+ import * as Accordion from "../components/ui/accordion/index.js";
19
19
 
20
- import { ctx } from "../store.svelte";
20
+ import { getStudioContext } from "../context";
21
21
  import { getDashboardNavs } from "../extensions/extensionUtils";
22
+
23
+ const { ctx } = getStudioContext();
22
24
  import { mediaQueries } from "../utils";
23
25
  import * as Popover from "./ui/popover";
24
26
  import { location } from "@wjfe/n-savant";
@@ -50,7 +52,7 @@
50
52
  [],
51
53
  ];
52
54
 
53
- const navs = getDashboardNavs();
55
+ const navs = getDashboardNavs(ctx);
54
56
 
55
57
  if (navs.top) {
56
58
  sections[0] = [...sections[0], ...navs.top];
@@ -62,20 +64,6 @@
62
64
  sections[2] = [...sections[2], ...navs.bottom];
63
65
  }
64
66
 
65
- // adding the logout server button
66
- if (!window.APP_ENV.LOBB_URL) {
67
- sections[2] = [
68
- ...sections[2],
69
- {
70
- label: "Log out of the server",
71
- onclick: () => {
72
- localStorage.removeItem("lobb_url");
73
- ctx.lobbUrl = null;
74
- },
75
- icon: LogOut,
76
- },
77
- ];
78
- }
79
67
  </script>
80
68
 
81
69
  {#snippet section(section: any)}
@@ -11,9 +11,9 @@
11
11
  today,
12
12
  } from "@internationalized/date";
13
13
  import { cn } from "../utils.js";
14
- import { buttonVariants } from "./ui/button/index.js";
15
- import { RangeCalendar } from "./ui/range-calendar/index.js";
16
- import * as Popover from "./ui/popover/index.js";
14
+ import { buttonVariants } from "../components/ui/button/index.js";
15
+ import { RangeCalendar } from "../components/ui/range-calendar/index.js";
16
+ import * as Popover from "../components/ui/popover/index.js";
17
17
  import Input from "./ui/input/input.svelte";
18
18
 
19
19
  interface Props {
@@ -217,7 +217,7 @@
217
217
  {/if}
218
218
  </div>
219
219
 
220
- <div bind:this={editorElement} class="rte-content min-h-48 p-3 text-sm"></div>
220
+ <div bind:this={editorElement} class="rte-content min-h-48 max-h-96 overflow-y-auto p-3 text-sm"></div>
221
221
  </div>
222
222
 
223
223
  <style>
@@ -1,11 +1,13 @@
1
1
  <script>
2
2
  import { CircleSlash2 } from "lucide-svelte";
3
- import DataTable from "../../dataTable/dataTable.svelte";
4
- import SidebarTrigger from "../../sidebar/sidebarTrigger.svelte";
5
- import { ctx } from "../../../store.svelte";
6
- import Singletone from "../../singletone.svelte";
3
+ import DataTable from "../../../components/dataTable/dataTable.svelte";
4
+ import SidebarTrigger from "../../../components/sidebar/sidebarTrigger.svelte";
5
+ import { getStudioContext } from "../../../context";
6
+ import Singletone from "../../../components/singletone.svelte";
7
7
  import { getExtensionUtils } from "../../../extensions/extensionUtils";
8
- import ExtensionsComponents from "../../extensionsComponents.svelte";
8
+ import ExtensionsComponents from "../../../components/extensionsComponents.svelte";
9
+
10
+ const { ctx, lobb } = getStudioContext();
9
11
 
10
12
  let { collectionName } = $props();
11
13
  let isSingletonCollection = $derived(ctx.meta.collections[collectionName].singleton);
@@ -19,7 +21,7 @@
19
21
  <!-- {#if true}
20
22
  <ExtensionsComponents
21
23
  name="studio.listView"
22
- utils={getExtensionUtils()}
24
+ utils={getExtensionUtils(lobb, ctx)}
23
25
  ></ExtensionsComponents>
24
26
  {:else if isSingletonCollection} -->
25
27
  {#if isSingletonCollection}
@@ -1,8 +1,10 @@
1
1
  <script lang="ts">
2
- import type { SideBarData } from "../../sidebar/sidebarElements.svelte";
3
- import Sidebar from "../../sidebar/sidebar.svelte";
4
- import { ctx } from "../../../store.svelte";
2
+ import type { SideBarData } from "../../../components/sidebar/sidebarElements.svelte";
3
+ import Sidebar from "../../../components/sidebar/sidebar.svelte";
4
+ import { getStudioContext } from "../../../context";
5
5
  import Collection from "./collection.svelte";
6
+
7
+ const { ctx } = getStudioContext();
6
8
  import { Table } from "lucide-svelte";
7
9
 
8
10
  let { collectionName } = $props();
@@ -1,10 +1,10 @@
1
1
  <script lang="ts">
2
2
  import { SvelteFlowProvider } from "@xyflow/svelte";
3
3
  import Flow from "./flow.svelte";
4
- import Sidebar from "../../sidebar/sidebar.svelte";
4
+ import Sidebar from "../../../components/sidebar/sidebar.svelte";
5
5
  import { location } from "@wjfe/n-savant";
6
6
  import SyncManager from "./syncManager.svelte";
7
- import SidebarTrigger from "../../sidebar/sidebarTrigger.svelte";
7
+ import SidebarTrigger from "../../../components/sidebar/sidebarTrigger.svelte";
8
8
 
9
9
  const currentPage = $derived(location.url.pathname.replace("/studio", "").split("/")[2]);
10
10
  </script>