@ekanos/sdk 0.25.0 → 0.26.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.
Files changed (62) hide show
  1. package/README.md +9 -11
  2. package/api-report.md +27 -6
  3. package/dist/components/base-activation-dialog.js +2 -2
  4. package/dist/components/base-activation-dialog.js.map +1 -1
  5. package/dist/components/base-activation-form.js +1 -1
  6. package/dist/components/base-activation-form.js.map +1 -1
  7. package/dist/components/base-marketplace-tile.js +2 -2
  8. package/dist/components/base-marketplace-tile.js.map +1 -1
  9. package/dist/components/index.d.ts +1 -0
  10. package/dist/components/index.js +1 -0
  11. package/dist/components/index.js.map +1 -1
  12. package/dist/components/oauth-activation-form.d.ts +8 -0
  13. package/dist/components/oauth-activation-form.js +10 -4
  14. package/dist/components/oauth-activation-form.js.map +1 -1
  15. package/dist/components/widgets/ai-prompt-chip.js +3 -3
  16. package/dist/components/widgets/ai-prompt-chip.js.map +1 -1
  17. package/dist/components/widgets/widget-ask-bar.js +1 -1
  18. package/dist/components/widgets/widget-ask-bar.js.map +1 -1
  19. package/dist/components/widgets/widget-ask-presentation.d.ts +35 -0
  20. package/dist/components/widgets/widget-ask-presentation.js +35 -0
  21. package/dist/components/widgets/widget-ask-presentation.js.map +1 -0
  22. package/dist/components/widgets/widget-state-components.d.ts +6 -1
  23. package/dist/components/widgets/widget-state-components.js +8 -8
  24. package/dist/components/widgets/widget-state-components.js.map +1 -1
  25. package/dist/components/widgets/widget.d.ts +2 -2
  26. package/dist/components/widgets/widget.js +33 -27
  27. package/dist/components/widgets/widget.js.map +1 -1
  28. package/dist/context/types.d.ts +1 -1
  29. package/dist/context/types.js.map +1 -1
  30. package/dist/contract/derive-contract.js +16 -10
  31. package/dist/contract/derive-contract.js.map +1 -1
  32. package/dist/contract/types.d.ts +1 -1
  33. package/dist/contract/types.js.map +1 -1
  34. package/dist/experience/client.d.ts +76 -0
  35. package/dist/experience/client.js +103 -2
  36. package/dist/experience/client.js.map +1 -1
  37. package/dist/experience/runtime.d.ts +16 -0
  38. package/dist/experience/runtime.js.map +1 -1
  39. package/dist/experience/sdk-instances.d.ts +11 -0
  40. package/dist/experience/sdk-instances.js +47 -0
  41. package/dist/experience/sdk-instances.js.map +1 -0
  42. package/dist/hooks/index.d.ts +1 -1
  43. package/dist/hooks/index.js.map +1 -1
  44. package/dist/hooks/partner-oauth.d.ts +15 -2
  45. package/dist/hooks/partner-oauth.js +3 -0
  46. package/dist/hooks/partner-oauth.js.map +1 -1
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js.map +1 -1
  49. package/dist/integration/index.d.ts +4 -2
  50. package/dist/integration/index.js +4 -1
  51. package/dist/integration/index.js.map +1 -1
  52. package/dist/testing/mock-context.d.ts +21 -2
  53. package/dist/testing/mock-context.js +102 -45
  54. package/dist/testing/mock-context.js.map +1 -1
  55. package/dist/types/workspace-target.d.ts +1 -1
  56. package/dist/types/workspace-target.js.map +1 -1
  57. package/dist/version.d.ts +7 -0
  58. package/dist/version.js +8 -0
  59. package/dist/version.js.map +1 -0
  60. package/eslint.design-preset.mjs +5 -3
  61. package/eslint.design-rules.mjs +195 -9
  62. package/package.json +3 -3
@@ -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,cAAc,EAAE,MAAM,wB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N,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,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,GAC3B,CAClB,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 { ActivationForm } 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 /** @deprecated The host names the integration; this is not shown. */\n title?: string;\n /** @deprecated The host describes the integration; this is not shown. */\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 ActivationForm 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 reconnect = false,\n } = props;\n\n const {\n slug,\n displayName,\n connectPath = `/api/integrations/${slug}/connect`,\n connectButtonText,\n activateButtonText,\n externalIdPrefix = slug,\n autoActivateOnConnect = true,\n } = config;\n\n const [error, setError] = useState<string | null>(null);\n const [activated, setActivated] = useState(false);\n\n const {\n data: connectionStatus,\n oauthJustCompleted,\n oauthError,\n isLoading: isCheckingConnection,\n } = useOAuthConnectionStatus(accountId, {\n connectionKey: `${slug}-connection`,\n checkConnection,\n errorParam,\n });\n\n const isConnected = connectionStatus?.isConnected ?? false;\n\n const form = useForm({ defaultValues: {} });\n\n const activateIntegration = useActivateIntegration();\n const { mutateAsync: activateMutateAsync } = activateIntegration;\n\n const startConnect = useCallback(() => {\n setError(null);\n const params = new URLSearchParams({\n accountId,\n returnPath: currentReturnPath(\n '/home',\n reconnect ? {} : { firstConnect: slug },\n ),\n });\n\n // For a user-scoped integration `accountId` is the PERSONAL account (see\n // the connect modal's scope-resolved id), which has no\n // source_id — so an OAuth callback cannot materialize workspaces from it\n // alone. Carry the team through as well; callbacks that don't read it\n // simply ignore the extra param.\n if (teamAccountId) {\n params.set('teamAccountId', teamAccountId);\n }\n\n window.location.href = `${connectPath}?${params.toString()}`;\n }, [accountId, teamAccountId, connectPath, reconnect, slug]);\n\n // Reports success exactly once, straight to the host — no in-form panel,\n // no second call from a \"Continue\" button.\n const handleActivate = useCallback(async () => {\n try {\n setError(null);\n await activateMutateAsync({\n accountId,\n sourceId,\n teamAccountId,\n integrationSlug: slug,\n activationData: {},\n });\n setActivated(true);\n\n onSuccess?.({\n success: true,\n externalId: `${externalIdPrefix}_${Date.now()}`,\n });\n } catch (err) {\n const errorMessage =\n err instanceof Error ? err.message : 'Activation failed';\n setError(errorMessage);\n }\n }, [\n accountId,\n sourceId,\n teamAccountId,\n slug,\n externalIdPrefix,\n activateMutateAsync,\n onSuccess,\n ]);\n\n const handleSubmit = useCallback(async () => {\n // A reconnect always goes back through sign-in — that is what issues\n // the fresh token — unless this render IS the return from it.\n if (!isConnected || (reconnect && !oauthJustCompleted)) {\n startConnect();\n return;\n }\n\n await handleActivate();\n }, [\n isConnected,\n reconnect,\n oauthJustCompleted,\n handleActivate,\n startConnect,\n ]);\n\n // Auto-activate after OAuth return, unless the integration opted out so the\n // user can review its post-connect configuration first.\n const hasAutoActivated = useRef(false);\n\n useEffect(() => {\n if (\n autoActivateOnConnect &&\n oauthJustCompleted &&\n isConnected &&\n !activated &&\n !activateIntegration.isPending &&\n !hasAutoActivated.current\n ) {\n hasAutoActivated.current = true;\n\n const id = requestAnimationFrame(() => {\n void handleActivate();\n });\n\n return () => cancelAnimationFrame(id);\n }\n }, [\n autoActivateOnConnect,\n oauthJustCompleted,\n isConnected,\n activated,\n activateIntegration.isPending,\n handleActivate,\n ]);\n\n const displayError = error || oauthError;\n\n // The round-trip is in flight from the moment the redirect lands until\n // activation reports back: the button reads as busy the whole way rather\n // than flashing \"Continue with X\" a second time.\n const finishing =\n autoActivateOnConnect && oauthJustCompleted && isConnected && !displayError;\n\n const signInAgain = reconnect && !oauthJustCompleted;\n\n const buttonText = signInAgain\n ? (connectButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.reconnectWith\"\n values={{ name: displayName }}\n defaults={`Reconnect with ${displayName}`}\n />\n ))\n : isConnected\n ? (activateButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.connect\"\n defaults=\"Connect\"\n />\n ))\n : (connectButtonText ?? (\n <Trans\n i18nKey=\"common:integrationConnect.continueWith\"\n values={{ name: displayName }}\n defaults={`Continue with ${displayName}`}\n />\n ));\n\n return (\n <ActivationForm\n onCancel={onCancel}\n form={form}\n onSubmit={handleSubmit}\n isLoading={externalLoading || activateIntegration.isPending || finishing}\n error={displayError}\n submitLabel={buttonText}\n submitLoadingLabel={\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 submitDisabled={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 </ActivationForm>\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,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAwD1D;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;;IACjE,MAAM,EACJ,MAAM,EACN,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,EAAE,eAAe,GAAG,KAAK,EAClC,SAAS,GAAG,KAAK,GAClB,GAAG,KAAK,CAAC;IAEV,MAAM,EACJ,IAAI,EACJ,WAAW,EACX,WAAW,GAAG,qBAAqB,IAAI,UAAU,EACjD,iB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,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,IAAC,IAAI,EAAC,cAAc,EAAC,SAAS,EAAC,sBAAsB,GAAG,EAC7D,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,GAC3B,CAClB,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 { ActivationForm } 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 /** @deprecated The host names the integration; this is not shown. */\n title?: string;\n /** @deprecated The host describes the integration; this is not shown. */\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 /**\n * Which declared OAuth connection this form connects: an\n * `oauthConnections` key (e.g. `agent`). Sent to the connect route as\n * `?connection=<id>`; absent or `default` is the main `oauth`. Pair it\n * with `createPartnerConnectionCheck(slug, { connection })` so the status\n * read asks about the same connection.\n */\n connection?: 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 ActivationForm 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 reconnect = false,\n } = props;\n\n const {\n slug,\n displayName,\n connectPath = `/api/integrations/${slug}/connect`,\n connectButtonText,\n activateButtonText,\n externalIdPrefix = slug,\n autoActivateOnConnect = true,\n connection,\n } = config;\n const namedConnection =\n connection && connection !== 'default' ? connection : undefined;\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: namedConnection\n ? `${slug}-${namedConnection}-connection`\n : `${slug}-connection`,\n checkConnection,\n errorParam,\n });\n\n const isConnected = connectionStatus?.isConnected ?? false;\n\n const form = useForm({ defaultValues: {} });\n\n const activateIntegration = useActivateIntegration();\n const { mutateAsync: activateMutateAsync } = activateIntegration;\n\n const startConnect = useCallback(() => {\n setError(null);\n const params = new URLSearchParams({\n accountId,\n returnPath: currentReturnPath(\n '/home',\n reconnect ? {} : { firstConnect: slug },\n ),\n });\n\n // For a user-scoped integration `accountId` is the PERSONAL account (see\n // the connect modal's scope-resolved id), which has no\n // source_id — so an OAuth callback cannot materialize workspaces from it\n // alone. Carry the team through as well; callbacks that don't read it\n // simply ignore the extra param.\n if (teamAccountId) {\n params.set('teamAccountId', teamAccountId);\n }\n\n if (namedConnection) {\n params.set('connection', namedConnection);\n }\n\n window.location.href = `${connectPath}?${params.toString()}`;\n }, [accountId, teamAccountId, connectPath, reconnect, slug, namedConnection]);\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 <ActivationForm\n onCancel={onCancel}\n form={form}\n onSubmit={handleSubmit}\n isLoading={externalLoading || activateIntegration.isPending || finishing}\n error={displayError}\n submitLabel={buttonText}\n submitLoadingLabel={\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 submitDisabled={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=\"check-circle\" 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 </ActivationForm>\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-wand-magic-sparkles", className: "h-4 w-4" }) }));
30
+ return (_jsx(Button, { variant: "ghost", size: "icon-sm", className: cn('p-0', className), onClick: handleClick, "aria-label": `Ask AI: ${label}`, children: _jsx(Icon, { name: "magic-wand", 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-wand-magic-sparkles", className: "text-primary 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: "magic-wand", className: "text-primary 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('px-3', className), "aria-label": label, children: [_jsx(Icon, { name: "fa-wand-magic-sparkles", className: "text-primary 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('px-3', className), "aria-label": label, children: [_jsx(Icon, { name: "magic-wand", className: "text-primary h-3.5 w-3.5 shrink-0" }), _jsx("span", { children: label })] }));
37
37
  }
38
38
  //# sourceMappingURL=ai-prompt-chip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-prompt-chip.js","sourceRoot":"","sources":["../../../src/components/widgets/ai-prompt-chip.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAqBpE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,OAAO,EACP,YAAY,EACZ,KAAK,EACL,UAAU,EACV,OAAO,GAAG,QAAQ,EAClB,SAAS,GACS;IAClB,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IAEvC,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,YAAY,CAAC;YACX,QAAQ,EAAE,YAAY;YACtB,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK;YACrB,QAAQ,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE;YACvB,eAAe,EAAE,MAAM;SACxB,CAAC,CAAC;QACH,UAAU,aAAV,UAAU,uBAAV,UAAU,EAAI,CAAC;IACjB,CAAC,CAAC;IAEF,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,CACL,KAAC,MAAM,IACL,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,EACvC,OAAO,EAAE,WAAW,gBACR,WAAW,KAAK,EAAE,YAE9B,KAAC,IAAI,IAAC,IAAI,EAAC,wBAAwB,EAAC,SAAS,EAAC,SAAS,GAAG,GACnD,CACV,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,CACL,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,EAAE,CACX,oEAAoE,EACpE,SAAS,CACV,gBACW,KAAK,aAEjB,KAAC,IAAI,IACH,IAAI,EAAC,wBAAwB,EAC7B,SAAS,EAAC,+BAA+B,GACzC,EACF,eAAM,SAAS,EAAC,WAAW,YAAE,KAAK,GAAQ,IACnC,CACV,CAAC;IACJ,CAAC;IAED,kBAAkB;IAClB,OAAO,CACL,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,gBACpB,KAAK,aAEjB,KAAC,IAAI,IACH,IAAI,EAAC,wBAAwB,EAC7B,SAAS,EAAC,mCAAmC,GAC7C,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 h-4 w-4 shrink-0\"\n />\n <span className=\"text-left\">{label}</span>\n </Button>\n );\n }\n\n // inline (Type B)\n return (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"xs\"\n onClick={handleClick}\n className={cn('px-3', className)}\n aria-label={label}\n >\n <Icon\n name=\"fa-wand-magic-sparkles\"\n className=\"text-primary h-3.5 w-3.5 shrink-0\"\n />\n <span>{label}</span>\n </Button>\n );\n}\n"]}
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,SAAS,EACd,SAAS,EAAE,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,EAC/B,OAAO,EAAE,WAAW,gBACR,WAAW,KAAK,EAAE,YAE9B,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,EAAC,SAAS,EAAC,SAAS,GAAG,GACvC,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,IAAC,IAAI,EAAC,YAAY,EAAC,SAAS,EAAC,+BAA+B,GAAG,EACpE,eAAM,SAAS,EAAC,WAAW,YAAE,KAAK,GAAQ,IACnC,CACV,CAAC;IACJ,CAAC;IAED,kBAAkB;IAClB,OAAO,CACL,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,gBACpB,KAAK,aAEjB,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,EAAC,SAAS,EAAC,mCAAmC,GAAG,EACxE,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=\"icon-sm\"\n className={cn('p-0', className)}\n onClick={handleClick}\n aria-label={`Ask AI: ${label}`}\n >\n <Icon name=\"magic-wand\" 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 name=\"magic-wand\" className=\"text-primary h-4 w-4 shrink-0\" />\n <span className=\"text-left\">{label}</span>\n </Button>\n );\n }\n\n // inline (Type B)\n return (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"xs\"\n onClick={handleClick}\n className={cn('px-3', className)}\n aria-label={label}\n >\n <Icon name=\"magic-wand\" className=\"text-primary h-3.5 w-3.5 shrink-0\" />\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 shrink-0 border-t", "data-test": "widget-ask-bar", "data-write-action": true, children: [_jsxs(Button, { type: "button", variant: "ghost", onClick: () => (isActive ? dismiss() : setIsActive(true)), "aria-expanded": isActive, "aria-label": isActive
55
55
  ? `Close ask input for ${context.title}`
56
- : `Ask about ${context.title}`, "data-test": "widget-ask-bar-toggle", className: "group/tag h-auto w-full justify-start gap-2.5 rounded-none px-4 py-2.5 text-left sm:px-5", children: [_jsx(AskIcon, { className: cn('text-muted-foreground h-5 w-5 shrink-0 transition-transform duration-200', isActive && 'scale-110') }), _jsx("span", { className: "text-muted-foreground group-hover/tag:text-foreground flex-1 text-base font-medium transition-colors", children: "Ask about this" }), _jsx(Icon, { name: "fa-chevron-up", className: cn('text-muted-foreground group-hover/tag:text-muted-foreground h-3.5 w-3.5 shrink-0 transition-transform duration-200', isActive && 'rotate-180') })] }), isActive && (_jsxs("div", { className: "border-border space-y-3 border-t p-3 sm:px-5", "data-test": "widget-ask-bar-input", children: [suggestions.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-2", "data-test": "widget-ask-bar-suggestions", children: suggestions.map((s) => (_jsxs(Button, { type: "button", variant: "outline", size: "xs", onClick: () => handleSuggestion(s.prompt), className: "px-3", "aria-label": s.label, children: [_jsx(Icon, { name: "fa-wand-magic-sparkles", className: "text-primary 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-muted-foreground h-5 w-5 shrink-0 transition-transform duration-200', isActive && 'scale-110') }), _jsx("span", { className: "text-muted-foreground group-hover/tag:text-foreground flex-1 text-base font-medium transition-colors", children: "Ask about this" }), _jsx(Icon, { name: "caret-up", className: cn('text-muted-foreground group-hover/tag:text-muted-foreground h-3.5 w-3.5 shrink-0 transition-transform duration-200', isActive && 'rotate-180') })] }), isActive && (_jsxs("div", { className: "border-border space-y-3 border-t p-3 sm:px-5", "data-test": "widget-ask-bar-input", children: [suggestions.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-2", "data-test": "widget-ask-bar-suggestions", children: suggestions.map((s) => (_jsxs(Button, { type: "button", variant: "outline", size: "xs", onClick: () => handleSuggestion(s.prompt), className: "px-3", "aria-label": s.label, children: [_jsx(Icon, { name: "magic-wand", className: "text-primary 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,MAA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,CAAC,CAAC,MAAM,CAAC,EACzC,SAAS,EAAC,MAAM,gBACJ,CAAC,CAAC,KAAK,aAEnB,KAAC,IAAI,IACH,IAAI,EAAC,wBAAwB,EAC7B,SAAS,EAAC,mCAAmC,GAC7C,EACF,eAAM,SAAS,EAAC,WAAW,YAAE,CAAC,CAAC,KAAK,GAAQ,KAZvC,CAAC,CAAC,KAAK,CAaL,CACV,CAAC,GACE,CACP,EACD,MAAC,WAAW,IAAC,QAAQ,EAAE,YAAY,aACjC,KAAC,eAAe,cACd,KAAC,mBAAmB,IAClB,SAAS,QACT,WAAW,EAAE,aAAa,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,gBAC5C,aAAa,OAAO,CAAC,KAAK,EAAE,EACxC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;wCACf,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;4CACvB,CAAC,CAAC,cAAc,EAAE,CAAC;4CACnB,OAAO,EAAE,CAAC;wCACZ,CAAC;oCACH,CAAC,GACD,GACc,EAClB,MAAC,iBAAiB,eAChB,KAAC,gBAAgB,KAAG,EACpB,KAAC,iBAAiB,iBAAW,qBAAqB,GAAG,IACnC,IACR,IACV,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport {\n PromptInput,\n PromptInputBody,\n PromptInputFooter,\n PromptInputSubmit,\n PromptInputTextarea,\n PromptInputTools,\n} from '@ekanos/ui/ai-prompt-input';\nimport { Button } from '@ekanos/ui/button';\nimport { Icon } from '@ekanos/ui/icon';\nimport { cn } from '@ekanos/ui/utils';\n\nimport { useAskAssistant } from '../../hooks/ask-assistant-context';\nimport type { WidgetAskContext } from '../../types/widget-ask-context';\nimport { AskIcon } from './ask-icon';\n\ninterface Props {\n context: WidgetAskContext;\n}\n\n/**\n * Widget footer tag + expanding prompt input.\n *\n * - closed: a quiet, always-visible tag row at the bottom of the widget\n * (\"Aperture icon · Ask about this · chevron up\")\n * - open: clicking the tag reveals an inline `PromptInput` (the canonical\n * AI input component) below it. The tag itself doubles as the\n * close affordance (chevron rotates).\n *\n * Dismisses on click-outside or Escape. Submitting sends the user's typed\n * question (or the widget's suggestedPrompt fallback) to the assistant dock.\n */\nexport function WidgetAskBar({ context }: Props) {\n const [isActive, setIsActive] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const askAssistant = useAskAssistant();\n\n const dismiss = useCallback(() => {\n setIsActive(false);\n }, []);\n\n const handleSubmit = useCallback(\n (message: { text: string }) => {\n const prompt = message.text.trim() || context.suggestedPrompt;\n askAssistant({ ...context, suggestedPrompt: prompt });\n dismiss();\n },\n [askAssistant, context, dismiss],\n );\n\n const handleSuggestion = useCallback(\n (prompt: string) => {\n askAssistant({ ...context, suggestedPrompt: prompt });\n dismiss();\n },\n [askAssistant, context, dismiss],\n );\n\n const suggestions = context.suggestedPrompts ?? [];\n\n useEffect(() => {\n if (!isActive) return;\n const onPointerDown = (e: PointerEvent) => {\n const el = containerRef.current;\n if (!el) return;\n if (el.contains(e.target as Node)) return;\n dismiss();\n };\n document.addEventListener('pointerdown', onPointerDown);\n return () => document.removeEventListener('pointerdown', onPointerDown);\n }, [dismiss, isActive]);\n\n return (\n <div\n ref={containerRef}\n className=\"border-border shrink-0 border-t\"\n data-test=\"widget-ask-bar\"\n data-write-action\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() => (isActive ? dismiss() : setIsActive(true))}\n aria-expanded={isActive}\n aria-label={\n isActive\n ? `Close ask input for ${context.title}`\n : `Ask about ${context.title}`\n }\n data-test=\"widget-ask-bar-toggle\"\n className=\"group/tag h-auto w-full justify-start gap-2.5 rounded-none px-4 py-2.5 text-left sm:px-5\"\n >\n <AskIcon\n className={cn(\n 'text-muted-foreground h-5 w-5 shrink-0 transition-transform duration-200',\n isActive && 'scale-110',\n )}\n />\n <span className=\"text-muted-foreground group-hover/tag:text-foreground flex-1 text-base font-medium transition-colors\">\n Ask about this\n </span>\n <Icon\n name=\"fa-chevron-up\"\n className={cn(\n 'text-muted-foreground group-hover/tag:text-muted-foreground h-3.5 w-3.5 shrink-0 transition-transform duration-200',\n isActive && 'rotate-180',\n )}\n />\n </Button>\n\n {isActive && (\n <div\n className=\"border-border space-y-3 border-t p-3 sm:px-5\"\n data-test=\"widget-ask-bar-input\"\n >\n {suggestions.length > 0 && (\n <div\n className=\"flex flex-wrap gap-2\"\n data-test=\"widget-ask-bar-suggestions\"\n >\n {suggestions.map((s) => (\n <Button\n key={s.label}\n type=\"button\"\n variant=\"outline\"\n size=\"xs\"\n onClick={() => handleSuggestion(s.prompt)}\n className=\"px-3\"\n aria-label={s.label}\n >\n <Icon\n name=\"fa-wand-magic-sparkles\"\n className=\"text-primary 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,MA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,eAC9C,sBAAsB,aAE/B,WAAW,CAAC,MAAM,GAAG,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,MAAM,gBACJ,CAAC,CAAC,KAAK,aAEnB,KAAC,IAAI,IACH,IAAI,EAAC,YAAY,EACjB,SAAS,EAAC,mCAAmC,GAC7C,EACF,eAAM,SAAS,EAAC,WAAW,YAAE,CAAC,CAAC,KAAK,GAAQ,KAZvC,CAAC,CAAC,KAAK,CAaL,CACV,CAAC,GACE,CACP,EACD,MAAC,WAAW,IAAC,QAAQ,EAAE,YAAY,aACjC,KAAC,eAAe,cACd,KAAC,mBAAmB,IAClB,SAAS,QACT,WAAW,EAAE,aAAa,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,gBAC5C,aAAa,OAAO,CAAC,KAAK,EAAE,EACxC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;wCACf,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;4CACvB,CAAC,CAAC,cAAc,EAAE,CAAC;4CACnB,OAAO,EAAE,CAAC;wCACZ,CAAC;oCACH,CAAC,GACD,GACc,EAClB,MAAC,iBAAiB,eAChB,KAAC,gBAAgB,KAAG,EACpB,KAAC,iBAAiB,iBAAW,qBAAqB,GAAG,IACnC,IACR,IACV,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport {\n PromptInput,\n PromptInputBody,\n PromptInputFooter,\n PromptInputSubmit,\n PromptInputTextarea,\n PromptInputTools,\n} from '@ekanos/ui/ai-prompt-input';\nimport { Button } from '@ekanos/ui/button';\nimport { Icon } from '@ekanos/ui/icon';\nimport { cn } from '@ekanos/ui/utils';\n\nimport { useAskAssistant } from '../../hooks/ask-assistant-context';\nimport type { WidgetAskContext } from '../../types/widget-ask-context';\nimport { AskIcon } from './ask-icon';\n\ninterface Props {\n context: WidgetAskContext;\n}\n\n/**\n * Widget footer tag + expanding prompt input.\n *\n * - closed: a quiet, always-visible tag row at the bottom of the widget\n * (\"Aperture icon · Ask about this · chevron up\")\n * - open: clicking the tag reveals an inline `PromptInput` (the canonical\n * AI input component) below it. The tag itself doubles as the\n * close affordance (chevron rotates).\n *\n * Dismisses on click-outside or Escape. Submitting sends the user's typed\n * question (or the widget's suggestedPrompt fallback) to the assistant dock.\n */\nexport function WidgetAskBar({ context }: Props) {\n const [isActive, setIsActive] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const askAssistant = useAskAssistant();\n\n const dismiss = useCallback(() => {\n setIsActive(false);\n }, []);\n\n const handleSubmit = useCallback(\n (message: { text: string }) => {\n const prompt = message.text.trim() || context.suggestedPrompt;\n askAssistant({ ...context, suggestedPrompt: prompt });\n dismiss();\n },\n [askAssistant, context, dismiss],\n );\n\n const handleSuggestion = useCallback(\n (prompt: string) => {\n askAssistant({ ...context, suggestedPrompt: prompt });\n dismiss();\n },\n [askAssistant, context, dismiss],\n );\n\n const suggestions = context.suggestedPrompts ?? [];\n\n useEffect(() => {\n if (!isActive) return;\n const onPointerDown = (e: PointerEvent) => {\n const el = containerRef.current;\n if (!el) return;\n if (el.contains(e.target as Node)) return;\n dismiss();\n };\n document.addEventListener('pointerdown', onPointerDown);\n return () => document.removeEventListener('pointerdown', onPointerDown);\n }, [dismiss, isActive]);\n\n return (\n <div\n ref={containerRef}\n className=\"border-border shrink-0 border-t\"\n data-test=\"widget-ask-bar\"\n data-write-action\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() => (isActive ? dismiss() : setIsActive(true))}\n aria-expanded={isActive}\n aria-label={\n isActive\n ? `Close ask input for ${context.title}`\n : `Ask about ${context.title}`\n }\n data-test=\"widget-ask-bar-toggle\"\n className=\"group/tag h-auto w-full justify-start gap-2.5 rounded-none px-4 py-2.5 text-left sm:px-5\"\n >\n <AskIcon\n className={cn(\n 'text-muted-foreground h-5 w-5 shrink-0 transition-transform duration-200',\n isActive && 'scale-110',\n )}\n />\n <span className=\"text-muted-foreground group-hover/tag:text-foreground flex-1 text-base font-medium transition-colors\">\n Ask about this\n </span>\n <Icon\n name=\"caret-up\"\n className={cn(\n 'text-muted-foreground group-hover/tag:text-muted-foreground h-3.5 w-3.5 shrink-0 transition-transform duration-200',\n isActive && 'rotate-180',\n )}\n />\n </Button>\n\n {isActive && (\n <div\n className=\"border-border space-y-3 border-t p-3 sm:px-5\"\n data-test=\"widget-ask-bar-input\"\n >\n {suggestions.length > 0 && (\n <div\n className=\"flex flex-wrap gap-2\"\n data-test=\"widget-ask-bar-suggestions\"\n >\n {suggestions.map((s) => (\n <Button\n key={s.label}\n type=\"button\"\n variant=\"outline\"\n size=\"xs\"\n onClick={() => handleSuggestion(s.prompt)}\n className=\"px-3\"\n aria-label={s.label}\n >\n <Icon\n name=\"magic-wand\"\n className=\"text-primary 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"]}
@@ -0,0 +1,35 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { WidgetAskContext } from '../../types/widget-ask-context.js';
3
+ /**
4
+ * Lets the host draw a widget's Ask: the SDK has no assistant mark or name of
5
+ * its own, so the host renders the control and the SDK places it beside the
6
+ * header's ⋯ menu (owner, 2026-11-10). With no provider, `Widget.AskFooter`
7
+ * draws the footer bar instead.
8
+ */
9
+ export interface WidgetAskPresentation {
10
+ render: (context: WidgetAskContext) => ReactNode;
11
+ }
12
+ export declare function WidgetAskPresentationProvider({ value, children, }: {
13
+ value: WidgetAskPresentation | null;
14
+ children: ReactNode;
15
+ }): import("react").JSX.Element;
16
+ export declare function useWidgetAskPresentation(): WidgetAskPresentation | null;
17
+ /**
18
+ * `Widget.AskFooter` sits at the card's foot but a host-drawn Ask draws
19
+ * beside the header's ⋯ menu, so the card carries the ask context between
20
+ * them.
21
+ */
22
+ interface WidgetAskSlot {
23
+ context: WidgetAskContext | null;
24
+ setContext: (context: WidgetAskContext | null) => void;
25
+ }
26
+ export declare function WidgetAskSlotProvider({ children }: {
27
+ children: ReactNode;
28
+ }): import("react").JSX.Element;
29
+ export declare function useWidgetAskSlot(): WidgetAskSlot | null;
30
+ /**
31
+ * Hands the footer's context to the header. The context is rebuilt every
32
+ * render, so it is compared by its JSON (a snapshot is JSON by contract).
33
+ */
34
+ export declare function usePublishAskContext(context: WidgetAskContext | null, enabled: boolean): void;
35
+ export {};
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, use, useEffect, useMemo, useState, } from 'react';
4
+ const WidgetAskPresentationContext = createContext(null);
5
+ export function WidgetAskPresentationProvider({ value, children, }) {
6
+ return (_jsx(WidgetAskPresentationContext, { value: value, children: children }));
7
+ }
8
+ export function useWidgetAskPresentation() {
9
+ return use(WidgetAskPresentationContext);
10
+ }
11
+ const WidgetAskSlotContext = createContext(null);
12
+ export function WidgetAskSlotProvider({ children }) {
13
+ const [context, setContext] = useState(null);
14
+ const value = useMemo(() => ({ context, setContext }), [context]);
15
+ return _jsx(WidgetAskSlotContext, { value: value, children: children });
16
+ }
17
+ export function useWidgetAskSlot() {
18
+ return use(WidgetAskSlotContext);
19
+ }
20
+ /**
21
+ * Hands the footer's context to the header. The context is rebuilt every
22
+ * render, so it is compared by its JSON (a snapshot is JSON by contract).
23
+ */
24
+ export function usePublishAskContext(context, enabled) {
25
+ const slot = useWidgetAskSlot();
26
+ const setContext = slot === null || slot === void 0 ? void 0 : slot.setContext;
27
+ const key = enabled && context ? JSON.stringify(context) : null;
28
+ useEffect(() => {
29
+ if (!setContext)
30
+ return;
31
+ setContext(key ? JSON.parse(key) : null);
32
+ return () => setContext(null);
33
+ }, [key, setContext]);
34
+ }
35
+ //# sourceMappingURL=widget-ask-presentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-ask-presentation.js","sourceRoot":"","sources":["../../../src/components/widgets/widget-ask-presentation.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAEL,aAAa,EACb,GAAG,EACH,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AAcf,MAAM,4BAA4B,GAChC,aAAa,CAA+B,IAAI,CAAC,CAAC;AAEpD,MAAM,UAAU,6BAA6B,CAAC,EAC5C,KAAK,EACL,QAAQ,GAIT;IACC,OAAO,CACL,KAAC,4BAA4B,IAAC,KAAK,EAAE,KAAK,YACvC,QAAQ,GACoB,CAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB;IACtC,OAAO,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAC3C,CAAC;AAYD,MAAM,oBAAoB,GAAG,aAAa,CAAuB,IAAI,CAAC,CAAC;AAEvE,MAAM,UAAU,qBAAqB,CAAC,EAAE,QAAQ,EAA2B;IACzE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAA0B,IAAI,CAAC,CAAC;IACtE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAClE,OAAO,KAAC,oBAAoB,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAwB,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,GAAG,CAAC,oBAAoB,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAgC,EAChC,OAAgB;IAEhB,MAAM,IAAI,GAAG,gBAAgB,EAAE,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC;IACpC,MAAM,GAAG,GAAG,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,UAAU;YAAE,OAAO;QACxB,UAAU,CAAC,GAAG,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC/D,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;AACxB,CAAC","sourcesContent":["'use client';\n\nimport {\n type ReactNode,\n createContext,\n use,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport type { WidgetAskContext } from '../../types/widget-ask-context';\n\n/**\n * Lets the host draw a widget's Ask: the SDK has no assistant mark or name of\n * its own, so the host renders the control and the SDK places it beside the\n * header's ⋯ menu (owner, 2026-11-10). With no provider, `Widget.AskFooter`\n * draws the footer bar instead.\n */\nexport interface WidgetAskPresentation {\n render: (context: WidgetAskContext) => ReactNode;\n}\n\nconst WidgetAskPresentationContext =\n createContext<WidgetAskPresentation | null>(null);\n\nexport function WidgetAskPresentationProvider({\n value,\n children,\n}: {\n value: WidgetAskPresentation | null;\n children: ReactNode;\n}) {\n return (\n <WidgetAskPresentationContext value={value}>\n {children}\n </WidgetAskPresentationContext>\n );\n}\n\nexport function useWidgetAskPresentation() {\n return use(WidgetAskPresentationContext);\n}\n\n/**\n * `Widget.AskFooter` sits at the card's foot but a host-drawn Ask draws\n * beside the header's ⋯ menu, so the card carries the ask context between\n * them.\n */\ninterface WidgetAskSlot {\n context: WidgetAskContext | null;\n setContext: (context: WidgetAskContext | null) => void;\n}\n\nconst WidgetAskSlotContext = createContext<WidgetAskSlot | null>(null);\n\nexport function WidgetAskSlotProvider({ children }: { children: ReactNode }) {\n const [context, setContext] = useState<WidgetAskContext | null>(null);\n const value = useMemo(() => ({ context, setContext }), [context]);\n return <WidgetAskSlotContext value={value}>{children}</WidgetAskSlotContext>;\n}\n\nexport function useWidgetAskSlot() {\n return use(WidgetAskSlotContext);\n}\n\n/**\n * Hands the footer's context to the header. The context is rebuilt every\n * render, so it is compared by its JSON (a snapshot is JSON by contract).\n */\nexport function usePublishAskContext(\n context: WidgetAskContext | null,\n enabled: boolean,\n) {\n const slot = useWidgetAskSlot();\n const setContext = slot?.setContext;\n const key = enabled && context ? JSON.stringify(context) : null;\n useEffect(() => {\n if (!setContext) return;\n setContext(key ? (JSON.parse(key) as WidgetAskContext) : null);\n return () => setContext(null);\n }, [key, setContext]);\n}\n"]}
@@ -21,6 +21,11 @@ export interface WidgetEmptyStateProps {
21
21
  * with no results.
22
22
  */
23
23
  tone?: 'positive' | 'neutral';
24
+ /**
25
+ * A Phosphor icon name, e.g. `tray`. Defaults to the
26
+ * tone's icon: a check for `positive`, a tray for `neutral`.
27
+ */
28
+ icon?: string;
24
29
  title?: ReactNode;
25
30
  description?: ReactNode;
26
31
  action?: WidgetStateAction;
@@ -38,7 +43,7 @@ export interface WidgetInactiveStateProps {
38
43
  * The empty state for a widget with nothing to show. Positive by default:
39
44
  * an empty review queue is good news, so it reassures instead of apologizing.
40
45
  */
41
- export declare function WidgetEmptyState({ tone, title, description, action, }: WidgetEmptyStateProps): import("react").JSX.Element;
46
+ export declare function WidgetEmptyState({ tone, icon, title, description, action, }: WidgetEmptyStateProps): import("react").JSX.Element;
42
47
  /**
43
48
  * Why the widget can't show data. `not-connected` offers one Connect button;
44
49
  * `no-access` is a calm note that points to an admin, never a lock screen;
@@ -25,14 +25,14 @@ function StateNote({ icon, title, description, action, role, testId, }) {
25
25
  * The empty state for a widget with nothing to show. Positive by default:
26
26
  * an empty review queue is good news, so it reassures instead of apologizing.
27
27
  */
28
- export function WidgetEmptyState({ tone = 'positive', title, description, action, }) {
28
+ export function WidgetEmptyState({ tone = 'positive', icon, title, description, action, }) {
29
29
  const positive = tone === 'positive';
30
- 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 ? _jsx(StateAction, { action: action, variant: "outline" }) : null, role: "status", testId: `widget-empty-${tone}` }));
30
+ return (_jsx(StateNote, { icon: icon !== null && icon !== void 0 ? icon : (positive ? 'check-circle' : 'tray'), 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 ? _jsx(StateAction, { action: action, variant: "outline" }) : null, role: "status", testId: `widget-empty-${tone}` }));
31
31
  }
32
32
  const INACTIVE_ICON = {
33
- 'not-connected': 'fa-plug',
34
- 'no-access': 'fa-user-group',
35
- 'setup-needed': 'fa-sliders',
33
+ 'not-connected': 'plug',
34
+ 'no-access': 'users-three',
35
+ 'setup-needed': 'sliders-horizontal',
36
36
  };
37
37
  /**
38
38
  * Why the widget can't show data. `not-connected` offers one Connect button;
@@ -42,7 +42,7 @@ const INACTIVE_ICON = {
42
42
  */
43
43
  export function WidgetInactiveState({ reason, integrationName, title, description, action, } = {}) {
44
44
  if (!reason) {
45
- return (_jsx(StateNote, { icon: "fa-plug", title: title !== null && title !== void 0 ? title : (_jsx(Trans, { i18nKey: "dashboard:widgetInactive", defaults: "Widget inactive" })), testId: "widget-inactive" }));
45
+ return (_jsx(StateNote, { icon: "plug", title: title !== null && title !== void 0 ? title : (_jsx(Trans, { i18nKey: "dashboard:widgetInactive", defaults: "Widget inactive" })), testId: "widget-inactive" }));
46
46
  }
47
47
  const name = integrationName !== null && integrationName !== void 0 ? integrationName : 'this integration';
48
48
  const defaults = {
@@ -70,12 +70,12 @@ export function WidgetLoadingSkeleton({ variant = 'rows', }) {
70
70
  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: "px-card pb-card space-y-2", 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: "px-card pb-card space-y-3", children: [_jsx(Skeleton, { className: "h-8 w-40" }), _jsx(Skeleton, { className: "h-60 w-full" })] })) : (_jsx("div", { className: "divide-y", children: [0, 1, 2].map((row) => (_jsx("div", { className: cn('px-card py-row', 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))) }))] }));
71
71
  }
72
72
  export function WidgetErrorState({ title, description, onRetry, retrying = false, }) {
73
- return (_jsx(StateNote, { role: "alert", icon: "fa-circle-exclamation", title: title !== null && title !== void 0 ? title : (_jsx(Trans, { i18nKey: "dashboard:widgetErrorTitle", defaults: "Couldn't load this widget" })), description: description !== null && description !== void 0 ? 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." }))), action: 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(retrying && 'animate-spin'), "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRetry", defaults: "Try again" })] })) : null, testId: "widget-error" }));
73
+ return (_jsx(StateNote, { role: "alert", icon: "warning-circle", title: title !== null && title !== void 0 ? title : (_jsx(Trans, { i18nKey: "dashboard:widgetErrorTitle", defaults: "Couldn't load this widget" })), description: description !== null && description !== void 0 ? 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." }))), action: onRetry ? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: onRetry, disabled: retrying, "data-test": "widget-error-retry", children: [_jsx(Icon, { name: "arrows-clockwise", className: cn(retrying && 'animate-spin'), "aria-hidden": true }), _jsx(Trans, { i18nKey: "dashboard:widgetRetry", defaults: "Try again" })] })) : null, testId: "widget-error" }));
74
74
  }
75
75
  export function WidgetDataLoading() {
76
76
  return (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Spinner, {}) }));
77
77
  }
78
78
  export function WidgetDisabledState() {
79
- return (_jsx(StateNote, { icon: "fa-ban", title: _jsx(Trans, { i18nKey: "dashboard:widgetDisabled", defaults: "Widget Disabled" }), testId: "widget-disabled" }));
79
+ return (_jsx(StateNote, { icon: "prohibit", title: _jsx(Trans, { i18nKey: "dashboard:widgetDisabled", defaults: "Widget Disabled" }), testId: "widget-disabled" }));
80
80
  }
81
81
  //# 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,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,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,K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nimport { Button } from '@ekanos/ui/button';\nimport { EmptyNote } from '@ekanos/ui/empty-note';\nimport { Icon } from '@ekanos/ui/icon';\nimport { Skeleton } from '@ekanos/ui/skeleton';\nimport { Spinner } from '@ekanos/ui/spinner';\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: the kit's inline empty note (an\n * icon, a title, one sentence and at most one action), inset by the card.\n */\nfunction StateNote({\n icon,\n title,\n description,\n action,\n role,\n testId,\n}: {\n icon: string;\n title: ReactNode;\n description?: ReactNode;\n action?: ReactNode;\n role?: 'alert' | 'status';\n testId: string;\n}) {\n return (\n <div role={role} className=\"px-card pb-card\" data-test={testId}>\n <EmptyNote icon={icon} title={title} action={action}>\n {description}\n </EmptyNote>\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 ? <StateAction action={action} variant=\"outline\" /> : null}\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 <StateNote\n icon=\"fa-plug\"\n title={\n title ?? (\n <Trans\n i18nKey=\"dashboard:widgetInactive\"\n defaults=\"Widget inactive\"\n />\n )\n }\n testId=\"widget-inactive\"\n />\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={\n action ? (\n <StateAction\n action={action}\n variant={reason === 'no-access' ? 'outline' : 'default'}\n />\n ) : null\n }\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=\"px-card pb-card space-y-2\">\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=\"px-card pb-card space-y-3\">\n <Skeleton className=\"h-8 w-40\" />\n <Skeleton className=\"h-60 w-full\" />\n </div>\n ) : (\n <div className=\"divide-y\">\n {[0, 1, 2].map((row) => (\n <div\n key={row}\n className={cn(\n 'px-card py-row',\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 <StateNote\n role=\"alert\"\n icon=\"fa-circle-exclamation\"\n title={\n title ?? (\n <Trans\n i18nKey=\"dashboard:widgetErrorTitle\"\n defaults=\"Couldn't load this widget\"\n />\n )\n }\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 }\n action={\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(retrying && 'animate-spin')}\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRetry\" defaults=\"Try again\" />\n </Button>\n ) : null\n }\n testId=\"widget-error\"\n />\n );\n}\n\nexport function WidgetDataLoading() {\n return (\n <div className=\"flex flex-1 items-center justify-center py-12\">\n <Spinner />\n </div>\n );\n}\n\nexport function WidgetDisabledState() {\n return (\n <StateNote\n icon=\"fa-ban\"\n title={\n <Trans i18nKey=\"dashboard:widgetDisabled\" defaults=\"Widget Disabled\" />\n }\n testId=\"widget-disabled\"\n />\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,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAkDtC,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,C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\nimport Link from 'next/link.js';\n\nimport { Button } from '@ekanos/ui/button';\nimport { EmptyNote } from '@ekanos/ui/empty-note';\nimport { Icon } from '@ekanos/ui/icon';\nimport { Skeleton } from '@ekanos/ui/skeleton';\nimport { Spinner } from '@ekanos/ui/spinner';\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 /**\n * A Phosphor icon name, e.g. `tray`. Defaults to the\n * tone's icon: a check for `positive`, a tray for `neutral`.\n */\n icon?: string;\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: the kit's inline empty note (an\n * icon, a title, one sentence and at most one action), inset by the card.\n */\nfunction StateNote({\n icon,\n title,\n description,\n action,\n role,\n testId,\n}: {\n icon: string;\n title: ReactNode;\n description?: ReactNode;\n action?: ReactNode;\n role?: 'alert' | 'status';\n testId: string;\n}) {\n return (\n <div role={role} className=\"px-card pb-card\" data-test={testId}>\n <EmptyNote icon={icon} title={title} action={action}>\n {description}\n </EmptyNote>\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 icon,\n title,\n description,\n action,\n}: WidgetEmptyStateProps) {\n const positive = tone === 'positive';\n\n return (\n <StateNote\n icon={icon ?? (positive ? 'check-circle' : 'tray')}\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 ? <StateAction action={action} variant=\"outline\" /> : null}\n role=\"status\"\n testId={`widget-empty-${tone}`}\n />\n );\n}\n\nconst INACTIVE_ICON: Record<WidgetInactiveReason, string> = {\n 'not-connected': 'plug',\n 'no-access': 'users-three',\n 'setup-needed': 'sliders-horizontal',\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 <StateNote\n icon=\"plug\"\n title={\n title ?? (\n <Trans\n i18nKey=\"dashboard:widgetInactive\"\n defaults=\"Widget inactive\"\n />\n )\n }\n testId=\"widget-inactive\"\n />\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={\n action ? (\n <StateAction\n action={action}\n variant={reason === 'no-access' ? 'outline' : 'default'}\n />\n ) : null\n }\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=\"px-card pb-card space-y-2\">\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=\"px-card pb-card space-y-3\">\n <Skeleton className=\"h-8 w-40\" />\n <Skeleton className=\"h-60 w-full\" />\n </div>\n ) : (\n <div className=\"divide-y\">\n {[0, 1, 2].map((row) => (\n <div\n key={row}\n className={cn(\n 'px-card py-row',\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 <StateNote\n role=\"alert\"\n icon=\"warning-circle\"\n title={\n title ?? (\n <Trans\n i18nKey=\"dashboard:widgetErrorTitle\"\n defaults=\"Couldn't load this widget\"\n />\n )\n }\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 }\n action={\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=\"arrows-clockwise\"\n className={cn(retrying && 'animate-spin')}\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRetry\" defaults=\"Try again\" />\n </Button>\n ) : null\n }\n testId=\"widget-error\"\n />\n );\n}\n\nexport function WidgetDataLoading() {\n return (\n <div className=\"flex flex-1 items-center justify-center py-12\">\n <Spinner />\n </div>\n );\n}\n\nexport function WidgetDisabledState() {\n return (\n <StateNote\n icon=\"prohibit\"\n title={\n <Trans i18nKey=\"dashboard:widgetDisabled\" defaults=\"Widget Disabled\" />\n }\n testId=\"widget-disabled\"\n />\n );\n}\n"]}
@@ -71,7 +71,7 @@ declare function WidgetHeader({ title, subtitle, description, context, trailing,
71
71
  * when `external`; otherwise it runs `onSelect`.
72
72
  */
73
73
  declare function WidgetMenuItem({ icon, href, external, onSelect, disabled, children, }: {
74
- /** A Font Awesome class, e.g. `fa-envelope`. */
74
+ /** A Phosphor icon name, e.g. `envelope`. */
75
75
  icon?: string;
76
76
  href?: string;
77
77
  external?: boolean;
@@ -85,7 +85,7 @@ declare function WidgetMenuItem({ icon, href, external, onSelect, disabled, chil
85
85
  * through `Widget.Header`'s `menu` prop.
86
86
  */
87
87
  declare function WidgetMenuChoice<Value extends string>({ icon, label, value, options, onChange, }: {
88
- /** A Font Awesome class, e.g. `fa-scale-balanced`. */
88
+ /** A Phosphor icon name, e.g. `scales`. */
89
89
  icon?: string;
90
90
  label: ReactNode;
91
91
  value: Value;