@lobb-js/studio 0.9.2 → 0.10.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.
@@ -14,7 +14,6 @@
14
14
  loadExtensions,
15
15
  } from "../extensions/extensionUtils";
16
16
  import extensionMap from 'virtual:lobb-studio-extensions';
17
- import { STUDIO_VERSION } from "../version.ts";
18
17
  import { mediaQueries } from "../utils";
19
18
  import Home from "./routes/home.svelte";
20
19
  import DataModel from "./routes/data_model/dataModel.svelte";
@@ -33,7 +32,6 @@
33
32
  extensions: {},
34
33
  meta: null,
35
34
  currentUrl: new URL(window.location.href),
36
- studioVersion: STUDIO_VERSION,
37
35
  });
38
36
 
39
37
  const lobb = createLobb(lobbUrl ?? "");
@@ -29,9 +29,12 @@
29
29
  const isRefrenceField = Boolean(
30
30
  getFieldRelation(ctx, collectionName, fieldName),
31
31
  );
32
+ const isPasswordField = ctx.meta.collections[collectionName].fields[fieldName]?.ui?.input?.type === "password";
32
33
  </script>
33
34
 
34
- {#if value === ""}
35
+ {#if isPasswordField}
36
+ <div class="text-muted-foreground tracking-widest">••••••</div>
37
+ {:else if value === ""}
35
38
  <div class="text-muted-foreground">EMPTY STRING</div>
36
39
  {:else if value === null || value === undefined}
37
40
  <div class="text-muted-foreground">NULL</div>
@@ -33,6 +33,7 @@
33
33
  parseDetailViewValues,
34
34
  serializeEntry,
35
35
  } from "../utils";
36
+ import { getChangedProperties } from "../../../utils";
36
37
  import type { Snippet } from "svelte";
37
38
  import FieldInput from "../fieldInput.svelte";
38
39
  import { emitEvent } from "../../../eventSystem";
@@ -55,6 +56,7 @@
55
56
  let entry: Record<string, any> = $state(
56
57
  getDefaultEntry(ctx, fieldNames, collectionName, values),
57
58
  );
59
+ const initialEntry = $state.snapshot(entry);
58
60
  let fieldsErrors: Record<string, any> = $state({});
59
61
  const subCollections = ctx.meta.relations.filter((relation) => relation.to.collection === collectionName).map((relation) => relation.from.collection);
60
62
  const subCollectionsValues: Record<string, any> = {};
@@ -66,7 +68,7 @@
66
68
  }
67
69
 
68
70
  async function handleSave() {
69
- let localEntry = $state.snapshot(entry);
71
+ let localEntry = getChangedProperties(initialEntry, $state.snapshot(entry));
70
72
 
71
73
  await emitEvent({ lobb, ctx }, "studio.collections.preCreate", {
72
74
  collectionName,
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import CodeEditor from "../codeEditor.svelte";
3
3
  import RichTextEditor from "../richTextEditor.svelte";
4
+ import PasswordInput from "./passwordInput.svelte";
4
5
 
5
6
  interface Props {
6
7
  value: any;
@@ -23,4 +24,6 @@
23
24
  <CodeEditor name={field.key} {...args} bind:value />
24
25
  {:else if type === "richtext"}
25
26
  <RichTextEditor name={field.key} bind:value />
27
+ {:else if type === "password"}
28
+ <PasswordInput bind:value {destructive} />
26
29
  {/if}
@@ -0,0 +1,27 @@
1
+ <script lang="ts">
2
+ import Input from "../ui/input/input.svelte";
3
+
4
+ interface Props {
5
+ value: any;
6
+ destructive?: boolean;
7
+ }
8
+
9
+ let { value = $bindable(), destructive }: Props = $props();
10
+
11
+ const originalValue = value;
12
+ let displayValue = $state("");
13
+
14
+ function onInput(e: Event) {
15
+ const input = e.target as HTMLInputElement;
16
+ displayValue = input.value;
17
+ value = input.value || originalValue;
18
+ }
19
+ </script>
20
+
21
+ <Input
22
+ type="password"
23
+ placeholder="••••••"
24
+ class="bg-muted/30 text-xs {destructive ? 'border-destructive bg-destructive/10' : ''}"
25
+ value={displayValue}
26
+ oninput={onInput}
27
+ />
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ value: any;
3
+ destructive?: boolean;
4
+ }
5
+ declare const PasswordInput: import("svelte").Component<Props, {}, "value">;
6
+ type PasswordInput = ReturnType<typeof PasswordInput>;
7
+ export default PasswordInput;
@@ -9,7 +9,7 @@
9
9
 
10
10
  const { ctx } = getStudioContext();
11
11
 
12
- let releaseDates: Record<string, string | null> = $state({});
12
+ let coreReleaseDate: string | null = $state(null);
13
13
 
14
14
  async function fetchReleaseDate(pkg: string, version: string): Promise<string | null> {
15
15
  try {
@@ -23,28 +23,16 @@
23
23
  }
24
24
 
25
25
  onMount(async () => {
26
- const [coreDate, studioDate] = await Promise.all([
27
- fetchReleaseDate("@lobb-js/core", ctx.meta.version),
28
- ctx.studioVersion ? fetchReleaseDate("@lobb-js/studio", ctx.studioVersion) : Promise.resolve(null),
29
- ]);
30
- releaseDates = { core: coreDate, studio: studioDate };
26
+ coreReleaseDate = await fetchReleaseDate("@lobb-js/core", ctx.meta.version);
31
27
  });
32
28
  </script>
33
29
 
34
30
  <div class="flex justify-end p-2 text-xs text-muted-foreground/50">
35
31
  <div class="flex flex-col text-end gap-0.5">
36
- {#if ctx.studioVersion}
37
- <div>
38
- studio: v{ctx.studioVersion}
39
- {#if releaseDates.studio}
40
- <span>({timeAgo.format(new Date(releaseDates.studio!))})</span>
41
- {/if}
42
- </div>
43
- {/if}
44
32
  <div>
45
33
  core: v{ctx.meta.version}
46
- {#if releaseDates.core}
47
- <span>({timeAgo.format(new Date(releaseDates.core!))})</span>
34
+ {#if coreReleaseDate}
35
+ <span>({timeAgo.format(new Date(coreReleaseDate))})</span>
48
36
  {/if}
49
37
  </div>
50
38
  </div>
@@ -17,7 +17,6 @@ interface Meta {
17
17
  studio_workflows: any[];
18
18
  }
19
19
  export interface CTX {
20
- studioVersion?: string;
21
20
  lobbUrl: string | null;
22
21
  extensions: Record<string, Extension>;
23
22
  meta: Meta;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobb-js/studio",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,7 +14,6 @@
14
14
  loadExtensions,
15
15
  } from "../extensions/extensionUtils";
16
16
  import extensionMap from 'virtual:lobb-studio-extensions';
17
- import { STUDIO_VERSION } from "../version.ts";
18
17
  import { mediaQueries } from "../utils";
19
18
  import Home from "./routes/home.svelte";
20
19
  import DataModel from "./routes/data_model/dataModel.svelte";
@@ -33,7 +32,6 @@
33
32
  extensions: {},
34
33
  meta: null,
35
34
  currentUrl: new URL(window.location.href),
36
- studioVersion: STUDIO_VERSION,
37
35
  });
38
36
 
39
37
  const lobb = createLobb(lobbUrl ?? "");
@@ -29,9 +29,12 @@
29
29
  const isRefrenceField = Boolean(
30
30
  getFieldRelation(ctx, collectionName, fieldName),
31
31
  );
32
+ const isPasswordField = ctx.meta.collections[collectionName].fields[fieldName]?.ui?.input?.type === "password";
32
33
  </script>
33
34
 
34
- {#if value === ""}
35
+ {#if isPasswordField}
36
+ <div class="text-muted-foreground tracking-widest">••••••</div>
37
+ {:else if value === ""}
35
38
  <div class="text-muted-foreground">EMPTY STRING</div>
36
39
  {:else if value === null || value === undefined}
37
40
  <div class="text-muted-foreground">NULL</div>
@@ -33,6 +33,7 @@
33
33
  parseDetailViewValues,
34
34
  serializeEntry,
35
35
  } from "../utils";
36
+ import { getChangedProperties } from "../../../utils";
36
37
  import type { Snippet } from "svelte";
37
38
  import FieldInput from "../fieldInput.svelte";
38
39
  import { emitEvent } from "../../../eventSystem";
@@ -55,6 +56,7 @@
55
56
  let entry: Record<string, any> = $state(
56
57
  getDefaultEntry(ctx, fieldNames, collectionName, values),
57
58
  );
59
+ const initialEntry = $state.snapshot(entry);
58
60
  let fieldsErrors: Record<string, any> = $state({});
59
61
  const subCollections = ctx.meta.relations.filter((relation) => relation.to.collection === collectionName).map((relation) => relation.from.collection);
60
62
  const subCollectionsValues: Record<string, any> = {};
@@ -66,7 +68,7 @@
66
68
  }
67
69
 
68
70
  async function handleSave() {
69
- let localEntry = $state.snapshot(entry);
71
+ let localEntry = getChangedProperties(initialEntry, $state.snapshot(entry));
70
72
 
71
73
  await emitEvent({ lobb, ctx }, "studio.collections.preCreate", {
72
74
  collectionName,
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import CodeEditor from "../codeEditor.svelte";
3
3
  import RichTextEditor from "../richTextEditor.svelte";
4
+ import PasswordInput from "./passwordInput.svelte";
4
5
 
5
6
  interface Props {
6
7
  value: any;
@@ -23,4 +24,6 @@
23
24
  <CodeEditor name={field.key} {...args} bind:value />
24
25
  {:else if type === "richtext"}
25
26
  <RichTextEditor name={field.key} bind:value />
27
+ {:else if type === "password"}
28
+ <PasswordInput bind:value {destructive} />
26
29
  {/if}
@@ -0,0 +1,27 @@
1
+ <script lang="ts">
2
+ import Input from "../ui/input/input.svelte";
3
+
4
+ interface Props {
5
+ value: any;
6
+ destructive?: boolean;
7
+ }
8
+
9
+ let { value = $bindable(), destructive }: Props = $props();
10
+
11
+ const originalValue = value;
12
+ let displayValue = $state("");
13
+
14
+ function onInput(e: Event) {
15
+ const input = e.target as HTMLInputElement;
16
+ displayValue = input.value;
17
+ value = input.value || originalValue;
18
+ }
19
+ </script>
20
+
21
+ <Input
22
+ type="password"
23
+ placeholder="••••••"
24
+ class="bg-muted/30 text-xs {destructive ? 'border-destructive bg-destructive/10' : ''}"
25
+ value={displayValue}
26
+ oninput={onInput}
27
+ />
@@ -9,7 +9,7 @@
9
9
 
10
10
  const { ctx } = getStudioContext();
11
11
 
12
- let releaseDates: Record<string, string | null> = $state({});
12
+ let coreReleaseDate: string | null = $state(null);
13
13
 
14
14
  async function fetchReleaseDate(pkg: string, version: string): Promise<string | null> {
15
15
  try {
@@ -23,28 +23,16 @@
23
23
  }
24
24
 
25
25
  onMount(async () => {
26
- const [coreDate, studioDate] = await Promise.all([
27
- fetchReleaseDate("@lobb-js/core", ctx.meta.version),
28
- ctx.studioVersion ? fetchReleaseDate("@lobb-js/studio", ctx.studioVersion) : Promise.resolve(null),
29
- ]);
30
- releaseDates = { core: coreDate, studio: studioDate };
26
+ coreReleaseDate = await fetchReleaseDate("@lobb-js/core", ctx.meta.version);
31
27
  });
32
28
  </script>
33
29
 
34
30
  <div class="flex justify-end p-2 text-xs text-muted-foreground/50">
35
31
  <div class="flex flex-col text-end gap-0.5">
36
- {#if ctx.studioVersion}
37
- <div>
38
- studio: v{ctx.studioVersion}
39
- {#if releaseDates.studio}
40
- <span>({timeAgo.format(new Date(releaseDates.studio!))})</span>
41
- {/if}
42
- </div>
43
- {/if}
44
32
  <div>
45
33
  core: v{ctx.meta.version}
46
- {#if releaseDates.core}
47
- <span>({timeAgo.format(new Date(releaseDates.core!))})</span>
34
+ {#if coreReleaseDate}
35
+ <span>({timeAgo.format(new Date(coreReleaseDate))})</span>
48
36
  {/if}
49
37
  </div>
50
38
  </div>
@@ -20,7 +20,6 @@ interface Meta {
20
20
  }
21
21
 
22
22
  export interface CTX {
23
- studioVersion?: string;
24
23
  lobbUrl: string | null;
25
24
  extensions: Record<string, Extension>;
26
25
  meta: Meta;
package/dist/version.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const STUDIO_VERSION: string;
package/dist/version.js DELETED
@@ -1,2 +0,0 @@
1
- import pkg from "../../package.json" assert { type: "json" };
2
- export var STUDIO_VERSION = pkg.version;
@@ -1,2 +0,0 @@
1
- import pkg from "../../package.json" assert { type: "json" };
2
- export const STUDIO_VERSION: string = pkg.version;