@atmo-dev/kit 0.16.0 → 0.17.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.
@@ -40,7 +40,10 @@
40
40
  viewer,
41
41
  initialTheme,
42
42
  prefill = null,
43
- mediaUrl = getCDNImageBlobUrl
43
+ mediaUrl = getCDNImageBlobUrl,
44
+ visibility = $bindable('public'),
45
+ visibilityOptions = ['public', 'unlisted'],
46
+ confirmVisibility
44
47
  }: {
45
48
  eventData: FlatEventRecord | null;
46
49
  actorDid: string;
@@ -53,6 +56,12 @@
53
56
  prefill?: EventEditorPrefill | null;
54
57
  /** Where the editor loads the event's current image from; the public CDN by default. */
55
58
  mediaUrl?: EventMediaUrl;
59
+ /** Who can see the event. Bind it to follow the host's choice; an existing event's record sets it. */
60
+ visibility?: Visibility;
61
+ /** The choices the switch offers, in order. Public and Unlisted by default. */
62
+ visibilityOptions?: readonly Visibility[];
63
+ /** Asked before the choice changes; returning false keeps the current one. */
64
+ confirmVisibility?: (next: Visibility) => boolean | Promise<boolean>;
56
65
  } = $props();
57
66
 
58
67
  let isNew = $derived(eventData === null);
@@ -79,7 +88,6 @@
79
88
  );
80
89
  let timezone = $state(initialTimezone);
81
90
  let mode: EventMode = $state(initialPrefill?.mode ?? 'inperson');
82
- let visibility: Visibility = $state('public');
83
91
  // svelte-ignore state_referenced_locally
84
92
  let eventTheme: EventTheme = $state(
85
93
  eventData === null
@@ -124,6 +132,16 @@
124
132
  ];
125
133
  });
126
134
  let showVisibility = $derived(adapter.features.visibility !== false);
135
+ const VISIBILITY_LABELS: Record<Visibility, string> = {
136
+ public: 'Public',
137
+ unlisted: 'Unlisted',
138
+ private: 'Private'
139
+ };
140
+ async function chooseVisibility(next: Visibility) {
141
+ if (next === visibility) return;
142
+ if (confirmVisibility && !(await confirmVisibility(next))) return;
143
+ visibility = next;
144
+ }
127
145
  let submitting = $state(false);
128
146
  let error: string | null = $state(null);
129
147
  let titleEditor = $state<Editor | null>(null);
@@ -438,20 +456,23 @@
438
456
  bind:value={
439
457
  () => visibility,
440
458
  (val) => {
441
- if (val) visibility = val as Visibility;
459
+ if (val) void chooseVisibility(val as Visibility);
442
460
  }
443
461
  }
444
462
  class="w-fit"
445
463
  size="xs"
446
464
  >
447
- <ToggleGroupItem value="public">Public</ToggleGroupItem>
448
- <ToggleGroupItem value="unlisted">Unlisted</ToggleGroupItem>
465
+ {#each visibilityOptions as option (option)}
466
+ <ToggleGroupItem value={option}>{VISIBILITY_LABELS[option]}</ToggleGroupItem>
467
+ {/each}
449
468
  </ToggleGroup>
450
469
  <div class="mt-1.5 text-xs text-base-600 dark:text-base-400">
451
470
  {#if visibility === 'public'}
452
471
  Anyone can view and it appears in discovery.
453
- {:else}
472
+ {:else if visibility === 'unlisted'}
454
473
  Public to anyone with the link, but hidden from discovery.
474
+ {:else}
475
+ Only people you invite can see it.
455
476
  {/if}
456
477
  </div>
457
478
  </div>
@@ -1,7 +1,7 @@
1
1
  import { type EventMediaUrl } from './event-media.js';
2
2
  import type { FlatEventRecord } from './contrail.js';
3
3
  import { type EventTheme } from './theme.js';
4
- import { type EventEditorPrefill } from './editor/types';
4
+ import { type EventEditorPrefill, type Visibility } from './editor/types';
5
5
  import type { EditorAdapter, EditorViewer } from './editor/adapter';
6
6
  type $$ComponentProps = {
7
7
  eventData: FlatEventRecord | null;
@@ -15,7 +15,13 @@ type $$ComponentProps = {
15
15
  prefill?: EventEditorPrefill | null;
16
16
  /** Where the editor loads the event's current image from; the public CDN by default. */
17
17
  mediaUrl?: EventMediaUrl;
18
+ /** Who can see the event. Bind it to follow the host's choice; an existing event's record sets it. */
19
+ visibility?: Visibility;
20
+ /** The choices the switch offers, in order. Public and Unlisted by default. */
21
+ visibilityOptions?: readonly Visibility[];
22
+ /** Asked before the choice changes; returning false keeps the current one. */
23
+ confirmVisibility?: (next: Visibility) => boolean | Promise<boolean>;
18
24
  };
19
- declare const EventEditor: import("svelte").Component<$$ComponentProps, {}, "">;
25
+ declare const EventEditor: import("svelte").Component<$$ComponentProps, {}, "visibility">;
20
26
  type EventEditor = ReturnType<typeof EventEditor>;
21
27
  export default EventEditor;
@@ -43,8 +43,8 @@ export type EditorAdapter = {
43
43
  */
44
44
  images?: boolean;
45
45
  /**
46
- * False for an event with no public listing to appear in: no Public / Unlisted switch, and
47
- * the record's discovery preference is left as it is.
46
+ * False for an event with no public listing to appear in: no visibility switch, and the
47
+ * record's discovery preference is left as it is.
48
48
  */
49
49
  visibility?: boolean;
50
50
  };
@@ -158,13 +158,14 @@ export async function buildEventRecord(args) {
158
158
  if (Array.isArray(record.locations)) {
159
159
  record.locations = normalizeEventLocations(record.locations);
160
160
  }
161
- // With no Public / Unlisted choice offered, the record keeps whatever preference it had.
161
+ // With no visibility choice offered, the record keeps whatever preference it had. Only a public
162
+ // event appears in discovery.
162
163
  if (visibility !== null) {
163
164
  const existingPrefs = (record.preferences ??
164
165
  {});
165
166
  record.preferences = {
166
167
  ...existingPrefs,
167
- showInDiscovery: visibility !== 'unlisted'
168
+ showInDiscovery: visibility === 'public'
168
169
  };
169
170
  }
170
171
  return record;
@@ -1,5 +1,5 @@
1
1
  export type EventMode = 'inperson' | 'virtual' | 'hybrid';
2
- export type Visibility = 'public' | 'unlisted';
2
+ export type Visibility = 'public' | 'unlisted' | 'private';
3
3
  export interface EventLocation {
4
4
  street?: string;
5
5
  locality?: string;
@@ -1,7 +1,7 @@
1
1
  /** Event types and pure helpers. Safe to import without Svelte, CSS or browser players. */
2
2
  export type { EventViewData } from './events/view-data.js';
3
3
  export type { EditorAdapter, EditorBlobRef, EditorViewer } from './events/editor/adapter.js';
4
- export type { EventEditorPrefill } from './events/editor/types.js';
4
+ export type { EventEditorPrefill, Visibility as EventVisibility } from './events/editor/types.js';
5
5
  export type { EventData, EventLexiconMain, EventLocationVariant, EventStatus, EventMode as EventLexiconMode } from './events/event-types.js';
6
6
  export type { FlatEventRecord, HostProfile, AttendeeInfo, AttendeeListLoader } from './events/contrail.js';
7
7
  export { eventUrl, isEventOngoing, RSVP_GOING, RSVP_INTERESTED } from './events/contrail.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmo-dev/kit",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "The shared UI foundation for Atmo apps.",
5
5
  "license": "MIT",
6
6
  "repository": {