@ekanos/sdk 0.19.0 → 0.20.0
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/api-report.md +23 -4
- package/dist/components/base-activation-dialog.js +1 -1
- package/dist/components/base-activation-dialog.js.map +1 -1
- package/dist/components/current-return-path.d.ts +16 -1
- package/dist/components/current-return-path.js +18 -1
- package/dist/components/current-return-path.js.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/oauth-activation-form.js +2 -2
- package/dist/components/oauth-activation-form.js.map +1 -1
- package/dist/components/widgets/ai-prompt-chip.js +1 -1
- package/dist/components/widgets/ai-prompt-chip.js.map +1 -1
- package/dist/components/widgets/widget-ask-bar.js +2 -2
- package/dist/components/widgets/widget-ask-bar.js.map +1 -1
- package/dist/components/widgets/widget-state-components.js +1 -1
- package/dist/components/widgets/widget-state-components.js.map +1 -1
- package/dist/components/widgets/widget.js +2 -2
- package/dist/components/widgets/widget.js.map +1 -1
- package/dist/experience/define-experience.d.ts +69 -4
- package/dist/experience/define-experience.js +48 -8
- package/dist/experience/define-experience.js.map +1 -1
- package/dist/experience/index.d.ts +2 -1
- package/dist/experience/index.js +1 -0
- package/dist/experience/index.js.map +1 -1
- package/dist/hooks/use-oauth-connection-status.d.ts +7 -217
- package/dist/hooks/use-oauth-connection-status.js +17 -1
- package/dist/hooks/use-oauth-connection-status.js.map +1 -1
- package/dist/types/integration.d.ts +3 -3
- package/dist/types/integration.js.map +1 -1
- package/eslint.design-rules.mjs +18 -0
- package/package.json +3 -3
package/api-report.md
CHANGED
|
@@ -9,7 +9,7 @@ This is the complete surface of every entrypoint. The authoring guide
|
|
|
9
9
|
for these symbols is README.md. Entrypoints marked WORKSPACE-ONLY are
|
|
10
10
|
not reachable from a published install — see the note in each section.
|
|
11
11
|
|
|
12
|
-
Total exported names: **
|
|
12
|
+
Total exported names: **345** across 12 entrypoints.
|
|
13
13
|
|
|
14
14
|
## `@ekanos/sdk` (37 exports)
|
|
15
15
|
|
|
@@ -53,7 +53,7 @@ Total exported names: **326** across 12 entrypoints.
|
|
|
53
53
|
| `WidgetVerdictTone` | type alias |
|
|
54
54
|
| `WorkspaceTargetDefinition` | interface |
|
|
55
55
|
|
|
56
|
-
## `@ekanos/sdk/components` (
|
|
56
|
+
## `@ekanos/sdk/components` (35 exports)
|
|
57
57
|
|
|
58
58
|
| Export | Kind |
|
|
59
59
|
| --- | --- |
|
|
@@ -66,6 +66,7 @@ Total exported names: **326** across 12 entrypoints.
|
|
|
66
66
|
| `BaseActivationFormProps` | interface |
|
|
67
67
|
| `BaseMarketplaceTile` | function |
|
|
68
68
|
| `BaseMarketplaceTileProps` | type alias |
|
|
69
|
+
| `FIRST_CONNECT_PARAM` | variable |
|
|
69
70
|
| `OAuthActivationForm` | function |
|
|
70
71
|
| `OAuthActivationFormConfig` | interface |
|
|
71
72
|
| `Widget` | variable |
|
|
@@ -315,19 +316,30 @@ Total exported names: **326** across 12 entrypoints.
|
|
|
315
316
|
| `snapFullWidthToRowBoundary` | function |
|
|
316
317
|
| `splitBalanced` | function |
|
|
317
318
|
|
|
318
|
-
## `@ekanos/sdk/experience` (
|
|
319
|
+
## `@ekanos/sdk/experience` (66 exports)
|
|
319
320
|
|
|
320
321
|
| Export | Kind |
|
|
321
322
|
| --- | --- |
|
|
322
323
|
| `AiStep` | interface |
|
|
323
324
|
| `ApprovalStep` | interface |
|
|
324
325
|
| `ApprovalToken` | interface |
|
|
326
|
+
| `EXPERIENCE_PAGE_KINDS` | variable |
|
|
327
|
+
| `ExperienceCanvasPageInput` | interface |
|
|
328
|
+
| `ExperienceCustomPageInput` | interface |
|
|
325
329
|
| `ExperienceDefinition` | interface |
|
|
326
330
|
| `ExperienceInput` | interface |
|
|
327
|
-
| `
|
|
331
|
+
| `ExperienceOverviewPageInput` | interface |
|
|
332
|
+
| `ExperiencePage` | type alias |
|
|
333
|
+
| `ExperiencePageInput` | type alias |
|
|
334
|
+
| `ExperiencePageKind` | type alias |
|
|
335
|
+
| `ExperiencePageProps` | interface |
|
|
336
|
+
| `ExperiencePageRoute` | interface |
|
|
328
337
|
| `ExperienceReviewQueue` | interface |
|
|
329
338
|
| `ExperienceRuntime` | interface |
|
|
330
339
|
| `ExperienceSidebar` | interface |
|
|
340
|
+
| `ExperienceSuggestedLayout` | type alias |
|
|
341
|
+
| `ExperienceSurfaces` | type alias |
|
|
342
|
+
| `ExperienceSurfacesSchema` | variable |
|
|
331
343
|
| `ExperienceWidget` | interface |
|
|
332
344
|
| `ExperienceWidgetWidth` | type alias |
|
|
333
345
|
| `InputArgs` | type alias |
|
|
@@ -337,6 +349,8 @@ Total exported names: **326** across 12 entrypoints.
|
|
|
337
349
|
| `IntegrationProvenance` | type alias |
|
|
338
350
|
| `IntegrationRegistry` | interface |
|
|
339
351
|
| `IntegrationShape` | interface |
|
|
352
|
+
| `LayoutItem` | type alias |
|
|
353
|
+
| `LayoutWorkspace` | type alias |
|
|
340
354
|
| `OPERATION_REFUSAL_REASONS` | variable |
|
|
341
355
|
| `OperationCallRequest` | interface |
|
|
342
356
|
| `OperationChannel` | type alias |
|
|
@@ -352,6 +366,8 @@ Total exported names: **326** across 12 entrypoints.
|
|
|
352
366
|
| `ReviewQueueSection` | type alias |
|
|
353
367
|
| `SerializeWorkflowOptions` | interface |
|
|
354
368
|
| `StepOptions` | interface |
|
|
369
|
+
| `SuggestedLayout` | type alias |
|
|
370
|
+
| `SuggestedLayoutSchema` | variable |
|
|
355
371
|
| `TEMPLATE_INSTALLATION_ID` | variable |
|
|
356
372
|
| `ToolStep` | interface |
|
|
357
373
|
| `WithRefs` | type alias |
|
|
@@ -363,10 +379,13 @@ Total exported names: **326** across 12 entrypoints.
|
|
|
363
379
|
| `WriteOperationKey` | type alias |
|
|
364
380
|
| `defineExperience` | function |
|
|
365
381
|
| `defineWorkflowTemplate` | function |
|
|
382
|
+
| `layoutAudienceNames` | function |
|
|
366
383
|
| `ref` | function |
|
|
384
|
+
| `resolveLayoutForAudience` | function |
|
|
367
385
|
| `serializeWorkflowTemplate` | function |
|
|
368
386
|
| `slotsUsedBy` | function |
|
|
369
387
|
| `step` | variable |
|
|
388
|
+
| `surfaceProblems` | function |
|
|
370
389
|
|
|
371
390
|
## `@ekanos/sdk/experience/client` (10 exports)
|
|
372
391
|
|
|
@@ -16,7 +16,7 @@ function ErrorAlert({ error }) {
|
|
|
16
16
|
return (_jsx(Alert, { variant: "destructive", role: "alert", children: _jsx(AlertDescription, { children: error }) }));
|
|
17
17
|
}
|
|
18
18
|
function LoadingOverlay() {
|
|
19
|
-
return (_jsx("div", { className: "bg-background/80 fixed inset-0 z-50 flex items-center justify-center", children: _jsxs("div", { className: "flex flex-col items-center gap-2", children: [_jsx(Icon, { name: "fa-spinner-third", className: "text-
|
|
19
|
+
return (_jsx("div", { className: "bg-background/80 fixed inset-0 z-50 flex items-center justify-center", children: _jsxs("div", { className: "flex flex-col items-center gap-2", children: [_jsx(Icon, { name: "fa-spinner-third", className: "text-muted-foreground h-8 w-8 animate-spin" }), _jsx("span", { className: "text-muted-foreground text-meta", children: "Loading..." })] }) }));
|
|
20
20
|
}
|
|
21
21
|
export function BaseActivationDialog({ isOpen, onClose, title, description, children, isLoading = false, error = null, success = false, successTitle, successMessage, onSuccessClose, maxWidth = 'sm:max-w-[600px]', inline = false, }) {
|
|
22
22
|
const handleClose = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-activation-dialog.js","sourceRoot":"","sources":["../../src/components/base-activation-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EACL,MAAM,EACN,aAAa,EACb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IAAI,OAAO,EAAE,YAC9D,MAAC,aAAa,IAAC,SAAS,EAAE,GAAG,QAAQ,+BAA+B,aAClE,MAAC,YAAY,eACX,KAAC,WAAW,cAAE,KAAK,GAAe,EAClC,KAAC,iBAAiB,cAAE,WAAW,GAAqB,IACvC,EAEf,KAAC,EAAE,IAAC,SAAS,EAAE,CAAC,CAAC,KAAK,YACpB,KAAC,UAAU,IAAC,KAAK,EAAE,KAAM,GAAI,GAC1B,EAEL,KAAC,EAAE,IAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,YACxC,KAAC,cAAc,IACb,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,aAAa,SACb,GACC,EAEJ,SAAS,IAAI,KAAC,cAAc,KAAG,IAClB,GACT,CACV,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { ReactNode, useEffect, useRef } from 'react';\n\nimport { Alert, AlertDescription } from '@ekanos/ui/alert';\nimport { Button } from '@ekanos/ui/button';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from '@ekanos/ui/dialog';\nimport { Icon } from '@ekanos/ui/icon';\nimport { If } from '@ekanos/ui/if';\nimport { Separator } from '@ekanos/ui/separator';\nimport { Trans } from '@ekanos/ui/trans';\nimport { cn } from '@ekanos/ui/utils';\n\ninterface BaseActivationDialogProps {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n description: string;\n children: ReactNode;\n isLoading?: boolean;\n error?: string | null;\n success?: boolean;\n successTitle?: string;\n successMessage?: string;\n onSuccessClose?: () => void;\n maxWidth?: string;\n /** @deprecated Use `ActivationInline` instead for inline rendering */\n inline?: boolean;\n}\n\nfunction SuccessContent({\n successTitle = 'Integration Activated!',\n successMessage = 'Your integration is now active and ready to use.',\n onClose,\n showSeparator = false,\n}: {\n successTitle?: string;\n successMessage?: string;\n onClose: () => void;\n showSeparator?: boolean;\n}) {\n return (\n <div className=\"flex flex-col items-center space-y-4 py-6\">\n <div className=\"bg-success/10 flex h-16 w-16 items-center justify-center rounded-full\">\n <Icon name=\"fa-circle-check\" className=\"text-success h-8 w-8\" />\n </div>\n <div className=\"text-center\">\n <h3 className=\"text-subhead\">{successTitle}</h3>\n <p className=\"text-muted-foreground text-meta mt-1\">{successMessage}</p>\n </div>\n {showSeparator && <Separator />}\n <div className=\"flex gap-2\">\n {showSeparator && (\n <Button variant=\"outline\" onClick={onClose}>\n <Trans\n i18nKey=\"common:stayOnMarketplace\"\n defaults=\"Stay on Marketplace\"\n />\n </Button>\n )}\n <Button onClick={onClose}>\n <Trans i18nKey=\"common:continue\" defaults=\"Continue\" />\n </Button>\n </div>\n </div>\n );\n}\n\nfunction ErrorAlert({ error }: { error: string }) {\n return (\n <Alert variant=\"destructive\" role=\"alert\">\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n );\n}\n\nfunction LoadingOverlay() {\n return (\n <div className=\"bg-background/80 fixed inset-0 z-50 flex items-center justify-center\">\n <div className=\"flex flex-col items-center gap-2\">\n <Icon\n name=\"fa-spinner-third\"\n className=\"text-primary h-8 w-8 animate-spin\"\n />\n <span className=\"text-muted-foreground text-meta\">Loading...</span>\n </div>\n </div>\n );\n}\n\nexport function BaseActivationDialog({\n isOpen,\n onClose,\n title,\n description,\n children,\n isLoading = false,\n error = null,\n success = false,\n successTitle,\n successMessage,\n onSuccessClose,\n maxWidth = 'sm:max-w-[600px]',\n inline = false,\n}: BaseActivationDialogProps) {\n const handleClose = () => {\n if (success && onSuccessClose) {\n onSuccessClose();\n } else {\n onClose();\n }\n };\n\n if (inline) {\n return (\n <ActivationInline\n isLoading={isLoading}\n error={error}\n success={success}\n onSuccessClose={success ? handleClose : undefined}\n >\n {children}\n </ActivationInline>\n );\n }\n\n return (\n <ActivationDialog\n isOpen={isOpen}\n onClose={handleClose}\n title={title}\n description={description}\n isLoading={isLoading}\n error={error}\n success={success}\n successTitle={successTitle}\n successMessage={successMessage}\n maxWidth={maxWidth}\n >\n {children}\n </ActivationDialog>\n );\n}\n\n// --- Explicit Variants ---\n\n/**\n * The form's body when it sits inside chrome the HOST owns (the connect\n * dialog, the workspace notice, first-use). The host already shows the\n * integration's name, what it does and what it can access, and it owns\n * the success moment (it closes and toasts) — so this renders the fields,\n * the error, and nothing else.\n *\n * `success` is a hand-off, not a screen: the moment it turns true,\n * `onSuccessClose` runs once, which is what lets a form written for the\n * old \"Continue\" panel finish the same way as one that reports success\n * directly. Nothing renders after it fires; the host takes over.\n */\nexport function ActivationInline({\n isLoading = false,\n error = null,\n success = false,\n onSuccessClose,\n children,\n}: {\n isLoading?: boolean;\n error?: string | null;\n success?: boolean;\n onSuccessClose?: () => void;\n children: ReactNode;\n}) {\n const handedOff = useRef(false);\n\n // Hands the success state to the host exactly once. An effect is the\n // right tool here: this reacts to a state transition that the form's own\n // submit handler set, and the host callback it calls navigates.\n useEffect(() => {\n if (!success || !onSuccessClose || handedOff.current) return;\n\n handedOff.current = true;\n onSuccessClose();\n }, [success, onSuccessClose]);\n\n if (success) {\n return null;\n }\n\n return (\n <div\n className={cn('flex flex-col gap-4', isLoading && 'opacity-70')}\n aria-busy={isLoading}\n >\n <If condition={!!error}>\n <ErrorAlert error={error!} />\n </If>\n {children}\n </div>\n );\n}\n\nexport function ActivationDialog({\n isOpen,\n onClose,\n title,\n description,\n children,\n isLoading = false,\n error = null,\n success = false,\n successTitle,\n successMessage,\n maxWidth = 'sm:max-w-[600px]',\n}: {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n description: string;\n children: ReactNode;\n isLoading?: boolean;\n error?: string | null;\n success?: boolean;\n successTitle?: string;\n successMessage?: string;\n maxWidth?: string;\n}) {\n return (\n <Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>\n <DialogContent className={`${maxWidth} max-h-[80vh] overflow-y-auto`}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n\n <If condition={!!error}>\n <ErrorAlert error={error!} />\n </If>\n\n <If condition={success} fallback={children}>\n <SuccessContent\n successTitle={successTitle}\n successMessage={successMessage}\n onClose={onClose}\n showSeparator\n />\n </If>\n\n {isLoading && <LoadingOverlay />}\n </DialogContent>\n </Dialog>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-activation-dialog.js","sourceRoot":"","sources":["../../src/components/base-activation-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAmBtC,SAAS,cAAc,CAAC,EACtB,YAAY,GAAG,wBAAwB,EACvC,cAAc,GAAG,kDAAkD,EACnE,OAAO,EACP,aAAa,GAAG,KAAK,GAMtB;IACC,OAAO,CACL,eAAK,SAAS,EAAC,2CAA2C,aACxD,cAAK,SAAS,EAAC,uEAAuE,YACpF,KAAC,IAAI,IAAC,IAAI,EAAC,iBAAiB,EAAC,SAAS,EAAC,sBAAsB,GAAG,GAC5D,EACN,eAAK,SAAS,EAAC,aAAa,aAC1B,aAAI,SAAS,EAAC,cAAc,YAAE,YAAY,GAAM,EAChD,YAAG,SAAS,EAAC,sCAAsC,YAAE,cAAc,GAAK,IACpE,EAC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AY,CAAC,eACpD,SAAS,aAEpB,KAAC,EAAE,IAAC,SAAS,EAAE,CAAC,CAAC,KAAK,YACpB,KAAC,UAAU,IAAC,KAAK,EAAE,KAAM,GAAI,GAC1B,EACJ,QAAQ,IACL,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,OAAO,EACP,KAAK,EACL,WAAW,EACX,QAAQ,EACR,SAAS,GAAG,KAAK,EACjB,KAAK,GAAG,IAAI,EACZ,OAAO,GAAG,KAAK,EACf,YAAY,EACZ,cAAc,EACd,QAAQ,GAAG,kBAAkB,GAa9B;IACC,OAAO,CACL,KAAC,MAAM,IAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,OAAO,EAAE,YAC9D,MAAC,aAAa,IAAC,SAAS,EAAE,GAAG,QAAQ,+BAA+B,aAClE,MAAC,YAAY,eACX,KAAC,WAAW,cAAE,KAAK,GAAe,EAClC,KAAC,iBAAiB,cAAE,WAAW,GAAqB,IACvC,EAEf,KAAC,EAAE,IAAC,SAAS,EAAE,CAAC,CAAC,KAAK,YACpB,KAAC,UAAU,IAAC,KAAK,EAAE,KAAM,GAAI,GAC1B,EAEL,KAAC,EAAE,IAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,YACxC,KAAC,cAAc,IACb,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,aAAa,SACb,GACC,EAEJ,SAAS,IAAI,KAAC,cAAc,KAAG,IAClB,GACT,CACV,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { ReactNode, useEffect, useRef } from 'react';\n\nimport { Alert, AlertDescription } from '@ekanos/ui/alert';\nimport { Button } from '@ekanos/ui/button';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from '@ekanos/ui/dialog';\nimport { Icon } from '@ekanos/ui/icon';\nimport { If } from '@ekanos/ui/if';\nimport { Separator } from '@ekanos/ui/separator';\nimport { Trans } from '@ekanos/ui/trans';\nimport { cn } from '@ekanos/ui/utils';\n\ninterface BaseActivationDialogProps {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n description: string;\n children: ReactNode;\n isLoading?: boolean;\n error?: string | null;\n success?: boolean;\n successTitle?: string;\n successMessage?: string;\n onSuccessClose?: () => void;\n maxWidth?: string;\n /** @deprecated Use `ActivationInline` instead for inline rendering */\n inline?: boolean;\n}\n\nfunction SuccessContent({\n successTitle = 'Integration Activated!',\n successMessage = 'Your integration is now active and ready to use.',\n onClose,\n showSeparator = false,\n}: {\n successTitle?: string;\n successMessage?: string;\n onClose: () => void;\n showSeparator?: boolean;\n}) {\n return (\n <div className=\"flex flex-col items-center space-y-4 py-6\">\n <div className=\"bg-success/10 flex h-16 w-16 items-center justify-center rounded-full\">\n <Icon name=\"fa-circle-check\" className=\"text-success h-8 w-8\" />\n </div>\n <div className=\"text-center\">\n <h3 className=\"text-subhead\">{successTitle}</h3>\n <p className=\"text-muted-foreground text-meta mt-1\">{successMessage}</p>\n </div>\n {showSeparator && <Separator />}\n <div className=\"flex gap-2\">\n {showSeparator && (\n <Button variant=\"outline\" onClick={onClose}>\n <Trans\n i18nKey=\"common:stayOnMarketplace\"\n defaults=\"Stay on Marketplace\"\n />\n </Button>\n )}\n <Button onClick={onClose}>\n <Trans i18nKey=\"common:continue\" defaults=\"Continue\" />\n </Button>\n </div>\n </div>\n );\n}\n\nfunction ErrorAlert({ error }: { error: string }) {\n return (\n <Alert variant=\"destructive\" role=\"alert\">\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n );\n}\n\nfunction LoadingOverlay() {\n return (\n <div className=\"bg-background/80 fixed inset-0 z-50 flex items-center justify-center\">\n <div className=\"flex flex-col items-center gap-2\">\n <Icon\n name=\"fa-spinner-third\"\n className=\"text-muted-foreground h-8 w-8 animate-spin\"\n />\n <span className=\"text-muted-foreground text-meta\">Loading...</span>\n </div>\n </div>\n );\n}\n\nexport function BaseActivationDialog({\n isOpen,\n onClose,\n title,\n description,\n children,\n isLoading = false,\n error = null,\n success = false,\n successTitle,\n successMessage,\n onSuccessClose,\n maxWidth = 'sm:max-w-[600px]',\n inline = false,\n}: BaseActivationDialogProps) {\n const handleClose = () => {\n if (success && onSuccessClose) {\n onSuccessClose();\n } else {\n onClose();\n }\n };\n\n if (inline) {\n return (\n <ActivationInline\n isLoading={isLoading}\n error={error}\n success={success}\n onSuccessClose={success ? handleClose : undefined}\n >\n {children}\n </ActivationInline>\n );\n }\n\n return (\n <ActivationDialog\n isOpen={isOpen}\n onClose={handleClose}\n title={title}\n description={description}\n isLoading={isLoading}\n error={error}\n success={success}\n successTitle={successTitle}\n successMessage={successMessage}\n maxWidth={maxWidth}\n >\n {children}\n </ActivationDialog>\n );\n}\n\n// --- Explicit Variants ---\n\n/**\n * The form's body when it sits inside chrome the HOST owns (the connect\n * dialog, the workspace notice, first-use). The host already shows the\n * integration's name, what it does and what it can access, and it owns\n * the success moment (it closes and toasts) — so this renders the fields,\n * the error, and nothing else.\n *\n * `success` is a hand-off, not a screen: the moment it turns true,\n * `onSuccessClose` runs once, which is what lets a form written for the\n * old \"Continue\" panel finish the same way as one that reports success\n * directly. Nothing renders after it fires; the host takes over.\n */\nexport function ActivationInline({\n isLoading = false,\n error = null,\n success = false,\n onSuccessClose,\n children,\n}: {\n isLoading?: boolean;\n error?: string | null;\n success?: boolean;\n onSuccessClose?: () => void;\n children: ReactNode;\n}) {\n const handedOff = useRef(false);\n\n // Hands the success state to the host exactly once. An effect is the\n // right tool here: this reacts to a state transition that the form's own\n // submit handler set, and the host callback it calls navigates.\n useEffect(() => {\n if (!success || !onSuccessClose || handedOff.current) return;\n\n handedOff.current = true;\n onSuccessClose();\n }, [success, onSuccessClose]);\n\n if (success) {\n return null;\n }\n\n return (\n <div\n className={cn('flex flex-col gap-4', isLoading && 'opacity-70')}\n aria-busy={isLoading}\n >\n <If condition={!!error}>\n <ErrorAlert error={error!} />\n </If>\n {children}\n </div>\n );\n}\n\nexport function ActivationDialog({\n isOpen,\n onClose,\n title,\n description,\n children,\n isLoading = false,\n error = null,\n success = false,\n successTitle,\n successMessage,\n maxWidth = 'sm:max-w-[600px]',\n}: {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n description: string;\n children: ReactNode;\n isLoading?: boolean;\n error?: string | null;\n success?: boolean;\n successTitle?: string;\n successMessage?: string;\n maxWidth?: string;\n}) {\n return (\n <Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>\n <DialogContent className={`${maxWidth} max-h-[80vh] overflow-y-auto`}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n\n <If condition={!!error}>\n <ErrorAlert error={error!} />\n </If>\n\n <If condition={success} fallback={children}>\n <SuccessContent\n successTitle={successTitle}\n successMessage={successMessage}\n onClose={onClose}\n showSeparator\n />\n </If>\n\n {isLoading && <LoadingOverlay />}\n </DialogContent>\n </Dialog>\n );\n}\n"]}
|
|
@@ -16,4 +16,19 @@
|
|
|
16
16
|
* Any NEW OAuth-style activation form must use this rather than reaching for
|
|
17
17
|
* `window.location.pathname` again.
|
|
18
18
|
*/
|
|
19
|
-
export declare function currentReturnPath(fallback?: string
|
|
19
|
+
export declare function currentReturnPath(fallback?: string, options?: {
|
|
20
|
+
firstConnect?: string;
|
|
21
|
+
}): string;
|
|
22
|
+
/**
|
|
23
|
+
* `?first_connect=<slug>` — the sign-in this return comes back from was a
|
|
24
|
+
* FIRST connect, not a reconnect.
|
|
25
|
+
*
|
|
26
|
+
* Most OAuth callbacks save the activation themselves before redirecting, so
|
|
27
|
+
* by the time the page renders the tool already reads as connected and a host
|
|
28
|
+
* deciding from that alone opens its manage view: the success then says
|
|
29
|
+
* "reconnected", or the frame is not mounted at all. Only the form knew which
|
|
30
|
+
* it was when it left, so it says so in the return path. Unlike
|
|
31
|
+
* `oauth_success`, which the connection hook strips on mount, this stays until
|
|
32
|
+
* the frame closes, so a refresh behind the success view keeps the answer.
|
|
33
|
+
*/
|
|
34
|
+
export declare const FIRST_CONNECT_PARAM = "first_connect";
|
|
@@ -16,11 +16,28 @@
|
|
|
16
16
|
* Any NEW OAuth-style activation form must use this rather than reaching for
|
|
17
17
|
* `window.location.pathname` again.
|
|
18
18
|
*/
|
|
19
|
-
export function currentReturnPath(fallback = '/home') {
|
|
19
|
+
export function currentReturnPath(fallback = '/home', options = {}) {
|
|
20
20
|
if (typeof window === 'undefined')
|
|
21
21
|
return fallback;
|
|
22
22
|
const url = new URL(window.location.href);
|
|
23
23
|
url.searchParams.delete('oauth_success');
|
|
24
|
+
url.searchParams.delete(FIRST_CONNECT_PARAM);
|
|
25
|
+
if (options.firstConnect) {
|
|
26
|
+
url.searchParams.set(FIRST_CONNECT_PARAM, options.firstConnect);
|
|
27
|
+
}
|
|
24
28
|
return `${url.pathname}${url.search}`;
|
|
25
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* `?first_connect=<slug>` — the sign-in this return comes back from was a
|
|
32
|
+
* FIRST connect, not a reconnect.
|
|
33
|
+
*
|
|
34
|
+
* Most OAuth callbacks save the activation themselves before redirecting, so
|
|
35
|
+
* by the time the page renders the tool already reads as connected and a host
|
|
36
|
+
* deciding from that alone opens its manage view: the success then says
|
|
37
|
+
* "reconnected", or the frame is not mounted at all. Only the form knew which
|
|
38
|
+
* it was when it left, so it says so in the return path. Unlike
|
|
39
|
+
* `oauth_success`, which the connection hook strips on mount, this stays until
|
|
40
|
+
* the frame closes, so a refresh behind the success view keeps the answer.
|
|
41
|
+
*/
|
|
42
|
+
export const FIRST_CONNECT_PARAM = 'first_connect';
|
|
26
43
|
//# sourceMappingURL=current-return-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current-return-path.js","sourceRoot":"","sources":["../../src/components/current-return-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,iBAAiB,
|
|
1
|
+
{"version":3,"file":"current-return-path.js","sourceRoot":"","sources":["../../src/components/current-return-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAQ,GAAG,OAAO,EAClB,OAAO,GAA8B,EAAE;IAEvC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,QAAQ,CAAC;IAEnD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACzC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAE7C,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACzB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,GAAG,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC","sourcesContent":["/**\n * The path an OAuth connect route should send the browser back to.\n *\n * Includes the QUERY STRING, which every call site used to drop by reading\n * `window.location.pathname` alone. That mattered the moment activation moved\n * into a modal addressed by `?integration=<slug>` (plan 067): the browser has\n * to land back on a URL that re-opens the modal, because the activation form\n * is what reads `?oauth_success=true` on mount and auto-activates\n * (`use-oauth-connection-status.ts`). Return to a bare path and the provider\n * token is stored while the integration is silently never activated — no\n * error, no toast, the row just stays \"Ready to connect\".\n *\n * `oauth_success` is stripped so a retry after a completed round-trip does\n * not ask the next return to re-announce a stale success.\n *\n * Any NEW OAuth-style activation form must use this rather than reaching for\n * `window.location.pathname` again.\n */\nexport function currentReturnPath(\n fallback = '/home',\n options: { firstConnect?: string } = {},\n): string {\n if (typeof window === 'undefined') return fallback;\n\n const url = new URL(window.location.href);\n url.searchParams.delete('oauth_success');\n url.searchParams.delete(FIRST_CONNECT_PARAM);\n\n if (options.firstConnect) {\n url.searchParams.set(FIRST_CONNECT_PARAM, options.firstConnect);\n }\n\n return `${url.pathname}${url.search}`;\n}\n\n/**\n * `?first_connect=<slug>` — the sign-in this return comes back from was a\n * FIRST connect, not a reconnect.\n *\n * Most OAuth callbacks save the activation themselves before redirecting, so\n * by the time the page renders the tool already reads as connected and a host\n * deciding from that alone opens its manage view: the success then says\n * \"reconnected\", or the frame is not mounted at all. Only the form knew which\n * it was when it left, so it says so in the return path. Unlike\n * `oauth_success`, which the connection hook strips on mount, this stays until\n * the frame closes, so a refresh behind the success view keeps the answer.\n */\nexport const FIRST_CONNECT_PARAM = 'first_connect';\n"]}
|
|
@@ -40,4 +40,4 @@ export { BaseMarketplaceTile } from './base-marketplace-tile.js';
|
|
|
40
40
|
export type { BaseMarketplaceTileProps } from './base-marketplace-tile.js';
|
|
41
41
|
export { OAuthActivationForm } from './oauth-activation-form.js';
|
|
42
42
|
export type { OAuthActivationFormConfig } from './oauth-activation-form.js';
|
|
43
|
-
export { currentReturnPath } from './current-return-path.js';
|
|
43
|
+
export { FIRST_CONNECT_PARAM, currentReturnPath } from './current-return-path.js';
|
package/dist/components/index.js
CHANGED
|
@@ -36,5 +36,5 @@ export { BaseActivationForm } from './base-activation-form.js';
|
|
|
36
36
|
export { ActivationDialog, ActivationInline, BaseActivationDialog, } from './base-activation-dialog.js';
|
|
37
37
|
export { BaseMarketplaceTile } from './base-marketplace-tile.js';
|
|
38
38
|
export { OAuthActivationForm } from './oauth-activation-form.js';
|
|
39
|
-
export { currentReturnPath } from './current-return-path.js';
|
|
39
|
+
export { FIRST_CONNECT_PARAM, currentReturnPath } from './current-return-path.js';
|
|
40
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACL,MAAM,EACN,gBAAgB,GAEjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,GASd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,iBAAiB,EAEjB,mBAAmB,GAKpB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["/**\n * @ekanos/sdk/components — client-side building blocks.\n *\n * Import from client components only. `Widget` is the compound API every\n * dashboard widget renders through; the activation forms are the two\n * sanctioned activation UX bases (credential-style and OAuth-style), and\n * `BaseMarketplaceTile` is the matching base for the marketplace tile.\n *\n * The SDK OWNS these implementations — the pre-inversion re-exports through\n * `@kit/integrations-core/components/*` are gone; core now re-exports FROM\n * here for first-party code (one source of truth, two consumption paths —\n * one source of truth with two consumption paths. UI primitives come from\n * `@ekanos/ui`\n * (the published slice of the host design system), never `@kit/ui`.\n *\n * Server seam: nothing here imports a server module. `OAuthActivationForm`\n * performs activation through the host-injected actions seam\n * (`IntegrationActivationProvider`, @ekanos/sdk/hooks) — a server-action\n * REFERENCE bound by the host, not server code shipped to the browser.\n *\n * `WidgetContext` is the single context identity both sides share: the\n * host's `DashboardWidgetProvider` (host chrome — persistence callbacks,\n * config hierarchy) provides it, the SDK's `Widget.*` reads it.\n *\n * Surface discipline: additions require an entry in\n * api-report.md, regenerated by `pnpm --filter @ekanos/sdk api-report`.\n */\n\nexport {\n Widget,\n useWidgetVerdict,\n type WidgetHeaderTrailing,\n} from './widgets/widget';\nexport {\n WidgetContext,\n type WidgetActions,\n type WidgetContextValue,\n type WidgetData,\n type WidgetHealth,\n type WidgetMeta,\n type WidgetRenderState,\n type WidgetSource,\n type WidgetState,\n} from './widgets/widget-context';\nexport { WidgetPreviewProvider } from './widgets/widget-preview-provider';\n\nexport type { WidgetPreviewProviderProps } from './widgets/widget-preview-provider';\nexport { AiPromptChip } from './widgets/ai-prompt-chip';\nexport { AskIcon } from './widgets/ask-icon';\nexport { WidgetAskBar } from './widgets/widget-ask-bar';\nexport {\n WidgetDataLoading,\n type WidgetEmptyStateProps,\n WidgetInactiveState,\n type WidgetInactiveReason,\n type WidgetInactiveStateProps,\n type WidgetSkeletonVariant,\n type WidgetStateAction,\n} from './widgets/widget-state-components';\n\nexport { BaseActivationForm } from './base-activation-form';\nexport type { BaseActivationFormProps } from './base-activation-form';\nexport {\n ActivationDialog,\n ActivationInline,\n BaseActivationDialog,\n} from './base-activation-dialog';\n\nexport { BaseMarketplaceTile } from './base-marketplace-tile';\nexport type { BaseMarketplaceTileProps } from './base-marketplace-tile';\n\nexport { OAuthActivationForm } from './oauth-activation-form';\nexport type { OAuthActivationFormConfig } from './oauth-activation-form';\n\nexport { currentReturnPath } from './current-return-path';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACL,MAAM,EACN,gBAAgB,GAEjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,GASd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,iBAAiB,EAEjB,mBAAmB,GAKpB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["/**\n * @ekanos/sdk/components — client-side building blocks.\n *\n * Import from client components only. `Widget` is the compound API every\n * dashboard widget renders through; the activation forms are the two\n * sanctioned activation UX bases (credential-style and OAuth-style), and\n * `BaseMarketplaceTile` is the matching base for the marketplace tile.\n *\n * The SDK OWNS these implementations — the pre-inversion re-exports through\n * `@kit/integrations-core/components/*` are gone; core now re-exports FROM\n * here for first-party code (one source of truth, two consumption paths —\n * one source of truth with two consumption paths. UI primitives come from\n * `@ekanos/ui`\n * (the published slice of the host design system), never `@kit/ui`.\n *\n * Server seam: nothing here imports a server module. `OAuthActivationForm`\n * performs activation through the host-injected actions seam\n * (`IntegrationActivationProvider`, @ekanos/sdk/hooks) — a server-action\n * REFERENCE bound by the host, not server code shipped to the browser.\n *\n * `WidgetContext` is the single context identity both sides share: the\n * host's `DashboardWidgetProvider` (host chrome — persistence callbacks,\n * config hierarchy) provides it, the SDK's `Widget.*` reads it.\n *\n * Surface discipline: additions require an entry in\n * api-report.md, regenerated by `pnpm --filter @ekanos/sdk api-report`.\n */\n\nexport {\n Widget,\n useWidgetVerdict,\n type WidgetHeaderTrailing,\n} from './widgets/widget';\nexport {\n WidgetContext,\n type WidgetActions,\n type WidgetContextValue,\n type WidgetData,\n type WidgetHealth,\n type WidgetMeta,\n type WidgetRenderState,\n type WidgetSource,\n type WidgetState,\n} from './widgets/widget-context';\nexport { WidgetPreviewProvider } from './widgets/widget-preview-provider';\n\nexport type { WidgetPreviewProviderProps } from './widgets/widget-preview-provider';\nexport { AiPromptChip } from './widgets/ai-prompt-chip';\nexport { AskIcon } from './widgets/ask-icon';\nexport { WidgetAskBar } from './widgets/widget-ask-bar';\nexport {\n WidgetDataLoading,\n type WidgetEmptyStateProps,\n WidgetInactiveState,\n type WidgetInactiveReason,\n type WidgetInactiveStateProps,\n type WidgetSkeletonVariant,\n type WidgetStateAction,\n} from './widgets/widget-state-components';\n\nexport { BaseActivationForm } from './base-activation-form';\nexport type { BaseActivationFormProps } from './base-activation-form';\nexport {\n ActivationDialog,\n ActivationInline,\n BaseActivationDialog,\n} from './base-activation-dialog';\n\nexport { BaseMarketplaceTile } from './base-marketplace-tile';\nexport type { BaseMarketplaceTileProps } from './base-marketplace-tile';\n\nexport { OAuthActivationForm } from './oauth-activation-form';\nexport type { OAuthActivationFormConfig } from './oauth-activation-form';\n\nexport { FIRST_CONNECT_PARAM, currentReturnPath } from './current-return-path';\n"]}
|
|
@@ -35,7 +35,7 @@ export function OAuthActivationForm(props) {
|
|
|
35
35
|
setError(null);
|
|
36
36
|
const params = new URLSearchParams({
|
|
37
37
|
accountId,
|
|
38
|
-
returnPath: currentReturnPath(),
|
|
38
|
+
returnPath: currentReturnPath('/home', reconnect ? {} : { firstConnect: slug }),
|
|
39
39
|
});
|
|
40
40
|
// For a user-scoped integration `accountId` is the PERSONAL account (see
|
|
41
41
|
// the connect modal's scope-resolved id), which has no
|
|
@@ -46,7 +46,7 @@ export function OAuthActivationForm(props) {
|
|
|
46
46
|
params.set('teamAccountId', teamAccountId);
|
|
47
47
|
}
|
|
48
48
|
window.location.href = `${connectPath}?${params.toString()}`;
|
|
49
|
-
}, [accountId, teamAccountId, connectPath]);
|
|
49
|
+
}, [accountId, teamAccountId, connectPath, reconnect, slug]);
|
|
50
50
|
// Reports success exactly once, straight to the host — no in-form panel,
|
|
51
51
|
// no second call from a "Continue" button.
|
|
52
52
|
const handleActivate = useCallback(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-activation-form.js","sourceRoot":"","sources":["../../src/components/oauth-activation-form.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAEL,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAGL,wBAAwB,GACzB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAgD1D;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;;IACjE,MAAM,EACJ,MAAM,EACN,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,EAAE,eAAe,GAAG,KAAK,EAClC,MAAM,GAAG,KAAK,EACd,SAAS,GAAG,KAAK,GAClB,GAAG,KAAK,CAAC;IAEV,MAAM,EACJ,IAAI,EACJ,WAAW,EACX,KAAK,GAAG,WAAW,WAAW,EAAE,EAChC,WAAW,GAAG,EAAE,EAChB,WAAW,GAAG,qBAAq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IACJ,OAAO,EAAC,oCAAoC,EAC5C,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAC7B,QAAQ,EAAE,gBAAgB,WAAW,GAAG,GACxC,IACG,CACR,CAAC,CAAC,CAAC,CACF,KAAC,KAAK,IACJ,OAAO,EAAC,yCAAyC,EACjD,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAC7B,QAAQ,EAAE,qBAAqB,WAAW,sCAAsC,GAChF,CACH,YAGF,WAAW,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GACvB,CACtB,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { Icon } from '@ekanos/ui/icon';\nimport { Trans } from '@ekanos/ui/trans';\nimport { useForm } from 'react-hook-form';\n\nimport { useActivateIntegration } from '../hooks/use-activate-integration';\nimport {\n type ConnectionCheckAction,\n type OAuthErrorParam,\n useOAuthConnectionStatus,\n} from '../hooks/use-oauth-connection-status';\nimport type { ActivationFormProps } from '../types/integration';\nimport { BaseActivationForm } from './base-activation-form';\nimport { currentReturnPath } from './current-return-path';\n\nexport interface OAuthActivationFormConfig {\n /** Integration slug — used for activation, the connect route, and ids. */\n slug: string;\n /** Human name used in default button copy, e.g. 'QuickBooks'. */\n displayName: string;\n /** Shown only when the form renders its own dialog (never inline). */\n title?: string;\n /** Shown only when the form renders its own dialog (never inline). */\n description?: string;\n /** @deprecated The host owns the success moment; this is not shown inline. */\n successMessage?: string;\n /** @deprecated The host owns the success moment; this is not shown inline. */\n successTitle?: string;\n /** Defaults to `/api/integrations/<slug>/connect`. */\n connectPath?: string;\n /** @deprecated No banner renders on return; the host toasts instead. */\n connectedBanner?: string;\n /** Defaults to `Continue with <displayName>`. */\n connectButtonText?: ReactNode;\n /** Defaults to `Connect`. Only reachable with `autoActivateOnConnect: false`. */\n activateButtonText?: ReactNode;\n /** externalId is `<prefix>_<timestamp>`; prefix defaults to the slug. */\n externalIdPrefix?: string;\n /**\n * Whether returning from OAuth should immediately activate (default `true`).\n *\n * Set `false` for integrations that expose post-connect configuration — the\n * user needs a chance to review or change it before activating, which\n * auto-activation skips right past. Connecting then leaves the form on a\n * \"Connect\" button as a deliberate second step.\n */\n autoActivateOnConnect?: boolean;\n}\n\ntype OAuthActivationFormProps = ActivationFormProps & {\n config: OAuthActivationFormConfig;\n checkConnection: ConnectionCheckAction;\n errorParam?: OAuthErrorParam;\n /**\n * Fields to fill in AFTER signing in, for an integration with\n * `autoActivateOnConnect: false`. Rendered only once connected. Not a\n * place for feature lists or permission badges — the host shows those.\n */\n children?: ReactNode;\n};\n\n/**\n * Shared activation form for OAuth-backed integrations: one \"Continue with\n * X\" button that sends the browser to the integration's connect route, then\n * auto-activates once the redirect returns with a live connection.\n *\n * Integrations with real activation fields (API keys, domains, …) should\n * keep a bespoke form built on BaseActivationForm instead.\n */\nexport function OAuthActivationForm(props: OAuthActivationFormProps) {\n const {\n config,\n checkConnection,\n errorParam,\n children,\n accountId,\n sourceId,\n teamAccountId,\n onSuccess,\n onCancel,\n isLoading: externalLoading = false,\n inline = false,\n reconnect = false,\n } = props;\n\n const {\n slug,\n displayName,\n title = `Connect ${displayName}`,\n description = '',\n connectPath = `/api/integrations/${slug}/connect`,\n connectButtonText,\n activateButtonText,\n externalIdPrefix = slug,\n autoActivateOnConnect = true,\n } = config;\n\n const [error, setError] = useState<string | null>(null);\n const [activated, setActivated] = useState(false);\n\n const {\n data: connectionStatus,\n oauthJustCompleted,\n oauthError,\n isLoading: isCheckingConnection,\n } = useOAuthConnectionStatus(accountId, {\n connectionKey: `${slug}-connection`,\n checkConnection,\n errorParam,\n });\n\n const isConnected = connectionStatus?.isConnected ?? false;\n\n const form = useForm({ defaultValues: {} });\n\n const activateIntegration = useActivateIntegration();\n const { mutateAsync: activateMutateAsync } = activateIntegration;\n\n const startConnect = useCallback(() => {\n setError(null);\n const params = new URLSearchParams({\n accountId,\n returnPath: currentReturnPath(),\n });\n\n // For a user-scoped integration `accountId` is the PERSONAL account (see\n // the connect modal's scope-resolved id), which has no\n // source_id — so an OAuth callback cannot materialize workspaces from it\n // alone. Carry the team through as well; callbacks that don't read it\n // simply ignore the extra param.\n if (teamAccountId) {\n params.set('teamAccountId', teamAccountId);\n }\n\n window.location.href = `${connectPath}?${params.toString()}`;\n }, [accountId, teamAccountId, connectPath]);\n\n // Reports success exactly once, straight to the host — no in-form panel,\n // no second call from a \"Continue\" button.\n const handleActivate = useCallback(async () => {\n try {\n setError(null);\n await activateMutateAsync({\n accountId,\n sourceId,\n teamAccountId,\n integrationSlug: slug,\n activationData: {},\n });\n setActivated(true);\n\n onSuccess?.({\n success: true,\n externalId: `${externalIdPrefix}_${Date.now()}`,\n });\n } catch (err) {\n const errorMessage =\n err instanceof Error ? err.message : 'Activation failed';\n setError(errorMessage);\n }\n }, [\n accountId,\n sourceId,\n teamAccountId,\n slug,\n externalIdPrefix,\n activateMutateAsync,\n onSuccess,\n ]);\n\n const handleSubmit = useCallback(async () => {\n // A reconnect always goes back through sign-in — that is what issues\n // the fresh token — unless this render IS the return from it.\n if (!isConnected || (reconnect && !oauthJustCompleted)) {\n startConnect();\n return;\n }\n\n await handleActivate();\n }, [\n isConnected,\n reconnect,\n oauthJustCompleted,\n handleActivate,\n startConnect,\n ]);\n\n // Auto-activate after OAuth return, unless the integration opted out so the\n // user can review its post-connect configuration first.\n const hasAutoActivated = useRef(false);\n\n useEffect(() => {\n if (\n autoActivateOnConnect &&\n oauthJustCompleted &&\n isConnected &&\n !activated &&\n !activateIntegration.isPending &&\n !hasAutoActivated.current\n ) {\n hasAutoActivated.current = true;\n\n const id = requestAnimationFrame(() => {\n void handleActivate();\n });\n\n return () => cancelAnimationFrame(id);\n }\n }, [\n autoActivateOnConnect,\n oauthJustCompleted,\n isConnected,\n activated,\n activateIntegration.isPending,\n handleActivate,\n ]);\n\n const displayError = error || oauthError;\n\n // The round-trip is in flight from the moment the redirect lands until\n // activation reports back: the button reads as busy the whole way rather\n // than flashing \"Continue with X\" a second time.\n const finishing =\n autoActivateOnConnect && oauthJustCompleted && isConnected && !displayError;\n\n const signInAgain = reconnect && !oauthJustCompleted;\n\n const buttonText = signInAgain\n ? (connectButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.reconnectWith\"\n values={{ name: displayName }}\n defaults={`Reconnect with ${displayName}`}\n />\n ))\n : isConnected\n ? (activateButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.connect\"\n defaults=\"Connect\"\n />\n ))\n : (connectButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.continueWith\"\n values={{ name: displayName }}\n defaults={`Continue with ${displayName}`}\n />\n ));\n\n return (\n <BaseActivationForm\n isOpen={true}\n inline={inline}\n onClose={() => onCancel?.()}\n title={title}\n description={description}\n form={form}\n onSubmit={handleSubmit}\n isLoading={externalLoading || activateIntegration.isPending || finishing}\n error={displayError}\n submitButtonText={buttonText}\n submitButtonLoadingText={\n isConnected && !signInAgain ? (\n <Trans\n i18nKey=\"common:integrationConnect.finishing\"\n defaults=\"Finishing setup…\"\n />\n ) : (\n <Trans\n i18nKey=\"common:integrationConnect.redirecting\"\n defaults=\"Opening sign-in…\"\n />\n )\n }\n submitButtonDisabled={isCheckingConnection}\n footnote={\n signInAgain ? (\n <Trans\n i18nKey=\"common:integrationConnect.reconnectFootnote\"\n values={{ name: displayName }}\n defaults={`You'll sign in on ${displayName}'s site again and come straight back here.`}\n />\n ) : isConnected ? (\n <span className=\"inline-flex items-center gap-1.5\">\n <Icon name=\"fa-circle-check\" className=\"text-success h-4 w-4\" />\n <Trans\n i18nKey=\"common:integrationConnect.signedIn\"\n values={{ name: displayName }}\n defaults={`Signed in to ${displayName}.`}\n />\n </span>\n ) : (\n <Trans\n i18nKey=\"common:integrationConnect.oauthFootnote\"\n values={{ name: displayName }}\n defaults={`You'll sign in on ${displayName}'s site and come straight back here.`}\n />\n )\n }\n >\n {isConnected && children ? children : null}\n </BaseActivationForm>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"oauth-activation-form.js","sourceRoot":"","sources":["../../src/components/oauth-activation-form.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAEL,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAGL,wBAAwB,GACzB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAgD1D;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;;IACjE,MAAM,EACJ,MAAM,EACN,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,EAAE,eAAe,GAAG,KAAK,EAClC,MAAM,GAAG,KAAK,EACd,SAAS,GAAG,KAAK,GAClB,GAAG,KAAK,CAAC;IAEV,MAAM,EACJ,IAAI,EACJ,WAAW,EACX,KAAK,GAAG,WAAW,WAAW,EAAE,EAChC,WAAW,GAAG,EAAE,EAChB,WAAW,GAAG,qBAAqB,IAAI,UAAU,EACjD,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GAAG,IAAI,EACvB,qBAAqB,GAAG,IAAI,GAC7B,GAAG,MAAM,CAAC;IAEX,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,SAAS,E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,GAAG,GACxC,IACG,CACR,CAAC,CAAC,CAAC,CACF,KAAC,KAAK,IACJ,OAAO,EAAC,yCAAyC,EACjD,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAC7B,QAAQ,EAAE,qBAAqB,WAAW,sCAAsC,GAChF,CACH,YAGF,WAAW,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GACvB,CACtB,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { Icon } from '@ekanos/ui/icon';\nimport { Trans } from '@ekanos/ui/trans';\nimport { useForm } from 'react-hook-form';\n\nimport { useActivateIntegration } from '../hooks/use-activate-integration';\nimport {\n type ConnectionCheckAction,\n type OAuthErrorParam,\n useOAuthConnectionStatus,\n} from '../hooks/use-oauth-connection-status';\nimport type { ActivationFormProps } from '../types/integration';\nimport { BaseActivationForm } from './base-activation-form';\nimport { currentReturnPath } from './current-return-path';\n\nexport interface OAuthActivationFormConfig {\n /** Integration slug — used for activation, the connect route, and ids. */\n slug: string;\n /** Human name used in default button copy, e.g. 'QuickBooks'. */\n displayName: string;\n /** Shown only when the form renders its own dialog (never inline). */\n title?: string;\n /** Shown only when the form renders its own dialog (never inline). */\n description?: string;\n /** @deprecated The host owns the success moment; this is not shown inline. */\n successMessage?: string;\n /** @deprecated The host owns the success moment; this is not shown inline. */\n successTitle?: string;\n /** Defaults to `/api/integrations/<slug>/connect`. */\n connectPath?: string;\n /** @deprecated No banner renders on return; the host toasts instead. */\n connectedBanner?: string;\n /** Defaults to `Continue with <displayName>`. */\n connectButtonText?: ReactNode;\n /** Defaults to `Connect`. Only reachable with `autoActivateOnConnect: false`. */\n activateButtonText?: ReactNode;\n /** externalId is `<prefix>_<timestamp>`; prefix defaults to the slug. */\n externalIdPrefix?: string;\n /**\n * Whether returning from OAuth should immediately activate (default `true`).\n *\n * Set `false` for integrations that expose post-connect configuration — the\n * user needs a chance to review or change it before activating, which\n * auto-activation skips right past. Connecting then leaves the form on a\n * \"Connect\" button as a deliberate second step.\n */\n autoActivateOnConnect?: boolean;\n}\n\ntype OAuthActivationFormProps = ActivationFormProps & {\n config: OAuthActivationFormConfig;\n checkConnection: ConnectionCheckAction;\n errorParam?: OAuthErrorParam;\n /**\n * Fields to fill in AFTER signing in, for an integration with\n * `autoActivateOnConnect: false`. Rendered only once connected. Not a\n * place for feature lists or permission badges — the host shows those.\n */\n children?: ReactNode;\n};\n\n/**\n * Shared activation form for OAuth-backed integrations: one \"Continue with\n * X\" button that sends the browser to the integration's connect route, then\n * auto-activates once the redirect returns with a live connection.\n *\n * Integrations with real activation fields (API keys, domains, …) should\n * keep a bespoke form built on BaseActivationForm instead.\n */\nexport function OAuthActivationForm(props: OAuthActivationFormProps) {\n const {\n config,\n checkConnection,\n errorParam,\n children,\n accountId,\n sourceId,\n teamAccountId,\n onSuccess,\n onCancel,\n isLoading: externalLoading = false,\n inline = false,\n reconnect = false,\n } = props;\n\n const {\n slug,\n displayName,\n title = `Connect ${displayName}`,\n description = '',\n connectPath = `/api/integrations/${slug}/connect`,\n connectButtonText,\n activateButtonText,\n externalIdPrefix = slug,\n autoActivateOnConnect = true,\n } = config;\n\n const [error, setError] = useState<string | null>(null);\n const [activated, setActivated] = useState(false);\n\n const {\n data: connectionStatus,\n oauthJustCompleted,\n oauthError,\n isLoading: isCheckingConnection,\n } = useOAuthConnectionStatus(accountId, {\n connectionKey: `${slug}-connection`,\n checkConnection,\n errorParam,\n });\n\n const isConnected = connectionStatus?.isConnected ?? false;\n\n const form = useForm({ defaultValues: {} });\n\n const activateIntegration = useActivateIntegration();\n const { mutateAsync: activateMutateAsync } = activateIntegration;\n\n const startConnect = useCallback(() => {\n setError(null);\n const params = new URLSearchParams({\n accountId,\n returnPath: currentReturnPath(\n '/home',\n reconnect ? {} : { firstConnect: slug },\n ),\n });\n\n // For a user-scoped integration `accountId` is the PERSONAL account (see\n // the connect modal's scope-resolved id), which has no\n // source_id — so an OAuth callback cannot materialize workspaces from it\n // alone. Carry the team through as well; callbacks that don't read it\n // simply ignore the extra param.\n if (teamAccountId) {\n params.set('teamAccountId', teamAccountId);\n }\n\n window.location.href = `${connectPath}?${params.toString()}`;\n }, [accountId, teamAccountId, connectPath, reconnect, slug]);\n\n // Reports success exactly once, straight to the host — no in-form panel,\n // no second call from a \"Continue\" button.\n const handleActivate = useCallback(async () => {\n try {\n setError(null);\n await activateMutateAsync({\n accountId,\n sourceId,\n teamAccountId,\n integrationSlug: slug,\n activationData: {},\n });\n setActivated(true);\n\n onSuccess?.({\n success: true,\n externalId: `${externalIdPrefix}_${Date.now()}`,\n });\n } catch (err) {\n const errorMessage =\n err instanceof Error ? err.message : 'Activation failed';\n setError(errorMessage);\n }\n }, [\n accountId,\n sourceId,\n teamAccountId,\n slug,\n externalIdPrefix,\n activateMutateAsync,\n onSuccess,\n ]);\n\n const handleSubmit = useCallback(async () => {\n // A reconnect always goes back through sign-in — that is what issues\n // the fresh token — unless this render IS the return from it.\n if (!isConnected || (reconnect && !oauthJustCompleted)) {\n startConnect();\n return;\n }\n\n await handleActivate();\n }, [\n isConnected,\n reconnect,\n oauthJustCompleted,\n handleActivate,\n startConnect,\n ]);\n\n // Auto-activate after OAuth return, unless the integration opted out so the\n // user can review its post-connect configuration first.\n const hasAutoActivated = useRef(false);\n\n useEffect(() => {\n if (\n autoActivateOnConnect &&\n oauthJustCompleted &&\n isConnected &&\n !activated &&\n !activateIntegration.isPending &&\n !hasAutoActivated.current\n ) {\n hasAutoActivated.current = true;\n\n const id = requestAnimationFrame(() => {\n void handleActivate();\n });\n\n return () => cancelAnimationFrame(id);\n }\n }, [\n autoActivateOnConnect,\n oauthJustCompleted,\n isConnected,\n activated,\n activateIntegration.isPending,\n handleActivate,\n ]);\n\n const displayError = error || oauthError;\n\n // The round-trip is in flight from the moment the redirect lands until\n // activation reports back: the button reads as busy the whole way rather\n // than flashing \"Continue with X\" a second time.\n const finishing =\n autoActivateOnConnect && oauthJustCompleted && isConnected && !displayError;\n\n const signInAgain = reconnect && !oauthJustCompleted;\n\n const buttonText = signInAgain\n ? (connectButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.reconnectWith\"\n values={{ name: displayName }}\n defaults={`Reconnect with ${displayName}`}\n />\n ))\n : isConnected\n ? (activateButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.connect\"\n defaults=\"Connect\"\n />\n ))\n : (connectButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.continueWith\"\n values={{ name: displayName }}\n defaults={`Continue with ${displayName}`}\n />\n ));\n\n return (\n <BaseActivationForm\n isOpen={true}\n inline={inline}\n onClose={() => onCancel?.()}\n title={title}\n description={description}\n form={form}\n onSubmit={handleSubmit}\n isLoading={externalLoading || activateIntegration.isPending || finishing}\n error={displayError}\n submitButtonText={buttonText}\n submitButtonLoadingText={\n isConnected && !signInAgain ? (\n <Trans\n i18nKey=\"common:integrationConnect.finishing\"\n defaults=\"Finishing setup…\"\n />\n ) : (\n <Trans\n i18nKey=\"common:integrationConnect.redirecting\"\n defaults=\"Opening sign-in…\"\n />\n )\n }\n submitButtonDisabled={isCheckingConnection}\n footnote={\n signInAgain ? (\n <Trans\n i18nKey=\"common:integrationConnect.reconnectFootnote\"\n values={{ name: displayName }}\n defaults={`You'll sign in on ${displayName}'s site again and come straight back here.`}\n />\n ) : isConnected ? (\n <span className=\"inline-flex items-center gap-1.5\">\n <Icon name=\"fa-circle-check\" className=\"text-success h-4 w-4\" />\n <Trans\n i18nKey=\"common:integrationConnect.signedIn\"\n values={{ name: displayName }}\n defaults={`Signed in to ${displayName}.`}\n />\n </span>\n ) : (\n <Trans\n i18nKey=\"common:integrationConnect.oauthFootnote\"\n values={{ name: displayName }}\n defaults={`You'll sign in on ${displayName}'s site and come straight back here.`}\n />\n )\n }\n >\n {isConnected && children ? children : null}\n </BaseActivationForm>\n );\n}\n"]}
|
|
@@ -33,6 +33,6 @@ export function AiPromptChip({ label, prompt, context, sourceWidget, title, onAf
|
|
|
33
33
|
return (_jsxs(Button, { type: "button", variant: "outline", onClick: handleClick, className: cn('h-auto w-full justify-start rounded-lg px-4 py-3 whitespace-normal', className), "aria-label": label, children: [_jsx(Icon, { name: "fa-wand-magic-sparkles", className: "text-primary-strong h-4 w-4 shrink-0" }), _jsx("span", { className: "text-left", children: label })] }));
|
|
34
34
|
}
|
|
35
35
|
// inline (Type B)
|
|
36
|
-
return (_jsxs(Button, { type: "button", variant: "outline", size: "xs", onClick: handleClick, className: cn('
|
|
36
|
+
return (_jsxs(Button, { type: "button", variant: "outline", size: "xs", onClick: handleClick, className: cn('px-3', className), "aria-label": label, children: [_jsx(Icon, { name: "fa-wand-magic-sparkles", className: "text-primary-strong h-3.5 w-3.5 shrink-0" }), _jsx("span", { children: label })] }));
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=ai-prompt-chip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-prompt-chip.js","sourceRoot":"","sources":["../../../src/components/widgets/ai-prompt-chip.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAqBpE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,OAAO,EACP,YAAY,EACZ,KAAK,EACL,UAAU,EACV,OAAO,GAAG,QAAQ,EAClB,SAAS,GACS;IAClB,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IAEvC,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,YAAY,CAAC;YACX,QAAQ,EAAE,YAAY;YACtB,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK;YACrB,QAAQ,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE;YACvB,eAAe,EAAE,MAAM;SACxB,CAAC,CAAC;QACH,UAAU,aAAV,UAAU,uBAAV,UAAU,EAAI,CAAC;IACjB,CAAC,CAAC;IAEF,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,CACL,KAAC,MAAM,IACL,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,EACvC,OAAO,EAAE,WAAW,gBACR,WAAW,KAAK,EAAE,YAE9B,KAAC,IAAI,IAAC,IAAI,EAAC,wBAAwB,EAAC,SAAS,EAAC,SAAS,GAAG,GACnD,CACV,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,CACL,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,EAAE,CACX,oEAAoE,EACpE,SAAS,CACV,gBACW,KAAK,aAEjB,KAAC,IAAI,IACH,IAAI,EAAC,wBAAwB,EAC7B,SAAS,EAAC,sCAAsC,GAChD,EACF,eAAM,SAAS,EAAC,WAAW,YAAE,KAAK,GAAQ,IACnC,CACV,CAAC;IACJ,CAAC;IAED,kBAAkB;IAClB,OAAO,CACL,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"ai-prompt-chip.js","sourceRoot":"","sources":["../../../src/components/widgets/ai-prompt-chip.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC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EAAC,wBAAwB,EAC7B,SAAS,EAAC,sCAAsC,GAChD,EACF,eAAM,SAAS,EAAC,WAAW,YAAE,KAAK,GAAQ,IACnC,CACV,CAAC;IACJ,CAAC;IAED,kBAAkB;IAClB,OAAO,CACL,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,gBACpB,KAAK,aAEjB,KAAC,IAAI,IACH,IAAI,EAAC,wBAAwB,EAC7B,SAAS,EAAC,0CAA0C,GACpD,EACF,yBAAO,KAAK,GAAQ,IACb,CACV,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { Button } from '@ekanos/ui/button';\nimport { Icon } from '@ekanos/ui/icon';\nimport { cn } from '@ekanos/ui/utils';\n\nimport { useAskAssistant } from '../../hooks/ask-assistant-context';\n\ntype AiPromptChipProps = {\n label: string;\n prompt: string;\n context?: Record<string, unknown>;\n sourceWidget: string;\n /**\n * Human-readable label for the dock's ArrivalChip (\"Asking about …\").\n * Falls back to the chip's display label when omitted.\n */\n title?: string;\n /**\n * Fires after the assistant has been invoked. Drawers pass their close\n * handler here so the dock takes over the screen on click.\n */\n onAfterAsk?: () => void;\n variant?: 'header' | 'inline' | 'footer';\n className?: string;\n};\n\n/**\n * AI handoff chip that opens the assistant dock pre-seeded with this\n * widget/drawer's snapshot. Routes through `useAskAssistant` so the dock\n * receives the standard `{widgetId, title, snapshot, suggestedPrompt}`\n * shape used by all AI handoffs in the app.\n *\n * Variants:\n * - header (Type A): Compact icon button for widget headers\n * - inline (Type B): Chip with sparkle icon + text, below data sections\n * - footer (Type C): Full-width chip in drawer footers\n */\nexport function AiPromptChip({\n label,\n prompt,\n context,\n sourceWidget,\n title,\n onAfterAsk,\n variant = 'inline',\n className,\n}: AiPromptChipProps) {\n const askAssistant = useAskAssistant();\n\n const handleClick = () => {\n askAssistant({\n widgetId: sourceWidget,\n title: title ?? label,\n snapshot: context ?? {},\n suggestedPrompt: prompt,\n });\n onAfterAsk?.();\n };\n\n if (variant === 'header') {\n return (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className={cn('h-8 w-8 p-0', className)}\n onClick={handleClick}\n aria-label={`Ask AI: ${label}`}\n >\n <Icon name=\"fa-wand-magic-sparkles\" className=\"h-4 w-4\" />\n </Button>\n );\n }\n\n if (variant === 'footer') {\n return (\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleClick}\n className={cn(\n 'h-auto w-full justify-start rounded-lg px-4 py-3 whitespace-normal',\n className,\n )}\n aria-label={label}\n >\n <Icon\n name=\"fa-wand-magic-sparkles\"\n className=\"text-primary-strong h-4 w-4 shrink-0\"\n />\n <span className=\"text-left\">{label}</span>\n </Button>\n );\n }\n\n // inline (Type B)\n return (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"xs\"\n onClick={handleClick}\n className={cn('px-3', className)}\n aria-label={label}\n >\n <Icon\n name=\"fa-wand-magic-sparkles\"\n className=\"text-primary-strong h-3.5 w-3.5 shrink-0\"\n />\n <span>{label}</span>\n </Button>\n );\n}\n"]}
|
|
@@ -51,9 +51,9 @@ export function WidgetAskBar({ context }) {
|
|
|
51
51
|
document.addEventListener('pointerdown', onPointerDown);
|
|
52
52
|
return () => document.removeEventListener('pointerdown', onPointerDown);
|
|
53
53
|
}, [dismiss, isActive]);
|
|
54
|
-
return (_jsxs("div", { ref: containerRef, className: "border-border
|
|
54
|
+
return (_jsxs("div", { ref: containerRef, className: "border-border shrink-0 border-t", "data-test": "widget-ask-bar", "data-write-action": true, children: [_jsxs(Button, { type: "button", variant: "ghost", onClick: () => (isActive ? dismiss() : setIsActive(true)), "aria-expanded": isActive, "aria-label": isActive
|
|
55
55
|
? `Close ask input for ${context.title}`
|
|
56
|
-
: `Ask about ${context.title}`, "data-test": "widget-ask-bar-toggle", className: "group/tag h-auto w-full justify-start gap-2.5 rounded-none px-4 py-2.5 text-left sm:px-5", children: [_jsx(AskIcon, { className: cn('text-
|
|
56
|
+
: `Ask about ${context.title}`, "data-test": "widget-ask-bar-toggle", className: "group/tag h-auto w-full justify-start gap-2.5 rounded-none px-4 py-2.5 text-left sm:px-5", children: [_jsx(AskIcon, { className: cn('text-muted-foreground h-5 w-5 shrink-0 transition-transform duration-200', isActive && 'scale-110') }), _jsx("span", { className: "text-muted-foreground group-hover/tag:text-foreground text-body flex-1 font-medium transition-colors", children: "Ask about this" }), _jsx(Icon, { name: "fa-chevron-up", className: cn('text-muted-foreground/50 group-hover/tag:text-muted-foreground h-3.5 w-3.5 shrink-0 transition-transform duration-200', isActive && 'rotate-180') })] }), isActive && (_jsxs("div", { className: "border-border space-y-3 border-t p-3 sm:px-5", "data-test": "widget-ask-bar-input", children: [suggestions.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-2", "data-test": "widget-ask-bar-suggestions", children: suggestions.map((s) => (_jsxs(Button, { type: "button", variant: "outline", size: "xs", onClick: () => handleSuggestion(s.prompt), className: "px-3", "aria-label": s.label, children: [_jsx(Icon, { name: "fa-wand-magic-sparkles", className: "text-primary-strong h-3.5 w-3.5 shrink-0" }), _jsx("span", { className: "text-left", children: s.label })] }, s.label))) })), _jsxs(PromptInput, { onSubmit: handleSubmit, children: [_jsx(PromptInputBody, { children: _jsx(PromptInputTextarea, { autoFocus: true, placeholder: `Ask about ${context.title.toLowerCase()}…`, "aria-label": `Ask about ${context.title}`, onKeyDown: (e) => {
|
|
57
57
|
if (e.key === 'Escape') {
|
|
58
58
|
e.preventDefault();
|
|
59
59
|
dismiss();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-ask-bar.js","sourceRoot":"","sources":["../../../src/components/widgets/widget-ask-bar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjE,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EL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,EACzC,SAAS,EAAC,MAAM,gBACJ,CAAC,CAAC,KAAK,aAEnB,KAAC,IAAI,IACH,IAAI,EAAC,wBAAwB,EAC7B,SAAS,EAAC,0CAA0C,GACpD,EACF,eAAM,SAAS,EAAC,WAAW,YAAE,CAAC,CAAC,KAAK,GAAQ,KAZvC,CAAC,CAAC,KAAK,CAaL,CACV,CAAC,GACE,CACP,EACD,MAAC,WAAW,IAAC,QAAQ,EAAE,YAAY,aACjC,KAAC,eAAe,cACd,KAAC,mBAAmB,IAClB,SAAS,QACT,WAAW,EAAE,aAAa,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,gBAC5C,aAAa,OAAO,CAAC,KAAK,EAAE,EACxC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;wCACf,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;4CACvB,CAAC,CAAC,cAAc,EAAE,CAAC;4CACnB,OAAO,EAAE,CAAC;wCACZ,CAAC;oCACH,CAAC,GACD,GACc,EAClB,MAAC,iBAAiB,eAChB,KAAC,gBAAgB,KAAG,EACpB,KAAC,iBAAiB,iBAAW,qBAAqB,GAAG,IACnC,IACR,IACV,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport {\n PromptInput,\n PromptInputBody,\n PromptInputFooter,\n PromptInputSubmit,\n PromptInputTextarea,\n PromptInputTools,\n} from '@ekanos/ui/ai-prompt-input';\nimport { Button } from '@ekanos/ui/button';\nimport { Icon } from '@ekanos/ui/icon';\nimport { cn } from '@ekanos/ui/utils';\n\nimport { useAskAssistant } from '../../hooks/ask-assistant-context';\nimport type { WidgetAskContext } from '../../types/widget-ask-context';\nimport { AskIcon } from './ask-icon';\n\ninterface Props {\n context: WidgetAskContext;\n}\n\n/**\n * Widget footer tag + expanding prompt input.\n *\n * - closed: a quiet, always-visible tag row at the bottom of the widget\n * (\"Aperture icon · Ask about this · chevron up\")\n * - open: clicking the tag reveals an inline `PromptInput` (the canonical\n * AI input component) below it. The tag itself doubles as the\n * close affordance (chevron rotates).\n *\n * Dismisses on click-outside or Escape. Submitting sends the user's typed\n * question (or the widget's suggestedPrompt fallback) to the assistant dock.\n */\nexport function WidgetAskBar({ context }: Props) {\n const [isActive, setIsActive] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const askAssistant = useAskAssistant();\n\n const dismiss = useCallback(() => {\n setIsActive(false);\n }, []);\n\n const handleSubmit = useCallback(\n (message: { text: string }) => {\n const prompt = message.text.trim() || context.suggestedPrompt;\n askAssistant({ ...context, suggestedPrompt: prompt });\n dismiss();\n },\n [askAssistant, context, dismiss],\n );\n\n const handleSuggestion = useCallback(\n (prompt: string) => {\n askAssistant({ ...context, suggestedPrompt: prompt });\n dismiss();\n },\n [askAssistant, context, dismiss],\n );\n\n const suggestions = context.suggestedPrompts ?? [];\n\n useEffect(() => {\n if (!isActive) return;\n const onPointerDown = (e: PointerEvent) => {\n const el = containerRef.current;\n if (!el) return;\n if (el.contains(e.target as Node)) return;\n dismiss();\n };\n document.addEventListener('pointerdown', onPointerDown);\n return () => document.removeEventListener('pointerdown', onPointerDown);\n }, [dismiss, isActive]);\n\n return (\n <div\n ref={containerRef}\n className=\"border-border shrink-0 border-t\"\n data-test=\"widget-ask-bar\"\n data-write-action\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() => (isActive ? dismiss() : setIsActive(true))}\n aria-expanded={isActive}\n aria-label={\n isActive\n ? `Close ask input for ${context.title}`\n : `Ask about ${context.title}`\n }\n data-test=\"widget-ask-bar-toggle\"\n className=\"group/tag h-auto w-full justify-start gap-2.5 rounded-none px-4 py-2.5 text-left sm:px-5\"\n >\n <AskIcon\n className={cn(\n 'text-muted-foreground h-5 w-5 shrink-0 transition-transform duration-200',\n isActive && 'scale-110',\n )}\n />\n <span className=\"text-muted-foreground group-hover/tag:text-foreground text-body flex-1 font-medium transition-colors\">\n Ask about this\n </span>\n <Icon\n name=\"fa-chevron-up\"\n className={cn(\n 'text-muted-foreground/50 group-hover/tag:text-muted-foreground h-3.5 w-3.5 shrink-0 transition-transform duration-200',\n isActive && 'rotate-180',\n )}\n />\n </Button>\n\n {isActive && (\n <div\n className=\"border-border space-y-3 border-t p-3 sm:px-5\"\n data-test=\"widget-ask-bar-input\"\n >\n {suggestions.length > 0 && (\n <div\n className=\"flex flex-wrap gap-2\"\n data-test=\"widget-ask-bar-suggestions\"\n >\n {suggestions.map((s) => (\n <Button\n key={s.label}\n type=\"button\"\n variant=\"outline\"\n size=\"xs\"\n onClick={() => handleSuggestion(s.prompt)}\n className=\"px-3\"\n aria-label={s.label}\n >\n <Icon\n name=\"fa-wand-magic-sparkles\"\n className=\"text-primary-strong h-3.5 w-3.5 shrink-0\"\n />\n <span className=\"text-left\">{s.label}</span>\n </Button>\n ))}\n </div>\n )}\n <PromptInput onSubmit={handleSubmit}>\n <PromptInputBody>\n <PromptInputTextarea\n autoFocus\n placeholder={`Ask about ${context.title.toLowerCase()}…`}\n aria-label={`Ask about ${context.title}`}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n dismiss();\n }\n }}\n />\n </PromptInputBody>\n <PromptInputFooter>\n <PromptInputTools />\n <PromptInputSubmit data-test=\"widget-ask-bar-send\" />\n </PromptInputFooter>\n </PromptInput>\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -65,7 +65,7 @@ export function WidgetInactiveState({ reason, integrationName, title, descriptio
|
|
|
65
65
|
* chart, `schedule` a day of events.
|
|
66
66
|
*/
|
|
67
67
|
export function WidgetLoadingSkeleton({ variant = 'rows', }) {
|
|
68
|
-
return (_jsxs("div", { role: "status", "aria-busy": "true", className: "flex flex-1 flex-col", "data-test": `widget-skeleton-${variant}`, children: [_jsx("span", { className: "sr-only", children: _jsx(Trans, { i18nKey: "dashboard:widgetLoading", defaults: "Loading..." }) }), variant === 'stat' ? (_jsxs("div", { className: "space-y-2 px-5 pt-2 pb-5", children: [_jsx(Skeleton, { className: "h-3 w-24" }), _jsx(Skeleton, { className: "h-8 w-40" }), _jsx(Skeleton, { className: "h-3 w-32" })] })) : variant === 'chart' ? (_jsxs("div", { className: "space-y-3 px-5 pt-2 pb-5", children: [_jsx(Skeleton, { className: "h-8 w-40" }), _jsx(Skeleton, { className: "h-60 w-full" })] })) : (_jsx("div", { className: "divide-border
|
|
68
|
+
return (_jsxs("div", { role: "status", "aria-busy": "true", className: "flex flex-1 flex-col", "data-test": `widget-skeleton-${variant}`, children: [_jsx("span", { className: "sr-only", children: _jsx(Trans, { i18nKey: "dashboard:widgetLoading", defaults: "Loading..." }) }), variant === 'stat' ? (_jsxs("div", { className: "space-y-2 px-5 pt-2 pb-5", children: [_jsx(Skeleton, { className: "h-3 w-24" }), _jsx(Skeleton, { className: "h-8 w-40" }), _jsx(Skeleton, { className: "h-3 w-32" })] })) : variant === 'chart' ? (_jsxs("div", { className: "space-y-3 px-5 pt-2 pb-5", children: [_jsx(Skeleton, { className: "h-8 w-40" }), _jsx(Skeleton, { className: "h-60 w-full" })] })) : (_jsx("div", { className: "divide-border divide-y", children: [0, 1, 2].map((row) => (_jsx("div", { className: cn('px-5 py-3', variant === 'schedule' ? 'flex items-start gap-3' : 'space-y-2'), children: variant === 'schedule' ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "h-4 w-14 shrink-0" }), _jsxs("div", { className: "flex-1 space-y-2", children: [_jsx(Skeleton, { className: "h-4 w-2/3" }), _jsx(Skeleton, { className: "h-3 w-1/3" })] })] })) : (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "h-4 w-2/3" }), _jsx(Skeleton, { className: "h-3 w-1/2" })] })) }, row))) }))] }));
|
|
69
69
|
}
|
|
70
70
|
export function WidgetErrorState({ title, description, onRetry, retrying = false, }) {
|
|
71
71
|
return (_jsxs("div", { role: "alert", className: "flex flex-col items-center justify-center gap-3 px-5 py-8 text-center", children: [_jsx("div", { className: "bg-destructive/10 flex h-10 w-10 items-center justify-center rounded-full", children: _jsx(Icon, { name: "fa-circle-exclamation", className: "text-destructive h-5 w-5", "aria-hidden": true }) }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-foreground text-label", children: title !== null && title !== void 0 ? title : (_jsx(Trans, { i18nKey: "dashboard:widgetErrorTitle", defaults: "Couldn't load this widget" })) }), _jsx("p", { className: "text-muted-foreground text-meta", children: description ? (description) : onRetry ? (_jsx(Trans, { i18nKey: "dashboard:widgetErrorBodyRetry", defaults: "Try again, or check back in a few minutes." })) : (_jsx(Trans, { i18nKey: "dashboard:widgetErrorBody", defaults: "Check back in a few minutes." })) })] }), onRetry ? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: onRetry, disabled: retrying, "data-test": "widget-error-retry", children: [_jsx(Icon, { name: "fa-arrows-rotate", className: cn('h-4 w-4', retrying && 'animate-spin'), "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRetry", defaults: "Try again" })] })) : null] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-state-components.js","sourceRoot":"","sources":["../../../src/components/widgets/widget-state-components.tsx"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AA6CtC,SAAS,WAAW,CAAC,EACnB,MAAM,EACN,OAAO,GAAG,SAAS,GAIpB;I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AAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,eACR,oBAAoB,aAE9B,KAAC,IAAI,IACH,IAAI,EAAC,kBAAkB,EACvB,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,QAAQ,IAAI,cAAc,CAAC,wBAEpD,EACF,KAAC,KAAK,IAAC,OAAO,EAAC,uBAAuB,EAAC,QAAQ,EAAC,WAAW,GAAG,IACvD,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,CACL,cAAK,SAAS,EAAC,+CAA+C,YAC5D,KAAC,IAAI,IACH,IAAI,EAAC,kBAAkB,EACvB,SAAS,EAAC,4CAA4C,GACtD,GACE,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,CACL,eAAK,SAAS,EAAC,4DAA4D,aACzE,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,oCAAoC,GAAG,EACrE,YAAG,SAAS,EAAC,iCAAiC,YAC5C,KAAC,KAAK,IAAC,OAAO,EAAC,0BAA0B,EAAC,QAAQ,EAAC,iBAAiB,GAAG,GACrE,IACA,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from 'react';\n\nimport Link from 'next/link.js';\n\nimport { Button } from '@ekanos/ui/button';\nimport { Icon } from '@ekanos/ui/icon';\nimport { Skeleton } from '@ekanos/ui/skeleton';\nimport { Trans } from '@ekanos/ui/trans';\nimport { cn } from '@ekanos/ui/utils';\n\n/**\n * The one action a state view offers: \"Connect QuickBooks\", \"Ask an admin\",\n * \"Create a deal\". A link with `href`, otherwise a button running `onClick`.\n */\nexport interface WidgetStateAction {\n label: ReactNode;\n href?: string;\n /** Open `href` in a new tab. */\n external?: boolean;\n onClick?: () => void;\n}\n\n/** The body shape a loading skeleton stands in for. */\nexport type WidgetSkeletonVariant = 'rows' | 'stat' | 'chart' | 'schedule';\n\n/** Why an active integration still can't show this widget's data. */\nexport type WidgetInactiveReason =\n | 'not-connected'\n | 'no-access'\n | 'setup-needed';\n\nexport interface WidgetEmptyStateProps {\n /**\n * `positive` (the default) says nothing needs the owner: \"You're all caught\n * up\". `neutral` is for an empty list that isn't good news, like a search\n * with no results.\n */\n tone?: 'positive' | 'neutral';\n title?: ReactNode;\n description?: ReactNode;\n action?: WidgetStateAction;\n}\n\nexport interface WidgetInactiveStateProps {\n reason?: WidgetInactiveReason;\n /** The integration's name, for the default copy (\"Connect QuickBooks\"). */\n integrationName?: string;\n title?: ReactNode;\n /** One sentence on what connecting or access gives the owner. */\n description?: ReactNode;\n action?: WidgetStateAction;\n}\n\nfunction StateAction({\n action,\n variant = 'default',\n}: {\n action: WidgetStateAction;\n variant?: 'default' | 'outline';\n}) {\n if (action.href) {\n const link = action.external ? (\n <a href={action.href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={action.href} />\n );\n\n return (\n <Button size=\"sm\" variant={variant} render={link} nativeButton={false}>\n {action.label}\n </Button>\n );\n }\n\n return (\n <Button size=\"sm\" variant={variant} type=\"button\" onClick={action.onClick}>\n {action.label}\n </Button>\n );\n}\n\n/**\n * The shared shape of every non-data state: an icon, a title, one sentence\n * and at most one action, left-aligned in the body's padding.\n */\nfunction StateNote({\n icon,\n title,\n description,\n action,\n actionVariant,\n role,\n testId,\n}: {\n icon: string;\n title: ReactNode;\n description?: ReactNode;\n action?: WidgetStateAction;\n actionVariant?: 'default' | 'outline';\n role?: 'alert' | 'status';\n testId: string;\n}) {\n return (\n <div\n role={role}\n className=\"flex flex-1 flex-col items-start gap-3 px-5 pt-2 pb-5\"\n data-test={testId}\n >\n <Icon name={icon} className=\"text-muted-foreground h-6 w-6\" aria-hidden />\n <div className=\"space-y-1\">\n <p className=\"text-foreground text-body font-medium\">{title}</p>\n {description ? (\n <p className=\"text-muted-foreground text-meta max-w-prose\">\n {description}\n </p>\n ) : null}\n </div>\n {action ? <StateAction action={action} variant={actionVariant} /> : null}\n </div>\n );\n}\n\n/**\n * The empty state for a widget with nothing to show. Positive by default:\n * an empty review queue is good news, so it reassures instead of apologizing.\n */\nexport function WidgetEmptyState({\n tone = 'positive',\n title,\n description,\n action,\n}: WidgetEmptyStateProps) {\n const positive = tone === 'positive';\n\n return (\n <StateNote\n icon={positive ? 'fa-circle-check' : 'fa-inbox'}\n title={\n title ??\n (positive ? (\n <Trans\n i18nKey=\"dashboard:widgetEmptyPositive\"\n defaults=\"You're all caught up\"\n />\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetEmptyNeutral\"\n defaults=\"Nothing here yet\"\n />\n ))\n }\n description={description}\n action={action}\n actionVariant=\"outline\"\n role=\"status\"\n testId={`widget-empty-${tone}`}\n />\n );\n}\n\nconst INACTIVE_ICON: Record<WidgetInactiveReason, string> = {\n 'not-connected': 'fa-plug',\n 'no-access': 'fa-user-group',\n 'setup-needed': 'fa-sliders',\n};\n\n/**\n * Why the widget can't show data. `not-connected` offers one Connect button;\n * `no-access` is a calm note that points to an admin, never a lock screen;\n * `setup-needed` points to the integration's settings. Without a `reason` it\n * keeps the original one-line \"Widget inactive\".\n */\nexport function WidgetInactiveState({\n reason,\n integrationName,\n title,\n description,\n action,\n}: WidgetInactiveStateProps = {}) {\n if (!reason) {\n return (\n <div className=\"flex flex-col items-center justify-center py-8 text-center\">\n <p className=\"text-muted-foreground text-meta\">\n {title ?? (\n <Trans\n i18nKey=\"dashboard:widgetInactive\"\n defaults=\"Widget inactive\"\n />\n )}\n </p>\n </div>\n );\n }\n\n const name = integrationName ?? 'this integration';\n\n const defaults: Record<\n WidgetInactiveReason,\n { title: ReactNode; description: ReactNode }\n > = {\n 'not-connected': {\n title: (\n <Trans\n i18nKey=\"dashboard:widgetNotConnectedTitle\"\n defaults=\"Connect {{name}}\"\n values={{ name }}\n />\n ),\n description: (\n <Trans\n i18nKey=\"dashboard:widgetNotConnectedBody\"\n defaults=\"Connect {{name}} and this card fills in with your own data.\"\n values={{ name }}\n />\n ),\n },\n 'no-access': {\n title: (\n <Trans\n i18nKey=\"dashboard:widgetNoAccessTitle\"\n defaults=\"Shared with admins for now\"\n />\n ),\n description: (\n <Trans\n i18nKey=\"dashboard:widgetNoAccessBody\"\n defaults=\"Your role doesn't include this data yet. Ask an admin if you need it.\"\n />\n ),\n },\n 'setup-needed': {\n title: (\n <Trans\n i18nKey=\"dashboard:widgetSetupNeededTitle\"\n defaults=\"Finish setting up {{name}}\"\n values={{ name }}\n />\n ),\n description: (\n <Trans\n i18nKey=\"dashboard:widgetSetupNeededBody\"\n defaults=\"One more step and this card starts showing data.\"\n />\n ),\n },\n };\n\n return (\n <StateNote\n icon={INACTIVE_ICON[reason]}\n title={title ?? defaults[reason].title}\n description={description ?? defaults[reason].description}\n action={action}\n actionVariant={reason === 'no-access' ? 'outline' : 'default'}\n testId={`widget-inactive-${reason}`}\n />\n );\n}\n\n/**\n * Loading, drawn as the body it stands in for so the card doesn't jump when\n * data lands. Rows suit lists and feeds, `stat` a headline figure, `chart` a\n * chart, `schedule` a day of events.\n */\nexport function WidgetLoadingSkeleton({\n variant = 'rows',\n}: {\n variant?: WidgetSkeletonVariant;\n}) {\n return (\n <div\n role=\"status\"\n aria-busy=\"true\"\n className=\"flex flex-1 flex-col\"\n data-test={`widget-skeleton-${variant}`}\n >\n <span className=\"sr-only\">\n <Trans i18nKey=\"dashboard:widgetLoading\" defaults=\"Loading...\" />\n </span>\n {variant === 'stat' ? (\n <div className=\"space-y-2 px-5 pt-2 pb-5\">\n <Skeleton className=\"h-3 w-24\" />\n <Skeleton className=\"h-8 w-40\" />\n <Skeleton className=\"h-3 w-32\" />\n </div>\n ) : variant === 'chart' ? (\n <div className=\"space-y-3 px-5 pt-2 pb-5\">\n <Skeleton className=\"h-8 w-40\" />\n <Skeleton className=\"h-60 w-full\" />\n </div>\n ) : (\n <div className=\"divide-border/50 divide-y\">\n {[0, 1, 2].map((row) => (\n <div\n key={row}\n className={cn(\n 'px-5 py-3',\n variant === 'schedule' ? 'flex items-start gap-3' : 'space-y-2',\n )}\n >\n {variant === 'schedule' ? (\n <>\n <Skeleton className=\"h-4 w-14 shrink-0\" />\n <div className=\"flex-1 space-y-2\">\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-3 w-1/3\" />\n </div>\n </>\n ) : (\n <>\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-3 w-1/2\" />\n </>\n )}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n\nexport function WidgetErrorState({\n title,\n description,\n onRetry,\n retrying = false,\n}: {\n title?: ReactNode;\n description?: ReactNode;\n onRetry?: () => void;\n retrying?: boolean;\n}) {\n return (\n <div\n role=\"alert\"\n className=\"flex flex-col items-center justify-center gap-3 px-5 py-8 text-center\"\n >\n <div className=\"bg-destructive/10 flex h-10 w-10 items-center justify-center rounded-full\">\n <Icon\n name=\"fa-circle-exclamation\"\n className=\"text-destructive h-5 w-5\"\n aria-hidden\n />\n </div>\n <div className=\"space-y-1\">\n <p className=\"text-foreground text-label\">\n {title ?? (\n <Trans\n i18nKey=\"dashboard:widgetErrorTitle\"\n defaults=\"Couldn't load this widget\"\n />\n )}\n </p>\n <p className=\"text-muted-foreground text-meta\">\n {description ? (\n description\n ) : onRetry ? (\n <Trans\n i18nKey=\"dashboard:widgetErrorBodyRetry\"\n defaults=\"Try again, or check back in a few minutes.\"\n />\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetErrorBody\"\n defaults=\"Check back in a few minutes.\"\n />\n )}\n </p>\n </div>\n {onRetry ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={onRetry}\n disabled={retrying}\n data-test=\"widget-error-retry\"\n >\n <Icon\n name=\"fa-arrows-rotate\"\n className={cn('h-4 w-4', retrying && 'animate-spin')}\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRetry\" defaults=\"Try again\" />\n </Button>\n ) : null}\n </div>\n );\n}\n\nexport function WidgetDataLoading() {\n return (\n <div className=\"flex flex-1 items-center justify-center py-12\">\n <Icon\n name=\"fa-spinner-third\"\n className=\"text-muted-foreground h-8 w-8 animate-spin\"\n />\n </div>\n );\n}\n\nexport function WidgetDisabledState() {\n return (\n <div className=\"flex flex-col items-center justify-center py-8 text-center\">\n <Icon name=\"fa-ban\" className=\"text-muted-foreground mb-4 h-8 w-8\" />\n <p className=\"text-muted-foreground text-meta\">\n <Trans i18nKey=\"dashboard:widgetDisabled\" defaults=\"Widget Disabled\" />\n </p>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"widget-state-components.js","sourceRoot":"","sources":["../../../src/components/widgets/widget-state-components.tsx"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AA6CtC,SAAS,WAAW,CAAC,EACnB,MAAM,EACN,OAAO,GAAG,SAAS,GAIpB;IACC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAC7B,YAAG,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,qBAAqB,GAAG,CACnE,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAI,CAC5B,CAAC;QAEF,OAAO,CACL,KAAC,MAAM,IAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,YAClE,MAAM,CAAC,KAAK,GAC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GACtD,GACE,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,CACL,eAAK,SAAS,EAAC,4DAA4D,aACzE,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,oCAAoC,GAAG,EACrE,YAAG,SAAS,EAAC,iCAAiC,YAC5C,KAAC,KAAK,IAAC,OAAO,EAAC,0BAA0B,EAAC,QAAQ,EAAC,iBAAiB,GAAG,GACrE,IACA,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from 'react';\n\nimport Link from 'next/link.js';\n\nimport { Button } from '@ekanos/ui/button';\nimport { Icon } from '@ekanos/ui/icon';\nimport { Skeleton } from '@ekanos/ui/skeleton';\nimport { Trans } from '@ekanos/ui/trans';\nimport { cn } from '@ekanos/ui/utils';\n\n/**\n * The one action a state view offers: \"Connect QuickBooks\", \"Ask an admin\",\n * \"Create a deal\". A link with `href`, otherwise a button running `onClick`.\n */\nexport interface WidgetStateAction {\n label: ReactNode;\n href?: string;\n /** Open `href` in a new tab. */\n external?: boolean;\n onClick?: () => void;\n}\n\n/** The body shape a loading skeleton stands in for. */\nexport type WidgetSkeletonVariant = 'rows' | 'stat' | 'chart' | 'schedule';\n\n/** Why an active integration still can't show this widget's data. */\nexport type WidgetInactiveReason =\n | 'not-connected'\n | 'no-access'\n | 'setup-needed';\n\nexport interface WidgetEmptyStateProps {\n /**\n * `positive` (the default) says nothing needs the owner: \"You're all caught\n * up\". `neutral` is for an empty list that isn't good news, like a search\n * with no results.\n */\n tone?: 'positive' | 'neutral';\n title?: ReactNode;\n description?: ReactNode;\n action?: WidgetStateAction;\n}\n\nexport interface WidgetInactiveStateProps {\n reason?: WidgetInactiveReason;\n /** The integration's name, for the default copy (\"Connect QuickBooks\"). */\n integrationName?: string;\n title?: ReactNode;\n /** One sentence on what connecting or access gives the owner. */\n description?: ReactNode;\n action?: WidgetStateAction;\n}\n\nfunction StateAction({\n action,\n variant = 'default',\n}: {\n action: WidgetStateAction;\n variant?: 'default' | 'outline';\n}) {\n if (action.href) {\n const link = action.external ? (\n <a href={action.href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={action.href} />\n );\n\n return (\n <Button size=\"sm\" variant={variant} render={link} nativeButton={false}>\n {action.label}\n </Button>\n );\n }\n\n return (\n <Button size=\"sm\" variant={variant} type=\"button\" onClick={action.onClick}>\n {action.label}\n </Button>\n );\n}\n\n/**\n * The shared shape of every non-data state: an icon, a title, one sentence\n * and at most one action, left-aligned in the body's padding.\n */\nfunction StateNote({\n icon,\n title,\n description,\n action,\n actionVariant,\n role,\n testId,\n}: {\n icon: string;\n title: ReactNode;\n description?: ReactNode;\n action?: WidgetStateAction;\n actionVariant?: 'default' | 'outline';\n role?: 'alert' | 'status';\n testId: string;\n}) {\n return (\n <div\n role={role}\n className=\"flex flex-1 flex-col items-start gap-3 px-5 pt-2 pb-5\"\n data-test={testId}\n >\n <Icon name={icon} className=\"text-muted-foreground h-6 w-6\" aria-hidden />\n <div className=\"space-y-1\">\n <p className=\"text-foreground text-body font-medium\">{title}</p>\n {description ? (\n <p className=\"text-muted-foreground text-meta max-w-prose\">\n {description}\n </p>\n ) : null}\n </div>\n {action ? <StateAction action={action} variant={actionVariant} /> : null}\n </div>\n );\n}\n\n/**\n * The empty state for a widget with nothing to show. Positive by default:\n * an empty review queue is good news, so it reassures instead of apologizing.\n */\nexport function WidgetEmptyState({\n tone = 'positive',\n title,\n description,\n action,\n}: WidgetEmptyStateProps) {\n const positive = tone === 'positive';\n\n return (\n <StateNote\n icon={positive ? 'fa-circle-check' : 'fa-inbox'}\n title={\n title ??\n (positive ? (\n <Trans\n i18nKey=\"dashboard:widgetEmptyPositive\"\n defaults=\"You're all caught up\"\n />\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetEmptyNeutral\"\n defaults=\"Nothing here yet\"\n />\n ))\n }\n description={description}\n action={action}\n actionVariant=\"outline\"\n role=\"status\"\n testId={`widget-empty-${tone}`}\n />\n );\n}\n\nconst INACTIVE_ICON: Record<WidgetInactiveReason, string> = {\n 'not-connected': 'fa-plug',\n 'no-access': 'fa-user-group',\n 'setup-needed': 'fa-sliders',\n};\n\n/**\n * Why the widget can't show data. `not-connected` offers one Connect button;\n * `no-access` is a calm note that points to an admin, never a lock screen;\n * `setup-needed` points to the integration's settings. Without a `reason` it\n * keeps the original one-line \"Widget inactive\".\n */\nexport function WidgetInactiveState({\n reason,\n integrationName,\n title,\n description,\n action,\n}: WidgetInactiveStateProps = {}) {\n if (!reason) {\n return (\n <div className=\"flex flex-col items-center justify-center py-8 text-center\">\n <p className=\"text-muted-foreground text-meta\">\n {title ?? (\n <Trans\n i18nKey=\"dashboard:widgetInactive\"\n defaults=\"Widget inactive\"\n />\n )}\n </p>\n </div>\n );\n }\n\n const name = integrationName ?? 'this integration';\n\n const defaults: Record<\n WidgetInactiveReason,\n { title: ReactNode; description: ReactNode }\n > = {\n 'not-connected': {\n title: (\n <Trans\n i18nKey=\"dashboard:widgetNotConnectedTitle\"\n defaults=\"Connect {{name}}\"\n values={{ name }}\n />\n ),\n description: (\n <Trans\n i18nKey=\"dashboard:widgetNotConnectedBody\"\n defaults=\"Connect {{name}} and this card fills in with your own data.\"\n values={{ name }}\n />\n ),\n },\n 'no-access': {\n title: (\n <Trans\n i18nKey=\"dashboard:widgetNoAccessTitle\"\n defaults=\"Shared with admins for now\"\n />\n ),\n description: (\n <Trans\n i18nKey=\"dashboard:widgetNoAccessBody\"\n defaults=\"Your role doesn't include this data yet. Ask an admin if you need it.\"\n />\n ),\n },\n 'setup-needed': {\n title: (\n <Trans\n i18nKey=\"dashboard:widgetSetupNeededTitle\"\n defaults=\"Finish setting up {{name}}\"\n values={{ name }}\n />\n ),\n description: (\n <Trans\n i18nKey=\"dashboard:widgetSetupNeededBody\"\n defaults=\"One more step and this card starts showing data.\"\n />\n ),\n },\n };\n\n return (\n <StateNote\n icon={INACTIVE_ICON[reason]}\n title={title ?? defaults[reason].title}\n description={description ?? defaults[reason].description}\n action={action}\n actionVariant={reason === 'no-access' ? 'outline' : 'default'}\n testId={`widget-inactive-${reason}`}\n />\n );\n}\n\n/**\n * Loading, drawn as the body it stands in for so the card doesn't jump when\n * data lands. Rows suit lists and feeds, `stat` a headline figure, `chart` a\n * chart, `schedule` a day of events.\n */\nexport function WidgetLoadingSkeleton({\n variant = 'rows',\n}: {\n variant?: WidgetSkeletonVariant;\n}) {\n return (\n <div\n role=\"status\"\n aria-busy=\"true\"\n className=\"flex flex-1 flex-col\"\n data-test={`widget-skeleton-${variant}`}\n >\n <span className=\"sr-only\">\n <Trans i18nKey=\"dashboard:widgetLoading\" defaults=\"Loading...\" />\n </span>\n {variant === 'stat' ? (\n <div className=\"space-y-2 px-5 pt-2 pb-5\">\n <Skeleton className=\"h-3 w-24\" />\n <Skeleton className=\"h-8 w-40\" />\n <Skeleton className=\"h-3 w-32\" />\n </div>\n ) : variant === 'chart' ? (\n <div className=\"space-y-3 px-5 pt-2 pb-5\">\n <Skeleton className=\"h-8 w-40\" />\n <Skeleton className=\"h-60 w-full\" />\n </div>\n ) : (\n <div className=\"divide-border divide-y\">\n {[0, 1, 2].map((row) => (\n <div\n key={row}\n className={cn(\n 'px-5 py-3',\n variant === 'schedule' ? 'flex items-start gap-3' : 'space-y-2',\n )}\n >\n {variant === 'schedule' ? (\n <>\n <Skeleton className=\"h-4 w-14 shrink-0\" />\n <div className=\"flex-1 space-y-2\">\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-3 w-1/3\" />\n </div>\n </>\n ) : (\n <>\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-3 w-1/2\" />\n </>\n )}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n\nexport function WidgetErrorState({\n title,\n description,\n onRetry,\n retrying = false,\n}: {\n title?: ReactNode;\n description?: ReactNode;\n onRetry?: () => void;\n retrying?: boolean;\n}) {\n return (\n <div\n role=\"alert\"\n className=\"flex flex-col items-center justify-center gap-3 px-5 py-8 text-center\"\n >\n <div className=\"bg-destructive/10 flex h-10 w-10 items-center justify-center rounded-full\">\n <Icon\n name=\"fa-circle-exclamation\"\n className=\"text-destructive h-5 w-5\"\n aria-hidden\n />\n </div>\n <div className=\"space-y-1\">\n <p className=\"text-foreground text-label\">\n {title ?? (\n <Trans\n i18nKey=\"dashboard:widgetErrorTitle\"\n defaults=\"Couldn't load this widget\"\n />\n )}\n </p>\n <p className=\"text-muted-foreground text-meta\">\n {description ? (\n description\n ) : onRetry ? (\n <Trans\n i18nKey=\"dashboard:widgetErrorBodyRetry\"\n defaults=\"Try again, or check back in a few minutes.\"\n />\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetErrorBody\"\n defaults=\"Check back in a few minutes.\"\n />\n )}\n </p>\n </div>\n {onRetry ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={onRetry}\n disabled={retrying}\n data-test=\"widget-error-retry\"\n >\n <Icon\n name=\"fa-arrows-rotate\"\n className={cn('h-4 w-4', retrying && 'animate-spin')}\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRetry\" defaults=\"Try again\" />\n </Button>\n ) : null}\n </div>\n );\n}\n\nexport function WidgetDataLoading() {\n return (\n <div className=\"flex flex-1 items-center justify-center py-12\">\n <Icon\n name=\"fa-spinner-third\"\n className=\"text-muted-foreground h-8 w-8 animate-spin\"\n />\n </div>\n );\n}\n\nexport function WidgetDisabledState() {\n return (\n <div className=\"flex flex-col items-center justify-center py-8 text-center\">\n <Icon name=\"fa-ban\" className=\"text-muted-foreground mb-4 h-8 w-8\" />\n <p className=\"text-muted-foreground text-meta\">\n <Trans i18nKey=\"dashboard:widgetDisabled\" defaults=\"Widget Disabled\" />\n </p>\n </div>\n );\n}\n"]}
|