@alepha/ui 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -1
- package/dist/account/AccountBrand.d.ts +10 -3
- package/dist/account/AccountBrand.d.ts.map +1 -1
- package/dist/account/AccountBrand.js +12 -6
- package/dist/account/AccountBrand.js.map +1 -1
- package/dist/account/AccountLayout.d.ts.map +1 -1
- package/dist/account/AccountLayout.js +1 -1
- package/dist/account/AccountLayout.js.map +1 -1
- package/dist/admin/AdminUserDetail.d.ts +3 -3
- package/dist/admin/AdminUserDetail.js +3 -3
- package/dist/admin/AdminUserDetail.js.map +1 -1
- package/dist/ai/AiChat.d.ts +36 -6
- package/dist/ai/AiChat.d.ts.map +1 -1
- package/dist/ai/AiChat.js +101 -63
- package/dist/ai/AiChat.js.map +1 -1
- package/dist/ai/AiChatComposer.d.ts +22 -0
- package/dist/ai/AiChatComposer.d.ts.map +1 -0
- package/dist/ai/AiChatComposer.js +75 -0
- package/dist/ai/AiChatComposer.js.map +1 -0
- package/dist/ai/AiChatConfirmCard.d.ts +5 -2
- package/dist/ai/AiChatConfirmCard.d.ts.map +1 -1
- package/dist/ai/AiChatConfirmCard.js +7 -6
- package/dist/ai/AiChatConfirmCard.js.map +1 -1
- package/dist/ai/AiChatConfirmFields.d.ts +9 -0
- package/dist/ai/AiChatConfirmFields.d.ts.map +1 -0
- package/dist/ai/AiChatConfirmFields.js +45 -0
- package/dist/ai/AiChatConfirmFields.js.map +1 -0
- package/dist/ai/AiChatEmpty.d.ts +26 -0
- package/dist/ai/AiChatEmpty.d.ts.map +1 -0
- package/dist/ai/AiChatEmpty.js +47 -0
- package/dist/ai/AiChatEmpty.js.map +1 -0
- package/dist/ai/AiChatHistory.d.ts +3 -2
- package/dist/ai/AiChatHistory.d.ts.map +1 -1
- package/dist/ai/AiChatHistory.js +51 -22
- package/dist/ai/AiChatHistory.js.map +1 -1
- package/dist/ai/AiChatMessage.d.ts +14 -0
- package/dist/ai/AiChatMessage.d.ts.map +1 -1
- package/dist/ai/AiChatMessage.js +20 -12
- package/dist/ai/AiChatMessage.js.map +1 -1
- package/dist/ai/index.d.ts +3 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +4 -1
- package/dist/ai/useAiChat.d.ts +4 -0
- package/dist/ai/useAiChat.d.ts.map +1 -1
- package/dist/ai/useAiChat.js +15 -1
- package/dist/ai/useAiChat.js.map +1 -1
- package/dist/core/Sidebar.js +2 -2
- package/dist/core/Sidebar.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/useToast.d.ts +22 -1
- package/dist/core/useToast.d.ts.map +1 -1
- package/dist/core/useToast.js +4 -1
- package/dist/core/useToast.js.map +1 -1
- package/dist/core/useUndoable.d.ts +93 -0
- package/dist/core/useUndoable.d.ts.map +1 -0
- package/dist/core/useUndoable.js +172 -0
- package/dist/core/useUndoable.js.map +1 -0
- package/dist/i18n/fr/uiFr.d.ts.map +1 -1
- package/dist/i18n/fr/uiFr.js +50 -1
- package/dist/i18n/fr/uiFr.js.map +1 -1
- package/dist/markdown/MarkdownView.d.ts +15 -0
- package/dist/markdown/MarkdownView.d.ts.map +1 -1
- package/dist/markdown/MarkdownView.js +4 -1
- package/dist/markdown/MarkdownView.js.map +1 -1
- package/dist/organizations/useInviteOrganizationMember.d.ts +2 -2
- package/dist/organizations/useInviteOrganizationMember.js.map +1 -1
- package/dist/shell/AppShellSidebarNavItem.d.ts.map +1 -1
- package/dist/shell/AppShellSidebarNavItem.js +25 -2
- package/dist/shell/AppShellSidebarNavItem.js.map +1 -1
- package/dist/shell/PlateTabBar.d.ts.map +1 -1
- package/dist/shell/PlateTabBar.js +2 -2
- package/dist/shell/PlateTabBar.js.map +1 -1
- package/dist/shell/SidebarBackHeader.d.ts +35 -0
- package/dist/shell/SidebarBackHeader.d.ts.map +1 -0
- package/dist/shell/SidebarBackHeader.js +34 -0
- package/dist/shell/SidebarBackHeader.js.map +1 -0
- package/dist/shell/appShellNav.d.ts +30 -0
- package/dist/shell/appShellNav.d.ts.map +1 -1
- package/dist/shell/appShellNav.js.map +1 -1
- package/dist/shell/index.d.ts +2 -1
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +2 -1
- package/dist/swagger/$uiSwagger.d.ts +75 -0
- package/dist/swagger/$uiSwagger.d.ts.map +1 -0
- package/dist/swagger/$uiSwagger.js +51 -0
- package/dist/swagger/$uiSwagger.js.map +1 -0
- package/dist/swagger/OpenApiSpec.d.ts +113 -0
- package/dist/swagger/OpenApiSpec.d.ts.map +1 -0
- package/dist/swagger/OpenApiSpec.js +186 -0
- package/dist/swagger/OpenApiSpec.js.map +1 -0
- package/dist/swagger/SwaggerAccessBadge.d.ts +16 -0
- package/dist/swagger/SwaggerAccessBadge.d.ts.map +1 -0
- package/dist/swagger/SwaggerAccessBadge.js +40 -0
- package/dist/swagger/SwaggerAccessBadge.js.map +1 -0
- package/dist/swagger/SwaggerAlephaMeta.d.ts +11 -0
- package/dist/swagger/SwaggerAlephaMeta.d.ts.map +1 -0
- package/dist/swagger/SwaggerAlephaMeta.js +103 -0
- package/dist/swagger/SwaggerAlephaMeta.js.map +1 -0
- package/dist/swagger/SwaggerCredentials.d.ts +11 -0
- package/dist/swagger/SwaggerCredentials.d.ts.map +1 -0
- package/dist/swagger/SwaggerCredentials.js +35 -0
- package/dist/swagger/SwaggerCredentials.js.map +1 -0
- package/dist/swagger/SwaggerExplorer.d.ts +31 -0
- package/dist/swagger/SwaggerExplorer.d.ts.map +1 -0
- package/dist/swagger/SwaggerExplorer.js +156 -0
- package/dist/swagger/SwaggerExplorer.js.map +1 -0
- package/dist/swagger/SwaggerMethodBadge.d.ts +10 -0
- package/dist/swagger/SwaggerMethodBadge.d.ts.map +1 -0
- package/dist/swagger/SwaggerMethodBadge.js +27 -0
- package/dist/swagger/SwaggerMethodBadge.js.map +1 -0
- package/dist/swagger/SwaggerNav.d.ts +16 -0
- package/dist/swagger/SwaggerNav.d.ts.map +1 -0
- package/dist/swagger/SwaggerNav.js +63 -0
- package/dist/swagger/SwaggerNav.js.map +1 -0
- package/dist/swagger/SwaggerOperationView.d.ts +22 -0
- package/dist/swagger/SwaggerOperationView.d.ts.map +1 -0
- package/dist/swagger/SwaggerOperationView.js +89 -0
- package/dist/swagger/SwaggerOperationView.js.map +1 -0
- package/dist/swagger/SwaggerParameters.d.ts +11 -0
- package/dist/swagger/SwaggerParameters.d.ts.map +1 -0
- package/dist/swagger/SwaggerParameters.js +80 -0
- package/dist/swagger/SwaggerParameters.js.map +1 -0
- package/dist/swagger/SwaggerRequestBuilder.d.ts +83 -0
- package/dist/swagger/SwaggerRequestBuilder.d.ts.map +1 -0
- package/dist/swagger/SwaggerRequestBuilder.js +231 -0
- package/dist/swagger/SwaggerRequestBuilder.js.map +1 -0
- package/dist/swagger/SwaggerResponseView.d.ts +25 -0
- package/dist/swagger/SwaggerResponseView.d.ts.map +1 -0
- package/dist/swagger/SwaggerResponseView.js +94 -0
- package/dist/swagger/SwaggerResponseView.js.map +1 -0
- package/dist/swagger/SwaggerResponses.d.ts +12 -0
- package/dist/swagger/SwaggerResponses.d.ts.map +1 -0
- package/dist/swagger/SwaggerResponses.js +75 -0
- package/dist/swagger/SwaggerResponses.js.map +1 -0
- package/dist/swagger/SwaggerSchemaView.d.ts +19 -0
- package/dist/swagger/SwaggerSchemaView.d.ts.map +1 -0
- package/dist/swagger/SwaggerSchemaView.js +98 -0
- package/dist/swagger/SwaggerSchemaView.js.map +1 -0
- package/dist/swagger/SwaggerSection.d.ts +14 -0
- package/dist/swagger/SwaggerSection.d.ts.map +1 -0
- package/dist/swagger/SwaggerSection.js +23 -0
- package/dist/swagger/SwaggerSection.js.map +1 -0
- package/dist/swagger/SwaggerTryIt.d.ts +31 -0
- package/dist/swagger/SwaggerTryIt.d.ts.map +1 -0
- package/dist/swagger/SwaggerTryIt.js +68 -0
- package/dist/swagger/SwaggerTryIt.js.map +1 -0
- package/dist/swagger/SwaggerTryItForm.d.ts +20 -0
- package/dist/swagger/SwaggerTryItForm.d.ts.map +1 -0
- package/dist/swagger/SwaggerTryItForm.js +52 -0
- package/dist/swagger/SwaggerTryItForm.js.map +1 -0
- package/dist/swagger/index.d.ts +29 -0
- package/dist/swagger/index.d.ts.map +1 -0
- package/dist/swagger/index.js +18 -0
- package/dist/swagger/useSwaggerAccess.d.ts +24 -0
- package/dist/swagger/useSwaggerAccess.d.ts.map +1 -0
- package/dist/swagger/useSwaggerAccess.js +33 -0
- package/dist/swagger/useSwaggerAccess.js.map +1 -0
- package/dist/table/DataTable.d.ts.map +1 -1
- package/dist/table/DataTable.js +50 -13
- package/dist/table/DataTable.js.map +1 -1
- package/dist/table/DataTableBody.d.ts +18 -1
- package/dist/table/DataTableBody.d.ts.map +1 -1
- package/dist/table/DataTableBody.js +83 -58
- package/dist/table/DataTableBody.js.map +1 -1
- package/dist/table/DataTableRowActionsInline.d.ts +17 -0
- package/dist/table/DataTableRowActionsInline.d.ts.map +1 -0
- package/dist/table/DataTableRowActionsInline.js +45 -0
- package/dist/table/DataTableRowActionsInline.js.map +1 -0
- package/dist/table/PermissionMatrix.d.ts +4 -4
- package/dist/table/PermissionMatrix.js +2 -2
- package/dist/table/PermissionMatrix.js.map +1 -1
- package/dist/table/dataTableBaseProps.d.ts +31 -0
- package/dist/table/dataTableBaseProps.d.ts.map +1 -1
- package/dist/table/dataTableTypes.d.ts +16 -2
- package/dist/table/dataTableTypes.d.ts.map +1 -1
- package/dist/table/useDataTableData.d.ts +3 -0
- package/dist/table/useDataTableData.d.ts.map +1 -1
- package/dist/table/useDataTableData.js +9 -2
- package/dist/table/useDataTableData.js.map +1 -1
- package/dist/table/useDataTableRefresh.d.ts +1 -0
- package/dist/table/useDataTableRefresh.d.ts.map +1 -1
- package/dist/table/useDataTableRefresh.js +13 -1
- package/dist/table/useDataTableRefresh.js.map +1 -1
- package/dist/table/useOptimisticRows.d.ts +64 -0
- package/dist/table/useOptimisticRows.d.ts.map +1 -0
- package/dist/table/useOptimisticRows.js +185 -0
- package/dist/table/useOptimisticRows.js.map +1 -0
- package/dist/table/useRowMotion.d.ts +27 -0
- package/dist/table/useRowMotion.d.ts.map +1 -0
- package/dist/table/useRowMotion.js +112 -0
- package/dist/table/useRowMotion.js.map +1 -0
- package/docs/packages-alepha-ui-core.md +1 -0
- package/docs/packages-alepha-ui-overview.md +53 -1
- package/docs/packages-alepha-ui-swagger.md +35 -0
- package/package.json +11 -3
- package/src/account/AccountBrand.tsx +25 -6
- package/src/account/AccountLayout.tsx +5 -1
- package/src/admin/AdminUserDetail.tsx +3 -3
- package/src/admin/__tests__/AdminUserDetail.spec.ts +2 -2
- package/src/ai/AiChat.tsx +160 -82
- package/src/ai/AiChatComposer.tsx +117 -0
- package/src/ai/AiChatConfirmCard.tsx +7 -5
- package/src/ai/AiChatConfirmFields.tsx +65 -0
- package/src/ai/AiChatEmpty.tsx +73 -0
- package/src/ai/AiChatHistory.tsx +64 -28
- package/src/ai/AiChatMessage.tsx +41 -14
- package/src/ai/__tests__/AiChat.browser.spec.tsx +146 -5
- package/src/ai/index.ts +3 -0
- package/src/ai/useAiChat.ts +18 -0
- package/src/core/Sidebar.tsx +2 -2
- package/src/core/__tests__/useUndoable.browser.spec.tsx +201 -0
- package/src/core/index.ts +7 -0
- package/src/core/useToast.tsx +30 -2
- package/src/core/useUndoable.tsx +285 -0
- package/src/form/__tests__/ControlChoices.browser.spec.tsx +2 -1
- package/src/i18n/fr/uiFr.ts +52 -0
- package/src/markdown/MarkdownView.tsx +27 -9
- package/src/organizations/useInviteOrganizationMember.ts +2 -2
- package/src/shell/AppShellSidebarNavItem.tsx +51 -1
- package/src/shell/PlateTabBar.tsx +8 -2
- package/src/shell/SidebarBackHeader.tsx +58 -0
- package/src/shell/appShellNav.tsx +31 -0
- package/src/shell/index.ts +5 -1
- package/src/swagger/$uiSwagger.tsx +95 -0
- package/src/swagger/OpenApiSpec.ts +300 -0
- package/src/swagger/SwaggerAccessBadge.tsx +64 -0
- package/src/swagger/SwaggerAlephaMeta.tsx +141 -0
- package/src/swagger/SwaggerCredentials.tsx +44 -0
- package/src/swagger/SwaggerExplorer.tsx +208 -0
- package/src/swagger/SwaggerMethodBadge.tsx +32 -0
- package/src/swagger/SwaggerNav.tsx +92 -0
- package/src/swagger/SwaggerOperationView.tsx +102 -0
- package/src/swagger/SwaggerParameters.tsx +74 -0
- package/src/swagger/SwaggerRequestBuilder.ts +331 -0
- package/src/swagger/SwaggerResponseView.tsx +107 -0
- package/src/swagger/SwaggerResponses.tsx +83 -0
- package/src/swagger/SwaggerSchemaView.tsx +134 -0
- package/src/swagger/SwaggerSection.tsx +29 -0
- package/src/swagger/SwaggerTryIt.tsx +95 -0
- package/src/swagger/SwaggerTryItForm.tsx +87 -0
- package/src/swagger/__tests__/$uiSwagger.spec.ts +52 -0
- package/src/swagger/__tests__/OpenApiSpec.spec.ts +139 -0
- package/src/swagger/__tests__/SwaggerAccess.browser.spec.tsx +124 -0
- package/src/swagger/__tests__/SwaggerOperationView.browser.spec.tsx +194 -0
- package/src/swagger/__tests__/SwaggerRequestBuilder.spec.ts +250 -0
- package/src/swagger/index.ts +75 -0
- package/src/swagger/useSwaggerAccess.ts +59 -0
- package/src/table/DataTable.tsx +85 -34
- package/src/table/DataTableBody.tsx +51 -7
- package/src/table/DataTableRowActionsInline.tsx +80 -0
- package/src/table/PermissionMatrix.tsx +4 -4
- package/src/table/__tests__/DataTableEmptyState.browser.spec.tsx +1 -1
- package/src/table/__tests__/DataTableListMode.browser.spec.tsx +174 -0
- package/src/table/__tests__/DataTableOptimistic.browser.spec.tsx +173 -0
- package/src/table/__tests__/PermissionMatrix.browser.spec.tsx +2 -2
- package/src/table/__tests__/queryFilters.spec.ts +10 -12
- package/src/table/dataTableBaseProps.ts +31 -0
- package/src/table/dataTableTypes.ts +16 -2
- package/src/table/useDataTableData.ts +18 -2
- package/src/table/useDataTableRefresh.ts +26 -2
- package/src/table/useOptimisticRows.ts +265 -0
- package/src/table/useRowMotion.ts +152 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useAuth } from "alepha/react/auth";
|
|
2
2
|
import { useI18n } from "alepha/react/i18n";
|
|
3
|
+
import { useRouter } from "alepha/react/router";
|
|
3
4
|
|
|
4
5
|
import { UserAvatar } from "../core/UserAvatar.tsx";
|
|
6
|
+
import { SidebarBackHeader } from "../shell/SidebarBackHeader.tsx";
|
|
5
7
|
|
|
6
8
|
export interface AccountBrandProps {
|
|
7
9
|
/**
|
|
@@ -9,12 +11,19 @@ export interface AccountBrandProps {
|
|
|
9
11
|
* says whose area this is and what it is.
|
|
10
12
|
*/
|
|
11
13
|
subtitle?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Route name the header's back arrow leads to: the application's home,
|
|
16
|
+
* since the account shell hides the application's own chrome.
|
|
17
|
+
*
|
|
18
|
+
* @default "home"
|
|
19
|
+
*/
|
|
20
|
+
homeRouteName?: string;
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
/**
|
|
15
|
-
* The account sidebar's default header:
|
|
16
|
-
* display name, collapsing to the
|
|
17
|
-
* icon rail.
|
|
24
|
+
* The account sidebar's default header: a back arrow home, then the
|
|
25
|
+
* signed-in user's avatar and display name, collapsing to the arrow alone
|
|
26
|
+
* when the sidebar folds to its icon rail.
|
|
18
27
|
*
|
|
19
28
|
* The account area is the user's own, so the header says whose it is rather
|
|
20
29
|
* than repeating the application's name. An application that wants its own
|
|
@@ -28,13 +37,23 @@ export interface AccountBrandProps {
|
|
|
28
37
|
export const AccountBrand = (props: AccountBrandProps) => {
|
|
29
38
|
const auth = useAuth();
|
|
30
39
|
const { tr } = useI18n();
|
|
40
|
+
const router = useRouter<any>();
|
|
41
|
+
// `router.path` throws on a name the application never declared, and an
|
|
42
|
+
// application without a home page has nowhere for the arrow to go.
|
|
43
|
+
const homeName = props.homeRouteName ?? "home";
|
|
44
|
+
const home = router.pages.some((page) => page.name === homeName)
|
|
45
|
+
? homeName
|
|
46
|
+
: undefined;
|
|
31
47
|
const user = auth.user;
|
|
32
48
|
const name = user?.name ?? user?.username ?? user?.email ?? "";
|
|
33
49
|
|
|
34
50
|
return (
|
|
35
|
-
<
|
|
51
|
+
<SidebarBackHeader
|
|
52
|
+
href={home ? router.path(home) : undefined}
|
|
53
|
+
label={tr("account.nav.backToSite", { default: "Back to site" })}
|
|
54
|
+
>
|
|
36
55
|
<UserAvatar fileId={user?.picture} className="size-7" alt={name} />
|
|
37
|
-
<div className="flex min-w-0 flex-col
|
|
56
|
+
<div className="flex min-w-0 flex-col">
|
|
38
57
|
<span
|
|
39
58
|
className="truncate text-sm font-semibold tracking-tight"
|
|
40
59
|
data-testid="account-brand-name"
|
|
@@ -46,6 +65,6 @@ export const AccountBrand = (props: AccountBrandProps) => {
|
|
|
46
65
|
tr("account.brand.subtitle", { default: "Account" })}
|
|
47
66
|
</span>
|
|
48
67
|
</div>
|
|
49
|
-
</
|
|
68
|
+
</SidebarBackHeader>
|
|
50
69
|
);
|
|
51
70
|
};
|
|
@@ -53,7 +53,11 @@ export const AccountLayout = () => {
|
|
|
53
53
|
variant="floating"
|
|
54
54
|
fill
|
|
55
55
|
extraNav={options.extraNav}
|
|
56
|
-
brand={
|
|
56
|
+
brand={
|
|
57
|
+
options.brand ?? (
|
|
58
|
+
<AccountBrand homeRouteName={options.homeRouteName} />
|
|
59
|
+
)
|
|
60
|
+
}
|
|
57
61
|
topbarActions={
|
|
58
62
|
<div className="flex items-center gap-1">
|
|
59
63
|
<button
|
|
@@ -74,9 +74,9 @@ type TabKey = "overview" | "security" | "sessions" | "audits";
|
|
|
74
74
|
* `AdminRouter`'s own route declares) and falling back to `:id` (the name
|
|
75
75
|
* this component read exclusively before `AdminRouter` existed).
|
|
76
76
|
*
|
|
77
|
-
* The fallback exists for
|
|
78
|
-
*
|
|
79
|
-
* this same component. Without it,
|
|
77
|
+
* The fallback exists for downstream apps that vendor `@alepha/ui`
|
|
78
|
+
* and declare their own user-detail route as `/users/:id` against
|
|
79
|
+
* this same component. Without it, such an application's next upgrade of
|
|
80
80
|
* `@alepha/ui` would resolve `userId` to `undefined`, fall through to the
|
|
81
81
|
* empty string, and load `AdminUserDetail` with no id at all instead of
|
|
82
82
|
* failing to build.
|
|
@@ -3,8 +3,8 @@ import { describe, expect, it } from "vitest";
|
|
|
3
3
|
import { resolveUserDetailId } from "../AdminUserDetail.tsx";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* `resolveUserDetailId` is
|
|
7
|
-
*
|
|
6
|
+
* `resolveUserDetailId` is what keeps a downstream app working across
|
|
7
|
+
* a vendored `@alepha/ui` upgrade when it declares its user-detail
|
|
8
8
|
* route as `/users/:id` against this same component, while `AdminRouter`'s
|
|
9
9
|
* own route declares `:userId`. Losing the `:id` fallback would resolve an
|
|
10
10
|
* empty id for that application instead of failing loudly.
|
package/src/ai/AiChat.tsx
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
import { useForm } from "alepha/react/form";
|
|
2
1
|
import { useI18n } from "alepha/react/i18n";
|
|
2
|
+
import { SquarePen, Sparkles, X } from "lucide-react";
|
|
3
|
+
import { type ComponentType, useEffect, useRef } from "react";
|
|
3
4
|
|
|
4
5
|
import { Alert, AlertDescription } from "../core/Alert.tsx";
|
|
5
6
|
import { Button } from "../core/Button.tsx";
|
|
6
7
|
import {
|
|
7
8
|
Drawer,
|
|
9
|
+
DrawerClose,
|
|
8
10
|
DrawerContent,
|
|
9
|
-
DrawerFooter,
|
|
10
|
-
DrawerHeader,
|
|
11
11
|
DrawerTitle,
|
|
12
12
|
} from "../core/Drawer.tsx";
|
|
13
13
|
import { Spinner } from "../core/Spinner.tsx";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
import {
|
|
15
|
+
type MarkdownLinkRenderer,
|
|
16
|
+
MarkdownView,
|
|
17
|
+
} from "../markdown/MarkdownView.tsx";
|
|
18
|
+
import { AiChatComposer } from "./AiChatComposer.tsx";
|
|
19
|
+
import {
|
|
20
|
+
AiChatConfirmCard,
|
|
21
|
+
type AiChatConfirmCardProps,
|
|
22
|
+
} from "./AiChatConfirmCard.tsx";
|
|
23
|
+
import { AiChatEmpty, type AiChatSuggestion } from "./AiChatEmpty.tsx";
|
|
17
24
|
import { AiChatHistory } from "./AiChatHistory.tsx";
|
|
18
|
-
import { AiChatMessage } from "./AiChatMessage.tsx";
|
|
19
|
-
import { aiChatMessageFormSchema } from "./aiChatMessageFormSchema.ts";
|
|
25
|
+
import { AiChatMessage, type AiChatToolLabel } from "./AiChatMessage.tsx";
|
|
20
26
|
import { type UseAiChatOptions, useAiChat } from "./useAiChat.ts";
|
|
21
27
|
|
|
22
28
|
export interface AiChatProps extends UseAiChatOptions {
|
|
@@ -27,16 +33,37 @@ export interface AiChatProps extends UseAiChatOptions {
|
|
|
27
33
|
*/
|
|
28
34
|
title?: string;
|
|
29
35
|
/**
|
|
30
|
-
*
|
|
36
|
+
* Offer the list of past conversations, in a header menu. Default true.
|
|
31
37
|
*/
|
|
32
38
|
history?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Questions a new conversation offers to start from.
|
|
41
|
+
*/
|
|
42
|
+
suggestions?: AiChatSuggestion[];
|
|
43
|
+
/**
|
|
44
|
+
* Names each tool step in the user's words ("Searched clients"), running
|
|
45
|
+
* and done. Without it a step shows the tool's own name.
|
|
46
|
+
*/
|
|
47
|
+
toolLabel?: AiChatToolLabel;
|
|
48
|
+
/**
|
|
49
|
+
* A confirmation card per tool name, in place of the generic field list:
|
|
50
|
+
* an app shows a booking as a booking. It gets the pending call as the
|
|
51
|
+
* server stored it, and the approve and deny callbacks.
|
|
52
|
+
*/
|
|
53
|
+
confirmCards?: Record<string, ComponentType<AiChatConfirmCardProps>>;
|
|
54
|
+
/**
|
|
55
|
+
* How links in the assistant's replies render (`MarkdownView`'s
|
|
56
|
+
* `renderLink`): route the paths the app knows, leave the rest as text.
|
|
57
|
+
*/
|
|
58
|
+
renderLink?: MarkdownLinkRenderer;
|
|
33
59
|
}
|
|
34
60
|
|
|
35
61
|
/**
|
|
36
|
-
* The assistant in a drawer:
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
62
|
+
* The assistant in a drawer: a quiet header (history menu, new
|
|
63
|
+
* conversation, close), the conversation with its tool steps and a
|
|
64
|
+
* confirmation card for every mutation the assistant wants to run, and a
|
|
65
|
+
* composer that sends on Enter and stops a running turn. It knows the page
|
|
66
|
+
* through `useAiContext()`, and runs `navigate` and `fillForm` for the model.
|
|
40
67
|
*
|
|
41
68
|
* Needs `AlephaApiAi` on the server and a `$ai` declared by the app.
|
|
42
69
|
*
|
|
@@ -44,22 +71,39 @@ export interface AiChatProps extends UseAiChatOptions {
|
|
|
44
71
|
* ```tsx
|
|
45
72
|
* const [open, setOpen] = useState(false);
|
|
46
73
|
* <Button onClick={() => setOpen(true)}>Ask</Button>
|
|
47
|
-
* <AiChat
|
|
74
|
+
* <AiChat
|
|
75
|
+
* open={open}
|
|
76
|
+
* onOpenChange={setOpen}
|
|
77
|
+
* suggestions={[{ label: "Who still owes today?" }]}
|
|
78
|
+
* />
|
|
48
79
|
* ```
|
|
49
80
|
*/
|
|
50
81
|
export const AiChat = (props: AiChatProps) => {
|
|
51
82
|
const { tr } = useI18n();
|
|
52
83
|
const chat = useAiChat(props);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
84
|
+
const thread = useRef<HTMLDivElement>(null);
|
|
85
|
+
const busy = chat.loading && !chat.pending;
|
|
86
|
+
const empty = chat.items.length === 0 && !chat.streaming && !busy;
|
|
87
|
+
|
|
88
|
+
// Keep the newest line in view as the conversation grows.
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
const node = thread.current;
|
|
91
|
+
if (node) {
|
|
92
|
+
node.scrollTop = node.scrollHeight;
|
|
93
|
+
}
|
|
94
|
+
}, [chat.items.length, chat.streaming, chat.activity, chat.pending]);
|
|
95
|
+
|
|
96
|
+
const running = chat.activity
|
|
97
|
+
? (props.toolLabel?.(chat.activity, "running") ??
|
|
98
|
+
tr("ai.chat.running", {
|
|
99
|
+
default: "Running $1",
|
|
100
|
+
args: [chat.activity],
|
|
101
|
+
}))
|
|
102
|
+
: undefined;
|
|
103
|
+
|
|
104
|
+
const Card = chat.pending
|
|
105
|
+
? (props.confirmCards?.[chat.pending.name] ?? AiChatConfirmCard)
|
|
106
|
+
: undefined;
|
|
63
107
|
|
|
64
108
|
return (
|
|
65
109
|
<Drawer
|
|
@@ -69,14 +113,15 @@ export const AiChat = (props: AiChatProps) => {
|
|
|
69
113
|
>
|
|
70
114
|
<DrawerContent
|
|
71
115
|
data-testid="ai-chat"
|
|
72
|
-
|
|
116
|
+
// From `sm` up the panel floats: a gap from the page's edges, every
|
|
117
|
+
// corner rounded, a shadow, and no bleed strip past its edge.
|
|
118
|
+
className="flex h-full w-full flex-col gap-0 p-0 sm:h-[calc(100dvh-1.5rem)] sm:max-w-md sm:[--drawer-inset:0.75rem] sm:after:hidden sm:data-[swipe-direction=right]:rounded-2xl sm:data-[swipe-direction=right]:border sm:data-[swipe-direction=right]:shadow-2xl"
|
|
73
119
|
>
|
|
74
|
-
<
|
|
75
|
-
<
|
|
120
|
+
<div className="border-border flex items-center gap-2 border-b py-2.5 pr-2.5 pl-4">
|
|
121
|
+
<Sparkles className="text-primary size-4 shrink-0" />
|
|
122
|
+
<DrawerTitle className="flex-1 truncate text-base font-medium">
|
|
76
123
|
{props.title ?? tr("ai.chat.title", { default: "Assistant" })}
|
|
77
124
|
</DrawerTitle>
|
|
78
|
-
</DrawerHeader>
|
|
79
|
-
<div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-4">
|
|
80
125
|
{props.history !== false && (
|
|
81
126
|
<AiChatHistory
|
|
82
127
|
current={chat.conversationId}
|
|
@@ -84,39 +129,85 @@ export const AiChat = (props: AiChatProps) => {
|
|
|
84
129
|
onOpen={(id) => chat.open(id)}
|
|
85
130
|
/>
|
|
86
131
|
)}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
<Button
|
|
133
|
+
size="icon-sm"
|
|
134
|
+
variant="minimal"
|
|
135
|
+
disabled={chat.loading || empty}
|
|
136
|
+
aria-label={tr("ai.chat.new", { default: "New conversation" })}
|
|
137
|
+
onClick={() => chat.open(undefined)}
|
|
138
|
+
>
|
|
139
|
+
<SquarePen className="size-4" />
|
|
140
|
+
</Button>
|
|
141
|
+
<DrawerClose
|
|
142
|
+
render={
|
|
143
|
+
<Button
|
|
144
|
+
size="icon-sm"
|
|
145
|
+
variant="minimal"
|
|
146
|
+
aria-label={tr("ai.chat.close", { default: "Close" })}
|
|
147
|
+
/>
|
|
148
|
+
}
|
|
149
|
+
>
|
|
150
|
+
<X className="size-4" />
|
|
151
|
+
</DrawerClose>
|
|
152
|
+
</div>
|
|
153
|
+
<div
|
|
154
|
+
ref={thread}
|
|
155
|
+
// `shrink-0` on every line: in a scrolling column a card (overflow
|
|
156
|
+
// hidden, so no content minimum) would shrink to its border once
|
|
157
|
+
// the thread outgrows the drawer (#Q3174).
|
|
158
|
+
className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-4 py-4 *:shrink-0"
|
|
159
|
+
>
|
|
160
|
+
{empty ? (
|
|
161
|
+
<AiChatEmpty
|
|
162
|
+
suggestions={props.suggestions}
|
|
163
|
+
disabled={chat.loading}
|
|
164
|
+
onPick={(prompt) => chat.send(prompt)}
|
|
119
165
|
/>
|
|
166
|
+
) : (
|
|
167
|
+
<>
|
|
168
|
+
{chat.items.map((item) => (
|
|
169
|
+
<AiChatMessage
|
|
170
|
+
key={item.id}
|
|
171
|
+
item={item}
|
|
172
|
+
renderLink={props.renderLink}
|
|
173
|
+
toolLabel={props.toolLabel}
|
|
174
|
+
/>
|
|
175
|
+
))}
|
|
176
|
+
{chat.streaming && (
|
|
177
|
+
<div
|
|
178
|
+
data-testid="ai-chat-streaming"
|
|
179
|
+
className="mr-4 self-start text-sm leading-relaxed"
|
|
180
|
+
>
|
|
181
|
+
<MarkdownView
|
|
182
|
+
content={chat.streaming}
|
|
183
|
+
renderLink={props.renderLink}
|
|
184
|
+
/>
|
|
185
|
+
</div>
|
|
186
|
+
)}
|
|
187
|
+
{running && (
|
|
188
|
+
<div className="text-muted-foreground flex items-center gap-1.5 px-0.5 text-xs">
|
|
189
|
+
<Spinner className="size-3.5" />
|
|
190
|
+
{running}
|
|
191
|
+
</div>
|
|
192
|
+
)}
|
|
193
|
+
{busy && !running && !chat.streaming && (
|
|
194
|
+
<div
|
|
195
|
+
className="text-muted-foreground flex items-center gap-1.5 px-0.5 text-xs"
|
|
196
|
+
aria-live="polite"
|
|
197
|
+
>
|
|
198
|
+
<Spinner className="size-3.5" />
|
|
199
|
+
{tr("ai.chat.thinking", { default: "Thinking…" })}
|
|
200
|
+
</div>
|
|
201
|
+
)}
|
|
202
|
+
{chat.pending?.kind === "confirm" && Card && (
|
|
203
|
+
<Card
|
|
204
|
+
pending={chat.pending}
|
|
205
|
+
loading={chat.loading}
|
|
206
|
+
onApprove={() => chat.approve()}
|
|
207
|
+
onDeny={() => chat.deny()}
|
|
208
|
+
/>
|
|
209
|
+
)}
|
|
210
|
+
</>
|
|
120
211
|
)}
|
|
121
212
|
{chat.error && (
|
|
122
213
|
<Alert variant="destructive" data-testid="ai-chat-error">
|
|
@@ -124,27 +215,14 @@ export const AiChat = (props: AiChatProps) => {
|
|
|
124
215
|
</Alert>
|
|
125
216
|
)}
|
|
126
217
|
</div>
|
|
127
|
-
<
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
default: "Ask the assistant",
|
|
136
|
-
})}
|
|
137
|
-
/>
|
|
138
|
-
<Button
|
|
139
|
-
type="submit"
|
|
140
|
-
intent="primary"
|
|
141
|
-
disabled={chat.loading || Boolean(chat.pending)}
|
|
142
|
-
>
|
|
143
|
-
{chat.loading && <Spinner />}
|
|
144
|
-
{tr("ai.chat.send", { default: "Send" })}
|
|
145
|
-
</Button>
|
|
146
|
-
</form>
|
|
147
|
-
</DrawerFooter>
|
|
218
|
+
<div className="border-border border-t px-3 pt-3 pb-2.5">
|
|
219
|
+
<AiChatComposer
|
|
220
|
+
busy={busy}
|
|
221
|
+
waiting={chat.pending?.kind === "confirm"}
|
|
222
|
+
onSend={(message) => chat.send(message)}
|
|
223
|
+
onStop={() => chat.stop()}
|
|
224
|
+
/>
|
|
225
|
+
</div>
|
|
148
226
|
</DrawerContent>
|
|
149
227
|
</Drawer>
|
|
150
228
|
);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { useI18n } from "alepha/react/i18n";
|
|
2
|
+
import { ArrowUp, Square } from "lucide-react";
|
|
3
|
+
import { type KeyboardEvent, useState } from "react";
|
|
4
|
+
|
|
5
|
+
import { Button } from "../core/Button.tsx";
|
|
6
|
+
import { cn } from "../core/utils.ts";
|
|
7
|
+
|
|
8
|
+
export interface AiChatComposerProps {
|
|
9
|
+
/**
|
|
10
|
+
* A turn is running: the send button becomes Stop.
|
|
11
|
+
*/
|
|
12
|
+
busy?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* A confirmation card waits for the user: nothing can be sent until it is
|
|
15
|
+
* answered, and the field says so.
|
|
16
|
+
*/
|
|
17
|
+
waiting?: boolean;
|
|
18
|
+
onSend: (message: string) => void;
|
|
19
|
+
onStop?: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Where the user writes to the assistant: a field that grows with what is
|
|
24
|
+
* typed, Enter to send, Shift+Enter for a new line, and one round button
|
|
25
|
+
* that sends, or stops the turn while it runs.
|
|
26
|
+
*
|
|
27
|
+
* What is typed lives here, so a re-render of the drawer never drops it.
|
|
28
|
+
*/
|
|
29
|
+
export const AiChatComposer = (props: AiChatComposerProps) => {
|
|
30
|
+
const { tr } = useI18n();
|
|
31
|
+
const [value, setValue] = useState("");
|
|
32
|
+
const blocked = Boolean(props.waiting);
|
|
33
|
+
const canSend = !props.busy && !blocked && value.trim().length > 0;
|
|
34
|
+
|
|
35
|
+
const send = () => {
|
|
36
|
+
if (!canSend) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const message = value.trim();
|
|
40
|
+
setValue("");
|
|
41
|
+
props.onSend(message);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const onKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
45
|
+
if (
|
|
46
|
+
event.key === "Enter" &&
|
|
47
|
+
!event.shiftKey &&
|
|
48
|
+
!event.nativeEvent.isComposing
|
|
49
|
+
) {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
send();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<form
|
|
57
|
+
data-testid="ai-chat-composer"
|
|
58
|
+
className="flex flex-col gap-1.5"
|
|
59
|
+
onSubmit={(event) => {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
send();
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
className={cn(
|
|
66
|
+
"border-border bg-background focus-within:border-ring focus-within:ring-ring/40 flex items-end gap-2 rounded-2xl border py-2 pr-2 pl-3 transition-shadow focus-within:ring-3",
|
|
67
|
+
blocked && "bg-muted/50",
|
|
68
|
+
)}
|
|
69
|
+
>
|
|
70
|
+
<textarea
|
|
71
|
+
aria-label={tr("ai.chat.message", { default: "Message" })}
|
|
72
|
+
rows={1}
|
|
73
|
+
value={value}
|
|
74
|
+
disabled={blocked}
|
|
75
|
+
placeholder={
|
|
76
|
+
blocked
|
|
77
|
+
? tr("ai.chat.waiting", {
|
|
78
|
+
default: "Confirm or cancel the card to go on",
|
|
79
|
+
})
|
|
80
|
+
: tr("ai.chat.placeholder", { default: "Ask the assistant" })
|
|
81
|
+
}
|
|
82
|
+
onChange={(event) => setValue(event.target.value)}
|
|
83
|
+
onKeyDown={onKeyDown}
|
|
84
|
+
className="placeholder:text-muted-foreground field-sizing-content max-h-40 min-h-7 flex-1 resize-none bg-transparent py-1 text-sm leading-relaxed outline-none disabled:cursor-not-allowed"
|
|
85
|
+
/>
|
|
86
|
+
{props.busy ? (
|
|
87
|
+
<Button
|
|
88
|
+
type="button"
|
|
89
|
+
size="icon-sm"
|
|
90
|
+
variant="outlined"
|
|
91
|
+
className="shrink-0 rounded-full"
|
|
92
|
+
aria-label={tr("ai.chat.stop", { default: "Stop" })}
|
|
93
|
+
onClick={() => props.onStop?.()}
|
|
94
|
+
>
|
|
95
|
+
<Square className="size-3 fill-current" />
|
|
96
|
+
</Button>
|
|
97
|
+
) : (
|
|
98
|
+
<Button
|
|
99
|
+
type="submit"
|
|
100
|
+
size="icon-sm"
|
|
101
|
+
intent="primary"
|
|
102
|
+
className="shrink-0 rounded-full"
|
|
103
|
+
disabled={!canSend}
|
|
104
|
+
aria-label={tr("ai.chat.send", { default: "Send" })}
|
|
105
|
+
>
|
|
106
|
+
<ArrowUp className="size-4" />
|
|
107
|
+
</Button>
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
<p className="text-muted-foreground px-1 text-[11px]">
|
|
111
|
+
{tr("ai.chat.hint", {
|
|
112
|
+
default: "Enter to send, Shift+Enter for a new line",
|
|
113
|
+
})}
|
|
114
|
+
</p>
|
|
115
|
+
</form>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
CardHeader,
|
|
10
10
|
CardTitle,
|
|
11
11
|
} from "../core/Card.tsx";
|
|
12
|
+
import { AiChatConfirmFields } from "./AiChatConfirmFields.tsx";
|
|
12
13
|
|
|
13
14
|
export interface AiChatConfirmCardProps {
|
|
14
15
|
/**
|
|
@@ -22,8 +23,11 @@ export interface AiChatConfirmCardProps {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
* Asks the user before the assistant runs a mutation
|
|
26
|
-
* sends the call id only.
|
|
26
|
+
* Asks the user before the assistant runs a mutation, its input as a list of
|
|
27
|
+
* fields. Approving or denying sends the call id only.
|
|
28
|
+
*
|
|
29
|
+
* An app replaces it for one tool with `AiChat`'s `confirmCards`, and gets
|
|
30
|
+
* the same props.
|
|
27
31
|
*/
|
|
28
32
|
export const AiChatConfirmCard = (props: AiChatConfirmCardProps) => {
|
|
29
33
|
const { tr } = useI18n();
|
|
@@ -39,9 +43,7 @@ export const AiChatConfirmCard = (props: AiChatConfirmCardProps) => {
|
|
|
39
43
|
</CardTitle>
|
|
40
44
|
</CardHeader>
|
|
41
45
|
<CardContent>
|
|
42
|
-
<
|
|
43
|
-
{JSON.stringify(props.pending.input, null, 2)}
|
|
44
|
-
</pre>
|
|
46
|
+
<AiChatConfirmFields input={props.pending.input} />
|
|
45
47
|
</CardContent>
|
|
46
48
|
<CardFooter className="gap-2">
|
|
47
49
|
<Button
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface AiChatConfirmFieldsProps {
|
|
2
|
+
input: Record<string, unknown>;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A call's input as label and value rows: the `params`, `query` and `body`
|
|
7
|
+
* parts flattened into one list, a nested object written as `a.b`.
|
|
8
|
+
*/
|
|
9
|
+
export const AiChatConfirmFields = (props: AiChatConfirmFieldsProps) => {
|
|
10
|
+
const rows = flattenInput(props.input);
|
|
11
|
+
if (rows.length === 0) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return (
|
|
15
|
+
<dl
|
|
16
|
+
data-testid="ai-chat-confirm-fields"
|
|
17
|
+
className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs"
|
|
18
|
+
>
|
|
19
|
+
{rows.map(([label, value]) => (
|
|
20
|
+
<div key={label} className="contents">
|
|
21
|
+
<dt className="text-muted-foreground">{label}</dt>
|
|
22
|
+
<dd className="break-all">{value}</dd>
|
|
23
|
+
</div>
|
|
24
|
+
))}
|
|
25
|
+
</dl>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const PARTS = new Set(["params", "query", "body"]);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A value as one line: a scalar as written, anything else as JSON.
|
|
33
|
+
*/
|
|
34
|
+
const scalar = (value: unknown): string =>
|
|
35
|
+
value === null ||
|
|
36
|
+
typeof value === "string" ||
|
|
37
|
+
typeof value === "number" ||
|
|
38
|
+
typeof value === "boolean"
|
|
39
|
+
? String(value)
|
|
40
|
+
: JSON.stringify(value);
|
|
41
|
+
|
|
42
|
+
const flattenInput = (
|
|
43
|
+
input: Record<string, unknown>,
|
|
44
|
+
prefix = "",
|
|
45
|
+
): Array<[string, string]> => {
|
|
46
|
+
const rows: Array<[string, string]> = [];
|
|
47
|
+
for (const [key, value] of Object.entries(input ?? {})) {
|
|
48
|
+
// The action's input parts are plumbing, not fields the user reads.
|
|
49
|
+
const label = !prefix && PARTS.has(key) ? "" : `${prefix}${key}`;
|
|
50
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
51
|
+
rows.push(
|
|
52
|
+
...flattenInput(
|
|
53
|
+
value as Record<string, unknown>,
|
|
54
|
+
label ? `${label}.` : "",
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
} else if (value !== undefined) {
|
|
58
|
+
rows.push([
|
|
59
|
+
label || key,
|
|
60
|
+
Array.isArray(value) ? value.map(scalar).join(", ") : scalar(value),
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return rows;
|
|
65
|
+
};
|