@knocklabs/react 0.11.6 → 0.11.7
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 +6 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.js +2 -0
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.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/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/GuideRowDetails.js +2 -0
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRowDetails.js.map +1 -0
- 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 +1 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/useDraggable.js.map +1 -1
- 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 -99
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.mjs +18 -0
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.mjs.map +1 -0
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideContextDetails.mjs +15 -29
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideContextDetails.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideRow.mjs +167 -49
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideRow.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideRowDetails.mjs +51 -0
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideRowDetails.mjs.map +1 -0
- package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs +128 -66
- package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/useDraggable.mjs +35 -32
- package/dist/esm/modules/guide/components/Toolbar/V2/useDraggable.mjs.map +1 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.mjs +65 -54
- package/dist/esm/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.mjs.map +1 -1
- package/dist/types/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.d.ts +6 -0
- package/dist/types/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.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/GuideRow.d.ts +3 -1
- package/dist/types/modules/guide/components/Toolbar/V2/GuideRow.d.ts.map +1 -1
- package/dist/types/modules/guide/components/Toolbar/V2/GuideRowDetails.d.ts +5 -0
- package/dist/types/modules/guide/components/Toolbar/V2/GuideRowDetails.d.ts.map +1 -0
- 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 +2 -0
- package/dist/types/modules/guide/components/Toolbar/V2/useDraggable.d.ts.map +1 -1
- package/dist/types/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.d.ts +9 -3
- package/dist/types/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.d.ts.map +1 -1
- package/package.json +3 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/DragHandle.js +0 -2
- package/dist/cjs/modules/guide/components/Toolbar/V2/DragHandle.js.map +0 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideHoverCard.js +0 -2
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuideHoverCard.js.map +0 -1
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuidesListDisplaySelect.js +0 -2
- package/dist/cjs/modules/guide/components/Toolbar/V2/GuidesListDisplaySelect.js.map +0 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/DragHandle.mjs +0 -20
- package/dist/esm/modules/guide/components/Toolbar/V2/DragHandle.mjs.map +0 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideHoverCard.mjs +0 -57
- package/dist/esm/modules/guide/components/Toolbar/V2/GuideHoverCard.mjs.map +0 -1
- package/dist/esm/modules/guide/components/Toolbar/V2/GuidesListDisplaySelect.mjs +0 -17
- package/dist/esm/modules/guide/components/Toolbar/V2/GuidesListDisplaySelect.mjs.map +0 -1
- package/dist/types/modules/guide/components/Toolbar/V2/DragHandle.d.ts +0 -9
- package/dist/types/modules/guide/components/Toolbar/V2/DragHandle.d.ts.map +0 -1
- package/dist/types/modules/guide/components/Toolbar/V2/GuidesListDisplaySelect.d.ts +0 -8
- package/dist/types/modules/guide/components/Toolbar/V2/GuidesListDisplaySelect.d.ts.map +0 -1
|
@@ -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 { 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\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\" | \"no_guide_present\";\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 = (\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 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 // Check if the focused guide actually exists and is selectable on the page.\n if (groupStage?.status === \"closed\" && runConfig.focusedGuideKeys) {\n const focusableGuide = orderedGuides.find(\n (g) =>\n runConfig.focusedGuideKeys![g.key] && g.annotation.selectable.status,\n );\n if (!focusableGuide) {\n return {\n error: \"no_guide_present\",\n guides: [],\n };\n }\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","runConfig","client","useGuideContext","useStore","store","state","checkStateIfThrottled","guideGroups","debug","counter","debugging","defaultGroup","error","groupStage","getStage","orderedGuides","display_sequence","map","guideKey","focusedGuideKeys","find","g","isUnknownGuide","input"],"mappings":"wJAaMA,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,YAA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,GAAA,CAC/DhD,MAAAA,EAAYiD,wBAAsBD,CAAK,EAEtC,MAAA,CACLd,SAAUc,EAAMd,SAChB1B,OAAQwC,EAAMxC,OACd0C,YAAaF,EAAME,YACnBjB,iBAAkBe,EAAMf,iBACxBkB,MAAOH,EAAMG,MACbC,QAASJ,EAAMI,QACfpD,UAAAA,CACF,CAAA,CACD,EAGG,GAAA,GAACV,EAAAA,EAAS6D,QAAT7D,MAAAA,EAAgB+D,WACZxC,OAKHyC,MAAAA,EAAehE,EAAS4D,YAAY,CAAC,EAC3C,GAAI,CAACI,EACI,MAAA,CACLC,MAAO,iBACP/C,OAAQ,CAAA,CACV,EAGIgD,MAAAA,EAAaZ,EAAOa,SAAS,EAI7BC,EAAgBJ,EAAaK,iBAAiBC,IAAkBC,GAAA,CAC9DxE,MAAAA,EAAQC,EAASkB,OAAOqD,CAAQ,EACtC,OAAKxE,EAIE2C,EAAc3C,EAAOC,EAAUkE,CAAU,EAHvChB,EAAgBqB,CAAQ,CAGe,CACjD,EAGD,OAAIL,GAAAA,YAAAA,EAAY5C,UAAW,UAAY+B,EAAUmB,kBAK3C,CAJmBJ,EAAcK,KAClCC,GACCrB,EAAUmB,iBAAkBE,EAAE7E,GAAG,GAAK6E,EAAE3B,WAAWN,WAAWnB,MAClE,EAES,CACL2C,MAAO,mBACP/C,OAAQ,CAAA,CACV,EAIG,CACLA,OAAQkD,CACV,CACF,EAEaO,EAAkBC,GAC7B,OAAOA,GAAU,UACjBA,IAAU,MACV,eAAgBA,GACfA,EAAuBzB,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\nimport { 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 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 InspectionResultOk = {\n status: \"ok\";\n guides: (AnnotatedGuide | UnknownGuide)[];\n};\ntype InspectionResultError = {\n status: \"error\";\n error: \"no_guides_fetched\" | \"no_guide_group\" | \"no_guide_present\";\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 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 = (\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) => {\n const guide = snapshot.guides[guideKey];\n if (!guide) {\n return newUnknownGuide(guideKey);\n }\n\n return annotateGuide(guide, 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 focusableGuide = orderedGuides.find(\n (g) => g.key === focusedGuideKey && g.annotation.selectable.status,\n );\n if (!focusableGuide) {\n return {\n status: \"error\",\n error: \"no_guide_present\",\n message: `No component that can render \\`${focusedGuideKey}\\` was found`,\n };\n }\n }\n\n return {\n status: \"ok\",\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","runConfig","client","useGuideContext","useStore","store","state","checkStateIfThrottled","guideGroups","debug","counter","queries","debugging","req","Object","entries","error","defaultGroup","groupStage","getStage","orderedGuides","display_sequence","map","guideKey","focusedGuideKey","keys","focusedGuideKeys","find","g","isUnknownGuide","input"],"mappings":"wJAaMA,EAAoCC,GACjCA,EAAMC,OAAO,CAACC,EAAKC,KAAU,CAAE,GAAGD,EAAK,CAACC,EAAKC,GAAG,EAAGD,CAAK,GAAI,CAAA,CAAE,EA+HjEE,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,EACl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,IAAkBC,GAAA,CAC9D5E,MAAAA,EAAQC,EAASkB,OAAOyD,CAAQ,EACtC,OAAK5E,EAIE2C,EAAc3C,EAAOC,EAAUsE,CAAU,EAHvCpB,EAAgByB,CAAQ,CAGe,CACjD,EAGKC,EAAkBV,OAAOW,KAAKxB,EAAUyB,kBAAoB,CAAA,CAAE,EAAE,CAAC,EACnER,OAAAA,GAAAA,YAAAA,EAAYhD,UAAW,UAAYsD,GAIjC,CAHmBJ,EAAcO,KAC5BC,GAAAA,EAAEnF,MAAQ+E,GAAmBI,EAAEjC,WAAWN,WAAWnB,MAC9D,EAES,CACLA,OAAQ,QACR8C,MAAO,mBACPrC,QAAS,kCAAkC6C,CAAe,cAC5D,EAIG,CACLtD,OAAQ,KACRJ,OAAQsD,CACV,CACF,EAEaS,EAAkBC,GAC7B,OAAOA,GAAU,UACjBA,IAAU,MACV,eAAgBA,GACfA,EAAuB/B,aAAe"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
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 d } from "./modules/core/components/Button/Button.mjs";
|
|
4
|
+
import { ButtonGroup as C } from "./modules/core/components/Button/ButtonGroup.mjs";
|
|
5
|
+
import { BellIcon as S } from "./modules/core/components/Icons/Bell.mjs";
|
|
6
|
+
import { CheckmarkCircle as K } from "./modules/core/components/Icons/CheckmarkCircle.mjs";
|
|
7
|
+
import { ChevronDown as M } from "./modules/core/components/Icons/ChevronDown.mjs";
|
|
8
|
+
import { CloseCircle as B } from "./modules/core/components/Icons/CloseCircle.mjs";
|
|
9
|
+
import { Spinner as A } from "./modules/core/components/Spinner/Spinner.mjs";
|
|
10
|
+
import { default as N } from "./modules/core/hooks/useOnBottomScroll.mjs";
|
|
11
|
+
import { EmptyFeed as G } from "./modules/feed/components/EmptyFeed/EmptyFeed.mjs";
|
|
12
|
+
import { NotificationCell as w } from "./modules/feed/components/NotificationCell/NotificationCell.mjs";
|
|
13
|
+
import { Avatar as I } from "./modules/feed/components/NotificationCell/Avatar.mjs";
|
|
14
|
+
import { NotificationFeed as V } from "./modules/feed/components/NotificationFeed/NotificationFeed.mjs";
|
|
15
|
+
import { NotificationFeedHeader as E } from "./modules/feed/components/NotificationFeed/NotificationFeedHeader.mjs";
|
|
16
|
+
import { MarkAsRead as L } from "./modules/feed/components/NotificationFeed/MarkAsRead.mjs";
|
|
17
|
+
import { NotificationFeedContainer as U } from "./modules/feed/components/NotificationFeedContainer/NotificationFeedContainer.mjs";
|
|
18
|
+
import { NotificationFeedPopover as q } from "./modules/feed/components/NotificationFeedPopover/NotificationFeedPopover.mjs";
|
|
19
|
+
import { NotificationIconButton as J } from "./modules/feed/components/NotificationIconButton/NotificationIconButton.mjs";
|
|
20
|
+
import { UnseenBadge as W } from "./modules/feed/components/UnseenBadge/UnseenBadge.mjs";
|
|
21
|
+
import { Banner as Y, BannerView as Z } from "./modules/guide/components/Banner/Banner.mjs";
|
|
22
|
+
import { Card as $, CardView as ee } from "./modules/guide/components/Card/Card.mjs";
|
|
23
23
|
import "react";
|
|
24
|
-
import { FilterStatus as
|
|
24
|
+
import { FilterStatus as te, I18nContext as re, KnockFeedProvider as ne, KnockGuideContext as ae, KnockI18nProvider as ie, KnockMsTeamsProvider as se, KnockProvider as me, KnockSlackProvider as ue, feedProviderKey as ce, formatBadgeCount as pe, formatTimestamp as fe, getBadgeAriaLabel as le, locales as de, msTeamsProviderKey as xe, renderNodeOrFallback as Ce, slackProviderKey as ke, toSentenceCase as Se, useAuthenticatedKnockClient as he, useConnectedMsTeamsChannels as Ke, useConnectedSlackChannels as Te, useCreateNotificationStore as Me, useFeedSettings as ve, useGuide as Be, useGuideContext as Pe, useGuides as Ae, useKnockClient as Fe, useKnockFeed as Ne, useKnockMsTeamsClient as be, useKnockSlackClient as Ge, useMsTeamsAuth as ge, useMsTeamsChannels as we, useMsTeamsConnectionStatus as ye, useMsTeamsTeams as Ie, useNotificationStore as Oe, useNotifications as Ve, usePreferences as De, useSlackAuth as Ee, useSlackChannels as He, useSlackConnectionStatus as Le, useStableOptions as Re, useTranslations as Ue } from "@knocklabs/react-core";
|
|
25
25
|
import "@telegraph/button";
|
|
26
26
|
import "@telegraph/layout";
|
|
27
27
|
import "@telegraph/tag";
|
|
@@ -29,90 +29,89 @@ import "@telegraph/typography";
|
|
|
29
29
|
import "lucide-react";
|
|
30
30
|
/* empty css */
|
|
31
31
|
import "@telegraph/icon";
|
|
32
|
+
import "@telegraph/segmented-control";
|
|
32
33
|
import "@telegraph/tooltip";
|
|
33
|
-
import "@radix-ui/react-hover-card";
|
|
34
34
|
import "@knocklabs/client";
|
|
35
|
-
import "
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import { SlackAuthContainer as no } from "./modules/slack/components/SlackAuthContainer/SlackAuthContainer.mjs";
|
|
35
|
+
import { Modal as qe, ModalView as ze } from "./modules/guide/components/Modal/Modal.mjs";
|
|
36
|
+
import { KnockGuideProvider as Qe } from "./modules/guide/providers/KnockGuideProvider.mjs";
|
|
37
|
+
import { MsTeamsAuthButton as Xe } from "./modules/ms-teams/components/MsTeamsAuthButton/MsTeamsAuthButton.mjs";
|
|
38
|
+
import { MsTeamsAuthContainer as Ze } from "./modules/ms-teams/components/MsTeamsAuthContainer/MsTeamsAuthContainer.mjs";
|
|
39
|
+
import { default as $e } from "./modules/ms-teams/components/MsTeamsChannelCombobox/MsTeamsChannelCombobox.mjs";
|
|
40
|
+
import { SlackAuthButton as oo } from "./modules/slack/components/SlackAuthButton/SlackAuthButton.mjs";
|
|
41
|
+
import { SlackAuthContainer as ro } from "./modules/slack/components/SlackAuthContainer/SlackAuthContainer.mjs";
|
|
43
42
|
import { SlackChannelCombobox as ao } from "./modules/slack/components/SlackChannelCombobox/SlackChannelCombobox.mjs";
|
|
44
43
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
I as Avatar,
|
|
45
|
+
Y as Banner,
|
|
46
|
+
Z as BannerView,
|
|
47
|
+
S as BellIcon,
|
|
48
|
+
d as Button,
|
|
49
|
+
C as ButtonGroup,
|
|
50
|
+
$ as Card,
|
|
51
|
+
ee as CardView,
|
|
52
|
+
K as CheckmarkCircle,
|
|
53
|
+
M as ChevronDown,
|
|
54
|
+
B as CloseCircle,
|
|
55
|
+
G as EmptyFeed,
|
|
56
|
+
te as FilterStatus,
|
|
57
|
+
re as I18nContext,
|
|
58
|
+
ne as KnockFeedProvider,
|
|
60
59
|
ae as KnockGuideContext,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
Qe as KnockGuideProvider,
|
|
61
|
+
ie as KnockI18nProvider,
|
|
62
|
+
se as KnockMsTeamsProvider,
|
|
63
|
+
me as KnockProvider,
|
|
64
|
+
ue as KnockSlackProvider,
|
|
65
|
+
L as MarkAsRead,
|
|
66
|
+
qe as Modal,
|
|
67
|
+
ze as ModalView,
|
|
68
|
+
Xe as MsTeamsAuthButton,
|
|
69
|
+
Ze as MsTeamsAuthContainer,
|
|
70
|
+
$e as MsTeamsChannelCombobox,
|
|
71
|
+
w as NotificationCell,
|
|
72
|
+
V as NotificationFeed,
|
|
73
|
+
U as NotificationFeedContainer,
|
|
74
|
+
E as NotificationFeedHeader,
|
|
75
|
+
q as NotificationFeedPopover,
|
|
76
|
+
J as NotificationIconButton,
|
|
77
|
+
oo as SlackAuthButton,
|
|
78
|
+
ro as SlackAuthContainer,
|
|
80
79
|
ao as SlackChannelCombobox,
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
A as Spinner,
|
|
81
|
+
W as UnseenBadge,
|
|
83
82
|
ce as feedProviderKey,
|
|
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
|
-
|
|
116
|
-
|
|
83
|
+
pe as formatBadgeCount,
|
|
84
|
+
fe as formatTimestamp,
|
|
85
|
+
le as getBadgeAriaLabel,
|
|
86
|
+
de as locales,
|
|
87
|
+
xe as msTeamsProviderKey,
|
|
88
|
+
Ce as renderNodeOrFallback,
|
|
89
|
+
ke as slackProviderKey,
|
|
90
|
+
Se as toSentenceCase,
|
|
91
|
+
he as useAuthenticatedKnockClient,
|
|
92
|
+
Ke as useConnectedMsTeamsChannels,
|
|
93
|
+
Te as useConnectedSlackChannels,
|
|
94
|
+
Me as useCreateNotificationStore,
|
|
95
|
+
ve as useFeedSettings,
|
|
96
|
+
Be as useGuide,
|
|
97
|
+
Pe as useGuideContext,
|
|
98
|
+
Ae as useGuides,
|
|
99
|
+
Fe as useKnockClient,
|
|
100
|
+
Ne as useKnockFeed,
|
|
101
|
+
be as useKnockMsTeamsClient,
|
|
102
|
+
Ge as useKnockSlackClient,
|
|
103
|
+
ge as useMsTeamsAuth,
|
|
104
|
+
we as useMsTeamsChannels,
|
|
105
|
+
ye as useMsTeamsConnectionStatus,
|
|
106
|
+
Ie as useMsTeamsTeams,
|
|
107
|
+
Oe as useNotificationStore,
|
|
108
|
+
Ve as useNotifications,
|
|
109
|
+
N as useOnBottomScroll,
|
|
110
|
+
De as usePreferences,
|
|
111
|
+
Ee as useSlackAuth,
|
|
112
|
+
He as useSlackChannels,
|
|
113
|
+
Le as useSlackConnectionStatus,
|
|
114
|
+
Re as useStableOptions,
|
|
115
|
+
Ue as useTranslations
|
|
117
116
|
};
|
|
118
117
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
import { Stack as i } from "@telegraph/layout";
|
|
3
|
+
import { Tooltip as a } from "@telegraph/tooltip";
|
|
4
|
+
const l = {
|
|
5
|
+
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
|
+
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
|
+
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
|
+
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
|
+
color: t,
|
|
11
|
+
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
|
+
flexShrink: 0
|
|
14
|
+
} }, l[t]));
|
|
15
|
+
export {
|
|
16
|
+
h as GuideAnnotatedStatusDot
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=GuideAnnotatedStatusDot.mjs.map
|
|
@@ -0,0 +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","Too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
|
3
|
-
import {
|
|
4
|
-
import { Stack as t, Box as g } from "@telegraph/layout";
|
|
5
|
-
import { Tooltip as p } from "@telegraph/tooltip";
|
|
1
|
+
import e from "react";
|
|
2
|
+
import { useGuideContext as o } from "@knocklabs/react-core";
|
|
3
|
+
import { Box as r, Stack as a } from "@telegraph/layout";
|
|
6
4
|
import { Text as n } from "@telegraph/typography";
|
|
7
|
-
|
|
8
|
-
import * as e from "react";
|
|
9
|
-
const C = () => {
|
|
5
|
+
const d = () => {
|
|
10
6
|
const {
|
|
11
|
-
client:
|
|
12
|
-
} =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
defaultGroup: i.guideGroups[0],
|
|
17
|
-
debugSettings: i.debug || {}
|
|
18
|
-
})), c = (o == null ? void 0 : o.display_interval) ?? null;
|
|
19
|
-
return /* @__PURE__ */ e.createElement(t, { direction: "column", borderTop: "px" }, /* @__PURE__ */ e.createElement(t, { h: "5", px: "2", bg: "gray-3", align: "center", gap: "1", style: {
|
|
20
|
-
cursor: "pointer"
|
|
21
|
-
}, onClick: () => u((i) => !i) }, /* @__PURE__ */ e.createElement(n, { as: "span", size: "0", weight: "medium" }, "More"), l ? /* @__PURE__ */ e.createElement(f, { size: 12 }) : /* @__PURE__ */ e.createElement(x, { size: 12 })), l && /* @__PURE__ */ e.createElement(t, { direction: "column" }, /* @__PURE__ */ e.createElement(t, { align: "center", justify: "space-between", py: "1", px: "2", borderTop: "px" }, /* @__PURE__ */ e.createElement(t, { align: "center", gap: "1" }, /* @__PURE__ */ e.createElement(n, { as: "span", size: "0", weight: "medium" }, "Client-only engagement"), /* @__PURE__ */ e.createElement(p, { label: "Contain engagement actions to the client side only while in preview without sending engagement events to the API" }, /* @__PURE__ */ e.createElement(m, { icon: d, size: "0", color: "gray", "aria-hidden": !0 }))), /* @__PURE__ */ e.createElement(s, { size: "0", variant: "soft", color: r.skipEngagementTracking ? "green" : "gray", onClick: () => a.setDebug({
|
|
22
|
-
...r,
|
|
23
|
-
skipEngagementTracking: !r.skipEngagementTracking
|
|
24
|
-
}) }, r.skipEngagementTracking ? "On" : "Off")), /* @__PURE__ */ e.createElement(t, { direction: "column", py: "1", px: "2" }, /* @__PURE__ */ e.createElement(t, { align: "center", justify: "space-between" }, /* @__PURE__ */ e.createElement(t, { align: "center", gap: "1" }, /* @__PURE__ */ e.createElement(n, { as: "span", size: "0", weight: "medium" }, "Suspend throttling"), /* @__PURE__ */ e.createElement(p, { label: "Suspend throttling during preview, and show next guide immediately" }, /* @__PURE__ */ e.createElement(m, { icon: d, size: "0", color: "gray", "aria-hidden": !0 }))), /* @__PURE__ */ e.createElement(s, { size: "0", variant: "soft", color: r.ignoreDisplayInterval ? "green" : "gray", onClick: () => a.setDebug({
|
|
25
|
-
...r,
|
|
26
|
-
ignoreDisplayInterval: !r.ignoreDisplayInterval
|
|
27
|
-
}) }, r.ignoreDisplayInterval ? "On" : "Off")), /* @__PURE__ */ e.createElement(t, { direction: "row", gap: "0_5", py: "1" }, /* @__PURE__ */ e.createElement(n, { as: "span", size: "0", color: "gray" }, "Throttle:", " ", r.ignoreDisplayInterval ? "(ignored)" : c === null ? "(none)" : `Every ${c}s`))), /* @__PURE__ */ e.createElement(t, { direction: "column", py: "1", px: "2", borderTop: "px" }, /* @__PURE__ */ e.createElement(n, { as: "span", size: "0", weight: "medium" }, "Target params"), /* @__PURE__ */ e.createElement(t, { direction: "column", gap: "0_5", mt: "1" }, /* @__PURE__ */ e.createElement(n, { as: "span", size: "0", color: "gray" }, "Tenant"), /* @__PURE__ */ e.createElement(n, { as: "code", size: "0" }, a.targetParams.tenant ? /* @__PURE__ */ e.createElement(g, { rounded: "2", overflow: "auto", backgroundColor: "gray-2", border: "px", style: {
|
|
28
|
-
maxHeight: "200px"
|
|
7
|
+
client: t
|
|
8
|
+
} = o();
|
|
9
|
+
return /* @__PURE__ */ e.createElement(r, { py: "3", px: "3" }, /* @__PURE__ */ e.createElement(n, { as: "span", size: "1", weight: "medium" }, "Target params"), /* @__PURE__ */ e.createElement(a, { direction: "column", gap: "2", mt: "2" }, /* @__PURE__ */ e.createElement(a, { direction: "row", gap: "2", align: "center" }, /* @__PURE__ */ e.createElement(n, { as: "span", size: "1", weight: "medium", color: "gray", width: "36", mt: "1" }, "Tenant"), /* @__PURE__ */ e.createElement(r, { rounded: "2", overflow: "auto", backgroundColor: "surface-2", border: "px", p: "1", style: {
|
|
10
|
+
flex: 1,
|
|
11
|
+
minWidth: 0
|
|
29
12
|
} }, /* @__PURE__ */ e.createElement("pre", { style: {
|
|
30
13
|
fontSize: "11px",
|
|
31
14
|
margin: 0
|
|
32
|
-
} }, /* @__PURE__ */ e.createElement("code", null,
|
|
15
|
+
} }, /* @__PURE__ */ e.createElement("code", null, t.targetParams.tenant || "-")))), /* @__PURE__ */ e.createElement(a, { direction: "row", gap: "2", align: "flex-start" }, /* @__PURE__ */ e.createElement(n, { as: "span", size: "1", weight: "medium", color: "gray", width: "36", mt: "1" }, "Data"), /* @__PURE__ */ e.createElement(r, { rounded: "2", overflow: "auto", backgroundColor: "surface-2", border: "px", p: "1", style: {
|
|
16
|
+
flex: 1,
|
|
17
|
+
minWidth: 0,
|
|
18
|
+
minHeight: "50px",
|
|
33
19
|
maxHeight: "200px"
|
|
34
20
|
} }, /* @__PURE__ */ e.createElement("pre", { style: {
|
|
35
21
|
fontSize: "11px",
|
|
36
22
|
margin: 0
|
|
37
|
-
} }, /* @__PURE__ */ e.createElement("code", null, JSON.stringify(
|
|
23
|
+
} }, /* @__PURE__ */ e.createElement("code", null, t.targetParams.data ? JSON.stringify(t.targetParams.data, null, 2) : "-"))))));
|
|
38
24
|
};
|
|
39
25
|
export {
|
|
40
|
-
|
|
26
|
+
d as GuideContextDetails
|
|
41
27
|
};
|
|
42
28
|
//# sourceMappingURL=GuideContextDetails.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuideContextDetails.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/GuideContextDetails.tsx"],"sourcesContent":["import { useGuideContext
|
|
1
|
+
{"version":3,"file":"GuideContextDetails.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/GuideContextDetails.tsx"],"sourcesContent":["import { useGuideContext } from \"@knocklabs/react-core\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport { Text } from \"@telegraph/typography\";\n\nexport const GuideContextDetails = () => {\n const { client } = useGuideContext();\n\n return (\n <Box py=\"3\" px=\"3\">\n <Text as=\"span\" size=\"1\" weight=\"medium\">\n Target params\n </Text>\n <Stack direction=\"column\" gap=\"2\" mt=\"2\">\n <Stack direction=\"row\" gap=\"2\" align=\"center\">\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color=\"gray\"\n width=\"36\"\n mt=\"1\"\n >\n Tenant\n </Text>\n <Box\n rounded=\"2\"\n overflow=\"auto\"\n backgroundColor=\"surface-2\"\n border=\"px\"\n p=\"1\"\n style={{ flex: 1, minWidth: 0 }}\n >\n <pre style={{ fontSize: \"11px\", margin: 0 }}>\n <code>{client.targetParams.tenant || \"-\"}</code>\n </pre>\n </Box>\n </Stack>\n <Stack direction=\"row\" gap=\"2\" align=\"flex-start\">\n <Text\n as=\"span\"\n size=\"1\"\n weight=\"medium\"\n color=\"gray\"\n width=\"36\"\n mt=\"1\"\n >\n Data\n </Text>\n <Box\n rounded=\"2\"\n overflow=\"auto\"\n backgroundColor=\"surface-2\"\n border=\"px\"\n p=\"1\"\n style={{\n flex: 1,\n minWidth: 0,\n minHeight: \"50px\",\n maxHeight: \"200px\",\n }}\n >\n <pre style={{ fontSize: \"11px\", margin: 0 }}>\n <code>\n {client.targetParams.data\n ? JSON.stringify(client.targetParams.data, null, 2)\n : \"-\"}\n </code>\n </pre>\n </Box>\n </Stack>\n </Stack>\n </Box>\n );\n};\n"],"names":["GuideContextDetails","client","useGuideContext","React","Box","Text","Stack","flex","minWidth","fontSize","margin","targetParams","tenant","minHeight","maxHeight","data","JSON","stringify"],"mappings":";;;;A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