@cosmicdrift/kumiko-renderer 0.416.0 → 0.418.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.d.ts +1 -4
- package/dist/app/action-form-body.js +14 -9
- package/dist/app/action-form-preview.d.ts +13 -0
- package/dist/app/action-form-preview.js +66 -0
- package/dist/app/action-form-support.d.ts +6 -1
- package/dist/app/action-form-support.js +26 -9
- package/dist/app/config-edit-body.js +71 -79
- package/dist/app/entity-list-screen.js +1 -1
- package/dist/app/header-actions-bar.d.ts +3 -1
- package/dist/app/header-actions-bar.js +12 -4
- package/dist/app/list-bulk-actions.d.ts +8 -1
- package/dist/app/list-bulk-actions.js +28 -4
- package/dist/app/locked-screen-header.d.ts +2 -0
- package/dist/app/locked-screen-header.js +8 -1
- package/dist/app/projection-detail-body.js +24 -5
- package/dist/app/projection-detail-guidance.d.ts +1 -0
- package/dist/app/projection-detail-guidance.js +7 -4
- package/dist/app/projection-detail-header-model.js +4 -1
- package/dist/app/projection-detail-header-region.js +25 -9
- package/dist/app/projection-detail-header.d.ts +2 -0
- package/dist/app/projection-detail-header.js +30 -3
- package/dist/app/projection-list-shim.js +1 -0
- package/dist/app/row-actions.d.ts +4 -0
- package/dist/app/row-actions.js +19 -3
- package/dist/app/use-projection-detail-actions.d.ts +3 -1
- package/dist/app/use-projection-detail-actions.js +9 -1
- package/dist/app/use-projection-detail-data.js +17 -1
- package/dist/app/use-projection-list-data.js +1 -1
- package/dist/card-options.d.ts +2 -0
- package/dist/components/choice-chip-class.d.ts +1 -0
- package/dist/components/choice-chip-class.js +9 -0
- package/dist/components/edit-mounts.d.ts +1 -1
- package/dist/components/embedded-list-paste.js +2 -2
- package/dist/components/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.js +7 -2
- package/dist/components/multi-select-count.d.ts +5 -0
- package/dist/components/multi-select-count.js +10 -0
- package/dist/components/narrow-description.d.ts +3 -0
- package/dist/components/narrow-description.js +12 -0
- package/dist/components/related-list-section.d.ts +5 -3
- package/dist/components/related-list-section.js +9 -4
- package/dist/components/related-photo-grid.js +17 -3
- package/dist/components/render-edit-field-grid.d.ts +12 -3
- package/dist/components/render-edit-field-grid.js +60 -18
- package/dist/components/render-edit-fields-section.js +45 -11
- package/dist/components/render-edit-header-actions.js +1 -1
- package/dist/components/render-edit-layout.js +5 -3
- package/dist/components/render-edit-section-kinds.js +50 -12
- package/dist/components/render-edit-titles.js +1 -1
- package/dist/components/render-edit-types.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +26 -7
- package/dist/components/render-field-choice-inputs.js +3 -0
- package/dist/components/render-field-control.js +1 -1
- package/dist/components/render-field-value-chips.js +6 -4
- package/dist/components/render-field-values.js +3 -3
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +30 -5
- package/dist/components/render-list-reference-columns.js +2 -4
- package/dist/components/render-list-row-tone.d.ts +2 -0
- package/dist/components/render-list-row-tone.js +6 -0
- package/dist/components/render-list-table-props.d.ts +13 -2
- package/dist/components/render-list-table-props.js +9 -3
- package/dist/components/render-list-types.d.ts +4 -0
- package/dist/components/render-list.js +12 -4
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/components/write-form-registry.d.ts +13 -0
- package/dist/components/write-form-registry.js +6 -0
- package/dist/components/write-form-section.d.ts +5 -1
- package/dist/components/write-form-section.js +55 -16
- package/dist/data-table-bulk-types.d.ts +11 -2
- package/dist/data-table-bulk-types.js +3 -1
- package/dist/headless/form/form-controller.d.ts +2 -0
- package/dist/headless/form/form-controller.js +2 -2
- package/dist/headless/format/index.d.ts +1 -1
- package/dist/headless/format/index.js +6 -5
- package/dist/headless/format/money.d.ts +5 -0
- package/dist/headless/format/money.js +10 -0
- package/dist/headless/format/relative-time.d.ts +2 -0
- package/dist/headless/format/relative-time.js +4 -1
- package/dist/headless/index.d.ts +1 -1
- package/dist/headless/index.js +1 -1
- package/dist/headless/view-model/edit.js +87 -37
- package/dist/headless/view-model/list.js +6 -0
- package/dist/headless/view-model/types.d.ts +50 -5
- package/dist/hooks/use-bulk-run.d.ts +2 -2
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +8 -2
- package/dist/primitives-record-guidance.d.ts +4 -0
- package/dist/primitives-share-types.d.ts +82 -0
- package/dist/primitives-share-types.js +1 -0
- package/dist/primitives.d.ts +34 -83
- package/dist/web/app/bold-markup.d.ts +3 -0
- package/dist/web/app/bold-markup.js +14 -0
- package/dist/web/app/dashboard-body.js +5 -1
- package/dist/web/app/dashboard-list-panel.js +7 -4
- package/dist/web/app/dashboard-panels.js +31 -3
- package/dist/web/app/dashboard-shared.d.ts +3 -1
- package/dist/web/app/dashboard-shared.js +3 -3
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +16 -2
- package/dist/web/app/dashboard-text-panel.js +11 -6
- package/dist/web/app/relative-time.js +10 -1
- package/dist/web/components/config-cascade.d.ts +2 -1
- package/dist/web/components/config-cascade.js +16 -4
- package/dist/web/drawn-icons.js +2 -1
- package/dist/web/layout/header-action-pinned.d.ts +4 -2
- package/dist/web/layout/header-action-pinned.js +13 -4
- package/dist/web/layout/header-overflow-menu.d.ts +2 -0
- package/dist/web/layout/header-overflow-menu.js +2 -0
- package/dist/web/layout/nav-tree.js +1 -1
- package/dist/web/layout/notification-bell.js +13 -4
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.js +4 -1
- package/dist/web/layout/shell-header.js +15 -7
- package/dist/web/primitives/banner.js +14 -3
- package/dist/web/primitives/card.js +5 -3
- package/dist/web/primitives/combobox.js +2 -2
- package/dist/web/primitives/data-table/actions-column.js +1 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +37 -14
- package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
- package/dist/web/primitives/data-table/card-frame.js +3 -0
- package/dist/web/primitives/data-table/card-row.js +28 -9
- package/dist/web/primitives/data-table/card-sort-select.js +1 -1
- package/dist/web/primitives/data-table/card-view.js +1 -1
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -1
- package/dist/web/primitives/data-table/data-cell-props.js +1 -0
- package/dist/web/primitives/data-table/density.d.ts +3 -1
- package/dist/web/primitives/data-table/density.js +11 -4
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -5
- package/dist/web/primitives/data-table/sort-options-select.js +2 -2
- package/dist/web/primitives/data-table/sortable-header.js +4 -4
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-chrome.js +1 -3
- package/dist/web/primitives/data-table/table-content.js +7 -11
- package/dist/web/primitives/data-table/table-data-cell.js +31 -17
- package/dist/web/primitives/data-table/table-header-row.js +1 -1
- package/dist/web/primitives/data-table/table-view.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +6 -7
- package/dist/web/primitives/data-table/use-bulk-selection.d.ts +1 -1
- package/dist/web/primitives/data-table/use-bulk-selection.js +5 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
- package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
- package/dist/web/primitives/data-table-cell.d.ts +13 -2
- package/dist/web/primitives/data-table-cell.js +125 -53
- package/dist/web/primitives/data-table.js +1 -1
- package/dist/web/primitives/default-form.d.ts +1 -1
- package/dist/web/primitives/default-form.js +11 -10
- package/dist/web/primitives/drawer.js +2 -7
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +2 -5
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
- package/dist/web/primitives/facet-trigger-label.js +4 -7
- package/dist/web/primitives/field.js +15 -8
- package/dist/web/primitives/form-footer-parts.js +2 -2
- package/dist/web/primitives/inline-suffix.d.ts +2 -0
- package/dist/web/primitives/inline-suffix.js +5 -0
- package/dist/web/primitives/input-choice-kinds.js +12 -2
- package/dist/web/primitives/input-number-kinds.js +2 -2
- package/dist/web/primitives/input-text-kinds.js +1 -1
- package/dist/web/primitives/layout-elements.d.ts +4 -4
- package/dist/web/primitives/layout-elements.js +49 -12
- package/dist/web/primitives/layout.d.ts +1 -1
- package/dist/web/primitives/layout.js +1 -1
- package/dist/web/primitives/metric.js +4 -5
- package/dist/web/primitives/money-input.js +8 -7
- package/dist/web/primitives/number-input.d.ts +2 -1
- package/dist/web/primitives/number-input.js +9 -4
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +12 -21
- package/dist/web/primitives/photo-grid.js +2 -1
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +6 -15
- package/dist/web/primitives/row-actions.js +38 -24
- package/dist/web/primitives/use-container-narrow.d.ts +12 -0
- package/dist/web/primitives/use-container-narrow.js +42 -0
- package/dist/web/pwa/pwa-support.js +13 -7
- package/dist/web/ui/input.js +1 -1
- package/dist/web/ui/textarea.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.js +6 -3
- package/dist/web/widgets/dashboard-list.d.ts +4 -1
- package/dist/web/widgets/dashboard-list.js +10 -5
- package/dist/web/widgets/progress-list.js +1 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +51 -0
- package/src/web/styles.css +3 -2
|
@@ -7,6 +7,7 @@ export type NumberInputProps = {
|
|
|
7
7
|
readonly locale?: string;
|
|
8
8
|
readonly grouping?: boolean;
|
|
9
9
|
readonly integer?: boolean;
|
|
10
|
+
readonly suffix?: string;
|
|
10
11
|
readonly disabled?: boolean;
|
|
11
12
|
readonly required?: boolean;
|
|
12
13
|
readonly hasError?: boolean;
|
|
@@ -16,4 +17,4 @@ export type NumberInputProps = {
|
|
|
16
17
|
readonly ariaDescribedBy?: string;
|
|
17
18
|
readonly ariaLabel?: string;
|
|
18
19
|
};
|
|
19
|
-
export declare function NumberInput({ id, name, value, onChange, locale, grouping, integer, disabled, required, hasError, placeholder, testId, className, ariaDescribedBy, ariaLabel, }: NumberInputProps): ReactNode;
|
|
20
|
+
export declare function NumberInput({ id, name, value, onChange, locale, grouping, integer, suffix, disabled, required, hasError, placeholder, testId, className, ariaDescribedBy, ariaLabel, }: NumberInputProps): ReactNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// NumberInput — type=text with a focus-aware locale format, so a blurred
|
|
3
3
|
// value shows thousands separators ("28.000") while editing shows the raw
|
|
4
4
|
// locale string ("28000"). Not type=number: browsers reject formatted
|
|
@@ -10,8 +10,9 @@ import { useLayoutEffect, useRef, useState } from "react";
|
|
|
10
10
|
import { resolveSafeLocale } from "../../headless/format/safe-locale.js";
|
|
11
11
|
import { cn } from "../lib/cn.js";
|
|
12
12
|
import { Input as UiInput } from "../ui/input.js";
|
|
13
|
+
import { inlineSuffixStyle } from "./inline-suffix.js";
|
|
13
14
|
import { formatLocaleNumber, parseLocaleNumber } from "./locale-number.js";
|
|
14
|
-
export function NumberInput({ id, name, value, onChange, locale, grouping = true, integer = false, disabled, required, hasError, placeholder, testId, className, ariaDescribedBy, ariaLabel, }) {
|
|
15
|
+
export function NumberInput({ id, name, value, onChange, locale, grouping = true, integer = false, suffix, disabled, required, hasError, placeholder, testId, className, ariaDescribedBy, ariaLabel, }) {
|
|
15
16
|
const resolvedLocale = resolveSafeLocale(locale);
|
|
16
17
|
const [focused, setFocused] = useState(false);
|
|
17
18
|
const [draft, setDraft] = useState("");
|
|
@@ -40,8 +41,12 @@ export function NumberInput({ id, name, value, onChange, locale, grouping = true
|
|
|
40
41
|
}
|
|
41
42
|
onChange(parsed);
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
+
const shownText = focused ? draft : format(grouping);
|
|
45
|
+
const input = (_jsx(UiInput, { ref: inputRef, type: "text", inputMode: integer ? "numeric" : "decimal", autoComplete: "off", id: id, name: name, disabled: disabled, "aria-required": required, "aria-invalid": hasError === true ? true : undefined, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "data-testid": testId, value: shownText, onFocus: () => {
|
|
44
46
|
setDraft(format(false));
|
|
45
47
|
setFocused(true);
|
|
46
|
-
}, onBlur: () => setFocused(false), onChange: (e) => handleChange(e.target.value), ...(placeholder !== undefined && { placeholder }), className: cn("text-left tabular-nums", className) }));
|
|
48
|
+
}, onBlur: () => setFocused(false), onChange: (e) => handleChange(e.target.value), ...(placeholder !== undefined && { placeholder }), className: cn("text-left tabular-nums", suffix !== undefined && "pr-8", className) }));
|
|
49
|
+
if (suffix === undefined)
|
|
50
|
+
return input;
|
|
51
|
+
return (_jsxs("div", { className: "relative", children: [input, _jsx("span", { style: inlineSuffixStyle(shownText), className: "pointer-events-none absolute top-1/2 -translate-y-1/2 select-none text-sm text-muted-foreground", children: suffix })] }));
|
|
47
52
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { PageHeaderProps } from "../../index.ts";
|
|
3
|
-
export declare function DefaultPageHeader({ title, recordTitle, status, actions, bodyTitle, overflowItems, hideBreadcrumb, breadcrumbScreenId, }: PageHeaderProps): ReactNode;
|
|
3
|
+
export declare function DefaultPageHeader({ title, recordTitle, narrowRecordTitle, status, actions, bodyTitle, overflowItems, hideBreadcrumb, breadcrumbScreenId, }: PageHeaderProps): ReactNode;
|
|
@@ -4,11 +4,12 @@ import { createPortal } from "react-dom";
|
|
|
4
4
|
import { usePageHeaderSlot } from "../layout/page-header-slot.js";
|
|
5
5
|
import { UNIFORM_BAR_CONTROLS_CLASSES } from "../layout/uniform-bar-controls.js";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
|
-
export function DefaultPageHeader({ title, recordTitle, status, actions, bodyTitle, overflowItems, hideBreadcrumb, breadcrumbScreenId, }) {
|
|
7
|
+
export function DefaultPageHeader({ title, recordTitle, narrowRecordTitle, status, actions, bodyTitle, overflowItems, hideBreadcrumb, breadcrumbScreenId, }) {
|
|
8
8
|
const slot = usePageHeaderSlot();
|
|
9
9
|
const setOverflowItems = slot?.setOverflowItems;
|
|
10
10
|
const setTitle = slot?.setTitle;
|
|
11
11
|
const setRecordTitle = slot?.setRecordTitle;
|
|
12
|
+
const setNarrowRecordTitle = slot?.setNarrowRecordTitle;
|
|
12
13
|
const setBodyTitle = slot?.setBodyTitle;
|
|
13
14
|
const setBreadcrumbHidden = slot?.setBreadcrumbHidden;
|
|
14
15
|
const setBreadcrumbScreenId = slot?.setBreadcrumbScreenId;
|
|
@@ -37,6 +38,12 @@ export function DefaultPageHeader({ title, recordTitle, status, actions, bodyTit
|
|
|
37
38
|
setRecordTitle(recordTitle);
|
|
38
39
|
return () => setRecordTitle(undefined);
|
|
39
40
|
}, [setRecordTitle, recordTitle]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (setNarrowRecordTitle === undefined || narrowRecordTitle === undefined)
|
|
43
|
+
return;
|
|
44
|
+
setNarrowRecordTitle(narrowRecordTitle);
|
|
45
|
+
return () => setNarrowRecordTitle(undefined);
|
|
46
|
+
}, [setNarrowRecordTitle, narrowRecordTitle]);
|
|
40
47
|
useEffect(() => {
|
|
41
48
|
if (setTitle === undefined || title === undefined)
|
|
42
49
|
return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronLeft, ChevronRight, Loader2 } from "lucide-react";
|
|
2
|
+
import { ChevronDown, ChevronLeft, ChevronRight, Loader2 } from "lucide-react";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
4
|
import { useOptionalLocale, useTranslation } from "../../index.js";
|
|
5
5
|
import { cn } from "../lib/cn.js";
|
|
@@ -52,8 +52,8 @@ export function InfiniteSentinel({ onReachEnd, loadingMore, hasMore, rowsCount,
|
|
|
52
52
|
const showEndLabel = !hasMore && rowsCount >= END_LABEL_MIN_ROWS;
|
|
53
53
|
return (_jsx("div", { ref: ref, "data-testid": testId, className: cn("flex items-center justify-center text-sm text-muted-foreground", showEndLabel || loadingMore ? "py-4" : ""), children: showEndLabel ? (_jsx("span", { "data-testid": testId !== undefined ? `${testId}-end` : undefined, children: t("kumiko.list.end-of-list") })) : loadingMore ? (_jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" })) : hasMore ? (_jsx("span", { "aria-hidden": "true", children: "\u00A0" })) : null }));
|
|
54
54
|
}
|
|
55
|
-
// Pager — left "X – Y of Z
|
|
56
|
-
//
|
|
55
|
+
// Pager — left "X – Y of Z", right the page size select in text style and "‹ Page 1 of 3 ›" from sm; below sm
|
|
56
|
+
// only the arrows.
|
|
57
57
|
// `pinned` renders the footer bar of a scrollBody table (fixed height, top
|
|
58
58
|
// border); unpinned it sits as a plain row below the table.
|
|
59
59
|
//
|
|
@@ -65,32 +65,23 @@ export function Pager({ page, limit, total, onPageChange, pageSizeOptions, onPag
|
|
|
65
65
|
const locale = useOptionalLocale();
|
|
66
66
|
const totalPages = Math.max(1, Math.ceil(total / limit));
|
|
67
67
|
const safePage = Math.max(1, Math.min(page, totalPages));
|
|
68
|
-
const from = (safePage - 1) * limit + 1;
|
|
68
|
+
const from = total === 0 ? 0 : (safePage - 1) * limit + 1;
|
|
69
69
|
const to = Math.min(safePage * limit, total);
|
|
70
70
|
return (_jsxs("div", { "data-testid": testId, className: plain === true
|
|
71
71
|
? "flex items-center justify-between px-4 pb-3 pt-1 text-[12.5px] tabular-nums text-muted-foreground"
|
|
72
72
|
: pinned === true
|
|
73
73
|
? TABLE_FOOTER_BAR_CLASS
|
|
74
|
-
: "mt-3 flex items-center gap-4 text-[12.5px] tabular-nums text-muted-foreground", children: [
|
|
74
|
+
: "mt-3 flex items-center gap-4 text-[12.5px] tabular-nums text-muted-foreground", children: [_jsx("div", { className: "flex min-w-0 flex-1 items-center gap-1", children: _jsx("div", { "data-testid": testId !== undefined ? `${testId}-status` : undefined, children: total === 0
|
|
75
|
+
? t("kumiko.pager.statusEmpty")
|
|
76
|
+
: t("kumiko.pager.status", {
|
|
75
77
|
from: from.toLocaleString(locale),
|
|
76
78
|
to: to.toLocaleString(locale),
|
|
77
79
|
total: total.toLocaleString(locale),
|
|
78
|
-
}) }), pageSizeOptions !== undefined && onPageSizeChange !== undefined && (_jsxs("div", { className: "hidden items-center sm:flex", children: [_jsx("
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (totalPages <= 7)
|
|
83
|
-
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
84
|
-
const wanted = new Set([1, current - 1, current, current + 1, totalPages]);
|
|
85
|
-
const pages = [...wanted].filter((page) => page >= 1 && page <= totalPages).sort((a, b) => a - b);
|
|
86
|
-
return pages.flatMap((page, index) => {
|
|
87
|
-
const previous = pages[index - 1];
|
|
88
|
-
return previous !== undefined && page - previous > 1 ? [{ gapBefore: page }, page] : [page];
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function PageNumberButton({ page, current, label, onClick, testId, }) {
|
|
92
|
-
return (_jsx("button", { type: "button", onClick: onClick, "aria-label": label, "aria-current": current ? "page" : undefined, "data-testid": testId, className: cn("inline-flex h-6 min-w-6 items-center justify-center rounded px-1.5", "hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", current && "bg-primary text-primary-foreground hover:bg-primary"), children: page.toLocaleString() }));
|
|
80
|
+
}) }) }), _jsxs("div", { className: "flex items-center gap-1", children: [pageSizeOptions !== undefined && onPageSizeChange !== undefined && (_jsxs("div", { className: "relative mr-2 hidden items-center sm:flex", children: [_jsx("select", { "aria-label": t("kumiko.pager.pageSizeLabel"), "data-testid": testId !== undefined ? `${testId}-page-size` : undefined, value: limit, onChange: (e) => onPageSizeChange(Number(e.target.value)), className: "h-8 cursor-pointer appearance-none rounded-md border border-border-strong bg-card py-0 pl-2.5 pr-7 text-[12.5px] text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", children: pageSizeOptions.map((size) => (_jsx("option", { value: size, children: t("kumiko.pager.pageSize", { size: size.toLocaleString(locale) }) }, size))) }), _jsx(ChevronDown, { className: "pointer-events-none absolute right-2 size-3.5 text-muted-foreground", "aria-hidden": "true" })] })), _jsx(PagerButton, { ariaLabel: t("kumiko.pager.previousPage"), disabled: safePage <= 1, onClick: () => onPageChange(safePage - 1), testId: testId !== undefined ? `${testId}-prev` : undefined, children: _jsx(ChevronLeft, { className: "size-3.5", "aria-hidden": "true" }) }), _jsx("span", { "data-testid": testId !== undefined ? `${testId}-page-label` : undefined, className: "hidden px-1 sm:inline", children: t("kumiko.pager.pageOf", {
|
|
81
|
+
page: safePage.toLocaleString(locale),
|
|
82
|
+
total: totalPages.toLocaleString(locale),
|
|
83
|
+
}) }), _jsx(PagerButton, { ariaLabel: t("kumiko.pager.nextPage"), disabled: safePage >= totalPages, onClick: () => onPageChange(safePage + 1), testId: testId !== undefined ? `${testId}-next` : undefined, children: _jsx(ChevronRight, { className: "size-3.5", "aria-hidden": "true" }) })] })] }));
|
|
93
84
|
}
|
|
94
85
|
function PagerButton({ children, onClick, ariaLabel, disabled, testId, }) {
|
|
95
|
-
return (_jsx("button", { type: "button", onClick: onClick, disabled: disabled, "aria-label": ariaLabel, "data-testid": testId, className: cn("inline-flex size-
|
|
86
|
+
return (_jsx("button", { type: "button", onClick: onClick, disabled: disabled, "aria-label": ariaLabel, "data-testid": testId, className: cn("inline-flex size-8 items-center justify-center rounded-md border border-border-strong bg-card", "hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", "disabled:pointer-events-none disabled:text-foreground-disabled"), children: children }));
|
|
96
87
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
2
3
|
import { FileThumbnail } from "./file-thumbnail.js";
|
|
3
4
|
export function DefaultPhotoGrid({ tiles, testId }) {
|
|
4
|
-
return (_jsx("ul", { "data-testid": testId, className: "m-0 grid list-none
|
|
5
|
+
return (_jsx("ul", { "data-testid": testId, className: "m-0 grid list-none gap-3.5 p-0 [grid-template-columns:repeat(2,minmax(0,1fr))] md:[grid-template-columns:repeat(3,minmax(0,1fr))]", children: tiles.map((tile) => (_jsxs("li", { "data-testid": testId !== undefined ? `${testId}-tile-${tile.id}` : undefined, className: cn("flex flex-col overflow-hidden rounded-lg border border-border bg-card", tile.leadsOnNarrow === true && "max-sm:-order-1"), children: [_jsxs("div", { className: "relative", children: [_jsx(FileThumbnail, { fileId: tile.imageId ?? "", className: "aspect-[3/2] w-full object-cover md:aspect-[2/1]" }), tile.badge !== undefined && (_jsx("span", { "data-slot": "photo-badge", className: "absolute top-2 left-2 rounded-full bg-status-warn-surface px-2 py-0.5 text-xs font-medium text-status-warn", children: tile.badge }))] }), _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-3 gap-y-2 p-3", children: [tile.caption !== undefined && (_jsx("span", { className: "min-w-0 truncate text-[13px] text-foreground", children: tile.caption })), tile.actions !== undefined && (_jsx("div", { className: "ml-auto flex flex-wrap items-center gap-x-3 gap-y-1", children: tile.actions }))] })] }, tile.id))) }));
|
|
5
6
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { RecordStepsProps } from "../../index.ts";
|
|
3
|
-
export declare function DefaultRecordSteps({ title, subtitle, emptyLabel, reasonLabel, narrowLimit, moreLabel, lessLabel, moreActionsLabel, items,
|
|
3
|
+
export declare function DefaultRecordSteps({ title, subtitle, emptyLabel, reasonLabel, narrowLimit, moreLabel, lessLabel, moreActionsLabel, items, testId, }: RecordStepsProps): ReactNode;
|
|
@@ -4,14 +4,6 @@ import { cn } from "../lib/cn.js";
|
|
|
4
4
|
import { InsideScreenFormColumnContext } from "./metric.js";
|
|
5
5
|
import { ReasonBox, ReasonInfoButton } from "./reason-box.js";
|
|
6
6
|
import { useIsBelowSmViewport } from "./use-narrow-viewport.js";
|
|
7
|
-
const STEP_STRIPE_CLASS = {
|
|
8
|
-
bad: "bg-status-bad",
|
|
9
|
-
warn: "bg-status-warn",
|
|
10
|
-
critical: "bg-status-critical",
|
|
11
|
-
ok: "bg-status-ok",
|
|
12
|
-
accent: "bg-primary",
|
|
13
|
-
neutral: "bg-border-strong",
|
|
14
|
-
};
|
|
15
7
|
function StepTitle({ item }) {
|
|
16
8
|
const narrow = useIsBelowSmViewport();
|
|
17
9
|
return narrow ? (item.narrowTitle ?? item.title) : item.title;
|
|
@@ -26,16 +18,15 @@ function StepDetail({ item }) {
|
|
|
26
18
|
function StepRow({ item, reasonLabel, moreActionsLabel, }) {
|
|
27
19
|
const [reasonOpen, setReasonOpen] = useState(item.reasonOpen === true);
|
|
28
20
|
const reasonBoxId = useId();
|
|
29
|
-
|
|
30
|
-
return (_jsxs("li", { "data-testid": `record-step-${item.id}`, "data-tone": item.tone, className: "relative grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-1 py-3 pl-5 pr-4 max-sm:py-[9px] max-sm:pl-3.5 max-sm:pr-0", children: [_jsx("span", { "aria-hidden": "true", className: cn("absolute inset-y-2.5 left-0 w-1 rounded-[2px] max-sm:inset-y-[9px]", STEP_STRIPE_CLASS[item.tone ?? "neutral"]) }), _jsxs("div", { className: "col-start-1 row-start-1 flex min-w-0 items-start gap-2", children: [_jsx("span", { className: "font-medium text-foreground max-sm:text-[13.5px]", "data-slot": "step-what", children: _jsx(StepTitle, { item: item }) }), item.reason !== undefined && (_jsx("span", { className: "flex max-sm:hidden", children: _jsx(ReasonInfoButton, { label: reasonLabel, open: reasonOpen, controls: reasonBoxId, onToggle: () => setReasonOpen((open) => !open) }) }))] }), _jsxs("div", { className: "col-start-2 row-start-1 flex shrink-0 items-center gap-3 max-sm:row-span-2 max-sm:self-center max-sm:[&_button]:h-8 max-sm:[&_button]:text-[13px]", children: [item.moreActions !== undefined && !narrow && (_jsxs("div", { className: "flex items-center gap-3 text-[12.5px] text-muted-foreground [&_a]:text-[12.5px] [&_a]:text-muted-foreground [&_button]:text-[12.5px] [&_button]:text-muted-foreground", children: [moreActionsLabel !== undefined && (_jsx("span", { "data-testid": `record-step-${item.id}-more-actions-label`, children: moreActionsLabel })), item.moreActions] })), item.actions] }), _jsx("div", { className: "col-start-1 row-start-2 min-w-0 sm:col-span-2", children: _jsx(StepDetail, { item: item }) }), item.moreActions !== undefined && narrow && (_jsxs("div", { "data-testid": `record-step-${item.id}-more-actions`, className: "col-span-2 row-start-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground [&_a]:text-xs [&_a]:text-muted-foreground [&_button]:text-xs [&_button]:text-muted-foreground", children: [moreActionsLabel !== undefined && _jsx("span", { children: moreActionsLabel }), item.moreActions] })), item.reason !== undefined && reasonOpen && (_jsx("div", { className: "col-span-2 row-start-3 max-sm:hidden", children: _jsx(ReasonBox, { id: reasonBoxId, testId: `record-step-${item.id}-reason`, ...(item.reasonTitle !== undefined && { title: item.reasonTitle }), children: item.reason }) }))] }));
|
|
21
|
+
return (_jsxs("li", { "data-testid": `record-step-${item.id}`, "data-tone": item.tone, className: "grid min-h-16 grid-cols-[minmax(0,1fr)_auto] content-center gap-x-3 gap-y-1 px-4 py-2.5", children: [_jsxs("div", { className: "col-start-1 row-start-1 flex min-w-0 items-start gap-2", children: [_jsx("span", { className: "font-medium text-foreground max-sm:text-[13.5px]", "data-slot": "step-what", children: _jsx(StepTitle, { item: item }) }), item.reason !== undefined && (_jsx("span", { className: "flex max-sm:hidden", children: _jsx(ReasonInfoButton, { label: reasonLabel, open: reasonOpen, controls: reasonBoxId, onToggle: () => setReasonOpen((open) => !open) }) }))] }), _jsx("div", { className: "col-start-1 row-start-2 min-w-0 sm:col-span-1", children: _jsx(StepDetail, { item: item }) }), item.actions !== undefined && (_jsx("div", { className: "flex shrink-0 items-center gap-3 max-sm:col-span-2 max-sm:row-start-3 max-sm:mt-1 [&_button]:h-9 [&_button_svg]:hidden max-sm:[&>*]:w-full max-sm:[&_button]:w-full sm:col-start-2 sm:row-span-2 sm:row-start-1 sm:self-center", children: item.actions })), item.moreActions !== undefined && (_jsxs("div", { "data-testid": `record-step-${item.id}-more-actions`, className: "col-span-2 row-start-4 mt-1 flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-border-row pt-2.5 text-[12.5px]", children: [moreActionsLabel !== undefined && (_jsx("span", { className: "text-muted-foreground max-sm:w-full", "data-testid": `record-step-${item.id}-more-actions-label`, children: moreActionsLabel })), _jsx("div", { className: "flex flex-wrap items-center gap-2 text-[12.5px] [&_button]:h-9 [&_button]:rounded-md [&_button]:border [&_button]:border-border-strong [&_button]:bg-card [&_button]:px-3 [&_button]:text-[12.5px] [&_button]:font-medium [&_button]:text-foreground [&_button_svg]:text-primary", children: item.moreActions })] })), item.reason !== undefined && reasonOpen && (_jsx("div", { className: "col-span-2 row-start-5 max-sm:hidden", children: _jsx(ReasonBox, { id: reasonBoxId, testId: `record-step-${item.id}-reason`, ...(item.reasonTitle !== undefined && { title: item.reasonTitle }), children: item.reason }) }))] }));
|
|
31
22
|
}
|
|
32
|
-
function StepsHeader({ title, subtitle
|
|
33
|
-
return (_jsxs("header", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1 px-4
|
|
23
|
+
function StepsHeader({ title, subtitle }) {
|
|
24
|
+
return (_jsxs("header", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1 px-4 pt-2.5", children: [_jsx("h3", { className: "m-0 text-[11.5px] font-normal text-muted-foreground", children: title }), subtitle !== undefined && (_jsx("span", { className: "text-[13px] text-muted-foreground max-sm:hidden", children: subtitle }))] }));
|
|
34
25
|
}
|
|
35
26
|
function StepsMoreToggle({ testId, expanded, label, onToggle, }) {
|
|
36
|
-
return (
|
|
27
|
+
return (_jsx("button", { type: "button", "data-testid": `${testId ?? "record-steps"}-toggle`, "aria-expanded": expanded, className: "w-full border-t border-border-row px-4 py-3 text-left text-sm font-medium text-primary hover:underline max-sm:py-[9px] max-sm:text-xs max-sm:font-normal", onClick: onToggle, children: label }));
|
|
37
28
|
}
|
|
38
|
-
export function DefaultRecordSteps({ title, subtitle, emptyLabel, reasonLabel, narrowLimit, moreLabel, lessLabel, moreActionsLabel, items,
|
|
29
|
+
export function DefaultRecordSteps({ title, subtitle, emptyLabel, reasonLabel, narrowLimit, moreLabel, lessLabel, moreActionsLabel, items, testId, }) {
|
|
39
30
|
const insideScreenFormColumn = useContext(InsideScreenFormColumnContext);
|
|
40
31
|
const narrow = useIsBelowSmViewport();
|
|
41
32
|
const [expanded, setExpanded] = useState(false);
|
|
@@ -46,5 +37,5 @@ export function DefaultRecordSteps({ title, subtitle, emptyLabel, reasonLabel, n
|
|
|
46
37
|
: expanded
|
|
47
38
|
? lessLabel
|
|
48
39
|
: moreLabel(items.length - visible.length);
|
|
49
|
-
return (_jsx("section", { "data-testid": testId, className: cn("shrink-0", !insideScreenFormColumn && "px-6 py-2 max-sm:px-4"), children: _jsxs("div", { className: "
|
|
40
|
+
return (_jsx("section", { "data-testid": testId, className: cn("shrink-0", !insideScreenFormColumn && "px-6 py-2 max-sm:px-4"), children: _jsxs("div", { className: "rounded-[9px] border border-border bg-card", children: [_jsx(StepsHeader, { title: title, subtitle: subtitle }), items.length === 0 ? (_jsx("p", { className: "m-0 px-4 py-3 text-sm text-muted-foreground", children: emptyLabel })) : (_jsx("ul", { className: "m-0 flex list-none flex-col divide-y divide-border-row p-0", children: visible.map((item) => (_jsx(StepRow, { item: item, reasonLabel: reasonLabel, moreActionsLabel: moreActionsLabel }, item.id))) })), limited && toggleLabel !== undefined && (_jsx(StepsMoreToggle, { testId: testId, expanded: expanded, label: toggleLabel, onToggle: () => setExpanded((open) => !open) }))] }) }));
|
|
50
41
|
}
|
|
@@ -11,6 +11,11 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
|
|
|
11
11
|
import { useToast } from "./toast.js";
|
|
12
12
|
import "../react-css-custom-properties.js";
|
|
13
13
|
import { actionIconFor, SECONDARY_BUTTON_EXTRA_CLASSES } from "./button.js";
|
|
14
|
+
// RowAction carries no AI marker; the sparkles icon is the convention for an
|
|
15
|
+
// AI-prepared action (same as record guidance), so it selects the soft look.
|
|
16
|
+
function isSoftAiAction(action, icon) {
|
|
17
|
+
return action.style !== "danger" && icon === "sparkles";
|
|
18
|
+
}
|
|
14
19
|
// The primary row action always remains a visible text button: `edit` when declared,
|
|
15
20
|
// otherwise the first visible action ("Edit appears in every row, always, as text").
|
|
16
21
|
function primaryRowAction(actions) {
|
|
@@ -91,9 +96,9 @@ function useRowActionTrigger(row) {
|
|
|
91
96
|
}
|
|
92
97
|
// An icon-only form without a resolvable icon would render an empty button.
|
|
93
98
|
// `compact` is the narrow card layout, where "responsive" collapses to its icon.
|
|
94
|
-
function effectiveRowActionDisplay(display, hasIcon, compact) {
|
|
99
|
+
function effectiveRowActionDisplay(display, hasIcon, compact, keepsLabel) {
|
|
95
100
|
if (display === "responsive")
|
|
96
|
-
return hasIcon && compact ? "icon" : "button";
|
|
101
|
+
return hasIcon && compact && !keepsLabel ? "icon" : "button";
|
|
97
102
|
if (display === "icon" && !hasIcon)
|
|
98
103
|
return "link";
|
|
99
104
|
return display;
|
|
@@ -102,25 +107,30 @@ function RowActionButton({ row, action, iconOnly = false, asLink = false, compac
|
|
|
102
107
|
const { busy, triggerNow } = useRowActionTrigger(row);
|
|
103
108
|
const [confirmOpen, setConfirmOpen] = useState(false);
|
|
104
109
|
const resolvedIcon = actionIconFor(action.icon);
|
|
105
|
-
const resolvedDisplay = effectiveRowActionDisplay(action.display, resolvedIcon !== undefined, compact);
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
const resolvedDisplay = effectiveRowActionDisplay(action.display, resolvedIcon !== undefined, compact, isSoftAiAction(action, resolvedIcon));
|
|
111
|
+
const display = resolvedDisplay;
|
|
112
|
+
if (display === "text") {
|
|
113
|
+
return (_jsx("span", { "data-testid": `row-${row.id}-action-${action.id}`, className: cn("px-2.5 text-muted-foreground", small ? "text-[13px]" : "text-sm"), children: action.label }));
|
|
114
|
+
}
|
|
108
115
|
const isBorderedButton = display === "button";
|
|
116
|
+
const isSoftAiButton = isBorderedButton && isSoftAiAction(action, resolvedIcon);
|
|
109
117
|
const showIconOnly = display === "icon" || (display === undefined && iconOnly && resolvedIcon !== undefined);
|
|
110
118
|
const linkLike = display === "link" || (display === undefined && asLink);
|
|
111
|
-
const variantClass =
|
|
112
|
-
?
|
|
113
|
-
|
|
119
|
+
const variantClass = isSoftAiButton
|
|
120
|
+
? "border border-transparent bg-primary/10 text-primary hover:bg-primary/15"
|
|
121
|
+
: isBorderedButton
|
|
122
|
+
? action.style === "primary"
|
|
123
|
+
? "border border-transparent bg-primary text-primary-foreground hover:bg-primary/90"
|
|
124
|
+
: action.style === "danger"
|
|
125
|
+
? "border border-destructive/40 bg-card text-destructive hover:bg-destructive/10"
|
|
126
|
+
: "border border-border-strong bg-card text-foreground hover:bg-accent"
|
|
114
127
|
: action.style === "danger"
|
|
115
|
-
? "
|
|
116
|
-
:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
: action.style === "primary"
|
|
122
|
-
? "text-primary hover:bg-primary/10"
|
|
123
|
-
: "text-foreground hover:bg-accent";
|
|
128
|
+
? "text-destructive hover:bg-destructive/10"
|
|
129
|
+
: linkLike
|
|
130
|
+
? "font-medium text-primary hover:bg-muted"
|
|
131
|
+
: action.style === "primary"
|
|
132
|
+
? "text-primary hover:bg-primary/10"
|
|
133
|
+
: "text-foreground hover:bg-accent";
|
|
124
134
|
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", "data-testid": `row-${row.id}-action-${action.id}`, disabled: busy, ...(showIconOnly && { "aria-label": action.label, title: action.label }), onClick: (e) => {
|
|
125
135
|
e.stopPropagation();
|
|
126
136
|
if (needsActionConfirm(action)) {
|
|
@@ -129,13 +139,17 @@ function RowActionButton({ row, action, iconOnly = false, asLink = false, compac
|
|
|
129
139
|
else {
|
|
130
140
|
void triggerNow(action);
|
|
131
141
|
}
|
|
132
|
-
}, className: cn("inline-flex items-center justify-center gap-1.5 text-sm",
|
|
133
|
-
?
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
:
|
|
142
|
+
}, className: cn("inline-flex items-center justify-center gap-1.5 text-sm", isSoftAiButton
|
|
143
|
+
? "h-[26px] rounded-md px-2.5 text-[12.5px] font-semibold"
|
|
144
|
+
: isBorderedButton
|
|
145
|
+
? small
|
|
146
|
+
? cn("rounded-md font-medium", COMPACT_TAP_CLASSES)
|
|
147
|
+
: "h-8 rounded-md px-3 font-medium max-md:h-11"
|
|
148
|
+
: linkLike
|
|
149
|
+
? small
|
|
150
|
+
? "h-8 rounded-md px-0 text-[13px] font-medium"
|
|
151
|
+
: "h-7 rounded-md px-2.5 max-md:h-11"
|
|
152
|
+
: "h-8 rounded-sm max-md:h-11", showIconOnly ? "w-8 max-md:w-11" : !linkLike && !isBorderedButton && "px-2", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", "disabled:opacity-50 disabled:pointer-events-none", variantClass), children: busy ? (_jsx(Loader2, { className: "size-3.5 animate-spin", "aria-hidden": "true" })) : resolvedIcon === undefined || (linkLike && !showIconOnly) ? (action.label) : showIconOnly ? (_jsx(Icon, { name: resolvedIcon, className: "size-4" })) : (_jsxs(_Fragment, { children: [_jsx(Icon, { name: resolvedIcon, className: "size-4" }), action.label] })) }), _jsx(DefaultDialog, { open: confirmOpen, onOpenChange: setConfirmOpen, title: action.label, ...(action.confirm !== undefined && { description: action.confirm }), confirmLabel: action.confirmLabel ?? action.label, ...(action.style === "danger" && { variant: "danger" }), onConfirm: () => triggerNow(action), testId: `row-${row.id}-action-${action.id}-dialog` })] }));
|
|
139
153
|
}
|
|
140
154
|
// Kebab dropdown for >2 actions, one inline confirm dialog per item like
|
|
141
155
|
// the inline-button path. Menu is controlled so it closes explicitly on
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
/** `narrow`: the referenced element is narrower than the card breakpoint. `docked`: the shell
|
|
3
|
+
* reports a docked assistant panel, which shrinks the content without changing the viewport (so
|
|
4
|
+
* a media query cannot see it) and not necessarily below the breakpoint. Both are false until
|
|
5
|
+
* measured and where ResizeObserver is missing. */
|
|
6
|
+
export declare function useContainerSqueeze<T extends HTMLElement>(): [
|
|
7
|
+
RefObject<T | null>,
|
|
8
|
+
{
|
|
9
|
+
readonly narrow: boolean;
|
|
10
|
+
readonly docked: boolean;
|
|
11
|
+
}
|
|
12
|
+
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { NARROW_VIEWPORT_BREAKPOINT_PX } from "./use-narrow-viewport.js";
|
|
3
|
+
// Set by the shell while the assistant panel is docked; the inset then gets that much right padding.
|
|
4
|
+
const DOCKED_PANEL_WIDTH_VAR = "--agent-panel-width";
|
|
5
|
+
function isPanelDocked(element) {
|
|
6
|
+
const width = Number.parseFloat(getComputedStyle(element).getPropertyValue(DOCKED_PANEL_WIDTH_VAR));
|
|
7
|
+
return Number.isFinite(width) && width > 0;
|
|
8
|
+
}
|
|
9
|
+
/** `narrow`: the referenced element is narrower than the card breakpoint. `docked`: the shell
|
|
10
|
+
* reports a docked assistant panel, which shrinks the content without changing the viewport (so
|
|
11
|
+
* a media query cannot see it) and not necessarily below the breakpoint. Both are false until
|
|
12
|
+
* measured and where ResizeObserver is missing. */
|
|
13
|
+
export function useContainerSqueeze() {
|
|
14
|
+
const ref = useRef(null);
|
|
15
|
+
const [narrow, setNarrow] = useState(false);
|
|
16
|
+
const [docked, setDocked] = useState(false);
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
const element = ref.current;
|
|
19
|
+
// skip: no element or no observer support (SSR, bare test DOMs) keeps the viewport rules
|
|
20
|
+
if (element === null || typeof ResizeObserver === "undefined")
|
|
21
|
+
return;
|
|
22
|
+
const measure = () => {
|
|
23
|
+
const width = element.getBoundingClientRect().width;
|
|
24
|
+
setNarrow(width > 0 && width < NARROW_VIEWPORT_BREAKPOINT_PX);
|
|
25
|
+
setDocked(isPanelDocked(element));
|
|
26
|
+
};
|
|
27
|
+
measure();
|
|
28
|
+
const observer = new ResizeObserver(measure);
|
|
29
|
+
observer.observe(element);
|
|
30
|
+
// An overflowing table keeps its width when the panel docks, so only the variable change tells.
|
|
31
|
+
const styleObserver = new MutationObserver(measure);
|
|
32
|
+
styleObserver.observe(element.ownerDocument.documentElement, {
|
|
33
|
+
attributes: true,
|
|
34
|
+
attributeFilter: ["style"],
|
|
35
|
+
});
|
|
36
|
+
return () => {
|
|
37
|
+
observer.disconnect();
|
|
38
|
+
styleObserver.disconnect();
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
return [ref, { narrow, docked }];
|
|
42
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
+
import { useBasePath } from "../../app/base-path-context.js";
|
|
3
4
|
import { PWA_SERVICE_WORKER_META_NAME, pwaCacheScopePrefixOf, } from "../../headless/pwa-service-worker-meta.js";
|
|
4
5
|
import { useTranslation } from "../../index.js";
|
|
5
6
|
import { cn } from "../lib/cn.js";
|
|
@@ -56,16 +57,20 @@ function registerServiceWorker(serviceWorkerUrl) {
|
|
|
56
57
|
.register(serviceWorkerUrl, { scope, updateViaCache: "none" })
|
|
57
58
|
.catch(() => undefined);
|
|
58
59
|
}
|
|
59
|
-
// Only
|
|
60
|
+
// Only a registration scoped exactly to this app's base path is touched: getRegistration() also
|
|
61
|
+
// returns an enclosing scope, which belongs to another app on the origin. A worker counts as the
|
|
60
62
|
// framework's own when it is served as /sw.js and left a cache with this scope's kumiko-pwa-
|
|
61
|
-
// prefix; app-owned workers
|
|
62
|
-
async function retireStaleServiceWorker() {
|
|
63
|
+
// prefix; app-owned workers have no such marker.
|
|
64
|
+
async function retireStaleServiceWorker(ownScopePath) {
|
|
63
65
|
if (!("serviceWorker" in navigator) || typeof caches === "undefined")
|
|
64
66
|
return;
|
|
65
|
-
const registration = await navigator.serviceWorker.getRegistration();
|
|
67
|
+
const registration = await navigator.serviceWorker.getRegistration(ownScopePath);
|
|
66
68
|
if (!registration?.active?.scriptURL.endsWith("/sw.js"))
|
|
67
69
|
return;
|
|
68
|
-
const
|
|
70
|
+
const registeredScopePath = new URL(registration.scope).pathname;
|
|
71
|
+
if (registeredScopePath !== ownScopePath)
|
|
72
|
+
return;
|
|
73
|
+
const cachePrefix = await pwaCacheScopePrefixOf(registeredScopePath);
|
|
69
74
|
const pwaCacheNames = (await caches.keys()).filter((name) => name.startsWith(cachePrefix));
|
|
70
75
|
if (pwaCacheNames.length === 0)
|
|
71
76
|
return;
|
|
@@ -108,14 +113,15 @@ function useInstallHint(enabled) {
|
|
|
108
113
|
const HINT_BUTTON_CLASSES = cn("rounded-md px-3 py-1 text-xs font-medium", "hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-ring");
|
|
109
114
|
export function PwaSupport() {
|
|
110
115
|
const t = useTranslation();
|
|
116
|
+
const basePath = useBasePath();
|
|
111
117
|
const serviceWorkerUrl = readPwaServiceWorkerUrl();
|
|
112
118
|
const [hint, dismiss] = useInstallHint(serviceWorkerUrl !== undefined);
|
|
113
119
|
useEffect(() => {
|
|
114
120
|
if (serviceWorkerUrl !== undefined)
|
|
115
121
|
registerServiceWorker(serviceWorkerUrl);
|
|
116
122
|
else
|
|
117
|
-
retireStaleServiceWorker().catch(() => undefined);
|
|
118
|
-
}, [serviceWorkerUrl]);
|
|
123
|
+
retireStaleServiceWorker(`${basePath}/`).catch(() => undefined);
|
|
124
|
+
}, [serviceWorkerUrl, basePath]);
|
|
119
125
|
if (hint.kind === "none")
|
|
120
126
|
return null;
|
|
121
127
|
const install = async (event) => {
|
package/dist/web/ui/input.js
CHANGED
|
@@ -3,6 +3,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
function Input({ className, type, ...props }) {
|
|
6
|
-
return (_jsx("input", { type: type, "data-slot": "input", className: cn("h-
|
|
6
|
+
return (_jsx("input", { type: type, "data-slot": "input", className: cn("h-[38px] w-full min-w-0 max-md:min-h-11 rounded-[7px] border-[1.5px] border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30", "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50", "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40", className), ...props }));
|
|
7
7
|
}
|
|
8
8
|
export { Input };
|
package/dist/web/ui/textarea.js
CHANGED
|
@@ -3,6 +3,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
function Textarea({ className, ...props }) {
|
|
6
|
-
return (_jsx("textarea", { "data-slot": "textarea", className: cn("flex field-sizing-content min-h-16 w-full rounded-
|
|
6
|
+
return (_jsx("textarea", { "data-slot": "textarea", className: cn("flex field-sizing-content min-h-16 w-full rounded-[7px] border-[1.5px] border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40", className), ...props }));
|
|
7
7
|
}
|
|
8
8
|
export { Textarea };
|
|
@@ -32,15 +32,18 @@ export function DashboardListCards({ columns, rows, testId, rowToneField, titleF
|
|
|
32
32
|
const plain = columns.filter((column) => column.hint === undefined);
|
|
33
33
|
const badgeColumns = plain.filter((column) => column.display === "badge");
|
|
34
34
|
const buttonColumns = plain.filter((column) => column.display === "button");
|
|
35
|
-
const otherColumns = plain.filter((column) => column.display !== "badge" && column.display !== "button");
|
|
35
|
+
const otherColumns = plain.filter((column) => column.display !== "badge" && column.display !== "button" && column.hiddenInCards !== true);
|
|
36
36
|
const cell = (column, row) => (_jsx(DashboardListCell, { column: column, row: row, ...cellProps }, column.field));
|
|
37
37
|
return (_jsx("ul", { "data-testid": testId, className: "m-0 flex list-none flex-col gap-2 p-0", children: rows.map((row, index) => {
|
|
38
38
|
const detail = detailOf(hintColumn?.hint, row);
|
|
39
|
-
const
|
|
39
|
+
const allBadges = badgeColumns.filter((column) => hasValue(row[column.field]));
|
|
40
|
+
// First badge (type) heads the card next to the time; further badges (e.g. AI) sit bottom left.
|
|
41
|
+
const badges = allBadges.slice(0, 1);
|
|
42
|
+
const footBadges = allBadges.slice(1);
|
|
40
43
|
const buttons = buttonColumns.filter((column) => hasValue(row[column.field]));
|
|
41
44
|
const others = otherColumns.filter((column) => hasValue(row[column.field]));
|
|
42
45
|
return (_jsxs("li", { "data-testid": "dashboard-list-card", className: cn("flex flex-col gap-1 rounded-lg border border-border bg-card px-3 py-2.5", cardToneClass(rowToneField === undefined
|
|
43
46
|
? undefined
|
|
44
|
-
: (rowToneOf(row, rowToneField) ?? "neutral"))), children: [(badges.length > 0 || detail !== undefined) && (_jsxs("div", { className: "flex min-w-0 items-center gap-2 text-xs text-muted-foreground", children: [badges.map((column) => cell(column, row)), detail !== undefined && (_jsx("small", { "data-testid": "dashboard-list-card-detail", className: "min-w-0 truncate text-xs", children: detail }))] })), hintColumn !== undefined && (_jsx(CardHeadline, { column: hintColumn, row: row, titleField: titleField })),
|
|
47
|
+
: (rowToneOf(row, rowToneField) ?? "neutral"))), children: [(badges.length > 0 || detail !== undefined) && (_jsxs("div", { className: "flex min-w-0 items-center gap-2 text-xs text-muted-foreground", children: [badges.map((column) => cell(column, row)), detail !== undefined && (_jsx("small", { "data-testid": "dashboard-list-card-detail", className: cn("ml-auto min-w-0 truncate text-xs", rowToneOf(row, rowToneField) === "warn" && "font-medium text-status-warn"), children: detail }))] })), hintColumn !== undefined && (_jsx(CardHeadline, { column: hintColumn, row: row, titleField: titleField })), others.map((column) => (_jsx("span", { className: "text-xs text-muted-foreground line-clamp-2", children: cell(column, row) }, column.field))), (footBadges.length > 0 || buttons.length > 0) && (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("div", { className: "flex min-w-0 items-center gap-2", children: footBadges.map((column) => cell(column, row)) }), buttons.length > 0 && (_jsx("div", { className: "flex shrink-0 flex-wrap justify-end gap-2 [&_a]:relative [&_a]:h-8 [&_a]:px-2.5 [&_a]:text-xs [&_a]:max-md:min-h-0 [&_a]:before:absolute [&_a]:before:inset-x-0 [&_a]:before:-inset-y-1.5 [&_a]:before:content-['']", children: buttons.map((column) => cell(column, row)) }))] }))] }, typeof row["id"] === "string" ? row["id"] : index));
|
|
45
48
|
}) }));
|
|
46
49
|
}
|
|
@@ -10,8 +10,9 @@ export type DashboardListColumn = {
|
|
|
10
10
|
readonly buttonVariant?: "primary";
|
|
11
11
|
readonly badgeToneField?: string;
|
|
12
12
|
readonly badgeDot?: false;
|
|
13
|
+
readonly badgeIcon?: "sparkles";
|
|
13
14
|
/** `false` leaves an empty cell blank instead of drawing the placeholder. */
|
|
14
|
-
readonly emptyPlaceholder?: false;
|
|
15
|
+
readonly emptyPlaceholder?: string | false;
|
|
15
16
|
/** Resolves the raw cell value to display text, e.g. a reference id to its label. */
|
|
16
17
|
readonly renderValue?: (value: unknown, row: Readonly<Record<string, unknown>>) => string;
|
|
17
18
|
/** Links the rendered text to its target, e.g. a reference cell to the record's detail. */
|
|
@@ -20,6 +21,8 @@ export type DashboardListColumn = {
|
|
|
20
21
|
readonly hint?: ListColumnHintViewModel;
|
|
21
22
|
/** `showOnNarrowOnly`: drawn in the phone cards only, never as a table column. */
|
|
22
23
|
readonly narrowOnly?: true;
|
|
24
|
+
/** `hideOnNarrow`: a table column that the phone cards leave out. */
|
|
25
|
+
readonly hiddenInCards?: true;
|
|
23
26
|
};
|
|
24
27
|
export type DashboardListRow = Readonly<Record<string, unknown>>;
|
|
25
28
|
type Row = DashboardListRow;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ArrowUpRight, ChevronRight } from "lucide-react";
|
|
2
|
+
import { ArrowUpRight, ChevronRight, Sparkles } from "lucide-react";
|
|
3
3
|
import { EMPTY_VALUE_PLACEHOLDER, } from "../../headless/index.js";
|
|
4
4
|
import { isSelectOptionTone } from "../../status-tone.js";
|
|
5
5
|
import { cn } from "../lib/cn.js";
|
|
@@ -39,7 +39,7 @@ export function dashboardListCellText(column, row, field, formats, translate) {
|
|
|
39
39
|
}
|
|
40
40
|
export function DashboardListCell({ column, row, formatPercent, formatNumber, formatDateTime, translate, leading, }) {
|
|
41
41
|
const raw = row[column.field];
|
|
42
|
-
const empty = column.emptyPlaceholder === false ? "" : EMPTY_VALUE_PLACEHOLDER;
|
|
42
|
+
const empty = column.emptyPlaceholder === false ? "" : (column.emptyPlaceholder ?? EMPTY_VALUE_PLACEHOLDER);
|
|
43
43
|
if (column.hint !== undefined) {
|
|
44
44
|
return _jsx(HintCell, { value: raw, row: row, hint: column.hint, leading: leading });
|
|
45
45
|
}
|
|
@@ -51,8 +51,11 @@ export function DashboardListCell({ column, row, formatPercent, formatNumber, fo
|
|
|
51
51
|
if (raw === undefined || raw === null || raw === "")
|
|
52
52
|
return empty;
|
|
53
53
|
const toneKey = column.badgeToneField !== undefined ? row[column.badgeToneField] : undefined;
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const isAi = column.badgeIcon === "sparkles";
|
|
55
|
+
const tone = isAi
|
|
56
|
+
? "accent"
|
|
57
|
+
: ((typeof toneKey === "string" ? LIST_BADGE_TONE[toneKey] : undefined) ?? "muted");
|
|
58
|
+
return (_jsxs(StatusBadge, { tone: tone, dot: !isAi && column.badgeDot !== false, children: [isAi && _jsx(Sparkles, { className: "size-3", "aria-hidden": "true" }), String(raw)] }));
|
|
56
59
|
}
|
|
57
60
|
if (column.display === "datetime") {
|
|
58
61
|
const atMs = timestampMsOf(raw);
|
|
@@ -118,6 +121,7 @@ export function DashboardListTable({ columns: allColumns, rows, formatPercent, f
|
|
|
118
121
|
const leadingBadgeColumns = leadingBadgeColumnsOf(visibleColumns);
|
|
119
122
|
const columns = visibleColumns.filter((column) => !leadingBadgeColumns.includes(column));
|
|
120
123
|
const hintColumn = columns.find((column) => column.hint !== undefined);
|
|
124
|
+
const deadlineFields = new Set(hintColumn?.hint?.narrowDetailField === undefined ? [] : [hintColumn.hint.narrowDetailField]);
|
|
121
125
|
const padded = rowToneField !== undefined || leadingBadgeColumns.length > 0;
|
|
122
126
|
const cellProps = { formatPercent, formatNumber, formatDateTime, translate };
|
|
123
127
|
return (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { "data-testid": testId, className: "w-full text-sm", children: [showHeader && (_jsx("thead", { children: _jsxs("tr", { className: "h-9 border-b border-border-row text-left text-xs text-muted-foreground", children: [columns.map((column) => (_jsx("th", { scope: "col", className: cn("px-4 font-medium", column.display === "button" && "text-right"), children: column.label }, column.field))), rowLink !== undefined && _jsx("th", { scope: "col", className: "w-8" })] }) })), _jsx("tbody", { children: rows.map((row, index) => {
|
|
@@ -139,7 +143,8 @@ export function DashboardListTable({ columns: allColumns, rows, formatPercent, f
|
|
|
139
143
|
!showHeader &&
|
|
140
144
|
"max-sm:grid max-sm:h-auto max-sm:grid-cols-1 max-sm:gap-1 max-sm:py-2", rowToneMarker === "bar" && rowToneClass(tone)), children: [columns.map((column, columnIndex) => {
|
|
141
145
|
const leading = leadingFor(column, columnIndex);
|
|
142
|
-
const
|
|
146
|
+
const plainCell = (_jsx(DashboardListCell, { column: column, row: row, ...cellProps, ...(column.hint !== undefined && { leading }) }));
|
|
147
|
+
const cell = tone === "warn" && deadlineFields.has(column.field) ? (_jsx("span", { className: "font-medium text-status-warn", children: plainCell })) : (plainCell);
|
|
143
148
|
return (_jsx("td", { className: cn("px-4", column.display === "button" && "text-right", !showHeader && "max-sm:block"), children: column.hint === undefined && dot !== null && columnIndex === 0 ? (_jsxs("span", { className: "flex items-center gap-2", children: [dot, cell] })) : (cell) }, column.field));
|
|
144
149
|
}), rowLink !== undefined && (_jsx("td", { className: "w-8 px-2 text-right", children: _jsx(RowLinkIcon, { link: rowTarget, icon: rowLink.icon, label: translate("kumiko.dashboard.list.open-row") }) }))] }, rowKey));
|
|
145
150
|
const reasonHint = columns.find((column) => column.hint !== undefined && hintReasonOf(column.hint, row) !== undefined)?.hint;
|
|
@@ -6,5 +6,5 @@ export function ProgressList({ rows, emptyContent, testId, }) {
|
|
|
6
6
|
if (rows.length === 0) {
|
|
7
7
|
return _jsx("div", { "data-testid": testId, children: emptyContent });
|
|
8
8
|
}
|
|
9
|
-
return (_jsx("ul", { "data-testid": testId, className: "flex max-h-64 flex-col gap-3 overflow-y-auto pr-1", children: rows.map((row) => (_jsxs("li", { className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex items-baseline justify-between gap-2 text-sm", children: [_jsx("span", { className: "font-medium", children: row.label }), _jsx("span", { className: cn("tabular-nums", row.tone === "danger" ? "text-status-critical" : "text-muted-foreground"), children: row.value })] }), row.
|
|
9
|
+
return (_jsx("ul", { "data-testid": testId, className: "flex max-h-64 flex-col gap-3 overflow-y-auto pr-1", children: rows.map((row) => (_jsxs("li", { className: "flex flex-col gap-1", children: [row.fraction !== null && _jsx(ProgressBar, { value: row.fraction, tone: row.tone }), _jsxs("div", { className: "flex items-baseline justify-between gap-2 text-sm", children: [_jsx("span", { className: "font-medium", children: row.label }), _jsx("span", { className: cn("tabular-nums", row.tone === "danger" ? "text-status-critical" : "text-muted-foreground"), children: row.value })] }), row.sub !== undefined && _jsx("div", { className: "text-xs text-muted-foreground", children: row.sub })] }, row.id))) }));
|
|
10
10
|
}
|
|
@@ -6,5 +6,5 @@ import { Sparkline, StatLinkFrame, TONE_VALUE, } from "./stat.js";
|
|
|
6
6
|
* sub line small beside it. Below `sm` plain text "<number> <label>" that joins the strip's single line. */
|
|
7
7
|
export function StatBoxCell({ label, narrowLabel, value, sub, tone = "default", icon, delta, spark, testId, link, }) {
|
|
8
8
|
const belowSm = useIsBelowSmViewport();
|
|
9
|
-
return (_jsx(StatLinkFrame, { link: link, testId: testId, children: belowSm ? (_jsxs("span", { "data-testid": testId, className: "whitespace-nowrap text-sm", children: [_jsx("span", { className: "tabular-nums text-foreground", children: value }), " ", _jsx("span", { className: "text-foreground", children: narrowLabel ?? label })] })) : (_jsxs("div", { "data-testid": testId, className: "flex min-w-0 items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5", children: [icon, _jsx("span", { className: cn("text-2xl font-semibold leading-none tabular-nums", TONE_VALUE[tone]), children: value }), _jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: "truncate text-sm font-semibold text-foreground", children: label }), sub !== undefined && (_jsx("span", { className: "truncate text-xs text-muted-foreground", children: sub }))] }), delta !== undefined && (_jsxs("span", { className: "whitespace-nowrap text-xs font-medium tabular-nums text-muted-foreground", children: [delta.direction === "up" ? "↑" : "↓", delta.value] })), spark !== undefined && (_jsx(Sparkline, { points: spark, className: cn("h-6 w-16 shrink-0", TONE_VALUE[tone]) }))] })) }));
|
|
9
|
+
return (_jsx(StatLinkFrame, { link: link, testId: testId, children: belowSm ? (_jsxs("span", { "data-testid": testId, className: "whitespace-nowrap text-sm", children: [_jsx("span", { className: "font-semibold tabular-nums text-foreground", children: value }), " ", _jsx("span", { className: "text-foreground", children: narrowLabel ?? label })] })) : (_jsxs("div", { "data-testid": testId, className: "flex min-w-0 items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5", children: [icon, _jsx("span", { className: cn("text-2xl font-semibold leading-none tabular-nums", TONE_VALUE[tone]), children: value }), _jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: "truncate text-sm font-semibold text-foreground", children: label }), sub !== undefined && (_jsx("span", { className: "truncate text-xs text-muted-foreground", children: sub }))] }), delta !== undefined && (_jsxs("span", { className: "whitespace-nowrap text-xs font-medium tabular-nums text-muted-foreground", children: [delta.direction === "up" ? "↑" : "↓", delta.value] })), spark !== undefined && (_jsx(Sparkline, { points: spark, className: cn("h-6 w-16 shrink-0", TONE_VALUE[tone]) }))] })) }));
|
|
10
10
|
}
|