@mediansh/widget 0.2.1 → 0.5.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.
package/dist/index.d.ts CHANGED
@@ -69,8 +69,7 @@ type MedianUser = {
69
69
  metadata?: Record<string, string>;
70
70
  };
71
71
 
72
- type MedianSupportProps = {
73
- apiKey: string;
72
+ type MedianSupportOptions = {
74
73
  /** Who is signed in on the host's site, if anyone. Shown to the team. */
75
74
  user?: MedianUser;
76
75
  /**
@@ -119,6 +118,22 @@ type MedianSupportProps = {
119
118
  * redeploy, and either side saying no is enough to keep it away.
120
119
  */
121
120
  requireEmail?: boolean;
121
+ /**
122
+ * Show the first lines of an unread reply on the closed button. On by
123
+ * default: the count says something arrived, and the card is what says
124
+ * whether it is worth opening.
125
+ *
126
+ * <MedianSupport apiKey="median_pk_..." messagePreview={false} />
127
+ *
128
+ * Pass `false` and the corner stays a button with a count on it. Nothing
129
+ * else changes: the reply is still there, still counted, still announced.
130
+ * For a page where a customer's words should never appear unprompted,
131
+ * over somebody's shoulder or in a screen share.
132
+ *
133
+ * Your team can turn it off from the dashboard without a redeploy, and
134
+ * either side saying no is enough to keep the card away.
135
+ */
136
+ messagePreview?: boolean;
122
137
  /**
123
138
  * Watch what goes wrong on the page, so a bug report arrives with the
124
139
  * error already attached instead of after four messages of asking.
@@ -175,6 +190,25 @@ type MedianSupportProps = {
175
190
  */
176
191
  onNavigate?: (path: string) => void;
177
192
  };
193
+ /**
194
+ * Two ways in, and every app has one of them.
195
+ *
196
+ * `apiKey` is the publishable id, and on its own it opens an anonymous
197
+ * thread. `identity` is the path to a route built with `medianIdentity`,
198
+ * which answers with the key and with whoever is signed in, already signed.
199
+ * A framework that renders its root layout on the server cannot hand this
200
+ * component a session any other way, so that is most of them.
201
+ *
202
+ * Passing both is worth it on a slow session: the button is up on the key
203
+ * from the prop straight away, and the person arrives when the route answers.
204
+ */
205
+ type MedianSupportProps = MedianSupportOptions & ({
206
+ apiKey: string;
207
+ identity?: string;
208
+ } | {
209
+ apiKey?: string;
210
+ identity: string;
211
+ });
178
212
  /**
179
213
  * The whole SDK, as one component. Drop it on a page with your publishable API
180
214
  * key and the launcher, the thread, the AI and the inbox on the other side are
@@ -380,8 +414,7 @@ type MedianSupportControl = {
380
414
  */
381
415
  declare function useMedianSupport(): MedianSupportControl;
382
416
 
383
- type MedianFeedbackProps = {
384
- apiKey: string;
417
+ type MedianFeedbackOptions = {
385
418
  /**
386
419
  * Your own trigger. Whatever you pass is rendered where you put it and the
387
420
  * panel hangs off it, the way a dropdown hangs off the thing that opens
@@ -444,6 +477,34 @@ type MedianFeedbackProps = {
444
477
  description?: string;
445
478
  placeholder?: string;
446
479
  };
480
+ /**
481
+ * Two ways in, the same two `<MedianSupport>` takes.
482
+ *
483
+ * `apiKey` is the publishable id on its own. `identity` is the path to a
484
+ * route built with `medianIdentity`, which answers with the key and with
485
+ * whoever is signed in, already signed. Pass both and the panel is usable on
486
+ * the key from the prop while the route is still answering.
487
+ */
488
+ type MedianFeedbackProps = MedianFeedbackOptions & ({
489
+ apiKey: string;
490
+ identity?: string;
491
+ } | {
492
+ apiKey?: string;
493
+ identity: string;
494
+ });
495
+ /**
496
+ * The same two ways in, for a host without JSX. Spelled out rather than
497
+ * `Omit`ped off the props above, because omitting a key from a union of two
498
+ * shapes flattens it into one and loses the "either, but not neither" the
499
+ * union is there to say.
500
+ */
501
+ type MedianFeedbackMountOptions = Omit<MedianFeedbackOptions, "children"> & ({
502
+ apiKey: string;
503
+ identity?: string;
504
+ } | {
505
+ apiKey?: string;
506
+ identity: string;
507
+ });
447
508
  /**
448
509
  * A feedback panel, hung off a trigger of your own.
449
510
  *
@@ -493,7 +554,7 @@ type MedianFeedbackInstance = {
493
554
  * right corner and your own button says when. Everything else is the
494
555
  * component's, unchanged.
495
556
  */
496
- declare function mountMedianFeedback(options: Omit<MedianFeedbackProps, "children">): MedianFeedbackInstance;
557
+ declare function mountMedianFeedback(options: MedianFeedbackMountOptions): MedianFeedbackInstance;
497
558
 
498
559
  declare const medianFeedback: {
499
560
  /** What the panel is doing right now. */