@cosmicdrift/kumiko-renderer 0.406.0 → 0.409.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/dist/app/action-form-body.js +23 -8
- package/dist/app/action-form-support.d.ts +7 -0
- package/dist/app/action-form-support.js +14 -1
- package/dist/app/config-edit-action-row.d.ts +7 -0
- package/dist/app/config-edit-action-row.js +45 -0
- package/dist/app/config-edit-body.js +32 -4
- package/dist/app/entity-list-screen.js +8 -11
- package/dist/app/nav.js +2 -1
- package/dist/app/projection-detail-body.js +3 -1
- package/dist/app/projection-detail-header.d.ts +1 -0
- package/dist/app/projection-detail-header.js +1 -1
- package/dist/app/projection-detail-navigation.d.ts +2 -1
- package/dist/app/projection-detail-navigation.js +6 -3
- package/dist/app/projection-detail-shim.js +3 -1
- package/dist/app/projection-list-render-props.d.ts +1 -1
- package/dist/app/projection-list-render-props.js +4 -2
- package/dist/app/projection-list-render.js +1 -1
- package/dist/app/screen-access.js +4 -2
- package/dist/app/screen-shared.d.ts +3 -2
- package/dist/app/screen-shared.js +29 -1
- package/dist/app/use-embedded-screen.d.ts +2 -0
- package/dist/app/use-embedded-screen.js +7 -1
- package/dist/components/edit-mounts.d.ts +3 -1
- package/dist/components/edit-mounts.js +3 -3
- package/dist/components/related-list-section.d.ts +3 -1
- package/dist/components/related-list-section.js +2 -2
- package/dist/components/render-edit-field-grid.d.ts +2 -2
- package/dist/components/render-edit-field-grid.js +12 -4
- package/dist/components/render-edit-fields-section.js +6 -7
- package/dist/components/render-edit-helpers.d.ts +4 -0
- package/dist/components/render-edit-helpers.js +5 -0
- package/dist/components/render-edit-section-kinds.js +6 -4
- package/dist/components/render-edit-submit.js +18 -1
- package/dist/components/render-edit-titles.js +6 -6
- package/dist/components/render-edit-types.d.ts +6 -0
- package/dist/components/render-field-control.d.ts +2 -0
- package/dist/components/render-field-control.js +23 -1
- package/dist/components/render-field-write-only.d.ts +1 -1
- package/dist/components/render-field-write-only.js +12 -2
- package/dist/components/render-field.js +2 -1
- package/dist/components/use-render-edit-sections.js +4 -4
- package/dist/format-when.d.ts +1 -1
- package/dist/format-when.js +2 -2
- package/dist/headless/format/escape.js +3 -2
- package/dist/headless/view-model/edit.js +0 -2
- package/dist/headless/view-model/types.d.ts +0 -3
- package/dist/i18n-defaults.js +38 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/primitives.d.ts +30 -7
- package/dist/primitives.js +1 -51
- package/dist/status-tone.d.ts +6 -0
- package/dist/status-tone.js +51 -0
- package/dist/toggle-set-member.d.ts +1 -0
- package/dist/toggle-set-member.js +8 -0
- package/dist/web/app/dashboard-header.js +5 -1
- package/dist/web/app/dashboard-screen-tiles.js +19 -3
- package/dist/web/icons.d.ts +2 -0
- package/dist/web/icons.js +3 -1
- package/dist/web/index.d.ts +3 -2
- package/dist/web/index.js +2 -1
- package/dist/web/layout/default-app-shell.d.ts +4 -1
- package/dist/web/layout/default-app-shell.js +5 -2
- package/dist/web/layout/focus-aware-sidebar.d.ts +27 -0
- package/dist/web/layout/focus-aware-sidebar.js +23 -0
- package/dist/web/layout/focus-rail.d.ts +16 -0
- package/dist/web/layout/focus-rail.js +61 -0
- package/dist/web/layout/nav-tree.d.ts +2 -1
- package/dist/web/layout/nav-tree.js +3 -9
- package/dist/web/layout/shell-focus.d.ts +19 -0
- package/dist/web/layout/shell-focus.js +35 -0
- package/dist/web/layout/shell-header.d.ts +1 -1
- package/dist/web/layout/shell-header.js +12 -9
- package/dist/web/layout/sidebar-brand.js +1 -1
- package/dist/web/layout/workspace-shell.d.ts +4 -1
- package/dist/web/layout/workspace-shell.js +5 -2
- package/dist/web/primitives/banner.js +3 -1
- package/dist/web/primitives/data-table/toolbar.js +2 -2
- package/dist/web/primitives/default-form.js +12 -5
- package/dist/web/primitives/field.js +4 -1
- package/dist/web/primitives/input-text-kinds.js +8 -2
- package/dist/web/primitives/layout-elements.js +2 -4
- package/dist/web/primitives/tabs.d.ts +1 -1
- package/dist/web/primitives/tabs.js +21 -4
- package/dist/web/theme-plugin.d.ts +1 -1
- package/dist/web/theme-plugin.js +7 -0
- package/dist/web/ui/sidebar.js +5 -2
- package/dist/web/widgets/ai-text-end-action.d.ts +12 -0
- package/dist/web/widgets/ai-text-end-action.js +15 -0
- package/dist/web/widgets/ai-text-field.d.ts +3 -0
- package/dist/web/widgets/ai-text-field.js +4 -3
- package/dist/web/widgets/attachment-card.d.ts +6 -0
- package/dist/web/widgets/attachment-card.js +11 -0
- package/dist/web/widgets/attachment-chip.d.ts +8 -0
- package/dist/web/widgets/attachment-chip.js +21 -0
- package/dist/web/widgets/clamped-text.d.ts +11 -0
- package/dist/web/widgets/clamped-text.js +38 -0
- package/dist/web/widgets/html-mail-frame.d.ts +17 -0
- package/dist/web/widgets/html-mail-frame.js +56 -0
- package/dist/web/widgets/index.d.ts +10 -1
- package/dist/web/widgets/index.js +9 -1
- package/dist/web/widgets/infinity-list.d.ts +3 -1
- package/dist/web/widgets/infinity-list.js +2 -2
- package/dist/web/widgets/message-body-view.d.ts +10 -0
- package/dist/web/widgets/message-body-view.js +36 -0
- package/dist/web/widgets/message-reader.d.ts +4 -0
- package/dist/web/widgets/message-reader.js +31 -0
- package/dist/web/widgets/message-thread.d.ts +5 -0
- package/dist/web/widgets/message-thread.js +66 -0
- package/dist/web/widgets/message-types.d.ts +68 -0
- package/dist/web/widgets/message-types.js +1 -0
- package/dist/web/widgets/mobile-top-bar.d.ts +21 -0
- package/dist/web/widgets/mobile-top-bar.js +8 -0
- package/dist/web/widgets/pdf-document.d.ts +19 -0
- package/dist/web/widgets/pdf-document.js +70 -0
- package/dist/web/widgets/pdf-page.d.ts +35 -0
- package/dist/web/widgets/pdf-page.js +155 -0
- package/dist/web/widgets/pdf-preview.d.ts +27 -7
- package/dist/web/widgets/pdf-preview.js +21 -133
- package/dist/web/widgets/pdf-search.d.ts +43 -0
- package/dist/web/widgets/pdf-search.js +178 -0
- package/dist/web/widgets/pdf-thumbnails.d.ts +10 -0
- package/dist/web/widgets/pdf-thumbnails.js +35 -0
- package/dist/web/widgets/pdf-viewer-toolbar.d.ts +22 -0
- package/dist/web/widgets/pdf-viewer-toolbar.js +35 -0
- package/dist/web/widgets/pdf-viewer.d.ts +21 -0
- package/dist/web/widgets/pdf-viewer.js +176 -0
- package/dist/web/widgets/quoted-text.d.ts +16 -0
- package/dist/web/widgets/quoted-text.js +76 -0
- package/dist/web/widgets/status-badge.js +3 -1
- package/dist/web/widgets/step-list-fit.d.ts +25 -0
- package/dist/web/widgets/step-list-fit.js +79 -0
- package/dist/web/widgets/step-list-row.d.ts +50 -0
- package/dist/web/widgets/step-list-row.js +97 -0
- package/dist/web/widgets/step-list.d.ts +33 -0
- package/dist/web/widgets/step-list.js +36 -0
- package/dist/web/widgets/surfaces.d.ts +23 -0
- package/dist/web/widgets/surfaces.js +15 -0
- package/dist/web/widgets/use-in-view.d.ts +5 -0
- package/dist/web/widgets/use-in-view.js +18 -0
- package/package.json +5 -5
- package/src/changes.json +186 -0
- package/src/web/styles.css +22 -0
|
@@ -5,5 +5,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
// `collapsible`.
|
|
6
6
|
import { ChevronsUpDown } from "lucide-react";
|
|
7
7
|
export function SidebarBrand({ name, plan, logo, collapsible = false, }) {
|
|
8
|
-
return (_jsxs("div", { className: "flex items-center gap-2.5 px-2 pt-1 pb-3 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0", children: [_jsx("div", { className: "flex size-7 shrink-0 items-center justify-center rounded-md bg-sidebar-primary text-sm font-semibold text-sidebar-primary-foreground", children: logo ?? _jsx("span", { children: name.charAt(0) }) }), _jsxs("div", { className: "grid min-w-0 flex-1 text-left leading-tight group-data-[collapsible=icon]:hidden", children: [_jsx("span", { className: "truncate text-sm font-semibold text-sidebar-foreground", children: name }), plan !== undefined && _jsx("span", { className: "truncate text-xs text-sidebar-muted", children: plan })] }), collapsible && (_jsx(ChevronsUpDown, { className: "ml-auto size-4 text-sidebar-muted group-data-[collapsible=icon]:hidden" }))] }));
|
|
8
|
+
return (_jsxs("div", { className: "flex items-center gap-2.5 px-2 pt-1 pb-3 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0 group-data-[focus-rail]/focus-rail:pt-0", children: [_jsx("div", { className: "flex size-7 shrink-0 items-center justify-center rounded-md bg-sidebar-primary text-sm font-semibold text-sidebar-primary-foreground group-data-[focus-rail]/focus-rail:size-8 group-data-[focus-rail]/focus-rail:rounded-md", children: logo ?? _jsx("span", { children: name.charAt(0) }) }), _jsxs("div", { className: "grid min-w-0 flex-1 text-left leading-tight group-data-[collapsible=icon]:hidden", children: [_jsx("span", { className: "truncate text-sm font-semibold text-sidebar-foreground", children: name }), plan !== undefined && _jsx("span", { className: "truncate text-xs text-sidebar-muted", children: plan })] }), collapsible && (_jsx(ChevronsUpDown, { className: "ml-auto size-4 text-sidebar-muted group-data-[collapsible=icon]:hidden" }))] }));
|
|
9
9
|
}
|
|
@@ -25,6 +25,9 @@ export type WorkspaceShellProps = {
|
|
|
25
25
|
* build information. It stays at the bottom via `mt-auto` (see
|
|
26
26
|
* Sidebar.footer). Symmetric with DefaultAppShell.sidebarFooter. */
|
|
27
27
|
readonly sidebarFooter?: ReactNode;
|
|
28
|
+
/** Top-level nav QNs the focus rail shows as tiles; the others sit behind a
|
|
29
|
+
* "More" tile that opens the full sidebar. Unset: every top-level entry. */
|
|
30
|
+
readonly focusRailNavQns?: readonly string[];
|
|
28
31
|
/** Runtime badge slot per nav leaf (bare nav id), same as DefaultAppShell. */
|
|
29
32
|
readonly navBadges?: ReadonlyMap<string, ReactNode>;
|
|
30
33
|
/** Viewport-fit shell. true → fixed viewport height (`h-svh`), content
|
|
@@ -34,7 +37,7 @@ export type WorkspaceShellProps = {
|
|
|
34
37
|
/** Screen content. */
|
|
35
38
|
readonly children: ReactNode;
|
|
36
39
|
};
|
|
37
|
-
export declare function WorkspaceShell({ brand, schema, topbarActions, user, initialWorkspaceId, sidebarFooter, navBadges, fill, children, }: WorkspaceShellProps): ReactNode;
|
|
40
|
+
export declare function WorkspaceShell({ brand, schema, topbarActions, user, initialWorkspaceId, sidebarFooter, focusRailNavQns, navBadges, fill, children, }: WorkspaceShellProps): ReactNode;
|
|
38
41
|
export declare function filterByAccess(workspaces: readonly WorkspaceSchema[], userRoles: readonly string[] | undefined): readonly WorkspaceSchema[];
|
|
39
42
|
/** Returns the short screen-id of the first nav-member that points at
|
|
40
43
|
* a screen. Walks the workspace's nav-list in order and skips section
|
|
@@ -36,13 +36,15 @@ import { useResolvers } from "../app/resolvers-context.js";
|
|
|
36
36
|
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarInset, SidebarProvider, SidebarRail, } from "../ui/sidebar.js";
|
|
37
37
|
import { EditorPanel } from "./editor-panel.js";
|
|
38
38
|
import { fillClasses } from "./fill-classes.js";
|
|
39
|
+
import { FocusAwareSidebarBody, focusSidebarProviderProps } from "./focus-aware-sidebar.js";
|
|
39
40
|
import { lastSegment, NavTree } from "./nav-tree.js";
|
|
40
41
|
import { PageHeaderSlotProvider } from "./page-header-slot.js";
|
|
42
|
+
import { ShellFocusProvider, useShellFocusHost } from "./shell-focus.js";
|
|
41
43
|
import { ShellHeader } from "./shell-header.js";
|
|
42
44
|
import { SidebarPanelProvider, useSidebarPanelHost } from "./sidebar-panel.js";
|
|
43
45
|
import { parseTargetFromSearchParams } from "./target-url.js";
|
|
44
46
|
import { WorkspaceSwitcher } from "./workspace-switcher.js";
|
|
45
|
-
export function WorkspaceShell({ brand, schema, topbarActions, user, initialWorkspaceId, sidebarFooter, navBadges, fill = true, children, }) {
|
|
47
|
+
export function WorkspaceShell({ brand, schema, topbarActions, user, initialWorkspaceId, sidebarFooter, focusRailNavQns, navBadges, fill = true, children, }) {
|
|
46
48
|
const app = useMemo(() => toAppSchema(schema), [schema]);
|
|
47
49
|
const visible = useMemo(() => filterByAccess(app.workspaces ?? [], user?.roles), [app.workspaces, user?.roles]);
|
|
48
50
|
const nav = useNav();
|
|
@@ -150,7 +152,8 @@ export function WorkspaceShell({ brand, schema, topbarActions, user, initialWork
|
|
|
150
152
|
// The second column appears only when a screen fills it (sidebar-09 pattern);
|
|
151
153
|
// otherwise every other screen would have an empty strip beside the navigation.
|
|
152
154
|
const panel = useSidebarPanelHost();
|
|
153
|
-
|
|
155
|
+
const focus = useShellFocusHost();
|
|
156
|
+
return (_jsx(SidebarProvider, { ...fillCls.provider, ...focusSidebarProviderProps(focus), children: _jsx(ShellFocusProvider, { value: focus.value, children: _jsxs(SidebarPanelProvider, { value: panel.value, children: [_jsxs(Sidebar, { collapsible: "icon", mobileTitle: t("kumiko.sidebar.title"), mobileDescription: t("kumiko.sidebar.description"), children: [_jsxs(FocusAwareSidebarBody, { focused: focus.focused, brand: brand, schema: app, user: user, allowedNavQns: allowedNavQns, railNavQns: focusRailNavQns, footer: sidebarFooter, children: [_jsxs(SidebarHeader, { "data-kumiko-layout": "sidebar-header", children: [brand, switcher] }), _jsx(SidebarContent, { "data-kumiko-layout": "sidebar-nav", children: sidebarContent }), sidebarFooter !== undefined && (_jsx(SidebarFooter, { "data-kumiko-layout": "sidebar-footer", className: "border-t border-sidebar-border", children: sidebarFooter }))] }), _jsx(SidebarRail, { "aria-label": t("kumiko.sidebar.toggle"), title: t("kumiko.sidebar.toggle") })] }), _jsx("div", { ref: panel.ref, "data-kumiko-layout": "sidebar-panel", className: panel.occupied ? "flex h-svh shrink-0 flex-col" : "hidden" }), _jsx(SidebarInset, { className: fillCls.inset, children: _jsxs(PageHeaderSlotProvider, { children: [_jsx(ShellHeader, { schema: app, ...(user !== undefined && { user }), ...(allowedNavQns !== undefined && { allowedNavQns }), ...(topbarActions !== undefined && { headerActions: topbarActions }) }), _jsx("main", { className: fillCls.main, children: activeTarget !== undefined ? (_jsx(EditorPanel, { resolvers: resolvers })) : (_jsx(UserRolesProvider, { roles: user?.roles, children: children })) })] }) })] }) }) }));
|
|
154
157
|
}
|
|
155
158
|
// --- helpers (exported for tests) ---
|
|
156
159
|
export function filterByAccess(workspaces, userRoles) {
|
|
@@ -20,7 +20,9 @@ export function DefaultBanner({ variant = "info", title, titleTestId, children,
|
|
|
20
20
|
? "border-status-warn/30 bg-status-warn/10 text-status-warn"
|
|
21
21
|
: isPrimary
|
|
22
22
|
? "border-l-4 border-l-primary bg-card text-card-foreground"
|
|
23
|
-
:
|
|
23
|
+
: variant === "hint"
|
|
24
|
+
? "border-transparent bg-muted text-foreground"
|
|
25
|
+
: "bg-card text-card-foreground"), children: [_jsxs("div", { className: "flex-1", children: [title !== undefined && (_jsx("div", { "data-testid": titleTestId, className: "font-semibold", children: title })), children] }), actions !== undefined && _jsx("div", { "data-slot": "actions", children: actions })] }));
|
|
24
26
|
// Page state: the banner sits alone in main (which no longer has padding).
|
|
25
27
|
// The wrapper adds 24px outer spacing so the banner does not stick
|
|
26
28
|
// edge-to-edge to the sidebar/browser.
|
|
@@ -53,8 +53,8 @@ export function renderToolbar(m, facetCluster) {
|
|
|
53
53
|
const collapsesFacetsBehindButton = m.isNarrow && m.fillsHeight && facetCluster !== undefined;
|
|
54
54
|
const mergesDescription = toolbarMergesDescription(m, facetCluster);
|
|
55
55
|
return (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-toolbar` : "render-list-toolbar", className: cn(toolbarClassName(m), mergesDescription && "justify-between", mergesDescription && m.fillsHeight && !m.isNarrow && "md:py-2",
|
|
56
|
-
// A dashboard panel
|
|
57
|
-
|
|
56
|
+
// A dashboard panel head above has no inset; the toolbar shares its edges like the table below.
|
|
57
|
+
m.fillsHeight && m.insideEmbeddedScreen && "px-0"), children: [mergesDescription && renderToolbarDescription(m, true, true), toolbarStart !== undefined && renderToolbarStart(m, toolbarStart), collapsesFacetsBehindButton ? renderFacetToggle(m, facetCluster) : facetCluster, _jsx(ToolbarEndCluster, { view: m.view, columnLabels: new Map(m.schemaColumns.map((col) => [col.field, col.label])), exportList: m.exportList, toolbarEnd: m.toolbarEnd })] }));
|
|
58
58
|
}
|
|
59
59
|
export function renderToolbarDescription(m, hasToolbar, inToolbarRow = false) {
|
|
60
60
|
const { testId, toolbarDescription, fillsHeight, isNarrow } = m;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
|
-
import { InsideDrawerProvider, useInsideDrawer } from "../../index.js";
|
|
3
|
+
import { InsideDrawerProvider, useInsideDrawer, useTranslation, } from "../../index.js";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
import { screenFormColumnWidthClassName, screenPaddingClassName } from "./layout.js";
|
|
6
6
|
import { InsideScreenFormColumnContext } from "./metric.js";
|
|
@@ -8,14 +8,21 @@ import "../react-css-custom-properties.js";
|
|
|
8
8
|
import { cardSurface } from "./card-styles.js";
|
|
9
9
|
import { BareFormContext, DrawerBodyContext, EmbeddedFormContext, InsideFormContext, ScreenFormContext, ScreenWidthContext, } from "./contexts.js";
|
|
10
10
|
import { FormFooter, FormRoot, FormScreenShell, FormSectionNav, FormSections, FormTitleBlock, isPinnedFooter, SECTION_NAV_MIN_ITEMS, } from "./form.js";
|
|
11
|
+
import { unsavedStatusText } from "./form-footer-parts.js";
|
|
11
12
|
// Form inside the Drawer primitive: the drawer header carries the title, so
|
|
12
13
|
// only the description (as help text), the scrolling sections and a pinned
|
|
13
14
|
// footer remain. The scroll area is a sibling of the footer, never its parent.
|
|
15
|
+
function FormSummaryBox({ summary, testId }) {
|
|
16
|
+
if (summary === undefined)
|
|
17
|
+
return null;
|
|
18
|
+
return (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-summary` : undefined, className: "flex flex-col gap-0.5 rounded-lg bg-muted px-3.5 py-3", children: [_jsx("span", { className: "text-sm font-semibold text-foreground", children: summary.title }), summary.subtitle !== undefined && (_jsx("span", { className: "text-[13px] text-foreground-secondary", children: summary.subtitle }))] }));
|
|
19
|
+
}
|
|
14
20
|
function DrawerFormLayout({ onSubmit, focusFirstErrorKey, subtitle, actions, secondaryActions, summary, testId, children, }) {
|
|
15
|
-
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: "flex h-full min-h-0 w-full flex-col", children: [_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-scroll` : undefined, className: "flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-6 py-5", children: [
|
|
21
|
+
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: "flex h-full min-h-0 w-full flex-col", children: [_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-scroll` : undefined, className: "flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-6 py-5", children: [_jsx(FormSummaryBox, { summary: summary, testId: testId }), subtitle !== undefined && (_jsx("p", { "data-testid": testId !== undefined ? `${testId}-subtitle` : undefined, className: "text-[13px] text-foreground-secondary", children: subtitle })), _jsx(InsideFormContext.Provider, { value: true, children: _jsx(ScreenFormContext.Provider, { value: true, children: _jsx(InsideDrawerProvider, { value: false, children: _jsx(DrawerBodyContext.Provider, { value: true, children: _jsx("div", { className: "flex flex-col gap-5", children: children }) }) }) }) })] }), (actions !== undefined || secondaryActions !== undefined) && (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-footer` : undefined, className: "flex h-16 shrink-0 items-center justify-end gap-2 border-t border-border px-6", children: [secondaryActions, actions] }))] }));
|
|
16
22
|
}
|
|
17
23
|
export function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, subtitle, actions, secondaryActions, testId, width, stickyActions, headerRegion, titleAction, fillHeight, chromeless, screenForm, unsavedCount, sectionNav, sideRail, summary, }) {
|
|
18
24
|
const insideDrawer = useInsideDrawer();
|
|
25
|
+
const t = useTranslation();
|
|
19
26
|
const isEmbeddedForm = useContext(EmbeddedFormContext);
|
|
20
27
|
const contextWidth = useContext(ScreenWidthContext);
|
|
21
28
|
// Embedded (AuthCard etc.): bare <form>, stacked fields with gap; the
|
|
@@ -30,7 +37,7 @@ export function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, sub
|
|
|
30
37
|
return (_jsx(DrawerFormLayout, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, subtitle: subtitle, actions: actions, secondaryActions: secondaryActions, summary: summary, testId: testId, children: children }));
|
|
31
38
|
}
|
|
32
39
|
if (isEmbeddedForm) {
|
|
33
|
-
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: "flex w-full flex-col gap-6", children: [_jsx(
|
|
40
|
+
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: "flex w-full flex-col gap-6", children: [_jsx(FormSections, { chromeless: true, stickyActions: undefined, fillHeight: false, screenForm: true, children: children }), (actions !== undefined || secondaryActions !== undefined) && (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-footer` : undefined, className: "flex flex-wrap items-center gap-2", children: [actions, secondaryActions, unsavedCount !== undefined && unsavedCount > 0 && (_jsxs("span", { "data-testid": testId !== undefined ? `${testId}-unsaved` : undefined, className: "flex items-center gap-2 text-[13px] text-foreground-secondary", children: [_jsx("span", { className: "size-1.5 shrink-0 rounded-full bg-status-active", "aria-hidden": "true" }), unsavedStatusText(t, unsavedCount)] }))] }))] }));
|
|
34
41
|
}
|
|
35
42
|
const isScreenForm = screenForm === true && fillHeight === true && chromeless !== true;
|
|
36
43
|
const screenFormWidth = width ?? contextWidth;
|
|
@@ -42,7 +49,7 @@ export function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, sub
|
|
|
42
49
|
const showsSectionNav = sectionNav !== undefined && sectionNav.length >= SECTION_NAV_MIN_ITEMS;
|
|
43
50
|
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: "flex h-full min-h-0 w-full flex-col", children: [_jsxs("div", { className: "flex min-h-0 flex-1 flex-col lg:flex-row", children: [sideRail, _jsx("div", { "data-testid": testId !== undefined ? `${testId}-scroll` : undefined, className: cn("min-h-0 flex-1 overflow-y-auto", screenPaddingClassName), children: _jsxs("div", { className: "flex gap-18", children: [_jsxs("div", { className: cn("flex w-full min-w-0 flex-col gap-9", screenFormWidth !== undefined
|
|
44
51
|
? screenFormColumnWidthClassName[screenFormWidth]
|
|
45
|
-
: "max-w-[640px]"), children: [_jsx(InsideScreenFormColumnContext.Provider, { value: true, children: headerRegion }), _jsx(FormTitleBlock, { title: title, subtitle: subtitle, titleAction: titleAction, testId: testId, bordered: false, fillHeight: false }), sections] }), showsSectionNav && _jsx(FormSectionNav, { items: sectionNav })] }) })] }), footer] }));
|
|
52
|
+
: "max-w-[640px]"), children: [_jsx(InsideScreenFormColumnContext.Provider, { value: true, children: headerRegion }), _jsx(FormTitleBlock, { title: title, subtitle: subtitle, titleAction: titleAction, testId: testId, bordered: false, fillHeight: false }), _jsx(FormSummaryBox, { summary: summary, testId: testId }), sections] }), showsSectionNav && _jsx(FormSectionNav, { items: sectionNav })] }) })] }), footer] }));
|
|
46
53
|
}
|
|
47
54
|
// Pinned footer (fillHeight + stickyActions): the footer is a full-bleed
|
|
48
55
|
// sibling BELOW the padded shell, so the shell's bottom inset does not float
|
|
@@ -59,7 +66,7 @@ export function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, sub
|
|
|
59
66
|
// the screen-level subtitle (screen.description) is independent of that
|
|
60
67
|
// and must survive tabs mode.
|
|
61
68
|
if (chromeless === true) {
|
|
62
|
-
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: cn("flex flex-col w-full", fillHeight === true && "h-full min-h-0"), children: [_jsxs(FormScreenShell, { maxWidth: "full", ...(fillHeight === true && { fillHeight: true }), className: cn("!p-0", pinnedShellClassName), children: [headerRegion !== undefined && (_jsx("div", { className: cn("flex flex-col", fillHeight === true && "shrink-0"), children: headerRegion })), _jsx(FormTitleBlock, { title: title, subtitle: subtitle, titleAction: titleAction, testId: testId, bordered: false, fillHeight: fillHeight }), sections, !pinnedFooter && footer] }), pinnedFooter && footer] }));
|
|
69
|
+
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: cn("flex flex-col w-full", fillHeight === true && "h-full min-h-0"), children: [_jsxs(FormScreenShell, { maxWidth: "full", ...(fillHeight === true && { fillHeight: true }), className: cn("!p-0", pinnedShellClassName), children: [headerRegion !== undefined && (_jsx("div", { "data-testid": testId !== undefined ? `${testId}-header-region` : undefined, className: cn("flex flex-col pb-1.5", fillHeight === true && "shrink-0"), children: headerRegion })), _jsx(FormTitleBlock, { title: title, subtitle: subtitle, titleAction: titleAction, testId: testId, bordered: false, fillHeight: fillHeight }), sections, !pinnedFooter && footer] }), pinnedFooter && footer] }));
|
|
63
70
|
}
|
|
64
71
|
// One card form: title as header (no divider under it), sections divided
|
|
65
72
|
// between each other, muted action footer. Shell width comes from
|
|
@@ -57,7 +57,10 @@ function DefaultFieldBody({ id, label, required, issues, labelAppendix, fieldApp
|
|
|
57
57
|
// Switch rows keep label left / switch right when stacked.
|
|
58
58
|
"@max-2xl:has-[[data-slot=switch]]:grid-cols-[minmax(0,1fr)_auto]", accent === true && "@max-2xl:pl-3"), children: [accent === true && (_jsx("span", { "aria-hidden": "true", "data-testid": testId !== undefined ? `${testId}-accent` : undefined, className: "absolute inset-y-3 w-0.5 bg-status-active @max-2xl:left-0 @2xl:-left-4" })), _jsxs("div", { className: "flex min-w-0 items-center gap-2 @2xl:col-start-1 @2xl:row-start-1", children: [labelEl, changedMarker, labelAppendix !== undefined && labelAppendix, statusEl] }), description !== undefined && (_jsx("div", { id: fieldDescriptionId(id), "data-testid": testId !== undefined ? `${testId}-description` : undefined, className: "min-w-0 text-sm text-muted-foreground @2xl:col-start-1 @2xl:row-start-2 @2xl:mt-1 @max-2xl:group-has-[[data-slot=switch]]/row:col-span-2", children: description })), _jsxs("div", { className: "flex min-w-0 flex-col gap-1.5 has-[[data-slot=switch]]:items-end @2xl:col-start-2 @2xl:row-span-4 @2xl:row-start-1 @max-2xl:group-has-[[data-slot=switch]]/row:col-start-2 @max-2xl:group-has-[[data-slot=switch]]/row:row-start-1", children: [_jsx(FieldLayoutContext.Provider, { value: "row", children: children }), errorsEl] }), fieldAppendix !== undefined && (_jsx("div", { className: "min-w-0 @2xl:col-start-1 @2xl:row-start-3 @2xl:mt-1 @max-2xl:group-has-[[data-slot=switch]]/row:col-span-2", children: fieldAppendix }))] }));
|
|
59
59
|
}
|
|
60
|
-
return (_jsxs("div", { "data-testid": testId, ...(belowControl && fieldAppendix !== undefined && { "data-appendix-below": "" }), className: "flex flex-col gap-1.5", children: [
|
|
60
|
+
return (_jsxs("div", { "data-testid": testId, ...(belowControl && fieldAppendix !== undefined && { "data-appendix-below": "" }), className: "flex flex-col gap-1.5", children: [hideLabel === true &&
|
|
61
|
+
changedMarker === null &&
|
|
62
|
+
labelAppendix === undefined &&
|
|
63
|
+
statusEl === null ? (labelEl) : (_jsxs("div", { className: "flex items-center justify-between gap-2", children: [changedMarker !== null ? (_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [labelEl, changedMarker] })) : (labelEl), labelAppendix !== undefined && labelAppendix, statusEl] })), description !== undefined && (_jsx("div", { id: fieldDescriptionId(id), "data-testid": testId !== undefined ? `${testId}-description` : undefined, className: "text-sm text-muted-foreground", children: description })), !belowControl && fieldAppendix !== undefined && fieldAppendix, children, errorsEl, belowControl && fieldAppendix !== undefined && fieldAppendix] }));
|
|
61
64
|
}
|
|
62
65
|
// ---- Input ----
|
|
63
66
|
// Field-icon registry: `EditFieldSpec.icon`/`InputProps.icon` sets a
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
import { Input as UiInput } from "../ui/input.js";
|
|
4
4
|
import { Textarea } from "../ui/textarea.js";
|
|
5
|
+
import { AiTextEndActionButton, endActionPaddingClass } from "../widgets/ai-text-end-action.js";
|
|
5
6
|
import { CodeInput } from "./code-input.js";
|
|
6
7
|
import { fieldIconFor, textareaMinHeight, withFieldIcon, withInputAddons, withTrailingAction, } from "./field.js";
|
|
7
|
-
|
|
8
|
+
function withEndAction(props, input) {
|
|
9
|
+
if (props.endAction === undefined)
|
|
10
|
+
return input;
|
|
11
|
+
return (_jsxs("div", { className: "relative", children: [input, _jsx(AiTextEndActionButton, { action: props.endAction, multiline: false, disabled: props.disabled === true, testId: props.testId })] }));
|
|
12
|
+
}
|
|
13
|
+
export const renderTextKind = (props, { common, textInputRef }) => withInputAddons(props, withEndAction(props, withFieldIcon(props.icon, _jsx(UiInput, { type: "text", ref: textInputRef, ...common, ...props.dataAttributes, "data-testid": props.testId, readOnly: props.readOnly, value: props.value, onChange: (e) => props.onChange(e.target.value), onKeyDown: props.onKeyDown, ...(props.placeholder !== undefined && { placeholder: props.placeholder }), ...(props.autoComplete !== undefined && { autoComplete: props.autoComplete }), className: cn(fieldIconFor(props.icon) !== undefined ? "pl-8" : undefined, endActionPaddingClass(props.endAction)) }))));
|
|
8
14
|
export const renderCodeKind = (props) => _jsx(CodeInput, { ...props });
|
|
9
15
|
export const renderEmailKind = (props, { common }) => (_jsx(UiInput, { type: "email", ...common, "data-testid": props.testId, value: props.value, onChange: (e) => props.onChange(e.target.value), ...(props.placeholder !== undefined && { placeholder: props.placeholder }), autoComplete: props.autoComplete ?? "email" }));
|
|
10
16
|
export const renderMonthKind = (props, { common }) => (_jsx(UiInput, { type: "month", ...common, "data-testid": props.testId, value: props.value, onChange: (e) => props.onChange(e.target.value) }));
|
|
@@ -75,8 +75,7 @@ export function DefaultGrid({ columns, children, testId, maxRows, flow, list, ar
|
|
|
75
75
|
if (list === true) {
|
|
76
76
|
return (_jsx("div", { ...groupProps, "data-testid": testId, className: "flex flex-col divide-y divide-border", children: children }));
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
if (flow === true && (insideDrawerBody || !declaresColumns)) {
|
|
78
|
+
if (flow === true) {
|
|
80
79
|
return (_jsx("div", { ...groupProps, "data-testid": testId, className: cn("flex gap-4", insideDrawerBody
|
|
81
80
|
? "flex-col items-start"
|
|
82
81
|
: // items-end aligns inputs when labels wrap to different heights; a
|
|
@@ -117,8 +116,7 @@ export function DefaultGrid({ columns, children, testId, maxRows, flow, list, ar
|
|
|
117
116
|
overflowY: "auto",
|
|
118
117
|
}),
|
|
119
118
|
};
|
|
120
|
-
return (_jsx("div", { ...groupProps, "data-testid": testId, className:
|
|
121
|
-
"items-end has-[[data-appendix-below]]:items-start has-[[role=alert]]:items-start"), style: style, children: children }));
|
|
119
|
+
return (_jsx("div", { ...groupProps, "data-testid": testId, className: "grid gap-[var(--kumiko-grid-gap,1rem)] grid-cols-1 sm:[grid-template-columns:var(--grid-cols)]", style: style, children: children }));
|
|
122
120
|
}
|
|
123
121
|
export function DefaultGridCell({ span, width, children }) {
|
|
124
122
|
const insideDrawerBody = useContext(DrawerBodyContext);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { TabsProps } from "../../index.ts";
|
|
3
|
-
export declare function DefaultTabs({ items, activeId, onSelect, testId }: TabsProps): ReactNode;
|
|
3
|
+
export declare function DefaultTabs({ items, activeId, onSelect, appearance, testId, }: TabsProps): ReactNode;
|
|
@@ -6,6 +6,14 @@ import { Tabs, TabsList, TabsTrigger } from "../ui/tabs.js";
|
|
|
6
6
|
// The underline is a real border-b-2 (board) instead of the vendored ::after bar, so the
|
|
7
7
|
// vendored active/dark border resets are overridden with identical variant chains.
|
|
8
8
|
const TAB_TRIGGER_CLASS = "h-full shrink-0 flex-none whitespace-nowrap rounded-none border-0 border-b-2 border-transparent focus-visible:border-transparent bg-transparent px-0 py-0 text-sm font-medium text-foreground-secondary after:hidden hover:text-foreground data-[state=active]:border-primary data-[state=active]:focus-visible:border-primary data-[state=active]:bg-transparent data-[state=active]:font-semibold data-[state=active]:text-foreground dark:text-foreground-secondary dark:data-[state=active]:border-primary dark:data-[state=active]:bg-transparent dark:data-[state=active]:text-foreground dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-primary";
|
|
9
|
+
// Strip inset and tab spacing per appearance. The muted looks pad each tab instead of the strip, so a
|
|
10
|
+
// tab's hover and underline span its label plus 10px; "filter" insets the strip so its first label
|
|
11
|
+
// lines up with a list pane's search field, "plain" sits flush with the content it switches.
|
|
12
|
+
const STRIP_SPACING = {
|
|
13
|
+
pill: { scroller: "px-1.5 @lg:px-6", list: "h-11 gap-2 @lg:gap-6", trigger: "" },
|
|
14
|
+
plain: { scroller: "px-0", list: "h-10 gap-1", trigger: "px-2.5 font-normal" },
|
|
15
|
+
filter: { scroller: "px-1.5", list: "h-10 gap-0", trigger: "px-2.5 font-normal" },
|
|
16
|
+
};
|
|
9
17
|
// A single fade-width both edges share — mask-image needs the same offset
|
|
10
18
|
// on each side or the gradient reads as lopsided.
|
|
11
19
|
const EDGE_FADE_PX = 24;
|
|
@@ -19,7 +27,7 @@ function edgeFadeMaskImage(start, end) {
|
|
|
19
27
|
return `linear-gradient(to left, transparent, black ${EDGE_FADE_PX}px)`;
|
|
20
28
|
return undefined;
|
|
21
29
|
}
|
|
22
|
-
export function DefaultTabs({ items, activeId, onSelect, testId }) {
|
|
30
|
+
export function DefaultTabs({ items, activeId, onSelect, appearance = "pill", testId, }) {
|
|
23
31
|
const scrollerRef = useRef(null);
|
|
24
32
|
// Two primitive booleans instead of one object: setState with a fresh
|
|
25
33
|
// object on every measurement would always change reference and force
|
|
@@ -101,7 +109,16 @@ export function DefaultTabs({ items, activeId, onSelect, testId }) {
|
|
|
101
109
|
};
|
|
102
110
|
}, [updateScrollEdges]);
|
|
103
111
|
const maskImage = edgeFadeMaskImage(scrollStart, scrollEnd);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
const spacing = STRIP_SPACING[appearance];
|
|
113
|
+
const isPill = appearance === "pill";
|
|
114
|
+
return (_jsx(Tabs, { value: activeId, onValueChange: onSelect, "data-testid": testId, className: "@container min-w-0", children: _jsx("div", { ref: scrollerRef, "data-scroll-start": scrollStart ? "" : undefined, "data-scroll-end": scrollEnd ? "" : undefined, className: cn("relative min-w-0 overflow-x-auto border-b border-border [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", spacing.scroller), style: maskImage !== undefined ? { maskImage, WebkitMaskImage: maskImage } : undefined, children: _jsx(TabsList, { variant: "line", className: cn("p-0", spacing.list), children: items.map((item) => (_jsxs(TabsTrigger, { value: item.id, className: cn(TAB_TRIGGER_CLASS, spacing.trigger), "aria-controls": undefined, "data-testid": testId !== undefined ? `${testId}-${item.id}` : undefined, children: [item.icon !== undefined && (_jsx("span", { "aria-hidden": "true", className: cn("inline-flex shrink-0",
|
|
115
|
+
// The trigger's own gap already spaces icon, label and count in the muted looks.
|
|
116
|
+
isPill ? "mr-1.5 [&>svg]:size-4" : "[&>svg]:size-3.5"), children: item.icon })), item.label, item.detail !== undefined && (_jsx("span", { className: cn("text-xs font-normal text-muted-foreground", isPill && "ml-1.5"), "data-testid": testId !== undefined ? `${testId}-${item.id}-detail` : undefined, children: item.detail })), item.count !== undefined && (_jsx("span", { className: cn(!isPill
|
|
117
|
+
? "text-xs font-normal text-muted-foreground tabular-nums"
|
|
118
|
+
: [
|
|
119
|
+
"ml-1.5 inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-[5px] text-xs font-medium",
|
|
120
|
+
item.id === activeId
|
|
121
|
+
? "bg-primary/10 text-foreground"
|
|
122
|
+
: "bg-status-neutral-surface text-foreground-secondary",
|
|
123
|
+
]), "data-testid": testId !== undefined ? `${testId}-${item.id}-count` : undefined, children: item.count }))] }, item.id))) }) }) }));
|
|
107
124
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import plugin from "tailwindcss/plugin";
|
|
2
2
|
import { type DefaultColorScheme } from "./default-color-scheme.ts";
|
|
3
|
-
export declare const FRAMEWORK_COLOR_NAMES: readonly ["background", "foreground", "foreground-secondary", "foreground-disabled", "card", "card-foreground", "popover", "popover-foreground", "primary", "primary-foreground", "secondary", "secondary-foreground", "muted", "muted-foreground", "accent", "accent-foreground", "destructive", "destructive-foreground", "border", "border-strong", "border-row", "input", "ring", "sidebar", "sidebar-foreground", "sidebar-primary", "sidebar-primary-foreground", "sidebar-accent", "sidebar-accent-foreground", "sidebar-muted", "sidebar-input", "sidebar-border", "sidebar-ring", "status-ok", "status-ok-surface", "status-warn", "status-warn-surface", "status-bad", "status-bad-surface", "status-critical", "status-critical-surface", "status-neutral", "status-neutral-surface", "status-active", "status-active-surface", "syntax-key", "syntax-string", "syntax-number", "syntax-literal", "promo", "promo-foreground", "promo-accent", "promo-accent-foreground"];
|
|
3
|
+
export declare const FRAMEWORK_COLOR_NAMES: readonly ["background", "foreground", "foreground-secondary", "foreground-disabled", "card", "card-foreground", "popover", "popover-foreground", "primary", "primary-foreground", "secondary", "secondary-foreground", "muted", "muted-foreground", "accent", "accent-foreground", "destructive", "destructive-foreground", "border", "border-strong", "border-row", "input", "ring", "sidebar", "sidebar-foreground", "sidebar-primary", "sidebar-primary-foreground", "sidebar-accent", "sidebar-accent-foreground", "sidebar-muted", "sidebar-input", "sidebar-border", "sidebar-ring", "status-ok", "status-ok-surface", "status-warn", "status-warn-surface", "status-bad", "status-bad-surface", "status-critical", "status-critical-surface", "status-neutral", "status-neutral-surface", "status-active", "status-active-surface", "sender-frame", "sender-frame-border", "sender-sheet", "ai-surface", "search-hit", "search-hit-active", "source-mark", "syntax-key", "syntax-string", "syntax-number", "syntax-literal", "promo", "promo-foreground", "promo-accent", "promo-accent-foreground"];
|
|
4
4
|
export type FrameworkColorName = (typeof FRAMEWORK_COLOR_NAMES)[number];
|
|
5
5
|
/** A plain string applies to both modes; `dark` falls back to `light`. */
|
|
6
6
|
export type ThemeColorValue = string | {
|
package/dist/web/theme-plugin.js
CHANGED
|
@@ -46,6 +46,13 @@ export const FRAMEWORK_COLOR_NAMES = [
|
|
|
46
46
|
"status-neutral-surface",
|
|
47
47
|
"status-active",
|
|
48
48
|
"status-active-surface",
|
|
49
|
+
"sender-frame",
|
|
50
|
+
"sender-frame-border",
|
|
51
|
+
"sender-sheet",
|
|
52
|
+
"ai-surface",
|
|
53
|
+
"search-hit",
|
|
54
|
+
"search-hit-active",
|
|
55
|
+
"source-mark",
|
|
49
56
|
"syntax-key",
|
|
50
57
|
"syntax-string",
|
|
51
58
|
"syntax-number",
|
package/dist/web/ui/sidebar.js
CHANGED
|
@@ -42,8 +42,11 @@ function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange: set
|
|
|
42
42
|
else {
|
|
43
43
|
_setOpen(openState);
|
|
44
44
|
}
|
|
45
|
-
// This sets the cookie to keep the sidebar state.
|
|
46
|
-
|
|
45
|
+
// This sets the cookie to keep the sidebar state. A controlled caller owns
|
|
46
|
+
// persistence; DefaultAppShell's focused-screen rail must not overwrite the user's choice.
|
|
47
|
+
if (!setOpenProp) {
|
|
48
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
49
|
+
}
|
|
47
50
|
}, [setOpenProp, open]);
|
|
48
51
|
// Helper to toggle the sidebar.
|
|
49
52
|
const toggleSidebar = React.useCallback(() => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { InputEndAction } from "../../primitives.tsx";
|
|
3
|
+
export type AiTextEndAction = InputEndAction;
|
|
4
|
+
/** Keeps typed text clear of the end action; a text button needs more room than an icon. */
|
|
5
|
+
export declare function endActionPaddingClass(action: AiTextEndAction | undefined): string | undefined;
|
|
6
|
+
/** Icon button inside the right edge of the input, e.g. a microphone. */
|
|
7
|
+
export declare function AiTextEndActionButton({ action, multiline, disabled, testId, }: {
|
|
8
|
+
readonly action: AiTextEndAction;
|
|
9
|
+
readonly multiline: boolean;
|
|
10
|
+
readonly disabled: boolean;
|
|
11
|
+
readonly testId: string | undefined;
|
|
12
|
+
}): ReactNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
/** Keeps typed text clear of the end action; a text button needs more room than an icon. */
|
|
4
|
+
export function endActionPaddingClass(action) {
|
|
5
|
+
if (action === undefined)
|
|
6
|
+
return undefined;
|
|
7
|
+
return action.label !== undefined ? "pr-28" : "pr-11";
|
|
8
|
+
}
|
|
9
|
+
/** Icon button inside the right edge of the input, e.g. a microphone. */
|
|
10
|
+
export function AiTextEndActionButton({ action, multiline, disabled, testId, }) {
|
|
11
|
+
if (action.label !== undefined) {
|
|
12
|
+
return (_jsx("button", { type: "button", disabled: disabled, onClick: action.onClick, "data-testid": testId !== undefined ? `${testId}-end-action` : undefined, className: cn("absolute right-1 z-10 flex h-7 items-center rounded-md border-0 bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50", multiline ? "top-1" : "top-1/2 -translate-y-1/2"), children: action.label }));
|
|
13
|
+
}
|
|
14
|
+
return (_jsx("button", { type: "button", "aria-label": action.ariaLabel, "aria-pressed": action.pressed, disabled: disabled, onClick: action.onClick, "data-testid": testId !== undefined ? `${testId}-end-action` : undefined, className: cn("absolute right-1.5 z-10 flex size-8 items-center justify-center rounded-md border-0 bg-transparent p-0 text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50 aria-pressed:bg-accent aria-pressed:text-foreground [&>svg]:size-4", multiline ? "top-1.5" : "top-1/2 -translate-y-1/2"), children: action.icon }));
|
|
15
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import { type AiTextEndAction } from "./ai-text-end-action.tsx";
|
|
2
3
|
type AiTextAction = "correct" | "translate" | "rewrite";
|
|
3
4
|
interface AiTextFieldBaseProps {
|
|
4
5
|
readonly label: string;
|
|
@@ -21,6 +22,8 @@ interface AiTextFieldBaseProps {
|
|
|
21
22
|
/** Target languages the translate action offers. First is preselected.
|
|
22
23
|
* Default `["en", "de", "fr", "es"]`. */
|
|
23
24
|
readonly translateLanguages?: readonly string[];
|
|
25
|
+
/** Icon button inside the right edge of the control (e.g. a microphone). */
|
|
26
|
+
readonly endAction?: AiTextEndAction;
|
|
24
27
|
}
|
|
25
28
|
export interface AiTextFieldProps extends AiTextFieldBaseProps {
|
|
26
29
|
}
|
|
@@ -25,6 +25,7 @@ import { Check, Languages, Wand2 } from "lucide-react";
|
|
|
25
25
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
26
26
|
import { useAiTextAction, useCompletion, usePrimitives, useTranslation } from "../../index.js";
|
|
27
27
|
import { cn } from "../lib/cn.js";
|
|
28
|
+
import { AiTextEndActionButton, endActionPaddingClass, } from "./ai-text-end-action.js";
|
|
28
29
|
import { ModeSwitch } from "./mode-switch.js";
|
|
29
30
|
const DEFAULT_LANGUAGES = ["en", "de", "fr", "es"];
|
|
30
31
|
const DEFAULT_ACTIONS = ["correct", "translate", "rewrite"];
|
|
@@ -37,7 +38,7 @@ const sharedTextClass = "w-full rounded-md border border-input px-3 py-2 text-sm
|
|
|
37
38
|
// horizontally, <textarea> soft-wraps and scrolls vertically.
|
|
38
39
|
const singleLineWrapClass = "whitespace-pre overflow-hidden";
|
|
39
40
|
const multilineWrapClass = "whitespace-pre-wrap break-words overflow-hidden";
|
|
40
|
-
function AiTextCore({ multiline, label, id, name, value, onChange, required, disabled, placeholder, testId, hideLabel, rows, completion = true, completionDebounceMs = 500, actions = DEFAULT_ACTIONS, translateLanguages = DEFAULT_LANGUAGES, }) {
|
|
41
|
+
function AiTextCore({ multiline, label, id, name, value, onChange, required, disabled, placeholder, testId, hideLabel, rows, completion = true, completionDebounceMs = 500, actions = DEFAULT_ACTIONS, translateLanguages = DEFAULT_LANGUAGES, endAction, }) {
|
|
41
42
|
const { Field, Button, Dialog, Text } = usePrimitives();
|
|
42
43
|
const t = useTranslation();
|
|
43
44
|
const { suggestion, state: completionState, requestCompletion, clear: clearCompletion, } = useCompletion(completionDebounceMs);
|
|
@@ -112,12 +113,12 @@ function AiTextCore({ multiline, label, id, name, value, onChange, required, dis
|
|
|
112
113
|
}, id: id, name: name, value: value, required: required, disabled: disabled === true || unavailable, placeholder: placeholder, rows: rows ?? 4, onChange: (e) => handleChange(e.target.value), onKeyDown: handleKeyDown, onBlur: clearCompletion, onScroll: (e) => {
|
|
113
114
|
if (overlayRef.current)
|
|
114
115
|
overlayRef.current.scrollTop = e.currentTarget.scrollTop;
|
|
115
|
-
}, className: cn(sharedTextClass, multilineWrapClass, "relative resize-y bg-transparent"), "data-testid": testId !== undefined ? `${testId}-input` : undefined })) : (_jsx("input", { ref: (el) => {
|
|
116
|
+
}, className: cn(sharedTextClass, multilineWrapClass, "relative resize-y bg-transparent", endActionPaddingClass(endAction)), "data-testid": testId !== undefined ? `${testId}-input` : undefined })) : (_jsx("input", { ref: (el) => {
|
|
116
117
|
controlRef.current = el;
|
|
117
118
|
}, id: id, name: name, type: "text", value: value, required: required, disabled: disabled === true || unavailable, placeholder: placeholder, onChange: (e) => handleChange(e.target.value), onKeyDown: handleKeyDown, onBlur: clearCompletion, onScroll: (e) => {
|
|
118
119
|
if (overlayRef.current)
|
|
119
120
|
overlayRef.current.scrollLeft = e.currentTarget.scrollLeft;
|
|
120
|
-
}, className: cn(sharedTextClass, singleLineWrapClass, "relative bg-transparent"), "data-testid": testId !== undefined ? `${testId}-input` : undefined }))] }), showGhost && _jsx(Text, { variant: "muted", children: t("kumiko.aiText.acceptHint") }), capExceeded && _jsx(Text, { variant: "muted", children: t("kumiko.aiText.capExceeded") }), showToolbar && (_jsxs("div", { className: "mt-1 flex gap-1", children: [actions.includes("correct") && (_jsx(Button, { variant: "secondary", size: "sm", disabled: value.length === 0, ariaLabel: t("kumiko.aiText.correct"), onClick: () => openDialog("correct"), children: _jsx(Check, { className: "size-3.5", "aria-hidden": "true" }) })), actions.includes("translate") && (_jsx(Button, { variant: "secondary", size: "sm", disabled: value.length === 0, ariaLabel: t("kumiko.aiText.translate"), onClick: () => openDialog("translate"), children: _jsx(Languages, { className: "size-3.5", "aria-hidden": "true" }) })), actions.includes("rewrite") && (_jsx(Button, { variant: "secondary", size: "sm", disabled: value.length === 0, ariaLabel: t("kumiko.aiText.rewrite"), onClick: () => openDialog("rewrite"), children: _jsx(Wand2, { className: "size-3.5", "aria-hidden": "true" }) }))] }))] }), _jsxs(Dialog, { open: dialogMode !== null, onOpenChange: (open) => {
|
|
121
|
+
}, className: cn(sharedTextClass, singleLineWrapClass, "relative bg-transparent", endActionPaddingClass(endAction)), "data-testid": testId !== undefined ? `${testId}-input` : undefined })), endAction !== undefined && (_jsx(AiTextEndActionButton, { action: endAction, multiline: multiline, disabled: disabled === true || unavailable, testId: testId }))] }), showGhost && _jsx(Text, { variant: "muted", children: t("kumiko.aiText.acceptHint") }), capExceeded && _jsx(Text, { variant: "muted", children: t("kumiko.aiText.capExceeded") }), showToolbar && (_jsxs("div", { className: "mt-1 flex gap-1", children: [actions.includes("correct") && (_jsx(Button, { variant: "secondary", size: "sm", disabled: value.length === 0, ariaLabel: t("kumiko.aiText.correct"), onClick: () => openDialog("correct"), children: _jsx(Check, { className: "size-3.5", "aria-hidden": "true" }) })), actions.includes("translate") && (_jsx(Button, { variant: "secondary", size: "sm", disabled: value.length === 0, ariaLabel: t("kumiko.aiText.translate"), onClick: () => openDialog("translate"), children: _jsx(Languages, { className: "size-3.5", "aria-hidden": "true" }) })), actions.includes("rewrite") && (_jsx(Button, { variant: "secondary", size: "sm", disabled: value.length === 0, ariaLabel: t("kumiko.aiText.rewrite"), onClick: () => openDialog("rewrite"), children: _jsx(Wand2, { className: "size-3.5", "aria-hidden": "true" }) }))] }))] }), _jsxs(Dialog, { open: dialogMode !== null, onOpenChange: (open) => {
|
|
121
122
|
if (!open)
|
|
122
123
|
closeDialog();
|
|
123
124
|
}, title: dialogMode !== null ? t(`kumiko.aiText.${dialogMode}`) : "", onConfirm: applyResult, testId: testId !== undefined ? `${testId}-dialog` : undefined, children: [dialogMode === "translate" && needsConfig && (_jsxs("div", { className: "mb-3 flex flex-col gap-2", children: [_jsx(ModeSwitch, { value: targetLanguage, options: translateLanguages.map((l) => ({ value: l, label: l.toUpperCase() })), onChange: setTargetLanguage }), _jsx(Button, { variant: "primary", size: "sm", onClick: runConfiguredAction, children: t(`kumiko.aiText.${dialogMode}`) })] })), dialogMode === "rewrite" && needsConfig && (_jsxs("div", { className: "mb-3 flex flex-col gap-2", children: [_jsx(ModeSwitch, { value: rewriteStyle, options: REWRITE_STYLES.map((s) => ({
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { MessageAttachment } from "./message-types.ts";
|
|
3
|
+
/** Full-width attachment row with a thumbnail box, name, second line and an "open original" link or button. */
|
|
4
|
+
export declare function AttachmentCard({ name, meta, kind, thumbnailUrl, onOpen, href, testId, }: Omit<MessageAttachment, "id"> & {
|
|
5
|
+
readonly testId?: string;
|
|
6
|
+
}): ReactNode;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from "../../index.js";
|
|
3
|
+
import { attachmentIconFor } from "./attachment-chip.js";
|
|
4
|
+
const OPEN_LINK_CLASS = "shrink-0 border-0 bg-transparent p-0 text-[13px] font-medium text-primary underline underline-offset-2";
|
|
5
|
+
/** Full-width attachment row with a thumbnail box, name, second line and an "open original" link or button. */
|
|
6
|
+
export function AttachmentCard({ name, meta, kind, thumbnailUrl, onOpen, href, testId, }) {
|
|
7
|
+
const t = useTranslation();
|
|
8
|
+
const Icon = attachmentIconFor(kind);
|
|
9
|
+
const openLabel = t("kumiko.widget.attachment-card.openOriginal");
|
|
10
|
+
return (_jsxs("div", { "data-testid": testId, className: "flex items-center gap-2 rounded-md border border-border px-2.5 py-2", children: [_jsx("span", { className: "flex h-[52px] w-10 shrink-0 items-center justify-center overflow-hidden rounded-[3px] border border-border bg-sender-frame text-muted-foreground", children: thumbnailUrl !== undefined ? (_jsx("img", { src: thumbnailUrl, alt: "", className: "size-full object-cover" })) : (_jsx(Icon, { "aria-hidden": "true", className: "size-4" })) }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "truncate font-medium", children: name }), meta !== undefined && (_jsx("span", { className: "text-xs tabular-nums text-muted-foreground", children: meta }))] }), href !== undefined ? (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", className: OPEN_LINK_CLASS, onClick: onOpen, children: openLabel })) : (onOpen !== undefined && (_jsx("button", { type: "button", className: OPEN_LINK_CLASS, onClick: onOpen, children: openLabel })))] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type LucideIcon } from "lucide-react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { MessageAttachment } from "./message-types.ts";
|
|
4
|
+
export declare function attachmentIconFor(kind: MessageAttachment["kind"]): LucideIcon;
|
|
5
|
+
/** File chip with icon, name and a second line; renders as link, button or plain box depending on href/onOpen. */
|
|
6
|
+
export declare function AttachmentChip({ name, meta, kind, onOpen, href, testId, }: MessageAttachment & {
|
|
7
|
+
readonly testId?: string;
|
|
8
|
+
}): ReactNode;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FileText, Image, Paperclip } from "lucide-react";
|
|
3
|
+
const CHIP_CLASS = "inline-flex h-11 items-center gap-2.5 rounded-md border border-border bg-transparent py-0 pl-1 pr-3 text-left text-foreground no-underline";
|
|
4
|
+
export function attachmentIconFor(kind) {
|
|
5
|
+
return kind === "image" ? Image : kind === "pdf" ? FileText : Paperclip;
|
|
6
|
+
}
|
|
7
|
+
function AttachmentIcon({ kind }) {
|
|
8
|
+
const Icon = attachmentIconFor(kind);
|
|
9
|
+
return (_jsx("span", { className: "flex size-9 shrink-0 items-center justify-center rounded bg-sender-frame text-muted-foreground", children: _jsx(Icon, { "aria-hidden": "true", className: "size-4" }) }));
|
|
10
|
+
}
|
|
11
|
+
/** File chip with icon, name and a second line; renders as link, button or plain box depending on href/onOpen. */
|
|
12
|
+
export function AttachmentChip({ name, meta, kind, onOpen, href, testId, }) {
|
|
13
|
+
const content = (_jsxs(_Fragment, { children: [_jsx(AttachmentIcon, { kind: kind }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: "truncate text-[13px] font-medium", children: name }), meta !== undefined && _jsx("span", { className: "text-xs text-muted-foreground", children: meta })] })] }));
|
|
14
|
+
if (href !== undefined) {
|
|
15
|
+
return (_jsx("a", { href: href, "data-testid": testId, className: CHIP_CLASS, onClick: onOpen, children: content }));
|
|
16
|
+
}
|
|
17
|
+
if (onOpen !== undefined) {
|
|
18
|
+
return (_jsx("button", { type: "button", "data-testid": testId, className: CHIP_CLASS, onClick: onOpen, children: content }));
|
|
19
|
+
}
|
|
20
|
+
return (_jsx("div", { "data-testid": testId, className: CHIP_CLASS, children: content }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/** Clamps content to `lines`; the toggle shows only while the content actually overflows. */
|
|
3
|
+
export declare function ClampedText({ children, lines, moreLabelKey, maxHeightPx, testId, }: {
|
|
4
|
+
readonly children: ReactNode;
|
|
5
|
+
readonly lines?: number;
|
|
6
|
+
/** Translation key of the toggle while the content is clamped. */
|
|
7
|
+
readonly moreLabelKey?: string;
|
|
8
|
+
/** Clamps by height instead of lines, for content line-clamp cannot reach such as a framed html mail. */
|
|
9
|
+
readonly maxHeightPx?: number;
|
|
10
|
+
readonly testId?: string;
|
|
11
|
+
}): ReactNode;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { usePrimitives, useTranslation } from "../../index.js";
|
|
4
|
+
const DEFAULT_CLAMP_LINES = 16;
|
|
5
|
+
/** Clamps content to `lines`; the toggle shows only while the content actually overflows. */
|
|
6
|
+
export function ClampedText({ children, lines = DEFAULT_CLAMP_LINES, moreLabelKey = "kumiko.widget.message-thread.showMore", maxHeightPx, testId, }) {
|
|
7
|
+
const t = useTranslation();
|
|
8
|
+
const { Button } = usePrimitives();
|
|
9
|
+
const contentRef = useRef(null);
|
|
10
|
+
const [expanded, setExpanded] = useState(false);
|
|
11
|
+
const [overflows, setOverflows] = useState(false);
|
|
12
|
+
// Expanded content never overflows its own box, so only the clamped state is measured.
|
|
13
|
+
useLayoutEffect(() => {
|
|
14
|
+
const element = contentRef.current;
|
|
15
|
+
if (element === null || expanded)
|
|
16
|
+
return undefined;
|
|
17
|
+
const measure = () => setOverflows(element.scrollHeight > element.clientHeight);
|
|
18
|
+
measure();
|
|
19
|
+
const observer = new ResizeObserver(measure);
|
|
20
|
+
observer.observe(element);
|
|
21
|
+
return () => observer.disconnect();
|
|
22
|
+
}, [expanded]);
|
|
23
|
+
return (_jsxs("div", { "data-testid": testId, className: "flex flex-col items-start gap-1", children: [_jsx("div", { ref: contentRef, className: "w-full", style: expanded
|
|
24
|
+
? undefined
|
|
25
|
+
: maxHeightPx !== undefined
|
|
26
|
+
? {
|
|
27
|
+
maxHeight: maxHeightPx,
|
|
28
|
+
overflow: "hidden",
|
|
29
|
+
// A height cut can fall through a line; the fade keeps that from reading as broken text.
|
|
30
|
+
maskImage: "linear-gradient(to bottom, black 60%, transparent)",
|
|
31
|
+
}
|
|
32
|
+
: {
|
|
33
|
+
display: "-webkit-box",
|
|
34
|
+
WebkitBoxOrient: "vertical",
|
|
35
|
+
WebkitLineClamp: lines,
|
|
36
|
+
overflow: "hidden",
|
|
37
|
+
}, children: children }), (overflows || expanded) && (_jsx(Button, { variant: "link", size: "sm", expanded: expanded, onClick: () => setExpanded((current) => !current), children: t(expanded ? "kumiko.widget.message-thread.showLess" : moreLabelKey) }))] }));
|
|
38
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
type MailFrameStyle = {
|
|
3
|
+
readonly fontFamily: string;
|
|
4
|
+
readonly color: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function buildMailSrcDoc(html: string, options: {
|
|
7
|
+
readonly allowRemoteImages: boolean;
|
|
8
|
+
readonly style: MailFrameStyle;
|
|
9
|
+
}): string;
|
|
10
|
+
/** Renders server-sanitized mail HTML in a script-free sandboxed iframe that grows to its content. */
|
|
11
|
+
export declare function HtmlMailFrame({ html, title, allowRemoteImages, testId, }: {
|
|
12
|
+
readonly html: string;
|
|
13
|
+
readonly title: string;
|
|
14
|
+
readonly allowRemoteImages: boolean;
|
|
15
|
+
readonly testId?: string;
|
|
16
|
+
}): ReactNode;
|
|
17
|
+
export {};
|