@ekanos/sdk 0.23.0 → 0.25.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 (42) hide show
  1. package/README.md +15 -13
  2. package/api-report.md +10 -3
  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 +2 -2
  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/widgets/ai-prompt-chip.js +2 -2
  13. package/dist/components/widgets/ai-prompt-chip.js.map +1 -1
  14. package/dist/components/widgets/widget-ask-bar.js +1 -1
  15. package/dist/components/widgets/widget-ask-bar.js.map +1 -1
  16. package/dist/components/widgets/widget-query-state.d.ts +57 -0
  17. package/dist/components/widgets/widget-query-state.js +44 -0
  18. package/dist/components/widgets/widget-query-state.js.map +1 -0
  19. package/dist/components/widgets/widget-state-components.js +13 -11
  20. package/dist/components/widgets/widget-state-components.js.map +1 -1
  21. package/dist/components/widgets/widget.d.ts +26 -31
  22. package/dist/components/widgets/widget.js +57 -57
  23. package/dist/components/widgets/widget.js.map +1 -1
  24. package/dist/experience/client.d.ts +7 -5
  25. package/dist/experience/client.js +7 -5
  26. package/dist/experience/client.js.map +1 -1
  27. package/dist/experience/define-experience.d.ts +13 -1
  28. package/dist/experience/define-experience.js +13 -1
  29. package/dist/experience/define-experience.js.map +1 -1
  30. package/dist/experience/runtime.d.ts +15 -8
  31. package/dist/experience/runtime.js.map +1 -1
  32. package/dist/experience/server.d.ts +3 -2
  33. package/dist/experience/server.js +3 -2
  34. package/dist/experience/server.js.map +1 -1
  35. package/dist/hooks/use-oauth-connection-status.js +3 -1
  36. package/dist/hooks/use-oauth-connection-status.js.map +1 -1
  37. package/dist/integration/index.d.ts +1 -1
  38. package/dist/integration/index.js.map +1 -1
  39. package/dist/integration/types.d.ts +1 -1
  40. package/dist/integration/types.js.map +1 -1
  41. package/eslint.design-rules.mjs +35 -160
  42. package/package.json +7 -7
@@ -0,0 +1,44 @@
1
+ /**
2
+ * How a widget's own read becomes its `Widget.DataState` status.
3
+ *
4
+ * Every data widget used to write this as a ternary over `isLoading` /
5
+ * `isError`, and every copy had the same bug: TanStack Query reports
6
+ * `isError` after a failed BACKGROUND refetch too, while the last good rows
7
+ * are still in `data`, so a card the member was reading flipped to its error
8
+ * view. A failed refresh with rows still on screen is not degraded: only a
9
+ * read that never produced rows is. The card keeps its rows and its
10
+ * "Updated …" footer says how old they are.
11
+ *
12
+ * No React here, so the rule is testable with plain objects.
13
+ */
14
+ /**
15
+ * The status, in the order a widget means it: not connected, then still
16
+ * loading, then a read that failed with nothing on screen, then ready.
17
+ */
18
+ export function widgetQueryStatus(query, connection) {
19
+ if (connection === null || connection === void 0 ? void 0 : connection.notConnected)
20
+ return 'inactive';
21
+ if (connection === null || connection === void 0 ? void 0 : connection.connectionPending)
22
+ return 'loading';
23
+ if (connection === null || connection === void 0 ? void 0 : connection.connectionError)
24
+ return 'error';
25
+ const loading = connection
26
+ ? connection.dataEnabled && query.isPending
27
+ : query.isLoading;
28
+ if (loading)
29
+ return 'loading';
30
+ const hasData = query.data !== undefined;
31
+ if (query.isError && !hasData)
32
+ return 'error';
33
+ return 'ready';
34
+ }
35
+ /** Everything `Widget.DataState` takes from one query. */
36
+ export function widgetQueryState(query, connection) {
37
+ return {
38
+ status: widgetQueryStatus(query, connection),
39
+ onRefresh: () => void query.refetch(),
40
+ refreshing: query.isFetching,
41
+ updatedAt: query.dataUpdatedAt,
42
+ };
43
+ }
44
+ //# sourceMappingURL=widget-query-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-query-state.js","sourceRoot":"","sources":["../../../src/components/widgets/widget-query-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA2CH;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAwE,EACxE,UAAiC;IAEjC,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,YAAY;QAAE,OAAO,UAAU,CAAC;IAChD,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB;QAAE,OAAO,SAAS,CAAC;IACpD,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,eAAe;QAAE,OAAO,OAAO,CAAC;IAEhD,MAAM,OAAO,GAAG,UAAU;QACxB,CAAC,CAAC,UAAU,CAAC,WAAW,IAAI,KAAK,CAAC,SAAS;QAC3C,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IACpB,IAAI,OAAO;QAAE,OAAO,SAAS,CAAC;IAE9B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;IACzC,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,gBAAgB,CAC9B,KAAkB,EAClB,UAAiC;IAEjC,OAAO;QACL,MAAM,EAAE,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC;QAC5C,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE;QACrC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,SAAS,EAAE,KAAK,CAAC,aAAa;KAC/B,CAAC;AACJ,CAAC","sourcesContent":["/**\n * How a widget's own read becomes its `Widget.DataState` status.\n *\n * Every data widget used to write this as a ternary over `isLoading` /\n * `isError`, and every copy had the same bug: TanStack Query reports\n * `isError` after a failed BACKGROUND refetch too, while the last good rows\n * are still in `data`, so a card the member was reading flipped to its error\n * view. A failed refresh with rows still on screen is not degraded: only a\n * read that never produced rows is. The card keeps its rows and its\n * \"Updated …\" footer says how old they are.\n *\n * No React here, so the rule is testable with plain objects.\n */\n\nimport type { WidgetDataStatus } from './widget';\n\n/**\n * The part of a TanStack Query result a widget's data state reads. A\n * `useQuery` result satisfies it as is.\n */\nexport interface WidgetQuery {\n data: unknown;\n /** No data yet (the query may not be fetching: see `isLoading`). */\n isPending: boolean;\n /** First load in flight: pending AND fetching. */\n isLoading: boolean;\n isError: boolean;\n isFetching: boolean;\n /** Epoch ms of the last success; `0` before the first. */\n dataUpdatedAt: number;\n refetch: () => unknown;\n}\n\n/**\n * The upstream connection a connector widget waits on before it reads,\n * as `useOAuthWidgetGate` returns it.\n */\nexport interface WidgetConnectionGate {\n /** The connection check answered: no token. */\n notConnected: boolean;\n /** The connection check has not answered yet. */\n connectionPending: boolean;\n /** The connection check failed with nothing to fall back on. */\n connectionError: boolean;\n /** Connected: the widget's own read is enabled. */\n dataEnabled: boolean;\n}\n\nexport interface WidgetQueryState {\n status: WidgetDataStatus;\n onRefresh: () => void;\n refreshing: boolean;\n updatedAt: number;\n}\n\n/**\n * The status, in the order a widget means it: not connected, then still\n * loading, then a read that failed with nothing on screen, then ready.\n */\nexport function widgetQueryStatus(\n query: Pick<WidgetQuery, 'data' | 'isPending' | 'isLoading' | 'isError'>,\n connection?: WidgetConnectionGate,\n): WidgetDataStatus {\n if (connection?.notConnected) return 'inactive';\n if (connection?.connectionPending) return 'loading';\n if (connection?.connectionError) return 'error';\n\n const loading = connection\n ? connection.dataEnabled && query.isPending\n : query.isLoading;\n if (loading) return 'loading';\n\n const hasData = query.data !== undefined;\n if (query.isError && !hasData) return 'error';\n return 'ready';\n}\n\n/** Everything `Widget.DataState` takes from one query. */\nexport function widgetQueryState(\n query: WidgetQuery,\n connection?: WidgetConnectionGate,\n): WidgetQueryState {\n return {\n status: widgetQueryStatus(query, connection),\n onRefresh: () => void query.refetch(),\n refreshing: query.isFetching,\n updatedAt: query.dataUpdatedAt,\n };\n}\n"]}
@@ -1,8 +1,10 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Link from 'next/link.js';
3
3
  import { Button } from '@ekanos/ui/button';
4
+ import { EmptyNote } from '@ekanos/ui/empty-note';
4
5
  import { Icon } from '@ekanos/ui/icon';
5
6
  import { Skeleton } from '@ekanos/ui/skeleton';
7
+ import { Spinner } from '@ekanos/ui/spinner';
6
8
  import { Trans } from '@ekanos/ui/trans';
7
9
  import { cn } from '@ekanos/ui/utils';
8
10
  function StateAction({ action, variant = 'default', }) {
@@ -13,11 +15,11 @@ function StateAction({ action, variant = 'default', }) {
13
15
  return (_jsx(Button, { size: "sm", variant: variant, type: "button", onClick: action.onClick, children: action.label }));
14
16
  }
15
17
  /**
16
- * The shared shape of every non-data state: an icon, a title, one sentence
17
- * and at most one action, left-aligned in the body's padding.
18
+ * The shared shape of every non-data state: the kit's inline empty note (an
19
+ * icon, a title, one sentence and at most one action), inset by the card.
18
20
  */
19
- function StateNote({ icon, title, description, action, actionVariant, role, testId, }) {
20
- return (_jsxs("div", { role: role, className: "flex flex-1 flex-col items-start gap-3 px-5 pt-2 pb-5", "data-test": testId, children: [_jsx(Icon, { name: icon, className: "text-muted-foreground h-6 w-6", "aria-hidden": true }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-foreground text-body font-medium", children: title }), description ? (_jsx("p", { className: "text-muted-foreground text-meta max-w-prose", children: description })) : null] }), action ? _jsx(StateAction, { action: action, variant: actionVariant }) : null] }));
21
+ function StateNote({ icon, title, description, action, role, testId, }) {
22
+ return (_jsx("div", { role: role, className: "px-card pb-card", "data-test": testId, children: _jsx(EmptyNote, { icon: icon, title: title, action: action, children: description }) }));
21
23
  }
22
24
  /**
23
25
  * The empty state for a widget with nothing to show. Positive by default:
@@ -25,7 +27,7 @@ function StateNote({ icon, title, description, action, actionVariant, role, test
25
27
  */
26
28
  export function WidgetEmptyState({ tone = 'positive', title, description, action, }) {
27
29
  const positive = tone === 'positive';
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}` }));
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}` }));
29
31
  }
30
32
  const INACTIVE_ICON = {
31
33
  'not-connected': 'fa-plug',
@@ -40,7 +42,7 @@ const INACTIVE_ICON = {
40
42
  */
41
43
  export function WidgetInactiveState({ reason, integrationName, title, description, action, } = {}) {
42
44
  if (!reason) {
43
- return (_jsx("div", { className: "flex flex-col items-center justify-center py-8 text-center", children: _jsx("p", { className: "text-muted-foreground text-meta", children: title !== null && title !== void 0 ? title : (_jsx(Trans, { i18nKey: "dashboard:widgetInactive", defaults: "Widget inactive" })) }) }));
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" }));
44
46
  }
45
47
  const name = integrationName !== null && integrationName !== void 0 ? integrationName : 'this integration';
46
48
  const defaults = {
@@ -57,7 +59,7 @@ export function WidgetInactiveState({ reason, integrationName, title, descriptio
57
59
  description: (_jsx(Trans, { i18nKey: "dashboard:widgetSetupNeededBody", defaults: "One more step and this card starts showing data." })),
58
60
  },
59
61
  };
60
- return (_jsx(StateNote, { icon: INACTIVE_ICON[reason], title: title !== null && title !== void 0 ? title : defaults[reason].title, description: description !== null && description !== void 0 ? description : defaults[reason].description, action: action, actionVariant: reason === 'no-access' ? 'outline' : 'default', testId: `widget-inactive-${reason}` }));
62
+ return (_jsx(StateNote, { icon: INACTIVE_ICON[reason], title: title !== null && title !== void 0 ? title : defaults[reason].title, description: description !== null && description !== void 0 ? description : defaults[reason].description, action: action ? (_jsx(StateAction, { action: action, variant: reason === 'no-access' ? 'outline' : 'default' })) : null, testId: `widget-inactive-${reason}` }));
61
63
  }
62
64
  /**
63
65
  * Loading, drawn as the body it stands in for so the card doesn't jump when
@@ -65,15 +67,15 @@ export function WidgetInactiveState({ reason, integrationName, title, descriptio
65
67
  * chart, `schedule` a day of events.
66
68
  */
67
69
  export function WidgetLoadingSkeleton({ variant = 'rows', }) {
68
- return (_jsxs("div", { role: "status", "aria-busy": "true", className: "flex flex-1 flex-col", "data-test": `widget-skeleton-${variant}`, children: [_jsx("span", { className: "sr-only", children: _jsx(Trans, { i18nKey: "dashboard:widgetLoading", defaults: "Loading..." }) }), variant === 'stat' ? (_jsxs("div", { className: "space-y-2 px-5 pt-2 pb-5", children: [_jsx(Skeleton, { className: "h-3 w-24" }), _jsx(Skeleton, { className: "h-8 w-40" }), _jsx(Skeleton, { className: "h-3 w-32" })] })) : variant === 'chart' ? (_jsxs("div", { className: "space-y-3 px-5 pt-2 pb-5", children: [_jsx(Skeleton, { className: "h-8 w-40" }), _jsx(Skeleton, { className: "h-60 w-full" })] })) : (_jsx("div", { className: "divide-border 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))) }))] }));
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))) }))] }));
69
71
  }
70
72
  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-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] }));
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" }));
72
74
  }
73
75
  export function WidgetDataLoading() {
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" }) }));
76
+ return (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Spinner, {}) }));
75
77
  }
76
78
  export function WidgetDisabledState() {
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" }) })] }));
79
+ return (_jsx(StateNote, { icon: "fa-ban", title: _jsx(Trans, { i18nKey: "dashboard:widgetDisabled", defaults: "Widget Disabled" }), testId: "widget-disabled" }));
78
80
  }
79
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,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,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IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,oCAAoC,GAAG,EACrE,YAAG,SAAS,EAAC,iCAAiC,YAC5C,KAAC,KAAK,IAAC,OAAO,EAAC,0BAA0B,EAAC,QAAQ,EAAC,iBAAiB,GAAG,GACrE,IACA,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from 'react';\n\nimport Link from 'next/link.js';\n\nimport { Button } from '@ekanos/ui/button';\nimport { Icon } from '@ekanos/ui/icon';\nimport { Skeleton } from '@ekanos/ui/skeleton';\nimport { Trans } from '@ekanos/ui/trans';\nimport { cn } from '@ekanos/ui/utils';\n\n/**\n * The one action a state view offers: \"Connect QuickBooks\", \"Ask an admin\",\n * \"Create a deal\". A link with `href`, otherwise a button running `onClick`.\n */\nexport interface WidgetStateAction {\n label: ReactNode;\n href?: string;\n /** Open `href` in a new tab. */\n external?: boolean;\n onClick?: () => void;\n}\n\n/** The body shape a loading skeleton stands in for. */\nexport type WidgetSkeletonVariant = 'rows' | 'stat' | 'chart' | 'schedule';\n\n/** Why an active integration still can't show this widget's data. */\nexport type WidgetInactiveReason =\n | 'not-connected'\n | 'no-access'\n | 'setup-needed';\n\nexport interface WidgetEmptyStateProps {\n /**\n * `positive` (the default) says nothing needs the owner: \"You're all caught\n * up\". `neutral` is for an empty list that isn't good news, like a search\n * with no results.\n */\n tone?: 'positive' | 'neutral';\n title?: ReactNode;\n description?: ReactNode;\n action?: WidgetStateAction;\n}\n\nexport interface WidgetInactiveStateProps {\n reason?: WidgetInactiveReason;\n /** The integration's name, for the default copy (\"Connect QuickBooks\"). */\n integrationName?: string;\n title?: ReactNode;\n /** One sentence on what connecting or access gives the owner. */\n description?: ReactNode;\n action?: WidgetStateAction;\n}\n\nfunction StateAction({\n action,\n variant = 'default',\n}: {\n action: WidgetStateAction;\n variant?: 'default' | 'outline';\n}) {\n if (action.href) {\n const link = action.external ? (\n <a href={action.href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={action.href} />\n );\n\n return (\n <Button size=\"sm\" variant={variant} render={link} nativeButton={false}>\n {action.label}\n </Button>\n );\n }\n\n return (\n <Button size=\"sm\" variant={variant} type=\"button\" onClick={action.onClick}>\n {action.label}\n </Button>\n );\n}\n\n/**\n * The shared shape of every non-data state: an icon, a title, one sentence\n * and at most one action, left-aligned in the body's padding.\n */\nfunction StateNote({\n icon,\n title,\n description,\n action,\n actionVariant,\n role,\n testId,\n}: {\n icon: string;\n title: ReactNode;\n description?: ReactNode;\n action?: WidgetStateAction;\n actionVariant?: 'default' | 'outline';\n role?: 'alert' | 'status';\n testId: string;\n}) {\n return (\n <div\n role={role}\n className=\"flex flex-1 flex-col items-start gap-3 px-5 pt-2 pb-5\"\n data-test={testId}\n >\n <Icon name={icon} className=\"text-muted-foreground h-6 w-6\" aria-hidden />\n <div className=\"space-y-1\">\n <p className=\"text-foreground text-body font-medium\">{title}</p>\n {description ? (\n <p className=\"text-muted-foreground text-meta max-w-prose\">\n {description}\n </p>\n ) : null}\n </div>\n {action ? <StateAction action={action} variant={actionVariant} /> : null}\n </div>\n );\n}\n\n/**\n * The empty state for a widget with nothing to show. Positive by default:\n * an empty review queue is good news, so it reassures instead of apologizing.\n */\nexport function WidgetEmptyState({\n tone = 'positive',\n title,\n description,\n action,\n}: WidgetEmptyStateProps) {\n const positive = tone === 'positive';\n\n return (\n <StateNote\n icon={positive ? 'fa-circle-check' : 'fa-inbox'}\n title={\n title ??\n (positive ? (\n <Trans\n i18nKey=\"dashboard:widgetEmptyPositive\"\n defaults=\"You're all caught up\"\n />\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetEmptyNeutral\"\n defaults=\"Nothing here yet\"\n />\n ))\n }\n description={description}\n action={action}\n actionVariant=\"outline\"\n role=\"status\"\n testId={`widget-empty-${tone}`}\n />\n );\n}\n\nconst INACTIVE_ICON: Record<WidgetInactiveReason, string> = {\n 'not-connected': 'fa-plug',\n 'no-access': 'fa-user-group',\n 'setup-needed': 'fa-sliders',\n};\n\n/**\n * Why the widget can't show data. `not-connected` offers one Connect button;\n * `no-access` is a calm note that points to an admin, never a lock screen;\n * `setup-needed` points to the integration's settings. Without a `reason` it\n * keeps the original one-line \"Widget inactive\".\n */\nexport function WidgetInactiveState({\n reason,\n integrationName,\n title,\n description,\n action,\n}: WidgetInactiveStateProps = {}) {\n if (!reason) {\n return (\n <div className=\"flex flex-col items-center justify-center py-8 text-center\">\n <p className=\"text-muted-foreground text-meta\">\n {title ?? (\n <Trans\n i18nKey=\"dashboard:widgetInactive\"\n defaults=\"Widget inactive\"\n />\n )}\n </p>\n </div>\n );\n }\n\n const name = integrationName ?? 'this integration';\n\n const defaults: Record<\n WidgetInactiveReason,\n { title: ReactNode; description: ReactNode }\n > = {\n 'not-connected': {\n title: (\n <Trans\n i18nKey=\"dashboard:widgetNotConnectedTitle\"\n defaults=\"Connect {{name}}\"\n values={{ name }}\n />\n ),\n description: (\n <Trans\n i18nKey=\"dashboard:widgetNotConnectedBody\"\n defaults=\"Connect {{name}} and this card fills in with your own data.\"\n values={{ name }}\n />\n ),\n },\n 'no-access': {\n title: (\n <Trans\n i18nKey=\"dashboard:widgetNoAccessTitle\"\n defaults=\"Shared with admins for now\"\n />\n ),\n description: (\n <Trans\n i18nKey=\"dashboard:widgetNoAccessBody\"\n defaults=\"Your role doesn't include this data yet. Ask an admin if you need it.\"\n />\n ),\n },\n 'setup-needed': {\n title: (\n <Trans\n i18nKey=\"dashboard:widgetSetupNeededTitle\"\n defaults=\"Finish setting up {{name}}\"\n values={{ name }}\n />\n ),\n description: (\n <Trans\n i18nKey=\"dashboard:widgetSetupNeededBody\"\n defaults=\"One more step and this card starts showing data.\"\n />\n ),\n },\n };\n\n return (\n <StateNote\n icon={INACTIVE_ICON[reason]}\n title={title ?? defaults[reason].title}\n description={description ?? defaults[reason].description}\n action={action}\n actionVariant={reason === 'no-access' ? 'outline' : 'default'}\n testId={`widget-inactive-${reason}`}\n />\n );\n}\n\n/**\n * Loading, drawn as the body it stands in for so the card doesn't jump when\n * data lands. Rows suit lists and feeds, `stat` a headline figure, `chart` a\n * chart, `schedule` a day of events.\n */\nexport function WidgetLoadingSkeleton({\n variant = 'rows',\n}: {\n variant?: WidgetSkeletonVariant;\n}) {\n return (\n <div\n role=\"status\"\n aria-busy=\"true\"\n className=\"flex flex-1 flex-col\"\n data-test={`widget-skeleton-${variant}`}\n >\n <span className=\"sr-only\">\n <Trans i18nKey=\"dashboard:widgetLoading\" defaults=\"Loading...\" />\n </span>\n {variant === 'stat' ? (\n <div className=\"space-y-2 px-5 pt-2 pb-5\">\n <Skeleton className=\"h-3 w-24\" />\n <Skeleton className=\"h-8 w-40\" />\n <Skeleton className=\"h-3 w-32\" />\n </div>\n ) : variant === 'chart' ? (\n <div className=\"space-y-3 px-5 pt-2 pb-5\">\n <Skeleton className=\"h-8 w-40\" />\n <Skeleton className=\"h-60 w-full\" />\n </div>\n ) : (\n <div className=\"divide-border divide-y\">\n {[0, 1, 2].map((row) => (\n <div\n key={row}\n className={cn(\n 'px-5 py-3',\n variant === 'schedule' ? 'flex items-start gap-3' : 'space-y-2',\n )}\n >\n {variant === 'schedule' ? (\n <>\n <Skeleton className=\"h-4 w-14 shrink-0\" />\n <div className=\"flex-1 space-y-2\">\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-3 w-1/3\" />\n </div>\n </>\n ) : (\n <>\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-3 w-1/2\" />\n </>\n )}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n\nexport function WidgetErrorState({\n title,\n description,\n onRetry,\n retrying = false,\n}: {\n title?: ReactNode;\n description?: ReactNode;\n onRetry?: () => void;\n retrying?: boolean;\n}) {\n return (\n <div\n role=\"alert\"\n className=\"flex flex-col items-center justify-center gap-3 px-5 py-8 text-center\"\n >\n <div className=\"bg-destructive/10 flex h-10 w-10 items-center justify-center rounded-full\">\n <Icon\n name=\"fa-circle-exclamation\"\n className=\"text-destructive h-5 w-5\"\n aria-hidden\n />\n </div>\n <div className=\"space-y-1\">\n <p className=\"text-foreground text-label\">\n {title ?? (\n <Trans\n i18nKey=\"dashboard:widgetErrorTitle\"\n defaults=\"Couldn't load this widget\"\n />\n )}\n </p>\n <p className=\"text-muted-foreground text-meta\">\n {description ? (\n description\n ) : onRetry ? (\n <Trans\n i18nKey=\"dashboard:widgetErrorBodyRetry\"\n defaults=\"Try again, or check back in a few minutes.\"\n />\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetErrorBody\"\n defaults=\"Check back in a few minutes.\"\n />\n )}\n </p>\n </div>\n {onRetry ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={onRetry}\n disabled={retrying}\n data-test=\"widget-error-retry\"\n >\n <Icon\n name=\"fa-arrows-rotate\"\n className={cn('h-4 w-4', retrying && 'animate-spin')}\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRetry\" defaults=\"Try again\" />\n </Button>\n ) : null}\n </div>\n );\n}\n\nexport function WidgetDataLoading() {\n return (\n <div className=\"flex flex-1 items-center justify-center py-12\">\n <Icon\n name=\"fa-spinner-third\"\n className=\"text-muted-foreground h-8 w-8 animate-spin\"\n />\n </div>\n );\n}\n\nexport function WidgetDisabledState() {\n return (\n <div className=\"flex flex-col items-center justify-center py-8 text-center\">\n <Icon name=\"fa-ban\" className=\"text-muted-foreground mb-4 h-8 w-8\" />\n <p className=\"text-muted-foreground text-meta\">\n <Trans i18nKey=\"dashboard:widgetDisabled\" defaults=\"Widget Disabled\" />\n </p>\n </div>\n );\n}\n"]}
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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AE,OAAO,EAChB,QAAQ,EAAE,QAAQ,eACR,oBAAoB,aAE9B,KAAC,IAAI,IACH,IAAI,EAAC,kBAAkB,EACvB,SAAS,EAAE,EAAE,CAAC,QAAQ,IAAI,cAAc,CAAC,wBAEzC,EACF,KAAC,KAAK,IAAC,OAAO,EAAC,uBAAuB,EAAC,QAAQ,EAAC,WAAW,GAAG,IACvD,CACV,CAAC,CAAC,CAAC,IAAI,EAEV,MAAM,EAAC,cAAc,GACrB,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,CACL,cAAK,SAAS,EAAC,+CAA+C,YAC5D,KAAC,OAAO,KAAG,GACP,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,CACL,KAAC,SAAS,IACR,IAAI,EAAC,QAAQ,EACb,KAAK,EACH,KAAC,KAAK,IAAC,OAAO,EAAC,0BAA0B,EAAC,QAAQ,EAAC,iBAAiB,GAAG,EAEzE,MAAM,EAAC,iBAAiB,GACxB,CACH,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from 'react';\n\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 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,6 +1,7 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import type { WidgetAskContext } from '../../types/widget-ask-context.js';
3
3
  import type { WidgetVerdict } from '../../types/widget-verdict.js';
4
+ import { type WidgetConnectionGate, type WidgetQuery } from './widget-query-state.js';
4
5
  import { type WidgetEmptyStateProps, type WidgetInactiveStateProps, type WidgetSkeletonVariant } from './widget-state-components.js';
5
6
  /**
6
7
  * The verdict the widget reported through `Widget.DataState`, for a body that
@@ -97,13 +98,13 @@ declare function WidgetMenuChoice<Value extends string>({ icon, label, value, op
97
98
  /**
98
99
  * The standard padded body for content rendered inside `Widget.Active`.
99
100
  *
100
- * `Widget.Active`'s own `CardContent` renders `p-0` — deliberately, so a
101
+ * `Widget.Active`'s body has no padding — deliberately, so a
101
102
  * full-bleed chart or table can run edge-to-edge inside the card. That means
102
103
  * ordinary content (text, rows, a KPI readout) is left flush against the
103
- * card's sides while `Widget.Header` stays inset (`px-5`) unless the body
104
- * supplies its own padding. `Widget.Body` is that padding: `px-5` matches
105
- * the header's horizontal inset so header and body align, `pt-4 pb-5`
106
- * balances the header's `pb-3`/card's bottom edge.
104
+ * card's sides while `Widget.Header` stays inset (`px-card`) unless the body
105
+ * supplies its own padding. `Widget.Body` is that padding: `px-card` matches
106
+ * the header's horizontal inset so header and body align, and `pb-card`
107
+ * matches the header's top.
107
108
  *
108
109
  * Every widget wraps its content in it:
109
110
  *
@@ -119,15 +120,15 @@ declare function WidgetMenuChoice<Value extends string>({ icon, label, value, op
119
120
  declare function WidgetBody({ flush, className, children, }: {
120
121
  /**
121
122
  * Drop the padding for content that runs to the card's edges: edge-to-edge
122
- * rows (which pad themselves, `px-5 py-3`), a full-bleed chart, an image.
123
+ * rows (which pad themselves, `px-card py-row`), a full-bleed chart, an image.
123
124
  */
124
125
  flush?: boolean;
125
126
  className?: string;
126
127
  children: ReactNode;
127
128
  }): import("react").JSX.Element;
128
129
  /**
129
- * Renders `children` once the widget's state is `active`. Its `CardContent`
130
- * is flush (`p-0`); wrap content in `Widget.Body`, which pads it to line up
130
+ * Renders `children` once the widget's state is `active`. Its body
131
+ * is flush; wrap content in `Widget.Body`, which pads it to line up
131
132
  * with the header, or `Widget.Body flush` for edge-to-edge rows and charts.
132
133
  * Never hand-roll a `px-*` wrapper.
133
134
  */
@@ -194,39 +195,33 @@ export type WidgetDataStatus = 'ready' | 'loading' | 'error' | 'inactive';
194
195
  * parent state is `active` — so the integration's `inactive` / `disabled` /
195
196
  * `loading` (initial) states still win.
196
197
  *
197
- * Read the parent integration state BEFORE wrapping in this component if you
198
- * need it to gate data fetching:
198
+ * Pass the widget's own query as `query` and the component works out the
199
+ * status, the shared Refresh menu item, the Try again button on its error
200
+ * view and the "Updated 3 minutes ago" footer. A connector widget that waits
201
+ * on an upstream OAuth connection also passes `connection`, the
202
+ * `useOAuthWidgetGate` result:
199
203
  *
200
204
  * ```tsx
201
205
  * const { state } = use(WidgetContext);
202
- * const integrationActive = state.state === 'active';
203
- * const { isLoading, isError } = useMyData(accountId, integrationActive);
206
+ * const gate = useOAuthWidgetGate(accountId, state.state === 'active', opts);
207
+ * const query = useMyData(accountId, gate.dataEnabled);
204
208
  * return (
205
- * <Widget.DataState
206
- * status={isLoading ? 'loading' : isError ? 'error' : 'ready'}
207
- * >
209
+ * <Widget.DataState query={query} connection={gate}>
208
210
  * <Widget.Card>…</Widget.Card>
209
211
  * </Widget.DataState>
210
212
  * );
211
213
  * ```
212
214
  *
213
- * `status` is one value because the states are exclusive: the ternary is
214
- * where a widget says which one wins when two are true.
215
- *
216
- * Pass `onRefresh`, `refreshing` and `updatedAt` to give the widget the
217
- * shared Refresh menu item, a Try again button on its error view, and an
218
- * "Updated 3 minutes ago" footer. With TanStack Query:
219
- *
220
- * ```tsx
221
- * <Widget.DataState
222
- * status={query.isLoading ? 'loading' : query.isError ? 'error' : 'ready'}
223
- * onRefresh={() => void query.refetch()}
224
- * refreshing={query.isFetching}
225
- * updatedAt={query.dataUpdatedAt}
226
- * >
227
- * ```
215
+ * A failed background refresh keeps the card on its rows (`ready`); only a
216
+ * read that failed with nothing on screen shows the error view. The rule is
217
+ * `widgetQueryStatus`. `status`, `onRefresh`, `refreshing` and `updatedAt`
218
+ * still take explicit values and win over what `query` gives.
228
219
  */
229
- declare function WidgetDataState({ status, loading, error, inactive, onRefresh, refreshing, updatedAt, verdict, children, }: {
220
+ declare function WidgetDataState({ query, connection, status: statusProp, loading, error, inactive, onRefresh: onRefreshProp, refreshing: refreshingProp, updatedAt: updatedAtProp, verdict, children, }: {
221
+ /** The widget's own read; a TanStack Query result fits. */
222
+ query?: WidgetQuery;
223
+ /** The upstream connection the read waits on (`useOAuthWidgetGate`). */
224
+ connection?: WidgetConnectionGate;
230
225
  /**
231
226
  * The widget's own data state. `inactive` is a widget-level "not connected"
232
227
  * state while the integration itself is active (the product is activated