@knocklabs/react 0.11.12 → 0.11.13

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 (50) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/modules/guide/components/Toolbar/V2/FocusChin.js +1 -1
  4. package/dist/cjs/modules/guide/components/Toolbar/V2/FocusChin.js.map +1 -1
  5. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.js +1 -1
  6. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.js.map +1 -1
  7. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideContextDetails.js +1 -1
  8. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideContextDetails.js.map +1 -1
  9. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRow.js +1 -1
  10. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRow.js.map +1 -1
  11. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRowDetails.js +1 -1
  12. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRowDetails.js.map +1 -1
  13. package/dist/cjs/modules/guide/components/Toolbar/V2/V2.js +1 -1
  14. package/dist/cjs/modules/guide/components/Toolbar/V2/V2.js.map +1 -1
  15. package/dist/cjs/modules/guide/components/Toolbar/V2/helpers.js +1 -1
  16. package/dist/cjs/modules/guide/components/Toolbar/V2/helpers.js.map +1 -1
  17. package/dist/cjs/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.js.map +1 -1
  18. package/dist/cjs/modules/guide/providers/KnockGuideProvider.js +1 -1
  19. package/dist/cjs/modules/guide/providers/KnockGuideProvider.js.map +1 -1
  20. package/dist/esm/index.mjs +1 -1
  21. package/dist/esm/modules/guide/components/Toolbar/V2/FocusChin.mjs +32 -31
  22. package/dist/esm/modules/guide/components/Toolbar/V2/FocusChin.mjs.map +1 -1
  23. package/dist/esm/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.mjs +6 -5
  24. package/dist/esm/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.mjs.map +1 -1
  25. package/dist/esm/modules/guide/components/Toolbar/V2/GuideContextDetails.mjs +14 -13
  26. package/dist/esm/modules/guide/components/Toolbar/V2/GuideContextDetails.mjs.map +1 -1
  27. package/dist/esm/modules/guide/components/Toolbar/V2/GuideRow.mjs +37 -37
  28. package/dist/esm/modules/guide/components/Toolbar/V2/GuideRow.mjs.map +1 -1
  29. package/dist/esm/modules/guide/components/Toolbar/V2/GuideRowDetails.mjs +39 -29
  30. package/dist/esm/modules/guide/components/Toolbar/V2/GuideRowDetails.mjs.map +1 -1
  31. package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs +83 -77
  32. package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs.map +1 -1
  33. package/dist/esm/modules/guide/components/Toolbar/V2/helpers.mjs +5 -48
  34. package/dist/esm/modules/guide/components/Toolbar/V2/helpers.mjs.map +1 -1
  35. package/dist/esm/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.mjs.map +1 -1
  36. package/dist/esm/modules/guide/providers/KnockGuideProvider.mjs +12 -10
  37. package/dist/esm/modules/guide/providers/KnockGuideProvider.mjs.map +1 -1
  38. package/dist/types/modules/guide/components/Toolbar/V2/FocusChin.d.ts.map +1 -1
  39. package/dist/types/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.d.ts.map +1 -1
  40. package/dist/types/modules/guide/components/Toolbar/V2/GuideContextDetails.d.ts.map +1 -1
  41. package/dist/types/modules/guide/components/Toolbar/V2/GuideRow.d.ts.map +1 -1
  42. package/dist/types/modules/guide/components/Toolbar/V2/GuideRowDetails.d.ts.map +1 -1
  43. package/dist/types/modules/guide/components/Toolbar/V2/V2.d.ts +5 -1
  44. package/dist/types/modules/guide/components/Toolbar/V2/V2.d.ts.map +1 -1
  45. package/dist/types/modules/guide/components/Toolbar/V2/helpers.d.ts +3 -7
  46. package/dist/types/modules/guide/components/Toolbar/V2/helpers.d.ts.map +1 -1
  47. package/dist/types/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.d.ts +1 -2
  48. package/dist/types/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.d.ts.map +1 -1
  49. package/dist/types/modules/guide/providers/KnockGuideProvider.d.ts.map +1 -1
  50. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"V2.js","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/V2.tsx"],"sourcesContent":["import { useGuideContext } from \"@knocklabs/react-core\";\nimport { Button } from \"@telegraph/button\";\nimport { Icon } from \"@telegraph/icon\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { SegmentedControl } from \"@telegraph/segmented-control\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport {\n ChevronDown,\n ChevronRight,\n GripVertical,\n LogOut,\n Minimize2,\n SlidersHorizontal,\n} from \"lucide-react\";\nimport React from \"react\";\n\nimport { KnockButton } from \"../KnockButton\";\nimport { TOOLBAR_Z_INDEX } from \"../shared\";\nimport \"../styles.css\";\n\nimport { FocusChin } from \"./FocusChin\";\nimport { GuideContextDetails } from \"./GuideContextDetails\";\nimport { GuideRow } from \"./GuideRow\";\nimport { DisplayOption, clearRunConfigLS, getRunConfig } from \"./helpers\";\nimport { useDraggable } from \"./useDraggable\";\nimport {\n InspectionResultOk,\n useInspectGuideClientStore,\n} from \"./useInspectGuideClientStore\";\n\nconst TOGGLE_COLLAPSED_HOTKEY = \".\";\n\nconst TOOLBAR_WIDTH = \"540px\";\n\nconst Kbd = ({ children }: { children: React.ReactNode }) => {\n return (\n <kbd\n style={{\n display: \"inline-block\",\n padding: \"1px 4px\",\n borderRadius: \"var(--tgph-rounded-2)\",\n border: \"1px solid rgba(255, 255, 255, 0.3)\",\n backgroundColor: \"rgba(255, 255, 255, 0.15)\",\n }}\n >\n {children}\n </kbd>\n );\n};\n\nconst filterGuides = (\n guides: InspectionResultOk[\"guides\"],\n displayOption: DisplayOption,\n) => {\n return guides.filter((guide) => {\n const { isEligible, isQualified } = guide.annotation;\n const isDisplayable = isEligible && isQualified;\n\n if (displayOption === \"only-displayable\" && !isDisplayable) {\n return false;\n }\n if (displayOption === \"only-eligible\" && !isEligible) {\n return false;\n }\n if (displayOption === \"only-active\" && !guide.annotation.active.status) {\n return false;\n }\n return true;\n });\n};\n\nexport const V2 = () => {\n const { client } = useGuideContext();\n\n const [displayOption, setDisplayOption] =\n React.useState<DisplayOption>(\"only-active\");\n const [runConfig, setRunConfig] = React.useState(() => getRunConfig());\n const [isCollapsed, setIsCollapsed] = React.useState(false);\n const [isContextPanelOpen, setIsContextPanelOpen] = React.useState(false);\n\n const [expandedGuideRowKey, setExpandedGuideRowKey] = React.useState<\n string | undefined\n >();\n\n React.useEffect(() => {\n setExpandedGuideRowKey(undefined);\n }, [displayOption]);\n\n React.useEffect(() => {\n const { isVisible = false, focusedGuideKeys = {} } = runConfig || {};\n const isDebugging = client.store.state.debug?.debugging;\n if (isVisible && !isDebugging) {\n client.setDebug({ focusedGuideKeys });\n\n // If focused, switch to all guides so you can see in the list.\n if (Object.keys(focusedGuideKeys).length > 0) {\n setDisplayOption(\"all-guides\");\n }\n }\n\n return () => {\n client.unsetDebug();\n };\n }, [runConfig, client, setDisplayOption]);\n\n // Toggle collapsed state with Ctrl + .\n React.useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.ctrlKey && e.key === TOGGLE_COLLAPSED_HOTKEY && !e.repeat) {\n e.preventDefault();\n setIsCollapsed((prev) => !prev);\n }\n };\n\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, []);\n\n const containerRef = React.useRef<HTMLDivElement>(null);\n const guideListRef = React.useRef<HTMLDivElement>(null);\n const { position, isDragging, handlePointerDown, hasDraggedRef } =\n useDraggable({\n elementRef: containerRef,\n reclampDeps: [isCollapsed],\n initialPosition: { top: 16, right: 16 },\n });\n\n const result = useInspectGuideClientStore(runConfig);\n if (!result || !runConfig?.isVisible) {\n return null;\n }\n\n const guides =\n result.status === \"ok\" ? filterGuides(result.guides, displayOption) : [];\n\n return (\n <Box\n tgphRef={containerRef}\n position=\"fixed\"\n style={{\n top: position.top + \"px\",\n right: position.right + \"px\",\n zIndex: TOOLBAR_Z_INDEX,\n }}\n >\n {isCollapsed ? (\n <Tooltip\n side=\"left\"\n delayDuration={500}\n label={\n <Text as=\"span\" size=\"1\">\n Guide Toolbar\n <Stack display=\"inline-block\" ml=\"3\">\n <Kbd>ctrl</Kbd> + <Kbd>.</Kbd>\n </Stack>\n </Text>\n }\n >\n <Stack\n border=\"px\"\n rounded=\"4\"\n align=\"center\"\n justify=\"center\"\n w=\"10\"\n h=\"10\"\n onPointerDown={handlePointerDown}\n backgroundColor=\"surface-1\"\n style={{\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n animation: \"toolbar-collapse-fade-in 150ms ease-out\",\n }}\n >\n <Box\n style={{\n transform: \"scale(0.7)\",\n transformOrigin: \"center center\",\n }}\n >\n <KnockButton\n onClick={() => {\n if (!hasDraggedRef.current) {\n setIsCollapsed(false);\n }\n }}\n positioned={false}\n />\n </Box>\n </Stack>\n </Tooltip>\n ) : (\n <Stack\n direction=\"column\"\n backgroundColor=\"surface-1\"\n rounded=\"4\"\n border=\"px\"\n overflow=\"hidden\"\n style={{\n width: TOOLBAR_WIDTH,\n boxShadow: \"0 8px 32px var(--tgph-gray-5)\",\n animation: \"toolbar-expand-fade-in 150ms ease-out\",\n }}\n >\n {/* Header — also acts as drag handle area */}\n <Stack\n w=\"full\"\n p=\"2\"\n justify=\"space-between\"\n direction=\"row\"\n align=\"center\"\n gap=\"2\"\n borderBottom=\"px\"\n onPointerDown={handlePointerDown}\n style={{\n boxSizing: \"border-box\",\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n }}\n >\n {/* Left: drag icon + segmented control + settings */}\n <Stack align=\"center\" gap=\"1_5\" style={{ minWidth: 0, flex: 1 }}>\n <Stack\n display=\"inline-flex\"\n align=\"center\"\n style={{\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n }}\n onPointerDown={(e: React.PointerEvent) => {\n // Already handled by parent, prevent double-fire\n e.stopPropagation();\n handlePointerDown(e);\n }}\n >\n <Icon color=\"gray\" size=\"1\" icon={GripVertical} aria-hidden />\n </Stack>\n <Stack\n align=\"center\"\n gap=\"1_5\"\n onPointerDown={(e: React.PointerEvent) => e.stopPropagation()}\n >\n <SegmentedControl.Root\n size=\"1\"\n type=\"single\"\n value={displayOption}\n onValueChange={(val: DisplayOption) => {\n if (!val) return;\n\n const debugSettings = client.store.state.debug;\n\n const focusedGuideKeys = Object.keys(\n debugSettings?.focusedGuideKeys || {},\n );\n\n // Exit out of focus if the currently focused guide is not\n // part of the selected list filter.\n if (result.status === \"ok\" && focusedGuideKeys.length > 0) {\n const currFocusedGuide = filterGuides(\n result.guides,\n val,\n ).find((g) => g.key === focusedGuideKeys[0]);\n\n if (!currFocusedGuide) {\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: {},\n });\n }\n }\n\n setDisplayOption(val);\n }}\n >\n <SegmentedControl.Option\n value=\"all-guides\"\n style={{ width: \"54px\" }}\n >\n All\n </SegmentedControl.Option>\n <SegmentedControl.Option\n value=\"only-active\"\n style={{ width: \"54px\" }}\n >\n Active\n </SegmentedControl.Option>\n <SegmentedControl.Option\n value=\"only-eligible\"\n style={{ width: \"54px\" }}\n >\n Eligible\n </SegmentedControl.Option>\n {/* Note: `only-displayable` is not available for now */}\n </SegmentedControl.Root>\n\n <Tooltip label=\"Settings & target params\">\n <Button\n size=\"1\"\n variant={isContextPanelOpen ? \"outline\" : \"ghost\"}\n color={isContextPanelOpen ? \"blue\" : \"gray\"}\n leadingIcon={{\n icon: SlidersHorizontal,\n alt: \"Inspect target params\",\n }}\n trailingIcon={\n isContextPanelOpen\n ? { icon: ChevronDown, alt: \"Hide context data\" }\n : { icon: ChevronRight, alt: \"Show context data\" }\n }\n onClick={() => setIsContextPanelOpen((v) => !v)}\n />\n </Tooltip>\n </Stack>\n </Stack>\n\n {/* Right: exit + minimize buttons */}\n <Stack\n align=\"center\"\n gap=\"1_5\"\n style={{ flexShrink: 0 }}\n onPointerDown={(e: React.PointerEvent) => e.stopPropagation()}\n >\n <Stack align=\"center\" gap=\"1_5\">\n <Button\n size=\"1\"\n variant=\"outline\"\n leadingIcon={{ icon: LogOut, alt: \"Exit\" }}\n onClick={() => {\n setRunConfig((curr) => ({ ...curr, isVisible: false }));\n clearRunConfigLS();\n client.unsetDebug();\n }}\n >\n Exit\n </Button>\n <Tooltip label=\"Minimize toolbar\">\n <Button\n size=\"1\"\n variant=\"outline\"\n leadingIcon={{ icon: Minimize2, alt: \"Minimize\" }}\n onClick={() => setIsCollapsed(true)}\n />\n </Tooltip>\n </Stack>\n </Stack>\n </Stack>\n\n {/* Collapsible panel to show context data */}\n {isContextPanelOpen && (\n <Box borderBottom=\"px\">\n <GuideContextDetails />\n </Box>\n )}\n\n {/* Guide list content area */}\n <Box\n tgphRef={guideListRef}\n p=\"1\"\n overflow=\"auto\"\n style={{ maxHeight: \"calc(80vh - 96px)\" }}\n >\n {result.status === \"error\" ? (\n <Box px=\"2\" pb=\"1\" style={{ lineHeight: \"1.2\" }}>\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color={\n result.error === \"no_guides_fetched\" ? \"default\" : \"red\"\n }\n >\n {result.message}\n </Text>\n </Box>\n ) : guides.length === 0 ? (\n <Box px=\"2\" pb=\"1\" style={{ lineHeight: \"1.2\" }}>\n <Text as=\"span\" size=\"1\" weight=\"medium\" color=\"default\">\n No guides match the current filter.\n </Text>\n </Box>\n ) : (\n guides.map((guide) => (\n <GuideRow\n key={guide.key}\n guide={guide}\n orderIndex={guide.orderIndex}\n isExpanded={guide.key === expandedGuideRowKey}\n onClick={() => {\n setExpandedGuideRowKey((k) =>\n k && k === guide.key ? undefined : guide.key,\n );\n }}\n />\n ))\n )}\n </Box>\n\n {/* Focus chin with dedicated controls */}\n <FocusChin guides={guides} guideListRef={guideListRef} />\n </Stack>\n )}\n </Box>\n );\n};\n"],"names":["TOGGLE_COLLAPSED_HOTKEY","TOOLBAR_WIDTH","Kbd","children","React","display","padding","borderRadius","border","backgroundColor","filterGuides","guides","displayOption","filter","guide","isEligible","isQualified","annotation","active","status","V2","client","useGuideContext","setDisplayOption","useState","runConfig","setRunConfig","getRunConfig","isCollapsed","setIsCollapsed","isContextPanelOpen","setIsContextPanelOpen","expandedGuideRowKey","setExpandedGuideRowKey","useEffect","undefined","isVisible","focusedGuideKeys","isDebugging","store","state","debug","debugging","setDebug","Object","keys","length","unsetDebug","handleKeyDown","e","ctrlKey","key","repeat","preventDefault","prev","addEventListener","removeEventListener","containerRef","useRef","guideListRef","position","isDragging","handlePointerDown","hasDraggedRef","useDraggable","elementRef","reclampDeps","initialPosition","top","right","result","useInspectGuideClientStore","Box","zIndex","TOOLBAR_Z_INDEX","Tooltip","Text","Stack","cursor","touchAction","userSelect","animation","transform","transformOrigin","KnockButton","current","width","boxShadow","boxSizing","minWidth","flex","stopPropagation","Icon","GripVertical","SegmentedControl","val","debugSettings","find","g","Button","icon","SlidersHorizontal","alt","ChevronDown","ChevronRight","v","flexShrink","LogOut","curr","clearRunConfigLS","Minimize2","GuideContextDetails","maxHeight","lineHeight","error","message","map","GuideRow","orderIndex","k","FocusChin"],"mappings":"2sBA+BMA,EAA0B,IAE1BC,EAAgB,QAEhBC,EAAMA,CAAC,CAAEC,SAAAA,CAAwC,IAEnDC,UAAA,cAAC,OACC,MAAO,CACLC,QAAS,eACTC,QAAS,UACTC,aAAc,wBACdC,OAAQ,qCACRC,gBAAiB,8BAGlBN,CACH,EAIEO,EAAeA,CACnBC,EACAC,IAEOD,EAAOE,OAAkBC,GAAA,CACxB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EAAAA,KAAK,CAAA,GAAG,OAAO,KAAK,IAAI,OAAO,SAAS,MAAM,SAAS,EAAA,qCAExD,CACF,EAEAjE,EAAOyG,IAAKtG,GACTV,EAAAA,QAAA,cAAAiH,EAAA,SAAA,CACC,IAAKvG,EAAMqC,IACX,MAAArC,EACA,WAAYA,EAAMwG,WAClB,WAAYxG,EAAMqC,MAAQnB,EAC1B,QAAS,IAAM,CACbC,KACEsF,GAAKA,IAAMzG,EAAMqC,IAAMhB,OAAYrB,EAAMqC,GAC3C,CAAA,GAGL,CAEL,0BAGCqE,EAAU,UAAA,CAAA,OAAA7G,EAAgB,aAAAgD,CAA2B,CAAA,CACxD,CAEJ,CAEJ"}
1
+ {"version":3,"file":"V2.js","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/V2.tsx"],"sourcesContent":["import { KnockGuideClient } from \"@knocklabs/client\";\nimport { useGuideContext } from \"@knocklabs/react-core\";\nimport { Button } from \"@telegraph/button\";\nimport { Icon } from \"@telegraph/icon\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { SegmentedControl } from \"@telegraph/segmented-control\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport {\n ChevronDown,\n ChevronRight,\n GripVertical,\n LogOut,\n Minimize2,\n SlidersHorizontal,\n} from \"lucide-react\";\nimport React from \"react\";\n\nimport { KnockButton } from \"../KnockButton\";\nimport { TOOLBAR_Z_INDEX } from \"../shared\";\nimport \"../styles.css\";\n\nimport { FocusChin } from \"./FocusChin\";\nimport { GuideContextDetails } from \"./GuideContextDetails\";\nimport { GuideRow } from \"./GuideRow\";\nimport { DisplayOption, sharedTooltipProps } from \"./helpers\";\nimport { useDraggable } from \"./useDraggable\";\nimport {\n InspectionResultOk,\n useInspectGuideClientStore,\n} from \"./useInspectGuideClientStore\";\n\nconst TOGGLE_COLLAPSED_HOTKEY = \".\";\n\nconst TOOLBAR_WIDTH = \"540px\";\n\nconst TOOLBAR_BOX_SHADOW = [\n \"0 0 0 1px rgba(0, 0, 0, 0.06)\",\n \"0 0 0 1px rgba(255, 255, 255, 0.10)\",\n \"inset 0 1px 0 rgba(255, 255, 255, 0.04)\",\n \"0 1px 1px 0 rgba(0, 0, 0, 0.04)\",\n \"0 4px 6px -1px rgba(0, 0, 0, 0.05)\",\n \"0 8px 16px -4px rgba(0, 0, 0, 0.06)\",\n].join(\", \");\n\nconst Kbd = ({ children }: { children: React.ReactNode }) => {\n return (\n <kbd\n style={{\n display: \"inline-block\",\n padding: \"1px 4px\",\n borderRadius: \"var(--tgph-rounded-2)\",\n border: \"1px solid rgba(255, 255, 255, 0.3)\",\n backgroundColor: \"rgba(255, 255, 255, 0.15)\",\n }}\n >\n {children}\n </kbd>\n );\n};\n\nconst getEmptyStateMessage = (displayOption: DisplayOption) => {\n switch (displayOption) {\n case \"all-guides\":\n return \"You have no guides. Get started by creating a guide.\";\n case \"only-active\":\n return \"There are no active guides.\";\n case \"only-eligible\":\n return \"Your current user is not eligible for any guides.\";\n }\n};\n\nconst filterGuides = (\n guides: InspectionResultOk[\"guides\"],\n displayOption: DisplayOption,\n) => {\n return guides.filter((guide) => {\n if (displayOption === \"only-eligible\" && !guide.annotation.isEligible) {\n return false;\n }\n if (displayOption === \"only-active\" && !guide.annotation.active.status) {\n return false;\n }\n return true;\n });\n};\n\ntype Props = {\n readyToTarget: boolean;\n};\n\nexport const V2 = ({ readyToTarget }: Props) => {\n const { client } = useGuideContext();\n\n const [displayOption, setDisplayOption] =\n React.useState<DisplayOption>(\"only-active\");\n const [runConfig, setRunConfig] = React.useState(() =>\n KnockGuideClient.getToolbarRunConfigFromUrl(),\n );\n const [isCollapsed, setIsCollapsed] = React.useState(false);\n const [isContextPanelOpen, setIsContextPanelOpen] = React.useState(false);\n\n const [expandedGuideRowKey, setExpandedGuideRowKey] = React.useState<\n string | undefined\n >();\n\n React.useEffect(() => {\n setExpandedGuideRowKey(undefined);\n }, [displayOption]);\n\n React.useEffect(() => {\n const { isVisible = false, focusedGuideKeys = {} } = runConfig || {};\n const isDebugging = client.store.state.debug?.debugging;\n if (isVisible && !isDebugging && readyToTarget) {\n client.setDebug({ focusedGuideKeys });\n\n // If focused, switch to all guides so you can see in the list.\n if (Object.keys(focusedGuideKeys).length > 0) {\n setDisplayOption(\"all-guides\");\n }\n }\n\n return () => {\n client.unsetDebug();\n };\n }, [readyToTarget, runConfig, client, setDisplayOption]);\n\n // Toggle collapsed state with Ctrl + .\n React.useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.ctrlKey && e.key === TOGGLE_COLLAPSED_HOTKEY && !e.repeat) {\n e.preventDefault();\n setIsCollapsed((prev) => !prev);\n }\n };\n\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, []);\n\n const containerRef = React.useRef<HTMLDivElement>(null);\n const guideListRef = React.useRef<HTMLDivElement>(null);\n const { position, isDragging, handlePointerDown, hasDraggedRef } =\n useDraggable({\n elementRef: containerRef,\n reclampDeps: [isCollapsed],\n initialPosition: { top: 16, right: 16 },\n });\n\n const result = useInspectGuideClientStore(runConfig);\n if (!result || !runConfig?.isVisible) {\n return null;\n }\n\n const guides =\n result.status === \"ok\" ? filterGuides(result.guides, displayOption) : [];\n\n return (\n <Box\n tgphRef={containerRef}\n position=\"fixed\"\n style={{\n top: position.top + \"px\",\n right: position.right + \"px\",\n zIndex: TOOLBAR_Z_INDEX,\n }}\n >\n {isCollapsed ? (\n <Tooltip\n side=\"left\"\n label={\n <Text as=\"span\" size=\"1\">\n Guide Toolbar\n <Stack display=\"inline-block\" ml=\"3\">\n <Kbd>ctrl</Kbd> + <Kbd>.</Kbd>\n </Stack>\n </Text>\n }\n {...sharedTooltipProps}\n >\n <Stack\n border=\"px\"\n rounded=\"4\"\n align=\"center\"\n justify=\"center\"\n w=\"10\"\n h=\"10\"\n onPointerDown={handlePointerDown}\n backgroundColor=\"surface-1\"\n style={{\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n animation: \"toolbar-collapse-fade-in 150ms ease-out\",\n }}\n >\n <Box\n style={{\n transform: \"scale(0.7)\",\n transformOrigin: \"center center\",\n }}\n >\n <KnockButton\n onClick={() => {\n if (!hasDraggedRef.current) {\n setIsCollapsed(false);\n }\n }}\n positioned={false}\n />\n </Box>\n </Stack>\n </Tooltip>\n ) : (\n <Stack\n direction=\"column\"\n backgroundColor=\"surface-1\"\n rounded=\"4\"\n overflow=\"hidden\"\n style={{\n width: TOOLBAR_WIDTH,\n boxShadow: TOOLBAR_BOX_SHADOW,\n animation: \"toolbar-expand-fade-in 150ms ease-out\",\n }}\n >\n {/* Header — also acts as drag handle area */}\n <Stack\n w=\"full\"\n p=\"2\"\n justify=\"space-between\"\n direction=\"row\"\n align=\"center\"\n gap=\"2\"\n borderBottom=\"px\"\n onPointerDown={handlePointerDown}\n style={{\n boxSizing: \"border-box\",\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n }}\n >\n {/* Left: drag icon + segmented control + settings */}\n <Stack align=\"center\" gap=\"1_5\" style={{ minWidth: 0, flex: 1 }}>\n <Stack\n display=\"inline-flex\"\n align=\"center\"\n style={{\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n }}\n onPointerDown={(e: React.PointerEvent) => {\n // Already handled by parent, prevent double-fire\n e.stopPropagation();\n handlePointerDown(e);\n }}\n >\n <Icon color=\"gray\" size=\"1\" icon={GripVertical} aria-hidden />\n </Stack>\n <Stack\n align=\"center\"\n gap=\"1_5\"\n onPointerDown={(e: React.PointerEvent) => e.stopPropagation()}\n >\n <SegmentedControl.Root\n size=\"1\"\n type=\"single\"\n value={displayOption}\n onValueChange={(val: DisplayOption) => {\n if (!val) return;\n\n const debugSettings = client.store.state.debug;\n\n const focusedGuideKeys = Object.keys(\n debugSettings?.focusedGuideKeys || {},\n );\n\n // Exit out of focus if the currently focused guide is not\n // part of the selected list filter.\n if (result.status === \"ok\" && focusedGuideKeys.length > 0) {\n const currFocusedGuide = filterGuides(\n result.guides,\n val,\n ).find((g) => g.key === focusedGuideKeys[0]);\n\n if (!currFocusedGuide) {\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: {},\n });\n }\n }\n\n setDisplayOption(val);\n }}\n >\n <SegmentedControl.Option\n value=\"all-guides\"\n style={{ width: \"54px\" }}\n >\n All\n </SegmentedControl.Option>\n <SegmentedControl.Option\n value=\"only-active\"\n style={{ width: \"54px\" }}\n >\n Active\n </SegmentedControl.Option>\n <SegmentedControl.Option\n value=\"only-eligible\"\n style={{ width: \"54px\" }}\n >\n Eligible\n </SegmentedControl.Option>\n </SegmentedControl.Root>\n\n <Tooltip label=\"Settings\" {...sharedTooltipProps}>\n <Button\n size=\"1\"\n variant={isContextPanelOpen ? \"outline\" : \"ghost\"}\n color={isContextPanelOpen ? \"blue\" : \"gray\"}\n leadingIcon={{\n icon: SlidersHorizontal,\n alt: \"Inspect target params\",\n }}\n trailingIcon={\n isContextPanelOpen\n ? { icon: ChevronDown, alt: \"Hide context data\" }\n : { icon: ChevronRight, alt: \"Show context data\" }\n }\n onClick={() => setIsContextPanelOpen((v) => !v)}\n />\n </Tooltip>\n </Stack>\n </Stack>\n\n {/* Right: exit + minimize buttons */}\n <Stack\n align=\"center\"\n gap=\"1_5\"\n style={{ flexShrink: 0 }}\n onPointerDown={(e: React.PointerEvent) => e.stopPropagation()}\n >\n <Stack align=\"center\" gap=\"1_5\">\n <Button\n size=\"1\"\n variant=\"outline\"\n leadingIcon={{ icon: LogOut, alt: \"Exit\" }}\n onClick={() => {\n setRunConfig((curr) => ({ ...curr, isVisible: false }));\n client.unsetDebug();\n }}\n >\n Exit\n </Button>\n <Tooltip label=\"Minimize toolbar\" {...sharedTooltipProps}>\n <Button\n size=\"1\"\n variant=\"outline\"\n leadingIcon={{ icon: Minimize2, alt: \"Minimize\" }}\n onClick={() => setIsCollapsed(true)}\n />\n </Tooltip>\n </Stack>\n </Stack>\n </Stack>\n\n {/* Collapsible panel to show context data */}\n {isContextPanelOpen && (\n <Box borderBottom=\"px\">\n <GuideContextDetails />\n </Box>\n )}\n\n {/* Guide list content area */}\n <Box\n tgphRef={guideListRef}\n p=\"1\"\n overflow=\"auto\"\n style={{ maxHeight: \"calc(80vh - 96px)\" }}\n >\n {result.status === \"error\" ? (\n <Box px=\"2\" pb=\"1\" style={{ lineHeight: \"1.2\" }}>\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color={\n result.error === \"no_guides_fetched\" ? \"default\" : \"red\"\n }\n >\n {result.message}\n </Text>\n </Box>\n ) : guides.length === 0 ? (\n <Box px=\"2\" pb=\"1\" style={{ lineHeight: \"1.2\" }}>\n <Text as=\"span\" size=\"1\" weight=\"medium\" color=\"default\">\n {getEmptyStateMessage(displayOption)}\n </Text>\n </Box>\n ) : (\n guides.map((guide) => (\n <GuideRow\n key={guide.key}\n guide={guide}\n orderIndex={guide.orderIndex}\n isExpanded={guide.key === expandedGuideRowKey}\n onClick={() => {\n setExpandedGuideRowKey((k) =>\n k && k === guide.key ? undefined : guide.key,\n );\n }}\n />\n ))\n )}\n </Box>\n\n {/* Focus chin with dedicated controls */}\n <FocusChin guides={guides} guideListRef={guideListRef} />\n </Stack>\n )}\n </Box>\n );\n};\n"],"names":["TOGGLE_COLLAPSED_HOTKEY","TOOLBAR_WIDTH","TOOLBAR_BOX_SHADOW","join","Kbd","children","React","display","padding","borderRadius","border","backgroundColor","getEmptyStateMessage","displayOption","filterGuides","guides","filter","guide","annotation","isEligible","active","status","V2","readyToTarget","client","useGuideContext","setDisplayOption","useState","runConfig","setRunConfig","KnockGuideClient","getToolbarRunConfigFromUrl","isCollapsed","setIsCollapsed","isContextPanelOpen","setIsContextPanelOpen","expandedGuideRowKey","setExpandedGuideRowKey","useEffect","undefined","isVisible","focusedGuideKeys","isDebugging","store","state","debug","debugging","setDebug","Object","keys","length","unsetDebug","handleKeyDown","e","ctrlKey","key","repeat","preventDefault","prev","addEventListener","removeEventListener","containerRef","useRef","guideListRef","position","isDragging","handlePointerDown","hasDraggedRef","useDraggable","elementRef","reclampDeps","initialPosition","top","right","result","useInspectGuideClientStore","Box","zIndex","TOOLBAR_Z_INDEX","Tooltip","Text","Stack","sharedTooltipProps","cursor","touchAction","userSelect","animation","transform","transformOrigin","KnockButton","current","width","boxShadow","boxSizing","minWidth","flex","stopPropagation","Icon","GripVertical","SegmentedControl","val","debugSettings","find","g","Button","icon","SlidersHorizontal","alt","ChevronDown","ChevronRight","v","flexShrink","LogOut","curr","Minimize2","GuideContextDetails","maxHeight","lineHeight","error","message","map","GuideRow","orderIndex","k","FocusChin"],"mappings":"0uBAgCMA,EAA0B,IAE1BC,EAAgB,QAEhBC,EAAqB,CACzB,gCACA,sCACA,0CACA,kCACA,qCACA,qCAAqC,EACrCC,KAAK,IAAI,EAELC,EAAMA,CAAC,CAAEC,SAAAA,CAAwC,IAEnDC,UAAA,cAAC,OACC,MAAO,CACLC,QAAS,eACTC,QAAS,UACTC,aAAc,wBACdC,OAAQ,qCACRC,gBAAiB,8BAGlBN,CACH,EAIEO,EAAwBC,GAAiC,CAC7D,OAAQA,EAAa,CACnB,IAAK,aACI,MAAA,uDACT,IAAK,cACI,MAAA,8BACT,IAAK,gBACI,MAAA,mDAAA,CAEb,EAEMC,EAAeA,CACnBC,EACAF,IAEOE,EAAOC,OAAkBC,GAC1BJ,EAAAA,IAAkB,iBAAmB,CAACI,EAAMC,WAAWC,YAGvDN,IAAkB,eAAiB,CAACI,EAAMC,WAAWE,OAAOC,OAIjE,EAOUC,EAAKA,CAAC,CAAEC,cAAAA,CAAqB,IAAM,CACxC,KAAA,CAAEC,OAAAA,GAAWC,kBAAgB,EAE7B,CAACZ,EAAea,CAAgB,EACpCpB,EAAAA,QAAMqB,SAAwB,aAAa,EACvC,CAACC,EAAWC,CAAY,EAAIvB,EAAAA,QAAMqB,SAAS,IAC/CG,EAAAA,i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AA7G,EAAgB,aAAAgD,CAA2B,CAAA,CACxD,CAEJ,CAEJ"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@knocklabs/react-core");require("react");;/* empty css */require("lodash.debounce");const t=require("../../../../core/utils.js"),u="knock_guide_toolbar",a="focused_guide_key",r="knock_guide_debug",l=()=>{const e={isVisible:!1},o=t.checkForWindow();if(!o||!o.location)return e;const c=new URLSearchParams(o.location.search),i=c.get(u),s=c.get(a);if(i!==null){const n={isVisible:i==="true"};return s&&(n.focusedGuideKeys={[s]:!0}),g(n),n}return d()||e},g=e=>{const o=t.checkForWindow();if(!(!o||!o.localStorage))try{o.localStorage.setItem(r,JSON.stringify(e))}catch{}},d=()=>{const e=t.checkForWindow();if(!(!e||!e.localStorage))try{const o=e.localStorage.getItem(r);if(o)return JSON.parse(o)}catch{}},f=()=>{const e=t.checkForWindow();if(!(!e||!e.localStorage))try{e.localStorage.removeItem(r)}catch{}},S={focusUnknownGuide:"No such guide exists",focusUncommittedGuide:"This guide has not been committed",focusUnselectableGuide:"No component that can display this guide is present"};exports.FOCUS_ERRORS=S;exports.clearRunConfigLS=f;exports.getRunConfig=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={delayDuration:1e3},o={focusUnknownGuide:"No such guide exists",focusUncommittedGuide:"This guide has not been committed",focusUnselectableGuide:"No component that can display this guide is present"};exports.FOCUS_ERRORS=o;exports.sharedTooltipProps=e;
2
2
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/helpers.ts"],"sourcesContent":["import { KnockGuide } from \"@knocklabs/client\";\n\nimport { checkForWindow } from \"../../../../../modules/core\";\n\nexport type DisplayOption =\n | \"all-guides\"\n | \"only-active\"\n | \"only-eligible\"\n | \"only-displayable\";\n\n// Use this param to start Toolbar and enter into a debugging session when\n// it is present and set to true.\nconst TOOLBAR_QUERY_PARAM = \"knock_guide_toolbar\";\n\n// Optional, when present pin/focus on this guide.\nconst GUIDE_KEY_PARAM = \"focused_guide_key\";\n\n// Use this key to read and write the run config data.\nconst LOCAL_STORAGE_KEY = \"knock_guide_debug\";\n\nexport type ToolbarV2RunConfig = {\n isVisible: boolean;\n focusedGuideKeys?: Record<KnockGuide[\"key\"], true>;\n};\n\nexport const getRunConfig = (): ToolbarV2RunConfig => {\n const fallback = { isVisible: false };\n\n const win = checkForWindow();\n if (!win || !win.location) {\n return fallback;\n }\n\n const urlSearchParams = new URLSearchParams(win.location.search);\n const toolbarParamValue = urlSearchParams.get(TOOLBAR_QUERY_PARAM);\n const guideKeyParamValue = urlSearchParams.get(GUIDE_KEY_PARAM);\n\n // If toolbar param detected in the URL, write to local storage before\n // returning.\n if (toolbarParamValue !== null) {\n const config: ToolbarV2RunConfig = {\n isVisible: toolbarParamValue === \"true\",\n };\n if (guideKeyParamValue) {\n config.focusedGuideKeys = { [guideKeyParamValue]: true };\n }\n\n writeRunConfigLS(config);\n return config;\n }\n\n // If not detected, check local storage for a persisted run config. If not\n // present then fall back to a default config.\n return readRunConfigLS() || fallback;\n};\n\nconst writeRunConfigLS = (config: ToolbarV2RunConfig) => {\n const win = checkForWindow();\n if (!win || !win.localStorage) return;\n\n try {\n win.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(config));\n } catch {\n // localStorage may be unavailable (e.g. private browsing)\n }\n};\n\nconst readRunConfigLS = (): ToolbarV2RunConfig | undefined => {\n const win = checkForWindow();\n if (!win || !win.localStorage) return undefined;\n\n try {\n const stored = win.localStorage.getItem(LOCAL_STORAGE_KEY);\n if (stored) {\n return JSON.parse(stored);\n }\n } catch {\n // localStorage may be unavailable (e.g. private browsing)\n }\n return undefined;\n};\n\nexport const clearRunConfigLS = () => {\n const win = checkForWindow();\n if (!win || !win.localStorage) return;\n\n try {\n win.localStorage.removeItem(LOCAL_STORAGE_KEY);\n } catch {\n // localStorage may be unavailable (e.g. private browsing)\n }\n};\n\nexport const FOCUS_ERRORS = {\n focusUnknownGuide: \"No such guide exists\",\n focusUncommittedGuide: \"This guide has not been committed\",\n focusUnselectableGuide: \"No component that can display this guide is present\",\n};\n"],"names":["TOOLBAR_QUERY_PARAM","GUIDE_KEY_PARAM","LOCAL_STORAGE_KEY","getRunConfig","fallback","isVisible","win","checkForWindow","location","urlSearchParams","URLSearchParams","search","toolbarParamValue","get","guideKeyParamValue","config","focusedGuideKeys","writeRunConfigLS","readRunConfigLS","localStorage","setItem","JSON","stringify","stored","getItem","parse","clearRunConfigLS","removeItem","FOCUS_ERRORS","focusUnknownGuide","focusUncommittedGuide","focusUnselectableGuide"],"mappings":"sQAYMA,EAAsB,sBAGtBC,EAAkB,oBAGlBC,EAAoB,oBAObC,EAAeA,IAA0B,CACpD,MAAMC,EAAW,CAAEC,UAAW,EAAM,EAE9BC,EAAMC,EAAAA,eAAe,EAC3B,GAAI,CAACD,GAAO,CAACA,EAAIE,SACRJ,OAAAA,EAGT,MAAMK,EAAkB,IAAIC,gBAAgBJ,EAAIE,SAASG,MAAM,EACzDC,EAAoBH,EAAgBI,IAAIb,CAAmB,EAC3Dc,EAAqBL,EAAgBI,IAAIZ,CAAe,EAI9D,GAAIW,IAAsB,KAAM,CAC9B,MAAMG,EAA6B,CACjCV,UAAWO,IAAsB,MACnC,EACA,OAAIE,IACFC,EAAOC,iBAAmB,CAAE,CAACF,CAAkB,EAAG,EAAK,GAGzDG,EAAiBF,CAAM,EAChBA,CAAAA,CAKT,OAAOG,EAAqBd,GAAAA,CAC9B,EAEMa,EAAoBF,GAA+B,CACvD,MAAMT,EAAMC,EAAAA,eAAe,EAC3B,GAAI,GAACD,GAAO,CAACA,EAAIa,cAEb,GAAA,CACFb,EAAIa,aAAaC,QAAQlB,EAAmBmB,KAAKC,UAAUP,CAAM,CAAC,CAAA,MAC5D,CAAA,CAGV,EAEMG,EAAkBA,IAAsC,CAC5D,MAAMZ,EAAMC,EAAAA,eAAe,EAC3B,GAAI,GAACD,GAAO,CAACA,EAAIa,cAEb,GAAA,CACF,MAAMI,EAASjB,EAAIa,aAAaK,QAAQtB,CAAiB,EACzD,GAAIqB,EACKF,OAAAA,KAAKI,MAAMF,CAAM,CAC1B,MACM,CAAA,CAIV,EAEaG,EAAmBA,IAAM,CACpC,MAAMpB,EAAMC,EAAAA,eAAe,EAC3B,GAAI,GAACD,GAAO,CAACA,EAAIa,cAEb,GAAA,CACEA,EAAAA,aAAaQ,WAAWzB,CAAiB,CAAA,MACvC,CAAA,CAGV,EAEa0B,EAAe,CAC1BC,kBAAmB,uBACnBC,sBAAuB,oCACvBC,uBAAwB,qDAC1B"}
1
+ {"version":3,"file":"helpers.js","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/helpers.ts"],"sourcesContent":["export const sharedTooltipProps = {\n delayDuration: 1000,\n};\n\nexport type DisplayOption = \"all-guides\" | \"only-active\" | \"only-eligible\";\n\nexport const FOCUS_ERRORS = {\n focusUnknownGuide: \"No such guide exists\",\n focusUncommittedGuide: \"This guide has not been committed\",\n focusUnselectableGuide: \"No component that can display this guide is present\",\n};\n"],"names":["sharedTooltipProps","delayDuration","FOCUS_ERRORS","focusUnknownGuide","focusUncommittedGuide","focusUnselectableGuide"],"mappings":"gFAAO,MAAMA,EAAqB,CAChCC,cAAe,GACjB,EAIaC,EAAe,CAC1BC,kBAAmB,uBACnBC,sBAAuB,oCACvBC,uBAAwB,qDAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"useInspectGuideClientStore.js","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.ts"],"sourcesContent":["import {\n KnockGuide,\n KnockGuideClientGroupStage,\n KnockGuideClientStoreState,\n KnockGuideIneligibilityMarker,\n KnockGuideSelectionResult,\n checkActivatable,\n checkStateIfThrottled,\n} from \"@knocklabs/client\";\nimport { useGuideContext, useStore } from \"@knocklabs/react-core\";\n\nimport { FOCUS_ERRORS, ToolbarV2RunConfig } from \"./helpers\";\n\nconst byKey = <T extends { key: string }>(items: T[]) => {\n return items.reduce((acc, item) => ({ ...acc, [item.key]: item }), {});\n};\n\n/**\n * This is the main module that will house core logic for the toolbar. It hooks\n * into the guide client state store, extracts relevant data for debugging, and\n * transforms it into easily consumable data for the toolbar - namely\n * \"annotating\" guides for its various statuses to display.\n */\n\n// Active: `true` status = good\ntype ActiveStatus = {\n status: boolean;\n};\n\n// Targetable: `true` status = good\ntype TargetableStatusTrue = {\n status: true;\n};\ntype TargetableStatusFalse = {\n status: false;\n reason: string;\n message: string;\n};\ntype TargetableStatus = TargetableStatusTrue | TargetableStatusFalse;\n\ntype ActivatableStatus = {\n status: boolean;\n};\n\n// Archived: `false` status = good\ntype ArchivedStatus = {\n status: boolean;\n};\n\n// Selectable:\n// - \"returned\": Queried and resolved to return the guide from useGuide(s).\n// - \"throttled\": Queried and resolved but being throttled, so not yet returned.\n// - \"queried\": Queried but not resolved, because there are other higher\n// priority guides that are ahead of this guide in the query result.\n// - undefined: Not reachable with any of the given queries and filters.\ntype SelectionResultByLimit = {\n one?: KnockGuideSelectionResult;\n all?: KnockGuideSelectionResult;\n};\ntype SelectionResultByQuery = {\n key?: SelectionResultByLimit;\n type?: SelectionResultByLimit;\n};\ntype SelectableStatusPresent = {\n status: \"returned\" | \"throttled\" | \"queried\";\n query: SelectionResultByQuery;\n};\ntype SelectableStatusAbsent = {\n status: undefined;\n};\ntype SelectableStatus = SelectableStatusPresent | SelectableStatusAbsent;\n\nexport type AnnotatedStatuses = {\n // Individual eligibility statuses:\n active: ActiveStatus;\n targetable: TargetableStatus;\n archived: ArchivedStatus;\n // Individual qualified statuses:\n activatable: ActivatableStatus;\n selectable: SelectableStatus;\n};\n\ntype GuideAnnotation = AnnotatedStatuses & {\n // Resolved eligibility based on active, targetable and archived statuses,\n // which are backend driven evaluation results that are exposed for debugging.\n isEligible: boolean;\n\n // Resolved display qualification based on an activatable status, which\n // informs \"when\" and \"where\" an eligible guide can be displayed to user.\n isQualified: boolean;\n};\n\nexport type AnnotatedGuide = KnockGuide & {\n orderIndex: number;\n annotation: GuideAnnotation;\n\n // Legacy fields, typed only to make tsc happy when we prune these out.\n activation_location_rules?: KnockGuide[\"activation_url_patterns\"];\n priority?: number;\n};\n\n// Exists and ordered in control but absent in switchboard (therefore not\n// included in the api response), which implies a newly created guide that has\n// never been published to switchboard.\nexport type UncommittedGuide = {\n __typename: \"UncommittedGuide\";\n orderIndex: number;\n key: KnockGuide[\"key\"];\n active: false;\n bypass_global_group_limit: false;\n annotation: {\n isEligible: false;\n isQualified: false;\n active: {\n status: false;\n };\n selectable: {\n status: undefined;\n };\n };\n};\n\nexport type InspectionResultOk = {\n status: \"ok\";\n guides: (AnnotatedGuide | UncommittedGuide)[];\n};\ntype InspectionResultError = {\n status: \"error\";\n error:\n | \"no_guides_fetched\"\n | \"no_guide_group\"\n | \"focus_unknown_guide\"\n | \"focus_uncommitted_guide\"\n | \"focus_unselectable_guide\";\n message: string;\n};\ntype InspectionResult = InspectionResultOk | InspectionResultError;\n\ntype StoreStateSnapshot = Pick<\n KnockGuideClientStoreState,\n | \"location\"\n | \"guides\"\n | \"guideGroups\"\n | \"ineligibleGuides\"\n | \"debug\"\n | \"counter\"\n | \"queries\"\n> & {\n throttled: boolean;\n};\n\nconst inferSelectByKeyReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const includeThrottled =\n !!query.key?.one?.metadata?.opts?.includeThrottled ||\n !!query.key?.all?.metadata?.opts?.includeThrottled;\n\n // If unthrottled, then it should always be returned.\n if (guide.bypass_global_group_limit) {\n return \"returned\";\n }\n\n // If resolved, expect this guide to be returned unless being throttled.\n if (guide.key === stage.resolved) {\n if (snapshot.throttled && !includeThrottled) {\n return \"throttled\";\n }\n return \"returned\";\n }\n\n // If queried but not resolved, it means this guide is being shadowed by\n // another guide with higher priority because throttled guides can be\n // displayed only one at a time.\n return \"queried\";\n};\n\nconst inferSelectOneByTypeReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const includeThrottled = !!query.type?.one?.metadata?.opts?.includeThrottled;\n\n const result = query.type!.one!;\n if (result.size === 0) {\n return \"queried\";\n }\n\n // There may be multiple unthrottled guides of the same type, being queried\n // by type to return a single guide, for example: useGuide({ type: \"card\" }).\n //\n // So it is possible for an unthrottled guide to be shadowed by another\n // unthrottled guide of the same type with higher priority, so we need to\n // look at the query result to determine its return status.\n if (guide.bypass_global_group_limit) {\n const guides = [...result.values()];\n const first = guides[0]!;\n\n if (guide.key !== first.key) {\n // Being shadowed by another guide with higher priority.\n return \"queried\";\n }\n return \"returned\";\n }\n\n // If resolved, expect this guide to be returned unless being throttled.\n if (guide.key === stage.resolved) {\n if (snapshot.throttled && !includeThrottled) {\n return \"throttled\";\n }\n return \"returned\";\n }\n\n // If queried but not resolved, it means this guide is being shadowed by\n // another guide with higher priority because throttled guides can be\n // displayed only one at a time.\n return \"queried\";\n};\n\nconst inferSelectAllByTypeReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const result = query.type!.all!;\n if (result.size === 0) {\n return \"queried\";\n }\n\n const guides = [...result.values()];\n const first = guides[0]!;\n\n // Might want to consider moving this up to do once.\n const guidesByKey: Record<KnockGuide[\"key\"], KnockGuide> = byKey(guides);\n\n // If includeThrottled given, then expect all selected guides to be returned.\n const includeThrottled = !!query.type?.all?.metadata?.opts?.includeThrottled;\n if (includeThrottled) {\n return guidesByKey[guide.key] ? \"returned\" : \"queried\";\n }\n\n // If the first selected guide is unthrottled or resolved, then we should\n // have at minimum one guide to return, and potentially more based on whether\n // we are throttling currently and which other guides are unthrottled.\n if (first.bypass_global_group_limit || first.key === stage.resolved) {\n if (!guidesByKey[guide.key]) {\n return \"queried\";\n }\n if (snapshot.throttled) {\n return guide.bypass_global_group_limit ? \"returned\" : \"throttled\";\n }\n return \"returned\";\n }\n\n return \"queried\";\n};\n\nconst inferSelectReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n) => {\n // Querying by key can only return up to a max of one guide, regardless of\n // useGuide or useGuides, and should take precedence in status designation.\n if (query.key) {\n return inferSelectByKeyReturnStatus(guide, snapshot, stage, query);\n }\n\n if (query.type?.all) {\n return inferSelectAllByTypeReturnStatus(guide, snapshot, stage, query);\n }\n if (query.type?.one) {\n return inferSelectOneByTypeReturnStatus(guide, snapshot, stage, query);\n }\n\n // Should not happen but just for completeness.\n return undefined;\n};\n\nconst toSelectableStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage | undefined,\n): SelectableStatus => {\n if (!stage || stage.status === \"open\") {\n return { status: undefined };\n }\n\n const query = {\n key: (stage.results.key || {})[guide.key],\n type: (stage.results.type || {})[guide.type],\n };\n\n const queried = Boolean(query.key || query.type);\n if (!queried) {\n // No present query in the current location can select this guide.\n return { status: undefined };\n }\n\n const status = inferSelectReturnStatus(guide, snapshot, stage, query);\n if (!status) {\n return { status: undefined };\n }\n\n return { status, query };\n};\n\nconst toIneligibilityStatus = (\n guide: KnockGuide,\n marker?: KnockGuideIneligibilityMarker,\n): Partial<AnnotatedStatuses> => {\n const statuses: Partial<AnnotatedStatuses> = {};\n\n if (\n marker?.reason === \"not_in_target_audience\" ||\n marker?.reason === \"target_conditions_not_met\"\n ) {\n statuses.targetable = {\n status: false,\n reason: marker.reason,\n message: marker.message,\n };\n }\n\n if (\n marker?.reason === \"marked_as_archived\" ||\n (guide.steps || []).every((s) => !!s.message.archived_at)\n ) {\n statuses.archived = {\n status: true,\n };\n }\n\n if (marker?.reason === \"guide_not_active\") {\n statuses.active = {\n status: false,\n };\n }\n\n return statuses;\n};\n\nconst resolveIsEligible = ({\n active,\n targetable,\n archived,\n}: AnnotatedStatuses) => {\n if (!active.status) return false;\n if (!targetable.status) return false;\n if (archived.status) return false;\n return true;\n};\n\nexport const resolveIsQualified = ({\n activatable,\n selectable,\n}: AnnotatedStatuses) => {\n if (!activatable.status) return false;\n if (!selectable.status) return false;\n return true;\n};\n\nconst annotateGuide = (\n guide: KnockGuide,\n orderIndex: number,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage | undefined,\n): AnnotatedGuide => {\n const { ineligibleGuides, location } = snapshot;\n const marker = ineligibleGuides[guide.key];\n const ineligiblity = toIneligibilityStatus(guide, marker);\n\n const statuses: AnnotatedStatuses = {\n // isEligible:\n active: ineligiblity?.active || { status: true },\n targetable: ineligiblity?.targetable || { status: true },\n archived: ineligiblity?.archived || { status: false },\n // isQualified:\n activatable: { status: checkActivatable(guide, location) },\n selectable: toSelectableStatus(guide, snapshot, stage),\n };\n\n const annotation: GuideAnnotation = {\n ...statuses,\n isEligible: resolveIsEligible(statuses),\n isQualified: resolveIsQualified(statuses),\n };\n\n return {\n ...guide,\n orderIndex,\n annotation,\n };\n};\n\nconst newUncommittedGuide = (key: KnockGuide[\"key\"], orderIndex: number) =>\n ({\n __typename: \"UncommittedGuide\",\n key,\n orderIndex,\n active: false,\n bypass_global_group_limit: false,\n annotation: {\n isEligible: false,\n isQualified: false,\n active: {\n status: false,\n },\n selectable: {\n status: undefined,\n },\n },\n }) as UncommittedGuide;\n\nexport const useInspectGuideClientStore = (\n runConfig: ToolbarV2RunConfig,\n): InspectionResult | undefined => {\n const { client } = useGuideContext();\n\n // Extract a snapshot of the client store state for debugging.\n const snapshot: StoreStateSnapshot = useStore(client.store, (state) => {\n const throttled = checkStateIfThrottled(state);\n\n return {\n location: state.location,\n guides: state.guides,\n guideGroups: state.guideGroups,\n ineligibleGuides: state.ineligibleGuides,\n debug: state.debug,\n counter: state.counter,\n queries: state.queries,\n throttled,\n };\n });\n\n // Not in debugging session, so noop.\n if (!snapshot.debug?.debugging) {\n return undefined;\n }\n\n // No recorded fetch requests, which implies an inflight request loading.\n const req = Object.entries(snapshot.queries)[0];\n if (!req || req[1].status === \"loading\") {\n return {\n status: \"error\",\n error: \"no_guides_fetched\",\n message: \"Loading...\",\n };\n }\n\n // Should always be a default group so this should never happen.\n const defaultGroup = snapshot.guideGroups[0];\n if (!defaultGroup) {\n return {\n status: \"error\",\n error: \"no_guide_group\",\n message: \"No guide group found\",\n };\n }\n\n const groupStage = client.getStage();\n\n // Annotate guides for various eligibility, activation and query statuses\n // that are useful for debugging purposes.\n const orderedGuides = defaultGroup.display_sequence.map((guideKey, index) => {\n const guide = snapshot.guides[guideKey];\n if (!guide) {\n return newUncommittedGuide(guideKey, index);\n }\n\n return annotateGuide(guide, index, snapshot, groupStage);\n });\n\n // Check if the focused guide actually exists and is selectable on the page.\n const focusedGuideKey = Object.keys(runConfig.focusedGuideKeys || {})[0];\n if (groupStage?.status === \"closed\" && focusedGuideKey) {\n const foundGuide = orderedGuides.find((g) => g.key === focusedGuideKey);\n\n // No such guide exists for the given focused guide key.\n if (!foundGuide) {\n return {\n status: \"error\",\n error: \"focus_unknown_guide\",\n message: `Unable to display \\`${focusedGuideKey}\\`, ${FOCUS_ERRORS.focusUnknownGuide.toLowerCase()}.`,\n };\n }\n\n // This guide exists but has never been committed and published, so it is\n // not present in the API response.\n if (isUncommittedGuide(foundGuide)) {\n return {\n status: \"error\",\n error: \"focus_uncommitted_guide\",\n message: `Unable to display \\`${focusedGuideKey}\\`, ${FOCUS_ERRORS.focusUncommittedGuide.toLowerCase()}.`,\n };\n }\n\n // This guide exists and is present in the response, but it is not queried\n // in the current page so it is impossible to force render this guide.\n if (!foundGuide.annotation.selectable.status) {\n return {\n status: \"error\",\n error: \"focus_unselectable_guide\",\n message: `Unable to display \\`${focusedGuideKey}\\`, ${FOCUS_ERRORS.focusUnselectableGuide.toLowerCase()}.`,\n };\n }\n }\n\n return {\n status: \"ok\",\n guides: orderedGuides,\n };\n};\n\nexport const isUncommittedGuide = (input: unknown): input is UncommittedGuide =>\n typeof input === \"object\" &&\n input !== null &&\n \"__typename\" in input &&\n (input as UncommittedGuide).__typename === \"UncommittedGuide\";\n"],"names":["byKey","items","reduce","acc","item","key","inferSelectByKeyReturnStatus","guide","snapshot","stage","query","includeThrottled","one","metadata","opts","all","bypass_global_group_limit","resolved","throttled","inferSelectOneByTypeReturnStatus","type","result","size","first","values","inferSelectAllByTypeReturnStatus","guides","guidesByKey","inferSelectReturnStatus","toSelectableStatus","status","undefined","results","Boolean","toIneligibilityStatus","marker","statuses","reason","targetable","message","steps","every","s","archived_at","archived","active","resolveIsEligible","resolveIsQualified","activatable","selectable","annotateGuide","orderIndex","ineligibleGuides","location","ineligiblity","checkActivatable","annotation","isEligible","isQualified","newUncommittedGuide","__typename","useInspectGuideClientStore","runConfig","client","useGuideContext","useStore","store","state","checkStateIfThrottled","guideGroups","debug","counter","queries","debugging","req","Object","entries","error","defaultGroup","groupStage","getStage","orderedGuides","display_sequence","map","guideKey","index","focusedGuideKey","keys","focusedGuideKeys","foundGuide","find","g","FOCUS_ERRORS","focusUnknownGuide","toLowerCase","isUncommittedGuide","focusUncommittedGuide","focusUnselectableGuide","input"],"mappings":"kLAaMA,EAAoCC,GACjCA,EAAMC,OAAO,CAACC,EAAKC,KAAU,CAAE,GAAGD,EAAK,CAACC,EAAKC,GAAG,EAAGD,CAAK,GAAI,CAAA,CAAE,EAyIjEE,EAA+BA,CACnCC,EACAC,EACAC,EACAC,IACsC,qBACtC,MAAMC,EACJ,CAAC,GAACD,GAAAA,GAAAA,GAAAA,EAAAA,EAAML,MAANK,YAAAA,EAAWE,MAAXF,YAAAA,EAAgBG,WAAhBH,YAAAA,EAA0BI,OAA1BJ,MAAAA,EAAgCC,mBAClC,CAAC,GAACD,GAAAA,GAAAA,GAAAA,EAAAA,EAAML,MAANK,YAAAA,EAAWK,MAAXL,YAAAA,EAAgBG,W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EAKEC,GAAAA,EAAmBN,CAAU,EACxB,MAAA,CACL3D,OAAQ,QACR+C,MAAO,0BACPtC,QAAS,uBAAuB+C,CAAe,OAAOM,EAAAA,aAAaI,sBAAsBF,aAAa,GACxG,EAKF,GAAI,CAACL,EAAWjC,WAAWP,WAAWnB,OAC7B,MAAA,CACLA,OAAQ,QACR+C,MAAO,2BACPtC,QAAS,uBAAuB+C,CAAe,OAAOM,EAAAA,aAAaK,uBAAuBH,aAAa,GACzG,CACF,CAGK,MAAA,CACLhE,OAAQ,KACRJ,OAAQuD,CACV,CACF,EAEac,EAAsBG,GACjC,OAAOA,GAAU,UACjBA,IAAU,MACV,eAAgBA,GACfA,EAA2BtC,aAAe"}
1
+ {"version":3,"file":"useInspectGuideClientStore.js","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.ts"],"sourcesContent":["import {\n KnockGuide,\n KnockGuideClientGroupStage,\n KnockGuideClientStoreState,\n KnockGuideIneligibilityMarker,\n KnockGuideSelectionResult,\n type ToolbarV2RunConfig,\n checkActivatable,\n checkStateIfThrottled,\n} from \"@knocklabs/client\";\nimport { useGuideContext, useStore } from \"@knocklabs/react-core\";\n\nimport { FOCUS_ERRORS } from \"./helpers\";\n\nconst byKey = <T extends { key: string }>(items: T[]) => {\n return items.reduce((acc, item) => ({ ...acc, [item.key]: item }), {});\n};\n\n/**\n * This is the main module that will house core logic for the toolbar. It hooks\n * into the guide client state store, extracts relevant data for debugging, and\n * transforms it into easily consumable data for the toolbar - namely\n * \"annotating\" guides for its various statuses to display.\n */\n\n// Active: `true` status = good\ntype ActiveStatus = {\n status: boolean;\n};\n\n// Targetable: `true` status = good\ntype TargetableStatusTrue = {\n status: true;\n};\ntype TargetableStatusFalse = {\n status: false;\n reason: string;\n message: string;\n};\ntype TargetableStatus = TargetableStatusTrue | TargetableStatusFalse;\n\ntype ActivatableStatus = {\n status: boolean;\n};\n\n// Archived: `false` status = good\ntype ArchivedStatus = {\n status: boolean;\n};\n\n// Selectable:\n// - \"returned\": Queried and resolved to return the guide from useGuide(s).\n// - \"throttled\": Queried and resolved but being throttled, so not yet returned.\n// - \"queried\": Queried but not resolved, because there are other higher\n// priority guides that are ahead of this guide in the query result.\n// - undefined: Not reachable with any of the given queries and filters.\ntype SelectionResultByLimit = {\n one?: KnockGuideSelectionResult;\n all?: KnockGuideSelectionResult;\n};\ntype SelectionResultByQuery = {\n key?: SelectionResultByLimit;\n type?: SelectionResultByLimit;\n};\ntype SelectableStatusPresent = {\n status: \"returned\" | \"throttled\" | \"queried\";\n query: SelectionResultByQuery;\n};\ntype SelectableStatusAbsent = {\n status: undefined;\n};\ntype SelectableStatus = SelectableStatusPresent | SelectableStatusAbsent;\n\nexport type AnnotatedStatuses = {\n // Individual eligibility statuses:\n active: ActiveStatus;\n targetable: TargetableStatus;\n archived: ArchivedStatus;\n // Individual qualified statuses:\n activatable: ActivatableStatus;\n selectable: SelectableStatus;\n};\n\ntype GuideAnnotation = AnnotatedStatuses & {\n // Resolved eligibility based on active, targetable and archived statuses,\n // which are backend driven evaluation results that are exposed for debugging.\n isEligible: boolean;\n\n // Resolved display qualification based on an activatable status, which\n // informs \"when\" and \"where\" an eligible guide can be displayed to user.\n isQualified: boolean;\n};\n\nexport type AnnotatedGuide = KnockGuide & {\n orderIndex: number;\n annotation: GuideAnnotation;\n\n // Legacy fields, typed only to make tsc happy when we prune these out.\n activation_location_rules?: KnockGuide[\"activation_url_patterns\"];\n priority?: number;\n};\n\n// Exists and ordered in control but absent in switchboard (therefore not\n// included in the api response), which implies a newly created guide that has\n// never been published to switchboard.\nexport type UncommittedGuide = {\n __typename: \"UncommittedGuide\";\n orderIndex: number;\n key: KnockGuide[\"key\"];\n active: false;\n bypass_global_group_limit: false;\n annotation: {\n isEligible: false;\n isQualified: false;\n active: {\n status: false;\n };\n selectable: {\n status: undefined;\n };\n };\n};\n\nexport type InspectionResultOk = {\n status: \"ok\";\n guides: (AnnotatedGuide | UncommittedGuide)[];\n};\ntype InspectionResultError = {\n status: \"error\";\n error:\n | \"no_guides_fetched\"\n | \"no_guide_group\"\n | \"focus_unknown_guide\"\n | \"focus_uncommitted_guide\"\n | \"focus_unselectable_guide\";\n message: string;\n};\ntype InspectionResult = InspectionResultOk | InspectionResultError;\n\ntype StoreStateSnapshot = Pick<\n KnockGuideClientStoreState,\n | \"location\"\n | \"guides\"\n | \"guideGroups\"\n | \"ineligibleGuides\"\n | \"debug\"\n | \"counter\"\n | \"queries\"\n> & {\n throttled: boolean;\n};\n\nconst inferSelectByKeyReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const includeThrottled =\n !!query.key?.one?.metadata?.opts?.includeThrottled ||\n !!query.key?.all?.metadata?.opts?.includeThrottled;\n\n // If unthrottled, then it should always be returned.\n if (guide.bypass_global_group_limit) {\n return \"returned\";\n }\n\n // If resolved, expect this guide to be returned unless being throttled.\n if (guide.key === stage.resolved) {\n if (snapshot.throttled && !includeThrottled) {\n return \"throttled\";\n }\n return \"returned\";\n }\n\n // If queried but not resolved, it means this guide is being shadowed by\n // another guide with higher priority because throttled guides can be\n // displayed only one at a time.\n return \"queried\";\n};\n\nconst inferSelectOneByTypeReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const includeThrottled = !!query.type?.one?.metadata?.opts?.includeThrottled;\n\n const result = query.type!.one!;\n if (result.size === 0) {\n return \"queried\";\n }\n\n // There may be multiple unthrottled guides of the same type, being queried\n // by type to return a single guide, for example: useGuide({ type: \"card\" }).\n //\n // So it is possible for an unthrottled guide to be shadowed by another\n // unthrottled guide of the same type with higher priority, so we need to\n // look at the query result to determine its return status.\n if (guide.bypass_global_group_limit) {\n const guides = [...result.values()];\n const first = guides[0]!;\n\n if (guide.key !== first.key) {\n // Being shadowed by another guide with higher priority.\n return \"queried\";\n }\n return \"returned\";\n }\n\n // If resolved, expect this guide to be returned unless being throttled.\n if (guide.key === stage.resolved) {\n if (snapshot.throttled && !includeThrottled) {\n return \"throttled\";\n }\n return \"returned\";\n }\n\n // If queried but not resolved, it means this guide is being shadowed by\n // another guide with higher priority because throttled guides can be\n // displayed only one at a time.\n return \"queried\";\n};\n\nconst inferSelectAllByTypeReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const result = query.type!.all!;\n if (result.size === 0) {\n return \"queried\";\n }\n\n const guides = [...result.values()];\n const first = guides[0]!;\n\n // Might want to consider moving this up to do once.\n const guidesByKey: Record<KnockGuide[\"key\"], KnockGuide> = byKey(guides);\n\n // If includeThrottled given, then expect all selected guides to be returned.\n const includeThrottled = !!query.type?.all?.metadata?.opts?.includeThrottled;\n if (includeThrottled) {\n return guidesByKey[guide.key] ? \"returned\" : \"queried\";\n }\n\n // If the first selected guide is unthrottled or resolved, then we should\n // have at minimum one guide to return, and potentially more based on whether\n // we are throttling currently and which other guides are unthrottled.\n if (first.bypass_global_group_limit || first.key === stage.resolved) {\n if (!guidesByKey[guide.key]) {\n return \"queried\";\n }\n if (snapshot.throttled) {\n return guide.bypass_global_group_limit ? \"returned\" : \"throttled\";\n }\n return \"returned\";\n }\n\n return \"queried\";\n};\n\nconst inferSelectReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n) => {\n // Querying by key can only return up to a max of one guide, regardless of\n // useGuide or useGuides, and should take precedence in status designation.\n if (query.key) {\n return inferSelectByKeyReturnStatus(guide, snapshot, stage, query);\n }\n\n if (query.type?.all) {\n return inferSelectAllByTypeReturnStatus(guide, snapshot, stage, query);\n }\n if (query.type?.one) {\n return inferSelectOneByTypeReturnStatus(guide, snapshot, stage, query);\n }\n\n // Should not happen but just for completeness.\n return undefined;\n};\n\nconst toSelectableStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage | undefined,\n): SelectableStatus => {\n if (!stage || stage.status === \"open\") {\n return { status: undefined };\n }\n\n const query = {\n key: (stage.results.key || {})[guide.key],\n type: (stage.results.type || {})[guide.type],\n };\n\n const queried = Boolean(query.key || query.type);\n if (!queried) {\n // No present query in the current location can select this guide.\n return { status: undefined };\n }\n\n const status = inferSelectReturnStatus(guide, snapshot, stage, query);\n if (!status) {\n return { status: undefined };\n }\n\n return { status, query };\n};\n\nconst toIneligibilityStatus = (\n guide: KnockGuide,\n marker?: KnockGuideIneligibilityMarker,\n): Partial<AnnotatedStatuses> => {\n const statuses: Partial<AnnotatedStatuses> = {};\n\n if (\n marker?.reason === \"not_in_target_audience\" ||\n marker?.reason === \"target_conditions_not_met\"\n ) {\n statuses.targetable = {\n status: false,\n reason: marker.reason,\n message: marker.message,\n };\n }\n\n if (\n marker?.reason === \"marked_as_archived\" ||\n (guide.steps || []).every((s) => !!s.message.archived_at)\n ) {\n statuses.archived = {\n status: true,\n };\n }\n\n if (marker?.reason === \"guide_not_active\") {\n statuses.active = {\n status: false,\n };\n }\n\n return statuses;\n};\n\nconst resolveIsEligible = ({\n active,\n targetable,\n archived,\n}: AnnotatedStatuses) => {\n if (!active.status) return false;\n if (!targetable.status) return false;\n if (archived.status) return false;\n return true;\n};\n\nexport const resolveIsQualified = ({\n activatable,\n selectable,\n}: AnnotatedStatuses) => {\n if (!activatable.status) return false;\n if (!selectable.status) return false;\n return true;\n};\n\nconst annotateGuide = (\n guide: KnockGuide,\n orderIndex: number,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage | undefined,\n): AnnotatedGuide => {\n const { ineligibleGuides, location } = snapshot;\n const marker = ineligibleGuides[guide.key];\n const ineligiblity = toIneligibilityStatus(guide, marker);\n\n const statuses: AnnotatedStatuses = {\n // isEligible:\n active: ineligiblity?.active || { status: true },\n targetable: ineligiblity?.targetable || { status: true },\n archived: ineligiblity?.archived || { status: false },\n // isQualified:\n activatable: { status: checkActivatable(guide, location) },\n selectable: toSelectableStatus(guide, snapshot, stage),\n };\n\n const annotation: GuideAnnotation = {\n ...statuses,\n isEligible: resolveIsEligible(statuses),\n isQualified: resolveIsQualified(statuses),\n };\n\n return {\n ...guide,\n orderIndex,\n annotation,\n };\n};\n\nconst newUncommittedGuide = (key: KnockGuide[\"key\"], orderIndex: number) =>\n ({\n __typename: \"UncommittedGuide\",\n key,\n orderIndex,\n active: false,\n bypass_global_group_limit: false,\n annotation: {\n isEligible: false,\n isQualified: false,\n active: {\n status: false,\n },\n selectable: {\n status: undefined,\n },\n },\n }) as UncommittedGuide;\n\nexport const useInspectGuideClientStore = (\n runConfig: ToolbarV2RunConfig,\n): InspectionResult | undefined => {\n const { client } = useGuideContext();\n\n // Extract a snapshot of the client store state for debugging.\n const snapshot: StoreStateSnapshot = useStore(client.store, (state) => {\n const throttled = checkStateIfThrottled(state);\n\n return {\n location: state.location,\n guides: state.guides,\n guideGroups: state.guideGroups,\n ineligibleGuides: state.ineligibleGuides,\n debug: state.debug,\n counter: state.counter,\n queries: state.queries,\n throttled,\n };\n });\n\n // Not in debugging session, so noop.\n if (!snapshot.debug?.debugging) {\n return undefined;\n }\n\n // No recorded fetch requests, which implies an inflight request loading.\n const req = Object.entries(snapshot.queries)[0];\n if (!req || req[1].status === \"loading\") {\n return {\n status: \"error\",\n error: \"no_guides_fetched\",\n message: \"Loading...\",\n };\n }\n\n // Should always be a default group so this should never happen.\n const defaultGroup = snapshot.guideGroups[0];\n if (!defaultGroup) {\n return {\n status: \"error\",\n error: \"no_guide_group\",\n message: \"No guide group found\",\n };\n }\n\n const groupStage = client.getStage();\n\n // Annotate guides for various eligibility, activation and query statuses\n // that are useful for debugging purposes.\n const orderedGuides = defaultGroup.display_sequence.map((guideKey, index) => {\n const guide = snapshot.guides[guideKey];\n if (!guide) {\n return newUncommittedGuide(guideKey, index);\n }\n\n return annotateGuide(guide, index, snapshot, groupStage);\n });\n\n // Check if the focused guide actually exists and is selectable on the page.\n const focusedGuideKey = Object.keys(runConfig.focusedGuideKeys || {})[0];\n if (groupStage?.status === \"closed\" && focusedGuideKey) {\n const foundGuide = orderedGuides.find((g) => g.key === focusedGuideKey);\n\n // No such guide exists for the given focused guide key.\n if (!foundGuide) {\n return {\n status: \"error\",\n error: \"focus_unknown_guide\",\n message: `Unable to display \\`${focusedGuideKey}\\`, ${FOCUS_ERRORS.focusUnknownGuide.toLowerCase()}.`,\n };\n }\n\n // This guide exists but has never been committed and published, so it is\n // not present in the API response.\n if (isUncommittedGuide(foundGuide)) {\n return {\n status: \"error\",\n error: \"focus_uncommitted_guide\",\n message: `Unable to display \\`${focusedGuideKey}\\`, ${FOCUS_ERRORS.focusUncommittedGuide.toLowerCase()}.`,\n };\n }\n\n // This guide exists and is present in the response, but it is not queried\n // in the current page so it is impossible to force render this guide.\n if (!foundGuide.annotation.selectable.status) {\n return {\n status: \"error\",\n error: \"focus_unselectable_guide\",\n message: `Unable to display \\`${focusedGuideKey}\\`, ${FOCUS_ERRORS.focusUnselectableGuide.toLowerCase()}.`,\n };\n }\n }\n\n return {\n status: \"ok\",\n guides: orderedGuides,\n };\n};\n\nexport const isUncommittedGuide = (input: unknown): input is UncommittedGuide =>\n typeof input === \"object\" &&\n input !== null &&\n \"__typename\" in input &&\n (input as UncommittedGuide).__typename === \"UncommittedGuide\";\n"],"names":["byKey","items","reduce","acc","item","key","inferSelectByKeyReturnStatus","guide","snapshot","stage","query","includeThrottled","one","metadata","opts","all","bypass_global_group_limit","resolved","throttled","inferSelectOneByTypeReturnStatus","type","result","size","first","values","inferSelectAllByTypeReturnStatus","guides","guidesByKey","inferSelectReturnStatus","toSelectableStatus","status","undefined","results","Boolean","toIneligibilityStatus","marker","statuses","reason","targetable","message","steps","every","s","archived_at","archived","active","resolveIsEligible","resolveIsQualified","activatable","selectable","annotateGuide","orderIndex","ineligibleGuides","location","ineligiblity","checkActivatable","annotation","isEligible","isQualified","newUncommittedGuide","__typename","useInspectGuideClientStore","runConfig","client","useGuideContext","useStore","store","state","checkStateIfThrottled","guideGroups","debug","counter","queries","debugging","req","Object","entries","error","defaultGroup","groupStage","getStage","orderedGuides","display_sequence","map","guideKey","index","focusedGuideKey","keys","focusedGuideKeys","foundGuide","find","g","FOCUS_ERRORS","focusUnknownGuide","toLowerCase","isUncommittedGuide","focusUncommittedGuide","focusUnselectableGuide","input"],"mappings":"kLAcMA,EAAoCC,GACjCA,EAAMC,OAAO,CAACC,EAAKC,KAAU,CAAE,GAAGD,EAAK,CAACC,EAAKC,GAAG,EAAGD,CAAK,GAAI,CAAA,CAAE,EAyIjEE,EAA+BA,CACnCC,EACAC,EACAC,EACAC,IACsC,qBACtC,MAAMC,EACJ,CAAC,GAACD,GAAAA,GAAAA,GAAAA,EAAAA,EAAML,MAANK,YAAAA,EAAWE,MAAXF,YAAAA,EAAgBG,WAAhBH,YAAAA,EAA0BI,OAA1BJ,MAAAA,EAAgCC,mBAClC,CAAC,GAACD,GAAAA,GAAAA,GAAAA,EAAAA,EAAML,MAANK,YAAAA,EAAWK,MAAXL,YAAAA,EAAgBG,WAAhBH,YAAAA,EAA0BI,OAA1BJ,MAAAA,EAAgCC,kBAGpC,OAAIJ,EAAMS,0BACD,WAILT,EAAMF,MAAQI,EAAMQ,SAClBT,EAASU,WAAa,CAACP,EAClB,YAEF,WAMF,SACT,EAEMQ,EAAmCA,CACvCZ,EACAC,EACAC,EACAC,IACsC,aACtC,MAAMC,EAAmB,CAAC,GAACD,GAAAA,GAAAA,GAAAA,EAAAA,EAAMU,OAANV,YAAAA,EAAYE,MAAZF,YAAAA,EAAiBG,WAAjBH,YAAAA,EAA2BI,OAA3BJ,MAAAA,EAAiCC,kBAEtDU,EAASX,EAAMU,KAAMR,IACvBS,GAAAA,EAAOC,OAAS,EACX,MAAA,UAST,GAAIf,EAAMS,0BAA2B,CAE7BO,MA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defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@knocklabs/react-core"),n=require("react");require("../components/Banner/Banner.js");require("../components/Card/Card.js");const o=require("../components/Toolbar/V1/V1.js"),a=require("../components/Toolbar/V2/V2.js");require("../components/Modal/Modal.js");const i=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},t=i(n),l=({children:e,toolbar:r="v2",...u})=>t.default.createElement(c.KnockGuideProvider,{...u,trackDebugParams:r==="v1"},e,r==="v2"?t.default.createElement(a.V2,null):t.default.createElement(o.V1,null));exports.KnockGuideProvider=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@knocklabs/react-core"),o=require("react");require("../components/Banner/Banner.js");require("../components/Card/Card.js");const i=require("../components/Toolbar/V1/V1.js"),a=require("../components/Toolbar/V2/V2.js");require("../components/Modal/Modal.js");const l=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},t=l(o),d=({children:e,toolbar:r="v2",readyToTarget:u,...c})=>t.default.createElement(n.KnockGuideProvider,{...c,readyToTarget:u,trackDebugParams:r==="v1"},e,r==="v2"?t.default.createElement(a.V2,{readyToTarget:u}):t.default.createElement(i.V1,null));exports.KnockGuideProvider=d;
2
2
  //# sourceMappingURL=KnockGuideProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KnockGuideProvider.js","sources":["../../../../../src/modules/guide/providers/KnockGuideProvider.tsx"],"sourcesContent":["import {\n KnockGuideProvider as KnockGuideProviderCore,\n type KnockGuideProviderProps,\n} from \"@knocklabs/react-core\";\nimport React from \"react\";\n\nimport { ToolbarV1, ToolbarV2 } from \"../components\";\n\ntype Props = KnockGuideProviderProps & {\n toolbar?: \"v1\" | \"v2\";\n};\n\n// Re-export the core KnockGuideProvider, so we can add React specific\n// functionality like the Toolbar component which shouldn't be included in other\n// contexts (e.g. React Native).\nexport const KnockGuideProvider: React.FC<React.PropsWithChildren<Props>> = ({\n children,\n toolbar = \"v2\",\n ...props\n}) => {\n return (\n <KnockGuideProviderCore\n {...props}\n // For backward compatibility with toolbar v1. Remove once v2 ships.\n trackDebugParams={toolbar === \"v1\"}\n >\n {children}\n {toolbar === \"v2\" ? <ToolbarV2 /> : <ToolbarV1 />}\n </KnockGuideProviderCore>\n );\n};\n"],"names":["KnockGuideProvider","children","toolbar","props","React","KnockGuideProviderCore","ToolbarV2","ToolbarV1"],"mappings":"uaAeaA,EAA+DA,CAAC,CAC3EC,SAAAA,EACAC,QAAAA,EAAU,KACV,GAAGC,CACL,IAEIC,EAAA,QAAA,cAACC,EAAA,mBAAA,CACC,GAAIF,EAEJ,iBAAkBD,IAAY,IAAA,EAE7BD,EACAC,IAAY,KAAOE,EAAA,QAAA,cAACE,EAAAA,GAAY,IAAA,0BAAIC,EAAAA,GAAY,IAAA,CACnD"}
1
+ {"version":3,"file":"KnockGuideProvider.js","sources":["../../../../../src/modules/guide/providers/KnockGuideProvider.tsx"],"sourcesContent":["import {\n KnockGuideProvider as KnockGuideProviderCore,\n type KnockGuideProviderProps,\n} from \"@knocklabs/react-core\";\nimport React from \"react\";\n\nimport { ToolbarV1, ToolbarV2 } from \"../components\";\n\ntype Props = KnockGuideProviderProps & {\n toolbar?: \"v1\" | \"v2\";\n};\n\n// Re-export the core KnockGuideProvider, so we can add React specific\n// functionality like the Toolbar component which shouldn't be included in other\n// contexts (e.g. React Native).\nexport const KnockGuideProvider: React.FC<React.PropsWithChildren<Props>> = ({\n children,\n toolbar = \"v2\",\n readyToTarget,\n ...props\n}) => {\n return (\n <KnockGuideProviderCore\n {...props}\n readyToTarget={readyToTarget}\n // For backward compatibility with toolbar v1. Remove once v2 ships.\n trackDebugParams={toolbar === \"v1\"}\n >\n {children}\n {toolbar === \"v2\" ? (\n <ToolbarV2 readyToTarget={readyToTarget} />\n ) : (\n <ToolbarV1 />\n )}\n </KnockGuideProviderCore>\n );\n};\n"],"names":["KnockGuideProvider","children","toolbar","readyToTarget","props","React","KnockGuideProviderCore","ToolbarV2","ToolbarV1"],"mappings":"uaAeaA,EAA+DA,CAAC,CAC3EC,SAAAA,EACAC,QAAAA,EAAU,KACVC,cAAAA,EACA,GAAGC,CACL,IAEIC,EAAA,QAAA,cAACC,EAAA,mBAAA,CACKF,GAAAA,EACJ,cAAAD,EAEA,iBAAkBD,IAAY,IAAA,EAE7BD,EACAC,IAAY,KACXG,UAAA,cAACE,MAAU,cAAAJ,4BAEVK,EACF,GAAA,IAAA,CACH"}
@@ -28,10 +28,10 @@ import "@telegraph/tag";
28
28
  import "@telegraph/typography";
29
29
  import "lucide-react";
30
30
  /* empty css */
31
+ import "@knocklabs/client";
31
32
  import "@telegraph/icon";
32
33
  import "@telegraph/segmented-control";
33
34
  import "@telegraph/tooltip";
34
- import "@knocklabs/client";
35
35
  import "@telegraph/toggle";
36
36
  import { Modal as ze, ModalView as Je } from "./modules/guide/components/Modal/Modal.mjs";
37
37
  import { KnockGuideProvider as We } from "./modules/guide/providers/KnockGuideProvider.mjs";
@@ -1,79 +1,80 @@
1
- import { useGuideContext as g, useStore as y } from "@knocklabs/react-core";
1
+ import { useGuideContext as h, useStore as y } from "@knocklabs/react-core";
2
2
  import { Button as d } from "@telegraph/button";
3
- import { Box as h, Stack as p } from "@telegraph/layout";
3
+ import { Box as x, Stack as f } from "@telegraph/layout";
4
4
  import { Tooltip as m } from "@telegraph/tooltip";
5
- import { Text as x } from "@telegraph/typography";
6
- import { ChevronLeft as E, ChevronRight as k, X as v } from "lucide-react";
5
+ import { Text as E } from "@telegraph/typography";
6
+ import { ChevronLeft as v, ChevronRight as k, X as C } from "lucide-react";
7
7
  import * as t from "react";
8
- import { GUIDE_ROW_DATA_SELECTOR as C } from "./GuideRow.mjs";
9
- const f = 60, b = (o, i) => {
8
+ import { GUIDE_ROW_DATA_SELECTOR as T } from "./GuideRow.mjs";
9
+ import { sharedTooltipProps as p } from "./helpers.mjs";
10
+ const b = 60, g = (o, i) => {
10
11
  requestAnimationFrame(() => {
11
- const n = o.querySelector(`[${C}="${CSS.escape(i)}"]`);
12
- if (!n || !(n instanceof HTMLElement)) return;
13
- const e = o.getBoundingClientRect(), c = n.getBoundingClientRect();
12
+ const r = o.querySelector(`[${T}="${CSS.escape(i)}"]`);
13
+ if (!r || !(r instanceof HTMLElement)) return;
14
+ const e = o.getBoundingClientRect(), c = r.getBoundingClientRect();
14
15
  c.top < e.top ? o.scrollTo({
15
- top: o.scrollTop - (e.top - c.top) - f,
16
+ top: o.scrollTop - (e.top - c.top) - b,
16
17
  behavior: "smooth"
17
18
  }) : c.bottom > e.bottom && o.scrollTo({
18
- top: o.scrollTop + (c.bottom - e.bottom) + f,
19
+ top: o.scrollTop + (c.bottom - e.bottom) + b,
19
20
  behavior: "smooth"
20
21
  });
21
22
  });
22
- }, K = ({
23
+ }, z = ({
23
24
  guides: o,
24
25
  guideListRef: i
25
26
  }) => {
26
27
  const {
27
- client: n
28
- } = g(), {
28
+ client: r
29
+ } = h(), {
29
30
  debugSettings: e
30
- } = y(n.store, (r) => ({
31
- debugSettings: r.debug
31
+ } = y(r.store, (n) => ({
32
+ debugSettings: n.debug
32
33
  })), c = Object.keys((e == null ? void 0 : e.focusedGuideKeys) || {});
33
34
  if (!(c.length > 0))
34
35
  return null;
35
36
  const a = c[0];
36
- return /* @__PURE__ */ t.createElement(h, { borderTop: "px", px: "3", py: "1", overflow: "hidden", backgroundColor: "blue-2" }, /* @__PURE__ */ t.createElement(p, { align: "center", justify: "space-between", gap: "4" }, /* @__PURE__ */ t.createElement(x, { as: "span", size: "1", weight: "medium", color: "blue", style: {
37
+ return /* @__PURE__ */ t.createElement(x, { borderTop: "px", px: "3", py: "1", overflow: "hidden", backgroundColor: "blue-2" }, /* @__PURE__ */ t.createElement(f, { align: "center", justify: "space-between", gap: "4" }, /* @__PURE__ */ t.createElement(E, { as: "span", size: "1", weight: "medium", color: "blue", style: {
37
38
  display: "block",
38
39
  overflow: "hidden",
39
40
  textOverflow: "ellipsis",
40
41
  whiteSpace: "nowrap",
41
42
  minWidth: 0
42
- } }, "Focus mode: ", a), /* @__PURE__ */ t.createElement(p, { align: "center", gap: "1", style: {
43
+ } }, "Focus mode: ", a), /* @__PURE__ */ t.createElement(f, { align: "center", gap: "1", style: {
43
44
  flexShrink: 0
44
- } }, /* @__PURE__ */ t.createElement(m, { label: "Focus previous guide" }, /* @__PURE__ */ t.createElement(d, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
45
- icon: E,
45
+ } }, /* @__PURE__ */ t.createElement(m, { label: "Focus previous guide", ...p }, /* @__PURE__ */ t.createElement(d, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
46
+ icon: v,
46
47
  alt: "Previous guide"
47
48
  }, onClick: () => {
48
- const r = o.filter((s) => !!s.annotation.selectable.status), u = r.findIndex((s) => s.key === a), l = u <= 0 ? void 0 : r[u - 1];
49
- l && (n.setDebug({
49
+ const n = o.filter((s) => !!s.annotation.selectable.status), u = n.findIndex((s) => s.key === a), l = u <= 0 ? void 0 : n[u - 1];
50
+ l && (r.setDebug({
50
51
  ...e,
51
52
  focusedGuideKeys: {
52
53
  [l.key]: !0
53
54
  }
54
- }), i.current && b(i.current, l.key));
55
- } })), /* @__PURE__ */ t.createElement(m, { label: "Focus next guide" }, /* @__PURE__ */ t.createElement(d, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
55
+ }), i.current && g(i.current, l.key));
56
+ } })), /* @__PURE__ */ t.createElement(m, { label: "Focus next guide", ...p }, /* @__PURE__ */ t.createElement(d, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
56
57
  icon: k,
57
58
  alt: "Next guide"
58
59
  }, onClick: () => {
59
- const r = o.filter((s) => !!s.annotation.selectable.status), u = r.findIndex((s) => s.key === a), l = u < 0 || u + 1 > r.length - 1 ? void 0 : r[u + 1];
60
- l && (n.setDebug({
60
+ const n = o.filter((s) => !!s.annotation.selectable.status), u = n.findIndex((s) => s.key === a), l = u < 0 || u + 1 > n.length - 1 ? void 0 : n[u + 1];
61
+ l && (r.setDebug({
61
62
  ...e,
62
63
  focusedGuideKeys: {
63
64
  [l.key]: !0
64
65
  }
65
- }), i.current && b(i.current, l.key));
66
- } })), /* @__PURE__ */ t.createElement(m, { label: "Exit focus lock" }, /* @__PURE__ */ t.createElement(d, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
67
- icon: v,
66
+ }), i.current && g(i.current, l.key));
67
+ } })), /* @__PURE__ */ t.createElement(m, { label: "Exit focus mode", ...p }, /* @__PURE__ */ t.createElement(d, { size: "0", variant: "ghost", color: "blue", leadingIcon: {
68
+ icon: C,
68
69
  alt: "Clear focus"
69
70
  }, onClick: () => {
70
- n.setDebug({
71
+ r.setDebug({
71
72
  ...e,
72
73
  focusedGuideKeys: {}
73
74
  });
74
75
  } })))));
75
76
  };
76
77
  export {
77
- K as FocusChin
78
+ z as FocusChin
78
79
  };
79
80
  //# sourceMappingURL=FocusChin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"FocusChin.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/FocusChin.tsx"],"sourcesContent":["import { useGuideContext, useStore } from \"@knocklabs/react-core\";\nimport { Button } from \"@telegraph/button\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport { ChevronLeft, ChevronRight, X } from \"lucide-react\";\nimport * as React from \"react\";\n\nimport { GUIDE_ROW_DATA_SELECTOR } from \"./GuideRow\";\nimport { InspectionResultOk } from \"./useInspectGuideClientStore\";\n\n// Extra scroll overshoot so the focused guide plus ~1-2 neighbors are visible,\n// reducing how often consecutive next/prev clicks trigger a scroll.\nconst SCROLL_OVERSHOOT = 60;\n\nconst maybeScrollGuideIntoView = (container: HTMLElement, guideKey: string) => {\n requestAnimationFrame(() => {\n const el = container.querySelector(\n `[${GUIDE_ROW_DATA_SELECTOR}=\"${CSS.escape(guideKey)}\"]`,\n );\n if (!el || !(el instanceof HTMLElement)) return;\n\n const containerRect = container.getBoundingClientRect();\n const elRect = el.getBoundingClientRect();\n\n if (elRect.top < containerRect.top) {\n container.scrollTo({\n top:\n container.scrollTop -\n (containerRect.top - elRect.top) -\n SCROLL_OVERSHOOT,\n behavior: \"smooth\",\n });\n } else if (elRect.bottom > containerRect.bottom) {\n container.scrollTo({\n top:\n container.scrollTop +\n (elRect.bottom - containerRect.bottom) +\n SCROLL_OVERSHOOT,\n behavior: \"smooth\",\n });\n }\n });\n};\n\ntype Props = {\n guides: InspectionResultOk[\"guides\"];\n guideListRef: React.RefObject<HTMLDivElement | null>;\n};\n\nexport const FocusChin = ({ guides, guideListRef }: Props) => {\n const { client } = useGuideContext();\n const { debugSettings } = useStore(client.store, (state) => ({\n debugSettings: state.debug,\n }));\n\n const focusedKeys = Object.keys(debugSettings?.focusedGuideKeys || {});\n\n const isFocused = focusedKeys.length > 0;\n if (!isFocused) {\n return null;\n }\n\n const currentKey = focusedKeys[0]!;\n\n return (\n <Box\n borderTop=\"px\"\n px=\"3\"\n py=\"1\"\n overflow=\"hidden\"\n backgroundColor=\"blue-2\"\n >\n <Stack align=\"center\" justify=\"space-between\" gap=\"4\">\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color=\"blue\"\n style={{\n display: \"block\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n minWidth: 0,\n }}\n >\n Focus mode: {currentKey}\n </Text>\n <Stack align=\"center\" gap=\"1\" style={{ flexShrink: 0 }}>\n <Tooltip label=\"Focus previous guide\">\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: ChevronLeft, alt: \"Previous guide\" }}\n onClick={() => {\n const selectableGuides = guides.filter(\n (g) => !!g.annotation.selectable.status,\n );\n const currIndex = selectableGuides.findIndex(\n (g) => g.key === currentKey,\n );\n const prevGuide =\n currIndex <= 0 ? undefined : selectableGuides[currIndex - 1];\n\n if (!prevGuide) return;\n\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: { [prevGuide.key]: true },\n });\n\n if (guideListRef.current) {\n maybeScrollGuideIntoView(guideListRef.current, prevGuide.key);\n }\n }}\n />\n </Tooltip>\n <Tooltip label=\"Focus next guide\">\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: ChevronRight, alt: \"Next guide\" }}\n onClick={() => {\n const selectableGuides = guides.filter(\n (g) => !!g.annotation.selectable.status,\n );\n const currIndex = selectableGuides.findIndex(\n (g) => g.key === currentKey,\n );\n const nextGuide =\n currIndex < 0 || currIndex + 1 > selectableGuides.length - 1\n ? undefined\n : selectableGuides[currIndex + 1];\n\n if (!nextGuide) return;\n\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: { [nextGuide.key]: true },\n });\n\n if (guideListRef.current) {\n maybeScrollGuideIntoView(guideListRef.current, nextGuide.key);\n }\n }}\n />\n </Tooltip>\n <Tooltip label=\"Exit focus lock\">\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: X, alt: \"Clear focus\" }}\n onClick={() => {\n client.setDebug({ ...debugSettings, focusedGuideKeys: {} });\n }}\n />\n </Tooltip>\n </Stack>\n </Stack>\n </Box>\n );\n};\n"],"names":["SCROLL_OVERSHOOT","maybeScrollGuideIntoView","container","guideKey","requestAnimationFrame","el","querySelector","GUIDE_ROW_DATA_SELECTOR","CSS","escape","HTMLElement","containerRect","getBoundingClientRect","elRect","top","scrollTo","scrollTop","behavior","bottom","FocusChin","guides","guideListRef","client","useGuideContext","debugSettings","useStore","store","state","debug","focusedKeys","Object","keys","focusedGuideKeys","length","currentKey","React","Box","Stack","Text","display","overflow","textOverflow","whiteSpace","minWidth","flexShrink","Tooltip","Button","icon","ChevronLeft","alt","selectableGuides","filter","g","annotation","selectable","status","currIndex","findIndex","key","prevGuide","undefined","setDebug","current","ChevronRight","nextGuide","X"],"mappings":";;;;;;;;AAaA,MAAMA,IAAmB,IAEnBC,IAA2BA,CAACC,GAAwBC,MAAqB;AAC7EC,wBAAsB,MAAM;A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AAS,IACvD2B,SACAV,EAAiBM,IAAY,CAAC;AAEpC,IAAKQ,MAEL1C,EAAOuC,SAAS;AAAA,MACd,GAAGrC;AAAAA,MACHQ,kBAAkB;AAAA,QAAE,CAACgC,EAAUN,GAAG,GAAG;AAAA,MAAA;AAAA,IAAK,CAC3C,GAEGrC,EAAayC,WACUzC,EAAAA,EAAayC,SAASE,EAAUN,GAAG;AAAA,EAC9D,GACA,CAEN,GACA,gBAAAvB,EAAA,cAACU,KAAQ,OAAM,kBAAA,GACZ,gBAAAV,EAAA,cAAAW,GAAA,EACC,MAAK,KACL,SAAQ,SACR,OAAM,QACN,aAAa;AAAA,IAAEC,MAAMkB;AAAAA,IAAGhB,KAAK;AAAA,EAAc,GAC3C,SAAS,MAAM;AACb3B,IAAAA,EAAOuC,SAAS;AAAA,MAAE,GAAGrC;AAAAA,MAAeQ,kBAAkB,CAAA;AAAA,IAAC,CAAG;AAAA,EAAA,EAC1D,CAAA,CAEN,CACF,CACF,CACF;AAEJ;"}
1
+ {"version":3,"file":"FocusChin.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/FocusChin.tsx"],"sourcesContent":["import { useGuideContext, useStore } from \"@knocklabs/react-core\";\nimport { Button } from \"@telegraph/button\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport { ChevronLeft, ChevronRight, X } from \"lucide-react\";\nimport * as React from \"react\";\n\nimport { GUIDE_ROW_DATA_SELECTOR } from \"./GuideRow\";\nimport { sharedTooltipProps } from \"./helpers\";\nimport { InspectionResultOk } from \"./useInspectGuideClientStore\";\n\n// Extra scroll overshoot so the focused guide plus ~1-2 neighbors are visible,\n// reducing how often consecutive next/prev clicks trigger a scroll.\nconst SCROLL_OVERSHOOT = 60;\n\nconst maybeScrollGuideIntoView = (container: HTMLElement, guideKey: string) => {\n requestAnimationFrame(() => {\n const el = container.querySelector(\n `[${GUIDE_ROW_DATA_SELECTOR}=\"${CSS.escape(guideKey)}\"]`,\n );\n if (!el || !(el instanceof HTMLElement)) return;\n\n const containerRect = container.getBoundingClientRect();\n const elRect = el.getBoundingClientRect();\n\n if (elRect.top < containerRect.top) {\n container.scrollTo({\n top:\n container.scrollTop -\n (containerRect.top - elRect.top) -\n SCROLL_OVERSHOOT,\n behavior: \"smooth\",\n });\n } else if (elRect.bottom > containerRect.bottom) {\n container.scrollTo({\n top:\n container.scrollTop +\n (elRect.bottom - containerRect.bottom) +\n SCROLL_OVERSHOOT,\n behavior: \"smooth\",\n });\n }\n });\n};\n\ntype Props = {\n guides: InspectionResultOk[\"guides\"];\n guideListRef: React.RefObject<HTMLDivElement | null>;\n};\n\nexport const FocusChin = ({ guides, guideListRef }: Props) => {\n const { client } = useGuideContext();\n const { debugSettings } = useStore(client.store, (state) => ({\n debugSettings: state.debug,\n }));\n\n const focusedKeys = Object.keys(debugSettings?.focusedGuideKeys || {});\n\n const isFocused = focusedKeys.length > 0;\n if (!isFocused) {\n return null;\n }\n\n const currentKey = focusedKeys[0]!;\n\n return (\n <Box\n borderTop=\"px\"\n px=\"3\"\n py=\"1\"\n overflow=\"hidden\"\n backgroundColor=\"blue-2\"\n >\n <Stack align=\"center\" justify=\"space-between\" gap=\"4\">\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color=\"blue\"\n style={{\n display: \"block\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n minWidth: 0,\n }}\n >\n Focus mode: {currentKey}\n </Text>\n <Stack align=\"center\" gap=\"1\" style={{ flexShrink: 0 }}>\n <Tooltip label=\"Focus previous guide\" {...sharedTooltipProps}>\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: ChevronLeft, alt: \"Previous guide\" }}\n onClick={() => {\n const selectableGuides = guides.filter(\n (g) => !!g.annotation.selectable.status,\n );\n const currIndex = selectableGuides.findIndex(\n (g) => g.key === currentKey,\n );\n const prevGuide =\n currIndex <= 0 ? undefined : selectableGuides[currIndex - 1];\n\n if (!prevGuide) return;\n\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: { [prevGuide.key]: true },\n });\n\n if (guideListRef.current) {\n maybeScrollGuideIntoView(guideListRef.current, prevGuide.key);\n }\n }}\n />\n </Tooltip>\n <Tooltip label=\"Focus next guide\" {...sharedTooltipProps}>\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: ChevronRight, alt: \"Next guide\" }}\n onClick={() => {\n const selectableGuides = guides.filter(\n (g) => !!g.annotation.selectable.status,\n );\n const currIndex = selectableGuides.findIndex(\n (g) => g.key === currentKey,\n );\n const nextGuide =\n currIndex < 0 || currIndex + 1 > selectableGuides.length - 1\n ? undefined\n : selectableGuides[currIndex + 1];\n\n if (!nextGuide) return;\n\n client.setDebug({\n ...debugSettings,\n focusedGuideKeys: { [nextGuide.key]: true },\n });\n\n if (guideListRef.current) {\n maybeScrollGuideIntoView(guideListRef.current, nextGuide.key);\n }\n }}\n />\n </Tooltip>\n <Tooltip label=\"Exit focus mode\" {...sharedTooltipProps}>\n <Button\n size=\"0\"\n variant=\"ghost\"\n color=\"blue\"\n leadingIcon={{ icon: X, alt: \"Clear focus\" }}\n onClick={() => {\n client.setDebug({ ...debugSettings, focusedGuideKeys: {} });\n }}\n />\n </Tooltip>\n </Stack>\n </Stack>\n </Box>\n );\n};\n"],"names":["SCROLL_OVERSHOOT","maybeScrollGuideIntoView","container","guideKey","requestAnimationFrame","el","querySelector","GUIDE_ROW_DATA_SELECTOR","CSS","escape","HTMLElement","containerRect","getBoundingClientRect","elRect","top","scrollTo","scrollTop","behavior","bottom","FocusChin","guides","guideListRef","client","useGuideContext","debugSettings","useStore","store","state","debug","focusedKeys","Object","keys","focusedGuideKeys","length","currentKey","React","Box","Stack","Text","display","overflow","textOverflow","whiteSpace","minWidth","flexShrink","Tooltip","sharedTooltipProps","Button","icon","ChevronLeft","alt","selectableGuides","filter","g","annotation","selectable","status","currIndex","findIndex","key","prevGuide","undefined","setDebug","current","ChevronRight","nextGuide","X"],"mappings":";;;;;;;;;AAcA,MAAMA,IAAmB,IAEnBC,IAA2BA,CAACC,GAAwBC,MAAqB;AAC7EC,wBAAsB,MAAM;AACpBC,UAAAA,IAAKH,EAAUI,cACnB,IAAIC,CAAuB,KAAKC,IAAIC,OAAON,CAAQ,CAAC,IACtD;AACA,QAAI,CAACE,KAAM,EAAEA,aAAcK,aAAc;AAEnCC,UAAAA,IAAgBT,EAAUU,sBAAsB,GAChDC,IAASR,EAAGO,sBAAsB;AAEpCC,IAAAA,EAAOC,MAAMH,EAAcG,MAC7BZ,EAAUa,SAAS;AAAA,MACjBD,KACEZ,EAAUc,aACTL,EAAcG,MAAMD,EAAOC,OAC5Bd;AAAAA,MACFiB,UAAU;AAAA,IAAA,CACX,IACQJ,EAAOK,SAASP,EAAcO,UACvChB,EAAUa,SAAS;AAAA,MACjBD,KACEZ,EAAUc,aACTH,EAAOK,SAASP,EAAcO,UAC/BlB;AAAAA,MACFiB,UAAU;AAAA,IAAA,CACX;AAAA,EACH,CACD;AACH,GAOaE,IAAYA,CAAC;AAAA,EAAEC,QAAAA;AAAAA,EAAQC,cAAAA;AAAoB,MAAM;AACtD,QAAA;AAAA,IAAEC,QAAAA;AAAAA,MAAWC,EAAgB,GAC7B;AAAA,IAAEC,eAAAA;AAAAA,EAAkBC,IAAAA,EAASH,EAAOI,OAAQC,CAAWA,OAAA;AAAA,IAC3DH,eAAeG,EAAMC;AAAAA,EAAAA,EACrB,GAEIC,IAAcC,OAAOC,MAAKP,KAAAA,gBAAAA,EAAeQ,qBAAoB,CAAA,CAAE;AAGrE,MAAI,EADcH,EAAYI,SAAS;AAE9B,WAAA;AAGHC,QAAAA,IAAaL,EAAY,CAAC;AAEhC,SACG,gBAAAM,EAAA,cAAAC,GAAA,EACC,WAAU,MACV,IAAG,KACH,IAAG,KACH,UAAS,UACT,iBAAgB,SAAA,mCAEf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AAA,IAAmB/B,EAAOgC,OAC7BC,CAAAA,MAAM,CAAC,CAACA,EAAEC,WAAWC,WAAWC,MACnC,GACMC,IAAYN,EAAiBO,UAChCL,CAAMA,MAAAA,EAAEM,QAAQzB,CACnB,GACM+B,IACJR,IAAY,KAAKA,IAAY,IAAIN,EAAiBlB,SAAS,IACvD4B,SACAV,EAAiBM,IAAY,CAAC;AAEpC,IAAKQ,MAEL3C,EAAOwC,SAAS;AAAA,MACd,GAAGtC;AAAAA,MACHQ,kBAAkB;AAAA,QAAE,CAACiC,EAAUN,GAAG,GAAG;AAAA,MAAA;AAAA,IAAK,CAC3C,GAEGtC,EAAa0C,WACU1C,EAAAA,EAAa0C,SAASE,EAAUN,GAAG;AAAA,EAC9D,GACA,CAEN,GACC,gBAAAxB,EAAA,cAAAU,GAAA,EAAQ,OAAM,mBAAsBC,GAAAA,EACnC,GAAA,gBAAAX,EAAA,cAACY,KACC,MAAK,KACL,SAAQ,SACR,OAAM,QACN,aAAa;AAAA,IAAEC,MAAMkB;AAAAA,IAAGhB,KAAK;AAAA,EAAc,GAC3C,SAAS,MAAM;AACb5B,IAAAA,EAAOwC,SAAS;AAAA,MAAE,GAAGtC;AAAAA,MAAeQ,kBAAkB,CAAA;AAAA,IAAC,CAAG;AAAA,EAAA,EAC1D,CAAA,CAEN,CACF,CACF,CACF;AAEJ;"}
@@ -1,18 +1,19 @@
1
1
  import e from "react";
2
2
  import { Stack as i } from "@telegraph/layout";
3
3
  import { Tooltip as a } from "@telegraph/tooltip";
4
- const l = {
4
+ import { sharedTooltipProps as l } from "./helpers.mjs";
5
+ const o = {
5
6
  blue: /* @__PURE__ */ e.createElement("svg", { width: "8", height: "8", viewBox: "0 0 8 8", "aria-hidden": !0 }, /* @__PURE__ */ e.createElement("circle", { cx: "4", cy: "4", r: "4", fill: "var(--tgph-blue-9)" })),
6
7
  yellow: /* @__PURE__ */ e.createElement("svg", { width: "8", height: "8", viewBox: "0 0 8 8", "aria-hidden": !0 }, /* @__PURE__ */ e.createElement("polygon", { points: "4,0.5 7.5,7.5 0.5,7.5", fill: "var(--tgph-yellow-9)" })),
7
8
  gray: /* @__PURE__ */ e.createElement("svg", { width: "8", height: "8", viewBox: "0 0 8 8", "aria-hidden": !0 }, /* @__PURE__ */ e.createElement("circle", { cx: "4", cy: "4", r: "2.75", fill: "none", stroke: "var(--tgph-gray-9)", strokeWidth: "2.5" })),
8
9
  red: /* @__PURE__ */ e.createElement("svg", { width: "8", height: "8", viewBox: "0 0 8 8", "aria-hidden": !0 }, /* @__PURE__ */ e.createElement("line", { x1: "1.5", y1: "1.5", x2: "6.5", y2: "6.5", stroke: "var(--tgph-red-9)", strokeWidth: "2", strokeLinecap: "round" }), /* @__PURE__ */ e.createElement("line", { x1: "6.5", y1: "1.5", x2: "1.5", y2: "6.5", stroke: "var(--tgph-red-9)", strokeWidth: "2", strokeLinecap: "round" }))
9
- }, h = ({
10
+ }, s = ({
10
11
  color: t,
11
12
  tooltip: r
12
- }) => /* @__PURE__ */ e.createElement(a, { label: r }, /* @__PURE__ */ e.createElement(i, { as: "span", align: "center", justify: "center", display: "inline-flex", p: "0_5", style: {
13
+ }) => /* @__PURE__ */ e.createElement(a, { label: r, ...l }, /* @__PURE__ */ e.createElement(i, { as: "span", align: "center", justify: "center", display: "inline-flex", p: "0_5", style: {
13
14
  flexShrink: 0
14
- } }, l[t]));
15
+ } }, o[t]));
15
16
  export {
16
- h as GuideAnnotatedStatusDot
17
+ s as GuideAnnotatedStatusDot
17
18
  };
18
19
  //# sourceMappingURL=GuideAnnotatedStatusDot.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"GuideAnnotatedStatusDot.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.tsx"],"sourcesContent":["import { Stack } from \"@telegraph/layout\";\nimport { Tooltip } from \"@telegraph/tooltip\";\n\nexport type StatusColor = \"blue\" | \"red\" | \"yellow\" | \"gray\";\n\n// Directly copied from the design prototype.\nconst STATUS_SHAPES: Record<StatusColor, React.ReactNode> = {\n blue: (\n <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" aria-hidden>\n <circle cx=\"4\" cy=\"4\" r=\"4\" fill=\"var(--tgph-blue-9)\" />\n </svg>\n ),\n yellow: (\n <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" aria-hidden>\n <polygon points=\"4,0.5 7.5,7.5 0.5,7.5\" fill=\"var(--tgph-yellow-9)\" />\n </svg>\n ),\n gray: (\n <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" aria-hidden>\n <circle\n cx=\"4\"\n cy=\"4\"\n r=\"2.75\"\n fill=\"none\"\n stroke=\"var(--tgph-gray-9)\"\n strokeWidth=\"2.5\"\n />\n </svg>\n ),\n red: (\n <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" aria-hidden>\n <line\n x1=\"1.5\"\n y1=\"1.5\"\n x2=\"6.5\"\n y2=\"6.5\"\n stroke=\"var(--tgph-red-9)\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n <line\n x1=\"6.5\"\n y1=\"1.5\"\n x2=\"1.5\"\n y2=\"6.5\"\n stroke=\"var(--tgph-red-9)\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n ),\n};\n\nexport const GuideAnnotatedStatusDot = ({\n color,\n tooltip,\n}: {\n color: StatusColor;\n tooltip: string;\n}) => {\n return (\n <Tooltip label={tooltip}>\n <Stack\n as=\"span\"\n align=\"center\"\n justify=\"center\"\n display=\"inline-flex\"\n p=\"0_5\"\n style={{ flexShrink: 0 }}\n >\n {STATUS_SHAPES[color]}\n </Stack>\n </Tooltip>\n );\n};\n"],"names":["STATUS_SHAPES","blue","React","yellow","gray","red","GuideAnnotatedStatusDot","color","tooltip","Tooltip","Stack","flexShrink"],"mappings":";;;AAMA,MAAMA,IAAsD;AAAA,EAC1DC,sCACG,OAAI,EAAA,OAAM,KAAI,QAAO,KAAI,SAAQ,WAAU,eAAW,MACpDC,gBAAAA,EAAA,cAAA,UAAA,EAAO,IAAG,KAAI,IAAG,KAAI,GAAE,KAAI,MAAK,qBAAoB,CAAA,CACvD;AAAA,EAEFC,QACGD,gBAAAA,EAAA,cAAA,OAAA,EAAI,OAAM,KAAI,QAAO,KAAI,SAAQ,WAAU,eAAW,MACpDA,gBAAAA,EAAA,cAAA,WAAA,EAAQ,QAAO,yBAAwB,MAAK,wBAAsB,CACrE;AAAA,EAEFE,MACGF,gBAAAA,EAAA,cAAA,OAAA,EAAI,OAAM,KAAI,QAAO,KAAI,SAAQ,WAAU,eAAW,GACrD,GAAAA,gBAAAA,EAAA,cAAC,YACC,IAAG,KACH,IAAG,KACH,GAAE,QACF,MAAK,QACL,QAAO,sBACP,aAAY,MAAK,CAAA,CAErB;AAAA,EAEFG,qCACG,OAAI,EAAA,OAAM,KAAI,QAAO,KAAI,SAAQ,WAAU,eAAW,MACpDH,gBAAAA,EAAA,cAAA,QAAA,EACC,IAAG,OACH,IAAG,OACH,IAAG,OACH,IAAG,OACH,QAAO,qBACP,aAAY,KACZ,eAAc,QAAO,CAAA,mCAEtB,QACC,EAAA,IAAG,OACH,IAAG,OACH,IAAG,OACH,IAAG,OACH,QAAO,qBACP,aAAY,KACZ,eAAc,SAAO,CAEzB;AAEJ,GAEaI,IAA0BA,CAAC;AAAA,EACtCC,OAAAA;AAAAA,EACAC,SAAAA;AAIF,sCAEKC,GAAQ,EAAA,OAAOD,KACdN,gBAAAA,EAAA,cAACQ,KACC,IAAG,QACH,OAAM,UACN,SAAQ,UACR,SAAQ,eACR,GAAE,OACF,OAAO;AAAA,EAAEC,YAAY;AAAA,KAEpBX,EAAcO,CAAK,CACtB,CACF;"}
1
+ {"version":3,"file":"GuideAnnotatedStatusDot.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.tsx"],"sourcesContent":["import { Stack } from \"@telegraph/layout\";\nimport { Tooltip } from \"@telegraph/tooltip\";\n\nimport { sharedTooltipProps } from \"./helpers\";\n\nexport type StatusColor = \"blue\" | \"red\" | \"yellow\" | \"gray\";\n\n// Directly copied from the design prototype.\nconst STATUS_SHAPES: Record<StatusColor, React.ReactNode> = {\n blue: (\n <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" aria-hidden>\n <circle cx=\"4\" cy=\"4\" r=\"4\" fill=\"var(--tgph-blue-9)\" />\n </svg>\n ),\n yellow: (\n <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" aria-hidden>\n <polygon points=\"4,0.5 7.5,7.5 0.5,7.5\" fill=\"var(--tgph-yellow-9)\" />\n </svg>\n ),\n gray: (\n <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" aria-hidden>\n <circle\n cx=\"4\"\n cy=\"4\"\n r=\"2.75\"\n fill=\"none\"\n stroke=\"var(--tgph-gray-9)\"\n strokeWidth=\"2.5\"\n />\n </svg>\n ),\n red: (\n <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" aria-hidden>\n <line\n x1=\"1.5\"\n y1=\"1.5\"\n x2=\"6.5\"\n y2=\"6.5\"\n stroke=\"var(--tgph-red-9)\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n <line\n x1=\"6.5\"\n y1=\"1.5\"\n x2=\"1.5\"\n y2=\"6.5\"\n stroke=\"var(--tgph-red-9)\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n ),\n};\n\nexport const GuideAnnotatedStatusDot = ({\n color,\n tooltip,\n}: {\n color: StatusColor;\n tooltip: string;\n}) => {\n return (\n <Tooltip label={tooltip} {...sharedTooltipProps}>\n <Stack\n as=\"span\"\n align=\"center\"\n justify=\"center\"\n display=\"inline-flex\"\n p=\"0_5\"\n style={{ flexShrink: 0 }}\n >\n {STATUS_SHAPES[color]}\n </Stack>\n </Tooltip>\n );\n};\n"],"names":["STATUS_SHAPES","blue","React","yellow","gray","red","GuideAnnotatedStatusDot","color","tooltip","Tooltip","sharedTooltipProps","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useStore as d } from "@knocklabs/react-core";
2
+ import { useGuideContext as d, useStore as s } from "@knocklabs/react-core";
3
3
  import { Box as o, Stack as t } from "@telegraph/layout";
4
- import { Toggle as m } from "@telegraph/toggle";
5
- import { Tooltip as i } from "@telegraph/tooltip";
4
+ import { Toggle as c } from "@telegraph/toggle";
5
+ import { Tooltip as l } from "@telegraph/tooltip";
6
6
  import { Text as a } from "@telegraph/typography";
7
- const f = () => {
7
+ import { sharedTooltipProps as m } from "./helpers.mjs";
8
+ const w = () => {
8
9
  const {
9
10
  client: r
10
- } = c(), {
11
- debugSettings: l
12
- } = d(r.store, (n) => ({
11
+ } = d(), {
12
+ debugSettings: i
13
+ } = s(r.store, (n) => ({
13
14
  debugSettings: n.debug || {}
14
15
  }));
15
- return /* @__PURE__ */ e.createElement(o, { py: "3", px: "3" }, /* @__PURE__ */ e.createElement(t, { direction: "column", gap: "1", width: "full" }, /* @__PURE__ */ e.createElement(a, { as: "span", size: "1", weight: "medium", display: "block" }, "Toolbar settings"), /* @__PURE__ */ e.createElement(t, { direction: "column", gap: "1" }, /* @__PURE__ */ e.createElement(t, { direction: "row", gap: "2", align: "center", h: "7" }, /* @__PURE__ */ e.createElement(i, { label: "Contain engagement actions to client side only" }, /* @__PURE__ */ e.createElement(o, { width: "36", mt: "1" }, /* @__PURE__ */ e.createElement(a, { as: "span", size: "1", weight: "medium", color: "gray", borderBottom: "px", borderStyle: "dashed" }, "Sandbox engagement"))), /* @__PURE__ */ e.createElement(m.Default, { size: "1", pt: "1_5", value: !!l.skipEngagementTracking, onValueChange: (n) => {
16
+ return /* @__PURE__ */ e.createElement(o, { py: "3", px: "3" }, /* @__PURE__ */ e.createElement(t, { direction: "column", gap: "1", width: "full" }, /* @__PURE__ */ e.createElement(a, { as: "span", size: "1", weight: "medium", display: "block" }, "Toolbar settings"), /* @__PURE__ */ e.createElement(t, { direction: "column", gap: "1" }, /* @__PURE__ */ e.createElement(t, { direction: "row", gap: "2", align: "center", h: "7" }, /* @__PURE__ */ e.createElement(l, { label: "When enabled, engagement actions are not sent to Knock.", ...m }, /* @__PURE__ */ e.createElement(o, { width: "36", mt: "1" }, /* @__PURE__ */ e.createElement(a, { as: "span", size: "1", weight: "medium", color: "gray", borderBottom: "px", borderStyle: "dashed" }, "Sandbox engagement"))), /* @__PURE__ */ e.createElement(c.Default, { size: "1", pt: "1_5", value: !!i.skipEngagementTracking, onValueChange: (n) => {
16
17
  r.setDebug({
17
- ...l,
18
+ ...i,
18
19
  skipEngagementTracking: n
19
20
  });
20
- } })), /* @__PURE__ */ e.createElement(t, { direction: "row", gap: "2", align: "center", h: "7" }, /* @__PURE__ */ e.createElement(i, { label: "Ignore throttle and show next guide immediately" }, /* @__PURE__ */ e.createElement(o, { width: "36", mt: "1" }, /* @__PURE__ */ e.createElement(a, { as: "span", size: "1", weight: "medium", color: "gray", borderBottom: "px", borderStyle: "dashed" }, "Ignore throttle"))), /* @__PURE__ */ e.createElement(m.Default, { size: "1", pt: "1_5", value: !!l.ignoreDisplayInterval, onValueChange: (n) => {
21
+ } })), /* @__PURE__ */ e.createElement(t, { direction: "row", gap: "2", align: "center", h: "7" }, /* @__PURE__ */ e.createElement(l, { label: "Ignore throttle and show next guide immediately", ...m }, /* @__PURE__ */ e.createElement(o, { width: "36", mt: "1" }, /* @__PURE__ */ e.createElement(a, { as: "span", size: "1", weight: "medium", color: "gray", borderBottom: "px", borderStyle: "dashed" }, "Ignore throttle"))), /* @__PURE__ */ e.createElement(c.Default, { size: "1", pt: "1_5", value: !!i.ignoreDisplayInterval, onValueChange: (n) => {
21
22
  r.setDebug({
22
- ...l,
23
+ ...i,
23
24
  ignoreDisplayInterval: n
24
25
  });
25
- } })))), /* @__PURE__ */ e.createElement(t, { direction: "column", gap: "1", width: "full" }, /* @__PURE__ */ e.createElement(i, { label: /* @__PURE__ */ e.createElement(a, { as: "span", size: "1" }, "The tenant and data payload passed to the guide client that are used for targeting", /* @__PURE__ */ e.createElement("br", null), "(via the targetParams prop to KnockGuideProvider)"), delayDuration: 500 }, /* @__PURE__ */ e.createElement(a, { as: "span", size: "1", weight: "medium", borderBottom: "px", borderStyle: "dashed", mt: "4", style: {
26
+ } })))), /* @__PURE__ */ e.createElement(t, { direction: "column", gap: "1", width: "full" }, /* @__PURE__ */ e.createElement(l, { label: /* @__PURE__ */ e.createElement(a, { as: "span", size: "1" }, "The tenant and data payload passed to KnockGuideProvider. Available for use in runtime conditions."), ...m }, /* @__PURE__ */ e.createElement(a, { as: "span", size: "1", weight: "medium", borderBottom: "px", borderStyle: "dashed", mt: "4", style: {
26
27
  whiteSpace: "nowrap",
27
28
  width: "fit-content"
28
29
  } }, "Target params")), /* @__PURE__ */ e.createElement(t, { direction: "column", gap: "2" }, /* @__PURE__ */ e.createElement(t, { direction: "row", gap: "2", align: "center" }, /* @__PURE__ */ e.createElement(a, { as: "span", size: "1", weight: "medium", color: "gray", width: "36", mt: "1" }, "Tenant"), /* @__PURE__ */ e.createElement(o, { rounded: "2", overflow: "auto", backgroundColor: "surface-2", border: "px", p: "1", style: {
@@ -42,6 +43,6 @@ const f = () => {
42
43
  } }, /* @__PURE__ */ e.createElement("code", null, r.targetParams.data ? JSON.stringify(r.targetParams.data, null, 2) : "-")))))));
43
44
  };
44
45
  export {
45
- f as GuideContextDetails
46
+ w as GuideContextDetails
46
47
  };
47
48
  //# sourceMappingURL=GuideContextDetails.mjs.map