@axium/notes 0.3.11 → 0.3.13

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/lib/Note.svelte CHANGED
@@ -5,10 +5,16 @@
5
5
  import { dynamicRows } from '@axium/client/attachments';
6
6
  import { AccessControlDialog, Icon, Popover } from '@axium/client/components';
7
7
  import { copy } from '@axium/client/gui';
8
+ import { toastStatus } from '@axium/client/toast';
8
9
  import type { Note } from '@axium/notes/common';
9
10
  import { download } from 'utilium/dom.js';
10
11
 
11
- let { note = $bindable(), notes = $bindable(), pageMode = false }: { note: Note; notes?: Note[]; pageMode?: boolean } = $props();
12
+ let {
13
+ note = $bindable(),
14
+ notes = $bindable(),
15
+ pageMode = false,
16
+ user,
17
+ }: { note: Note; notes?: Note[]; pageMode?: boolean; user?: UserPublic } = $props();
12
18
 
13
19
  let acl = $state<HTMLDialogElement>();
14
20
  </script>
@@ -29,10 +35,13 @@
29
35
  <div
30
36
  class="menu-item"
31
37
  onclick={() =>
32
- fetchAPI('DELETE', 'notes/:id', {}, note.id).then(() => {
33
- if (!notes) goto('/notes');
34
- else notes.splice(notes.indexOf(note), 1);
35
- })}
38
+ toastStatus(
39
+ fetchAPI('DELETE', 'notes/:id', {}, note.id).then(() => {
40
+ if (!notes) goto('/notes');
41
+ else notes.splice(notes.indexOf(note), 1);
42
+ }),
43
+ text('notes.toast_deleted')
44
+ )}
36
45
  >
37
46
  <Icon i="trash" />
38
47
  <span>{text('generic.delete')}</span>
@@ -68,7 +77,7 @@
68
77
  </div>
69
78
  {/if}
70
79
  </Popover>
71
- <AccessControlDialog bind:dialog={acl} item={note} itemType="notes" editable />
80
+ <AccessControlDialog bind:dialog={acl} item={note} itemType="notes" {user} />
72
81
  </div>
73
82
  <textarea
74
83
  bind:value={note.content}
package/locales/en.json CHANGED
@@ -11,6 +11,7 @@
11
11
  "new": "New Note",
12
12
  "note_title": "Notes — {title}",
13
13
  "open_new_tab": "Open in New Tab",
14
- "share": "Share"
14
+ "share": "Share",
15
+ "toast_deleted": "Note deleted"
15
16
  }
16
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/notes",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "Notes for Axium",
6
6
  "funding": {
@@ -36,8 +36,8 @@
36
36
  "build": "tsc"
37
37
  },
38
38
  "peerDependencies": {
39
- "@axium/client": ">=0.18.0",
40
- "@axium/core": ">=0.19.0",
39
+ "@axium/client": ">=0.20.0",
40
+ "@axium/core": ">=0.23.0",
41
41
  "@axium/server": ">=0.35.0",
42
42
  "@sveltejs/kit": "^2.27.3",
43
43
  "utilium": "^2.4.0"
@@ -1,8 +1,8 @@
1
1
  import { getCurrentSession } from '@axium/client/user';
2
- import type { Session } from '@axium/core';
2
+ import type { Session, UserPublic } from '@axium/core';
3
3
 
4
4
  export async function load({ parent }) {
5
- let { session }: { session?: Session | null } = await parent();
5
+ let { session }: { session?: (Session & { user: UserPublic }) | null } = await parent();
6
6
 
7
7
  session ||= await getCurrentSession().catch(() => null);
8
8
 
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { fetchAPI, text } from '@axium/client';
3
3
  import { Icon } from '@axium/client/components';
4
+ import { toast } from '@axium/client/toast';
4
5
  import { Note } from '@axium/notes/components';
5
6
 
6
7
  const { data } = $props();
@@ -18,8 +19,12 @@
18
19
  id="create-note"
19
20
  class="icon-text mobile-float-right"
20
21
  onclick={async () => {
21
- const result = await fetchAPI('PUT', 'users/:id/notes', { title: '' }, data.session.userId);
22
- notes.push(result);
22
+ try {
23
+ const result = await fetchAPI('PUT', 'users/:id/notes', { title: '' }, data.session.userId);
24
+ notes.push(result);
25
+ } catch (e) {
26
+ toast('error', e);
27
+ }
23
28
  }}
24
29
  >
25
30
  <Icon i="plus" />
@@ -27,7 +32,7 @@
27
32
  </button>
28
33
  <div class="lists-container">
29
34
  {#each notes as note}
30
- <Note {note} bind:notes />
35
+ <Note {note} bind:notes user={data.session?.user} />
31
36
  {/each}
32
37
  </div>
33
38
  </div>
@@ -34,7 +34,7 @@
34
34
  </div>
35
35
  {/if}
36
36
 
37
- <Note note={data.note} pageMode />
37
+ <Note note={data.note} pageMode user={data.session?.user} />
38
38
  </div>
39
39
 
40
40
  <style>