@krak-stack/registry 0.10.14 → 0.10.16

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.
@@ -1,9 +1,8 @@
1
- // ../../src/components/support-dialog.tsx
2
- import { Dialog as DialogPrimitive2 } from "@base-ui/react/dialog";
1
+ // ../../src/components/support.tsx
3
2
  import { Effect, FileSystem, Result, Schema } from "effect";
4
3
  import { Multipart } from "effect/http";
5
4
  import { HttpApiSchema } from "effect/http-api";
6
- import { ImageIcon, Paperclip, XIcon as XIcon2 } from "lucide-react";
5
+ import { CheckIcon as CheckIcon2, ImageIcon, Paperclip, XIcon as XIcon2 } from "lucide-react";
7
6
  import {
8
7
  useId,
9
8
  useRef,
@@ -160,30 +159,49 @@ function AttachmentAction({
160
159
  });
161
160
  }
162
161
 
162
+ // ../../src/components/ui/checkbox.tsx
163
+ import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
164
+ import { CheckIcon } from "lucide-react";
165
+ import { jsx as jsx3 } from "react/jsx-runtime";
166
+ "use client";
167
+ function Checkbox({ className, ...props }) {
168
+ return /* @__PURE__ */ jsx3(CheckboxPrimitive.Root, {
169
+ "data-slot": "checkbox",
170
+ className: cn("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary", className),
171
+ ...props,
172
+ children: /* @__PURE__ */ jsx3(CheckboxPrimitive.Indicator, {
173
+ "data-slot": "checkbox-indicator",
174
+ className: "grid place-content-center text-current transition-none [&>svg]:size-3.5",
175
+ children: /* @__PURE__ */ jsx3(CheckIcon, {})
176
+ })
177
+ });
178
+ }
179
+
163
180
  // ../../src/components/ui/dialog.tsx
164
181
  import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
182
+ import { cn as cn2 } from "cn";
165
183
  import { XIcon } from "lucide-react";
166
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
184
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
167
185
  function Dialog({ ...props }) {
168
- return /* @__PURE__ */ jsx3(DialogPrimitive.Root, {
186
+ return /* @__PURE__ */ jsx4(DialogPrimitive.Root, {
169
187
  "data-slot": "dialog",
170
188
  ...props
171
189
  });
172
190
  }
173
191
  function DialogTrigger({ ...props }) {
174
- return /* @__PURE__ */ jsx3(DialogPrimitive.Trigger, {
192
+ return /* @__PURE__ */ jsx4(DialogPrimitive.Trigger, {
175
193
  "data-slot": "dialog-trigger",
176
194
  ...props
177
195
  });
178
196
  }
179
197
  function DialogPortal({ ...props }) {
180
- return /* @__PURE__ */ jsx3(DialogPrimitive.Portal, {
198
+ return /* @__PURE__ */ jsx4(DialogPrimitive.Portal, {
181
199
  "data-slot": "dialog-portal",
182
200
  ...props
183
201
  });
184
202
  }
185
203
  function DialogClose({ ...props }) {
186
- return /* @__PURE__ */ jsx3(DialogPrimitive.Close, {
204
+ return /* @__PURE__ */ jsx4(DialogPrimitive.Close, {
187
205
  "data-slot": "dialog-close",
188
206
  ...props
189
207
  });
@@ -192,52 +210,120 @@ function DialogOverlay({
192
210
  className,
193
211
  ...props
194
212
  }) {
195
- return /* @__PURE__ */ jsx3(DialogPrimitive.Backdrop, {
213
+ return /* @__PURE__ */ jsx4(DialogPrimitive.Backdrop, {
196
214
  "data-slot": "dialog-overlay",
197
- className: cn("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", className),
215
+ className: cn2("data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs", className),
198
216
  ...props
199
217
  });
200
218
  }
219
+ function DialogContent({
220
+ className,
221
+ children,
222
+ showCloseButton = true,
223
+ ...props
224
+ }) {
225
+ return /* @__PURE__ */ jsxs(DialogPortal, {
226
+ children: [
227
+ /* @__PURE__ */ jsx4(DialogOverlay, {}),
228
+ /* @__PURE__ */ jsxs(DialogPrimitive.Popup, {
229
+ "data-slot": "dialog-content",
230
+ className: cn2("bg-popover text-popover-foreground ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl p-6 text-sm ring-1 duration-100 outline-none sm:max-w-md", className),
231
+ ...props,
232
+ children: [
233
+ children,
234
+ showCloseButton && /* @__PURE__ */ jsxs(DialogPrimitive.Close, {
235
+ "data-slot": "dialog-close",
236
+ render: /* @__PURE__ */ jsx4(Button, {
237
+ variant: "ghost",
238
+ className: "absolute top-4 right-4",
239
+ size: "icon-sm"
240
+ }),
241
+ children: [
242
+ /* @__PURE__ */ jsx4(XIcon, {}),
243
+ /* @__PURE__ */ jsx4("span", {
244
+ className: "sr-only",
245
+ children: "Close"
246
+ })
247
+ ]
248
+ })
249
+ ]
250
+ })
251
+ ]
252
+ });
253
+ }
201
254
  function DialogHeader({ className, ...props }) {
202
- return /* @__PURE__ */ jsx3("div", {
255
+ return /* @__PURE__ */ jsx4("div", {
203
256
  "data-slot": "dialog-header",
204
- className: cn("grid gap-1.5", className),
257
+ className: cn2("flex flex-col gap-2", className),
205
258
  ...props
206
259
  });
207
260
  }
208
- function DialogFooter({ className, ...props }) {
209
- return /* @__PURE__ */ jsx3("div", {
210
- "data-slot": "dialog-footer",
211
- className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
261
+ function DialogTitle({ className, ...props }) {
262
+ return /* @__PURE__ */ jsx4(DialogPrimitive.Title, {
263
+ "data-slot": "dialog-title",
264
+ className: cn2("leading-none font-medium", className),
212
265
  ...props
213
266
  });
214
267
  }
215
- function DialogTitle({
268
+ function DialogDescription({
216
269
  className,
217
270
  ...props
218
271
  }) {
219
- return /* @__PURE__ */ jsx3(DialogPrimitive.Title, {
220
- "data-slot": "dialog-title",
221
- className: cn("text-lg font-medium", className),
272
+ return /* @__PURE__ */ jsx4(DialogPrimitive.Description, {
273
+ "data-slot": "dialog-description",
274
+ className: cn2("text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3", className),
222
275
  ...props
223
276
  });
224
277
  }
225
- function DialogDescription({
278
+
279
+ // ../../src/components/ui/field.tsx
280
+ import { useMemo } from "react";
281
+ import { cva as cva3 } from "class-variance-authority";
282
+
283
+ // ../../src/components/ui/label.tsx
284
+ import { jsx as jsx5 } from "react/jsx-runtime";
285
+ "use client";
286
+ function Label({ className, ...props }) {
287
+ return /* @__PURE__ */ jsx5("label", {
288
+ "data-slot": "label",
289
+ className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
290
+ ...props
291
+ });
292
+ }
293
+
294
+ // ../../src/components/ui/separator.tsx
295
+ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
296
+
297
+ // ../../src/components/ui/field.tsx
298
+ import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
299
+ var fieldVariants = cva3("group/field flex w-full gap-3 data-[invalid=true]:text-destructive", {
300
+ variants: {
301
+ orientation: {
302
+ vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
303
+ horizontal: "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
304
+ responsive: "flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
305
+ }
306
+ },
307
+ defaultVariants: {
308
+ orientation: "vertical"
309
+ }
310
+ });
311
+ function FieldLabel({
226
312
  className,
227
313
  ...props
228
314
  }) {
229
- return /* @__PURE__ */ jsx3(DialogPrimitive.Description, {
230
- "data-slot": "dialog-description",
231
- className: cn("text-sm text-muted-foreground", className),
315
+ return /* @__PURE__ */ jsx6(Label, {
316
+ "data-slot": "field-label",
317
+ className: cn("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-3 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col", className),
232
318
  ...props
233
319
  });
234
320
  }
235
321
 
236
322
  // ../../src/components/ui/input.tsx
237
323
  import { Input as InputPrimitive } from "@base-ui/react/input";
238
- import { jsx as jsx4 } from "react/jsx-runtime";
324
+ import { jsx as jsx7 } from "react/jsx-runtime";
239
325
  function Input({ className, type, ...props }) {
240
- return /* @__PURE__ */ jsx4(InputPrimitive, {
326
+ return /* @__PURE__ */ jsx7(InputPrimitive, {
241
327
  type,
242
328
  "data-slot": "input",
243
329
  className: cn("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
@@ -245,34 +331,24 @@ function Input({ className, type, ...props }) {
245
331
  });
246
332
  }
247
333
 
248
- // ../../src/components/support-dialog.tsx
334
+ // ../../src/components/support.tsx
249
335
  import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
250
336
 
251
- // ../../src/components/ui/label.tsx
252
- import { jsx as jsx5 } from "react/jsx-runtime";
253
- "use client";
254
- function Label({ className, ...props }) {
255
- return /* @__PURE__ */ jsx5("label", {
256
- "data-slot": "label",
257
- className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
258
- ...props
259
- });
260
- }
261
-
262
337
  // ../../src/components/ui/textarea.tsx
263
- import { jsx as jsx6 } from "react/jsx-runtime";
338
+ import { jsx as jsx8 } from "react/jsx-runtime";
264
339
  function Textarea({ className, ...props }) {
265
- return /* @__PURE__ */ jsx6("textarea", {
340
+ return /* @__PURE__ */ jsx8("textarea", {
266
341
  "data-slot": "textarea",
267
342
  className: cn("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
268
343
  ...props
269
344
  });
270
345
  }
271
346
 
272
- // ../../src/components/support-dialog.tsx
273
- import { jsx as jsx7, jsxs as jsxs2, Fragment } from "react/jsx-runtime";
347
+ // ../../src/components/support.tsx
348
+ import { jsx as jsx9, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
274
349
  var supportMessageLimit = 5000;
275
350
  var supportReplyEmailLimit = 254;
351
+ var supportErrorDetailsLimit = 8000;
276
352
  var supportScreenshotLimit = 3;
277
353
  var supportScreenshotMaxBytes = 5 * 1024 * 1024;
278
354
  var screenshotFormats = new Map([
@@ -296,17 +372,20 @@ var screenshotAccept = Array.from(screenshotFormats.keys()).join(",");
296
372
  var SupportMessage = Schema.Trim.check(Schema.isNonEmpty(), Schema.isMaxLength(supportMessageLimit)).annotate({ identifier: "SupportMessage" });
297
373
  var SupportReplyEmail = Schema.Trim.check(Schema.isMaxLength(supportReplyEmailLimit), Schema.isPattern(/^[^\s@,<>]+@[^\s@,<>]+$/)).annotate({ identifier: "SupportReplyEmail" });
298
374
  var SupportScreenshots = Schema.Array(Schema.File.check(Schema.makeFilter((file) => screenshotFormats.has(file.type) && file.size > 0 && file.size <= supportScreenshotMaxBytes))).check(Schema.isMaxLength(supportScreenshotLimit)).annotate({ identifier: "SupportScreenshots" });
375
+ var SupportErrorDetails = Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(supportErrorDetailsLimit)).annotate({ identifier: "SupportErrorDetails" });
299
376
  var SupportRequestSchema = Schema.Struct({
300
377
  message: SupportMessage,
301
378
  replyEmail: Schema.optionalKey(SupportReplyEmail),
379
+ errorDetails: Schema.optionalKey(SupportErrorDetails),
302
380
  attachments: SupportScreenshots
303
381
  }).annotate({ identifier: "SupportRequest" });
304
382
  var SupportMultipartPayload = Schema.Struct({
305
383
  message: SupportMessage,
306
384
  replyEmail: Schema.optionalKey(SupportReplyEmail),
385
+ errorDetails: Schema.optionalKey(SupportErrorDetails),
307
386
  attachments: Schema.optionalKey(Multipart.FilesSchema.check(Schema.isMaxLength(supportScreenshotLimit)))
308
387
  }).annotate({ identifier: "SupportMultipartPayload" }).pipe(HttpApiSchema.asMultipart({
309
- maxParts: supportScreenshotLimit + 2,
388
+ maxParts: supportScreenshotLimit + 3,
310
389
  maxFieldSize: 32 * 1024,
311
390
  maxFileSize: supportScreenshotMaxBytes,
312
391
  maxTotalSize: supportScreenshotLimit * supportScreenshotMaxBytes + 1024 * 1024
@@ -337,70 +416,119 @@ var labels = {
337
416
  description: "Share any details that will help us answer your question or understand what went wrong.",
338
417
  placeholder: "I need help with…",
339
418
  replyEmail: "Reply email",
419
+ replyEmailPlaceholder: "you@example.com",
340
420
  attach: "Attach screenshots",
341
421
  invalidAttachments: "Screenshots weren’t added. Choose up to 3 PNG, JPEG or WebP images, 5 MB each.",
342
422
  removeAttachment: "Remove screenshot",
343
423
  submit: "Send message",
344
424
  pending: "Sending…",
345
- success: "Your message was sent.",
425
+ success: "Message sent",
426
+ successDescription: "We will get back to you as soon as possible.",
346
427
  close: "Close",
347
428
  invalid: "Check your message and reply email if requested.",
348
- failed: "Could not send your message. Try again."
429
+ failed: "Could not send your message. Try again.",
430
+ includeErrorDetails: "Include error details",
431
+ optional: "optional",
432
+ directEmail: "Or email us directly at"
349
433
  },
350
434
  fr: {
351
435
  title: "Dites-nous comment nous pouvons vous aider",
352
436
  description: "Donnez-nous les détails qui nous aideront à répondre à votre question ou à comprendre le problème.",
353
437
  placeholder: "J’ai besoin d’aide pour…",
354
438
  replyEmail: "Adresse courriel pour la réponse",
439
+ replyEmailPlaceholder: "vous@example.com",
355
440
  attach: "Joindre des captures d’écran",
356
441
  invalidAttachments: "Les captures d’écran n’ont pas été ajoutées. Choisissez jusqu’à 3 images PNG, JPEG ou WebP de 5 Mo chacune.",
357
442
  removeAttachment: "Retirer la capture d’écran",
358
443
  submit: "Envoyer le message",
359
444
  pending: "Envoi en cours…",
360
- success: "Votre message a été envoyé.",
445
+ success: "Message envoyé",
446
+ successDescription: "Nous vous répondrons dès que possible.",
361
447
  close: "Fermer",
362
448
  invalid: "Vérifiez le message et, si elle est demandée, l’adresse courriel.",
363
- failed: "Impossible d’envoyer votre message. Réessayez."
449
+ failed: "Impossible d’envoyer votre message. Réessayez.",
450
+ includeErrorDetails: "Inclure les détails de l’erreur",
451
+ optional: "facultatif",
452
+ directEmail: "Ou écrivez-nous directement à"
364
453
  }
365
454
  };
366
- var SupportDialog = ({
367
- locale: localeOverride,
368
- messages,
369
- trigger,
370
- askForReplyEmail = false,
371
- onSubmit
372
- }) => {
455
+ var useSupportFormMessages = (localeOverride, messages) => {
373
456
  const locale = useKrakstackLocale(localeOverride);
374
457
  const language = locale.split("-")[0] ?? locale;
375
- const copy = {
458
+ return {
376
459
  ...language === "fr" ? labels.fr : labels.en,
377
460
  ...messages?.[language],
378
461
  ...messages?.[locale]
379
462
  };
463
+ };
464
+ var FieldLabel2 = ({
465
+ htmlFor,
466
+ children,
467
+ optional,
468
+ optionalText
469
+ }) => /* @__PURE__ */ jsxs3(FieldLabel, {
470
+ htmlFor,
471
+ children: [
472
+ children,
473
+ optional && /* @__PURE__ */ jsxs3("span", {
474
+ className: "text-muted-foreground font-normal",
475
+ children: [
476
+ " ",
477
+ "(",
478
+ optionalText,
479
+ ")"
480
+ ]
481
+ })
482
+ ]
483
+ });
484
+ var SupportCheck = () => /* @__PURE__ */ jsx9("span", {
485
+ className: "bg-primary/10 text-primary mb-1 grid size-12 place-items-center rounded-full",
486
+ children: /* @__PURE__ */ jsx9(CheckIcon2, {
487
+ className: "size-6",
488
+ "aria-hidden": "true"
489
+ })
490
+ });
491
+ var SupportConfirmation = ({
492
+ title,
493
+ description
494
+ }) => /* @__PURE__ */ jsxs3("div", {
495
+ role: "status",
496
+ className: "bg-muted/40 flex flex-col items-center gap-3 rounded-xl border px-6 py-8 text-center",
497
+ children: [
498
+ /* @__PURE__ */ jsx9(SupportCheck, {}),
499
+ /* @__PURE__ */ jsx9("h2", {
500
+ className: "text-xl font-semibold",
501
+ children: title
502
+ }),
503
+ description && /* @__PURE__ */ jsx9("p", {
504
+ className: "text-muted-foreground text-sm",
505
+ children: description
506
+ })
507
+ ]
508
+ });
509
+ var SupportForm = ({
510
+ locale,
511
+ messages,
512
+ askForReplyEmail,
513
+ defaultReplyEmail,
514
+ supportEmail,
515
+ errorDetails,
516
+ onSubmit
517
+ }) => {
518
+ const copy = useSupportFormMessages(locale, messages);
380
519
  const id = useId();
381
- const [open, setOpen] = useState(false);
520
+ const details = errorDetails?.trim().slice(0, supportErrorDetailsLimit);
521
+ const directEmail = Schema.decodeUnknownOption(SupportReplyEmail)(supportEmail);
382
522
  const [attachments, setAttachments] = useState([]);
383
523
  const [invalidAttachments, setInvalidAttachments] = useState(false);
384
524
  const fileInput = useRef(null);
385
525
  const [status, setStatus] = useState("idle");
386
526
  const submitting = useRef(false);
387
527
  const pending = status === "pending";
388
- const handleOpenChange = (next, details) => {
389
- if (submitting.current) {
390
- details.cancel();
391
- return;
392
- }
393
- if (next) {
394
- setAttachments([]);
395
- setInvalidAttachments(false);
396
- setStatus("idle");
397
- }
398
- setOpen(next);
399
- };
400
528
  const addAttachments = (files) => {
401
529
  if (submitting.current || !files.length)
402
530
  return;
403
- const result = Schema.decodeUnknownResult(SupportScreenshots)([
531
+ const result = Schema.decodeResult(SupportScreenshots)([
404
532
  ...attachments,
405
533
  ...files
406
534
  ]);
@@ -420,11 +548,16 @@ var SupportDialog = ({
420
548
  if (submitting.current)
421
549
  return;
422
550
  const form = new FormData(event.currentTarget);
423
- const request = Schema.decodeUnknownResult(SupportRequestSchema)({
551
+ const replyEmail = form.get("replyEmail");
552
+ const payload = {
424
553
  message: form.get("message"),
425
- ...askForReplyEmail ? { replyEmail: form.get("replyEmail") } : {},
426
554
  attachments
427
- });
555
+ };
556
+ if (replyEmail || askForReplyEmail === true)
557
+ payload.replyEmail = replyEmail;
558
+ if (details && form.has("includeErrorDetails"))
559
+ payload.errorDetails = details;
560
+ const request = Schema.decodeUnknownResult(SupportRequestSchema)(payload);
428
561
  if (Result.isFailure(request)) {
429
562
  setStatus("invalid");
430
563
  return;
@@ -442,199 +575,267 @@ var SupportDialog = ({
442
575
  submitting.current = false;
443
576
  }
444
577
  };
445
- return /* @__PURE__ */ jsxs2(Dialog, {
446
- open,
447
- onOpenChange: handleOpenChange,
578
+ return /* @__PURE__ */ jsxs3("div", {
579
+ className: "grid min-w-0 gap-4",
448
580
  children: [
449
- /* @__PURE__ */ jsx7(DialogTrigger, {
450
- render: trigger ?? /* @__PURE__ */ jsx7(Button, {
451
- variant: "outline",
452
- children: copy.title
453
- })
454
- }),
455
- /* @__PURE__ */ jsxs2(DialogPortal, {
581
+ status === "success" ? /* @__PURE__ */ jsx9(SupportConfirmation, {
582
+ title: copy.success,
583
+ description: copy.successDescription
584
+ }) : /* @__PURE__ */ jsxs3("form", {
585
+ className: "grid gap-4",
586
+ onSubmit: submit,
587
+ "aria-busy": pending,
456
588
  children: [
457
- /* @__PURE__ */ jsx7(DialogOverlay, {}),
458
- /* @__PURE__ */ jsxs2(DialogPrimitive2.Popup, {
459
- className: "bg-popover text-popover-foreground ring-foreground/10 fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-auto rounded-xl p-6 ring-1 outline-none",
589
+ /* @__PURE__ */ jsxs3("fieldset", {
590
+ disabled: pending,
591
+ className: "grid min-w-0 gap-4",
460
592
  children: [
461
- /* @__PURE__ */ jsxs2(DialogHeader, {
462
- className: status === "success" ? undefined : "pe-8",
593
+ askForReplyEmail !== false && /* @__PURE__ */ jsxs3("div", {
594
+ className: "grid gap-2",
463
595
  children: [
464
- /* @__PURE__ */ jsx7(DialogTitle, {
465
- children: /* @__PURE__ */ jsx7("span", {
466
- id: `${id}-title`,
467
- children: copy.title
468
- })
596
+ /* @__PURE__ */ jsx9(FieldLabel2, {
597
+ htmlFor: `${id}-email`,
598
+ optional: askForReplyEmail !== true,
599
+ optionalText: copy.optional,
600
+ children: copy.replyEmail
469
601
  }),
470
- copy.description && /* @__PURE__ */ jsx7(DialogDescription, {
471
- children: copy.description
602
+ /* @__PURE__ */ jsx9(Input, {
603
+ id: `${id}-email`,
604
+ name: "replyEmail",
605
+ type: "email",
606
+ autoComplete: "email",
607
+ placeholder: copy.replyEmailPlaceholder,
608
+ maxLength: supportReplyEmailLimit,
609
+ defaultValue: defaultReplyEmail,
610
+ required: askForReplyEmail === true
472
611
  })
473
612
  ]
474
613
  }),
475
- status !== "success" && /* @__PURE__ */ jsx7(DialogClose, {
476
- render: /* @__PURE__ */ jsx7(Button, {
477
- className: "absolute end-4 top-4",
478
- variant: "ghost",
479
- size: "icon-sm",
480
- "aria-label": copy.close,
481
- disabled: pending
482
- }),
483
- children: /* @__PURE__ */ jsx7(XIcon2, {
484
- "aria-hidden": "true"
485
- })
486
- }),
487
- status === "success" ? /* @__PURE__ */ jsxs2(Fragment, {
614
+ /* @__PURE__ */ jsxs3("div", {
615
+ className: "grid gap-2",
488
616
  children: [
489
- /* @__PURE__ */ jsx7("p", {
490
- role: "status",
491
- className: "text-sm",
492
- children: copy.success
617
+ /* @__PURE__ */ jsx9(Textarea, {
618
+ id: `${id}-message`,
619
+ "aria-label": copy.title,
620
+ name: "message",
621
+ rows: 8,
622
+ className: "min-h-44",
623
+ placeholder: copy.placeholder,
624
+ required: true,
625
+ maxLength: supportMessageLimit,
626
+ onPaste: pasteScreenshot
493
627
  }),
494
- /* @__PURE__ */ jsx7(DialogFooter, {
495
- children: /* @__PURE__ */ jsx7(DialogClose, {
496
- render: /* @__PURE__ */ jsx7(Button, {
497
- autoFocus: true
498
- }),
499
- children: copy.close
500
- })
501
- })
502
- ]
503
- }) : /* @__PURE__ */ jsxs2("form", {
504
- className: "grid gap-4",
505
- onSubmit: submit,
506
- "aria-busy": pending,
507
- children: [
508
- /* @__PURE__ */ jsxs2("fieldset", {
509
- disabled: pending,
510
- className: "grid min-w-0 gap-4",
511
- children: [
512
- askForReplyEmail && /* @__PURE__ */ jsxs2("div", {
513
- className: "grid gap-2",
514
- children: [
515
- /* @__PURE__ */ jsx7(Label, {
516
- htmlFor: `${id}-email`,
517
- children: copy.replyEmail
518
- }),
519
- /* @__PURE__ */ jsx7(Input, {
520
- id: `${id}-email`,
521
- name: "replyEmail",
522
- type: "email",
523
- autoComplete: "email",
524
- maxLength: supportReplyEmailLimit,
525
- required: true
526
- })
527
- ]
528
- }),
529
- /* @__PURE__ */ jsxs2("div", {
530
- className: "grid gap-2",
628
+ /* @__PURE__ */ jsx9("input", {
629
+ ref: fileInput,
630
+ type: "file",
631
+ "aria-label": copy.attach,
632
+ accept: screenshotAccept,
633
+ multiple: true,
634
+ hidden: true,
635
+ onChange: (event) => {
636
+ addAttachments(Array.from(event.currentTarget.files ?? []));
637
+ event.currentTarget.value = "";
638
+ }
639
+ }),
640
+ attachments.length > 0 && /* @__PURE__ */ jsx9("ul", {
641
+ className: "flex min-w-0 flex-wrap gap-2",
642
+ children: attachments.map((file, index) => /* @__PURE__ */ jsx9("li", {
643
+ className: "max-w-full min-w-0",
644
+ children: /* @__PURE__ */ jsxs3(Attachment, {
645
+ size: "xs",
646
+ className: "min-w-0 flex-nowrap",
531
647
  children: [
532
- /* @__PURE__ */ jsx7(Textarea, {
533
- id: `${id}-message`,
534
- "aria-labelledby": `${id}-title`,
535
- name: "message",
536
- rows: 8,
537
- className: "min-h-44",
538
- placeholder: copy.placeholder,
539
- required: true,
540
- maxLength: supportMessageLimit,
541
- onPaste: pasteScreenshot
542
- }),
543
- /* @__PURE__ */ jsx7("input", {
544
- ref: fileInput,
545
- type: "file",
546
- "aria-label": copy.attach,
547
- accept: screenshotAccept,
548
- multiple: true,
549
- hidden: true,
550
- onChange: (event) => {
551
- addAttachments(Array.from(event.currentTarget.files ?? []));
552
- event.currentTarget.value = "";
553
- }
554
- }),
555
- attachments.length > 0 && /* @__PURE__ */ jsx7("ul", {
556
- className: "flex min-w-0 flex-wrap gap-2",
557
- children: attachments.map((file, index) => /* @__PURE__ */ jsx7("li", {
558
- className: "max-w-full min-w-0",
559
- children: /* @__PURE__ */ jsxs2(Attachment, {
560
- size: "xs",
561
- className: "min-w-0 flex-nowrap",
562
- children: [
563
- /* @__PURE__ */ jsxs2(AttachmentContent, {
564
- className: "flex items-center gap-1.5",
565
- children: [
566
- /* @__PURE__ */ jsx7(AttachmentMedia, {
567
- className: "shrink-0",
568
- children: /* @__PURE__ */ jsx7(ImageIcon, {
569
- "aria-hidden": "true"
570
- })
571
- }),
572
- /* @__PURE__ */ jsx7(AttachmentTitle, {
573
- title: file.name,
574
- children: file.name
575
- })
576
- ]
577
- }),
578
- /* @__PURE__ */ jsx7(AttachmentActions, {
579
- className: "pe-1",
580
- children: /* @__PURE__ */ jsx7(AttachmentAction, {
581
- type: "button",
582
- "aria-label": `${copy.removeAttachment}: ${file.name}`,
583
- onClick: () => {
584
- setAttachments(attachments.filter((_, position) => position !== index));
585
- setInvalidAttachments(false);
586
- },
587
- children: /* @__PURE__ */ jsx7(XIcon2, {
588
- "aria-hidden": "true"
589
- })
590
- })
591
- })
592
- ]
648
+ /* @__PURE__ */ jsxs3(AttachmentContent, {
649
+ className: "flex items-center gap-1.5",
650
+ children: [
651
+ /* @__PURE__ */ jsx9(AttachmentMedia, {
652
+ className: "shrink-0",
653
+ children: /* @__PURE__ */ jsx9(ImageIcon, {
654
+ "aria-hidden": "true"
655
+ })
656
+ }),
657
+ /* @__PURE__ */ jsx9(AttachmentTitle, {
658
+ title: file.name,
659
+ children: file.name
593
660
  })
594
- }, index))
661
+ ]
595
662
  }),
596
- invalidAttachments && /* @__PURE__ */ jsx7("p", {
597
- role: "alert",
598
- className: "text-destructive text-sm",
599
- children: copy.invalidAttachments
663
+ /* @__PURE__ */ jsx9(AttachmentActions, {
664
+ className: "pe-1",
665
+ children: /* @__PURE__ */ jsx9(AttachmentAction, {
666
+ type: "button",
667
+ "aria-label": `${copy.removeAttachment}: ${file.name}`,
668
+ onClick: () => {
669
+ setAttachments(attachments.filter((_, position) => position !== index));
670
+ setInvalidAttachments(false);
671
+ },
672
+ children: /* @__PURE__ */ jsx9(XIcon2, {
673
+ "aria-hidden": "true"
674
+ })
675
+ })
600
676
  })
601
677
  ]
602
678
  })
603
- ]
679
+ }, index))
604
680
  }),
605
- (status === "failed" || status === "invalid") && /* @__PURE__ */ jsx7("p", {
681
+ invalidAttachments && /* @__PURE__ */ jsx9("p", {
606
682
  role: "alert",
607
683
  className: "text-destructive text-sm",
608
- children: status === "invalid" ? copy.invalid : copy.failed
684
+ children: copy.invalidAttachments
685
+ })
686
+ ]
687
+ }),
688
+ details && /* @__PURE__ */ jsxs3("div", {
689
+ className: "flex items-center gap-2",
690
+ children: [
691
+ /* @__PURE__ */ jsx9(Checkbox, {
692
+ id: `${id}-include-error-details`,
693
+ name: "includeErrorDetails",
694
+ defaultChecked: true,
695
+ disabled: pending
609
696
  }),
610
- /* @__PURE__ */ jsxs2("div", {
611
- className: "flex flex-wrap items-center justify-between gap-2",
612
- children: [
613
- /* @__PURE__ */ jsxs2(Button, {
614
- type: "button",
615
- variant: "ghost",
616
- size: "sm",
617
- disabled: pending,
618
- onClick: () => fileInput.current?.click(),
619
- children: [
620
- /* @__PURE__ */ jsx7(Paperclip, {
621
- "aria-hidden": "true"
622
- }),
623
- copy.attach
624
- ]
625
- }),
626
- /* @__PURE__ */ jsx7(Button, {
627
- type: "submit",
628
- size: "sm",
629
- className: "ms-auto",
630
- disabled: pending,
631
- children: pending ? copy.pending : copy.submit
632
- })
633
- ]
697
+ /* @__PURE__ */ jsx9(FieldLabel, {
698
+ htmlFor: `${id}-include-error-details`,
699
+ children: copy.includeErrorDetails
634
700
  })
635
701
  ]
636
702
  })
637
703
  ]
704
+ }),
705
+ (status === "failed" || status === "invalid") && /* @__PURE__ */ jsx9("p", {
706
+ role: "alert",
707
+ className: "text-destructive text-sm",
708
+ children: status === "invalid" ? copy.invalid : copy.failed
709
+ }),
710
+ /* @__PURE__ */ jsxs3("div", {
711
+ className: "flex flex-wrap items-center justify-between gap-2",
712
+ children: [
713
+ /* @__PURE__ */ jsxs3(Button, {
714
+ type: "button",
715
+ variant: "outline",
716
+ size: "sm",
717
+ disabled: pending,
718
+ onClick: () => fileInput.current?.click(),
719
+ children: [
720
+ /* @__PURE__ */ jsx9(Paperclip, {
721
+ "aria-hidden": "true"
722
+ }),
723
+ copy.attach
724
+ ]
725
+ }),
726
+ /* @__PURE__ */ jsx9(Button, {
727
+ type: "submit",
728
+ size: "sm",
729
+ className: "ms-auto",
730
+ disabled: pending,
731
+ children: pending ? copy.pending : copy.submit
732
+ })
733
+ ]
734
+ })
735
+ ]
736
+ }),
737
+ status !== "success" && directEmail._tag === "Some" && /* @__PURE__ */ jsxs3("p", {
738
+ className: "text-muted-foreground text-sm",
739
+ children: [
740
+ copy.directEmail,
741
+ " ",
742
+ /* @__PURE__ */ jsx9("a", {
743
+ className: "break-words underline underline-offset-4",
744
+ href: `mailto:${encodeURIComponent(directEmail.value).replace(/%40/g, "@")}`,
745
+ children: directEmail.value
746
+ })
747
+ ]
748
+ })
749
+ ]
750
+ });
751
+ };
752
+ var SupportDialog = ({ trigger, ...props }) => {
753
+ const copy = useSupportFormMessages(props.locale, props.messages);
754
+ const [open, setOpen] = useState(false);
755
+ const [pending, setPending] = useState(false);
756
+ const [sent, setSent] = useState(false);
757
+ const submitting = useRef(false);
758
+ const [draft, setDraft] = useState(0);
759
+ const description = sent ? copy.successDescription : copy.description;
760
+ return /* @__PURE__ */ jsxs3(Dialog, {
761
+ open,
762
+ onOpenChange: (next, details) => {
763
+ if (submitting.current) {
764
+ details.cancel();
765
+ return;
766
+ }
767
+ if (next) {
768
+ setSent(false);
769
+ setDraft((version) => version + 1);
770
+ }
771
+ setOpen(next);
772
+ },
773
+ children: [
774
+ /* @__PURE__ */ jsx9(DialogTrigger, {
775
+ render: trigger ?? /* @__PURE__ */ jsx9(Button, {
776
+ variant: "outline",
777
+ children: copy.title
778
+ })
779
+ }),
780
+ /* @__PURE__ */ jsxs3(DialogContent, {
781
+ showCloseButton: false,
782
+ className: "max-h-[calc(100dvh-2rem)] gap-4 overflow-auto text-base sm:max-w-lg",
783
+ children: [
784
+ /* @__PURE__ */ jsxs3(DialogHeader, {
785
+ role: sent ? "status" : undefined,
786
+ className: sent ? undefined : "pe-8",
787
+ children: [
788
+ /* @__PURE__ */ jsxs3(DialogTitle, {
789
+ className: sent ? "flex items-center gap-2" : undefined,
790
+ children: [
791
+ sent ? copy.success : copy.title,
792
+ sent && /* @__PURE__ */ jsx9(CheckIcon2, {
793
+ className: "text-primary size-4",
794
+ "aria-hidden": "true"
795
+ })
796
+ ]
797
+ }),
798
+ description && /* @__PURE__ */ jsx9(DialogDescription, {
799
+ children: description
800
+ })
801
+ ]
802
+ }),
803
+ sent ? /* @__PURE__ */ jsx9(DialogClose, {
804
+ render: /* @__PURE__ */ jsx9(Button, {
805
+ variant: "outline",
806
+ className: "justify-self-end",
807
+ autoFocus: true
808
+ }),
809
+ children: copy.close
810
+ }) : /* @__PURE__ */ jsxs3(Fragment, {
811
+ children: [
812
+ /* @__PURE__ */ jsx9(DialogClose, {
813
+ render: /* @__PURE__ */ jsx9(Button, {
814
+ className: "absolute end-4 top-4",
815
+ variant: "ghost",
816
+ size: "icon-sm",
817
+ "aria-label": copy.close,
818
+ disabled: pending
819
+ }),
820
+ children: /* @__PURE__ */ jsx9(XIcon2, {
821
+ "aria-hidden": "true"
822
+ })
823
+ }),
824
+ /* @__PURE__ */ jsx9(SupportForm, {
825
+ ...props,
826
+ onSubmit: async (request) => {
827
+ submitting.current = true;
828
+ setPending(true);
829
+ try {
830
+ await props.onSubmit(request);
831
+ setSent(true);
832
+ } finally {
833
+ submitting.current = false;
834
+ setPending(false);
835
+ }
836
+ }
837
+ }, draft)
838
+ ]
638
839
  })
639
840
  ]
640
841
  })
@@ -644,6 +845,7 @@ var SupportDialog = ({
644
845
  export {
645
846
  InvalidSupportScreenshot,
646
847
  SupportDialog,
848
+ SupportForm,
647
849
  SupportMultipartPayload,
648
850
  SupportReplyEmail,
649
851
  SupportRequestSchema,