@ekanos/sdk 0.17.0 → 0.18.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/README.md CHANGED
@@ -636,11 +636,11 @@ export function AcmePaymentsMarketplaceTile({
636
636
  href,
637
637
  }: MarketplaceTileProps) {
638
638
  return (
639
- <Card className="shadow-card flex h-full flex-col border-0">
639
+ <Card className="shadow-ring flex h-full flex-col border-0">
640
640
  <CardHeader className="gap-3">
641
641
  <div className="flex items-start justify-between gap-3">
642
642
  <div className="bg-muted flex h-12 w-12 items-center justify-center rounded-lg">
643
- <Icon name="fa-light fa-credit-card" className="h-6 w-6" aria-hidden />
643
+ <Icon name="fa-credit-card" className="h-6 w-6" aria-hidden />
644
644
  </div>
645
645
  {isActivated && <Badge variant="secondary">Connected</Badge>}
646
646
  </div>
@@ -10,13 +10,13 @@ import { Separator } from '@ekanos/ui/separator';
10
10
  import { Trans } from '@ekanos/ui/trans';
11
11
  import { cn } from '@ekanos/ui/utils';
12
12
  function SuccessContent({ successTitle = 'Integration Activated!', successMessage = 'Your integration is now active and ready to use.', onClose, showSeparator = false, }) {
13
- return (_jsxs("div", { className: "flex flex-col items-center space-y-4 py-6", children: [_jsx("div", { className: "bg-success/10 flex h-16 w-16 items-center justify-center rounded-full", children: _jsx(Icon, { name: "fa-light fa-circle-check", className: "text-success h-8 w-8" }) }), _jsxs("div", { className: "text-center", children: [_jsx("h3", { className: "text-subhead", children: successTitle }), _jsx("p", { className: "text-muted-foreground text-meta mt-1", children: successMessage })] }), showSeparator && _jsx(Separator, {}), _jsxs("div", { className: "flex gap-2", children: [showSeparator && (_jsx(Button, { variant: "outline", onClick: onClose, children: _jsx(Trans, { i18nKey: "common:stayOnMarketplace", defaults: "Stay on Marketplace" }) })), _jsx(Button, { onClick: onClose, children: _jsx(Trans, { i18nKey: "common:continue", defaults: "Continue" }) })] })] }));
13
+ return (_jsxs("div", { className: "flex flex-col items-center space-y-4 py-6", children: [_jsx("div", { className: "bg-success/10 flex h-16 w-16 items-center justify-center rounded-full", children: _jsx(Icon, { name: "fa-circle-check", className: "text-success h-8 w-8" }) }), _jsxs("div", { className: "text-center", children: [_jsx("h3", { className: "text-subhead", children: successTitle }), _jsx("p", { className: "text-muted-foreground text-meta mt-1", children: successMessage })] }), showSeparator && _jsx(Separator, {}), _jsxs("div", { className: "flex gap-2", children: [showSeparator && (_jsx(Button, { variant: "outline", onClick: onClose, children: _jsx(Trans, { i18nKey: "common:stayOnMarketplace", defaults: "Stay on Marketplace" }) })), _jsx(Button, { onClick: onClose, children: _jsx(Trans, { i18nKey: "common:continue", defaults: "Continue" }) })] })] }));
14
14
  }
15
15
  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-[1000] flex items-center justify-center", children: _jsxs("div", { className: "flex flex-col items-center gap-2", children: [_jsx(Icon, { name: "fa-light fa-spinner-third", className: "text-primary h-8 w-8 animate-spin" }), _jsx("span", { className: "text-muted-foreground text-meta", children: "Loading..." })] }) }));
19
+ return (_jsx("div", { className: "bg-background/80 fixed inset-0 z-[1000] 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-primary 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,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K,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\n name=\"fa-light fa-circle-check\"\n className=\"text-success h-8 w-8\"\n />\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-[1000] flex items-center justify-center\">\n <div className=\"flex flex-col items-center gap-2\">\n <Icon\n name=\"fa-light 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,iB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["'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-[1000] 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"]}
@@ -20,7 +20,7 @@ export function BaseActivationForm({ isOpen, onClose, title, description, form,
20
20
  const hasFields = children !== null && children !== undefined;
21
21
  const formContent = (_jsx(Form, Object.assign({}, form, { children: _jsxs("form", { onSubmit: form.handleSubmit(handleSubmit), className: "flex flex-col gap-5", "data-test": "activation-form", children: [hasFields ? (_jsx("fieldset", { className: "flex min-w-0 flex-col gap-5", disabled: loading, children: children })) : null, _jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: hasFields
22
22
  ? 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end'
23
- : 'flex flex-col', children: [inline && showCancelButton && hasFields ? (_jsx(Button, { type: "button", variant: "ghost", onClick: onClose, disabled: loading, "data-test": "activation-cancel", children: _jsx(Trans, { i18nKey: "common:cancel", defaults: "Cancel" }) })) : null, _jsx(Button, { type: "submit", size: hasFields ? 'default' : 'lg', className: hasFields ? undefined : 'w-full', disabled: loading || submitButtonDisabled, "data-test": "activation-submit", children: loading ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "fa-light fa-spinner-third", className: "h-4 w-4 animate-spin" }), submitButtonLoadingText !== null && submitButtonLoadingText !== void 0 ? submitButtonLoadingText : (_jsx(Trans, { i18nKey: "common:integrationConnect.connecting", defaults: "Connecting\u2026" }))] })) : ((submitButtonText !== null && submitButtonText !== void 0 ? submitButtonText : (_jsx(Trans, { i18nKey: "common:integrationConnect.connect", defaults: "Connect" })))) })] }), footnote ? (_jsx("p", { className: hasFields
23
+ : 'flex flex-col', children: [inline && showCancelButton && hasFields ? (_jsx(Button, { type: "button", variant: "ghost", onClick: onClose, disabled: loading, "data-test": "activation-cancel", children: _jsx(Trans, { i18nKey: "common:cancel", defaults: "Cancel" }) })) : null, _jsx(Button, { type: "submit", size: hasFields ? 'default' : 'lg', className: hasFields ? undefined : 'w-full', disabled: loading || submitButtonDisabled, "data-test": "activation-submit", children: loading ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "fa-spinner-third", className: "h-4 w-4 animate-spin" }), submitButtonLoadingText !== null && submitButtonLoadingText !== void 0 ? submitButtonLoadingText : (_jsx(Trans, { i18nKey: "common:integrationConnect.connecting", defaults: "Connecting\u2026" }))] })) : ((submitButtonText !== null && submitButtonText !== void 0 ? submitButtonText : (_jsx(Trans, { i18nKey: "common:integrationConnect.connect", defaults: "Connect" })))) })] }), footnote ? (_jsx("p", { className: hasFields
24
24
  ? 'text-muted-foreground text-meta sm:text-right'
25
25
  : 'text-muted-foreground text-meta text-center', children: footnote })) : null] })] }) })));
26
26
  return (_jsx(BaseActivationDialog, { isOpen: isOpen, onClose: onClose, title: title, description: description, isLoading: loading, error: error, success: success, successTitle: successTitle, successMessage: successMessage, onSuccessClose: onSuccessClose, maxWidth: maxWidth, inline: inline, children: formContent }));
@@ -1 +1 @@
1
- {"version":3,"file":"base-activation-form.js","sourceRoot":"","sources":["../../src/components/base-activation-form.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAa,aAAa,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAsDhE,MAAM,UAAU,kBAAkB,CAEhC,EACA,MAAM,EACN,OAAO,EACP,KAAK,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GAAG,KAAK,EACjB,KAAK,GAAG,IAAI,EACZ,OAAO,GAAG,KAAK,EACf,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,GAAG,KAAK,EAC5B,gBAAgB,GAAG,IAAI,EACvB,QAAQ,EACR,QAAQ,EACR,MAAM,GAAG,KAAK,GACwB;IACtC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,GAAG,aAAa,EAAE,CAAC;IACnD,MAAM,OAAO,GAAG,OAAO,IAAI,SAAS,CAAC;IAErC,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,EAAE;QAC1C,eAAe,CAAC,KAAK,IAAI,EAAE;YACzB,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,0EAA0E;IAC1E,oEAAoE;IACpE,iCAAiC;IACjC,MAAM,SAA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C,kBAAa,GACtB,CACH,IACA,CACJ,CAAC,CAAC,CAAC,CACF,CAAC,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,CACnB,KAAC,KAAK,IACJ,OAAO,EAAC,mCAAmC,EAC3C,QAAQ,EAAC,SAAS,GAClB,CACH,CAAC,CACH,GACM,IACL,EAEL,QAAQ,CAAC,CAAC,CAAC,CACV,YACE,SAAS,EACP,SAAS;gCACP,CAAC,CAAC,+CAA+C;gCACjD,CAAC,CAAC,6CAA6C,YAGlD,QAAQ,GACP,CACL,CAAC,CAAC,CAAC,IAAI,IACJ,IACD,IACF,CACR,CAAC;IAEF,OAAO,CACL,KAAC,oBAAoB,IACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,YAEb,WAAW,GACS,CACxB,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { ReactNode, useTransition } from 'react';\n\nimport { Button } from '@ekanos/ui/button';\nimport { Form } from '@ekanos/ui/form';\nimport { Icon } from '@ekanos/ui/icon';\nimport { Trans } from '@ekanos/ui/trans';\nimport { FieldValues, UseFormReturn } from 'react-hook-form';\n\nimport { BaseActivationDialog } from './base-activation-dialog';\n\nexport interface BaseActivationFormProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n isOpen: boolean;\n onClose: () => void;\n /** Shown only when NOT inline. Inline, the host names the integration. */\n title: string;\n /** Shown only when NOT inline. */\n description: string;\n /**\n * Generic rather than `UseFormReturn<any>`: with current react-hook-form\n * typings a concrete `UseFormReturn<T>` is NOT assignable to\n * `UseFormReturn<any>` (the `control._options.validate` parameter is\n * checked contravariantly), which broke every out-of-repo consumer — the\n * clean-room pack test caught it. Inference from the `form` prop keeps\n * every call site source-compatible.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n form: UseFormReturn<TFieldValues, any, any>;\n onSubmit: (data: TFieldValues) => Promise<void> | void;\n children: ReactNode;\n isLoading?: boolean;\n error?: string | null;\n success?: boolean;\n successTitle?: string;\n successMessage?: string;\n onSuccessClose?: () => void;\n /** Defaults to \"Connect\" — the one verb every integration shares. */\n submitButtonText?: ReactNode;\n /** Defaults to \"Connecting…\". */\n submitButtonLoadingText?: ReactNode;\n submitButtonDisabled?: boolean;\n /**\n * Inline with fields, a Cancel button sits beside Connect and calls\n * `onClose`; pass `false` for a surface that supplies its own way out.\n * A form with no fields never shows one — its single button spans the\n * frame and the surrounding dialog's close is the way out.\n */\n showCancelButton?: boolean;\n /** @deprecated The action row is right-aligned; this is ignored. */\n centerSubmitButton?: boolean;\n /**\n * One quiet line under the action row — what happens next (\"You'll sign\n * in on QuickBooks' site and come back here.\"). Nothing else belongs\n * there: not features, not permissions, the host shows those.\n */\n footnote?: ReactNode;\n maxWidth?: string;\n /** Render inline instead of in a dialog */\n inline?: boolean;\n}\n\nexport function BaseActivationForm<\n TFieldValues extends FieldValues = FieldValues,\n>({\n isOpen,\n onClose,\n title,\n description,\n form,\n onSubmit,\n children,\n isLoading = false,\n error = null,\n success = false,\n successTitle,\n successMessage,\n onSuccessClose,\n submitButtonText,\n submitButtonLoadingText,\n submitButtonDisabled = false,\n showCancelButton = true,\n footnote,\n maxWidth,\n inline = false,\n}: BaseActivationFormProps<TFieldValues>) {\n const [pending, startTransition] = useTransition();\n const loading = pending || isLoading;\n\n const handleSubmit = (data: TFieldValues) => {\n startTransition(async () => {\n await onSubmit(data);\n });\n };\n\n // `children` is null for a form with nothing to fill in (an OAuth button,\n // a one-click connect), and the action row is then the whole form —\n // no empty field block above it.\n const hasFields = children !== null && children !== undefined;\n\n const formContent = (\n <Form {...form}>\n <form\n onSubmit={form.handleSubmit(handleSubmit)}\n className=\"flex flex-col gap-5\"\n data-test=\"activation-form\"\n >\n {hasFields ? (\n <fieldset className=\"flex min-w-0 flex-col gap-5\" disabled={loading}>\n {children}\n </fieldset>\n ) : null}\n\n {/*\n Two shapes. With fields: Cancel + Connect, right-aligned, under\n what was filled in. Without (a sign-in button, a one-click\n connect): the button IS the form, so it spans the frame and needs\n no Cancel of its own — the dialog's close does that job.\n */}\n <div className=\"flex flex-col gap-2\">\n <div\n className={\n hasFields\n ? 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end'\n : 'flex flex-col'\n }\n >\n {inline && showCancelButton && hasFields ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={onClose}\n disabled={loading}\n data-test=\"activation-cancel\"\n >\n <Trans i18nKey=\"common:cancel\" defaults=\"Cancel\" />\n </Button>\n ) : null}\n\n <Button\n type=\"submit\"\n size={hasFields ? 'default' : 'lg'}\n className={hasFields ? undefined : 'w-full'}\n disabled={loading || submitButtonDisabled}\n data-test=\"activation-submit\"\n >\n {loading ? (\n <>\n <Icon\n name=\"fa-light fa-spinner-third\"\n className=\"h-4 w-4 animate-spin\"\n />\n {submitButtonLoadingText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.connecting\"\n defaults=\"Connecting…\"\n />\n )}\n </>\n ) : (\n (submitButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.connect\"\n defaults=\"Connect\"\n />\n ))\n )}\n </Button>\n </div>\n\n {footnote ? (\n <p\n className={\n hasFields\n ? 'text-muted-foreground text-meta sm:text-right'\n : 'text-muted-foreground text-meta text-center'\n }\n >\n {footnote}\n </p>\n ) : null}\n </div>\n </form>\n </Form>\n );\n\n return (\n <BaseActivationDialog\n isOpen={isOpen}\n onClose={onClose}\n title={title}\n description={description}\n isLoading={loading}\n error={error}\n success={success}\n successTitle={successTitle}\n successMessage={successMessage}\n onSuccessClose={onSuccessClose}\n maxWidth={maxWidth}\n inline={inline}\n >\n {formContent}\n </BaseActivationDialog>\n );\n}\n"]}
1
+ {"version":3,"file":"base-activation-form.js","sourceRoot":"","sources":["../../src/components/base-activation-form.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAa,aAAa,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAsDhE,MAAM,UAAU,kBAAkB,CAEhC,EACA,MAAM,EACN,OAAO,EACP,KAAK,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GAAG,KAAK,EACjB,KAAK,GAAG,IAAI,EACZ,OAAO,GAAG,KAAK,EACf,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,GAAG,KAAK,EAC5B,gBAAgB,GAAG,IAAI,EACvB,QAAQ,EACR,QAAQ,EACR,MAAM,GAAG,KAAK,GACwB;IACtC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,GAAG,aAAa,EAAE,CAAC;IACnD,MAAM,OAAO,GAAG,OAAO,IAAI,SAAS,CAAC;IAErC,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,EAAE;QAC1C,eAAe,CAAC,KAAK,IAAI,EAAE;YACzB,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,0EAA0E;IAC1E,oEAAoE;IACpE,iCAAiC;IACjC,MAAM,SAAS,GAAG,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,CAAC;IAE9D,MAAM,WAAW,GAAG,CAClB,KAA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AAgB,GAAI,CACnB,KAAC,KAAK,IACJ,OAAO,EAAC,mCAAmC,EAC3C,QAAQ,EAAC,SAAS,GAClB,CACH,CAAC,CACH,GACM,IACL,EAEL,QAAQ,CAAC,CAAC,CAAC,CACV,YACE,SAAS,EACP,SAAS;gCACP,CAAC,CAAC,+CAA+C;gCACjD,CAAC,CAAC,6CAA6C,YAGlD,QAAQ,GACP,CACL,CAAC,CAAC,CAAC,IAAI,IACJ,IACD,IACF,CACR,CAAC;IAEF,OAAO,CACL,KAAC,oBAAoB,IACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,YAEb,WAAW,GACS,CACxB,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { ReactNode, useTransition } from 'react';\n\nimport { Button } from '@ekanos/ui/button';\nimport { Form } from '@ekanos/ui/form';\nimport { Icon } from '@ekanos/ui/icon';\nimport { Trans } from '@ekanos/ui/trans';\nimport { FieldValues, UseFormReturn } from 'react-hook-form';\n\nimport { BaseActivationDialog } from './base-activation-dialog';\n\nexport interface BaseActivationFormProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n isOpen: boolean;\n onClose: () => void;\n /** Shown only when NOT inline. Inline, the host names the integration. */\n title: string;\n /** Shown only when NOT inline. */\n description: string;\n /**\n * Generic rather than `UseFormReturn<any>`: with current react-hook-form\n * typings a concrete `UseFormReturn<T>` is NOT assignable to\n * `UseFormReturn<any>` (the `control._options.validate` parameter is\n * checked contravariantly), which broke every out-of-repo consumer — the\n * clean-room pack test caught it. Inference from the `form` prop keeps\n * every call site source-compatible.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n form: UseFormReturn<TFieldValues, any, any>;\n onSubmit: (data: TFieldValues) => Promise<void> | void;\n children: ReactNode;\n isLoading?: boolean;\n error?: string | null;\n success?: boolean;\n successTitle?: string;\n successMessage?: string;\n onSuccessClose?: () => void;\n /** Defaults to \"Connect\" — the one verb every integration shares. */\n submitButtonText?: ReactNode;\n /** Defaults to \"Connecting…\". */\n submitButtonLoadingText?: ReactNode;\n submitButtonDisabled?: boolean;\n /**\n * Inline with fields, a Cancel button sits beside Connect and calls\n * `onClose`; pass `false` for a surface that supplies its own way out.\n * A form with no fields never shows one — its single button spans the\n * frame and the surrounding dialog's close is the way out.\n */\n showCancelButton?: boolean;\n /** @deprecated The action row is right-aligned; this is ignored. */\n centerSubmitButton?: boolean;\n /**\n * One quiet line under the action row — what happens next (\"You'll sign\n * in on QuickBooks' site and come back here.\"). Nothing else belongs\n * there: not features, not permissions, the host shows those.\n */\n footnote?: ReactNode;\n maxWidth?: string;\n /** Render inline instead of in a dialog */\n inline?: boolean;\n}\n\nexport function BaseActivationForm<\n TFieldValues extends FieldValues = FieldValues,\n>({\n isOpen,\n onClose,\n title,\n description,\n form,\n onSubmit,\n children,\n isLoading = false,\n error = null,\n success = false,\n successTitle,\n successMessage,\n onSuccessClose,\n submitButtonText,\n submitButtonLoadingText,\n submitButtonDisabled = false,\n showCancelButton = true,\n footnote,\n maxWidth,\n inline = false,\n}: BaseActivationFormProps<TFieldValues>) {\n const [pending, startTransition] = useTransition();\n const loading = pending || isLoading;\n\n const handleSubmit = (data: TFieldValues) => {\n startTransition(async () => {\n await onSubmit(data);\n });\n };\n\n // `children` is null for a form with nothing to fill in (an OAuth button,\n // a one-click connect), and the action row is then the whole form —\n // no empty field block above it.\n const hasFields = children !== null && children !== undefined;\n\n const formContent = (\n <Form {...form}>\n <form\n onSubmit={form.handleSubmit(handleSubmit)}\n className=\"flex flex-col gap-5\"\n data-test=\"activation-form\"\n >\n {hasFields ? (\n <fieldset className=\"flex min-w-0 flex-col gap-5\" disabled={loading}>\n {children}\n </fieldset>\n ) : null}\n\n {/*\n Two shapes. With fields: Cancel + Connect, right-aligned, under\n what was filled in. Without (a sign-in button, a one-click\n connect): the button IS the form, so it spans the frame and needs\n no Cancel of its own — the dialog's close does that job.\n */}\n <div className=\"flex flex-col gap-2\">\n <div\n className={\n hasFields\n ? 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end'\n : 'flex flex-col'\n }\n >\n {inline && showCancelButton && hasFields ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={onClose}\n disabled={loading}\n data-test=\"activation-cancel\"\n >\n <Trans i18nKey=\"common:cancel\" defaults=\"Cancel\" />\n </Button>\n ) : null}\n\n <Button\n type=\"submit\"\n size={hasFields ? 'default' : 'lg'}\n className={hasFields ? undefined : 'w-full'}\n disabled={loading || submitButtonDisabled}\n data-test=\"activation-submit\"\n >\n {loading ? (\n <>\n <Icon\n name=\"fa-spinner-third\"\n className=\"h-4 w-4 animate-spin\"\n />\n {submitButtonLoadingText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.connecting\"\n defaults=\"Connecting…\"\n />\n )}\n </>\n ) : (\n (submitButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.connect\"\n defaults=\"Connect\"\n />\n ))\n )}\n </Button>\n </div>\n\n {footnote ? (\n <p\n className={\n hasFields\n ? 'text-muted-foreground text-meta sm:text-right'\n : 'text-muted-foreground text-meta text-center'\n }\n >\n {footnote}\n </p>\n ) : null}\n </div>\n </form>\n </Form>\n );\n\n return (\n <BaseActivationDialog\n isOpen={isOpen}\n onClose={onClose}\n title={title}\n description={description}\n isLoading={loading}\n error={error}\n success={success}\n successTitle={successTitle}\n successMessage={successMessage}\n onSuccessClose={onSuccessClose}\n maxWidth={maxWidth}\n inline={inline}\n >\n {formContent}\n </BaseActivationDialog>\n );\n}\n"]}
@@ -27,7 +27,7 @@ export function BaseMarketplaceTile(props) {
27
27
  if (target.nextSibling) {
28
28
  target.nextSibling.style.display = 'flex';
29
29
  }
30
- } }), _jsx("div", { className: "bg-border ring-border/50 heading-headline hidden h-full w-full items-center justify-center rounded-lg ring-1", children: displayBrandName.charAt(0).toUpperCase() })] })) : (_jsx("div", { className: "bg-border ring-border/50 heading-headline flex h-16 w-16 items-center justify-center rounded-lg border-2 ring-1", children: displayBrandName.charAt(0).toUpperCase() })) }), _jsx(CardTitle, { className: "heading-subhead-lg line-clamp-2", children: displayTitle }), _jsx(If, { condition: categories.length > 0, children: _jsxs("div", { className: "mt-2 flex flex-wrap justify-center gap-1", children: [categories.slice(0, 2).map((cat) => (_jsx(CategoryChip, { productColor: productColor, children: cat.name }, cat.id))), _jsx(If, { condition: categories.length > 2, children: _jsxs(CategoryChip, { productColor: productColor, children: ["+", categories.length - 2] }) })] }) })] }), _jsx(CardContent, { className: "flex-1 pb-8 text-center", children: _jsx(If, { condition: displaySummary, children: _jsx(CardDescription, { className: "text-muted-foreground text-body line-clamp-2 leading-relaxed", children: displaySummary }) }) }), _jsx(If, { condition: displayBrandName !== displayTitle, children: _jsx("p", { className: "text-muted-foreground/70 text-meta absolute right-3 bottom-3", children: displayBrandName }) }), _jsx(If, { condition: !!ctaLink, children: _jsx("div", { className: "text-muted-foreground/60 group-hover:text-foreground absolute bottom-3 left-3 transition-colors", "aria-hidden": "true", children: _jsx(Icon, { name: "fa-light fa-arrow-up-right-from-square", className: "h-4 w-4" }) }) })] }));
30
+ } }), _jsx("div", { className: "bg-border ring-border/50 heading-headline hidden h-full w-full items-center justify-center rounded-lg ring-1", children: displayBrandName.charAt(0).toUpperCase() })] })) : (_jsx("div", { className: "bg-border ring-border/50 heading-headline flex h-16 w-16 items-center justify-center rounded-lg border-2 ring-1", children: displayBrandName.charAt(0).toUpperCase() })) }), _jsx(CardTitle, { className: "heading-subhead-lg line-clamp-2", children: displayTitle }), _jsx(If, { condition: categories.length > 0, children: _jsxs("div", { className: "mt-2 flex flex-wrap justify-center gap-1", children: [categories.slice(0, 2).map((cat) => (_jsx(CategoryChip, { productColor: productColor, children: cat.name }, cat.id))), _jsx(If, { condition: categories.length > 2, children: _jsxs(CategoryChip, { productColor: productColor, children: ["+", categories.length - 2] }) })] }) })] }), _jsx(CardContent, { className: "flex-1 pb-8 text-center", children: _jsx(If, { condition: displaySummary, children: _jsx(CardDescription, { className: "text-muted-foreground text-body line-clamp-2 leading-relaxed", children: displaySummary }) }) }), _jsx(If, { condition: displayBrandName !== displayTitle, children: _jsx("p", { className: "text-muted-foreground/70 text-meta absolute right-3 bottom-3", children: displayBrandName }) }), _jsx(If, { condition: !!ctaLink, children: _jsx("div", { className: "text-muted-foreground/60 group-hover:text-foreground absolute bottom-3 left-3 transition-colors", "aria-hidden": "true", children: _jsx(Icon, { name: "fa-arrow-up-right-from-square", className: "h-4 w-4" }) }) })] }));
31
31
  // External link: opens in new tab
32
32
  if (ctaLink) {
33
33
  return (_jsx("a", { href: ctaLink, target: "_blank", rel: "noopener noreferrer", className: "block h-full", "aria-label": `${displayTitle} (opens in new tab)`, children: cardContent }));
@@ -1 +1 @@
1
- {"version":3,"file":"base-marketplace-tile.js","sourceRoot":"","sources":["../../src/components/base-marketplace-tile.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,yEAAyE;AACzE,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,OAAO,EACL,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AA0CtC,MAAM,UAAU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IAED,mCAAmC;IACnC,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CACL,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC,cAAc,YACvC,WAAW,GACP,CACR,CAAC;IACJ,CAAC;IAED,8DAA8D;IAC9D,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,EACpB,YAAY,EACZ,QAAQ,GAIT;IACC,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,yKAAyK,EACzK,YAAY,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,cAAc,CAC1D,EACD,KAAK,EACH,YAAY;YACV,CAAC,CAAE,EAAE,iBAAiB,EAAE,YAAY,EAAoB;YACxD,CAAC,CAAC,SAAS,YAGd,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode } from 'react';\n\n// `next/link.js`, not `next/link`. `next` ships no `exports` map, so the\n// extensionless subpath only resolves under a bundler — Node's own ESM loader\n// throws ERR_MODULE_NOT_FOUND, and any partner running vitest or plain Node\n// against the published tarball loses this whole module. The `.js` form is not\n// a bypass of Next's resolution: `create-compiler-aliases.js` keys its aliases\n// on the RESOLVED FILE PATH (`<next>/link.js`, with the comment \"Handle fully\n// specified imports like `next/image.js`\"), so an App Router build still gets\n// `next/dist/client/app-dir/link`, exactly as `next/link` would. Next's dist\n// also ends with `Object.assign(exports.default, exports); module.exports =\n// exports.default`, so Node's CJS-default interop and a bundler's `__esModule`\n// interop land on the same component object. Do not \"tidy\" the extension away.\nimport Link from 'next/link.js';\n\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '@ekanos/ui/card';\nimport { Icon } from '@ekanos/ui/icon';\nimport { If } from '@ekanos/ui/if';\nimport { cn } from '@ekanos/ui/utils';\n\nimport type { MarketplaceTileProps } from '../types/integration';\n\n// Type for product category\nexport interface ProductCategory {\n id: string;\n name: string;\n slug: string;\n description?: string;\n}\n\nexport type BaseMarketplaceTileProps = MarketplaceTileProps & {\n /** The display name of the product */\n name: string;\n /** Full description of the product (used for detail pages) */\n description: string;\n /** URL-friendly identifier for the product */\n slug: string;\n /** Short summary text displayed on the tile (1-2 sentences) */\n summary?: string;\n /** Name of the company/brand that provides this product */\n brandName?: string;\n /** Path to the product logo image */\n logoPath?: string;\n /** Text for the call-to-action button */\n ctaText?: string;\n /** External URL for the CTA (opens in new tab when set) */\n ctaLink?: string;\n\n /** Array of categories this product belongs to */\n categories?: ProductCategory[];\n\n /** Hex color from product schema for tile theming */\n productColor?: string;\n /** Additional CSS classes to apply to the tile */\n className?: string;\n\n /** Internal navigation URL for the integration detail page */\n href?: string;\n};\n\nexport function BaseMarketplaceTile(props: BaseMarketplaceTileProps) {\n const {\n name,\n summary,\n brandName,\n logoPath,\n categories = [],\n productColor,\n className,\n href,\n ctaLink,\n } = props;\n\n const displayTitle = name || 'Unknown Product';\n const displaySummary = summary;\n const displayBrandName = brandName || displayTitle;\n\n const cardContent = (\n <Card\n className={cn(\n 'group bg-card relative flex h-full w-full cursor-pointer flex-col overflow-hidden border-0 pt-3 pb-2 shadow-sm transition-all duration-300 hover:shadow-md',\n className,\n )}\n >\n {/* Header: Centered Logo, Title, Categories */}\n <CardHeader className=\"flex flex-col items-center pt-6 pb-3 text-center\">\n {/* Logo */}\n <div className=\"mb-3\">\n {logoPath ? (\n <div className=\"flex h-16 w-16 items-center justify-center\">\n {/* eslint-disable-next-line @next/next/no-img-element */}\n <img\n src={logoPath}\n alt={`${displayBrandName} logo`}\n width={64}\n height={64}\n className=\"max-h-full max-w-full object-contain\"\n onError={(e) => {\n const target = e.target as HTMLImageElement;\n target.style.display = 'none';\n if (target.nextSibling) {\n (target.nextSibling as HTMLElement).style.display = 'flex';\n }\n }}\n />\n <div className=\"bg-border ring-border/50 heading-headline hidden h-full w-full items-center justify-center rounded-lg ring-1\">\n {displayBrandName.charAt(0).toUpperCase()}\n </div>\n </div>\n ) : (\n <div className=\"bg-border ring-border/50 heading-headline flex h-16 w-16 items-center justify-center rounded-lg border-2 ring-1\">\n {displayBrandName.charAt(0).toUpperCase()}\n </div>\n )}\n </div>\n\n {/* Title */}\n <CardTitle className=\"heading-subhead-lg line-clamp-2\">\n {displayTitle}\n </CardTitle>\n\n {/* Category Badges - Under Title */}\n <If condition={categories.length > 0}>\n <div className=\"mt-2 flex flex-wrap justify-center gap-1\">\n {categories.slice(0, 2).map((cat) => (\n <CategoryChip key={cat.id} productColor={productColor}>\n {cat.name}\n </CategoryChip>\n ))}\n <If condition={categories.length > 2}>\n <CategoryChip productColor={productColor}>\n +{categories.length - 2}\n </CategoryChip>\n </If>\n </div>\n </If>\n </CardHeader>\n\n {/* Content: Summary */}\n <CardContent className=\"flex-1 pb-8 text-center\">\n <If condition={displaySummary}>\n <CardDescription className=\"text-muted-foreground text-body line-clamp-2 leading-relaxed\">\n {displaySummary}\n </CardDescription>\n </If>\n </CardContent>\n\n {/* Brand Name - Bottom Right */}\n <If condition={displayBrandName !== displayTitle}>\n <p className=\"text-muted-foreground/70 text-meta absolute right-3 bottom-3\">\n {displayBrandName}\n </p>\n </If>\n\n {/* External Link Indicator */}\n <If condition={!!ctaLink}>\n <div\n className=\"text-muted-foreground/60 group-hover:text-foreground absolute bottom-3 left-3 transition-colors\"\n aria-hidden=\"true\"\n >\n <Icon\n name=\"fa-light fa-arrow-up-right-from-square\"\n className=\"h-4 w-4\"\n />\n </div>\n </If>\n </Card>\n );\n\n // External link: opens in new tab\n if (ctaLink) {\n return (\n <a\n href={ctaLink}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"block h-full\"\n aria-label={`${displayTitle} (opens in new tab)`}\n >\n {cardContent}\n </a>\n );\n }\n\n // Internal link: uses Next.js Link\n if (href) {\n return (\n <Link href={href} className=\"block h-full\">\n {cardContent}\n </Link>\n );\n }\n\n // Fallback: render without Link (for backwards compatibility)\n return cardContent;\n}\n\n/**\n * A category chip, tinted with the product's own colour when it has one. The\n * colour is a partner's product colour from the product schema, not a theme\n * token — a data colour, so it is a chip rather than a `Badge` (a Badge owns\n * its colour). The tint is that colour at 40% alpha.\n */\nfunction CategoryChip({\n productColor,\n children,\n}: {\n productColor?: string;\n children: ReactNode;\n}) {\n return (\n <span\n className={cn(\n 'text-secondary-foreground text-fine inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full px-2 py-0.5 font-medium whitespace-nowrap',\n productColor ? 'bg-(--product-color)/40' : 'bg-secondary',\n )}\n style={\n productColor\n ? ({ '--product-color': productColor } as CSSProperties)\n : undefined\n }\n >\n {children}\n </span>\n );\n}\n"]}
1
+ {"version":3,"file":"base-marketplace-tile.js","sourceRoot":"","sources":["../../src/components/base-marketplace-tile.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,yEAAyE;AACzE,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,OAAO,EACL,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AA0CtC,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,SAAS,EACT,QAAQ,EACR,UAAU,GAAG,EAAE,EACf,YAAY,EACZ,SAAS,EACT,IAAI,EACJ,OAAO,GACR,GAAG,KAAK,CAAC;IAEV,MAAM,YAAY,GAAG,IAAI,IAAI,iBAAiB,CAAC;IAC/C,MAAM,cA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AAY,CAAC,EACpB,YAAY,EACZ,QAAQ,GAIT;IACC,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,yKAAyK,EACzK,YAAY,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,cAAc,CAC1D,EACD,KAAK,EACH,YAAY;YACV,CAAC,CAAE,EAAE,iBAAiB,EAAE,YAAY,EAAoB;YACxD,CAAC,CAAC,SAAS,YAGd,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode } from 'react';\n\n// `next/link.js`, not `next/link`. `next` ships no `exports` map, so the\n// extensionless subpath only resolves under a bundler — Node's own ESM loader\n// throws ERR_MODULE_NOT_FOUND, and any partner running vitest or plain Node\n// against the published tarball loses this whole module. The `.js` form is not\n// a bypass of Next's resolution: `create-compiler-aliases.js` keys its aliases\n// on the RESOLVED FILE PATH (`<next>/link.js`, with the comment \"Handle fully\n// specified imports like `next/image.js`\"), so an App Router build still gets\n// `next/dist/client/app-dir/link`, exactly as `next/link` would. Next's dist\n// also ends with `Object.assign(exports.default, exports); module.exports =\n// exports.default`, so Node's CJS-default interop and a bundler's `__esModule`\n// interop land on the same component object. Do not \"tidy\" the extension away.\nimport Link from 'next/link.js';\n\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '@ekanos/ui/card';\nimport { Icon } from '@ekanos/ui/icon';\nimport { If } from '@ekanos/ui/if';\nimport { cn } from '@ekanos/ui/utils';\n\nimport type { MarketplaceTileProps } from '../types/integration';\n\n// Type for product category\nexport interface ProductCategory {\n id: string;\n name: string;\n slug: string;\n description?: string;\n}\n\nexport type BaseMarketplaceTileProps = MarketplaceTileProps & {\n /** The display name of the product */\n name: string;\n /** Full description of the product (used for detail pages) */\n description: string;\n /** URL-friendly identifier for the product */\n slug: string;\n /** Short summary text displayed on the tile (1-2 sentences) */\n summary?: string;\n /** Name of the company/brand that provides this product */\n brandName?: string;\n /** Path to the product logo image */\n logoPath?: string;\n /** Text for the call-to-action button */\n ctaText?: string;\n /** External URL for the CTA (opens in new tab when set) */\n ctaLink?: string;\n\n /** Array of categories this product belongs to */\n categories?: ProductCategory[];\n\n /** Hex color from product schema for tile theming */\n productColor?: string;\n /** Additional CSS classes to apply to the tile */\n className?: string;\n\n /** Internal navigation URL for the integration detail page */\n href?: string;\n};\n\nexport function BaseMarketplaceTile(props: BaseMarketplaceTileProps) {\n const {\n name,\n summary,\n brandName,\n logoPath,\n categories = [],\n productColor,\n className,\n href,\n ctaLink,\n } = props;\n\n const displayTitle = name || 'Unknown Product';\n const displaySummary = summary;\n const displayBrandName = brandName || displayTitle;\n\n const cardContent = (\n <Card\n className={cn(\n 'group bg-card relative flex h-full w-full cursor-pointer flex-col overflow-hidden border-0 pt-3 pb-2 shadow-sm transition-all duration-300 hover:shadow-md',\n className,\n )}\n >\n {/* Header: Centered Logo, Title, Categories */}\n <CardHeader className=\"flex flex-col items-center pt-6 pb-3 text-center\">\n {/* Logo */}\n <div className=\"mb-3\">\n {logoPath ? (\n <div className=\"flex h-16 w-16 items-center justify-center\">\n {/* eslint-disable-next-line @next/next/no-img-element */}\n <img\n src={logoPath}\n alt={`${displayBrandName} logo`}\n width={64}\n height={64}\n className=\"max-h-full max-w-full object-contain\"\n onError={(e) => {\n const target = e.target as HTMLImageElement;\n target.style.display = 'none';\n if (target.nextSibling) {\n (target.nextSibling as HTMLElement).style.display = 'flex';\n }\n }}\n />\n <div className=\"bg-border ring-border/50 heading-headline hidden h-full w-full items-center justify-center rounded-lg ring-1\">\n {displayBrandName.charAt(0).toUpperCase()}\n </div>\n </div>\n ) : (\n <div className=\"bg-border ring-border/50 heading-headline flex h-16 w-16 items-center justify-center rounded-lg border-2 ring-1\">\n {displayBrandName.charAt(0).toUpperCase()}\n </div>\n )}\n </div>\n\n {/* Title */}\n <CardTitle className=\"heading-subhead-lg line-clamp-2\">\n {displayTitle}\n </CardTitle>\n\n {/* Category Badges - Under Title */}\n <If condition={categories.length > 0}>\n <div className=\"mt-2 flex flex-wrap justify-center gap-1\">\n {categories.slice(0, 2).map((cat) => (\n <CategoryChip key={cat.id} productColor={productColor}>\n {cat.name}\n </CategoryChip>\n ))}\n <If condition={categories.length > 2}>\n <CategoryChip productColor={productColor}>\n +{categories.length - 2}\n </CategoryChip>\n </If>\n </div>\n </If>\n </CardHeader>\n\n {/* Content: Summary */}\n <CardContent className=\"flex-1 pb-8 text-center\">\n <If condition={displaySummary}>\n <CardDescription className=\"text-muted-foreground text-body line-clamp-2 leading-relaxed\">\n {displaySummary}\n </CardDescription>\n </If>\n </CardContent>\n\n {/* Brand Name - Bottom Right */}\n <If condition={displayBrandName !== displayTitle}>\n <p className=\"text-muted-foreground/70 text-meta absolute right-3 bottom-3\">\n {displayBrandName}\n </p>\n </If>\n\n {/* External Link Indicator */}\n <If condition={!!ctaLink}>\n <div\n className=\"text-muted-foreground/60 group-hover:text-foreground absolute bottom-3 left-3 transition-colors\"\n aria-hidden=\"true\"\n >\n <Icon name=\"fa-arrow-up-right-from-square\" className=\"h-4 w-4\" />\n </div>\n </If>\n </Card>\n );\n\n // External link: opens in new tab\n if (ctaLink) {\n return (\n <a\n href={ctaLink}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"block h-full\"\n aria-label={`${displayTitle} (opens in new tab)`}\n >\n {cardContent}\n </a>\n );\n }\n\n // Internal link: uses Next.js Link\n if (href) {\n return (\n <Link href={href} className=\"block h-full\">\n {cardContent}\n </Link>\n );\n }\n\n // Fallback: render without Link (for backwards compatibility)\n return cardContent;\n}\n\n/**\n * A category chip, tinted with the product's own colour when it has one. The\n * colour is a partner's product colour from the product schema, not a theme\n * token — a data colour, so it is a chip rather than a `Badge` (a Badge owns\n * its colour). The tint is that colour at 40% alpha.\n */\nfunction CategoryChip({\n productColor,\n children,\n}: {\n productColor?: string;\n children: ReactNode;\n}) {\n return (\n <span\n className={cn(\n 'text-secondary-foreground text-fine inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full px-2 py-0.5 font-medium whitespace-nowrap',\n productColor ? 'bg-(--product-color)/40' : 'bg-secondary',\n )}\n style={\n productColor\n ? ({ '--product-color': productColor } as CSSProperties)\n : undefined\n }\n >\n {children}\n </span>\n );\n}\n"]}
@@ -128,6 +128,6 @@ export function OAuthActivationForm(props) {
128
128
  : isConnected
129
129
  ? (activateButtonText !== null && activateButtonText !== void 0 ? activateButtonText : (_jsx(Trans, { i18nKey: "common:integrationConnect.connect", defaults: "Connect" })))
130
130
  : (connectButtonText !== null && connectButtonText !== void 0 ? connectButtonText : (_jsx(Trans, { i18nKey: "common:integrationConnect.continueWith", values: { name: displayName }, defaults: `Continue with ${displayName}` })));
131
- return (_jsx(BaseActivationForm, { isOpen: true, inline: inline, onClose: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(), title: title, description: description, form: form, onSubmit: handleSubmit, isLoading: externalLoading || activateIntegration.isPending || finishing, error: displayError, submitButtonText: buttonText, submitButtonLoadingText: isConnected && !signInAgain ? (_jsx(Trans, { i18nKey: "common:integrationConnect.finishing", defaults: "Finishing setup\u2026" })) : (_jsx(Trans, { i18nKey: "common:integrationConnect.redirecting", defaults: "Opening sign-in\u2026" })), submitButtonDisabled: isCheckingConnection, footnote: signInAgain ? (_jsx(Trans, { i18nKey: "common:integrationConnect.reconnectFootnote", values: { name: displayName }, defaults: `You'll sign in on ${displayName}'s site again and come straight back here.` })) : isConnected ? (_jsxs("span", { className: "inline-flex items-center gap-1.5", children: [_jsx(Icon, { name: "fa-light fa-circle-check", className: "text-success h-4 w-4" }), _jsx(Trans, { i18nKey: "common:integrationConnect.signedIn", values: { name: displayName }, defaults: `Signed in to ${displayName}.` })] })) : (_jsx(Trans, { i18nKey: "common:integrationConnect.oauthFootnote", values: { name: displayName }, defaults: `You'll sign in on ${displayName}'s site and come straight back here.` })), children: isConnected && children ? children : null }));
131
+ return (_jsx(BaseActivationForm, { isOpen: true, inline: inline, onClose: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(), title: title, description: description, form: form, onSubmit: handleSubmit, isLoading: externalLoading || activateIntegration.isPending || finishing, error: displayError, submitButtonText: buttonText, submitButtonLoadingText: isConnected && !signInAgain ? (_jsx(Trans, { i18nKey: "common:integrationConnect.finishing", defaults: "Finishing setup\u2026" })) : (_jsx(Trans, { i18nKey: "common:integrationConnect.redirecting", defaults: "Opening sign-in\u2026" })), submitButtonDisabled: isCheckingConnection, footnote: signInAgain ? (_jsx(Trans, { i18nKey: "common:integrationConnect.reconnectFootnote", values: { name: displayName }, defaults: `You'll sign in on ${displayName}'s site again and come straight back here.` })) : isConnected ? (_jsxs("span", { className: "inline-flex items-center gap-1.5", children: [_jsx(Icon, { name: "fa-circle-check", className: "text-success h-4 w-4" }), _jsx(Trans, { i18nKey: "common:integrationConnect.signedIn", values: { name: displayName }, defaults: `Signed in to ${displayName}.` })] })) : (_jsx(Trans, { i18nKey: "common:integrationConnect.oauthFootnote", values: { name: displayName }, defaults: `You'll sign in on ${displayName}'s site and come straight back here.` })), children: isConnected && children ? children : null }));
132
132
  }
133
133
  //# sourceMappingURL=oauth-activation-form.js.map
@@ -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,i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uC,EAC/C,QAAQ,EAAC,uBAAkB,GAC3B,CACH,EAEH,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EACN,WAAW,CAAC,CAAC,CAAC,CACZ,KAAC,KAAK,IACJ,OAAO,EAAC,6CAA6C,EACrD,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAC7B,QAAQ,EAAE,qBAAqB,WAAW,4CAA4C,GACtF,CACH,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAChB,gBAAM,SAAS,EAAC,kCAAkC,aAChD,KAAC,IAAI,IACH,IAAI,EAAC,0BAA0B,EAC/B,SAAS,EAAC,sBAAsB,GAChC,EACF,KAAC,KAAK,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\n name=\"fa-light fa-circle-check\"\n className=\"text-success h-4 w-4\"\n />\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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AAE,qBAAqB,WAAW,4CAA4C,GACtF,CACH,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAChB,gBAAM,SAAS,EAAC,kCAAkC,aAChD,KAAC,IAAI,IAAC,IAAI,EAAC,iBAAiB,EAAC,SAAS,EAAC,sBAAsB,GAAG,EAChE,KAAC,KAAK,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"]}
@@ -27,12 +27,12 @@ export function AiPromptChip({ label, prompt, context, sourceWidget, title, onAf
27
27
  onAfterAsk === null || onAfterAsk === void 0 ? void 0 : onAfterAsk();
28
28
  };
29
29
  if (variant === 'header') {
30
- return (_jsx(Button, { variant: "ghost", size: "sm", className: cn('h-8 w-8 p-0', className), onClick: handleClick, "aria-label": `Ask AI: ${label}`, children: _jsx(Icon, { name: "fa-light fa-wand-magic-sparkles", className: "h-4 w-4" }) }));
30
+ return (_jsx(Button, { variant: "ghost", size: "sm", className: cn('h-8 w-8 p-0', className), onClick: handleClick, "aria-label": `Ask AI: ${label}`, children: _jsx(Icon, { name: "fa-wand-magic-sparkles", className: "h-4 w-4" }) }));
31
31
  }
32
32
  if (variant === 'footer') {
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-light fa-wand-magic-sparkles", className: "text-primary-strong h-4 w-4 shrink-0" }), _jsx("span", { className: "text-left", children: label })] }));
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('rounded-full px-3', className), "aria-label": label, children: [_jsx(Icon, { name: "fa-light fa-wand-magic-sparkles", className: "text-primary-strong h-3.5 w-3.5 shrink-0" }), _jsx("span", { children: label })] }));
36
+ return (_jsxs(Button, { type: "button", variant: "outline", size: "xs", onClick: handleClick, className: cn('rounded-full 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,iCAAiC,EAAC,SAAS,EAAC,SAAS,GAAG,GAC5D,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,iCAAiC,EACtC,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,mBAAmB,EAAE,SAAS,CAAC,gBACjC,KAAK,aAEjB,KAAC,IAAI,IACH,IAAI,EAAC,iCAAiC,EACtC,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-light 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-light 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('rounded-full px-3', className)}\n aria-label={label}\n >\n <Icon\n name=\"fa-light 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"]}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AAI,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,mBAAmB,EAAE,SAAS,CAAC,gBACjC,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('rounded-full 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"]}
@@ -53,7 +53,7 @@ export function WidgetAskBar({ context }) {
53
53
  }, [dismiss, isActive]);
54
54
  return (_jsxs("div", { ref: containerRef, className: "border-border/60 shrink-0 border-t", "data-test": "widget-ask-bar", 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-primary 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-light 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/40 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: "rounded-full px-3", "aria-label": s.label, children: [_jsx(Icon, { name: "fa-light 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) => {
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-primary 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/40 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: "rounded-full 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,OAAO,EACL,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AACpC,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;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAMrC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,OAAO,EAAS;;IAC7C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CA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AC,CAAC,KAAK,aAEnB,KAAC,IAAI,IACH,IAAI,EAAC,iCAAiC,EACtC,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/60 shrink-0 border-t\"\n data-test=\"widget-ask-bar\"\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-primary 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-light 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/40 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=\"rounded-full px-3\"\n aria-label={s.label}\n >\n <Icon\n name=\"fa-light 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"]}
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,OAAO,EACL,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,E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,CAAC,IAAI,CACzB,cACE,SAAS,EAAC,sBAAsB,eACtB,4BAA4B,YAErC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACtB,MAAC,MAAM,IAEL,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,mBAAmB,gBACjB,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/60 shrink-0 border-t\"\n data-test=\"widget-ask-bar\"\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-primary 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/40 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=\"rounded-full 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"]}
@@ -25,12 +25,12 @@ function StateNote({ icon, title, description, action, actionVariant, role, test
25
25
  */
26
26
  export function WidgetEmptyState({ tone = 'positive', title, description, action, }) {
27
27
  const positive = tone === 'positive';
28
- return (_jsx(StateNote, { icon: positive ? 'fa-light fa-circle-check' : 'fa-light fa-inbox', title: title !== null && title !== void 0 ? title : (positive ? (_jsx(Trans, { i18nKey: "dashboard:widgetEmptyPositive", defaults: "You're all caught up" })) : (_jsx(Trans, { i18nKey: "dashboard:widgetEmptyNeutral", defaults: "Nothing here yet" }))), description: description, action: action, actionVariant: "outline", role: "status", testId: `widget-empty-${tone}` }));
28
+ return (_jsx(StateNote, { icon: positive ? 'fa-circle-check' : 'fa-inbox', title: title !== null && title !== void 0 ? title : (positive ? (_jsx(Trans, { i18nKey: "dashboard:widgetEmptyPositive", defaults: "You're all caught up" })) : (_jsx(Trans, { i18nKey: "dashboard:widgetEmptyNeutral", defaults: "Nothing here yet" }))), description: description, action: action, actionVariant: "outline", role: "status", testId: `widget-empty-${tone}` }));
29
29
  }
30
30
  const INACTIVE_ICON = {
31
- 'not-connected': 'fa-light fa-plug',
32
- 'no-access': 'fa-light fa-user-group',
33
- 'setup-needed': 'fa-light fa-sliders',
31
+ 'not-connected': 'fa-plug',
32
+ 'no-access': 'fa-user-group',
33
+ 'setup-needed': 'fa-sliders',
34
34
  };
35
35
  /**
36
36
  * Why the widget can't show data. `not-connected` offers one Connect button;
@@ -68,12 +68,12 @@ export function WidgetLoadingSkeleton({ variant = 'rows', }) {
68
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/50 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
- 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-light 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-light fa-arrows-rotate", className: cn('h-4 w-4', retrying && 'animate-spin'), "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRetry", defaults: "Try again" })] })) : null] }));
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] }));
72
72
  }
73
73
  export function WidgetDataLoading() {
74
- return (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Icon, { name: "fa-light fa-spinner-third", className: "text-muted-foreground h-8 w-8 animate-spin" }) }));
74
+ return (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Icon, { name: "fa-spinner-third", className: "text-muted-foreground h-8 w-8 animate-spin" }) }));
75
75
  }
76
76
  export function WidgetDisabledState() {
77
- return (_jsxs("div", { className: "flex flex-col items-center justify-center py-8 text-center", children: [_jsx(Icon, { name: "fa-light fa-ban", className: "text-muted-foreground mb-4 h-8 w-8" }), _jsx("p", { className: "text-muted-foreground text-meta", children: _jsx(Trans, { i18nKey: "dashboard:widgetDisabled", defaults: "Widget Disabled" }) })] }));
77
+ return (_jsxs("div", { className: "flex flex-col items-center justify-center py-8 text-center", children: [_jsx(Icon, { name: "fa-ban", className: "text-muted-foreground mb-4 h-8 w-8" }), _jsx("p", { className: "text-muted-foreground text-meta", children: _jsx(Trans, { i18nKey: "dashboard:widgetDisabled", defaults: "Widget Disabled" }) })] }));
78
78
  }
79
79
  //# sourceMappingURL=widget-state-components.js.map
@@ -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;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,GACN,CACV,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,MAAM,IAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,QAAQ,EAAC,OAAO,E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,iBAAiB,EACtB,SAAS,EAAC,oCAAoC,GAC9C,EACF,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-light fa-circle-check' : 'fa-light 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-light fa-plug',\n 'no-access': 'fa-light fa-user-group',\n 'setup-needed': 'fa-light 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-light 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-light 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-light 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\n name=\"fa-light fa-ban\"\n className=\"text-muted-foreground mb-4 h-8 w-8\"\n />\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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,CAAC,CAAC,CAAC,CACF,KAAC,KAAK,IACJ,OAAO,EAAC,2BAA2B,EACnC,QAAQ,EAAC,8BAA8B,GACvC,CACH,GACC,IACA,EACL,OAAO,CAAC,CAAC,CAAC,CACT,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,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"]}
@@ -70,7 +70,7 @@ declare function WidgetHeader({ title, subtitle, description, context, trailing,
70
70
  * when `external`; otherwise it runs `onSelect`.
71
71
  */
72
72
  declare function WidgetMenuItem({ icon, href, external, onSelect, disabled, children, }: {
73
- /** A Font Awesome class, e.g. `fa-light fa-envelope`. */
73
+ /** A Font Awesome class, e.g. `fa-envelope`. */
74
74
  icon?: string;
75
75
  href?: string;
76
76
  external?: boolean;
@@ -84,7 +84,7 @@ declare function WidgetMenuItem({ icon, href, external, onSelect, disabled, chil
84
84
  * through `Widget.Header`'s `menu` prop.
85
85
  */
86
86
  declare function WidgetMenuChoice<Value extends string>({ icon, label, value, options, onChange, }: {
87
- /** A Font Awesome class, e.g. `fa-light fa-scale-balanced`. */
87
+ /** A Font Awesome class, e.g. `fa-scale-balanced`. */
88
88
  icon?: string;
89
89
  label: ReactNode;
90
90
  value: Value;
@@ -46,7 +46,7 @@ class WidgetErrorBoundary extends Component {
46
46
  }
47
47
  render() {
48
48
  if (this.state.hasError) {
49
- return (_jsxs("div", { role: "alert", className: "flex flex-1 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-light 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: _jsx(Trans, { i18nKey: "dashboard:widgetCrashedTitle", defaults: "This widget ran into a problem" }) }), _jsx("p", { className: "text-muted-foreground text-meta max-w-xs", children: _jsx(Trans, { i18nKey: "dashboard:widgetCrashedBody", defaults: "Try again. If it keeps happening, reload the page." }) })] }), _jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: this.retry, "data-test": "widget-crash-retry", children: [_jsx(Icon, { name: "fa-light fa-arrows-rotate", className: "h-4 w-4", "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRetry", defaults: "Try again" })] })] }));
49
+ return (_jsxs("div", { role: "alert", className: "flex flex-1 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: _jsx(Trans, { i18nKey: "dashboard:widgetCrashedTitle", defaults: "This widget ran into a problem" }) }), _jsx("p", { className: "text-muted-foreground text-meta max-w-xs", children: _jsx(Trans, { i18nKey: "dashboard:widgetCrashedBody", defaults: "Try again. If it keeps happening, reload the page." }) })] }), _jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: this.retry, "data-test": "widget-crash-retry", children: [_jsx(Icon, { name: "fa-arrows-rotate", className: "h-4 w-4", "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRetry", defaults: "Try again" })] })] }));
50
50
  }
51
51
  return this.props.children;
52
52
  }
@@ -77,7 +77,7 @@ function WidgetCard({ children }) {
77
77
  return (_jsxs(Card, { className: cn(
78
78
  // Neutralize the shadcn card's own py-6/gap-6 box model — widget
79
79
  // chrome owns all vertical spacing via its header/content/footer.
80
- 'shadow-widget @container/widget relative flex h-full flex-col gap-0 overflow-hidden rounded-lg border-0 py-0', meta.className), "data-widget-id": meta.widgetId, children: [children, _jsx(WidgetFreshness, {})] }));
80
+ 'shadow-ring @container/widget relative flex h-full flex-col gap-0 overflow-hidden rounded-lg border-0 py-0', meta.className), "data-widget-id": meta.widgetId, children: [children, _jsx(WidgetFreshness, {})] }));
81
81
  }
82
82
  // ─── Header ─────────────────────────────────────────────────────────────────
83
83
  function CollapseButton() {
@@ -85,13 +85,13 @@ function CollapseButton() {
85
85
  const { state, actions, meta } = useWidget();
86
86
  return (_jsx(Button, { variant: "outline", size: "icon", onClick: actions.toggleCollapsed, disabled: state.pendingCollapse, className: "bg-background dark:bg-secondary relative h-6 w-6 rounded-full before:absolute before:top-1/2 before:left-1/2 before:h-11 before:w-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']", "aria-expanded": !state.collapsed, "aria-controls": `widget-content-${meta.widgetId}`, "aria-label": state.collapsed
87
87
  ? `Expand ${(_a = meta.title) !== null && _a !== void 0 ? _a : 'widget'}`
88
- : `Collapse ${(_b = meta.title) !== null && _b !== void 0 ? _b : 'widget'}`, children: _jsx(Icon, { name: "fa-light fa-chevron-right", className: cn('ease-out-strong h-4 w-4 transition-transform duration-200 motion-reduce:transition-none', !state.collapsed && 'rotate-90') }) }));
88
+ : `Collapse ${(_b = meta.title) !== null && _b !== void 0 ? _b : 'widget'}`, children: _jsx(Icon, { name: "fa-chevron-right", className: cn('ease-out-strong h-4 w-4 transition-transform duration-200 motion-reduce:transition-none', !state.collapsed && 'rotate-90') }) }));
89
89
  }
90
90
  function HeaderTrailing({ trailing }) {
91
91
  var _a;
92
92
  if (trailing.kind === 'link') {
93
93
  const link = trailing.external ? (_jsx("a", { href: trailing.href, target: "_blank", rel: "noopener noreferrer" })) : (_jsx(Link, { href: trailing.href }));
94
- return (_jsxs(Button, { variant: "ghost", size: "sm", render: link, nativeButton: false, "data-test": "widget-header-link", children: [trailing.label, _jsx(Icon, { name: "fa-light fa-chevron-right", className: "h-3 w-3", "aria-hidden": true })] }));
94
+ return (_jsxs(Button, { variant: "ghost", size: "sm", render: link, nativeButton: false, "data-test": "widget-header-link", children: [trailing.label, _jsx(Icon, { name: "fa-chevron-right", className: "h-3 w-3", "aria-hidden": true })] }));
95
95
  }
96
96
  return (_jsxs(Select, { value: trailing.value, onValueChange: (value) => {
97
97
  if (typeof value === 'string')
@@ -106,12 +106,13 @@ const VERDICT_BADGE_TONE = {
106
106
  };
107
107
  /**
108
108
  * The verdict under the title. Anything but `clear` is a status pill, the
109
- * words carrying the tone and the dot confirming it; `clear` reads muted,
110
- * with a check, because good news shouldn't shout.
109
+ * words carrying the tone and the dot confirming it. `clear` is plain ink and
110
+ * a check, no colour at all (plan 251 D24): calm is the absence of colour,
111
+ * so colour on a dashboard always means "look here".
111
112
  */
112
113
  function VerdictLine({ verdict }) {
113
114
  if (verdict.tone === 'clear') {
114
- return (_jsxs("p", { className: "text-muted-foreground text-meta flex min-w-0 items-center gap-1.5", "data-test": "widget-verdict", "data-verdict": "clear", children: [_jsx(Icon, { name: "fa-light fa-circle-check", className: "h-3.5 w-3.5 shrink-0", "aria-hidden": true }), _jsx("span", { className: "truncate", children: verdict.sentence })] }));
115
+ return (_jsxs("p", { className: "text-foreground text-meta flex min-w-0 items-center gap-1.5", "data-test": "widget-verdict", "data-verdict": "clear", children: [_jsx(Icon, { name: "fa-circle-check", className: "h-3.5 w-3.5 shrink-0", "aria-hidden": true }), _jsx("span", { className: "truncate", children: verdict.sentence })] }));
115
116
  }
116
117
  return (_jsx(StatusBadge, { tone: VERDICT_BADGE_TONE[verdict.tone], className: "mt-0.5 max-w-full", "data-test": "widget-verdict", "data-verdict": verdict.tone, children: _jsx("span", { className: "truncate", children: verdict.sentence }) }));
117
118
  }
@@ -151,9 +152,7 @@ function WidgetMenu({ items }) {
151
152
  if (!hasNavigation && !meta.isPinnable)
152
153
  return null;
153
154
  const title = (_a = meta.title) !== null && _a !== void 0 ? _a : 'widget';
154
- return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { variant: "ghost", size: "icon-sm", className: "text-muted-foreground hover:text-foreground", "aria-label": `Actions for ${title}`, "data-test": `widget-menu-${meta.widgetId}` }), children: _jsx(Icon, { name: "fa-light fa-ellipsis", className: "h-4 w-4", "aria-hidden": true }) }), _jsxs(DropdownMenuContent, { align: "end", className: "min-w-48", children: [items, meta.openHref ? (_jsxs(DropdownMenuItem, { render: _jsx(Link, { href: meta.openHref }), children: [_jsx(Icon, { name: "fa-light fa-arrow-up-right-from-square", "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetOpenInWorkspace", defaults: "Open in workspace" })] })) : null, refresh ? (_jsxs(DropdownMenuItem, { onClick: refresh, disabled: data === null || data === void 0 ? void 0 : data.refreshing, children: [_jsx(Icon, { name: "fa-light fa-arrows-rotate", "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRefresh", defaults: "Refresh" })] })) : null, hasNavigation && meta.isPinnable ? _jsx(DropdownMenuSeparator, {}) : null, meta.isPinnable ? (_jsxs(DropdownMenuItem, { onClick: actions.togglePinned, disabled: state.pendingPin, "data-test": `widget-menu-pin-${meta.widgetId}`, children: [_jsx(Icon, { name: state.pinned
155
- ? 'fa-light fa-thumbtack-slash'
156
- : 'fa-light fa-thumbtack', "aria-hidden": true }), state.pinned ? (_jsx(Trans, { i18nKey: "dashboard:widgetUnpin", defaults: "Unpin from board" })) : (_jsx(Trans, { i18nKey: "dashboard:widgetPin", defaults: "Pin to board" }))] })) : null] })] }));
155
+ return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { variant: "ghost", size: "icon-sm", className: "text-muted-foreground hover:text-foreground", "aria-label": `Actions for ${title}`, "data-test": `widget-menu-${meta.widgetId}` }), children: _jsx(Icon, { name: "fa-ellipsis", className: "h-4 w-4", "aria-hidden": true }) }), _jsxs(DropdownMenuContent, { align: "end", className: "min-w-48", children: [items, meta.openHref ? (_jsxs(DropdownMenuItem, { render: _jsx(Link, { href: meta.openHref }), children: [_jsx(Icon, { name: "fa-arrow-up-right-from-square", "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetOpenInWorkspace", defaults: "Open in workspace" })] })) : null, refresh ? (_jsxs(DropdownMenuItem, { onClick: refresh, disabled: data === null || data === void 0 ? void 0 : data.refreshing, children: [_jsx(Icon, { name: "fa-arrows-rotate", "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRefresh", defaults: "Refresh" })] })) : null, hasNavigation && meta.isPinnable ? _jsx(DropdownMenuSeparator, {}) : null, meta.isPinnable ? (_jsxs(DropdownMenuItem, { onClick: actions.togglePinned, disabled: state.pendingPin, "data-test": `widget-menu-pin-${meta.widgetId}`, children: [_jsx(Icon, { name: state.pinned ? 'fa-thumbtack-slash' : 'fa-thumbtack', "aria-hidden": true }), state.pinned ? (_jsx(Trans, { i18nKey: "dashboard:widgetUnpin", defaults: "Unpin from board" })) : (_jsx(Trans, { i18nKey: "dashboard:widgetPin", defaults: "Pin to board" }))] })) : null] })] }));
157
156
  }
158
157
  /**
159
158
  * One widget-specific entry in the header's ⋯ menu; pass it through
@@ -162,9 +161,7 @@ function WidgetMenu({ items }) {
162
161
  */
163
162
  function WidgetMenuItem({ icon, href, external = false, onSelect, disabled, children, }) {
164
163
  const link = !href ? undefined : external ? (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer" })) : (_jsx(Link, { href: href }));
165
- return (_jsxs(DropdownMenuItem, { render: link, onClick: onSelect, disabled: disabled, children: [_jsx(Icon, { name: icon !== null && icon !== void 0 ? icon : (external
166
- ? 'fa-light fa-arrow-up-right-from-square'
167
- : 'fa-light fa-arrow-right'), "aria-hidden": true }), children] }));
164
+ return (_jsxs(DropdownMenuItem, { render: link, onClick: onSelect, disabled: disabled, children: [_jsx(Icon, { name: icon !== null && icon !== void 0 ? icon : (external ? 'fa-arrow-up-right-from-square' : 'fa-arrow-right'), "aria-hidden": true }), children] }));
168
165
  }
169
166
  /**
170
167
  * A setting that doesn't earn the header's one trailing slot (a comparison
@@ -173,7 +170,7 @@ function WidgetMenuItem({ icon, href, external = false, onSelect, disabled, chil
173
170
  */
174
171
  function WidgetMenuChoice({ icon, label, value, options, onChange, }) {
175
172
  const current = options.find((option) => option.value === value);
176
- return (_jsxs(DropdownMenuSub, { children: [_jsxs(DropdownMenuSubTrigger, { children: [_jsx(Icon, { name: icon !== null && icon !== void 0 ? icon : 'fa-light fa-sliders', "aria-hidden": true }), _jsx("span", { className: "flex-1", children: label }), current ? (_jsx("span", { className: "text-muted-foreground text-fine", children: current.label })) : null] }), _jsx(DropdownMenuSubContent, { className: "min-w-44", children: _jsx(DropdownMenuRadioGroup, { value: value, onValueChange: (next) => {
173
+ return (_jsxs(DropdownMenuSub, { children: [_jsxs(DropdownMenuSubTrigger, { children: [_jsx(Icon, { name: icon !== null && icon !== void 0 ? icon : 'fa-sliders', "aria-hidden": true }), _jsx("span", { className: "flex-1", children: label }), current ? (_jsx("span", { className: "text-muted-foreground text-fine", children: current.label })) : null] }), _jsx(DropdownMenuSubContent, { className: "min-w-44", children: _jsx(DropdownMenuRadioGroup, { value: value, onValueChange: (next) => {
177
174
  const match = options.find((option) => option.value === next);
178
175
  if (match)
179
176
  onChange(match.value);
@@ -188,7 +185,7 @@ function WidgetFreshness() {
188
185
  const updated = useRelativeTime(data === null || data === void 0 ? void 0 : data.updatedAt);
189
186
  if (state.state !== 'active' || state.collapsed || !updated)
190
187
  return null;
191
- return (_jsx("div", { className: "text-muted-foreground border-border/60 text-fine flex shrink-0 items-center gap-1.5 border-t px-5 py-2.5", "aria-live": "polite", children: (data === null || data === void 0 ? void 0 : data.refreshing) ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "fa-light fa-arrows-rotate", className: "h-3 w-3 animate-spin", "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRefreshing", defaults: "Refreshing\u2026" })] })) : (_jsx(Trans, { i18nKey: "dashboard:widgetUpdated", defaults: "Updated {{time}}", values: { time: updated } })) }));
188
+ return (_jsx("div", { className: "text-muted-foreground border-border/60 text-fine flex shrink-0 items-center gap-1.5 border-t px-5 py-2.5", "aria-live": "polite", children: (data === null || data === void 0 ? void 0 : data.refreshing) ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "fa-arrows-rotate", className: "h-3 w-3 animate-spin", "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRefreshing", defaults: "Refreshing\u2026" })] })) : (_jsx(Trans, { i18nKey: "dashboard:widgetUpdated", defaults: "Updated {{time}}", values: { time: updated } })) }));
192
189
  }
193
190
  // ─── State-gated content ────────────────────────────────────────────────────
194
191
  function CollapsibleBody({ collapsed, maxContentHeight, widgetId, children, }) {
@@ -344,7 +341,7 @@ function WidgetHealthFooter() {
344
341
  ((_b = meta.health) === null || _b === void 0 ? void 0 : _b.status) === 'degraded';
345
342
  if (!shouldShow)
346
343
  return null;
347
- return (_jsxs("div", { className: "text-warning border-warning/30 bg-warning/5 text-fine flex items-center gap-2 border-t px-4 py-2", children: [_jsx(Icon, { name: "fa-light fa-circle-exclamation", className: "h-4 w-4 shrink-0", "aria-hidden": true }), _jsx("span", { children: lastSynced ? (_jsx(Trans, { i18nKey: "common:integrationHealth.degradedWidgetNoticeSince", defaults: "Data may be out of date. Last synced {{time}}.", values: { time: lastSynced } })) : (_jsx(Trans, { i18nKey: "common:integrationHealth.degradedWidgetNotice", defaults: "This integration is degraded \u2014 data may be stale." })) })] }));
344
+ return (_jsxs("div", { className: "text-warning border-warning/30 bg-warning/5 text-fine flex items-center gap-2 border-t px-4 py-2", children: [_jsx(Icon, { name: "fa-circle-exclamation", className: "h-4 w-4 shrink-0", "aria-hidden": true }), _jsx("span", { children: lastSynced ? (_jsx(Trans, { i18nKey: "common:integrationHealth.degradedWidgetNoticeSince", defaults: "Data may be out of date. Last synced {{time}}.", values: { time: lastSynced } })) : (_jsx(Trans, { i18nKey: "common:integrationHealth.degradedWidgetNotice", defaults: "This integration is degraded \u2014 data may be stale." })) })] }));
348
345
  }
349
346
  function toEpochMs(value) {
350
347
  if (value === null || value === undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../src/components/widgets/widget.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;AAEb,OAAO,EACL,SAAS,EAGT,GAAG,EACH,OAAO,GACR,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EACL,IAAI,EACJ,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,MAAM,EACN,aAAa,EACb,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,OAAO,EACP,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAItC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAA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,EAAE,WAAW;IAClB,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,SAAS,EAAE,eAAe;IAC1B,YAAY,EAAE,kBAAkB;CACjC,CAAC","sourcesContent":["'use client';\n\nimport {\n Component,\n type CSSProperties,\n type ReactNode,\n use,\n useMemo,\n} from 'react';\n\nimport Link from 'next/link.js';\n\nimport { Button } from '@ekanos/ui/button';\nimport {\n Card,\n CardContent,\n CardFooter,\n CardHeader,\n CardTitle,\n} from '@ekanos/ui/card';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from '@ekanos/ui/dropdown-menu';\nimport { Icon } from '@ekanos/ui/icon';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@ekanos/ui/select';\nimport { StatusBadge } from '@ekanos/ui/status-badge';\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from '@ekanos/ui/tooltip';\nimport { Trans } from '@ekanos/ui/trans';\nimport { cn } from '@ekanos/ui/utils';\n\nimport type { WidgetAskContext } from '../../types/widget-ask-context';\nimport type { WidgetVerdict } from '../../types/widget-verdict';\nimport { useAnimatedHeight } from './use-animated-height';\nimport { useRelativeTime } from './use-relative-time';\nimport { WidgetAskBar } from './widget-ask-bar';\nimport { WidgetContext, type WidgetRenderState } from './widget-context';\nimport {\n WidgetDisabledState,\n WidgetEmptyState,\n type WidgetEmptyStateProps,\n WidgetErrorState,\n WidgetInactiveState,\n type WidgetInactiveStateProps,\n WidgetLoadingSkeleton,\n type WidgetSkeletonVariant,\n} from './widget-state-components';\n\n// ─── Error Boundary ─────────────────────────────────────────────────────────\n\nclass WidgetErrorBoundary extends Component<\n { widgetId: string; onRetry?: () => void; children: ReactNode },\n { hasError: boolean }\n> {\n state = { hasError: false };\n static getDerivedStateFromError() {\n return { hasError: true };\n }\n componentDidCatch(error: Error, info: React.ErrorInfo) {\n console.error(`Widget \"${this.props.widgetId}\" crashed:`, error, info);\n }\n retry = () => {\n this.props.onRetry?.();\n this.setState({ hasError: false });\n };\n render() {\n if (this.state.hasError) {\n return (\n <div\n role=\"alert\"\n className=\"flex flex-1 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-light 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 <Trans\n i18nKey=\"dashboard:widgetCrashedTitle\"\n defaults=\"This widget ran into a problem\"\n />\n </p>\n <p className=\"text-muted-foreground text-meta max-w-xs\">\n <Trans\n i18nKey=\"dashboard:widgetCrashedBody\"\n defaults=\"Try again. If it keeps happening, reload the page.\"\n />\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={this.retry}\n data-test=\"widget-crash-retry\"\n >\n <Icon\n name=\"fa-light fa-arrows-rotate\"\n className=\"h-4 w-4\"\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRetry\" defaults=\"Try again\" />\n </Button>\n </div>\n );\n }\n return this.props.children;\n }\n}\n\n// ─── Hook ───────────────────────────────────────────────────────────────────\n\nfunction useWidget() {\n const ctx = use(WidgetContext);\n if (!ctx) {\n throw new Error(\n 'Widget.* compound components must be rendered inside a widget provider. ' +\n 'On the Ekanos dashboard the host supplies one. Anywhere else — your own ' +\n 'app, a story, a component test — wrap the widget in ' +\n \"`WidgetPreviewProvider` from '@ekanos/sdk/components'.\",\n );\n }\n return ctx;\n}\n\n/**\n * The verdict the widget reported through `Widget.DataState`, for a body that\n * wants to echo it (an empty state, a summary row). `undefined` before the\n * widget has one.\n */\nexport function useWidgetVerdict(): WidgetVerdict | undefined {\n return useWidget().data?.verdict;\n}\n\n// ─── Card ───────────────────────────────────────────────────────────────────\n\nfunction WidgetCard({ children }: { children: ReactNode }) {\n const { meta } = useWidget();\n return (\n <Card\n className={cn(\n // Neutralize the shadcn card's own py-6/gap-6 box model — widget\n // chrome owns all vertical spacing via its header/content/footer.\n 'shadow-widget @container/widget relative flex h-full flex-col gap-0 overflow-hidden rounded-lg border-0 py-0',\n meta.className,\n )}\n data-widget-id={meta.widgetId}\n >\n {children}\n <WidgetFreshness />\n </Card>\n );\n}\n\n// ─── Header ─────────────────────────────────────────────────────────────────\n\nfunction CollapseButton() {\n const { state, actions, meta } = useWidget();\n return (\n <Button\n variant=\"outline\"\n size=\"icon\"\n onClick={actions.toggleCollapsed}\n disabled={state.pendingCollapse}\n className=\"bg-background dark:bg-secondary relative h-6 w-6 rounded-full before:absolute before:top-1/2 before:left-1/2 before:h-11 before:w-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\"\n aria-expanded={!state.collapsed}\n aria-controls={`widget-content-${meta.widgetId}`}\n aria-label={\n state.collapsed\n ? `Expand ${meta.title ?? 'widget'}`\n : `Collapse ${meta.title ?? 'widget'}`\n }\n >\n <Icon\n name=\"fa-light fa-chevron-right\"\n className={cn(\n 'ease-out-strong h-4 w-4 transition-transform duration-200 motion-reduce:transition-none',\n !state.collapsed && 'rotate-90',\n )}\n />\n </Button>\n );\n}\n\n/**\n * The header's one trailing control (the design system's widget rules): a \"View all ›\"\n * link to where the data lives, or a period switch. Everything else goes in\n * the ⋯ menu.\n */\nexport type WidgetHeaderTrailing =\n | {\n kind: 'link';\n href: string;\n label: ReactNode;\n /** Open in a new tab. */\n external?: boolean;\n }\n | {\n kind: 'period';\n value: string;\n options: ReadonlyArray<{ value: string; label: string }>;\n onChange: (value: string) => void;\n /** Accessible name; defaults to \"Period\". */\n label?: string;\n };\n\nfunction HeaderTrailing({ trailing }: { trailing: WidgetHeaderTrailing }) {\n if (trailing.kind === 'link') {\n const link = trailing.external ? (\n <a href={trailing.href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={trailing.href} />\n );\n\n return (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n render={link}\n nativeButton={false}\n data-test=\"widget-header-link\"\n >\n {trailing.label}\n <Icon\n name=\"fa-light fa-chevron-right\"\n className=\"h-3 w-3\"\n aria-hidden\n />\n </Button>\n );\n }\n\n return (\n <Select\n value={trailing.value}\n onValueChange={(value) => {\n if (typeof value === 'string') trailing.onChange(value);\n }}\n >\n <SelectTrigger\n size=\"sm\"\n aria-label={trailing.label ?? 'Period'}\n data-test=\"widget-header-period\"\n >\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {trailing.options.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n}\n\nconst VERDICT_BADGE_TONE = {\n attention: 'warning',\n critical: 'destructive',\n degraded: 'warning',\n unknown: 'neutral',\n} as const;\n\n/**\n * The verdict under the title. Anything but `clear` is a status pill, the\n * words carrying the tone and the dot confirming it; `clear` reads muted,\n * with a check, because good news shouldn't shout.\n */\nfunction VerdictLine({ verdict }: { verdict: WidgetVerdict }) {\n if (verdict.tone === 'clear') {\n return (\n <p\n className=\"text-muted-foreground text-meta flex min-w-0 items-center gap-1.5\"\n data-test=\"widget-verdict\"\n data-verdict=\"clear\"\n >\n <Icon\n name=\"fa-light fa-circle-check\"\n className=\"h-3.5 w-3.5 shrink-0\"\n aria-hidden\n />\n <span className=\"truncate\">{verdict.sentence}</span>\n </p>\n );\n }\n\n return (\n <StatusBadge\n tone={VERDICT_BADGE_TONE[verdict.tone]}\n className=\"mt-0.5 max-w-full\"\n data-test=\"widget-verdict\"\n data-verdict={verdict.tone}\n >\n <span className=\"truncate\">{verdict.sentence}</span>\n </StatusBadge>\n );\n}\n\n/** Widgets already warned about `children` beside `trailing`, so each warns once. */\nconst warnedChildrenWithTrailing = new Set<string>();\n\nfunction WidgetHeader({\n title,\n subtitle,\n description,\n context,\n trailing,\n menu,\n children,\n}: {\n /** Override the provider's title — useful when the rendered name differs from the config name. */\n title?: string;\n /**\n * Override the provider's subtitle. It renders as the context line when\n * `context` is not set.\n */\n subtitle?: string;\n /** Override the provider's description — useful for widget-computed values. */\n description?: string;\n /**\n * One muted line under the title that frames the data: \"This month\",\n * \"As of today\", \"3 accounts\". A verdict that needs the owner replaces it;\n * a clear one joins it (\"This month · All caught up\").\n */\n context?: ReactNode;\n /** At most one control on the right: a \"View all ›\" link or a period switch. */\n trailing?: WidgetHeaderTrailing;\n /**\n * `Widget.MenuItem`s and `Widget.MenuChoice`s placed at the top of the\n * header's ⋯ menu: occasional actions (\"Open in QuickBooks\") and secondary\n * settings (a comparison basis) that don't earn the one trailing slot.\n */\n menu?: ReactNode;\n /**\n * @deprecated Free controls beside the ⋯ menu. Use `trailing` for the one\n * control a header carries and `menu` for the rest; `children` goes away\n * in a later major release.\n */\n children?: ReactNode;\n}) {\n const { meta, state, data } = useWidget();\n const effectiveTitle = title ?? meta.title;\n const effectiveDescription = description ?? meta.description;\n const contextLine = context ?? subtitle ?? meta.subtitle;\n // A verdict speaks for data on screen, so it shows only while active.\n const verdict = state.state === 'active' ? data?.verdict : undefined;\n\n if (\n process.env.NODE_ENV !== 'production' &&\n children &&\n trailing &&\n !warnedChildrenWithTrailing.has(meta.widgetId)\n ) {\n warnedChildrenWithTrailing.add(meta.widgetId);\n console.warn(\n `Widget.Header (${meta.widgetId}): pass \\`trailing\\` or \\`children\\`, not both. \\`children\\` is deprecated; move other controls into \\`menu\\`.`,\n );\n }\n\n if (!effectiveTitle) return null;\n\n const titleNode = effectiveDescription ? (\n <>\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger\n render={<CardTitle className=\"text-title cursor-help truncate\" />}\n >\n {effectiveTitle}\n </TooltipTrigger>\n <TooltipContent>\n <p>{effectiveDescription}</p>\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n <span className=\"sr-only\">{effectiveDescription}</span>\n </>\n ) : (\n <CardTitle className=\"text-title truncate\">{effectiveTitle}</CardTitle>\n );\n\n return (\n <CardHeader className=\"flex-shrink-0 px-5 pt-4 pb-3\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex min-w-0 items-start gap-2.5\">\n {meta.isCollapsible ? <CollapseButton /> : null}\n <div className=\"min-w-0 space-y-0.5\">\n {titleNode}\n {verdict && verdict.tone !== 'clear' ? (\n <VerdictLine verdict={verdict} />\n ) : contextLine ? (\n <p\n className=\"text-muted-foreground text-meta truncate\"\n data-test=\"widget-header-context\"\n >\n {contextLine}\n {verdict ? (\n <>\n {' · '}\n <span data-test=\"widget-verdict\" data-verdict=\"clear\">\n {verdict.sentence}\n </span>\n </>\n ) : null}\n </p>\n ) : verdict ? (\n <VerdictLine verdict={verdict} />\n ) : null}\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {trailing ? <HeaderTrailing trailing={trailing} /> : null}\n {children}\n <WidgetMenu items={menu} />\n </div>\n </div>\n </CardHeader>\n );\n}\n\n/**\n * The actions every widget shares, whatever it renders: open its full\n * surface, reload it, pin or unpin it. Each item needs something from the host\n * or the widget's data layer, so the menu shows only what applies — and\n * nothing at all when nothing does.\n */\nfunction WidgetMenu({ items }: { items?: ReactNode }) {\n const { state, actions, meta, data } = useWidget();\n const refresh = state.state === 'active' ? data?.refresh : undefined;\n const hasNavigation = !!items || !!meta.openHref || !!refresh;\n\n if (!hasNavigation && !meta.isPinnable) return null;\n\n const title = meta.title ?? 'widget';\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"text-muted-foreground hover:text-foreground\"\n aria-label={`Actions for ${title}`}\n data-test={`widget-menu-${meta.widgetId}`}\n />\n }\n >\n <Icon name=\"fa-light fa-ellipsis\" className=\"h-4 w-4\" aria-hidden />\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-48\">\n {items}\n {meta.openHref ? (\n <DropdownMenuItem render={<Link href={meta.openHref} />}>\n <Icon name=\"fa-light fa-arrow-up-right-from-square\" aria-hidden />\n <Trans\n i18nKey=\"dashboard:widgetOpenInWorkspace\"\n defaults=\"Open in workspace\"\n />\n </DropdownMenuItem>\n ) : null}\n {refresh ? (\n <DropdownMenuItem onClick={refresh} disabled={data?.refreshing}>\n <Icon name=\"fa-light fa-arrows-rotate\" aria-hidden />\n <Trans i18nKey=\"dashboard:widgetRefresh\" defaults=\"Refresh\" />\n </DropdownMenuItem>\n ) : null}\n {hasNavigation && meta.isPinnable ? <DropdownMenuSeparator /> : null}\n {meta.isPinnable ? (\n <DropdownMenuItem\n onClick={actions.togglePinned}\n disabled={state.pendingPin}\n data-test={`widget-menu-pin-${meta.widgetId}`}\n >\n <Icon\n name={\n state.pinned\n ? 'fa-light fa-thumbtack-slash'\n : 'fa-light fa-thumbtack'\n }\n aria-hidden\n />\n {state.pinned ? (\n <Trans\n i18nKey=\"dashboard:widgetUnpin\"\n defaults=\"Unpin from board\"\n />\n ) : (\n <Trans i18nKey=\"dashboard:widgetPin\" defaults=\"Pin to board\" />\n )}\n </DropdownMenuItem>\n ) : null}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/**\n * One widget-specific entry in the header's ⋯ menu; pass it through\n * `Widget.Header`'s `menu` prop. With `href` it is a link, opened in a new tab\n * when `external`; otherwise it runs `onSelect`.\n */\nfunction WidgetMenuItem({\n icon,\n href,\n external = false,\n onSelect,\n disabled,\n children,\n}: {\n /** A Font Awesome class, e.g. `fa-light fa-envelope`. */\n icon?: string;\n href?: string;\n external?: boolean;\n onSelect?: () => void;\n disabled?: boolean;\n children: ReactNode;\n}) {\n const link = !href ? undefined : external ? (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={href} />\n );\n\n return (\n <DropdownMenuItem render={link} onClick={onSelect} disabled={disabled}>\n <Icon\n name={\n icon ??\n (external\n ? 'fa-light fa-arrow-up-right-from-square'\n : 'fa-light fa-arrow-right')\n }\n aria-hidden\n />\n {children}\n </DropdownMenuItem>\n );\n}\n\n/**\n * A setting that doesn't earn the header's one trailing slot (a comparison\n * basis, an as-of month), as a submenu of choices in the ⋯ menu. Pass it\n * through `Widget.Header`'s `menu` prop.\n */\nfunction WidgetMenuChoice<Value extends string>({\n icon,\n label,\n value,\n options,\n onChange,\n}: {\n /** A Font Awesome class, e.g. `fa-light fa-scale-balanced`. */\n icon?: string;\n label: ReactNode;\n value: Value;\n options: ReadonlyArray<{ value: Value; label: ReactNode }>;\n onChange: (value: Value) => void;\n}) {\n const current = options.find((option) => option.value === value);\n\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <Icon name={icon ?? 'fa-light fa-sliders'} aria-hidden />\n <span className=\"flex-1\">{label}</span>\n {current ? (\n <span className=\"text-muted-foreground text-fine\">\n {current.label}\n </span>\n ) : null}\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"min-w-44\">\n <DropdownMenuRadioGroup\n value={value}\n onValueChange={(next) => {\n const match = options.find((option) => option.value === next);\n if (match) onChange(match.value);\n }}\n >\n {options.map((option) => (\n <DropdownMenuRadioItem key={option.value} value={option.value}>\n {option.label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/**\n * \"Updated 3 minutes ago\" under an active widget whose data layer reports\n * when it last loaded (see `Widget.DataState`'s `updatedAt`).\n */\nfunction WidgetFreshness() {\n const { state, data } = useWidget();\n const updated = useRelativeTime(data?.updatedAt);\n\n if (state.state !== 'active' || state.collapsed || !updated) return null;\n\n return (\n <div\n className=\"text-muted-foreground border-border/60 text-fine flex shrink-0 items-center gap-1.5 border-t px-5 py-2.5\"\n aria-live=\"polite\"\n >\n {data?.refreshing ? (\n <>\n <Icon\n name=\"fa-light fa-arrows-rotate\"\n className=\"h-3 w-3 animate-spin\"\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRefreshing\" defaults=\"Refreshing…\" />\n </>\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetUpdated\"\n defaults=\"Updated {{time}}\"\n values={{ time: updated }}\n />\n )}\n </div>\n );\n}\n\n// ─── State-gated content ────────────────────────────────────────────────────\n\nfunction CollapsibleBody({\n collapsed,\n maxContentHeight,\n widgetId,\n children,\n}: {\n collapsed: boolean;\n maxContentHeight?: string;\n widgetId: string;\n children: ReactNode;\n}) {\n return (\n <div\n className={cn(\n 'ease-out-strong grid min-h-0 flex-1 transition-all duration-300 motion-reduce:transition-none',\n collapsed ? 'grid-rows-[0fr]' : 'grid-rows-[1fr]',\n )}\n >\n <div className=\"min-h-0 overflow-hidden\">\n <CardContent\n id={`widget-content-${widgetId}`}\n className={cn(\n 'flex h-full min-h-0 flex-1 flex-col overflow-y-auto p-0',\n 'ease-out-strong transition-opacity duration-200 motion-reduce:transition-none',\n collapsed ? 'opacity-0' : 'opacity-100',\n maxContentHeight && 'max-h-(--widget-max-height)',\n )}\n style={\n maxContentHeight\n ? ({ '--widget-max-height': maxContentHeight } as CSSProperties)\n : undefined\n }\n >\n {children}\n </CardContent>\n </div>\n </div>\n );\n}\n\nfunction StaticBody({\n maxContentHeight,\n children,\n}: {\n maxContentHeight?: string;\n children: ReactNode;\n}) {\n const { innerRef, height } = useAnimatedHeight();\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n <div\n className={cn(\n 'h-(--body-height) overflow-hidden transition-all duration-250 ease-out motion-reduce:transition-none',\n maxContentHeight && 'max-h-(--widget-max-height)',\n )}\n style={\n {\n '--body-height': height === 'auto' ? 'auto' : `${height}px`,\n '--widget-max-height': maxContentHeight,\n } as CSSProperties\n }\n >\n <div ref={innerRef}>{children}</div>\n </div>\n </CardContent>\n );\n}\n\n/**\n * The standard padded body for content rendered inside `Widget.Active`.\n *\n * `Widget.Active`'s own `CardContent` renders `p-0` — deliberately, so a\n * full-bleed chart or table can run edge-to-edge inside the card. That means\n * ordinary content (text, rows, a KPI readout) is left flush against the\n * card's sides while `Widget.Header` stays inset (`px-5`) unless the body\n * supplies its own padding. `Widget.Body` is that padding: `px-5` matches\n * the header's horizontal inset so header and body align, `pt-4 pb-5`\n * balances the header's `pb-3`/card's bottom edge.\n *\n * Every widget wraps its content in it:\n *\n * ```tsx\n * <Widget.Active>\n * <Widget.Body>{/* text, a Stat, a form *\\/}</Widget.Body>\n * </Widget.Active>\n * ```\n *\n * Pass `flush` when the content runs to the card's edges: edge-to-edge rows\n * that pad themselves, a chart, a table with its own header row, an image.\n */\nfunction WidgetBody({\n flush = false,\n className,\n children,\n}: {\n /**\n * Drop the padding for content that runs to the card's edges: edge-to-edge\n * rows (which pad themselves, `px-5 py-3`), a full-bleed chart, an image.\n */\n flush?: boolean;\n className?: string;\n children: ReactNode;\n}) {\n return (\n <div\n className={cn(\n 'flex flex-1 flex-col',\n flush ? 'pb-2' : 'gap-4 px-5 pt-4 pb-5',\n className,\n )}\n data-flush={flush || undefined}\n >\n {children}\n </div>\n );\n}\n\n/**\n * Renders `children` once the widget's state is `active`. Its `CardContent`\n * is flush (`p-0`); wrap content in `Widget.Body`, which pads it to line up\n * with the header, or `Widget.Body flush` for edge-to-edge rows and charts.\n * Never hand-roll a `px-*` wrapper.\n */\nfunction WidgetActive({ children }: { children: ReactNode }) {\n const { state, meta, data } = useWidget();\n if (state.state !== 'active') return null;\n const body = (\n <WidgetErrorBoundary widgetId={meta.widgetId} onRetry={data?.refresh}>\n {children}\n </WidgetErrorBoundary>\n );\n return meta.isCollapsible ? (\n <CollapsibleBody\n collapsed={state.collapsed}\n maxContentHeight={meta.maxContentHeight}\n widgetId={meta.widgetId}\n >\n {body}\n </CollapsibleBody>\n ) : (\n <StaticBody maxContentHeight={meta.maxContentHeight}>{body}</StaticBody>\n );\n}\n\n/**\n * Shows while the widget loads: a skeleton shaped like its body (`variant`,\n * `rows` by default), never a spinner.\n */\nfunction WidgetLoading({\n variant,\n children,\n}: {\n variant?: WidgetSkeletonVariant;\n children?: ReactNode;\n}) {\n const { state } = useWidget();\n if (state.state !== 'loading') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? <WidgetLoadingSkeleton variant={variant} />}\n </CardContent>\n );\n}\n\n/**\n * Shows when the widget's data failed to load. Offers Try again whenever the\n * widget reports `onRefresh` through `Widget.DataState`. `title` and\n * `description` replace the default copy with something specific (\"Couldn't\n * load your inbox\").\n */\nfunction WidgetError({\n title,\n description,\n children,\n}: {\n title?: ReactNode;\n description?: ReactNode;\n children?: ReactNode;\n}) {\n const { state, data } = useWidget();\n if (state.state !== 'error') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? (\n <WidgetErrorState\n title={title}\n description={description}\n onRetry={data?.refresh}\n retrying={data?.refreshing}\n />\n )}\n </CardContent>\n );\n}\n\n/**\n * Shows when the widget can't reach its data. Give it a `reason`:\n * `not-connected` (one Connect button in `action`), `no-access` (a calm note\n * pointing to an admin) or `setup-needed`. `integrationName` defaults to the\n * host's source name.\n */\nfunction WidgetInactive({\n children,\n integrationName,\n ...props\n}: WidgetInactiveStateProps & { children?: ReactNode }) {\n const { state, meta } = useWidget();\n if (state.state !== 'inactive') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? (\n <WidgetInactiveState\n integrationName={integrationName ?? meta.source?.name}\n {...props}\n />\n )}\n </CardContent>\n );\n}\n\n/**\n * What an active widget shows when it has nothing to list. Render it inside\n * `Widget.Active`. Positive by default (\"You're all caught up\"), because an\n * empty queue is good news; `tone=\"neutral\"` for an empty search.\n */\nfunction WidgetEmpty(props: WidgetEmptyStateProps) {\n return <WidgetEmptyState {...props} />;\n}\n\nfunction WidgetDisabled({ children }: { children?: ReactNode }) {\n const { state } = useWidget();\n if (state.state !== 'disabled') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? <WidgetDisabledState />}\n </CardContent>\n );\n}\n\n// ─── Footers ────────────────────────────────────────────────────────────────\n\nfunction WidgetFooter({ children }: { children: ReactNode }) {\n const { state, meta } = useWidget();\n if (state.state !== 'active') return null;\n return (\n <CardFooter\n className={cn(\n 'ease-out-strong flex-shrink-0 pb-6 transition-opacity duration-200 motion-reduce:transition-none',\n meta.isCollapsible && state.collapsed\n ? 'pointer-events-none opacity-0'\n : 'opacity-100',\n )}\n aria-hidden={meta.isCollapsible && state.collapsed}\n >\n {children}\n </CardFooter>\n );\n}\n\nfunction WidgetActions({ children }: { children: ReactNode }) {\n return (\n <CardFooter className=\"bg-muted flex-shrink-0 justify-end border-t py-3\">\n {children}\n </CardFooter>\n );\n}\n\nfunction WidgetAskFooter({ context }: { context?: WidgetAskContext }) {\n const { state, meta, data } = useWidget();\n const effectiveContext = context ?? meta.askContext;\n const shouldShow =\n (meta.aiFooterEnabled || !!effectiveContext) &&\n state.state === 'active' &&\n !state.collapsed;\n if (!shouldShow) return null;\n const base = effectiveContext ?? {\n widgetId: meta.widgetId,\n title: meta.title ?? meta.widgetId,\n snapshot: null,\n suggestedPrompt: `Tell me about ${meta.title ?? 'this widget'}.`,\n };\n return <WidgetAskBar context={withVerdict(base, data?.verdict)} />;\n}\n\n/**\n * Adds the widget's own conclusion to what the assistant sees, so an answer\n * starts from the verdict on the card instead of re-deriving it.\n */\nfunction withVerdict(\n context: WidgetAskContext,\n verdict: WidgetVerdict | undefined,\n): WidgetAskContext {\n if (!verdict) return context;\n return {\n ...context,\n snapshot: {\n ...context.snapshot,\n verdict: {\n tone: verdict.tone,\n sentence: verdict.sentence,\n ...(verdict.count !== undefined ? { count: verdict.count } : {}),\n },\n },\n };\n}\n\n/**\n * Renders a subtle \"data may be stale\" banner when the widget's integration is\n * `degraded` (but still active). Unhealthy integrations route to `disabled`\n * instead, so this only fires for the degraded middle ground.\n */\nfunction WidgetHealthFooter() {\n const { state, meta } = useWidget();\n const lastSuccessAt = toEpochMs(meta.health?.lastSuccessAt);\n const lastSynced = useRelativeTime(lastSuccessAt);\n const shouldShow =\n state.state === 'active' &&\n !state.collapsed &&\n meta.health?.status === 'degraded';\n if (!shouldShow) return null;\n return (\n <div className=\"text-warning border-warning/30 bg-warning/5 text-fine flex items-center gap-2 border-t px-4 py-2\">\n <Icon\n name=\"fa-light fa-circle-exclamation\"\n className=\"h-4 w-4 shrink-0\"\n aria-hidden\n />\n <span>\n {lastSynced ? (\n <Trans\n i18nKey=\"common:integrationHealth.degradedWidgetNoticeSince\"\n defaults=\"Data may be out of date. Last synced {{time}}.\"\n values={{ time: lastSynced }}\n />\n ) : (\n <Trans\n i18nKey=\"common:integrationHealth.degradedWidgetNotice\"\n defaults=\"This integration is degraded — data may be stale.\"\n />\n )}\n </span>\n </div>\n );\n}\n\nfunction toEpochMs(\n value: number | string | Date | null | undefined,\n): number | undefined {\n if (value === null || value === undefined) return undefined;\n const ms =\n value instanceof Date ? value.getTime() : new Date(value).getTime();\n return Number.isFinite(ms) && ms > 0 ? ms : undefined;\n}\n\n// ─── Data state override ────────────────────────────────────────────────────\n\n/**\n * Wraps children in a sub-provider that overrides the effective render state\n * with the widget's own data loading / error state. Only overrides when the\n * parent state is `active` — so the integration's `inactive` / `disabled` /\n * `loading` (initial) states still win.\n *\n * Read the parent integration state BEFORE wrapping in this component if you\n * need it to gate data fetching:\n *\n * ```tsx\n * const { state } = use(WidgetContext);\n * const integrationActive = state.state === 'active';\n * const { isLoading, isError } = useMyData(accountId, integrationActive);\n * return (\n * <Widget.DataState loading={isLoading} error={isError}>\n * <Widget.Card>…</Widget.Card>\n * </Widget.DataState>\n * );\n * ```\n *\n * Pass `onRefresh`, `refreshing` and `updatedAt` to give the widget the\n * shared Refresh menu item, a Try again button on its error view, and an\n * \"Updated 3 minutes ago\" footer. With TanStack Query:\n *\n * ```tsx\n * <Widget.DataState\n * loading={query.isLoading}\n * error={query.isError}\n * onRefresh={() => void query.refetch()}\n * refreshing={query.isFetching}\n * updatedAt={query.dataUpdatedAt}\n * >\n * ```\n */\nfunction WidgetDataState({\n loading,\n error,\n inactive,\n onRefresh,\n refreshing = false,\n updatedAt,\n verdict,\n children,\n}: {\n loading?: boolean;\n error?: boolean;\n /**\n * Force the `inactive` render state even though the integration itself is\n * active. Use for widget-level \"not connected\" states (e.g. the product is\n * activated but the upstream OAuth connection is missing). Takes priority\n * over `loading` / `error`.\n */\n inactive?: boolean;\n /** Reloads the widget's data. */\n onRefresh?: () => void;\n /** A reload is in flight. */\n refreshing?: boolean;\n /**\n * When the data on screen last loaded successfully: epoch milliseconds, an\n * ISO string or a `Date`. `0` means never, which TanStack Query's\n * `dataUpdatedAt` reports before the first success.\n */\n updatedAt?: number | string | Date | null;\n /**\n * The widget's verdict on its data (the design system's widget rules): `{ tone,\n * sentence, count? }`. Compute it with the same function the integration's\n * server `getAttention` uses, so the card and home's Needs you agree.\n */\n verdict?: WidgetVerdict;\n children: ReactNode;\n}) {\n const parent = useWidget();\n const overrideState: WidgetRenderState =\n parent.state.state !== 'active'\n ? parent.state.state\n : inactive\n ? 'inactive'\n : loading\n ? 'loading'\n : error\n ? 'error'\n : 'active';\n const updatedAtMs = toEpochMs(updatedAt);\n const reportsData =\n onRefresh !== undefined ||\n updatedAtMs !== undefined ||\n verdict !== undefined;\n const value = useMemo(\n () => ({\n state: { ...parent.state, state: overrideState },\n actions: parent.actions,\n meta: parent.meta,\n data: reportsData\n ? { updatedAt: updatedAtMs, refreshing, refresh: onRefresh, verdict }\n : parent.data,\n }),\n [\n parent.state,\n parent.actions,\n parent.meta,\n parent.data,\n overrideState,\n reportsData,\n updatedAtMs,\n refreshing,\n onRefresh,\n verdict,\n ],\n );\n return <WidgetContext value={value}>{children}</WidgetContext>;\n}\n\n// ─── Compound export ────────────────────────────────────────────────────────\n\nexport const Widget = {\n Card: WidgetCard,\n Header: WidgetHeader,\n MenuItem: WidgetMenuItem,\n MenuChoice: WidgetMenuChoice,\n DataState: WidgetDataState,\n Active: WidgetActive,\n Body: WidgetBody,\n Empty: WidgetEmpty,\n Loading: WidgetLoading,\n Error: WidgetError,\n Inactive: WidgetInactive,\n Disabled: WidgetDisabled,\n Footer: WidgetFooter,\n Actions: WidgetActions,\n AskFooter: WidgetAskFooter,\n HealthFooter: WidgetHealthFooter,\n};\n"]}
1
+ {"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../src/components/widgets/widget.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;AAEb,OAAO,EACL,SAAS,EAGT,GAAG,EACH,OAAO,GACR,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EACL,IAAI,EACJ,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,MAAM,EACN,aAAa,EACb,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,OAAO,EACP,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAItC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,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AAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,SAAS,EAAE,eAAe;IAC1B,YAAY,EAAE,kBAAkB;CACjC,CAAC","sourcesContent":["'use client';\n\nimport {\n Component,\n type CSSProperties,\n type ReactNode,\n use,\n useMemo,\n} from 'react';\n\nimport Link from 'next/link.js';\n\nimport { Button } from '@ekanos/ui/button';\nimport {\n Card,\n CardContent,\n CardFooter,\n CardHeader,\n CardTitle,\n} from '@ekanos/ui/card';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from '@ekanos/ui/dropdown-menu';\nimport { Icon } from '@ekanos/ui/icon';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@ekanos/ui/select';\nimport { StatusBadge } from '@ekanos/ui/status-badge';\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from '@ekanos/ui/tooltip';\nimport { Trans } from '@ekanos/ui/trans';\nimport { cn } from '@ekanos/ui/utils';\n\nimport type { WidgetAskContext } from '../../types/widget-ask-context';\nimport type { WidgetVerdict } from '../../types/widget-verdict';\nimport { useAnimatedHeight } from './use-animated-height';\nimport { useRelativeTime } from './use-relative-time';\nimport { WidgetAskBar } from './widget-ask-bar';\nimport { WidgetContext, type WidgetRenderState } from './widget-context';\nimport {\n WidgetDisabledState,\n WidgetEmptyState,\n type WidgetEmptyStateProps,\n WidgetErrorState,\n WidgetInactiveState,\n type WidgetInactiveStateProps,\n WidgetLoadingSkeleton,\n type WidgetSkeletonVariant,\n} from './widget-state-components';\n\n// ─── Error Boundary ─────────────────────────────────────────────────────────\n\nclass WidgetErrorBoundary extends Component<\n { widgetId: string; onRetry?: () => void; children: ReactNode },\n { hasError: boolean }\n> {\n state = { hasError: false };\n static getDerivedStateFromError() {\n return { hasError: true };\n }\n componentDidCatch(error: Error, info: React.ErrorInfo) {\n console.error(`Widget \"${this.props.widgetId}\" crashed:`, error, info);\n }\n retry = () => {\n this.props.onRetry?.();\n this.setState({ hasError: false });\n };\n render() {\n if (this.state.hasError) {\n return (\n <div\n role=\"alert\"\n className=\"flex flex-1 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 <Trans\n i18nKey=\"dashboard:widgetCrashedTitle\"\n defaults=\"This widget ran into a problem\"\n />\n </p>\n <p className=\"text-muted-foreground text-meta max-w-xs\">\n <Trans\n i18nKey=\"dashboard:widgetCrashedBody\"\n defaults=\"Try again. If it keeps happening, reload the page.\"\n />\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={this.retry}\n data-test=\"widget-crash-retry\"\n >\n <Icon name=\"fa-arrows-rotate\" className=\"h-4 w-4\" aria-hidden />\n <Trans i18nKey=\"dashboard:widgetRetry\" defaults=\"Try again\" />\n </Button>\n </div>\n );\n }\n return this.props.children;\n }\n}\n\n// ─── Hook ───────────────────────────────────────────────────────────────────\n\nfunction useWidget() {\n const ctx = use(WidgetContext);\n if (!ctx) {\n throw new Error(\n 'Widget.* compound components must be rendered inside a widget provider. ' +\n 'On the Ekanos dashboard the host supplies one. Anywhere else — your own ' +\n 'app, a story, a component test — wrap the widget in ' +\n \"`WidgetPreviewProvider` from '@ekanos/sdk/components'.\",\n );\n }\n return ctx;\n}\n\n/**\n * The verdict the widget reported through `Widget.DataState`, for a body that\n * wants to echo it (an empty state, a summary row). `undefined` before the\n * widget has one.\n */\nexport function useWidgetVerdict(): WidgetVerdict | undefined {\n return useWidget().data?.verdict;\n}\n\n// ─── Card ───────────────────────────────────────────────────────────────────\n\nfunction WidgetCard({ children }: { children: ReactNode }) {\n const { meta } = useWidget();\n return (\n <Card\n className={cn(\n // Neutralize the shadcn card's own py-6/gap-6 box model — widget\n // chrome owns all vertical spacing via its header/content/footer.\n 'shadow-ring @container/widget relative flex h-full flex-col gap-0 overflow-hidden rounded-lg border-0 py-0',\n meta.className,\n )}\n data-widget-id={meta.widgetId}\n >\n {children}\n <WidgetFreshness />\n </Card>\n );\n}\n\n// ─── Header ─────────────────────────────────────────────────────────────────\n\nfunction CollapseButton() {\n const { state, actions, meta } = useWidget();\n return (\n <Button\n variant=\"outline\"\n size=\"icon\"\n onClick={actions.toggleCollapsed}\n disabled={state.pendingCollapse}\n className=\"bg-background dark:bg-secondary relative h-6 w-6 rounded-full before:absolute before:top-1/2 before:left-1/2 before:h-11 before:w-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\"\n aria-expanded={!state.collapsed}\n aria-controls={`widget-content-${meta.widgetId}`}\n aria-label={\n state.collapsed\n ? `Expand ${meta.title ?? 'widget'}`\n : `Collapse ${meta.title ?? 'widget'}`\n }\n >\n <Icon\n name=\"fa-chevron-right\"\n className={cn(\n 'ease-out-strong h-4 w-4 transition-transform duration-200 motion-reduce:transition-none',\n !state.collapsed && 'rotate-90',\n )}\n />\n </Button>\n );\n}\n\n/**\n * The header's one trailing control (the design system's widget rules): a \"View all ›\"\n * link to where the data lives, or a period switch. Everything else goes in\n * the ⋯ menu.\n */\nexport type WidgetHeaderTrailing =\n | {\n kind: 'link';\n href: string;\n label: ReactNode;\n /** Open in a new tab. */\n external?: boolean;\n }\n | {\n kind: 'period';\n value: string;\n options: ReadonlyArray<{ value: string; label: string }>;\n onChange: (value: string) => void;\n /** Accessible name; defaults to \"Period\". */\n label?: string;\n };\n\nfunction HeaderTrailing({ trailing }: { trailing: WidgetHeaderTrailing }) {\n if (trailing.kind === 'link') {\n const link = trailing.external ? (\n <a href={trailing.href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={trailing.href} />\n );\n\n return (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n render={link}\n nativeButton={false}\n data-test=\"widget-header-link\"\n >\n {trailing.label}\n <Icon name=\"fa-chevron-right\" className=\"h-3 w-3\" aria-hidden />\n </Button>\n );\n }\n\n return (\n <Select\n value={trailing.value}\n onValueChange={(value) => {\n if (typeof value === 'string') trailing.onChange(value);\n }}\n >\n <SelectTrigger\n size=\"sm\"\n aria-label={trailing.label ?? 'Period'}\n data-test=\"widget-header-period\"\n >\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {trailing.options.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n}\n\nconst VERDICT_BADGE_TONE = {\n attention: 'warning',\n critical: 'destructive',\n degraded: 'warning',\n unknown: 'neutral',\n} as const;\n\n/**\n * The verdict under the title. Anything but `clear` is a status pill, the\n * words carrying the tone and the dot confirming it. `clear` is plain ink and\n * a check, no colour at all (plan 251 D24): calm is the absence of colour,\n * so colour on a dashboard always means \"look here\".\n */\nfunction VerdictLine({ verdict }: { verdict: WidgetVerdict }) {\n if (verdict.tone === 'clear') {\n return (\n <p\n className=\"text-foreground text-meta flex min-w-0 items-center gap-1.5\"\n data-test=\"widget-verdict\"\n data-verdict=\"clear\"\n >\n <Icon\n name=\"fa-circle-check\"\n className=\"h-3.5 w-3.5 shrink-0\"\n aria-hidden\n />\n <span className=\"truncate\">{verdict.sentence}</span>\n </p>\n );\n }\n\n return (\n <StatusBadge\n tone={VERDICT_BADGE_TONE[verdict.tone]}\n className=\"mt-0.5 max-w-full\"\n data-test=\"widget-verdict\"\n data-verdict={verdict.tone}\n >\n <span className=\"truncate\">{verdict.sentence}</span>\n </StatusBadge>\n );\n}\n\n/** Widgets already warned about `children` beside `trailing`, so each warns once. */\nconst warnedChildrenWithTrailing = new Set<string>();\n\nfunction WidgetHeader({\n title,\n subtitle,\n description,\n context,\n trailing,\n menu,\n children,\n}: {\n /** Override the provider's title — useful when the rendered name differs from the config name. */\n title?: string;\n /**\n * Override the provider's subtitle. It renders as the context line when\n * `context` is not set.\n */\n subtitle?: string;\n /** Override the provider's description — useful for widget-computed values. */\n description?: string;\n /**\n * One muted line under the title that frames the data: \"This month\",\n * \"As of today\", \"3 accounts\". A verdict that needs the owner replaces it;\n * a clear one joins it (\"This month · All caught up\").\n */\n context?: ReactNode;\n /** At most one control on the right: a \"View all ›\" link or a period switch. */\n trailing?: WidgetHeaderTrailing;\n /**\n * `Widget.MenuItem`s and `Widget.MenuChoice`s placed at the top of the\n * header's ⋯ menu: occasional actions (\"Open in QuickBooks\") and secondary\n * settings (a comparison basis) that don't earn the one trailing slot.\n */\n menu?: ReactNode;\n /**\n * @deprecated Free controls beside the ⋯ menu. Use `trailing` for the one\n * control a header carries and `menu` for the rest; `children` goes away\n * in a later major release.\n */\n children?: ReactNode;\n}) {\n const { meta, state, data } = useWidget();\n const effectiveTitle = title ?? meta.title;\n const effectiveDescription = description ?? meta.description;\n const contextLine = context ?? subtitle ?? meta.subtitle;\n // A verdict speaks for data on screen, so it shows only while active.\n const verdict = state.state === 'active' ? data?.verdict : undefined;\n\n if (\n process.env.NODE_ENV !== 'production' &&\n children &&\n trailing &&\n !warnedChildrenWithTrailing.has(meta.widgetId)\n ) {\n warnedChildrenWithTrailing.add(meta.widgetId);\n console.warn(\n `Widget.Header (${meta.widgetId}): pass \\`trailing\\` or \\`children\\`, not both. \\`children\\` is deprecated; move other controls into \\`menu\\`.`,\n );\n }\n\n if (!effectiveTitle) return null;\n\n const titleNode = effectiveDescription ? (\n <>\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger\n render={<CardTitle className=\"text-title cursor-help truncate\" />}\n >\n {effectiveTitle}\n </TooltipTrigger>\n <TooltipContent>\n <p>{effectiveDescription}</p>\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n <span className=\"sr-only\">{effectiveDescription}</span>\n </>\n ) : (\n <CardTitle className=\"text-title truncate\">{effectiveTitle}</CardTitle>\n );\n\n return (\n <CardHeader className=\"flex-shrink-0 px-5 pt-4 pb-3\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex min-w-0 items-start gap-2.5\">\n {meta.isCollapsible ? <CollapseButton /> : null}\n <div className=\"min-w-0 space-y-0.5\">\n {titleNode}\n {verdict && verdict.tone !== 'clear' ? (\n <VerdictLine verdict={verdict} />\n ) : contextLine ? (\n <p\n className=\"text-muted-foreground text-meta truncate\"\n data-test=\"widget-header-context\"\n >\n {contextLine}\n {verdict ? (\n <>\n {' · '}\n <span data-test=\"widget-verdict\" data-verdict=\"clear\">\n {verdict.sentence}\n </span>\n </>\n ) : null}\n </p>\n ) : verdict ? (\n <VerdictLine verdict={verdict} />\n ) : null}\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {trailing ? <HeaderTrailing trailing={trailing} /> : null}\n {children}\n <WidgetMenu items={menu} />\n </div>\n </div>\n </CardHeader>\n );\n}\n\n/**\n * The actions every widget shares, whatever it renders: open its full\n * surface, reload it, pin or unpin it. Each item needs something from the host\n * or the widget's data layer, so the menu shows only what applies — and\n * nothing at all when nothing does.\n */\nfunction WidgetMenu({ items }: { items?: ReactNode }) {\n const { state, actions, meta, data } = useWidget();\n const refresh = state.state === 'active' ? data?.refresh : undefined;\n const hasNavigation = !!items || !!meta.openHref || !!refresh;\n\n if (!hasNavigation && !meta.isPinnable) return null;\n\n const title = meta.title ?? 'widget';\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"text-muted-foreground hover:text-foreground\"\n aria-label={`Actions for ${title}`}\n data-test={`widget-menu-${meta.widgetId}`}\n />\n }\n >\n <Icon name=\"fa-ellipsis\" className=\"h-4 w-4\" aria-hidden />\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-48\">\n {items}\n {meta.openHref ? (\n <DropdownMenuItem render={<Link href={meta.openHref} />}>\n <Icon name=\"fa-arrow-up-right-from-square\" aria-hidden />\n <Trans\n i18nKey=\"dashboard:widgetOpenInWorkspace\"\n defaults=\"Open in workspace\"\n />\n </DropdownMenuItem>\n ) : null}\n {refresh ? (\n <DropdownMenuItem onClick={refresh} disabled={data?.refreshing}>\n <Icon name=\"fa-arrows-rotate\" aria-hidden />\n <Trans i18nKey=\"dashboard:widgetRefresh\" defaults=\"Refresh\" />\n </DropdownMenuItem>\n ) : null}\n {hasNavigation && meta.isPinnable ? <DropdownMenuSeparator /> : null}\n {meta.isPinnable ? (\n <DropdownMenuItem\n onClick={actions.togglePinned}\n disabled={state.pendingPin}\n data-test={`widget-menu-pin-${meta.widgetId}`}\n >\n <Icon\n name={state.pinned ? 'fa-thumbtack-slash' : 'fa-thumbtack'}\n aria-hidden\n />\n {state.pinned ? (\n <Trans\n i18nKey=\"dashboard:widgetUnpin\"\n defaults=\"Unpin from board\"\n />\n ) : (\n <Trans i18nKey=\"dashboard:widgetPin\" defaults=\"Pin to board\" />\n )}\n </DropdownMenuItem>\n ) : null}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/**\n * One widget-specific entry in the header's ⋯ menu; pass it through\n * `Widget.Header`'s `menu` prop. With `href` it is a link, opened in a new tab\n * when `external`; otherwise it runs `onSelect`.\n */\nfunction WidgetMenuItem({\n icon,\n href,\n external = false,\n onSelect,\n disabled,\n children,\n}: {\n /** A Font Awesome class, e.g. `fa-envelope`. */\n icon?: string;\n href?: string;\n external?: boolean;\n onSelect?: () => void;\n disabled?: boolean;\n children: ReactNode;\n}) {\n const link = !href ? undefined : external ? (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={href} />\n );\n\n return (\n <DropdownMenuItem render={link} onClick={onSelect} disabled={disabled}>\n <Icon\n name={\n icon ??\n (external ? 'fa-arrow-up-right-from-square' : 'fa-arrow-right')\n }\n aria-hidden\n />\n {children}\n </DropdownMenuItem>\n );\n}\n\n/**\n * A setting that doesn't earn the header's one trailing slot (a comparison\n * basis, an as-of month), as a submenu of choices in the ⋯ menu. Pass it\n * through `Widget.Header`'s `menu` prop.\n */\nfunction WidgetMenuChoice<Value extends string>({\n icon,\n label,\n value,\n options,\n onChange,\n}: {\n /** A Font Awesome class, e.g. `fa-scale-balanced`. */\n icon?: string;\n label: ReactNode;\n value: Value;\n options: ReadonlyArray<{ value: Value; label: ReactNode }>;\n onChange: (value: Value) => void;\n}) {\n const current = options.find((option) => option.value === value);\n\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <Icon name={icon ?? 'fa-sliders'} aria-hidden />\n <span className=\"flex-1\">{label}</span>\n {current ? (\n <span className=\"text-muted-foreground text-fine\">\n {current.label}\n </span>\n ) : null}\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"min-w-44\">\n <DropdownMenuRadioGroup\n value={value}\n onValueChange={(next) => {\n const match = options.find((option) => option.value === next);\n if (match) onChange(match.value);\n }}\n >\n {options.map((option) => (\n <DropdownMenuRadioItem key={option.value} value={option.value}>\n {option.label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/**\n * \"Updated 3 minutes ago\" under an active widget whose data layer reports\n * when it last loaded (see `Widget.DataState`'s `updatedAt`).\n */\nfunction WidgetFreshness() {\n const { state, data } = useWidget();\n const updated = useRelativeTime(data?.updatedAt);\n\n if (state.state !== 'active' || state.collapsed || !updated) return null;\n\n return (\n <div\n className=\"text-muted-foreground border-border/60 text-fine flex shrink-0 items-center gap-1.5 border-t px-5 py-2.5\"\n aria-live=\"polite\"\n >\n {data?.refreshing ? (\n <>\n <Icon\n name=\"fa-arrows-rotate\"\n className=\"h-3 w-3 animate-spin\"\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRefreshing\" defaults=\"Refreshing…\" />\n </>\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetUpdated\"\n defaults=\"Updated {{time}}\"\n values={{ time: updated }}\n />\n )}\n </div>\n );\n}\n\n// ─── State-gated content ────────────────────────────────────────────────────\n\nfunction CollapsibleBody({\n collapsed,\n maxContentHeight,\n widgetId,\n children,\n}: {\n collapsed: boolean;\n maxContentHeight?: string;\n widgetId: string;\n children: ReactNode;\n}) {\n return (\n <div\n className={cn(\n 'ease-out-strong grid min-h-0 flex-1 transition-all duration-300 motion-reduce:transition-none',\n collapsed ? 'grid-rows-[0fr]' : 'grid-rows-[1fr]',\n )}\n >\n <div className=\"min-h-0 overflow-hidden\">\n <CardContent\n id={`widget-content-${widgetId}`}\n className={cn(\n 'flex h-full min-h-0 flex-1 flex-col overflow-y-auto p-0',\n 'ease-out-strong transition-opacity duration-200 motion-reduce:transition-none',\n collapsed ? 'opacity-0' : 'opacity-100',\n maxContentHeight && 'max-h-(--widget-max-height)',\n )}\n style={\n maxContentHeight\n ? ({ '--widget-max-height': maxContentHeight } as CSSProperties)\n : undefined\n }\n >\n {children}\n </CardContent>\n </div>\n </div>\n );\n}\n\nfunction StaticBody({\n maxContentHeight,\n children,\n}: {\n maxContentHeight?: string;\n children: ReactNode;\n}) {\n const { innerRef, height } = useAnimatedHeight();\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n <div\n className={cn(\n 'h-(--body-height) overflow-hidden transition-all duration-250 ease-out motion-reduce:transition-none',\n maxContentHeight && 'max-h-(--widget-max-height)',\n )}\n style={\n {\n '--body-height': height === 'auto' ? 'auto' : `${height}px`,\n '--widget-max-height': maxContentHeight,\n } as CSSProperties\n }\n >\n <div ref={innerRef}>{children}</div>\n </div>\n </CardContent>\n );\n}\n\n/**\n * The standard padded body for content rendered inside `Widget.Active`.\n *\n * `Widget.Active`'s own `CardContent` renders `p-0` — deliberately, so a\n * full-bleed chart or table can run edge-to-edge inside the card. That means\n * ordinary content (text, rows, a KPI readout) is left flush against the\n * card's sides while `Widget.Header` stays inset (`px-5`) unless the body\n * supplies its own padding. `Widget.Body` is that padding: `px-5` matches\n * the header's horizontal inset so header and body align, `pt-4 pb-5`\n * balances the header's `pb-3`/card's bottom edge.\n *\n * Every widget wraps its content in it:\n *\n * ```tsx\n * <Widget.Active>\n * <Widget.Body>{/* text, a Stat, a form *\\/}</Widget.Body>\n * </Widget.Active>\n * ```\n *\n * Pass `flush` when the content runs to the card's edges: edge-to-edge rows\n * that pad themselves, a chart, a table with its own header row, an image.\n */\nfunction WidgetBody({\n flush = false,\n className,\n children,\n}: {\n /**\n * Drop the padding for content that runs to the card's edges: edge-to-edge\n * rows (which pad themselves, `px-5 py-3`), a full-bleed chart, an image.\n */\n flush?: boolean;\n className?: string;\n children: ReactNode;\n}) {\n return (\n <div\n className={cn(\n 'flex flex-1 flex-col',\n flush ? 'pb-2' : 'gap-4 px-5 pt-4 pb-5',\n className,\n )}\n data-flush={flush || undefined}\n >\n {children}\n </div>\n );\n}\n\n/**\n * Renders `children` once the widget's state is `active`. Its `CardContent`\n * is flush (`p-0`); wrap content in `Widget.Body`, which pads it to line up\n * with the header, or `Widget.Body flush` for edge-to-edge rows and charts.\n * Never hand-roll a `px-*` wrapper.\n */\nfunction WidgetActive({ children }: { children: ReactNode }) {\n const { state, meta, data } = useWidget();\n if (state.state !== 'active') return null;\n const body = (\n <WidgetErrorBoundary widgetId={meta.widgetId} onRetry={data?.refresh}>\n {children}\n </WidgetErrorBoundary>\n );\n return meta.isCollapsible ? (\n <CollapsibleBody\n collapsed={state.collapsed}\n maxContentHeight={meta.maxContentHeight}\n widgetId={meta.widgetId}\n >\n {body}\n </CollapsibleBody>\n ) : (\n <StaticBody maxContentHeight={meta.maxContentHeight}>{body}</StaticBody>\n );\n}\n\n/**\n * Shows while the widget loads: a skeleton shaped like its body (`variant`,\n * `rows` by default), never a spinner.\n */\nfunction WidgetLoading({\n variant,\n children,\n}: {\n variant?: WidgetSkeletonVariant;\n children?: ReactNode;\n}) {\n const { state } = useWidget();\n if (state.state !== 'loading') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? <WidgetLoadingSkeleton variant={variant} />}\n </CardContent>\n );\n}\n\n/**\n * Shows when the widget's data failed to load. Offers Try again whenever the\n * widget reports `onRefresh` through `Widget.DataState`. `title` and\n * `description` replace the default copy with something specific (\"Couldn't\n * load your inbox\").\n */\nfunction WidgetError({\n title,\n description,\n children,\n}: {\n title?: ReactNode;\n description?: ReactNode;\n children?: ReactNode;\n}) {\n const { state, data } = useWidget();\n if (state.state !== 'error') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? (\n <WidgetErrorState\n title={title}\n description={description}\n onRetry={data?.refresh}\n retrying={data?.refreshing}\n />\n )}\n </CardContent>\n );\n}\n\n/**\n * Shows when the widget can't reach its data. Give it a `reason`:\n * `not-connected` (one Connect button in `action`), `no-access` (a calm note\n * pointing to an admin) or `setup-needed`. `integrationName` defaults to the\n * host's source name.\n */\nfunction WidgetInactive({\n children,\n integrationName,\n ...props\n}: WidgetInactiveStateProps & { children?: ReactNode }) {\n const { state, meta } = useWidget();\n if (state.state !== 'inactive') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? (\n <WidgetInactiveState\n integrationName={integrationName ?? meta.source?.name}\n {...props}\n />\n )}\n </CardContent>\n );\n}\n\n/**\n * What an active widget shows when it has nothing to list. Render it inside\n * `Widget.Active`. Positive by default (\"You're all caught up\"), because an\n * empty queue is good news; `tone=\"neutral\"` for an empty search.\n */\nfunction WidgetEmpty(props: WidgetEmptyStateProps) {\n return <WidgetEmptyState {...props} />;\n}\n\nfunction WidgetDisabled({ children }: { children?: ReactNode }) {\n const { state } = useWidget();\n if (state.state !== 'disabled') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? <WidgetDisabledState />}\n </CardContent>\n );\n}\n\n// ─── Footers ────────────────────────────────────────────────────────────────\n\nfunction WidgetFooter({ children }: { children: ReactNode }) {\n const { state, meta } = useWidget();\n if (state.state !== 'active') return null;\n return (\n <CardFooter\n className={cn(\n 'ease-out-strong flex-shrink-0 pb-6 transition-opacity duration-200 motion-reduce:transition-none',\n meta.isCollapsible && state.collapsed\n ? 'pointer-events-none opacity-0'\n : 'opacity-100',\n )}\n aria-hidden={meta.isCollapsible && state.collapsed}\n >\n {children}\n </CardFooter>\n );\n}\n\nfunction WidgetActions({ children }: { children: ReactNode }) {\n return (\n <CardFooter className=\"bg-muted flex-shrink-0 justify-end border-t py-3\">\n {children}\n </CardFooter>\n );\n}\n\nfunction WidgetAskFooter({ context }: { context?: WidgetAskContext }) {\n const { state, meta, data } = useWidget();\n const effectiveContext = context ?? meta.askContext;\n const shouldShow =\n (meta.aiFooterEnabled || !!effectiveContext) &&\n state.state === 'active' &&\n !state.collapsed;\n if (!shouldShow) return null;\n const base = effectiveContext ?? {\n widgetId: meta.widgetId,\n title: meta.title ?? meta.widgetId,\n snapshot: null,\n suggestedPrompt: `Tell me about ${meta.title ?? 'this widget'}.`,\n };\n return <WidgetAskBar context={withVerdict(base, data?.verdict)} />;\n}\n\n/**\n * Adds the widget's own conclusion to what the assistant sees, so an answer\n * starts from the verdict on the card instead of re-deriving it.\n */\nfunction withVerdict(\n context: WidgetAskContext,\n verdict: WidgetVerdict | undefined,\n): WidgetAskContext {\n if (!verdict) return context;\n return {\n ...context,\n snapshot: {\n ...context.snapshot,\n verdict: {\n tone: verdict.tone,\n sentence: verdict.sentence,\n ...(verdict.count !== undefined ? { count: verdict.count } : {}),\n },\n },\n };\n}\n\n/**\n * Renders a subtle \"data may be stale\" banner when the widget's integration is\n * `degraded` (but still active). Unhealthy integrations route to `disabled`\n * instead, so this only fires for the degraded middle ground.\n */\nfunction WidgetHealthFooter() {\n const { state, meta } = useWidget();\n const lastSuccessAt = toEpochMs(meta.health?.lastSuccessAt);\n const lastSynced = useRelativeTime(lastSuccessAt);\n const shouldShow =\n state.state === 'active' &&\n !state.collapsed &&\n meta.health?.status === 'degraded';\n if (!shouldShow) return null;\n return (\n <div className=\"text-warning border-warning/30 bg-warning/5 text-fine flex items-center gap-2 border-t px-4 py-2\">\n <Icon\n name=\"fa-circle-exclamation\"\n className=\"h-4 w-4 shrink-0\"\n aria-hidden\n />\n <span>\n {lastSynced ? (\n <Trans\n i18nKey=\"common:integrationHealth.degradedWidgetNoticeSince\"\n defaults=\"Data may be out of date. Last synced {{time}}.\"\n values={{ time: lastSynced }}\n />\n ) : (\n <Trans\n i18nKey=\"common:integrationHealth.degradedWidgetNotice\"\n defaults=\"This integration is degraded — data may be stale.\"\n />\n )}\n </span>\n </div>\n );\n}\n\nfunction toEpochMs(\n value: number | string | Date | null | undefined,\n): number | undefined {\n if (value === null || value === undefined) return undefined;\n const ms =\n value instanceof Date ? value.getTime() : new Date(value).getTime();\n return Number.isFinite(ms) && ms > 0 ? ms : undefined;\n}\n\n// ─── Data state override ────────────────────────────────────────────────────\n\n/**\n * Wraps children in a sub-provider that overrides the effective render state\n * with the widget's own data loading / error state. Only overrides when the\n * parent state is `active` — so the integration's `inactive` / `disabled` /\n * `loading` (initial) states still win.\n *\n * Read the parent integration state BEFORE wrapping in this component if you\n * need it to gate data fetching:\n *\n * ```tsx\n * const { state } = use(WidgetContext);\n * const integrationActive = state.state === 'active';\n * const { isLoading, isError } = useMyData(accountId, integrationActive);\n * return (\n * <Widget.DataState loading={isLoading} error={isError}>\n * <Widget.Card>…</Widget.Card>\n * </Widget.DataState>\n * );\n * ```\n *\n * Pass `onRefresh`, `refreshing` and `updatedAt` to give the widget the\n * shared Refresh menu item, a Try again button on its error view, and an\n * \"Updated 3 minutes ago\" footer. With TanStack Query:\n *\n * ```tsx\n * <Widget.DataState\n * loading={query.isLoading}\n * error={query.isError}\n * onRefresh={() => void query.refetch()}\n * refreshing={query.isFetching}\n * updatedAt={query.dataUpdatedAt}\n * >\n * ```\n */\nfunction WidgetDataState({\n loading,\n error,\n inactive,\n onRefresh,\n refreshing = false,\n updatedAt,\n verdict,\n children,\n}: {\n loading?: boolean;\n error?: boolean;\n /**\n * Force the `inactive` render state even though the integration itself is\n * active. Use for widget-level \"not connected\" states (e.g. the product is\n * activated but the upstream OAuth connection is missing). Takes priority\n * over `loading` / `error`.\n */\n inactive?: boolean;\n /** Reloads the widget's data. */\n onRefresh?: () => void;\n /** A reload is in flight. */\n refreshing?: boolean;\n /**\n * When the data on screen last loaded successfully: epoch milliseconds, an\n * ISO string or a `Date`. `0` means never, which TanStack Query's\n * `dataUpdatedAt` reports before the first success.\n */\n updatedAt?: number | string | Date | null;\n /**\n * The widget's verdict on its data (the design system's widget rules): `{ tone,\n * sentence, count? }`. Compute it with the same function the integration's\n * server `getAttention` uses, so the card and home's Needs you agree.\n */\n verdict?: WidgetVerdict;\n children: ReactNode;\n}) {\n const parent = useWidget();\n const overrideState: WidgetRenderState =\n parent.state.state !== 'active'\n ? parent.state.state\n : inactive\n ? 'inactive'\n : loading\n ? 'loading'\n : error\n ? 'error'\n : 'active';\n const updatedAtMs = toEpochMs(updatedAt);\n const reportsData =\n onRefresh !== undefined ||\n updatedAtMs !== undefined ||\n verdict !== undefined;\n const value = useMemo(\n () => ({\n state: { ...parent.state, state: overrideState },\n actions: parent.actions,\n meta: parent.meta,\n data: reportsData\n ? { updatedAt: updatedAtMs, refreshing, refresh: onRefresh, verdict }\n : parent.data,\n }),\n [\n parent.state,\n parent.actions,\n parent.meta,\n parent.data,\n overrideState,\n reportsData,\n updatedAtMs,\n refreshing,\n onRefresh,\n verdict,\n ],\n );\n return <WidgetContext value={value}>{children}</WidgetContext>;\n}\n\n// ─── Compound export ────────────────────────────────────────────────────────\n\nexport const Widget = {\n Card: WidgetCard,\n Header: WidgetHeader,\n MenuItem: WidgetMenuItem,\n MenuChoice: WidgetMenuChoice,\n DataState: WidgetDataState,\n Active: WidgetActive,\n Body: WidgetBody,\n Empty: WidgetEmpty,\n Loading: WidgetLoading,\n Error: WidgetError,\n Inactive: WidgetInactive,\n Disabled: WidgetDisabled,\n Footer: WidgetFooter,\n Actions: WidgetActions,\n AskFooter: WidgetAskFooter,\n HealthFooter: WidgetHealthFooter,\n};\n"]}
@@ -16,7 +16,7 @@ export interface WorkspaceTargetDefinition {
16
16
  * alphanumeric with single hyphens between segments. */
17
17
  slug: string;
18
18
  name: string;
19
- /** A Font Awesome class string, e.g. `fa-light fa-inbox`. Legacy Lucide
19
+ /** A Font Awesome class string, e.g. `fa-inbox`. Legacy Lucide
20
20
  * names are still translated at render time during the migration, but must
21
21
  * not be written. Validated by the host at gate time. */
22
22
  icon?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-target.js","sourceRoot":"","sources":["../../src/types/workspace-target.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The contract an integration uses to declare the workspaces it ships with\n * (`BaseIntegration.getWorkspaceTargets()`).\n *\n * The host's canonical definition is `z.input<typeof WorkspaceTargetSchema>`\n * (`@kit/integrations-core`, `schemas/workspace-target.schema.ts`) — the\n * schema validates declarations in CI and at materialization time, including\n * cross-field rules a type cannot carry (icon-name validity, slug format,\n * `inheritsWidgets`/`includedWidgetIds` exclusivity, one inheriting target\n * per set). This structural twin exists so the SDK's root entrypoint owns its\n * types without importing the host schema; the parity test beside these types\n * keeps the two shapes mutually assignable.\n */\nexport interface WorkspaceTargetDefinition {\n /** Stable URL segment — `/workspace/<slug>` routes reference it. Lowercase\n * alphanumeric with single hyphens between segments. */\n slug: string;\n name: string;\n /** A Font Awesome class string, e.g. `fa-light fa-inbox`. Legacy Lucide\n * names are still translated at render time during the migration, but must\n * not be written. Validated by the host at gate time. */\n icon?: string;\n description?: string;\n /** Defaults to `'masonry'` when omitted. */\n layout?: 'masonry' | 'two-column';\n /**\n * Whether this workspace receives the product's otherwise-unplaced\n * widgets. Exactly one target per product must set it; mutually exclusive\n * with `includedWidgetIds`.\n */\n inheritsWidgets?: boolean;\n /** Limit this workspace to specific widget ids. */\n includedWidgetIds?: string[];\n /**\n * Create this workspace on a Source as soon as the product is made\n * available there, instead of waiting for an admin to add it. Only for a\n * product that works as shipped (`activation: { required: false }`).\n */\n materializeOnEntitlement?: boolean;\n}\n"]}
1
+ {"version":3,"file":"workspace-target.js","sourceRoot":"","sources":["../../src/types/workspace-target.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The contract an integration uses to declare the workspaces it ships with\n * (`BaseIntegration.getWorkspaceTargets()`).\n *\n * The host's canonical definition is `z.input<typeof WorkspaceTargetSchema>`\n * (`@kit/integrations-core`, `schemas/workspace-target.schema.ts`) — the\n * schema validates declarations in CI and at materialization time, including\n * cross-field rules a type cannot carry (icon-name validity, slug format,\n * `inheritsWidgets`/`includedWidgetIds` exclusivity, one inheriting target\n * per set). This structural twin exists so the SDK's root entrypoint owns its\n * types without importing the host schema; the parity test beside these types\n * keeps the two shapes mutually assignable.\n */\nexport interface WorkspaceTargetDefinition {\n /** Stable URL segment — `/workspace/<slug>` routes reference it. Lowercase\n * alphanumeric with single hyphens between segments. */\n slug: string;\n name: string;\n /** A Font Awesome class string, e.g. `fa-inbox`. Legacy Lucide\n * names are still translated at render time during the migration, but must\n * not be written. Validated by the host at gate time. */\n icon?: string;\n description?: string;\n /** Defaults to `'masonry'` when omitted. */\n layout?: 'masonry' | 'two-column';\n /**\n * Whether this workspace receives the product's otherwise-unplaced\n * widgets. Exactly one target per product must set it; mutually exclusive\n * with `includedWidgetIds`.\n */\n inheritsWidgets?: boolean;\n /** Limit this workspace to specific widget ids. */\n includedWidgetIds?: string[];\n /**\n * Create this workspace on a Source as soon as the product is made\n * available there, instead of waiting for an admin to add it. Only for a\n * product that works as shipped (`activation: { required: false }`).\n */\n materializeOnEntitlement?: boolean;\n}\n"]}
@@ -99,6 +99,13 @@ function stringVisitors(test, message) {
99
99
  };
100
100
  }
101
101
 
102
+ /**
103
+ * A default icon family written before an icon name (plan 251 D44). Icons are
104
+ * written family-less (`fa-gear`) so the theme's icon style reaches every one;
105
+ * `fa-solid` / `fa-duotone` emphasis and `fa-brands` are deliberate and allowed.
106
+ */
107
+ const DEFAULT_ICON_FAMILY = /(?:^|[\s'"`])fa-(?:light|regular)\s+fa-[a-z0-9]/;
108
+
102
109
  const BADGE_TONES = new Set(['success', 'warning', 'info']);
103
110
 
104
111
  const TONE_BADGE_MESSAGE =
@@ -336,7 +343,7 @@ function isRenderPropValue(node) {
336
343
  const CARD_FILL = /(?:^|\s)bg-card(?=$|\s)/;
337
344
  const CARD_CORNER = /(?:^|\s)rounded(?:-[\w[\]]+)?(?=$|\s)/;
338
345
  const CARD_EDGE =
339
- /(?:^|\s)(?:shadow-(?:card|widget|xs|sm|md)|border(?:-border)?)(?=$|\s)/;
346
+ /(?:^|\s)(?:shadow-(?:ring|card|widget|xs|sm|md)|border(?:-border)?)(?=$|\s)/;
340
347
 
341
348
  /** @param {string} value */
342
349
  function isHandDrawnCard(value) {
@@ -415,6 +422,19 @@ export default {
415
422
  'white/black color utilities ignore the theme, dark mode and Source branding. Use a token: bg-card or bg-background for surfaces, text-foreground / text-primary-foreground for text. A modal scrim may stay black with a disable comment saying so (design-system theming rule).',
416
423
  ),
417
424
  },
425
+ 'no-default-icon-family': {
426
+ meta: {
427
+ type: 'problem',
428
+ docs: {
429
+ description:
430
+ 'Disallow fa-light / fa-regular in an icon name; write it family-less so the theme decides.',
431
+ },
432
+ },
433
+ create: stringVisitors(
434
+ DEFAULT_ICON_FAMILY,
435
+ 'Write the icon family-less (`fa-gear`, not `fa-light fa-gear`): the theme decides the family, regular by default or a Source’s icon style, so a family written here is one more icon a re-brand cannot reach. `fa-solid` / `fa-duotone` for deliberate emphasis and `fa-brands` stay (plan 251 D44).',
436
+ ),
437
+ },
418
438
  'no-overlay-width-class': {
419
439
  meta: {
420
440
  type: 'problem',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekanos/sdk",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "private": false,
5
5
  "description": "The official SDK for building Ekanos integrations.",
6
6
  "homepage": "https://sdk.ekanos.dev/sdk/overview",
@@ -77,25 +77,25 @@
77
77
  "access": "public"
78
78
  },
79
79
  "dependencies": {
80
- "@ekanos/integration-schema": "0.17.0",
81
- "@ekanos/ui": "0.17.0",
82
- "@supabase/supabase-js": "2.87.1",
80
+ "@ekanos/integration-schema": "0.18.0",
81
+ "@ekanos/ui": "0.18.0",
82
+ "@supabase/supabase-js": "2.118.0",
83
83
  "server-only": "^0.0.1"
84
84
  },
85
85
  "devDependencies": {
86
- "@hookform/resolvers": "^5.9.1",
86
+ "@hookform/resolvers": "^5.9.2",
87
87
  "@kit/tsconfig": "0.1.0",
88
- "@tanstack/react-query": "5.103.2",
89
- "@types/react": "19.2.18",
90
- "@types/react-dom": "19.2.5",
88
+ "@tanstack/react-query": "5.104.4",
89
+ "@types/react": "19.3.0",
90
+ "@types/react-dom": "19.3.0",
91
91
  "eslint": "^10.11.0",
92
92
  "next": "16.4.2",
93
- "react": "19.2.8",
94
- "react-dom": "19.2.8",
95
- "react-hook-form": "^7.88.0",
93
+ "react": "19.3.1",
94
+ "react-dom": "19.3.1",
95
+ "react-hook-form": "^7.90.0",
96
96
  "typescript": "^7.0.2",
97
97
  "vitest": "4.1.10",
98
- "zod": "4.6.5"
98
+ "zod": "4.6.7"
99
99
  },
100
100
  "peerDependencies": {
101
101
  "@hookform/resolvers": "^5.2.2",