@knocklabs/react 0.11.3 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/index.css +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/KnockButton.js +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/KnockButton.js.map +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/DragHandle.js +2 -0
- package/dist/cjs/modules/guide/components/Toolbar/V2/DragHandle.js.map +1 -0
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideContextDetails.js +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideContextDetails.js.map +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideHoverCard.js +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideHoverCard.js.map +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRow.js +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRow.js.map +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/V2.js +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/V2.js.map +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/useDraggable.js +2 -0
- package/dist/cjs/modules/guide/components/Toolbar/V2/useDraggable.js.map +1 -0
- package/dist/cjs/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.js +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.js.map +1 -1
- package/dist/esm/index.mjs +98 -97
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/KnockButton.mjs +14 -8
- package/dist/esm/modules/guide/components/Toolbar/KnockButton.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/DragHandle.mjs +20 -0
- package/dist/esm/modules/guide/components/Toolbar/V2/DragHandle.mjs.map +1 -0
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideContextDetails.mjs +26 -11
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideContextDetails.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideHoverCard.mjs +46 -16
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideHoverCard.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideRow.mjs +48 -30
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideRow.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs +53 -36
- package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/useDraggable.mjs +74 -0
- package/dist/esm/modules/guide/components/Toolbar/V2/useDraggable.mjs.map +1 -0
- package/dist/esm/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.mjs +73 -88
- package/dist/esm/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.mjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/types/modules/guide/components/Toolbar/KnockButton.d.ts +2 -1
- package/dist/types/modules/guide/components/Toolbar/KnockButton.d.ts.map +1 -1
- package/dist/types/modules/guide/components/Toolbar/V2/DragHandle.d.ts +9 -0
- package/dist/types/modules/guide/components/Toolbar/V2/DragHandle.d.ts.map +1 -0
- package/dist/types/modules/guide/components/Toolbar/V2/GuideContextDetails.d.ts.map +1 -1
- package/dist/types/modules/guide/components/Toolbar/V2/GuideHoverCard.d.ts.map +1 -1
- package/dist/types/modules/guide/components/Toolbar/V2/GuideRow.d.ts.map +1 -1
- package/dist/types/modules/guide/components/Toolbar/V2/V2.d.ts.map +1 -1
- package/dist/types/modules/guide/components/Toolbar/V2/useDraggable.d.ts +26 -0
- package/dist/types/modules/guide/components/Toolbar/V2/useDraggable.d.ts.map +1 -0
- package/dist/types/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.d.ts.map +1 -1
- package/package.json +11 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("@knocklabs/react-core"),f=require("@telegraph/button"),n=require("@telegraph/layout"),E=require("@telegraph/typography"),p=require("lucide-react"),x=require("react"),h=require("../KnockButton.js"),q=require("../shared.js");;/* empty css */const g=require("./DragHandle.js"),C=require("./GuideContextDetails.js"),w=require("./GuideRow.js"),G=require("./GuidesListDisplaySelect.js"),S=require("./helpers.js"),R=require("./useDraggable.js"),k=require("./useInspectGuideClientStore.js"),B=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},e=B(x),I=({guides:t,displayOption:i})=>t.map((l,a)=>{const{isEligible:o,isQualified:s,selectable:u}=l.annotation,r=o&&s,c=r&&u.status==="returned";return i==="only-displaying"&&!c||i==="only-displayable"&&!r||i==="all-eligible"&&!o?null:e.default.createElement(w.GuideRow,{key:l.key,guide:l,orderIndex:a})}),L=()=>{const{client:t}=D.useGuideContext(),[i,l]=e.default.useState("only-displayable"),[a,o]=e.default.useState(S.detectToolbarParam()),[s,u]=e.default.useState(!0);e.default.useEffect(()=>{if(a)return t.setDebug(),()=>{t.unsetDebug()}},[a,t]);const r=e.default.useRef(null),{position:c,isDragging:m,handlePointerDown:b}=R.useDraggable({elementRef:r,reclampDeps:[s],rightPadding:g.DRAG_HANDLE_OVERHANG,initialPosition:{top:16,right:16}}),d=k.useInspectGuideClientStore();return d?e.default.createElement(n.Box,{tgphRef:r,position:"fixed",style:{top:c.top+"px",right:c.right+"px",zIndex:q.TOOLBAR_Z_INDEX}},e.default.createElement(g.DragHandle,{onPointerDown:b,isDragging:m}),s?e.default.createElement(h.KnockButton,{onClick:()=>u(!1),positioned:!1}):e.default.createElement(n.Stack,{direction:"column",backgroundColor:"surface-2",shadow:"2",rounded:"3",border:"px",overflow:"hidden",style:{width:"400px"}},e.default.createElement(n.Stack,{w:"full",p:"2",justify:"space-between",direction:"row",style:{boxSizing:"border-box"}},e.default.createElement(n.Box,{style:{width:"220px"}},e.default.createElement(G.GuidesListDisplaySelect,{value:i,onChange:y=>l(y)})),e.default.createElement(n.Stack,{gap:"2"},e.default.createElement(f.Button,{onClick:()=>o(!1),size:"1",variant:"soft",trailingIcon:{icon:p.Undo2,"aria-hidden":!0}},"Exit"),e.default.createElement(f.Button,{onClick:()=>u(!0),size:"1",variant:"soft",leadingIcon:{icon:p.Minimize2,alt:"Collapse guide toolbar"}}))),e.default.createElement(n.Box,{w:"full"},e.default.createElement(C.GuideContextDetails,null),d.error&&e.default.createElement(n.Box,{px:"2",pb:"1"},e.default.createElement(E.Text,{as:"span",size:"0",weight:"medium",color:"red"},d.error)),e.default.createElement(I,{guides:d.guides,displayOption:i})))):null};exports.V2=L;
|
|
2
2
|
//# sourceMappingURL=V2.js.map
|
|
@@ -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 { Box, Stack } from \"@telegraph/layout\";\nimport { Minimize2, Undo2 } from \"lucide-react\";\nimport React from \"react\";\n\nimport { KnockButton } from \"../KnockButton\";\nimport { TOOLBAR_Z_INDEX } from \"../shared\";\nimport \"../styles.css\";\n\nimport { GuideContextDetails } from \"./GuideContextDetails\";\nimport { GuideRow } from \"./GuideRow\";\nimport {\n DisplayOption,\n GuidesListDisplaySelect,\n} from \"./GuidesListDisplaySelect\";\nimport { detectToolbarParam } from \"./helpers\";\nimport {\n InspectionResult,\n useInspectGuideClientStore,\n} from \"./useInspectGuideClientStore\";\n\nconst GuidesList = ({\n guides,\n displayOption,\n}: {\n guides: InspectionResult[\"guides\"];\n displayOption: DisplayOption;\n}) => {\n return guides.map((guide, idx) => {\n const { isEligible, isQualified, selectable } = guide.annotation;\n const isDisplayable = isEligible && isQualified;\n const isDisplaying = isDisplayable && selectable.status === \"returned\";\n\n if (displayOption === \"only-displaying\" && !isDisplaying) {\n return null;\n }\n if (displayOption === \"only-displayable\" && !isDisplayable) {\n return null;\n }\n if (displayOption === \"all-eligible\" && !isEligible) {\n return null;\n }\n\n return <GuideRow key={guide.key} guide={guide} orderIndex={idx} />;\n });\n};\n\nexport const V2 = () => {\n const { client } = useGuideContext();\n\n const [guidesListDisplayOption, setGuidesListDisplayOption] =\n React.useState<DisplayOption>(\"only-displayable\");\n\n const [isVisible, setIsVisible] = React.useState(detectToolbarParam());\n const [isCollapsed, setIsCollapsed] = React.useState(true);\n\n React.useEffect(() => {\n if (!isVisible) {\n return;\n }\n\n client.setDebug();\n\n return () => {\n client.unsetDebug();\n };\n }, [isVisible, client]);\n\n const result = useInspectGuideClientStore();\n if (!result) {\n return null;\n }\n\n return (\n <Box
|
|
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 { Box, Stack } from \"@telegraph/layout\";\nimport { Text } from \"@telegraph/typography\";\nimport { Minimize2, Undo2 } from \"lucide-react\";\nimport React from \"react\";\n\nimport { KnockButton } from \"../KnockButton\";\nimport { TOOLBAR_Z_INDEX } from \"../shared\";\nimport \"../styles.css\";\n\nimport { DRAG_HANDLE_OVERHANG, DragHandle } from \"./DragHandle\";\nimport { GuideContextDetails } from \"./GuideContextDetails\";\nimport { GuideRow } from \"./GuideRow\";\nimport {\n DisplayOption,\n GuidesListDisplaySelect,\n} from \"./GuidesListDisplaySelect\";\nimport { detectToolbarParam } from \"./helpers\";\nimport { useDraggable } from \"./useDraggable\";\nimport {\n InspectionResult,\n useInspectGuideClientStore,\n} from \"./useInspectGuideClientStore\";\n\nconst GuidesList = ({\n guides,\n displayOption,\n}: {\n guides: InspectionResult[\"guides\"];\n displayOption: DisplayOption;\n}) => {\n return guides.map((guide, idx) => {\n const { isEligible, isQualified, selectable } = guide.annotation;\n const isDisplayable = isEligible && isQualified;\n const isDisplaying = isDisplayable && selectable.status === \"returned\";\n\n if (displayOption === \"only-displaying\" && !isDisplaying) {\n return null;\n }\n if (displayOption === \"only-displayable\" && !isDisplayable) {\n return null;\n }\n if (displayOption === \"all-eligible\" && !isEligible) {\n return null;\n }\n\n return <GuideRow key={guide.key} guide={guide} orderIndex={idx} />;\n });\n};\n\nexport const V2 = () => {\n const { client } = useGuideContext();\n\n const [guidesListDisplayOption, setGuidesListDisplayOption] =\n React.useState<DisplayOption>(\"only-displayable\");\n\n const [isVisible, setIsVisible] = React.useState(detectToolbarParam());\n const [isCollapsed, setIsCollapsed] = React.useState(true);\n\n React.useEffect(() => {\n if (!isVisible) {\n return;\n }\n\n client.setDebug();\n\n return () => {\n client.unsetDebug();\n };\n }, [isVisible, client]);\n\n const containerRef = React.useRef<HTMLDivElement>(null);\n const { position, isDragging, handlePointerDown } = useDraggable({\n elementRef: containerRef,\n reclampDeps: [isCollapsed],\n rightPadding: DRAG_HANDLE_OVERHANG,\n initialPosition: { top: 16, right: 16 },\n });\n\n const result = useInspectGuideClientStore();\n if (!result) {\n return null;\n }\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 <DragHandle onPointerDown={handlePointerDown} isDragging={isDragging} />\n {isCollapsed ? (\n <KnockButton onClick={() => setIsCollapsed(false)} positioned={false} />\n ) : (\n <Stack\n direction=\"column\"\n backgroundColor=\"surface-2\"\n shadow=\"2\"\n rounded=\"3\"\n border=\"px\"\n overflow=\"hidden\"\n style={{ width: \"400px\" }}\n >\n <Stack\n w=\"full\"\n p=\"2\"\n justify=\"space-between\"\n direction=\"row\"\n style={{ boxSizing: \"border-box\" }}\n >\n <Box style={{ width: \"220px\" }}>\n <GuidesListDisplaySelect\n value={guidesListDisplayOption}\n onChange={(opt) => setGuidesListDisplayOption(opt)}\n />\n </Box>\n\n <Stack gap=\"2\">\n <Button\n onClick={() => setIsVisible(false)}\n size=\"1\"\n variant=\"soft\"\n trailingIcon={{ icon: Undo2, \"aria-hidden\": true }}\n >\n Exit\n </Button>\n <Button\n onClick={() => setIsCollapsed(true)}\n size=\"1\"\n variant=\"soft\"\n leadingIcon={{ icon: Minimize2, alt: \"Collapse guide toolbar\" }}\n />\n </Stack>\n </Stack>\n\n <Box w=\"full\">\n <GuideContextDetails />\n {result.error && (\n <Box px=\"2\" pb=\"1\">\n <Text as=\"span\" size=\"0\" weight=\"medium\" color=\"red\">\n {result.error}\n </Text>\n </Box>\n )}\n <GuidesList\n guides={result.guides}\n displayOption={guidesListDisplayOption}\n />\n </Box>\n </Stack>\n )}\n </Box>\n );\n};\n"],"names":["GuidesList","guides","displayOption","map","guide","idx","isEligible","isQualified","selectable","annotation","isDisplayable","isDisplaying","status","GuideRow","key","V2","client","useGuideContext","guidesListDisplayOption","setGuidesListDisplayOption","React","useState","isVisible","setIsVisible","detectToolbarParam","isCollapsed","setIsCollapsed","useEffect","setDebug","unsetDebug","containerRef","useRef","position","isDragging","handlePointerDown","useDraggable","elementRef","reclampDeps","rightPadding","DRAG_HANDLE_OVERHANG","initialPosition","top","right","result","useInspectGuideClientStore","Box","zIndex","TOOLBAR_Z_INDEX","DragHandle","KnockButton","Stack","width","boxSizing","GuidesListDisplaySelect","opt","Button","icon","Undo2","Minimize2","alt","GuideContextDetails","error","Text"],"mappings":"+oBAyBMA,EAAaA,CAAC,CAClBC,OAAAA,EACAC,cAAAA,CAIF,IACSD,EAAOE,IAAI,CAACC,EAAOC,IAAQ,CAC1B,KAAA,CAAEC,WAAAA,EAAYC,YAAAA,EAAaC,WAAAA,GAAeJ,EAAMK,WAChDC,EAAgBJ,GAAcC,EAC9BI,EAAeD,GAAiBF,EAAWI,SAAW,WAQxDV,OANAA,IAAkB,mBAAqB,CAACS,GAGxCT,IAAkB,oBAAsB,CAACQ,GAGzC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F=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},n=F(C),S={top:16,right:16};function R(e,u,h,o=0){const r=window.innerWidth,f=window.innerHeight,v=u+o,d=r-e.right-u,p=Math.max(0,Math.min(d,r-v)),i=Math.max(0,Math.min(e.top,f-h)),s=r-p-u;return{top:i,right:s}}function I({elementRef:e,initialPosition:u=S,reclampDeps:h=[],rightPadding:o=0}){const[r,f]=n.default.useState(u),[v,d]=n.default.useState(!1),p=n.default.useRef(r);p.current=r;const i=n.default.useRef({x:0,y:0}),s=n.default.useRef({top:0,right:0}),c=n.default.useRef(null),g=n.default.useRef(!1),a=n.default.useRef(null),w=n.default.useCallback(()=>{const t=e.current;if(!t)return;const l=t.getBoundingClientRect();f(m=>R(m,l.width,l.height,o))},[e,o]),y=n.default.useCallback(t=>{t.preventDefault(),i.current={x:t.clientX,y:t.clientY},s.current={...p.current},g.current=!0,d(!0);const l=E=>{g.current&&c.current===null&&(c.current=requestAnimationFrame(()=>{if(c.current=null,!g.current)return;const L=E.clientX-i.current.x,x=E.clientY-i.current.y,M={top:s.current.top+x,right:s.current.right-L},P=e.current;if(!P)return;const b=P.getBoundingClientRect(),A=R(M,b.width,b.height,o);f(A)}))},m=()=>{g.current=!1,d(!1),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null),document.removeEventListener("pointermove",l),document.removeEventListener("pointerup",D),a.current=null},D=()=>m();document.addEventListener("pointermove",l),document.addEventListener("pointerup",D),a.current=m},[e,o]);return n.default.useEffect(()=>()=>{var t;(t=a.current)==null||t.call(a)},[]),n.default.useEffect(()=>{const t=()=>w();return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[w]),n.default.useEffect(()=>{const t=requestAnimationFrame(()=>w());return()=>cancelAnimationFrame(t)},h),{position:r,isDragging:v,handlePointerDown:y}}exports.clampPosition=R;exports.useDraggable=I;
|
|
2
|
+
//# sourceMappingURL=useDraggable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDraggable.js","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/useDraggable.ts"],"sourcesContent":["import React from \"react\";\n\n// NOTE: This hook was generated entirely with Claude then lightly touched up,\n// and the behavior works correctly from testing it manually in the browser.\n\ntype Position = { top: number; right: number };\n\ntype UseDraggableOptions = {\n elementRef: React.RefObject<HTMLElement | null>;\n initialPosition?: Position;\n reclampDeps?: React.DependencyList;\n /** Extra space to reserve beyond the element's right edge (px). */\n rightPadding?: number;\n};\n\ntype UseDraggableReturn = {\n position: Position;\n isDragging: boolean;\n handlePointerDown: (e: React.PointerEvent) => void;\n};\n\nconst DEFAULT_POSITION: Position = { top: 16, right: 16 };\n\n/**\n * @param rightPadding Extra space to reserve on the right edge (e.g. for a\n * drag handle that protrudes beyond the element). The element's left edge\n * is clamped so that `elementWidth + rightPadding` stays within the viewport.\n */\nexport function clampPosition(\n pos: Position,\n elementWidth: number,\n elementHeight: number,\n rightPadding = 0,\n): Position {\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n const totalWidth = elementWidth + rightPadding;\n const left = viewportWidth - pos.right - elementWidth;\n const clampedLeft = Math.max(0, Math.min(left, viewportWidth - totalWidth));\n const clampedTop = Math.max(\n 0,\n Math.min(pos.top, viewportHeight - elementHeight),\n );\n const clampedRight = viewportWidth - clampedLeft - elementWidth;\n\n return { top: clampedTop, right: clampedRight };\n}\n\nexport function useDraggable({\n elementRef,\n initialPosition = DEFAULT_POSITION,\n reclampDeps = [],\n rightPadding = 0,\n}: UseDraggableOptions): UseDraggableReturn {\n const [position, setPosition] = React.useState<Position>(initialPosition);\n const [isDragging, setIsDragging] = React.useState(false);\n\n const positionRef = React.useRef(position);\n positionRef.current = position;\n\n const startPointerRef = React.useRef({ x: 0, y: 0 });\n const startPositionRef = React.useRef<Position>({ top: 0, right: 0 });\n const rafIdRef = React.useRef<number | null>(null);\n const isDraggingRef = React.useRef(false);\n const cleanupListenersRef = React.useRef<(() => void) | null>(null);\n\n const reclamp = React.useCallback(() => {\n const el = elementRef.current;\n if (!el) return;\n const rect = el.getBoundingClientRect();\n setPosition((prev) =>\n clampPosition(prev, rect.width, rect.height, rightPadding),\n );\n }, [elementRef, rightPadding]);\n\n // Stable pointerdown handler\n const handlePointerDown = React.useCallback(\n (e: React.PointerEvent) => {\n e.preventDefault();\n startPointerRef.current = { x: e.clientX, y: e.clientY };\n startPositionRef.current = { ...positionRef.current };\n isDraggingRef.current = true;\n setIsDragging(true);\n\n const onPointerMove = (moveEvent: PointerEvent) => {\n if (!isDraggingRef.current) return;\n\n if (rafIdRef.current !== null) return;\n\n rafIdRef.current = requestAnimationFrame(() => {\n rafIdRef.current = null;\n if (!isDraggingRef.current) return;\n\n const dx = moveEvent.clientX - startPointerRef.current.x;\n const dy = moveEvent.clientY - startPointerRef.current.y;\n\n const newPos: Position = {\n top: startPositionRef.current.top + dy,\n right: startPositionRef.current.right - dx,\n };\n\n const el = elementRef.current;\n if (!el) return;\n const rect = el.getBoundingClientRect();\n const clamped = clampPosition(\n newPos,\n rect.width,\n rect.height,\n rightPadding,\n );\n setPosition(clamped);\n });\n };\n\n const cleanup = () => {\n isDraggingRef.current = false;\n setIsDragging(false);\n if (rafIdRef.current !== null) {\n cancelAnimationFrame(rafIdRef.current);\n rafIdRef.current = null;\n }\n document.removeEventListener(\"pointermove\", onPointerMove);\n document.removeEventListener(\"pointerup\", onPointerUp);\n cleanupListenersRef.current = null;\n };\n\n const onPointerUp = () => cleanup();\n\n document.addEventListener(\"pointermove\", onPointerMove);\n document.addEventListener(\"pointerup\", onPointerUp);\n cleanupListenersRef.current = cleanup;\n },\n [elementRef, rightPadding],\n );\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n cleanupListenersRef.current?.();\n };\n }, []);\n\n // Re-clamp on window resize\n React.useEffect(() => {\n const onResize = () => reclamp();\n window.addEventListener(\"resize\", onResize);\n return () => window.removeEventListener(\"resize\", onResize);\n }, [reclamp]);\n\n // Re-clamp when deps change (e.g. collapse toggle)\n React.useEffect(() => {\n const id = requestAnimationFrame(() => reclamp());\n return () => cancelAnimationFrame(id);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, reclampDeps);\n\n return { position, isDragging, handlePointerDown };\n}\n"],"names":["DEFAULT_POSITION","top","right","clampPosition","pos","elementWidth","elementHeight","rightPadding","viewportWidth","window","innerWidth","viewportHeight","innerHeight","totalWidth","left","clampedLeft","Math","max","min","clampedTop","clampedRight","useDraggable","elementRef","initialPosition","reclampDeps","position","setPosition","React","useState","isDragging","setIsDragging","positionRef","useRef","current","startPointerRef","x","y","startPositionRef","rafIdRef","isDraggingRef","cleanupListenersRef","reclamp","useCallback","el","rect","getBoundingClientRect","prev","width","height","handlePointerDown","e","preventDefault","clientX","clientY","onPointerMove","moveEvent","requestAnimationFrame","dx","dy","newPos","clamped","cleanup","cancelAnimationFrame","removeEventListener","onPointerUp","addEventListener","useEffect","onResize","id"],"mappings":"wKAqBMA,EAA6B,CAAEC,IAAK,GAAIC,MAAO,EAAG,EAOjD,SAASC,EACdC,EACAC,EACAC,EACAC,EAAe,EACL,CACV,MAAMC,EAAgBC,OAAOC,WACvBC,EAAiBF,OAAOG,YAExBC,EAAaR,EAAeE,EAC5BO,EAAON,EAAgBJ,EAAIF,MAAQG,EACnCU,EAAcC,KAAKC,IAAI,EAAGD,KAAKE,IAAIJ,EAAMN,EAAgBK,CAAU,CAAC,EACpEM,EAAaH,KAAKC,IACtB,EACAD,KAAKE,IAAId,EAAIH,IAAKU,EAAiBL,CAAa,CAClD,EACMc,EAAeZ,EAAgBO,EAAcV,EAE5C,MAAA,CAAEJ,IAAKkB,EAAYjB,MAAOkB,CAAa,CAChD,CAEO,SAASC,EAAa,CAC3BC,WAAAA,EACAC,gBAAAA,EAAkBvB,EAClBwB,YAAAA,EAAc,CAAE,EAChBjB,aAAAA,EAAe,CACI,EAAuB,CAC1C,KAAM,CAACkB,EAAUC,CAAW,EAAIC,EAAAA,QAAMC,SAAmBL,CAAe,EAClE,CAACM,EAAYC,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EAEMd,EAAKrB,EAAWW,QACtB,GAAI,CAACU,EAAI,OACHC,MAAAA,EAAOD,EAAGE,sBAAsB,EAChCe,EAAUzD,EACdwD,EACAf,EAAKG,MACLH,EAAKI,OACLzC,CACF,EACAmB,EAAYkC,CAAO,CAAA,CACpB,EACH,EAEMC,EAAUA,IAAM,CACpBtB,EAAcN,QAAU,GACxBH,EAAc,EAAK,EACfQ,EAASL,UAAY,OACvB6B,qBAAqBxB,EAASL,OAAO,EACrCK,EAASL,QAAU,MAEZ8B,SAAAA,oBAAoB,cAAeT,CAAa,EAChDS,SAAAA,oBAAoB,YAAaC,CAAW,EACrDxB,EAAoBP,QAAU,IAChC,EAEM+B,EAAcA,IAAMH,EAAQ,EAEzBI,SAAAA,iBAAiB,cAAeX,CAAa,EAC7CW,SAAAA,iBAAiB,YAAaD,CAAW,EAClDxB,EAAoBP,QAAU4B,CAAAA,EAEhC,CAACvC,EAAYf,CAAY,CAC3B,EAGAoB,OAAAA,EAAAA,QAAMuC,UAAU,IACP,IAAM,QACX1B,EAAAA,EAAoBP,UAApBO,MAAAA,EAAAA,KAAAA,EACF,EACC,EAAE,EAGLb,EAAAA,QAAMuC,UAAU,IAAM,CACdC,MAAAA,EAAWA,IAAM1B,EAAQ,EACxBwB,cAAAA,iBAAiB,SAAUE,CAAQ,EACnC,IAAM1D,OAAOsD,oBAAoB,SAAUI,CAAQ,CAAA,EACzD,CAAC1B,CAAO,CAAC,EAGZd,EAAAA,QAAMuC,UAAU,IAAM,CACpB,MAAME,EAAKZ,sBAAsB,IAAMf,GAAS,EACzC,MAAA,IAAMqB,qBAAqBM,CAAE,GAEnC5C,CAAW,EAEP,CAAEC,SAAAA,EAAUI,WAAAA,EAAYoB,kBAAAA,CAAkB,CACnD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@knocklabs/client"),p=require("@knocklabs/react-core"),b=e=>e.reduce((
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@knocklabs/client"),p=require("@knocklabs/react-core"),b=e=>e.reduce((t,s)=>({...t,[s.key]:s}),{}),g=(e,t,s,r)=>{var u,n,o,l,a,c,d,f;const i=!!((l=(o=(n=(u=r.key)==null?void 0:u.one)==null?void 0:n.metadata)==null?void 0:o.opts)!=null&&l.includeThrottled)||!!((f=(d=(c=(a=r.key)==null?void 0:a.all)==null?void 0:c.metadata)==null?void 0:d.opts)!=null&&f.includeThrottled);return e.bypass_global_group_limit?"returned":e.key===s.resolved?t.throttled&&!i?"throttled":"returned":"queried"},v=(e,t,s,r)=>{var n,o,l,a;const i=!!((a=(l=(o=(n=r.type)==null?void 0:n.one)==null?void 0:o.metadata)==null?void 0:l.opts)!=null&&a.includeThrottled),u=r.type.one;if(u.size===0)return"queried";if(e.bypass_global_group_limit){const d=[...u.values()][0];return e.key!==d.key?"queried":"returned"}return e.key===s.resolved?t.throttled&&!i?"throttled":"returned":"queried"},h=(e,t,s,r)=>{var a,c,d,f;const i=r.type.all;if(i.size===0)return"queried";const u=[...i.values()],n=u[0],o=b(u);return(f=(d=(c=(a=r.type)==null?void 0:a.all)==null?void 0:c.metadata)==null?void 0:d.opts)!=null&&f.includeThrottled?o[e.key]?"returned":"queried":(n.bypass_global_group_limit||n.key===s.resolved)&&o[e.key]?t.throttled?e.bypass_global_group_limit?"returned":"throttled":"returned":"queried"},S=(e,t,s,r)=>{var i,u;if(r.key)return g(e,t,s,r);if((i=r.type)!=null&&i.all)return h(e,t,s,r);if((u=r.type)!=null&&u.one)return v(e,t,s,r)},G=(e,t,s)=>{if(!s||s.status==="open")return{status:void 0};const r={key:(s.results.key||{})[e.key],type:(s.results.type||{})[e.type]};if(!!!(r.key||r.type))return{status:void 0};const u=S(e,t,s,r);return u?{status:u,query:r}:{status:void 0}},T=(e,t)=>{const s={};return((t==null?void 0:t.reason)==="not_in_target_audience"||(t==null?void 0:t.reason)==="target_conditions_not_met")&&(s.targetable={status:!1,reason:t.reason,message:t.message}),((t==null?void 0:t.reason)==="marked_as_archived"||(e.steps||[]).every(r=>!!r.message.archived_at))&&(s.archived={status:!0}),(t==null?void 0:t.reason)==="guide_not_active"&&(s.active={status:!1}),s},I=({active:e,targetable:t,archived:s})=>!(!e.status||!t.status||s.status),_=({activatable:e,selectable:t})=>!(!e.status||!t.status),q=(e,t,s)=>{const{ineligibleGuides:r,location:i}=t,u=r[e.key],n=T(e,u),o={active:(n==null?void 0:n.active)||{status:!0},targetable:(n==null?void 0:n.targetable)||{status:!0},archived:(n==null?void 0:n.archived)||{status:!1},activatable:{status:y.checkActivatable(e,i)},selectable:G(e,t,s)},l={...o,isEligible:I(o),isQualified:_(o)};return{...e,annotation:l}},w=e=>({__typename:"UnknownGuide",key:e,active:!1,bypass_global_group_limit:!1,annotation:{isEligible:!1,isQualified:!1,selectable:{status:void 0}}}),B=()=>{var u;const{client:e}=p.useGuideContext(),t=p.useStore(e.store,n=>{const o=y.checkStateIfThrottled(n);return{location:n.location,guides:n.guides,guideGroups:n.guideGroups,ineligibleGuides:n.ineligibleGuides,debug:n.debug,counter:n.counter,throttled:o}});if(!((u=t.debug)!=null&&u.debugging))return;const s=t.guideGroups[0];if(!s)return{error:"no_guide_group",guides:[]};const r=e.getStage();return{guides:s.display_sequence.map(n=>{const o=t.guides[n];return o?q(o,t,r):w(n)})}},U=e=>typeof e=="object"&&e!==null&&"__typename"in e&&e.__typename==="UnknownGuide";exports.isUnknownGuide=U;exports.resolveIsQualified=_;exports.useInspectGuideClientStore=B;
|
|
2
2
|
//# sourceMappingURL=useInspectGuideClientStore.js.map
|
|
@@ -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\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\ntype 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 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 UnknownGuide = {\n __typename: \"UnknownGuide\";\n key: KnockGuide[\"key\"];\n active: false;\n bypass_global_group_limit: false;\n annotation: {\n isEligible: false;\n isQualified: false;\n selectable: {\n status: undefined;\n };\n };\n};\n\nexport type InspectionResult = {\n guides: (AnnotatedGuide | UnknownGuide)[];\n error?: \"no_guide_group\";\n};\n\ntype StoreStateSnapshot = Pick<\n KnockGuideClientStoreState,\n | \"location\"\n | \"guides\"\n | \"guideGroups\"\n | \"ineligibleGuides\"\n | \"debug\"\n | \"counter\"\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 marker: KnockGuideIneligibilityMarker,\n): Partial<AnnotatedStatuses> | undefined => {\n switch (marker.reason) {\n case \"not_in_target_audience\":\n case \"target_conditions_not_met\":\n return {\n targetable: {\n status: false,\n reason: marker.reason,\n message: marker.message,\n },\n };\n\n case \"marked_as_archived\":\n return {\n archived: {\n status: true,\n },\n };\n\n case \"guide_not_active\":\n return {\n active: {\n status: false,\n },\n };\n\n default:\n return undefined;\n }\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 snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage | undefined,\n): AnnotatedGuide => {\n const { ineligibleGuides, location } = snapshot;\n const marker = ineligibleGuides[guide.key];\n const ineligiblity = marker ? toIneligibilityStatus(marker) : undefined;\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 annotation,\n };\n};\n\nconst newUnknownGuide = (key: KnockGuide[\"key\"]) =>\n ({\n __typename: \"UnknownGuide\",\n key,\n active: false,\n bypass_global_group_limit: false,\n annotation: {\n isEligible: false,\n isQualified: false,\n selectable: {\n status: undefined,\n },\n },\n }) as UnknownGuide;\n\nexport const useInspectGuideClientStore = (): 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 throttled,\n };\n });\n\n // Not in debugging session, so noop.\n if (!snapshot.debug?.debugging) {\n return undefined;\n }\n\n // Only for completeness, as there should always be a default group so this\n // should never happen.\n const defaultGroup = snapshot.guideGroups[0];\n if (!defaultGroup) {\n return {\n error: \"no_guide_group\",\n guides: [],\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) => {\n const guide = snapshot.guides[guideKey];\n if (!guide) {\n return newUnknownGuide(guideKey);\n }\n\n return annotateGuide(guide, snapshot, groupStage);\n });\n\n return {\n guides: orderedGuides,\n };\n};\n\nexport const isUnknownGuide = (input: unknown): input is UnknownGuide =>\n typeof input === \"object\" &&\n input !== null &&\n \"__typename\" in input &&\n (input as UnknownGuide).__typename === \"UnknownGuide\";\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","reason","targetable","message","archived","active","resolveIsEligible","resolveIsQualified","activatable","selectable","annotateGuide","ineligibleGuides","location","ineligiblity","statuses","checkActivatable","annotation","isEligible","isQualified","newUnknownGuide","__typename","useInspectGuideClientStore","client","useGuideContext","useStore","store","state","checkStateIfThrottled","guideGroups","debug","counter","debugging","defaultGroup","error","groupStage","getStage","display_sequence","map","guideKey","isUnknownGuide","input"],"mappings":"wJAWMA,EAAoCC,GACjCA,EAAMC,OAAO,CAACC,EAAKC,KAAU,CAAE,GAAGD,EAAK,CAACC,EAAKC,GAAG,EAAGD,CAAK,GAAI,CAAA,CAAE,EAwHjEE,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,Y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C,GAAI,CAACI,EACI,MAAA,CACLC,MAAO,iBACP1C,OAAQ,CAAA,CACV,EAGI2C,MAAAA,EAAaZ,EAAOa,SAAS,EAa5B,MAAA,CACL5C,OAVoByC,EAAaI,iBAAiBC,IAAkBC,GAAA,CAC9DlE,MAAAA,EAAQC,EAASkB,OAAO+C,CAAQ,EACtC,OAAKlE,EAIEsC,EAActC,EAAOC,EAAU6D,CAAU,EAHvCf,EAAgBmB,CAAQ,CAGe,CACjD,CAID,CACF,EAEaC,EAAkBC,GAC7B,OAAOA,GAAU,UACjBA,IAAU,MACV,eAAgBA,GACfA,EAAuBpB,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 checkActivatable,\n checkStateIfThrottled,\n} from \"@knocklabs/client\";\nimport { useGuideContext, useStore } from \"@knocklabs/react-core\";\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\ntype 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 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 UnknownGuide = {\n __typename: \"UnknownGuide\";\n key: KnockGuide[\"key\"];\n active: false;\n bypass_global_group_limit: false;\n annotation: {\n isEligible: false;\n isQualified: false;\n selectable: {\n status: undefined;\n };\n };\n};\n\nexport type InspectionResult = {\n guides: (AnnotatedGuide | UnknownGuide)[];\n error?: \"no_guide_group\";\n};\n\ntype StoreStateSnapshot = Pick<\n KnockGuideClientStoreState,\n | \"location\"\n | \"guides\"\n | \"guideGroups\"\n | \"ineligibleGuides\"\n | \"debug\"\n | \"counter\"\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 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 annotation,\n };\n};\n\nconst newUnknownGuide = (key: KnockGuide[\"key\"]) =>\n ({\n __typename: \"UnknownGuide\",\n key,\n active: false,\n bypass_global_group_limit: false,\n annotation: {\n isEligible: false,\n isQualified: false,\n selectable: {\n status: undefined,\n },\n },\n }) as UnknownGuide;\n\nexport const useInspectGuideClientStore = (): 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 throttled,\n };\n });\n\n // Not in debugging session, so noop.\n if (!snapshot.debug?.debugging) {\n return undefined;\n }\n\n // Only for completeness, as there should always be a default group so this\n // should never happen.\n const defaultGroup = snapshot.guideGroups[0];\n if (!defaultGroup) {\n return {\n error: \"no_guide_group\",\n guides: [],\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) => {\n const guide = snapshot.guides[guideKey];\n if (!guide) {\n return newUnknownGuide(guideKey);\n }\n\n return annotateGuide(guide, snapshot, groupStage);\n });\n\n return {\n guides: orderedGuides,\n };\n};\n\nexport const isUnknownGuide = (input: unknown): input is UnknownGuide =>\n typeof input === \"object\" &&\n input !== null &&\n \"__typename\" in input &&\n (input as UnknownGuide).__typename === \"UnknownGuide\";\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","ineligibleGuides","location","ineligiblity","checkActivatable","annotation","isEligible","isQualified","newUnknownGuide","__typename","useInspectGuideClientStore","client","useGuideContext","useStore","store","state","checkStateIfThrottled","guideGroups","debug","counter","debugging","defaultGroup","error","groupStage","getStage","display_sequence","map","guideKey","isUnknownGuide","input"],"mappings":"wJAWMA,EAAoCC,GACjCA,EAAMC,OAAO,CAACC,EAAKC,KAAU,CAAE,GAAGD,EAAK,CAACC,EAAKC,GAAG,EAAGD,CAAK,GAAI,CAAA,CAAE,EAwHjEE,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,MAAAA,EADS,CAAC,GAAGF,EAAOG,QAAQ,EACb,CAAC,EAElBjB,OAAAA,EAAMF,MAAQkB,EAAMlB,IAEf,UAEF,UAAA,CAILE,OAAAA,EAAMF,MAAQI,EAAMQ,SAClBT,EAASU,WAAa,CAACP,EAClB,YAEF,WAMF,SACT,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IAAU,MACV,eAAgBA,GACfA,EAAuBpB,aAAe"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,117 +1,118 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { Button as
|
|
4
|
-
import { ButtonGroup as
|
|
5
|
-
import { BellIcon as
|
|
6
|
-
import { CheckmarkCircle as
|
|
7
|
-
import { ChevronDown as
|
|
8
|
-
import { CloseCircle as
|
|
9
|
-
import { Spinner as
|
|
10
|
-
import { default as
|
|
11
|
-
import { EmptyFeed as
|
|
12
|
-
import { NotificationCell as
|
|
13
|
-
import { Avatar as
|
|
14
|
-
import { NotificationFeed as
|
|
15
|
-
import { NotificationFeedHeader as
|
|
16
|
-
import { MarkAsRead as
|
|
17
|
-
import { NotificationFeedContainer as
|
|
18
|
-
import { NotificationFeedPopover as
|
|
19
|
-
import { NotificationIconButton as
|
|
20
|
-
import { UnseenBadge as
|
|
21
|
-
import { Banner as
|
|
22
|
-
import { Card as
|
|
3
|
+
import { Button as x } from "./modules/core/components/Button/Button.mjs";
|
|
4
|
+
import { ButtonGroup as k } from "./modules/core/components/Button/ButtonGroup.mjs";
|
|
5
|
+
import { BellIcon as h } from "./modules/core/components/Icons/Bell.mjs";
|
|
6
|
+
import { CheckmarkCircle as T } from "./modules/core/components/Icons/CheckmarkCircle.mjs";
|
|
7
|
+
import { ChevronDown as v } from "./modules/core/components/Icons/ChevronDown.mjs";
|
|
8
|
+
import { CloseCircle as P } from "./modules/core/components/Icons/CloseCircle.mjs";
|
|
9
|
+
import { Spinner as F } from "./modules/core/components/Spinner/Spinner.mjs";
|
|
10
|
+
import { default as b } from "./modules/core/hooks/useOnBottomScroll.mjs";
|
|
11
|
+
import { EmptyFeed as g } from "./modules/feed/components/EmptyFeed/EmptyFeed.mjs";
|
|
12
|
+
import { NotificationCell as y } from "./modules/feed/components/NotificationCell/NotificationCell.mjs";
|
|
13
|
+
import { Avatar as O } from "./modules/feed/components/NotificationCell/Avatar.mjs";
|
|
14
|
+
import { NotificationFeed as D } from "./modules/feed/components/NotificationFeed/NotificationFeed.mjs";
|
|
15
|
+
import { NotificationFeedHeader as H } from "./modules/feed/components/NotificationFeed/NotificationFeedHeader.mjs";
|
|
16
|
+
import { MarkAsRead as R } from "./modules/feed/components/NotificationFeed/MarkAsRead.mjs";
|
|
17
|
+
import { NotificationFeedContainer as j } from "./modules/feed/components/NotificationFeedContainer/NotificationFeedContainer.mjs";
|
|
18
|
+
import { NotificationFeedPopover as z } from "./modules/feed/components/NotificationFeedPopover/NotificationFeedPopover.mjs";
|
|
19
|
+
import { NotificationIconButton as Q } from "./modules/feed/components/NotificationIconButton/NotificationIconButton.mjs";
|
|
20
|
+
import { UnseenBadge as X } from "./modules/feed/components/UnseenBadge/UnseenBadge.mjs";
|
|
21
|
+
import { Banner as Z, BannerView as _ } from "./modules/guide/components/Banner/Banner.mjs";
|
|
22
|
+
import { Card as ee, CardView as oe } from "./modules/guide/components/Card/Card.mjs";
|
|
23
23
|
import "react";
|
|
24
|
-
import { FilterStatus as
|
|
24
|
+
import { FilterStatus as re, I18nContext as ne, KnockFeedProvider as ie, KnockGuideContext as ae, KnockI18nProvider as se, KnockMsTeamsProvider as me, KnockProvider as ue, KnockSlackProvider as pe, feedProviderKey as ce, formatBadgeCount as fe, formatTimestamp as le, getBadgeAriaLabel as de, locales as xe, msTeamsProviderKey as Ce, renderNodeOrFallback as ke, slackProviderKey as Se, toSentenceCase as he, useAuthenticatedKnockClient as Ke, useConnectedMsTeamsChannels as Te, useConnectedSlackChannels as Me, useCreateNotificationStore as ve, useFeedSettings as Be, useGuide as Pe, useGuideContext as Ae, useGuides as Fe, useKnockClient as Ne, useKnockFeed as be, useKnockMsTeamsClient as Ge, useKnockSlackClient as ge, useMsTeamsAuth as we, useMsTeamsChannels as ye, useMsTeamsConnectionStatus as Ie, useMsTeamsTeams as Oe, useNotificationStore as Ve, useNotifications as De, usePreferences as Ee, useSlackAuth as He, useSlackChannels as Le, useSlackConnectionStatus as Re, useStableOptions as Ue, useTranslations as je } from "@knocklabs/react-core";
|
|
25
25
|
import "@telegraph/button";
|
|
26
26
|
import "@telegraph/layout";
|
|
27
27
|
import "@telegraph/tag";
|
|
28
28
|
import "@telegraph/typography";
|
|
29
29
|
import "lucide-react";
|
|
30
30
|
/* empty css */
|
|
31
|
+
import "@telegraph/icon";
|
|
31
32
|
import "@telegraph/tooltip";
|
|
32
33
|
import "@radix-ui/react-hover-card";
|
|
33
34
|
import "@knocklabs/client";
|
|
34
35
|
import "@telegraph/select";
|
|
35
|
-
import { Modal as
|
|
36
|
-
import { KnockGuideProvider as
|
|
37
|
-
import { MsTeamsAuthButton as
|
|
38
|
-
import { MsTeamsAuthContainer as
|
|
39
|
-
import { default as
|
|
40
|
-
import { SlackAuthButton as
|
|
41
|
-
import { SlackAuthContainer as
|
|
36
|
+
import { Modal as ze, ModalView as Je } from "./modules/guide/components/Modal/Modal.mjs";
|
|
37
|
+
import { KnockGuideProvider as We } from "./modules/guide/providers/KnockGuideProvider.mjs";
|
|
38
|
+
import { MsTeamsAuthButton as Ye } from "./modules/ms-teams/components/MsTeamsAuthButton/MsTeamsAuthButton.mjs";
|
|
39
|
+
import { MsTeamsAuthContainer as _e } from "./modules/ms-teams/components/MsTeamsAuthContainer/MsTeamsAuthContainer.mjs";
|
|
40
|
+
import { default as eo } from "./modules/ms-teams/components/MsTeamsChannelCombobox/MsTeamsChannelCombobox.mjs";
|
|
41
|
+
import { SlackAuthButton as to } from "./modules/slack/components/SlackAuthButton/SlackAuthButton.mjs";
|
|
42
|
+
import { SlackAuthContainer as no } from "./modules/slack/components/SlackAuthContainer/SlackAuthContainer.mjs";
|
|
42
43
|
import { SlackChannelCombobox as ao } from "./modules/slack/components/SlackChannelCombobox/SlackChannelCombobox.mjs";
|
|
43
44
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
O as Avatar,
|
|
46
|
+
Z as Banner,
|
|
47
|
+
_ as BannerView,
|
|
48
|
+
h as BellIcon,
|
|
49
|
+
x as Button,
|
|
50
|
+
k as ButtonGroup,
|
|
51
|
+
ee as Card,
|
|
52
|
+
oe as CardView,
|
|
53
|
+
T as CheckmarkCircle,
|
|
54
|
+
v as ChevronDown,
|
|
55
|
+
P as CloseCircle,
|
|
56
|
+
g as EmptyFeed,
|
|
57
|
+
re as FilterStatus,
|
|
58
|
+
ne as I18nContext,
|
|
59
|
+
ie as KnockFeedProvider,
|
|
59
60
|
ae as KnockGuideContext,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
We as KnockGuideProvider,
|
|
62
|
+
se as KnockI18nProvider,
|
|
63
|
+
me as KnockMsTeamsProvider,
|
|
64
|
+
ue as KnockProvider,
|
|
65
|
+
pe as KnockSlackProvider,
|
|
66
|
+
R as MarkAsRead,
|
|
67
|
+
ze as Modal,
|
|
68
|
+
Je as ModalView,
|
|
69
|
+
Ye as MsTeamsAuthButton,
|
|
70
|
+
_e as MsTeamsAuthContainer,
|
|
71
|
+
eo as MsTeamsChannelCombobox,
|
|
72
|
+
y as NotificationCell,
|
|
73
|
+
D as NotificationFeed,
|
|
74
|
+
j as NotificationFeedContainer,
|
|
75
|
+
H as NotificationFeedHeader,
|
|
76
|
+
z as NotificationFeedPopover,
|
|
77
|
+
Q as NotificationIconButton,
|
|
78
|
+
to as SlackAuthButton,
|
|
79
|
+
no as SlackAuthContainer,
|
|
79
80
|
ao as SlackChannelCombobox,
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
F as Spinner,
|
|
82
|
+
X as UnseenBadge,
|
|
82
83
|
ce as feedProviderKey,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
84
|
+
fe as formatBadgeCount,
|
|
85
|
+
le as formatTimestamp,
|
|
86
|
+
de as getBadgeAriaLabel,
|
|
87
|
+
xe as locales,
|
|
88
|
+
Ce as msTeamsProviderKey,
|
|
89
|
+
ke as renderNodeOrFallback,
|
|
90
|
+
Se as slackProviderKey,
|
|
91
|
+
he as toSentenceCase,
|
|
92
|
+
Ke as useAuthenticatedKnockClient,
|
|
93
|
+
Te as useConnectedMsTeamsChannels,
|
|
94
|
+
Me as useConnectedSlackChannels,
|
|
95
|
+
ve as useCreateNotificationStore,
|
|
96
|
+
Be as useFeedSettings,
|
|
97
|
+
Pe as useGuide,
|
|
98
|
+
Ae as useGuideContext,
|
|
99
|
+
Fe as useGuides,
|
|
100
|
+
Ne as useKnockClient,
|
|
101
|
+
be as useKnockFeed,
|
|
102
|
+
Ge as useKnockMsTeamsClient,
|
|
103
|
+
ge as useKnockSlackClient,
|
|
104
|
+
we as useMsTeamsAuth,
|
|
105
|
+
ye as useMsTeamsChannels,
|
|
106
|
+
Ie as useMsTeamsConnectionStatus,
|
|
107
|
+
Oe as useMsTeamsTeams,
|
|
108
|
+
Ve as useNotificationStore,
|
|
109
|
+
De as useNotifications,
|
|
110
|
+
b as useOnBottomScroll,
|
|
111
|
+
Ee as usePreferences,
|
|
112
|
+
He as useSlackAuth,
|
|
113
|
+
Le as useSlackChannels,
|
|
114
|
+
Re as useSlackConnectionStatus,
|
|
115
|
+
Ue as useStableOptions,
|
|
116
|
+
je as useTranslations
|
|
116
117
|
};
|
|
117
118
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import t from "react";
|
|
2
|
-
import { Button as
|
|
3
|
-
import { TOOLBAR_Z_INDEX as
|
|
2
|
+
import { Button as a } from "@telegraph/button";
|
|
3
|
+
import { TOOLBAR_Z_INDEX as r } from "./shared.mjs";
|
|
4
4
|
/* empty css */
|
|
5
|
-
const
|
|
6
|
-
onClick: e
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const s = ({
|
|
6
|
+
onClick: e,
|
|
7
|
+
positioned: o = !0
|
|
8
|
+
}) => /* @__PURE__ */ t.createElement(a, { onClick: e, ...o && {
|
|
9
|
+
position: "fixed",
|
|
10
|
+
top: "4",
|
|
11
|
+
right: "4",
|
|
12
|
+
style: {
|
|
13
|
+
zIndex: r
|
|
14
|
+
}
|
|
15
|
+
}, bg: "surface-2", shadow: "3", rounded: "3", w: "10", h: "10", variant: "soft", "data-tgph-appearance": "dark", "aria-label": "Expand guide toolbar" }, /* @__PURE__ */ t.createElement("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
10
16
|
position: "absolute",
|
|
11
17
|
top: "50%",
|
|
12
18
|
left: "50%",
|
|
13
19
|
transform: "translate(-50%, -50%)"
|
|
14
20
|
} }, /* @__PURE__ */ t.createElement("path", { d: "M11.6001 32.4V7.59998H16.6365V21.8219H16.7774L22.3067 14.8525H27.9418L21.8138 22.0696L28.4001 32.4H22.7996L18.8555 25.572L16.6365 28.0839V32.4H11.6001Z", fill: "#EDEEEF" }), /* @__PURE__ */ t.createElement("path", { d: "M28.4 10.4C28.4 11.9464 27.1467 13.2 25.6 13.2C24.0534 13.2 22.8 11.9464 22.8 10.4C22.8 8.85358 24.0534 7.59998 25.6 7.59998C27.1467 7.59998 28.4 8.85358 28.4 10.4Z", fill: "#FF573A" })));
|
|
15
21
|
export {
|
|
16
|
-
|
|
22
|
+
s as KnockButton
|
|
17
23
|
};
|
|
18
24
|
//# sourceMappingURL=KnockButton.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnockButton.mjs","sources":["../../../../../../src/modules/guide/components/Toolbar/KnockButton.tsx"],"sourcesContent":["import { Button } from \"@telegraph/button\";\n\nimport { TOOLBAR_Z_INDEX } from \"./shared\";\nimport \"./styles.css\";\n\ntype Props = {\n onClick: () => void;\n};\n\nexport const KnockButton = ({ onClick }: Props) => {\n return (\n <Button\n onClick={onClick}\n position
|
|
1
|
+
{"version":3,"file":"KnockButton.mjs","sources":["../../../../../../src/modules/guide/components/Toolbar/KnockButton.tsx"],"sourcesContent":["import { Button } from \"@telegraph/button\";\n\nimport { TOOLBAR_Z_INDEX } from \"./shared\";\nimport \"./styles.css\";\n\ntype Props = {\n onClick: () => void;\n positioned?: boolean;\n};\n\nexport const KnockButton = ({ onClick, positioned = true }: Props) => {\n return (\n <Button\n onClick={onClick}\n {...(positioned && {\n position: \"fixed\" as const,\n top: \"4\" as const,\n right: \"4\" as const,\n style: { zIndex: TOOLBAR_Z_INDEX },\n })}\n bg=\"surface-2\"\n shadow=\"3\"\n rounded=\"3\"\n w=\"10\"\n h=\"10\"\n variant=\"soft\"\n data-tgph-appearance=\"dark\"\n aria-label=\"Expand guide toolbar\"\n >\n <svg\n width=\"40\"\n height=\"40\"\n viewBox=\"0 0 40 40\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n }}\n >\n <path\n d=\"M11.6001 32.4V7.59998H16.6365V21.8219H16.7774L22.3067 14.8525H27.9418L21.8138 22.0696L28.4001 32.4H22.7996L18.8555 25.572L16.6365 28.0839V32.4H11.6001Z\"\n fill=\"#EDEEEF\"\n />\n <path\n d=\"M28.4 10.4C28.4 11.9464 27.1467 13.2 25.6 13.2C24.0534 13.2 22.8 11.9464 22.8 10.4C22.8 8.85358 24.0534 7.59998 25.6 7.59998C27.1467 7.59998 28.4 8.85358 28.4 10.4Z\"\n fill=\"#FF573A\"\n />\n </svg>\n </Button>\n );\n};\n"],"names":["KnockButton","onClick","positioned","React","Button","position","top","right","style","zIndex","TOOLBAR_Z_INDEX","left","transform"],"mappings":";;;;AAUO,MAAMA,IAAcA,CAAC;AAAA,EAAEC,SAAAA;AAAAA,EAASC,YAAAA,IAAa;AAAY,MAE3DC,gBAAAA,EAAA,cAAAC,GAAA,EACC,SAAAH,GACKC,GAAAA,KAAc;AAAA,EACjBG,UAAU;AAAA,EACVC,KAAK;AAAA,EACLC,OAAO;AAAA,EACPC,OAAO;AAAA,IAAEC,QAAQC;AAAAA,EAAAA;AAAgB,GAEnC,IAAG,aACH,QAAO,KACP,SAAQ,KACR,GAAE,MACF,GAAE,MACF,SAAQ,QACR,wBAAqB,QACrB,cAAW,uBAEX,GAAAP,gBAAAA,EAAA,cAAC,OACC,EAAA,OAAM,MACN,QAAO,MACP,SAAQ,aACR,MAAK,QACL,OAAM,8BACN,OAAO;AAAA,EACLE,UAAU;AAAA,EACVC,KAAK;AAAA,EACLK,MAAM;AAAA,EACNC,WAAW;AAAA,KAGbT,gBAAAA,EAAA,cAAC,QACC,EAAA,GAAE,2JACF,MAAK,UAAS,CAAA,GAEhBA,gBAAAA,EAAA,cAAC,UACC,GAAE,wKACF,MAAK,UAAS,CAAA,CAElB,CACF;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Icon as o } from "@telegraph/icon";
|
|
2
|
+
import { Box as a } from "@telegraph/layout";
|
|
3
|
+
import { GripVertical as i } from "lucide-react";
|
|
4
|
+
import r from "react";
|
|
5
|
+
const n = 16, s = ({
|
|
6
|
+
onPointerDown: e,
|
|
7
|
+
isDragging: t
|
|
8
|
+
}) => /* @__PURE__ */ r.createElement(a, { "data-tgph-appearance": "dark", onPointerDown: e, borderRadius: "2", position: "absolute", style: {
|
|
9
|
+
top: "9px",
|
|
10
|
+
right: `-${n}px`,
|
|
11
|
+
height: "24px",
|
|
12
|
+
cursor: t ? "grabbing" : "grab",
|
|
13
|
+
touchAction: "none",
|
|
14
|
+
userSelect: "none"
|
|
15
|
+
} }, /* @__PURE__ */ r.createElement(o, { color: "gray", size: "1", icon: i, "aria-hidden": !0 }));
|
|
16
|
+
export {
|
|
17
|
+
n as DRAG_HANDLE_OVERHANG,
|
|
18
|
+
s as DragHandle
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=DragHandle.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragHandle.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/DragHandle.tsx"],"sourcesContent":["import { Icon } from \"@telegraph/icon\";\nimport { Box } from \"@telegraph/layout\";\nimport { GripVertical } from \"lucide-react\";\nimport React from \"react\";\n\n// How far the drag handle protrudes beyond the toolbar's right edge (px)\nexport const DRAG_HANDLE_OVERHANG = 16;\n\ntype DragHandleProps = {\n onPointerDown: (e: React.PointerEvent) => void;\n isDragging: boolean;\n};\n\nexport const DragHandle = ({ onPointerDown, isDragging }: DragHandleProps) => {\n return (\n <Box\n data-tgph-appearance=\"dark\"\n onPointerDown={onPointerDown}\n borderRadius=\"2\"\n position=\"absolute\"\n style={{\n top: \"9px\",\n right: `-${DRAG_HANDLE_OVERHANG}px`,\n height: \"24px\",\n cursor: isDragging ? \"grabbing\" : \"grab\",\n touchAction: \"none\",\n userSelect: \"none\",\n }}\n >\n <Icon color=\"gray\" size=\"1\" icon={GripVertical} aria-hidden />\n </Box>\n );\n};\n"],"names":["DRAG_HANDLE_OVERHANG","DragHandle","onPointerDown","isDragging","React","Box","top","right","height","cursor","touchAction","userSelect","Icon","GripVertical"],"mappings":";;;;AAMO,MAAMA,IAAuB,IAOvBC,IAAaA,CAAC;AAAA,EAAEC,eAAAA;AAAAA,EAAeC,YAAAA;AAA4B,MAEpEC,gBAAAA,EAAA,cAACC,KACC,wBAAqB,QACrB,eAAAH,GACA,cAAa,KACb,UAAS,YACT,OAAO;AAAA,EACLI,KAAK;AAAA,EACLC,OAAO,IAAIP,CAAoB;AAAA,EAC/BQ,QAAQ;AAAA,EACRC,QAAQN,IAAa,aAAa;AAAA,EAClCO,aAAa;AAAA,EACbC,YAAY;AACd,EAAA,GAECP,gBAAAA,EAAA,cAAAQ,GAAA,EAAK,OAAM,QAAO,MAAK,KAAI,MAAMC,GAAc,eAAW,GAAA,CAAA,CAC7D;"}
|