@mx-cartographer/experiences 9.7.202 → 9.7.204

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/core/stores/AnalyticsStore.es.js +9 -8
  3. package/dist/core/stores/AnalyticsStore.es.js.map +1 -1
  4. package/dist/core/stores/InsightsV2Store.d.ts +4 -0
  5. package/dist/core/stores/InsightsV2Store.es.js +10 -8
  6. package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
  7. package/dist/core/types/Insights.d.ts +1 -0
  8. package/dist/core/types/Insights.es.js.map +1 -1
  9. package/dist/core/utils/PostHog.d.ts +2 -0
  10. package/dist/core/utils/PostHog.es.js +6 -0
  11. package/dist/core/utils/PostHog.es.js.map +1 -0
  12. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +28 -28
  13. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
  14. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.d.ts +4 -4
  15. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +14 -14
  16. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
  17. package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.d.ts +5 -5
  18. package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +26 -26
  19. package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js.map +1 -1
  20. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.d.ts +14 -0
  21. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.es.js +324 -0
  22. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.es.js.map +1 -0
  23. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/index.d.ts +1 -0
  24. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.d.ts +29 -0
  25. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.es.js +25 -0
  26. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.es.js.map +1 -0
  27. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +34 -34
  28. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
  29. package/dist/insights-v2/blocks/ComponentBlocks/index.d.ts +1 -0
  30. package/dist/insights-v2/components/BaseLayout.es.js +137 -135
  31. package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
  32. package/dist/insights-v2/components/Header.d.ts +5 -1
  33. package/dist/insights-v2/components/Header.es.js +15 -15
  34. package/dist/insights-v2/components/Header.es.js.map +1 -1
  35. package/dist/insights-v2/components/MerchantHighlightCard.d.ts +2 -2
  36. package/dist/insights-v2/components/MerchantHighlightCard.es.js +5 -5
  37. package/dist/insights-v2/components/MerchantHighlightCard.es.js.map +1 -1
  38. package/dist/insights-v2/index.es.js +51 -49
  39. package/dist/insights-v2/mappings/blocks.es.js +96 -94
  40. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  41. package/package.json +1 -1
@@ -7,18 +7,18 @@ interface DebtsBlockProps {
7
7
  * Debts component block: the Debt Payment Reminder card (Figma 1943:219556). One bordered card:
8
8
  *
9
9
  * - the upcoming payment, from `data.series[0]`: `logo`, `primary_text` (payment name),
10
- * `secondary_text` (account name) and `amount` (the payment);
11
- * - "Payment Due On" with `data.due_date` (ISO day, shown as "September 15");
10
+ * `secondary_text` (account name) and `amount` (the payment)
11
+ * - "Payment Due On" with `data.due_date` (ISO day, shown as "September 15")
12
12
  * - "Minimum Payment" with `data.minimum_payment`, only when ditto sends one (Figma "Has Minimum
13
- * Payment"; "No Minimum Payment" omits the line);
13
+ * Payment" "No Minimum Payment" omits the line)
14
14
  * - the account balance, `data.amount`.
15
15
  *
16
16
  * The last line drawn sits on the grey surface: the balance on full, the due date on mini (whose
17
17
  * Figma draws the due date alone).
18
18
  *
19
19
  * Every caption comes from the backend, in the beat's own slots (`due_date_label`, `minimum_payment_label`,
20
- * `amount_label`); there is no frontend fallback. A line whose label or value is missing or invalid is left out
21
- * rather than drawn unlabelled or blank; a missing label for a line that has a value also warns once, naming the
20
+ * `amount_label`) there is no frontend fallback. A line whose label or value is missing or invalid is left out
21
+ * rather than drawn unlabelled or blank a missing label for a line that has a value also warns once, naming the
22
22
  * slot. With no payment row there is no card.
23
23
  */
24
24
  declare const DebtsBlock: ({ payload }: DebtsBlockProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,28 +1,28 @@
1
1
  import { DATE_FORMATS_INTL as R, formatDate as w } from "../../../../core/constants/DateFormats.es.js";
2
2
  import { slot as a } from "../../../../core/types/Insights.es.js";
3
- import { CURRENCY_FORMAT as f, formatCurrency as _ } from "../../../../core/utils/NumberFormatting.es.js";
4
- import { asLogoRef as k, asNonEmptyText as u, asNumber as v, asText as T } from "../../slotReaders.es.js";
3
+ import { CURRENCY_FORMAT as b, formatCurrency as _ } from "../../../../core/utils/NumberFormatting.es.js";
4
+ import { asLogoRef as k, asNonEmptyText as c, asNumber as v, asText as T } from "../../slotReaders.es.js";
5
5
  import A from "../../../components/LogoFromGuid.es.js";
6
6
  import F from "../../../components/InsightTransactionRow.es.js";
7
7
  import { parseDueDate as O } from "../RepeatingTransactionBlock/weekStrip.es.js";
8
8
  import { useEffect as j } from "react";
9
- import y from "@mui/material/Stack";
9
+ import g from "@mui/material/Stack";
10
10
  import { Text as L } from "@mxenabled/mxui";
11
- import { Fragment as C, jsx as n, jsxs as g } from "react/jsx-runtime";
11
+ import { Fragment as C, jsx as n, jsxs as y } from "react/jsx-runtime";
12
12
  import E from "@mui/material/Divider";
13
13
  var I = 32, N = (r) => {
14
14
  if (Array.isArray(r))
15
15
  for (const e of r) {
16
16
  if (typeof e != "object" || e === null) continue;
17
- const { amount: t, logo: l, primary_text: i, secondary_text: o } = e, m = u(i);
17
+ const { amount: t, logo: i, primary_text: l, secondary_text: o } = e, m = c(l);
18
18
  if (m) return {
19
19
  name: m,
20
20
  account: T(o),
21
21
  amount: v(t),
22
- logo: k(l)
22
+ logo: k(i)
23
23
  };
24
24
  }
25
- }, S = ({ grey: r, label: e, value: t }) => /* @__PURE__ */ g(C, { children: [/* @__PURE__ */ n(E, {}), /* @__PURE__ */ g(y, {
25
+ }, S = ({ grey: r, label: e, value: t }) => /* @__PURE__ */ y(C, { children: [/* @__PURE__ */ n(E, {}), /* @__PURE__ */ y(g, {
26
26
  sx: {
27
27
  alignItems: "center",
28
28
  bgcolor: r ? "background.default" : "background.paper",
@@ -34,40 +34,40 @@ var I = 32, N = (r) => {
34
34
  },
35
35
  children: [/* @__PURE__ */ n(L, {
36
36
  color: "text.primary",
37
- variant: "subtitle2",
37
+ variant: "caption",
38
38
  children: e
39
39
  }), /* @__PURE__ */ n(L, {
40
- bold: !0,
41
40
  color: "text.primary",
42
41
  variant: "caption",
42
+ sx: { fontWeight: 700 },
43
43
  children: t
44
44
  })]
45
45
  })] }), q = ({ payload: r }) => {
46
- const e = r.instance_slot?.data, t = u(a(e, "due_date_label")), l = u(a(e, "minimum_payment_label")), i = u(a(e, "amount_label")), o = N(a(e, "series")), m = T(a(e, "due_date")), c = m ? O(m) : null, d = v(a(e, "minimum_payment")), p = v(a(e, "amount")), x = o !== void 0, b = [
47
- c && !t && "due_date_label",
48
- d !== void 0 && !l && "minimum_payment_label",
49
- p !== void 0 && !i && "amount_label"
46
+ const e = r.instance_slot?.data, t = c(a(e, "due_date_label")), i = c(a(e, "minimum_payment_label")), l = c(a(e, "amount_label")), o = N(a(e, "series")), m = T(a(e, "due_date")), u = m ? O(m) : null, d = v(a(e, "minimum_payment")), p = v(a(e, "amount")), x = o !== void 0, f = [
47
+ u && !t && "due_date_label",
48
+ d !== void 0 && !i && "minimum_payment_label",
49
+ p !== void 0 && !l && "amount_label"
50
50
  ].filter(Boolean).join(", ");
51
51
  if (j(() => {
52
- x && b && console.warn(`debts_block: backend sent no ${b}; hiding those lines`);
53
- }, [x, b]), !o) return null;
52
+ x && f && console.warn(`debts_block: backend sent no ${f}; hiding those lines`);
53
+ }, [x, f]), !o) return null;
54
54
  const h = [
55
- t && c ? {
55
+ t && u ? {
56
56
  label: t,
57
- value: w(c, R.FULL_MONTH_DAY)
58
- } : null,
59
- l && d !== void 0 ? {
60
- label: l,
61
- value: _(d, f.cents)
57
+ value: w(u, R.FULL_MONTH_DAY)
62
58
  } : null,
63
- i && p !== void 0 ? {
59
+ i && d !== void 0 ? {
64
60
  label: i,
65
- value: _(p, f.cents)
61
+ value: _(d, b.cents)
62
+ } : null,
63
+ l && p !== void 0 ? {
64
+ label: l,
65
+ value: _(p, b.cents)
66
66
  } : null
67
67
  ].filter((s) => s !== null);
68
- return /* @__PURE__ */ n(y, {
68
+ return /* @__PURE__ */ n(g, {
69
69
  sx: { px: 16 },
70
- children: /* @__PURE__ */ g(y, {
70
+ children: /* @__PURE__ */ y(g, {
71
71
  sx: {
72
72
  border: "1px solid",
73
73
  borderColor: "divider",
@@ -76,7 +76,7 @@ var I = 32, N = (r) => {
76
76
  width: "100%"
77
77
  },
78
78
  children: [/* @__PURE__ */ n(F, {
79
- amount: o.amount === void 0 ? "" : _(o.amount, f.cents),
79
+ amount: o.amount === void 0 ? "" : _(o.amount, b.cents),
80
80
  leading: /* @__PURE__ */ n(A, {
81
81
  logo: o.logo,
82
82
  size: I
@@ -1 +1 @@
1
- {"version":3,"file":"DebtsBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.tsx"],"sourcesContent":["import { useEffect } from 'react'\n\nimport Divider from '@mui/material/Divider'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { slot, type InsightsPayload, type LogoRef } from '../../../../core'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../../core/constants'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport InsightTransactionRow from '../../../components/InsightTransactionRow'\nimport LogoFromGuid from '../../../components/LogoFromGuid'\nimport { asLogoRef, asNonEmptyText, asNumber, asText } from '../../slotReaders'\nimport { parseDueDate } from '../RepeatingTransactionBlock/weekStrip'\n\ninterface DebtsBlockProps {\n payload: InsightsPayload\n beatGuid?: string\n}\n\nconst ROW_LOGO_SIZE = 32\n\ninterface PaymentRow {\n name: string\n account?: string\n amount?: number\n logo?: LogoRef\n}\n\n/** The first `series` row with a name, read through the shared slot readers; else undefined. */\nconst readPayment = (series: unknown): PaymentRow | undefined => {\n if (!Array.isArray(series)) return undefined\n for (const row of series) {\n if (typeof row !== 'object' || row === null) continue\n const { amount, logo, primary_text, secondary_text } = row as Record<string, unknown>\n const name = asNonEmptyText(primary_text)\n if (name) {\n return {\n name,\n account: asText(secondary_text),\n amount: asNumber(amount),\n logo: asLogoRef(logo),\n }\n }\n }\n return undefined\n}\n\n/** A label / value line under the payment row; the card's last line sits on the grey surface. */\nconst SummaryLine = ({ grey, label, value }: { grey?: boolean; label: string; value: string }) => (\n <>\n <Divider />\n <Stack\n sx={{\n alignItems: 'center',\n bgcolor: grey ? 'background.default' : 'background.paper',\n flexDirection: 'row',\n justifyContent: 'space-between',\n minHeight: 40,\n px: 16,\n py: 2,\n }}\n >\n <Text color=\"text.primary\" variant=\"subtitle2\">\n {label}\n </Text>\n <Text bold={true} color=\"text.primary\" variant=\"caption\">\n {value}\n </Text>\n </Stack>\n </>\n)\n\n/**\n * Debts component block: the Debt Payment Reminder card (Figma 1943:219556). One bordered card:\n *\n * - the upcoming payment, from `data.series[0]`: `logo`, `primary_text` (payment name),\n * `secondary_text` (account name) and `amount` (the payment);\n * - \"Payment Due On\" with `data.due_date` (ISO day, shown as \"September 15\");\n * - \"Minimum Payment\" with `data.minimum_payment`, only when ditto sends one (Figma \"Has Minimum\n * Payment\"; \"No Minimum Payment\" omits the line);\n * - the account balance, `data.amount`.\n *\n * The last line drawn sits on the grey surface: the balance on full, the due date on mini (whose\n * Figma draws the due date alone).\n *\n * Every caption comes from the backend, in the beat's own slots (`due_date_label`, `minimum_payment_label`,\n * `amount_label`); there is no frontend fallback. A line whose label or value is missing or invalid is left out\n * rather than drawn unlabelled or blank; a missing label for a line that has a value also warns once, naming the\n * slot. With no payment row there is no card.\n */\nconst DebtsBlock = ({ payload }: DebtsBlockProps) => {\n // Backend data is untrusted: every value goes through the shared slot readers before use.\n const data = payload.instance_slot?.data\n const dueLabel = asNonEmptyText(slot(data, 'due_date_label'))\n const minimumLabel = asNonEmptyText(slot(data, 'minimum_payment_label'))\n const balanceLabel = asNonEmptyText(slot(data, 'amount_label'))\n const payment = readPayment(slot(data, 'series'))\n const dueDateIso = asText(slot(data, 'due_date'))\n const dueDate = dueDateIso ? parseDueDate(dueDateIso) : null\n const minimum = asNumber(slot(data, 'minimum_payment'))\n const balance = asNumber(slot(data, 'amount'))\n const hasPayment = payment !== undefined\n\n // Only the labels for lines this card has a value to draw (mini sends no balance).\n const missingKeys = [\n dueDate && !dueLabel && 'due_date_label',\n minimum !== undefined && !minimumLabel && 'minimum_payment_label',\n balance !== undefined && !balanceLabel && 'amount_label',\n ]\n .filter(Boolean)\n .join(', ')\n\n useEffect(() => {\n if (hasPayment && missingKeys) {\n console.warn(`debts_block: backend sent no ${missingKeys}; hiding those lines`)\n }\n }, [hasPayment, missingKeys])\n\n if (!payment) return null\n\n // Figma's order; the last line drawn sits on the grey surface.\n const lines = [\n dueLabel && dueDate\n ? { label: dueLabel, value: formatDate(dueDate, DATE_FORMATS_INTL.FULL_MONTH_DAY) }\n : null,\n minimumLabel && minimum !== undefined\n ? { label: minimumLabel, value: formatCurrency(minimum, CURRENCY_FORMAT.cents) }\n : null,\n balanceLabel && balance !== undefined\n ? { label: balanceLabel, value: formatCurrency(balance, CURRENCY_FORMAT.cents) }\n : null,\n ].filter((line): line is { label: string; value: string } => line !== null)\n\n return (\n <Stack sx={{ px: 16 }}>\n <Stack\n sx={{\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '8px',\n overflow: 'hidden',\n width: '100%',\n }}\n >\n <InsightTransactionRow\n amount={\n payment.amount === undefined\n ? ''\n : formatCurrency(payment.amount, CURRENCY_FORMAT.cents)\n }\n leading={<LogoFromGuid logo={payment.logo} size={ROW_LOGO_SIZE} />}\n subtitle={payment.account ?? ''}\n title={payment.name}\n />\n {lines.map((line, index) => (\n <SummaryLine\n grey={index === lines.length - 1}\n key={index}\n label={line.label}\n value={line.value}\n />\n ))}\n </Stack>\n </Stack>\n )\n}\n\nexport default DebtsBlock\n"],"mappings":";;;;;;;;;;;;AAqBA,IAAM,IAAgB,IAUhB,IAAA,CAAe,MAA4C;AAC/D,MAAK,MAAM,QAAQ,CAAM;AACzB,eAAW,KAAO,GAAQ;AACxB,UAAI,OAAO,KAAQ,YAAY,MAAQ,KAAM;AAC7C,YAAM,EAAE,QAAA,GAAQ,MAAA,GAAM,cAAA,GAAc,gBAAA,EAAA,IAAmB,GACjD,IAAO,EAAe,CAAY;AACxC,UAAI,EACF,QAAO;AAAA,QACL,MAAA;AAAA,QACA,SAAS,EAAO,CAAc;AAAA,QAC9B,QAAQ,EAAS,CAAM;AAAA,QACvB,MAAM,EAAU,CAAI;AAAA,MACtB;AAAA,IAEJ;AAEF,GAGM,IAAA,CAAe,EAAE,MAAA,GAAM,OAAA,GAAO,OAAA,EAAA,MAClC,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD,CAAU,CAAA,GACV,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS,IAAO,uBAAuB;AAAA,IACvC,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAAA,EATF,UAAA,CAWE,gBAAA,EAAC,GAAD;AAAA,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ACxB;AAAA,MAAE,OAAO;AAAA,MAAc,OAAO,EAAe,GAAS,EAAgB,KAAK;AAAA,IAAE,IAC7E;AAAA,EACN,EAAE,OAAA,CAAQ,MAAmD,MAAS,IAAI;AAE1E,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,IAAI,GAAG;AAAA,IAClB,UAAA,gBAAA,EAAC,GAAD;AAAA,MACE,IAAI;AAAA,QACF,QAAQ;AAAA,QACR,aAAa;AAAA,QACb,cAAc;AAAA,QACd,UAAU;AAAA,QACV,OAAO;AAAA,MACT;AAAA,MAPF,UAAA,CASE,gBAAA,EAAC,GAAD;AAAA,QACE,QACE,EAAQ,WAAW,SACf,KACA,EAAe,EAAQ,QAAQ,EAAgB,KAAK;AAAA,QAE1D,SAAS,gBAAA,EAAC,GAAD;AAAA,UAAc,MAAM,EAAQ;AAAA,UAAM,MAAM;AAAA,QAAgB,CAAA;AAAA,QACjE,UAAU,EAAQ,WAAW;AAAA,QAC7B,OAAO,EAAQ;AAAA,MAChB,CAAA,GACA,EAAM,IAAA,CAAK,GAAM,MAChB,gBAAA,EAAC,GAAD;AAAA,QACE,MAAM,MAAU,EAAM,SAAS;AAAA,QAE/B,OAAO,EAAK;AAAA,QACZ,OAAO,EAAK;AAAA,MACb,GAHM,CAGN,CACF,CACI;AAAA;EACF,CAAA;AAEX"}
1
+ {"version":3,"file":"DebtsBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.tsx"],"sourcesContent":["import { useEffect } from 'react'\n\nimport Divider from '@mui/material/Divider'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { slot, type InsightsPayload, type LogoRef } from '../../../../core'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../../core/constants'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport InsightTransactionRow from '../../../components/InsightTransactionRow'\nimport LogoFromGuid from '../../../components/LogoFromGuid'\nimport { asLogoRef, asNonEmptyText, asNumber, asText } from '../../slotReaders'\nimport { parseDueDate } from '../RepeatingTransactionBlock/weekStrip'\n\ninterface DebtsBlockProps {\n payload: InsightsPayload\n beatGuid?: string\n}\n\nconst ROW_LOGO_SIZE = 32\n\ninterface PaymentRow {\n name: string\n account?: string\n amount?: number\n logo?: LogoRef\n}\n\n/** The first `series` row with a name, read through the shared slot readers else undefined. */\nconst readPayment = (series: unknown): PaymentRow | undefined => {\n if (!Array.isArray(series)) return undefined\n for (const row of series) {\n if (typeof row !== 'object' || row === null) continue\n const { amount, logo, primary_text, secondary_text } = row as Record<string, unknown>\n const name = asNonEmptyText(primary_text)\n if (name) {\n return {\n name,\n account: asText(secondary_text),\n amount: asNumber(amount),\n logo: asLogoRef(logo),\n }\n }\n }\n return undefined\n}\n\n/** A label / value line under the payment row the card's last line sits on the grey surface. */\nconst SummaryLine = ({ grey, label, value }: { grey?: boolean; label: string; value: string }) => (\n <>\n <Divider />\n <Stack\n sx={{\n alignItems: 'center',\n bgcolor: grey ? 'background.default' : 'background.paper',\n flexDirection: 'row',\n justifyContent: 'space-between',\n minHeight: 40,\n px: 16,\n py: 2,\n }}\n >\n <Text color=\"text.primary\" variant=\"caption\">\n {label}\n </Text>\n <Text color=\"text.primary\" variant=\"caption\" sx={{ fontWeight: 700 }}>\n {value}\n </Text>\n </Stack>\n </>\n)\n\n/**\n * Debts component block: the Debt Payment Reminder card (Figma 1943:219556). One bordered card:\n *\n * - the upcoming payment, from `data.series[0]`: `logo`, `primary_text` (payment name),\n * `secondary_text` (account name) and `amount` (the payment)\n * - \"Payment Due On\" with `data.due_date` (ISO day, shown as \"September 15\")\n * - \"Minimum Payment\" with `data.minimum_payment`, only when ditto sends one (Figma \"Has Minimum\n * Payment\" \"No Minimum Payment\" omits the line)\n * - the account balance, `data.amount`.\n *\n * The last line drawn sits on the grey surface: the balance on full, the due date on mini (whose\n * Figma draws the due date alone).\n *\n * Every caption comes from the backend, in the beat's own slots (`due_date_label`, `minimum_payment_label`,\n * `amount_label`) there is no frontend fallback. A line whose label or value is missing or invalid is left out\n * rather than drawn unlabelled or blank a missing label for a line that has a value also warns once, naming the\n * slot. With no payment row there is no card.\n */\nconst DebtsBlock = ({ payload }: DebtsBlockProps) => {\n // Backend data is untrusted: every value goes through the shared slot readers before use.\n const data = payload.instance_slot?.data\n const dueLabel = asNonEmptyText(slot(data, 'due_date_label'))\n const minimumLabel = asNonEmptyText(slot(data, 'minimum_payment_label'))\n const balanceLabel = asNonEmptyText(slot(data, 'amount_label'))\n const payment = readPayment(slot(data, 'series'))\n const dueDateIso = asText(slot(data, 'due_date'))\n const dueDate = dueDateIso ? parseDueDate(dueDateIso) : null\n const minimum = asNumber(slot(data, 'minimum_payment'))\n const balance = asNumber(slot(data, 'amount'))\n const hasPayment = payment !== undefined\n\n // Only the labels for lines this card has a value to draw (mini sends no balance).\n const missingKeys = [\n dueDate && !dueLabel && 'due_date_label',\n minimum !== undefined && !minimumLabel && 'minimum_payment_label',\n balance !== undefined && !balanceLabel && 'amount_label',\n ]\n .filter(Boolean)\n .join(', ')\n\n useEffect(() => {\n if (hasPayment && missingKeys) {\n console.warn(`debts_block: backend sent no ${missingKeys}; hiding those lines`)\n }\n }, [hasPayment, missingKeys])\n\n if (!payment) return null\n\n // Figma's order the last line drawn sits on the grey surface.\n const lines = [\n dueLabel && dueDate\n ? {\n label: dueLabel,\n value: formatDate(dueDate, DATE_FORMATS_INTL.FULL_MONTH_DAY),\n }\n : null,\n minimumLabel && minimum !== undefined\n ? {\n label: minimumLabel,\n value: formatCurrency(minimum, CURRENCY_FORMAT.cents),\n }\n : null,\n balanceLabel && balance !== undefined\n ? {\n label: balanceLabel,\n value: formatCurrency(balance, CURRENCY_FORMAT.cents),\n }\n : null,\n ].filter((line): line is { label: string; value: string } => line !== null)\n\n return (\n <Stack sx={{ px: 16 }}>\n <Stack\n sx={{\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '8px',\n overflow: 'hidden',\n width: '100%',\n }}\n >\n <InsightTransactionRow\n amount={\n payment.amount === undefined\n ? ''\n : formatCurrency(payment.amount, CURRENCY_FORMAT.cents)\n }\n leading={<LogoFromGuid logo={payment.logo} size={ROW_LOGO_SIZE} />}\n subtitle={payment.account ?? ''}\n title={payment.name}\n />\n {lines.map((line, index) => (\n <SummaryLine\n grey={index === lines.length - 1}\n key={index}\n label={line.label}\n value={line.value}\n />\n ))}\n </Stack>\n </Stack>\n )\n}\n\nexport default DebtsBlock\n"],"mappings":";;;;;;;;;;;;AAqBA,IAAM,IAAgB,IAUhB,IAAA,CAAe,MAA4C;AAC/D,MAAK,MAAM,QAAQ,CAAM;AACzB,eAAW,KAAO,GAAQ;AACxB,UAAI,OAAO,KAAQ,YAAY,MAAQ,KAAM;AAC7C,YAAM,EAAE,QAAA,GAAQ,MAAA,GAAM,cAAA,GAAc,gBAAA,EAAA,IAAmB,GACjD,IAAO,EAAe,CAAY;AACxC,UAAI,EACF,QAAO;AAAA,QACL,MAAA;AAAA,QACA,SAAS,EAAO,CAAc;AAAA,QAC9B,QAAQ,EAAS,CAAM;AAAA,QACvB,MAAM,EAAU,CAAI;AAAA,MACtB;AAAA,IAEJ;AAEF,GAGM,IAAA,CAAe,EAAE,MAAA,GAAM,OAAA,GAAO,OAAA,EAAA,MAClC,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD,CAAU,CAAA,GACV,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS,IAAO,uBAAuB;AAAA,IACvC,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAAA,EATF,UAAA,CAWE,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAe,SAAQ;AAAA,IAChC,UAAA;AAAA,EACG,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,IAAM,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AAE,OAAA,CAAQ,MAAmD,MAAS,IAAI;AAE1E,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,IAAI,GAAG;AAAA,IAClB,UAAA,gBAAA,EAAC,GAAD;AAAA,MACE,IAAI;AAAA,QACF,QAAQ;AAAA,QACR,aAAa;AAAA,QACb,cAAc;AAAA,QACd,UAAU;AAAA,QACV,OAAO;AAAA,MACT;AAAA,MAPF,UAAA,CASE,gBAAA,EAAC,GAAD;AAAA,QACE,QACE,EAAQ,WAAW,SACf,KACA,EAAe,EAAQ,QAAQ,EAAgB,KAAK;AAAA,QAE1D,SAAS,gBAAA,EAAC,GAAD;AAAA,UAAc,MAAM,EAAQ;AAAA,UAAM,MAAM;AAAA,QAAgB,CAAA;AAAA,QACjE,UAAU,EAAQ,WAAW;AAAA,QAC7B,OAAO,EAAQ;AAAA,MAChB,CAAA,GACA,EAAM,IAAA,CAAK,GAAM,MAChB,gBAAA,EAAC,GAAD;AAAA,QACE,MAAM,MAAU,EAAM,SAAS;AAAA,QAE/B,OAAO,EAAK;AAAA,QACZ,OAAO,EAAK;AAAA,MACb,GAHM,CAGN,CACF,CACI;AAAA;EACF,CAAA;AAEX"}
@@ -0,0 +1,14 @@
1
+ import { BlockProps } from '../../types';
2
+ /** beatContext key: the survey's shown event already fired for this beat (survives a remount after Undo). */
3
+ export declare const SURVEY_SHOWN_KEY = "survey_shown";
4
+ /** beatContext key: the result phase ('sent' | 'error'), so a remount shows it, not the survey again. */
5
+ export declare const SURVEY_PHASE_KEY = "survey_phase";
6
+ /**
7
+ * The User Feedback survey (Figma 1283:81740): two 1-5 ratings and a free-text answer, one per step,
8
+ * then a thank-you. The question is the card's title. On submit it sends PostHog's survey events and
9
+ * dismisses the beat, keeping the card (and its thank-you) in the feed until the next refresh.
10
+ */
11
+ declare const FeedbackBlock: (({ beatGuid, payload }: BlockProps) => import("react/jsx-runtime").JSX.Element | null) & {
12
+ displayName: string;
13
+ };
14
+ export default FeedbackBlock;
@@ -0,0 +1,324 @@
1
+ import { buildDynamicCopy as F } from "../../../../core/utils/Localization.es.js";
2
+ import { useGlobalStore as se, useInsightsV2Store as ie } from "../../../../common/context/hooks.es.js";
3
+ import { VISUALLY_HIDDEN_SX as ae } from "../../../../common/constants/Styles.es.js";
4
+ import { BEAT_CARD_TITLE_KEY as V, BEAT_KEEP_AFTER_DISMISS_KEY as j } from "../../../../core/stores/InsightsV2Store.es.js";
5
+ import { useBeatActions as ce } from "../../../beatActions.es.js";
6
+ import { asNonEmptyText as le } from "../../slotReaders.es.js";
7
+ import { HOST_ACTIONS as ue } from "../../../ctaActions/hostActions.es.js";
8
+ import { useAnalyticsEvent as pe } from "../../../analytics/useAnalyticsEvent.es.js";
9
+ import { userFeedbackSurveyEvents as fe, userFeedbackSurveyId as de } from "./survey.es.js";
10
+ import { useEffect as x, useRef as m, useState as _ } from "react";
11
+ import { observer as me } from "mobx-react-lite";
12
+ import u from "@mui/material/Stack";
13
+ import { Text as C } from "@mxenabled/mxui";
14
+ import z from "@mui/material/Button";
15
+ import { Icon as he } from "@mxenabled/mx-icons";
16
+ import { jsx as o, jsxs as h } from "react/jsx-runtime";
17
+ import { alpha as ge } from "@mui/material/styles";
18
+ import S from "@mui/material/Box";
19
+ import ye from "@mui/material/TextField";
20
+ import be from "@mui/material/ButtonBase";
21
+ var xe = [
22
+ "question1",
23
+ "question2",
24
+ "question3",
25
+ "strongly_disagree",
26
+ "strongly_agree",
27
+ "continue",
28
+ "submit_feedback",
29
+ "feedback",
30
+ "feedback_placeholder",
31
+ "thank_you",
32
+ "feedback_sent",
33
+ "oops",
34
+ "feedback_error",
35
+ "try_again",
36
+ "rating_aria",
37
+ "step_count"
38
+ ], _e = (e) => xe.every((i) => le(e?.[i]) !== void 0) ? e : void 0, g = [
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5
44
+ ], X = 3, U = 500, ve = "survey_shown", M = "survey_phase", $ = {
45
+ ArrowDown: 1,
46
+ ArrowLeft: -1,
47
+ ArrowRight: 1,
48
+ ArrowUp: -1
49
+ }, Se = (e) => e === "sent" || e === "error", Ee = ({ step: e }) => /* @__PURE__ */ o(u, {
50
+ "aria-hidden": !0,
51
+ direction: "row",
52
+ sx: {
53
+ gap: 4,
54
+ height: 4
55
+ },
56
+ children: Array.from({ length: X }, (i, t) => /* @__PURE__ */ o(S, { sx: (a) => ({
57
+ bgcolor: t <= e ? "primary.main" : a.palette.grey[a.palette.mode === "dark" ? 500 : 300],
58
+ borderRadius: "24px",
59
+ flex: 1
60
+ }) }, t))
61
+ }), Re = (e, i) => {
62
+ if (e === "Home") return 0;
63
+ if (e === "End") return g.length - 1;
64
+ if (e in $) return (i + $[e] + g.length) % g.length;
65
+ }, ke = ({ ariaLabel: e, label: i, onChange: t, tabStopRef: a, value: n }) => {
66
+ const p = m([]), y = n === void 0 ? 0 : g.indexOf(n), b = (l, f) => {
67
+ const c = Re(l.key, f);
68
+ c !== void 0 && (l.preventDefault(), p.current[c]?.focus(), t(g[c]));
69
+ };
70
+ return /* @__PURE__ */ o(u, {
71
+ "aria-label": i,
72
+ direction: "row",
73
+ role: "radiogroup",
74
+ children: g.map((l, f) => {
75
+ const c = l === n;
76
+ return /* @__PURE__ */ o(be, {
77
+ "aria-checked": c,
78
+ "aria-label": e(l),
79
+ onClick: () => t(l),
80
+ onKeyDown: (r) => b(r, f),
81
+ ref: (r) => {
82
+ p.current[f] = r, f === y && (a.current = r);
83
+ },
84
+ role: "radio",
85
+ sx: (r) => ({
86
+ bgcolor: c ? ge(r.palette.primary.main, r.palette.action.selectedOpacity) : void 0,
87
+ border: 1,
88
+ borderColor: c ? "primary.main" : "divider",
89
+ color: "primary.main",
90
+ flex: 1,
91
+ fontSize: 13,
92
+ fontWeight: 600,
93
+ height: 44,
94
+ lineHeight: "16px",
95
+ zIndex: c ? 1 : 0,
96
+ "&:not(:first-of-type)": { ml: "-1px" },
97
+ "&:first-of-type": {
98
+ borderBottomLeftRadius: 4,
99
+ borderTopLeftRadius: 4
100
+ },
101
+ "&:last-of-type": {
102
+ borderBottomRightRadius: 4,
103
+ borderTopRightRadius: 4
104
+ },
105
+ "&.Mui-focusVisible": {
106
+ outline: `2px solid ${r.palette.info.main}`,
107
+ outlineOffset: -2,
108
+ zIndex: 2
109
+ }
110
+ }),
111
+ tabIndex: f === y ? 0 : -1,
112
+ children: l
113
+ }, l);
114
+ })
115
+ });
116
+ }, W = ({ action: e, bannerRef: i, message: t, severity: a }) => /* @__PURE__ */ h(u, {
117
+ direction: "row",
118
+ ref: i,
119
+ role: a === "error" ? "alert" : "status",
120
+ sx: (n) => {
121
+ const p = n.palette.mode === "dark";
122
+ return {
123
+ bgcolor: p ? n.palette[a].main : n.palette[a][600],
124
+ borderRadius: "4px",
125
+ color: p ? n.palette.common.black : n.palette.common.white,
126
+ px: 16,
127
+ py: 8
128
+ };
129
+ },
130
+ tabIndex: -1,
131
+ children: [/* @__PURE__ */ o(S, {
132
+ sx: {
133
+ flexShrink: 0,
134
+ pt: 8,
135
+ width: 32
136
+ },
137
+ children: /* @__PURE__ */ o(he, {
138
+ fill: !0,
139
+ name: a === "success" ? "check_circle" : "error",
140
+ size: 24
141
+ })
142
+ }), /* @__PURE__ */ h(u, {
143
+ sx: {
144
+ gap: 12,
145
+ pl: 4,
146
+ py: 8
147
+ },
148
+ children: [/* @__PURE__ */ o(C, {
149
+ sx: { color: "inherit" },
150
+ variant: "subtitle1",
151
+ children: t
152
+ }), e]
153
+ })]
154
+ }), Me = me(({ beatGuid: e = "", payload: i }) => {
155
+ const t = _e(i.instance_slot?.data), { beatContext: a, setBeatContext: n } = ie(), { onCtaAction: p } = ce(), y = se(), b = pe(), l = y.appDataStore.appConfig?.postHogPublicKey, f = de(l), c = fe(l), [r, J] = _(0), [E, Q] = _([]), [R, Z] = _(""), [d, G] = _(() => {
156
+ const s = a[e]?.[M];
157
+ return Se(s) ? s : "survey";
158
+ }), [I, B] = _(!1), k = m(!1), D = m(i.is_dismissed);
159
+ D.current = i.is_dismissed;
160
+ const w = m(null), K = m(null), P = m(null), H = m(!1), L = !!t;
161
+ x(() => {
162
+ !L || a[e]?.survey_shown || (n(e, { [ve]: !0 }), b(c.shown));
163
+ }, [
164
+ e,
165
+ L,
166
+ f
167
+ ]);
168
+ const ee = m(d);
169
+ x(() => {
170
+ d !== "survey" && d !== ee.current && w.current?.focus();
171
+ }, [d]), x(() => {
172
+ H.current && (r === 2 ? P.current?.focus() : K.current?.focus());
173
+ }, [r]);
174
+ const O = t ? [
175
+ t.question1,
176
+ t.question2,
177
+ t.question3
178
+ ] : [], te = {
179
+ sent: t?.thank_you,
180
+ error: t?.oops
181
+ }, T = d === "survey" ? O[r] : te[d];
182
+ if (x(() => {
183
+ e && typeof T == "string" && n(e, { [V]: T });
184
+ }, [
185
+ e,
186
+ n,
187
+ T
188
+ ]), x(() => () => {
189
+ e && n(e, { [V]: void 0 });
190
+ }, [e, n]), !t) return null;
191
+ const N = (s) => {
192
+ n(e, { [M]: s }), G(s);
193
+ }, Y = async () => {
194
+ try {
195
+ if (!p) throw new Error("No onCtaAction handler to dismiss the beat");
196
+ n(e, { [j]: !0 }), await p({
197
+ beatGuid: e,
198
+ name: ue.dismissBeat
199
+ }), N("sent");
200
+ } catch (s) {
201
+ y.captureException(s, {
202
+ store: "FeedbackBlock",
203
+ handler: "dismissBeat"
204
+ }), D.current || n(e, { [j]: !1 }), N("error");
205
+ }
206
+ }, q = async (s) => {
207
+ if (!k.current) {
208
+ k.current = !0, B(!0);
209
+ try {
210
+ await s();
211
+ } finally {
212
+ k.current = !1, B(!1);
213
+ }
214
+ }
215
+ }, re = () => q(() => {
216
+ const [s, A] = E;
217
+ return b(c.sent(s, A, R.trim().slice(0, U))), b(c.dismissed), Y();
218
+ }), oe = () => {
219
+ H.current = !0, J(r + 1);
220
+ };
221
+ if (d !== "survey") return /* @__PURE__ */ o(S, {
222
+ sx: {
223
+ pb: 16,
224
+ px: 16,
225
+ width: "100%"
226
+ },
227
+ children: d === "sent" ? /* @__PURE__ */ o(W, {
228
+ bannerRef: w,
229
+ message: t.feedback_sent,
230
+ severity: "success"
231
+ }) : /* @__PURE__ */ o(W, {
232
+ action: /* @__PURE__ */ o(z, {
233
+ disabled: I,
234
+ onClick: () => {
235
+ q(Y);
236
+ },
237
+ sx: {
238
+ alignSelf: "flex-start",
239
+ color: "inherit",
240
+ minHeight: 0,
241
+ p: 0
242
+ },
243
+ variant: "text",
244
+ children: t.try_again
245
+ }),
246
+ bannerRef: w,
247
+ message: t.feedback_error,
248
+ severity: "error"
249
+ })
250
+ });
251
+ const v = r === 2, ne = v ? R.trim() !== "" : E[r] !== void 0;
252
+ return /* @__PURE__ */ h(u, {
253
+ sx: { width: "100%" },
254
+ children: [/* @__PURE__ */ h(u, {
255
+ sx: {
256
+ gap: 24,
257
+ pb: 16,
258
+ px: 16
259
+ },
260
+ children: [
261
+ /* @__PURE__ */ o(S, {
262
+ component: "span",
263
+ sx: ae,
264
+ children: F(t.step_count, String(r + 1), String(X))
265
+ }),
266
+ /* @__PURE__ */ o(Ee, { step: r }),
267
+ v ? /* @__PURE__ */ o(ye, {
268
+ inputRef: P,
269
+ label: t.feedback,
270
+ minRows: 2,
271
+ multiline: !0,
272
+ onChange: (s) => Z(s.target.value),
273
+ placeholder: t.feedback_placeholder,
274
+ slotProps: { htmlInput: { maxLength: U } },
275
+ value: R
276
+ }) : /* @__PURE__ */ h(u, {
277
+ sx: {
278
+ gap: 6,
279
+ pb: 8
280
+ },
281
+ children: [/* @__PURE__ */ o(ke, {
282
+ ariaLabel: (s) => F(t.rating_aria, String(s)),
283
+ label: O[r],
284
+ onChange: (s) => Q((A) => Object.assign([...A], { [r]: s })),
285
+ tabStopRef: K,
286
+ value: E[r]
287
+ }), /* @__PURE__ */ h(u, {
288
+ direction: "row",
289
+ sx: { justifyContent: "space-between" },
290
+ children: [/* @__PURE__ */ o(C, {
291
+ color: "text.secondary",
292
+ variant: "caption",
293
+ children: t.strongly_disagree
294
+ }), /* @__PURE__ */ o(C, {
295
+ color: "text.secondary",
296
+ variant: "caption",
297
+ children: t.strongly_agree
298
+ })]
299
+ })]
300
+ })
301
+ ]
302
+ }), /* @__PURE__ */ o(u, {
303
+ sx: {
304
+ pb: 16,
305
+ px: 16
306
+ },
307
+ children: /* @__PURE__ */ o(z, {
308
+ disabled: !ne || I,
309
+ onClick: v ? () => {
310
+ re();
311
+ } : oe,
312
+ variant: "outlined",
313
+ children: v ? t.submit_feedback : t.continue
314
+ })
315
+ })]
316
+ });
317
+ });
318
+ export {
319
+ M as SURVEY_PHASE_KEY,
320
+ ve as SURVEY_SHOWN_KEY,
321
+ Me as default
322
+ };
323
+
324
+ //# sourceMappingURL=FeedbackBlock.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedbackBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.tsx"],"sourcesContent":["import { type KeyboardEvent, type RefObject, useEffect, useRef, useState } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport ButtonBase from '@mui/material/ButtonBase'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport { alpha } from '@mui/material/styles'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useGlobalStore, useInsightsV2Store, VISUALLY_HIDDEN_SX } from '../../../../common'\nimport {\n BEAT_CARD_TITLE_KEY,\n BEAT_KEEP_AFTER_DISMISS_KEY,\n} from '../../../../core/stores/InsightsV2Store'\nimport type { InstanceSlotData } from '../../../../core/types/Insights'\nimport { buildDynamicCopy } from '../../../../core/utils/Localization'\nimport { useAnalyticsEvent } from '../../../analytics'\nimport { useBeatActions } from '../../../beatActions'\nimport { HOST_ACTIONS } from '../../../ctaActions'\nimport { asNonEmptyText } from '../../slotReaders'\nimport type { BlockProps } from '../../types'\nimport { userFeedbackSurveyEvents, userFeedbackSurveyId } from './survey'\n\n/** The survey's words, sent by the server in `instance_slot.data`. */\nconst COPY_SLOTS = [\n 'question1',\n 'question2',\n 'question3',\n 'strongly_disagree',\n 'strongly_agree',\n 'continue',\n 'submit_feedback',\n 'feedback',\n 'feedback_placeholder',\n 'thank_you',\n 'feedback_sent',\n 'oops',\n 'feedback_error',\n 'try_again',\n // `_1{rating}`: a scale button's accessible name.\n 'rating_aria',\n // `_1{step} of _2{total}`: the survey's progress for screen readers (the step bar is decorative).\n 'step_count',\n] as const\ntype FeedbackCopy = Record<(typeof COPY_SLOTS)[number], string>\n\n/** Every copy slot as non-blank text, else undefined: the survey draws nothing rather than a blank label. */\nconst readCopy = (data?: InstanceSlotData): FeedbackCopy | undefined =>\n COPY_SLOTS.every((key) => asNonEmptyText(data?.[key]) !== undefined)\n ? (data as FeedbackCopy)\n : undefined\n\nconst RATINGS = [1, 2, 3, 4, 5]\nconst STEPS = 3\n/** The free-text answer's limit, on the field and on the sent payload. */\nconst FEEDBACK_MAX_LENGTH = 500\n/** beatContext key: the survey's shown event already fired for this beat (survives a remount after Undo). */\nexport const SURVEY_SHOWN_KEY = 'survey_shown'\n/** beatContext key: the result phase ('sent' | 'error'), so a remount shows it, not the survey again. */\nexport const SURVEY_PHASE_KEY = 'survey_phase'\n\n// ARIA radio group keys: arrows step (wrapping), Home and End jump to the ends.\nconst RATING_KEY_STEPS: Record<string, number> = {\n ArrowDown: 1,\n ArrowLeft: -1,\n ArrowRight: 1,\n ArrowUp: -1,\n}\n\ntype Phase = 'survey' | 'sent' | 'error'\n\nconst isResultPhase = (value: unknown): value is Exclude<Phase, 'survey'> =>\n value === 'sent' || value === 'error'\n\nconst StepBar = ({ step }: { step: number }) => (\n <Stack aria-hidden={true} direction=\"row\" sx={{ gap: 4, height: 4 }}>\n {Array.from({ length: STEPS }, (_, index) => (\n <Box\n key={index}\n sx={(theme) => ({\n // Figma `_components/stepper/inactive`: grey 300 light, 500 dark.\n bgcolor:\n index <= step\n ? 'primary.main'\n : theme.palette.grey[theme.palette.mode === 'dark' ? 500 : 300],\n borderRadius: '24px',\n flex: 1,\n })}\n />\n ))}\n </Stack>\n)\n\n// Figma \"Toggle | NumberRating\": five joined 44px cells, the picked one tinted primary. A radio group:\n// one tab stop (the picked cell, else the first), and the arrow keys move focus and pick.\nconst ratingKeyTarget = (key: string, index: number) => {\n if (key === 'Home') return 0\n if (key === 'End') return RATINGS.length - 1\n if (key in RATING_KEY_STEPS) {\n return (index + RATING_KEY_STEPS[key] + RATINGS.length) % RATINGS.length\n }\n return undefined\n}\n\nconst RatingScale = ({\n ariaLabel,\n label,\n onChange,\n tabStopRef,\n value,\n}: {\n ariaLabel: (rating: number) => string\n label: string\n onChange: (rating: number) => void\n /** Receives the group's tab stop, for focus to land on after Continue. */\n tabStopRef: RefObject<HTMLButtonElement | null>\n value?: number\n}) => {\n const cells = useRef<(HTMLButtonElement | null)[]>([])\n const tabStop = value === undefined ? 0 : RATINGS.indexOf(value)\n\n const onKeyDown = (event: KeyboardEvent, index: number) => {\n const target = ratingKeyTarget(event.key, index)\n if (target === undefined) return\n event.preventDefault()\n cells.current[target]?.focus()\n onChange(RATINGS[target])\n }\n\n return (\n <Stack aria-label={label} direction=\"row\" role=\"radiogroup\">\n {RATINGS.map((rating, index) => {\n const selected = rating === value\n return (\n <ButtonBase\n aria-checked={selected}\n aria-label={ariaLabel(rating)}\n key={rating}\n onClick={() => onChange(rating)}\n onKeyDown={(event) => onKeyDown(event, index)}\n ref={(cell) => {\n cells.current[index] = cell\n if (index === tabStop) tabStopRef.current = cell\n }}\n role=\"radio\"\n sx={(theme) => ({\n bgcolor: selected\n ? alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity)\n : undefined,\n border: 1,\n borderColor: selected ? 'primary.main' : 'divider',\n color: 'primary.main',\n flex: 1,\n fontSize: 13,\n fontWeight: 600,\n height: 44,\n lineHeight: '16px',\n zIndex: selected ? 1 : 0,\n // Joined cells: one shared border between neighbours, the picked cell drawn on top.\n '&:not(:first-of-type)': { ml: '-1px' },\n '&:first-of-type': { borderBottomLeftRadius: 4, borderTopLeftRadius: 4 },\n '&:last-of-type': { borderBottomRightRadius: 4, borderTopRightRadius: 4 },\n // Inset, so the joined neighbours do not cover it; raised above the picked cell.\n '&.Mui-focusVisible': {\n outline: `2px solid ${theme.palette.info.main}`,\n outlineOffset: -2,\n zIndex: 2,\n },\n })}\n tabIndex={index === tabStop ? 0 : -1}\n >\n {rating}\n </ButtonBase>\n )\n })}\n </Stack>\n )\n}\n\n// Figma `<Snackbar>` (`_components/snackbar/*/background`): light mode draws white text on the 600 tone; dark\n// mode the lighter main tone, where white fails AA, so black text (6.6:1 on error, 7.6:1 on success). The icon\n// takes the same colour.\nconst StatusBanner = ({\n action,\n bannerRef,\n message,\n severity,\n}: {\n action?: React.ReactNode\n bannerRef: RefObject<HTMLDivElement | null>\n message: string\n severity: 'success' | 'error'\n}) => (\n <Stack\n direction=\"row\"\n ref={bannerRef}\n role={severity === 'error' ? 'alert' : 'status'}\n sx={(theme) => {\n const isDark = theme.palette.mode === 'dark'\n return {\n bgcolor: isDark ? theme.palette[severity].main : theme.palette[severity][600],\n borderRadius: '4px',\n color: isDark ? theme.palette.common.black : theme.palette.common.white,\n px: 16,\n py: 8,\n }\n }}\n tabIndex={-1}\n >\n <Box sx={{ flexShrink: 0, pt: 8, width: 32 }}>\n <Icon fill={true} name={severity === 'success' ? 'check_circle' : 'error'} size={24} />\n </Box>\n <Stack sx={{ gap: 12, pl: 4, py: 8 }}>\n <Text sx={{ color: 'inherit' }} variant=\"subtitle1\">\n {message}\n </Text>\n {action}\n </Stack>\n </Stack>\n)\n\n/**\n * The User Feedback survey (Figma 1283:81740): two 1-5 ratings and a free-text answer, one per step,\n * then a thank-you. The question is the card's title. On submit it sends PostHog's survey events and\n * dismisses the beat, keeping the card (and its thank-you) in the feed until the next refresh.\n */\nconst FeedbackBlock = observer(({ beatGuid = '', payload }: BlockProps) => {\n const copy = readCopy(payload.instance_slot?.data)\n const { beatContext, setBeatContext } = useInsightsV2Store()\n const { onCtaAction } = useBeatActions()\n const stores = useGlobalStore()\n const fireAnalyticsEvent = useAnalyticsEvent()\n const postHogPublicKey = stores.appDataStore.appConfig?.postHogPublicKey\n const surveyId = userFeedbackSurveyId(postHogPublicKey)\n const surveyEvents = userFeedbackSurveyEvents(postHogPublicKey)\n\n const [step, setStep] = useState(0)\n const [ratings, setRatings] = useState<(number | undefined)[]>([])\n const [text, setText] = useState('')\n const [phase, setPhase] = useState<Phase>(() => {\n const savedPhase = beatContext[beatGuid]?.[SURVEY_PHASE_KEY]\n return isResultPhase(savedPhase) ? savedPhase : 'survey'\n })\n const [isSubmitting, setIsSubmitting] = useState(false)\n // The state disables the button on the next render; the ref drops a second click before it.\n const isSubmittingRef = useRef(false)\n // The latest is_dismissed, read after the host's dismiss call settles.\n const isDismissedRef = useRef(payload.is_dismissed)\n isDismissedRef.current = payload.is_dismissed\n\n const bannerRef = useRef<HTMLDivElement>(null)\n const ratingTabStopRef = useRef<HTMLButtonElement>(null)\n const feedbackInputRef = useRef<HTMLTextAreaElement>(null)\n const hasContinuedRef = useRef(false)\n\n // Once per beat, as pulse's survey shown, and only once the survey can draw.\n const hasCopy = !!copy\n useEffect(() => {\n if (!hasCopy || beatContext[beatGuid]?.[SURVEY_SHOWN_KEY]) return\n setBeatContext(beatGuid, { [SURVEY_SHOWN_KEY]: true })\n fireAnalyticsEvent(surveyEvents.shown)\n }, [beatGuid, hasCopy, surveyId])\n\n // The survey's controls unmount with the result, so focus moves to the banner that replaced them.\n // Only on a change: a card that mounts with its result (a remount) must not steal focus.\n const initialPhase = useRef(phase)\n useEffect(() => {\n if (phase !== 'survey' && phase !== initialPhase.current) bannerRef.current?.focus()\n }, [phase])\n\n // After Continue the pressed button stays, so focus moves on to the next step's first control.\n useEffect(() => {\n if (!hasContinuedRef.current) return\n if (step === STEPS - 1) feedbackInputRef.current?.focus()\n else ratingTabStopRef.current?.focus()\n }, [step])\n\n const questions = copy ? [copy.question1, copy.question2, copy.question3] : []\n const resultTitles = { sent: copy?.thank_you, error: copy?.oops }\n const title = phase === 'survey' ? questions[step] : resultTitles[phase]\n\n useEffect(() => {\n if (beatGuid && typeof title === 'string') {\n setBeatContext(beatGuid, { [BEAT_CARD_TITLE_KEY]: title })\n }\n }, [beatGuid, setBeatContext, title])\n\n // Hand the header back to the envelope's title when the block goes.\n useEffect(\n () => () => {\n if (beatGuid) setBeatContext(beatGuid, { [BEAT_CARD_TITLE_KEY]: undefined })\n },\n [beatGuid, setBeatContext],\n )\n\n if (!copy) return null\n\n const showResult = (result: Exclude<Phase, 'survey'>) => {\n setBeatContext(beatGuid, { [SURVEY_PHASE_KEY]: result })\n setPhase(result)\n }\n\n const dismiss = async () => {\n try {\n if (!onCtaAction) throw new Error('No onCtaAction handler to dismiss the beat')\n setBeatContext(beatGuid, { [BEAT_KEEP_AFTER_DISMISS_KEY]: true })\n await onCtaAction({ beatGuid, name: HOST_ACTIONS.dismissBeat })\n showResult('sent')\n } catch (error) {\n stores.captureException(error, { store: 'FeedbackBlock', handler: 'dismissBeat' })\n // Set before the call (the host flips is_dismissed mid-call); cleared so the menu returns on\n // failure, unless the host dismissed the beat anyway (clearing it would swap Oops for the hidden card).\n if (!isDismissedRef.current)\n setBeatContext(beatGuid, { [BEAT_KEEP_AFTER_DISMISS_KEY]: false })\n showResult('error')\n }\n }\n\n // One run at a time: Submit and Try Again ignore a press while the host's dismiss is pending.\n const runOnce = async (run: () => Promise<void>) => {\n if (isSubmittingRef.current) return\n isSubmittingRef.current = true\n setIsSubmitting(true)\n try {\n await run()\n } finally {\n isSubmittingRef.current = false\n setIsSubmitting(false)\n }\n }\n\n const submit = () =>\n runOnce(() => {\n const [first, second] = ratings\n fireAnalyticsEvent(\n surveyEvents.sent(first, second, text.trim().slice(0, FEEDBACK_MAX_LENGTH)),\n )\n fireAnalyticsEvent(surveyEvents.dismissed)\n return dismiss()\n })\n\n const continueToNextStep = () => {\n hasContinuedRef.current = true\n setStep(step + 1)\n }\n\n if (phase !== 'survey') {\n return (\n <Box sx={{ pb: 16, px: 16, width: '100%' }}>\n {phase === 'sent' ? (\n <StatusBanner bannerRef={bannerRef} message={copy.feedback_sent} severity=\"success\" />\n ) : (\n <StatusBanner\n action={\n <Button\n disabled={isSubmitting}\n onClick={() => void runOnce(dismiss)}\n sx={{ alignSelf: 'flex-start', color: 'inherit', minHeight: 0, p: 0 }}\n variant=\"text\"\n >\n {copy.try_again}\n </Button>\n }\n bannerRef={bannerRef}\n message={copy.feedback_error}\n severity=\"error\"\n />\n )}\n </Box>\n )\n }\n\n const isTextStep = step === STEPS - 1\n const canContinue = isTextStep ? text.trim() !== '' : ratings[step] !== undefined\n\n return (\n <Stack sx={{ width: '100%' }}>\n <Stack sx={{ gap: 24, pb: 16, px: 16 }}>\n <Box component=\"span\" sx={VISUALLY_HIDDEN_SX}>\n {buildDynamicCopy(copy.step_count, String(step + 1), String(STEPS)) as string}\n </Box>\n <StepBar step={step} />\n {isTextStep ? (\n <TextField\n inputRef={feedbackInputRef}\n label={copy.feedback}\n minRows={2}\n multiline={true}\n onChange={(event) => setText(event.target.value)}\n placeholder={copy.feedback_placeholder}\n slotProps={{ htmlInput: { maxLength: FEEDBACK_MAX_LENGTH } }}\n value={text}\n />\n ) : (\n <Stack sx={{ gap: 6, pb: 8 }}>\n <RatingScale\n ariaLabel={(rating) => buildDynamicCopy(copy.rating_aria, String(rating)) as string}\n label={questions[step]}\n onChange={(rating) =>\n setRatings((current) => Object.assign([...current], { [step]: rating }))\n }\n tabStopRef={ratingTabStopRef}\n value={ratings[step]}\n />\n <Stack direction=\"row\" sx={{ justifyContent: 'space-between' }}>\n <Text color=\"text.secondary\" variant=\"caption\">\n {copy.strongly_disagree}\n </Text>\n <Text color=\"text.secondary\" variant=\"caption\">\n {copy.strongly_agree}\n </Text>\n </Stack>\n </Stack>\n )}\n </Stack>\n <Stack sx={{ pb: 16, px: 16 }}>\n <Button\n disabled={!canContinue || isSubmitting}\n onClick={isTextStep ? () => void submit() : continueToNextStep}\n variant=\"outlined\"\n >\n {isTextStep ? copy.submit_feedback : copy.continue}\n </Button>\n </Stack>\n </Stack>\n )\n})\n\nexport default FeedbackBlock\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,IAAM,KAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AACF,GAIM,KAAA,CAAY,MAChB,GAAW,MAAA,CAAO,MAAQ,GAAe,IAAO,CAAA,CAAI,MAAM,MAAS,IAC9D,IACD,QAEA,IAAU;AAAA,EAAC;AAAA,EAAG;AAAA,EAAG;AAAA,EAAG;AAAA,EAAG;AAAC,GACxB,IAAQ,GAER,IAAsB,KAEf,KAAmB,gBAEnB,IAAmB,gBAG1B,IAA2C;AAAA,EAC/C,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,SAAS;AACX,GAIM,KAAA,CAAiB,MACrB,MAAU,UAAU,MAAU,SAE1B,KAAA,CAAW,EAAE,MAAA,EAAA,MACjB,gBAAA,EAAC,GAAD;AAAA,EAAO,eAAa;AAAA,EAAM,WAAU;AAAA,EAAM,IAAI;AAAA,IAAE,KAAK;AAAA,IAAG,QAAQ;AAAA,EAAE;AAAA,EAC/D,UAAA,MAAM,KAAK,EAAE,QAAQ,EAAM,GAAA,CAAI,GAAG,MACjC,gBAAA,EAAC,GAAD,EAEE,IAAA,CAAK,OAAW;AAAA,IAEd,SACE,KAAS,IACL,iBACA,EAAM,QAAQ,KAAK,EAAM,QAAQ,SAAS,SAAS,MAAM,GAAA;AAAA,IAC/D,cAAc;AAAA,IACd,MAAM;AAAA,EACR,GACD,GAVM,CAUN,CACF;AACI,CAAA,GAKH,KAAA,CAAmB,GAAa,MAAkB;AACtD,MAAI,MAAQ,OAA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ACE,WAAA,CAAY,MAAW,EAAiB,EAAK,aAAa,OAAO,CAAM,CAAC;AAAA,YACxE,OAAO,EAAU,CAAA;AAAA,YACjB,UAAA,CAAW,MACT,EAAA,CAAY,MAAY,OAAO,OAAO,CAAC,GAAG,CAAO,GAAG,EAAA,CAAG,CAAA,GAAO,EAAO,CAAC,CAAC;AAAA,YAEzE,YAAY;AAAA,YACZ,OAAO,EAAQ,CAAA;AAAA,UAChB,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,YAAO,WAAU;AAAA,YAAM,IAAI,EAAE,gBAAgB,gBAAgB;AAAA,YAA7D,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,cAAM,OAAM;AAAA,cAAiB,SAAQ;AAAA,cAClC,UAAA,EAAK;AAAA,YACF,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,cAAM,OAAM;AAAA,cAAiB,SAAQ;AAAA,cAClC,UAAA,EAAK;AAAA,YACF,CAAA,CACD;AAAA,UACF,CAAA,CAAA;AAAA;MAEJ;AAAA,IACP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,IAAI;AAAA,QAAI,IAAI;AAAA,MAAG;AAAA,MAC1B,UAAA,gBAAA,EAAC,GAAD;AAAA,QACE,UAAU,CAAC,MAAe;AAAA,QAC1B,SAAS,IAAA,MAAA;AAAmB,UAAK,GAAO;AAAA,YAAI;AAAA,QAC5C,SAAQ;AAAA,QAEP,UAAA,IAAa,EAAK,kBAAkB,EAAK;AAAA,MACpC,CAAA;AAAA,IACH,CAAA,CACF;AAAA;AAEX,CAAC"}
@@ -0,0 +1 @@
1
+ export { default as FeedbackBlock } from './FeedbackBlock';
@@ -0,0 +1,29 @@
1
+ /** pulse's USER_FEEDBACK_INSIGHT_SURVEY_ID: the same PostHog survey, per environment. */
2
+ export declare const userFeedbackSurveyId: (postHogPublicKey?: string) => "01986709-032e-0000-5496-ad8f17623225" | "0198428e-bfe6-0000-002d-1fe2e87b3821";
3
+ /** The PostHog survey events pulse's UserFeedback beat sends, with the same keys. */
4
+ export declare const userFeedbackSurveyEvents: (postHogPublicKey?: string) => {
5
+ shown: {
6
+ postHog: {
7
+ eventName: string;
8
+ properties: () => {
9
+ $survey_id: string;
10
+ };
11
+ };
12
+ };
13
+ dismissed: {
14
+ postHog: {
15
+ eventName: string;
16
+ properties: () => {
17
+ $survey_id: string;
18
+ };
19
+ };
20
+ };
21
+ sent: (first?: number, second?: number, feedback?: string) => {
22
+ postHog: {
23
+ eventName: string;
24
+ properties: () => {
25
+ $survey_id: string;
26
+ };
27
+ };
28
+ };
29
+ };
@@ -0,0 +1,25 @@
1
+ import { isProductionPostHogKey as u } from "../../../../core/utils/PostHog.es.js";
2
+ var v = (e) => u(e) ? "01986709-032e-0000-5496-ad8f17623225" : "0198428e-bfe6-0000-002d-1fe2e87b3821", y = (e) => {
3
+ const n = v(e), s = (r, o = {}) => ({ postHog: {
4
+ eventName: r,
5
+ properties: () => ({
6
+ $survey_id: n,
7
+ ...o
8
+ })
9
+ } });
10
+ return {
11
+ shown: s("survey shown"),
12
+ dismissed: s("survey dismissed"),
13
+ sent: (r, o, t) => s("survey sent", {
14
+ $survey_response: r,
15
+ $survey_response_1: o,
16
+ $survey_response_2: t
17
+ })
18
+ };
19
+ };
20
+ export {
21
+ y as userFeedbackSurveyEvents,
22
+ v as userFeedbackSurveyId
23
+ };
24
+
25
+ //# sourceMappingURL=survey.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"survey.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.ts"],"sourcesContent":["import { isProductionPostHogKey } from '../../../../core/utils/PostHog'\nimport type { AnalyticsEventConfigEntry } from '../../../analytics/analyticsEventsConfig'\n\n/** pulse's USER_FEEDBACK_INSIGHT_SURVEY_ID: the same PostHog survey, per environment. */\nexport const userFeedbackSurveyId = (postHogPublicKey?: string) =>\n isProductionPostHogKey(postHogPublicKey)\n ? '01986709-032e-0000-5496-ad8f17623225'\n : '0198428e-bfe6-0000-002d-1fe2e87b3821'\n\n/** The PostHog survey events pulse's UserFeedback beat sends, with the same keys. */\nexport const userFeedbackSurveyEvents = (postHogPublicKey?: string) => {\n const $survey_id = userFeedbackSurveyId(postHogPublicKey)\n const event = (eventName: string, extra: Record<string, unknown> = {}) =>\n ({\n postHog: { eventName, properties: () => ({ $survey_id, ...extra }) },\n }) satisfies AnalyticsEventConfigEntry\n\n return {\n shown: event('survey shown'),\n dismissed: event('survey dismissed'),\n sent: (first?: number, second?: number, feedback?: string) =>\n event('survey sent', {\n $survey_response: first,\n $survey_response_1: second,\n $survey_response_2: feedback,\n }),\n }\n}\n"],"mappings":";AAIA,IAAa,IAAA,CAAwB,MACnC,EAAuB,CAAgB,IACnC,yCACA,wCAGO,IAAA,CAA4B,MAA8B;AACrE,QAAM,IAAa,EAAqB,CAAgB,GAClD,IAAA,CAAS,GAAmB,IAAiC,CAAC,OACjE,EACC,SAAS;AAAA,IAAE,WAAA;AAAA,IAAW,YAAA,OAAmB;AAAA,MAAE,YAAA;AAAA,MAAY,GAAG;AAAA,IAAM;AAAA,EAAG,EACrE;AAEF,SAAO;AAAA,IACL,OAAO,EAAM,cAAc;AAAA,IAC3B,WAAW,EAAM,kBAAkB;AAAA,IACnC,MAAA,CAAO,GAAgB,GAAiB,MACtC,EAAM,eAAe;AAAA,MACnB,kBAAkB;AAAA,MAClB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,IACtB,CAAC;AAAA,EACL;AACF"}