@checkflow/sdk 1.1.4 → 1.1.5

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/react.d.mts CHANGED
@@ -1,11 +1,27 @@
1
1
  import { H as HighlightAnnotation } from './highlighter-D0FpwCSU.mjs';
2
- import { a as FeedbackResponse, C as CheckflowConfig } from './types-CBCRUGst.mjs';
2
+ import { B as ButtonConfig, U as UserProfile, a as FeedbackResponse, C as CheckflowConfig } from './types-fCeePy5c.mjs';
3
3
 
4
4
  /**
5
5
  * Initialize Checkflow in a React/Next.js app.
6
6
  * Call this in your root layout or _app file.
7
+ *
8
+ * @param config - SDK configuration including apiKey, user profile, and widget options
7
9
  */
8
10
  declare function useCheckflowInit(config: CheckflowConfig): void;
11
+ /**
12
+ * Update the user profile after initialization.
13
+ * Useful when user logs in/out.
14
+ */
15
+ declare function setUser(user: UserProfile | undefined): Promise<void>;
16
+ /**
17
+ * Clear the user profile.
18
+ */
19
+ declare function clearUser(): Promise<void>;
20
+ /**
21
+ * Open the feedback modal programmatically.
22
+ * Use this when you want to trigger the modal from a custom button.
23
+ */
24
+ declare function openFeedbackModal(): Promise<void>;
9
25
  /**
10
26
  * Hook to send feedback programmatically from React components.
11
27
  */
@@ -20,10 +36,39 @@ declare function useCheckflowFeedback(): {
20
36
  highlight: () => Promise<HighlightAnnotation[]>;
21
37
  show: () => Promise<void>;
22
38
  hide: () => Promise<void>;
39
+ openModal: typeof openFeedbackModal;
40
+ setUser: typeof setUser;
41
+ clearUser: typeof clearUser;
23
42
  };
24
43
  /**
25
44
  * Cleanup function for React useEffect.
26
45
  */
27
46
  declare function destroyCheckflow(): void;
47
+ /**
48
+ * Props for the FeedbackButton component.
49
+ * All button styling can be customized via className, style, or button config.
50
+ */
51
+ interface FeedbackButtonProps {
52
+ /** Button text content */
53
+ children?: string;
54
+ /** Custom CSS class */
55
+ className?: string;
56
+ /** Inline styles */
57
+ style?: Record<string, string | number>;
58
+ /** Button configuration for SDK styling */
59
+ buttonConfig?: ButtonConfig;
60
+ /** Click handler (called before opening modal) */
61
+ onClick?: () => void;
62
+ }
63
+ /**
64
+ * Get the onClick handler for a feedback button.
65
+ * Use this to create your own custom button that opens the feedback modal.
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * <button onClick={getFeedbackButtonHandler()}>Report Bug</button>
70
+ * ```
71
+ */
72
+ declare function getFeedbackButtonHandler(onClick?: () => void): () => void;
28
73
 
29
- export { destroyCheckflow, useCheckflowFeedback, useCheckflowInit };
74
+ export { type FeedbackButtonProps, clearUser, destroyCheckflow, getFeedbackButtonHandler, openFeedbackModal, setUser, useCheckflowFeedback, useCheckflowInit };
package/dist/react.d.ts CHANGED
@@ -1,11 +1,27 @@
1
1
  import { H as HighlightAnnotation } from './highlighter-D0FpwCSU.js';
2
- import { a as FeedbackResponse, C as CheckflowConfig } from './types-CBCRUGst.js';
2
+ import { B as ButtonConfig, U as UserProfile, a as FeedbackResponse, C as CheckflowConfig } from './types-fCeePy5c.js';
3
3
 
4
4
  /**
5
5
  * Initialize Checkflow in a React/Next.js app.
6
6
  * Call this in your root layout or _app file.
7
+ *
8
+ * @param config - SDK configuration including apiKey, user profile, and widget options
7
9
  */
8
10
  declare function useCheckflowInit(config: CheckflowConfig): void;
11
+ /**
12
+ * Update the user profile after initialization.
13
+ * Useful when user logs in/out.
14
+ */
15
+ declare function setUser(user: UserProfile | undefined): Promise<void>;
16
+ /**
17
+ * Clear the user profile.
18
+ */
19
+ declare function clearUser(): Promise<void>;
20
+ /**
21
+ * Open the feedback modal programmatically.
22
+ * Use this when you want to trigger the modal from a custom button.
23
+ */
24
+ declare function openFeedbackModal(): Promise<void>;
9
25
  /**
10
26
  * Hook to send feedback programmatically from React components.
11
27
  */
@@ -20,10 +36,39 @@ declare function useCheckflowFeedback(): {
20
36
  highlight: () => Promise<HighlightAnnotation[]>;
21
37
  show: () => Promise<void>;
22
38
  hide: () => Promise<void>;
39
+ openModal: typeof openFeedbackModal;
40
+ setUser: typeof setUser;
41
+ clearUser: typeof clearUser;
23
42
  };
24
43
  /**
25
44
  * Cleanup function for React useEffect.
26
45
  */
27
46
  declare function destroyCheckflow(): void;
47
+ /**
48
+ * Props for the FeedbackButton component.
49
+ * All button styling can be customized via className, style, or button config.
50
+ */
51
+ interface FeedbackButtonProps {
52
+ /** Button text content */
53
+ children?: string;
54
+ /** Custom CSS class */
55
+ className?: string;
56
+ /** Inline styles */
57
+ style?: Record<string, string | number>;
58
+ /** Button configuration for SDK styling */
59
+ buttonConfig?: ButtonConfig;
60
+ /** Click handler (called before opening modal) */
61
+ onClick?: () => void;
62
+ }
63
+ /**
64
+ * Get the onClick handler for a feedback button.
65
+ * Use this to create your own custom button that opens the feedback modal.
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * <button onClick={getFeedbackButtonHandler()}>Report Bug</button>
70
+ * ```
71
+ */
72
+ declare function getFeedbackButtonHandler(onClick?: () => void): () => void;
28
73
 
29
- export { destroyCheckflow, useCheckflowFeedback, useCheckflowInit };
74
+ export { type FeedbackButtonProps, clearUser, destroyCheckflow, getFeedbackButtonHandler, openFeedbackModal, setUser, useCheckflowFeedback, useCheckflowInit };
package/dist/react.js CHANGED
@@ -1321,9 +1321,16 @@ var init_editor = __esm({
1321
1321
  });
1322
1322
 
1323
1323
  // src/widget.ts
1324
+ var widget_exports = {};
1325
+ __export(widget_exports, {
1326
+ mountWidget: () => mountWidget,
1327
+ openFeedbackModal: () => openFeedbackModal,
1328
+ unmountWidget: () => unmountWidget
1329
+ });
1324
1330
  function mountWidget(config2 = {}, onSubmit, opts) {
1325
1331
  if (container) return;
1326
1332
  onSubmitCallback = onSubmit;
1333
+ currentUser = opts?.user;
1327
1334
  const cfg = { ...DEFAULT_CONFIG, ...config2 };
1328
1335
  currentCfg = cfg;
1329
1336
  container = document.createElement("div");
@@ -1334,13 +1341,20 @@ function mountWidget(config2 = {}, onSubmit, opts) {
1334
1341
  const btn = container.querySelector("#cf-trigger");
1335
1342
  btn?.addEventListener("click", () => openModal(cfg, opts));
1336
1343
  }
1344
+ function openFeedbackModal(config2 = {}, onSubmit, opts) {
1345
+ onSubmitCallback = onSubmit;
1346
+ currentUser = opts?.user;
1347
+ const cfg = { ...DEFAULT_CONFIG, ...config2 };
1348
+ currentCfg = cfg;
1349
+ injectStyles(cfg);
1350
+ openModal(cfg, opts);
1351
+ }
1337
1352
  function getBackdropClass(cfg, expanded) {
1338
1353
  if (expanded) return "cf-backdrop--center";
1339
1354
  if (cfg.position === "center") return "cf-backdrop--center";
1340
- return "cf-backdrop--corner cf-pos-" + cfg.position;
1355
+ return "cf-backdrop--corner cf-pos-" + (cfg.position || "bottom-right");
1341
1356
  }
1342
1357
  function openModal(cfg, opts) {
1343
- if (!container) return;
1344
1358
  const existing = document.getElementById("cf-modal-backdrop");
1345
1359
  if (existing) existing.remove();
1346
1360
  isExpanded = false;
@@ -1453,8 +1467,10 @@ function bindModalEvents(cfg, opts) {
1453
1467
  });
1454
1468
  backdrop.querySelector("#cf-submit")?.addEventListener("click", () => {
1455
1469
  const desc = backdrop.querySelector("#cf-desc")?.value;
1456
- const name = backdrop.querySelector("#cf-name")?.value;
1457
- const email = backdrop.querySelector("#cf-email")?.value;
1470
+ const nameEl = backdrop.querySelector("#cf-name");
1471
+ const emailEl = backdrop.querySelector("#cf-email");
1472
+ const name = nameEl?.value || currentUser?.name;
1473
+ const email = emailEl?.value || currentUser?.email;
1458
1474
  if (!desc?.trim()) {
1459
1475
  const descEl = backdrop.querySelector("#cf-desc");
1460
1476
  if (descEl) {
@@ -1496,33 +1512,93 @@ function showToast(msg) {
1496
1512
  setTimeout(() => toast.remove(), 3e3);
1497
1513
  }
1498
1514
  function injectStyles(cfg) {
1515
+ const existingStyle = document.getElementById("cf-widget-styles");
1516
+ if (existingStyle) existingStyle.remove();
1517
+ const btn = cfg.button || {};
1518
+ const sizePreset = SIZE_PRESETS[btn.size || "default"] || SIZE_PRESETS.default;
1519
+ const variantPreset = VARIANT_PRESETS[btn.variant || "default"] || VARIANT_PRESETS.default;
1520
+ const bgColor = btn.backgroundColor || cfg.color || variantPreset.bg;
1521
+ const textColor = btn.textColor || variantPreset.color;
1522
+ const borderRadius = btn.borderRadius || "8px";
1523
+ const padding = btn.padding || sizePreset.padding;
1524
+ const fontSize = btn.fontSize || sizePreset.fontSize;
1525
+ const fontWeight = btn.fontWeight || "500";
1526
+ const border = btn.border || variantPreset.border;
1527
+ const boxShadow = btn.boxShadow || "0 2px 8px rgba(0,0,0,0.15)";
1528
+ const primaryColor = cfg.color || "#1e3a5f";
1499
1529
  const style = document.createElement("style");
1500
1530
  style.id = "cf-widget-styles";
1501
1531
  style.textContent = `
1502
1532
  @keyframes cf-toast-in { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
1503
1533
  @keyframes cf-modal-in { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
1504
1534
 
1535
+ /* User card styles */
1536
+ .cf-user-card {
1537
+ display:flex;
1538
+ align-items:center;
1539
+ gap:12px;
1540
+ padding:12px;
1541
+ background:#f8f9fa;
1542
+ border-radius:10px;
1543
+ margin-bottom:4px;
1544
+ }
1545
+ .cf-user-avatar {
1546
+ width:40px;
1547
+ height:40px;
1548
+ border-radius:50%;
1549
+ object-fit:cover;
1550
+ }
1551
+ .cf-user-avatar-placeholder {
1552
+ width:40px;
1553
+ height:40px;
1554
+ border-radius:50%;
1555
+ background:${primaryColor};
1556
+ color:#fff;
1557
+ display:flex;
1558
+ align-items:center;
1559
+ justify-content:center;
1560
+ font-size:16px;
1561
+ font-weight:600;
1562
+ }
1563
+ .cf-user-info {
1564
+ flex:1;
1565
+ min-width:0;
1566
+ }
1567
+ .cf-user-name {
1568
+ font-size:14px;
1569
+ font-weight:600;
1570
+ color:#1a1a2e;
1571
+ }
1572
+ .cf-user-email {
1573
+ font-size:12px;
1574
+ color:#666;
1575
+ overflow:hidden;
1576
+ text-overflow:ellipsis;
1577
+ white-space:nowrap;
1578
+ }
1579
+
1580
+ /* Trigger button - now inline, not fixed position */
1505
1581
  #cf-trigger {
1506
1582
  position:fixed;
1507
- ${getPositionCSS(cfg.position)}
1583
+ ${getPositionCSS(cfg.position || "bottom-right")}
1508
1584
  z-index:100000;
1509
- background:${cfg.color};
1510
- color:#fff;
1511
- border:none;
1512
- border-radius:50px;
1513
- padding:11px 20px;
1514
- font-size:14px;
1515
- font-weight:500;
1585
+ background:${bgColor};
1586
+ color:${textColor};
1587
+ border:${border};
1588
+ border-radius:${borderRadius};
1589
+ padding:${padding};
1590
+ font-size:${fontSize};
1591
+ font-weight:${fontWeight};
1516
1592
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
1517
1593
  cursor:pointer;
1518
- box-shadow:0 4px 16px rgba(0,0,0,.18);
1519
- display:flex;
1594
+ box-shadow:${boxShadow};
1595
+ display:inline-flex;
1520
1596
  align-items:center;
1521
1597
  gap:8px;
1522
- transition:transform .15s,box-shadow .15s;
1598
+ transition:transform .15s,box-shadow .15s,opacity .15s;
1523
1599
  }
1524
- #cf-trigger:hover { transform:scale(1.04); box-shadow:0 6px 24px rgba(0,0,0,.22); }
1525
- #cf-trigger svg { width:18px; height:18px; }
1600
+ #cf-trigger:hover { opacity:0.9; }
1601
+ #cf-trigger svg { width:16px; height:16px; flex-shrink:0; }
1526
1602
 
1527
1603
  #cf-modal-backdrop {
1528
1604
  position:fixed;
@@ -1623,7 +1699,7 @@ function injectStyles(cfg) {
1623
1699
  transition:all .15s;
1624
1700
  }
1625
1701
  .cf-tool-highlight {
1626
- background:${cfg.color};
1702
+ background:${primaryColor};
1627
1703
  color:#fff;
1628
1704
  }
1629
1705
  .cf-tool-highlight:hover { opacity:.9; }
@@ -1671,8 +1747,8 @@ function injectStyles(cfg) {
1671
1747
  }
1672
1748
  .cf-field input::placeholder, .cf-field textarea::placeholder { color:#bbb; }
1673
1749
  .cf-field input:focus, .cf-field textarea:focus {
1674
- border-color:${cfg.color};
1675
- box-shadow:0 0 0 3px ${cfg.color}18;
1750
+ border-color:${primaryColor};
1751
+ box-shadow:0 0 0 3px ${primaryColor}18;
1676
1752
  }
1677
1753
  .cf-field textarea { resize:vertical; min-height:100px; }
1678
1754
 
@@ -1711,7 +1787,7 @@ function injectStyles(cfg) {
1711
1787
  padding:13px;
1712
1788
  border:none;
1713
1789
  border-radius:10px;
1714
- background:${cfg.color};
1790
+ background:${primaryColor};
1715
1791
  color:#fff;
1716
1792
  font-size:15px;
1717
1793
  font-weight:600;
@@ -1719,7 +1795,7 @@ function injectStyles(cfg) {
1719
1795
  font-family:inherit;
1720
1796
  transition:all .15s;
1721
1797
  }
1722
- .cf-submit-btn:hover { opacity:.92; transform:translateY(-1px); box-shadow:0 4px 12px ${cfg.color}40; }
1798
+ .cf-submit-btn:hover { opacity:.92; transform:translateY(-1px); box-shadow:0 4px 12px ${primaryColor}40; }
1723
1799
  .cf-submit-btn:disabled { opacity:.5; cursor:not-allowed; transform:none; }
1724
1800
 
1725
1801
  .cf-cancel-btn {
@@ -1750,7 +1826,7 @@ function injectStyles(cfg) {
1750
1826
  text-decoration:none;
1751
1827
  font-weight:500;
1752
1828
  }
1753
- .cf-footer a:hover { color:${cfg.color}; }
1829
+ .cf-footer a:hover { color:${primaryColor}; }
1754
1830
  `;
1755
1831
  document.head.appendChild(style);
1756
1832
  }
@@ -1769,10 +1845,15 @@ function getPositionCSS(pos) {
1769
1845
  }
1770
1846
  }
1771
1847
  function getTriggerHTML(cfg) {
1848
+ const btn = cfg.button || {};
1849
+ const text = btn.text || cfg.text || "Report Bug";
1850
+ const showIcon = btn.showIcon !== false;
1851
+ const customClass = btn.className || "";
1852
+ const icon = showIcon ? `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>` : "";
1772
1853
  return `
1773
- <button id="cf-trigger">
1774
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
1775
- ${cfg.text}
1854
+ <button id="cf-trigger" class="${customClass}">
1855
+ ${icon}
1856
+ ${text}
1776
1857
  </button>
1777
1858
  `;
1778
1859
  }
@@ -1781,15 +1862,29 @@ function getCheckflowLogo() {
1781
1862
  }
1782
1863
  function getModalHTML(cfg, expanded) {
1783
1864
  const modalClass = expanded ? "cf-modal cf-modal--expanded" : "cf-modal cf-modal--compact";
1784
- const formFields = `
1865
+ const hasUser = currentUser && (currentUser.name || currentUser.email);
1866
+ const userInfoCard = hasUser ? `
1867
+ <div class="cf-user-card">
1868
+ ${currentUser?.avatar ? `<img class="cf-user-avatar" src="${currentUser.avatar}" alt="${currentUser.name || "User"}" />` : `<div class="cf-user-avatar-placeholder">${(currentUser?.name || currentUser?.email || "U").charAt(0).toUpperCase()}</div>`}
1869
+ <div class="cf-user-info">
1870
+ ${currentUser?.name ? `<div class="cf-user-name">${currentUser.name}</div>` : ""}
1871
+ ${currentUser?.email ? `<div class="cf-user-email">${currentUser.email}</div>` : ""}
1872
+ </div>
1873
+ </div>
1874
+ ` : "";
1875
+ const nameEmailFields = hasUser ? "" : `
1785
1876
  <div class="cf-field">
1786
- <label>Nom <span>(obligatoire)</span></label>
1877
+ <label>Nom <span>(optionnel)</span></label>
1787
1878
  <input id="cf-name" type="text" placeholder="Votre nom" />
1788
1879
  </div>
1789
1880
  <div class="cf-field">
1790
- <label>Email <span>(obligatoire)</span></label>
1881
+ <label>Email <span>(optionnel)</span></label>
1791
1882
  <input id="cf-email" type="email" placeholder="votre.email@exemple.com" />
1792
1883
  </div>
1884
+ `;
1885
+ const formFields = `
1886
+ ${userInfoCard}
1887
+ ${nameEmailFields}
1793
1888
  <div class="cf-field">
1794
1889
  <label>Description <span>(obligatoire)</span></label>
1795
1890
  <textarea id="cf-desc" placeholder="Quel est le probl\xE8me ? Que vous attendiez-vous \xE0 voir ?"></textarea>
@@ -1838,16 +1933,44 @@ function getModalHTML(cfg, expanded) {
1838
1933
  </div>
1839
1934
  `;
1840
1935
  }
1841
- var DEFAULT_CONFIG, container, onSubmitCallback, screenshotDataUrl, annotatedImageUrl, annotationsData, isExpanded, currentCfg;
1936
+ var DEFAULT_BUTTON_CONFIG, SIZE_PRESETS, VARIANT_PRESETS, DEFAULT_CONFIG, container, onSubmitCallback, screenshotDataUrl, annotatedImageUrl, annotationsData, isExpanded, currentCfg, currentUser;
1842
1937
  var init_widget = __esm({
1843
1938
  "src/widget.ts"() {
1844
1939
  "use strict";
1845
1940
  init_editor();
1941
+ DEFAULT_BUTTON_CONFIG = {
1942
+ text: "Report Bug",
1943
+ backgroundColor: "#1e3a5f",
1944
+ textColor: "#ffffff",
1945
+ borderRadius: "8px",
1946
+ padding: "10px 18px",
1947
+ fontSize: "14px",
1948
+ fontWeight: "500",
1949
+ border: "none",
1950
+ boxShadow: "0 2px 8px rgba(0,0,0,0.15)",
1951
+ className: "",
1952
+ showIcon: true,
1953
+ size: "default",
1954
+ variant: "default"
1955
+ };
1956
+ SIZE_PRESETS = {
1957
+ xs: { padding: "6px 10px", fontSize: "12px" },
1958
+ sm: { padding: "8px 14px", fontSize: "13px" },
1959
+ default: { padding: "10px 18px", fontSize: "14px" },
1960
+ lg: { padding: "12px 24px", fontSize: "15px" }
1961
+ };
1962
+ VARIANT_PRESETS = {
1963
+ default: { bg: "#1e3a5f", color: "#ffffff", border: "none" },
1964
+ outline: { bg: "transparent", color: "#1e3a5f", border: "1px solid #1e3a5f" },
1965
+ ghost: { bg: "transparent", color: "#1e3a5f", border: "none" },
1966
+ link: { bg: "transparent", color: "#1e3a5f", border: "none" }
1967
+ };
1846
1968
  DEFAULT_CONFIG = {
1847
1969
  position: "bottom-right",
1848
1970
  color: "#1e3a5f",
1849
1971
  text: "Report Bug",
1850
- showOnInit: true
1972
+ showOnInit: true,
1973
+ button: DEFAULT_BUTTON_CONFIG
1851
1974
  };
1852
1975
  container = null;
1853
1976
  onSubmitCallback = null;
@@ -1856,6 +1979,7 @@ var init_widget = __esm({
1856
1979
  annotationsData = [];
1857
1980
  isExpanded = false;
1858
1981
  currentCfg = { ...DEFAULT_CONFIG };
1982
+ currentUser = void 0;
1859
1983
  }
1860
1984
  });
1861
1985
 
@@ -1929,10 +2053,13 @@ var init_screenshot = __esm({
1929
2053
  var index_exports = {};
1930
2054
  __export(index_exports, {
1931
2055
  captureScreenshot: () => captureScreenshot,
2056
+ clearUser: () => clearUser,
1932
2057
  destroy: () => destroy,
1933
2058
  hideWidget: () => hideWidget,
1934
2059
  init: () => init,
2060
+ openFeedbackModal: () => openFeedbackModal2,
1935
2061
  sendFeedback: () => sendFeedback,
2062
+ setUser: () => setUser,
1936
2063
  showWidget: () => showWidget
1937
2064
  });
1938
2065
  function init(cfg) {
@@ -1961,7 +2088,8 @@ function init(cfg) {
1961
2088
  });
1962
2089
  },
1963
2090
  {
1964
- onScreenshot: () => captureScreenshot()
2091
+ onScreenshot: () => captureScreenshot(),
2092
+ user: config.user
1965
2093
  }
1966
2094
  );
1967
2095
  }
@@ -1991,12 +2119,22 @@ async function sendFeedback(data) {
1991
2119
  if (data.annotations && data.annotations.length > 0) {
1992
2120
  payload.annotations = data.annotations;
1993
2121
  }
1994
- if (data.reporter_name) {
2122
+ if (config.user?.name) {
2123
+ payload.reporter_name = config.user.name;
2124
+ } else if (data.reporter_name) {
1995
2125
  payload.reporter_name = data.reporter_name;
1996
2126
  }
1997
- if (data.reporter_email) {
2127
+ if (config.user?.email) {
2128
+ payload.reporter_email = config.user.email;
2129
+ } else if (data.reporter_email) {
1998
2130
  payload.reporter_email = data.reporter_email;
1999
2131
  }
2132
+ if (config.user?.id) {
2133
+ payload.user_id = config.user.id;
2134
+ }
2135
+ if (config.user?.avatar) {
2136
+ payload.user_avatar = config.user.avatar;
2137
+ }
2000
2138
  try {
2001
2139
  const res = await fetch(`${config.endpoint}/sdk/feedback`, {
2002
2140
  method: "POST",
@@ -2032,10 +2170,45 @@ function showWidget() {
2032
2170
  });
2033
2171
  },
2034
2172
  {
2035
- onScreenshot: () => captureScreenshot()
2173
+ onScreenshot: () => captureScreenshot(),
2174
+ user: config.user
2036
2175
  }
2037
2176
  );
2038
2177
  }
2178
+ function setUser(user) {
2179
+ if (config) {
2180
+ config.user = user;
2181
+ }
2182
+ }
2183
+ function clearUser() {
2184
+ if (config) {
2185
+ config.user = void 0;
2186
+ }
2187
+ }
2188
+ function openFeedbackModal2() {
2189
+ if (!config) return;
2190
+ Promise.resolve().then(() => (init_widget(), widget_exports)).then(({ openFeedbackModal: openModal2 }) => {
2191
+ openModal2(
2192
+ config.widget,
2193
+ (data) => {
2194
+ sendFeedback({
2195
+ title: data.title,
2196
+ description: data.description,
2197
+ type: data.type,
2198
+ priority: data.priority,
2199
+ screenshot_data: data.screenshot,
2200
+ annotations: data.annotations,
2201
+ reporter_name: data.reporter_name,
2202
+ reporter_email: data.reporter_email
2203
+ });
2204
+ },
2205
+ {
2206
+ onScreenshot: () => captureScreenshot(),
2207
+ user: config.user
2208
+ }
2209
+ );
2210
+ });
2211
+ }
2039
2212
  function hideWidget() {
2040
2213
  unmountWidget();
2041
2214
  }
@@ -2203,20 +2376,41 @@ var init_highlighter = __esm({
2203
2376
  // src/react.ts
2204
2377
  var react_exports = {};
2205
2378
  __export(react_exports, {
2379
+ clearUser: () => clearUser2,
2206
2380
  destroyCheckflow: () => destroyCheckflow,
2381
+ getFeedbackButtonHandler: () => getFeedbackButtonHandler,
2382
+ openFeedbackModal: () => openFeedbackModal3,
2383
+ setUser: () => setUser2,
2207
2384
  useCheckflowFeedback: () => useCheckflowFeedback,
2208
2385
  useCheckflowInit: () => useCheckflowInit
2209
2386
  });
2210
2387
  module.exports = __toCommonJS(react_exports);
2211
2388
  var _initialized = false;
2389
+ var _config = null;
2212
2390
  function useCheckflowInit(config2) {
2213
2391
  if (typeof window === "undefined") return;
2214
2392
  if (_initialized) return;
2215
2393
  _initialized = true;
2394
+ _config = config2;
2216
2395
  Promise.resolve().then(() => (init_index(), index_exports)).then(({ init: init2 }) => {
2217
2396
  init2(config2);
2218
2397
  });
2219
2398
  }
2399
+ async function setUser2(user) {
2400
+ if (typeof window === "undefined") return;
2401
+ const { setUser: sdkSetUser } = await Promise.resolve().then(() => (init_index(), index_exports));
2402
+ sdkSetUser(user);
2403
+ }
2404
+ async function clearUser2() {
2405
+ if (typeof window === "undefined") return;
2406
+ const { clearUser: sdkClearUser } = await Promise.resolve().then(() => (init_index(), index_exports));
2407
+ sdkClearUser();
2408
+ }
2409
+ async function openFeedbackModal3() {
2410
+ if (typeof window === "undefined") return;
2411
+ const { openFeedbackModal: sdkOpenModal } = await Promise.resolve().then(() => (init_index(), index_exports));
2412
+ sdkOpenModal();
2413
+ }
2220
2414
  function useCheckflowFeedback() {
2221
2415
  return {
2222
2416
  send: async (data) => {
@@ -2243,7 +2437,10 @@ function useCheckflowFeedback() {
2243
2437
  if (typeof window === "undefined") return;
2244
2438
  const { hideWidget: hideWidget2 } = await Promise.resolve().then(() => (init_index(), index_exports));
2245
2439
  hideWidget2();
2246
- }
2440
+ },
2441
+ openModal: openFeedbackModal3,
2442
+ setUser: setUser2,
2443
+ clearUser: clearUser2
2247
2444
  };
2248
2445
  }
2249
2446
  function destroyCheckflow() {
@@ -2251,11 +2448,22 @@ function destroyCheckflow() {
2251
2448
  Promise.resolve().then(() => (init_index(), index_exports)).then(({ destroy: destroy2 }) => {
2252
2449
  destroy2();
2253
2450
  _initialized = false;
2451
+ _config = null;
2254
2452
  });
2255
2453
  }
2454
+ function getFeedbackButtonHandler(onClick) {
2455
+ return () => {
2456
+ onClick?.();
2457
+ openFeedbackModal3();
2458
+ };
2459
+ }
2256
2460
  // Annotate the CommonJS export names for ESM import in node:
2257
2461
  0 && (module.exports = {
2462
+ clearUser,
2258
2463
  destroyCheckflow,
2464
+ getFeedbackButtonHandler,
2465
+ openFeedbackModal,
2466
+ setUser,
2259
2467
  useCheckflowFeedback,
2260
2468
  useCheckflowInit
2261
2469
  });
package/dist/react.mjs CHANGED
@@ -1,13 +1,30 @@
1
1
  // src/react.ts
2
2
  var _initialized = false;
3
+ var _config = null;
3
4
  function useCheckflowInit(config) {
4
5
  if (typeof window === "undefined") return;
5
6
  if (_initialized) return;
6
7
  _initialized = true;
8
+ _config = config;
7
9
  import("./index.mjs").then(({ init }) => {
8
10
  init(config);
9
11
  });
10
12
  }
13
+ async function setUser(user) {
14
+ if (typeof window === "undefined") return;
15
+ const { setUser: sdkSetUser } = await import("./index.mjs");
16
+ sdkSetUser(user);
17
+ }
18
+ async function clearUser() {
19
+ if (typeof window === "undefined") return;
20
+ const { clearUser: sdkClearUser } = await import("./index.mjs");
21
+ sdkClearUser();
22
+ }
23
+ async function openFeedbackModal() {
24
+ if (typeof window === "undefined") return;
25
+ const { openFeedbackModal: sdkOpenModal } = await import("./index.mjs");
26
+ sdkOpenModal();
27
+ }
11
28
  function useCheckflowFeedback() {
12
29
  return {
13
30
  send: async (data) => {
@@ -34,7 +51,10 @@ function useCheckflowFeedback() {
34
51
  if (typeof window === "undefined") return;
35
52
  const { hideWidget } = await import("./index.mjs");
36
53
  hideWidget();
37
- }
54
+ },
55
+ openModal: openFeedbackModal,
56
+ setUser,
57
+ clearUser
38
58
  };
39
59
  }
40
60
  function destroyCheckflow() {
@@ -42,10 +62,21 @@ function destroyCheckflow() {
42
62
  import("./index.mjs").then(({ destroy }) => {
43
63
  destroy();
44
64
  _initialized = false;
65
+ _config = null;
45
66
  });
46
67
  }
68
+ function getFeedbackButtonHandler(onClick) {
69
+ return () => {
70
+ onClick?.();
71
+ openFeedbackModal();
72
+ };
73
+ }
47
74
  export {
75
+ clearUser,
48
76
  destroyCheckflow,
77
+ getFeedbackButtonHandler,
78
+ openFeedbackModal,
79
+ setUser,
49
80
  useCheckflowFeedback,
50
81
  useCheckflowInit
51
82
  };