react-os-shell 0.2.47 → 0.2.48

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
@@ -351,6 +351,35 @@ declare function NotificationBell({ useUnreadCount, list, markRead, markAllRead,
351
351
  * The Provider is mounted once at the App root.
352
352
  */
353
353
  type ReportType = 'bug' | 'suggestion';
354
+ /** Extra select-style field the consumer can inject into the bug-report
355
+ * dialog (e.g. a "module" picker that the consumer's submit callback
356
+ * forwards to its API). Rendered above the description textarea so
357
+ * reporters confirm or override before submitting. The shell stays
358
+ * generic — it knows nothing about what the field actually means. */
359
+ interface BugReportExtraSelectField {
360
+ /** Stable key — used as the form-field name and as the lookup key
361
+ * in the submission payload's `extras` map. */
362
+ key: string;
363
+ /** Visible label above the select. */
364
+ label: string;
365
+ type: 'select';
366
+ /** Choices rendered in the dropdown, in order. */
367
+ options: {
368
+ value: string;
369
+ label: string;
370
+ }[];
371
+ /** Initial value. Either a literal or a function called with the
372
+ * open-dialog context (current URL, the pending report type) so the
373
+ * consumer can auto-detect from where the user is when the dialog
374
+ * opens. */
375
+ defaultValue?: string | ((ctx: {
376
+ url: string;
377
+ reportType: ReportType;
378
+ }) => string);
379
+ /** Optional helper text shown beneath the select. */
380
+ hint?: string;
381
+ }
382
+ type BugReportExtraField = BugReportExtraSelectField;
354
383
  interface BugReportSubmission {
355
384
  description: string;
356
385
  reportType: ReportType;
@@ -359,6 +388,9 @@ interface BugReportSubmission {
359
388
  * they passed into `openBugReportDialog`. May be null if the original
360
389
  * capture failed and the user submitted without uploading a fallback. */
361
390
  screenshot: Blob | null;
391
+ /** Map of consumer-supplied extra-field values keyed by field.key. Empty
392
+ * object when no extras were declared. */
393
+ extras: Record<string, string>;
362
394
  }
363
395
  /** Generic bug-report record shape consumed by the shell's list/detail UI. */
364
396
  interface BugReport {
@@ -384,11 +416,19 @@ interface BugReportSubmitPayload {
384
416
  userAgent: string;
385
417
  viewport: string;
386
418
  reportType: ReportType;
419
+ /** Values for any consumer-declared `extraFields` (keyed by field.key).
420
+ * Always present; empty object when no extras were declared. */
421
+ extras: Record<string, string>;
387
422
  }
388
423
  /** Config bundle for the bug-report subsystem. Consumer-supplied; the shell
389
424
  * never calls a hardcoded URL. */
390
425
  interface BugReportConfig {
391
426
  submit: (p: BugReportSubmitPayload) => Promise<unknown>;
427
+ /** Extra fields to render inside the bug-report dialog above the
428
+ * description textarea. Keeps the consumer's domain-specific
429
+ * metadata (e.g. "which module is this report about?") in the same
430
+ * one-step submit flow without forking the shell dialog. */
431
+ extraFields?: BugReportExtraField[];
392
432
  /** Fetcher for the admin Bug Reports list. Receives query-string-shaped
393
433
  * params (e.g. `is_resolved=false`); paginated response. When omitted the
394
434
  * Bug Reports list page is unavailable. */
@@ -730,4 +770,4 @@ declare function useNewHotkey(callback: () => void): void;
730
770
  */
731
771
  declare function useEditHotkey(callback: (() => void) | null): void;
732
772
 
733
- export { ALT, ALT_SHIFT_D, ALT_SHIFT_E, ALT_SHIFT_N, type BugReport, type BugReportConfig, BugReportConfigProvider, BugReportDetail, BugReportProvider, type BugReportSubmission, type BugReportSubmitPayload, CMD_A, CMD_DOT, CMD_ENTER, CMD_K, CMD_S, CancelButton, type ChangelogEntry, ConfirmProvider, CopyButton, Customization, Desktop, type DesktopHostConfig, DesktopHostProvider, DocFavStar, ENTER, type EntityFetcher, GLASS_DIVIDER, GLASS_INPUT_BG, GlobalSearch, Layout, type LayoutProps, MOD, Modal, ModalActions, NotificationBell, type NotificationsConfig, PopupMenu, PopupMenuDivider, PopupMenuItem, PopupMenuLabel, SHIFT, type SearchConfig, type SearchProvider, type SearchResult, type SemanticGroup, type ShellAuth, ShellAuthProvider, ShellEntityFetcherProvider, type ShellNotification, type ShellPrefsAdapter, ShellPrefsProvider, ShortcutHelp, StartMenu, StatusBadge, StatusBadgeProvider, type StickyEntityRef, type StickyResolver, VERSION, WindowManagerProvider, WindowRegistry, WindowTitle, confirm, confirmDestructive, createWindowRegistry, formatDate, glassStyle, isMac, openBugReportDialog, prompt, reportBug, setShellApiClient, setShellAuthBridge, setShellNavIcons, setWindowDefaultPosition, toast, useBugReport, useClickOutside, useDesktopHost, useEditHotkey, useLocalStoragePrefs, useModalActive, useNewHotkey, useShellAuth, useShellEntityFetcher, useShellPrefs, useWidgetSettings, useWindowManager, useWindowMenuItem, useWindowTitle };
773
+ export { ALT, ALT_SHIFT_D, ALT_SHIFT_E, ALT_SHIFT_N, type BugReport, type BugReportConfig, BugReportConfigProvider, BugReportDetail, type BugReportExtraField, type BugReportExtraSelectField, BugReportProvider, type BugReportSubmission, type BugReportSubmitPayload, CMD_A, CMD_DOT, CMD_ENTER, CMD_K, CMD_S, CancelButton, type ChangelogEntry, ConfirmProvider, CopyButton, Customization, Desktop, type DesktopHostConfig, DesktopHostProvider, DocFavStar, ENTER, type EntityFetcher, GLASS_DIVIDER, GLASS_INPUT_BG, GlobalSearch, Layout, type LayoutProps, MOD, Modal, ModalActions, NotificationBell, type NotificationsConfig, PopupMenu, PopupMenuDivider, PopupMenuItem, PopupMenuLabel, type ReportType, SHIFT, type SearchConfig, type SearchProvider, type SearchResult, type SemanticGroup, type ShellAuth, ShellAuthProvider, ShellEntityFetcherProvider, type ShellNotification, type ShellPrefsAdapter, ShellPrefsProvider, ShortcutHelp, StartMenu, StatusBadge, StatusBadgeProvider, type StickyEntityRef, type StickyResolver, VERSION, WindowManagerProvider, WindowRegistry, WindowTitle, confirm, confirmDestructive, createWindowRegistry, formatDate, glassStyle, isMac, openBugReportDialog, prompt, reportBug, setShellApiClient, setShellAuthBridge, setShellNavIcons, setWindowDefaultPosition, toast, useBugReport, useClickOutside, useDesktopHost, useEditHotkey, useLocalStoragePrefs, useModalActive, useNewHotkey, useShellAuth, useShellEntityFetcher, useShellPrefs, useWidgetSettings, useWindowManager, useWindowMenuItem, useWindowTitle };
package/dist/index.js CHANGED
@@ -483,18 +483,37 @@ function BugReportProvider({ children }) {
483
483
  const [previewUrl, setPreviewUrl] = useState(null);
484
484
  const [description, setDescription] = useState("");
485
485
  const [reportType, setReportType] = useState("bug");
486
+ const [extras, setExtras] = useState({});
486
487
  const [annotating, setAnnotating] = useState(false);
487
488
  const resolveRef = useRef();
489
+ const config = useContext(BugReportContext);
490
+ const extraFields = config?.extraFields ?? [];
488
491
  const openFn = useCallback((s) => {
489
492
  setScreenshot(s);
490
493
  setDescription("");
491
494
  setReportType("bug");
495
+ const seeded = {};
496
+ const ctx = { url: window.location.href, reportType: "bug" };
497
+ for (const f of extraFields) {
498
+ if (typeof f.defaultValue === "function") {
499
+ try {
500
+ seeded[f.key] = f.defaultValue(ctx) ?? "";
501
+ } catch {
502
+ seeded[f.key] = f.options[0]?.value ?? "";
503
+ }
504
+ } else if (typeof f.defaultValue === "string") {
505
+ seeded[f.key] = f.defaultValue;
506
+ } else {
507
+ seeded[f.key] = f.options[0]?.value ?? "";
508
+ }
509
+ }
510
+ setExtras(seeded);
492
511
  setAnnotating(false);
493
512
  setOpen(true);
494
513
  return new Promise((resolve) => {
495
514
  resolveRef.current = resolve;
496
515
  });
497
- }, []);
516
+ }, [extraFields]);
498
517
  useEffect(() => {
499
518
  globalOpen = openFn;
500
519
  }, [openFn]);
@@ -510,7 +529,7 @@ function BugReportProvider({ children }) {
510
529
  const handleSubmit = () => {
511
530
  setAnnotating(false);
512
531
  setOpen(false);
513
- resolveRef.current?.({ description: description.trim(), reportType, screenshot });
532
+ resolveRef.current?.({ description: description.trim(), reportType, screenshot, extras });
514
533
  };
515
534
  const handleCancel = () => {
516
535
  setAnnotating(false);
@@ -572,6 +591,20 @@ function BugReportProvider({ children }) {
572
591
  /* @__PURE__ */ jsx("p", { className: "mt-1 text-[11px] text-gray-400", children: "Click Annotate to mark up the screenshot before sending." })
573
592
  ] }),
574
593
  !previewUrl && /* @__PURE__ */ jsx(UploadDropZone, { onSelect: (blob) => setScreenshot(blob) }),
594
+ extraFields.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-4 space-y-3", children: extraFields.map((f) => /* @__PURE__ */ jsxs("div", { children: [
595
+ /* @__PURE__ */ jsx("label", { htmlFor: `bug-report-extra-${f.key}`, className: "block text-sm font-medium text-gray-700", children: f.label }),
596
+ /* @__PURE__ */ jsx(
597
+ "select",
598
+ {
599
+ id: `bug-report-extra-${f.key}`,
600
+ value: extras[f.key] ?? "",
601
+ onChange: (e) => setExtras((prev) => ({ ...prev, [f.key]: e.target.value })),
602
+ className: "mt-1 block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:ring-1 focus:ring-blue-500 focus:outline-none",
603
+ children: f.options.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
604
+ }
605
+ ),
606
+ f.hint && /* @__PURE__ */ jsx("p", { className: "mt-1 text-[11px] text-gray-500", children: f.hint })
607
+ ] }, f.key)) }),
575
608
  /* @__PURE__ */ jsxs("label", { className: "mt-4 block text-sm font-medium text-gray-700", children: [
576
609
  isBug ? "What went wrong?" : "What's your suggestion?",
577
610
  /* @__PURE__ */ jsx("span", { className: "font-normal text-gray-400 ml-1", children: "(optional)" })
@@ -862,7 +895,7 @@ function StatusBadge({ status }) {
862
895
  }
863
896
 
864
897
  // src/version.ts
865
- var VERSION = "0.2.47" ;
898
+ var VERSION = "0.2.48" ;
866
899
  var APP_VERSION = VERSION;
867
900
 
868
901
  // src/changelog.ts
@@ -909,7 +942,8 @@ async function reportBug(submit) {
909
942
  url: window.location.href,
910
943
  userAgent: navigator.userAgent,
911
944
  viewport: `${window.innerWidth}x${window.innerHeight}`,
912
- reportType: submission.reportType
945
+ reportType: submission.reportType,
946
+ extras: submission.extras ?? {}
913
947
  });
914
948
  toast_default.success(submission.reportType === "bug" ? "Bug sent to admins." : "Suggestion sent to admins.");
915
949
  } catch (err) {