@cosmicdrift/kumiko-renderer 0.413.1 → 0.414.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-support.js +4 -0
- package/dist/app/content-previews.d.ts +39 -0
- package/dist/app/content-previews.js +28 -0
- package/dist/app/entity-edit-screen.js +2 -5
- package/dist/app/entity-list-screen.js +30 -50
- package/dist/app/form-schema.d.ts +1 -0
- package/dist/app/form-schema.js +24 -0
- package/dist/app/list-sort-options.d.ts +4 -0
- package/dist/app/list-sort-options.js +11 -0
- package/dist/app/named-filter-facet.d.ts +17 -3
- package/dist/app/named-filter-facet.js +88 -5
- package/dist/app/projection-detail-body.d.ts +2 -4
- package/dist/app/projection-detail-body.js +7 -1
- package/dist/app/projection-detail-guidance-data.d.ts +7 -0
- package/dist/app/projection-detail-guidance-data.js +101 -0
- package/dist/app/projection-detail-guidance.d.ts +13 -0
- package/dist/app/projection-detail-guidance.js +197 -0
- package/dist/app/projection-detail-header-model.d.ts +1 -3
- package/dist/app/projection-detail-header-model.js +4 -8
- package/dist/app/projection-detail-header-region.d.ts +2 -1
- package/dist/app/projection-detail-header-region.js +63 -23
- package/dist/app/projection-detail-header.d.ts +6 -1
- package/dist/app/projection-detail-header.js +75 -18
- package/dist/app/projection-detail-states.d.ts +3 -3
- package/dist/app/projection-list-body.js +4 -2
- package/dist/app/projection-list-render.js +3 -1
- package/dist/app/projection-list-shim.d.ts +4 -1
- package/dist/app/projection-list-shim.js +35 -8
- package/dist/app/reference-link.d.ts +3 -2
- package/dist/app/reference-link.js +19 -4
- package/dist/app/row-actions.js +3 -3
- package/dist/app/screen-access.d.ts +4 -0
- package/dist/app/screen-access.js +19 -0
- package/dist/app/screen-shared.js +3 -1
- package/dist/app/unique-label-keys.d.ts +1 -0
- package/dist/app/unique-label-keys.js +9 -0
- package/dist/app/use-entity-list-payload.d.ts +25 -0
- package/dist/app/use-entity-list-payload.js +57 -0
- package/dist/app/use-entity-range-facets.js +2 -3
- package/dist/app/use-facet-counts.d.ts +5 -0
- package/dist/app/use-facet-counts.js +7 -0
- package/dist/app/use-list-summary-row.d.ts +10 -0
- package/dist/app/use-list-summary-row.js +33 -0
- package/dist/app/use-named-filter-queue.d.ts +20 -0
- package/dist/app/use-named-filter-queue.js +9 -0
- package/dist/app/use-projection-detail-actions.d.ts +4 -4
- package/dist/app/use-projection-detail-actions.js +30 -1
- package/dist/app/use-projection-list-data.d.ts +5 -0
- package/dist/app/use-projection-list-data.js +35 -6
- package/dist/app/use-projection-list-query.d.ts +2 -0
- package/dist/app/use-projection-list-query.js +29 -16
- package/dist/app/use-related-list-tab-counts.js +5 -1
- package/dist/app/use-row-decoration.d.ts +11 -0
- package/dist/app/use-row-decoration.js +55 -0
- package/dist/app/use-screen-list-rows.d.ts +4 -1
- package/dist/app/use-screen-list-rows.js +14 -5
- package/dist/app/use-screen-list-table.d.ts +3 -1
- package/dist/app/use-screen-list-table.js +10 -1
- package/dist/app/write-failed-error.d.ts +1 -0
- package/dist/app/write-failed-error.js +10 -0
- package/dist/compact-tap-classes.d.ts +1 -0
- package/dist/compact-tap-classes.js +3 -0
- package/dist/components/embedded-list-field.js +13 -12
- package/dist/components/list-empty-state.d.ts +8 -1
- package/dist/components/list-empty-state.js +4 -1
- package/dist/components/list-group-page-bridges.d.ts +1 -1
- package/dist/components/list-group-page-bridges.js +2 -2
- package/dist/components/related-list-section.js +4 -22
- package/dist/components/render-edit-action-button.d.ts +3 -1
- package/dist/components/render-edit-action-button.js +5 -3
- package/dist/components/render-edit-render-model.d.ts +2 -2
- package/dist/components/render-edit-types.d.ts +4 -2
- package/dist/components/render-edit.js +3 -1
- package/dist/components/render-list-hint-columns.d.ts +8 -0
- package/dist/components/render-list-hint-columns.js +77 -0
- package/dist/components/render-list-reference-columns.js +4 -2
- package/dist/components/render-list-row-tone.d.ts +3 -0
- package/dist/components/render-list-row-tone.js +10 -0
- package/dist/components/render-list-table-props.d.ts +9 -1
- package/dist/components/render-list-table-props.js +4 -1
- package/dist/components/render-list-toolbar-action.d.ts +1 -2
- package/dist/components/render-list-toolbar-model.d.ts +3 -0
- package/dist/components/render-list-toolbar-model.js +21 -6
- package/dist/components/render-list-toolbar.d.ts +3 -2
- package/dist/components/render-list-toolbar.js +8 -6
- package/dist/components/render-list-types.d.ts +6 -1
- package/dist/components/render-list.js +26 -7
- package/dist/components/use-render-edit-controlled-sync.js +3 -5
- package/dist/components/use-render-edit-draft-save.js +7 -9
- package/dist/components/use-render-edit-schema.d.ts +3 -0
- package/dist/components/use-render-edit-schema.js +15 -0
- package/dist/components/use-render-edit-state.d.ts +1 -0
- package/dist/components/use-render-edit-state.js +4 -1
- package/dist/components/use-render-edit-steps.js +2 -3
- package/dist/components/use-render-list-columns.d.ts +3 -1
- package/dist/components/use-render-list-columns.js +22 -10
- package/dist/context/screen-focus-context.d.ts +14 -0
- package/dist/context/screen-focus-context.js +28 -0
- package/dist/data-table-facet-types.d.ts +2 -0
- package/dist/data-table-view-types.d.ts +20 -1
- package/dist/headless/form/form-controller.js +3 -1
- package/dist/headless/form/zod-bridge.d.ts +7 -1
- package/dist/headless/form/zod-bridge.js +10 -0
- package/dist/headless/index.d.ts +2 -1
- package/dist/headless/index.js +1 -0
- package/dist/headless/pwa-service-worker-meta.d.ts +1 -0
- package/dist/headless/pwa-service-worker-meta.js +3 -0
- package/dist/headless/view-model/index.d.ts +1 -1
- package/dist/headless/view-model/list-file-display.js +3 -2
- package/dist/headless/view-model/list.js +16 -0
- package/dist/headless/view-model/types.d.ts +33 -0
- package/dist/hooks/list-column-layout.js +2 -1
- package/dist/hooks/list-server-groups.js +14 -1
- package/dist/hooks/list-state-schema.d.ts +1 -0
- package/dist/hooks/list-state-schema.js +9 -1
- package/dist/hooks/use-debounced-value.d.ts +1 -0
- package/dist/hooks/use-debounced-value.js +11 -0
- package/dist/hooks/use-list-aggregates.d.ts +5 -1
- package/dist/hooks/use-list-aggregates.js +9 -5
- package/dist/hooks/use-list-table.d.ts +2 -1
- package/dist/hooks/use-list-table.js +3 -9
- package/dist/hooks/use-list-url-state.d.ts +2 -0
- package/dist/hooks/use-list-url-state.js +12 -4
- package/dist/hooks/use-list-view-state.js +23 -3
- package/dist/hooks/use-reference-lookup.js +7 -2
- package/dist/hooks/use-remembered-list-params.d.ts +6 -2
- package/dist/hooks/use-remembered-list-params.js +18 -3
- package/dist/hooks/use-store.js +0 -1
- package/dist/i18n-defaults.js +37 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -1
- package/dist/live/dispatcher-live.js +2 -0
- package/dist/metric-types.d.ts +2 -0
- package/dist/primitives-record-guidance.d.ts +53 -0
- package/dist/primitives-record-guidance.js +1 -0
- package/dist/primitives.d.ts +41 -31
- package/dist/server-clock.d.ts +6 -0
- package/dist/server-clock.js +20 -0
- package/dist/session/session-ended.d.ts +1 -0
- package/dist/session/session-ended.js +2 -2
- package/dist/status-tone.d.ts +1 -0
- package/dist/status-tone.js +5 -0
- package/dist/web/app/browser-locale.js +1 -1
- package/dist/web/app/client-plugin.d.ts +6 -1
- package/dist/web/app/create-app.d.ts +2 -1
- package/dist/web/app/create-app.js +15 -5
- package/dist/web/app/dashboard-body.js +25 -11
- package/dist/web/app/dashboard-header.d.ts +2 -1
- package/dist/web/app/dashboard-header.js +19 -7
- package/dist/web/app/dashboard-list-panel.d.ts +12 -0
- package/dist/web/app/dashboard-list-panel.js +149 -0
- package/dist/web/app/dashboard-narrow-gate.d.ts +6 -0
- package/dist/web/app/dashboard-narrow-gate.js +6 -0
- package/dist/web/app/dashboard-narrow-order.d.ts +3 -0
- package/dist/web/app/dashboard-narrow-order.js +6 -0
- package/dist/web/app/dashboard-navigation-link.d.ts +12 -0
- package/dist/web/app/dashboard-navigation-link.js +21 -0
- package/dist/web/app/dashboard-panels.d.ts +6 -23
- package/dist/web/app/dashboard-panels.js +53 -123
- package/dist/web/app/dashboard-reference-list-table.d.ts +5 -1
- package/dist/web/app/dashboard-reference-list-table.js +12 -4
- package/dist/web/app/dashboard-shared.d.ts +23 -7
- package/dist/web/app/dashboard-shared.js +44 -17
- package/dist/web/app/dashboard-stat-group-panel.d.ts +13 -0
- package/dist/web/app/dashboard-stat-group-panel.js +67 -0
- package/dist/web/app/dashboard-text-panel.d.ts +12 -0
- package/dist/web/app/dashboard-text-panel.js +163 -0
- package/dist/web/app/dashboard-text.d.ts +2 -0
- package/dist/web/app/dashboard-text.js +1 -1
- package/dist/web/app/dashboard-visibility.js +1 -1
- package/dist/web/app/relative-time.js +2 -1
- package/dist/web/editor/editor-footer.d.ts +28 -0
- package/dist/web/editor/editor-footer.js +23 -0
- package/dist/web/editor/editor-frame.d.ts +23 -0
- package/dist/web/editor/editor-frame.js +24 -0
- package/dist/web/editor/editor-header.d.ts +36 -0
- package/dist/web/editor/editor-header.js +30 -0
- package/dist/web/editor/editor-rail.d.ts +32 -0
- package/dist/web/editor/editor-rail.js +37 -0
- package/dist/web/editor/editor-workbench.d.ts +34 -0
- package/dist/web/editor/editor-workbench.js +19 -0
- package/dist/web/editor/index.d.ts +6 -0
- package/dist/web/editor/index.js +6 -0
- package/dist/web/editor/relative-when.d.ts +1 -0
- package/dist/web/editor/relative-when.js +18 -0
- package/dist/web/index.d.ts +7 -1
- package/dist/web/index.js +5 -1
- package/dist/web/layout/default-app-shell.js +6 -4
- package/dist/web/layout/focus-aware-sidebar.d.ts +4 -7
- package/dist/web/layout/focus-aware-sidebar.js +5 -7
- package/dist/web/layout/header-action-pinned.d.ts +8 -0
- package/dist/web/layout/header-action-pinned.js +25 -0
- package/dist/web/layout/nav-collapse-state.d.ts +5 -0
- package/dist/web/layout/nav-collapse-state.js +66 -0
- package/dist/web/layout/nav-tree.js +25 -5
- 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.d.ts +8 -0
- package/dist/web/layout/screen-focus.js +42 -0
- package/dist/web/layout/shell-focus.d.ts +6 -5
- package/dist/web/layout/shell-focus.js +12 -9
- package/dist/web/layout/shell-header.js +38 -10
- package/dist/web/layout/sidebar-open-state.d.ts +6 -0
- package/dist/web/layout/sidebar-open-state.js +28 -0
- package/dist/web/layout/uniform-bar-controls.d.ts +2 -2
- package/dist/web/layout/uniform-bar-controls.js +4 -3
- package/dist/web/layout/use-in-app-inbox.js +8 -1
- package/dist/web/layout/workspace-shell.js +6 -4
- package/dist/web/lib/upload-file-ref.d.ts +2 -2
- package/dist/web/lib/upload-file-ref.js +4 -9
- package/dist/web/presence/use-presence.js +7 -2
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +14 -6
- package/dist/web/primitives/calendar-day-picker.js +24 -5
- package/dist/web/primitives/card.js +1 -1
- package/dist/web/primitives/code-input.js +6 -1
- package/dist/web/primitives/data-table/actions-column.d.ts +1 -0
- package/dist/web/primitives/data-table/actions-column.js +4 -2
- package/dist/web/primitives/data-table/card-body.d.ts +5 -0
- package/dist/web/primitives/data-table/card-body.js +47 -5
- package/dist/web/primitives/data-table/card-frame.d.ts +8 -0
- package/dist/web/primitives/data-table/card-frame.js +9 -0
- package/dist/web/primitives/data-table/card-row.js +40 -7
- package/dist/web/primitives/data-table/card-sort-select.d.ts +6 -2
- package/dist/web/primitives/data-table/card-sort-select.js +10 -7
- package/dist/web/primitives/data-table/card-view.js +12 -2
- package/dist/web/primitives/data-table/column-picker-section.js +9 -2
- package/dist/web/primitives/data-table/column-resize-handle.js +3 -4
- package/dist/web/primitives/data-table/column-role.d.ts +1 -0
- package/dist/web/primitives/data-table/column-role.js +1 -0
- package/dist/web/primitives/data-table/data-cell-props.d.ts +5 -0
- package/dist/web/primitives/data-table/data-cell-props.js +5 -0
- package/dist/web/primitives/data-table/density.js +1 -0
- package/dist/web/primitives/data-table/facet-cluster.d.ts +2 -1
- package/dist/web/primitives/data-table/facet-cluster.js +2 -2
- package/dist/web/primitives/data-table/group-band.js +4 -0
- package/dist/web/primitives/data-table/hint-cell.d.ts +16 -0
- package/dist/web/primitives/data-table/hint-cell.js +74 -0
- package/dist/web/primitives/data-table/hint-column-width.d.ts +3 -0
- package/dist/web/primitives/data-table/hint-column-width.js +11 -0
- package/dist/web/primitives/data-table/measure-value.js +2 -3
- package/dist/web/primitives/data-table/row-action-column.d.ts +3 -0
- package/dist/web/primitives/data-table/row-action-column.js +4 -0
- package/dist/web/primitives/data-table/sort-options-select.d.ts +22 -0
- package/dist/web/primitives/data-table/sort-options-select.js +46 -0
- package/dist/web/primitives/data-table/sortable-header.d.ts +3 -1
- package/dist/web/primitives/data-table/sortable-header.js +5 -3
- package/dist/web/primitives/data-table/table-body.d.ts +1 -1
- package/dist/web/primitives/data-table/table-body.js +5 -3
- package/dist/web/primitives/data-table/table-chrome.js +3 -1
- package/dist/web/primitives/data-table/table-content.js +10 -5
- package/dist/web/primitives/data-table/table-data-cell.js +9 -3
- package/dist/web/primitives/data-table/table-header-row.js +5 -2
- package/dist/web/primitives/data-table/table-view.js +17 -3
- package/dist/web/primitives/data-table/toolbar-end-cluster.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +31 -3
- package/dist/web/primitives/data-table/totals-footer.d.ts +20 -0
- package/dist/web/primitives/data-table/totals-footer.js +40 -9
- package/dist/web/primitives/data-table/use-bulk-selection.js +2 -1
- package/dist/web/primitives/data-table/use-column-pins.js +4 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +1 -0
- package/dist/web/primitives/data-table/use-data-table-state.js +9 -5
- package/dist/web/primitives/data-table/use-measured-column-widths.js +5 -4
- package/dist/web/primitives/data-table/use-row-selection.js +22 -11
- package/dist/web/primitives/data-table/view-menu.js +7 -1
- package/dist/web/primitives/data-table-cell.d.ts +21 -2
- package/dist/web/primitives/data-table-cell.js +96 -19
- package/dist/web/primitives/embedded-file-cell.js +3 -2
- package/dist/web/primitives/embedded-list-cards.js +3 -4
- package/dist/web/primitives/facet-filter.d.ts +4 -2
- package/dist/web/primitives/facet-filter.js +26 -3
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/file-thumbnail.d.ts +6 -2
- package/dist/web/primitives/file-thumbnail.js +13 -6
- package/dist/web/primitives/file-upload.js +3 -2
- package/dist/web/primitives/file-view-action.d.ts +6 -0
- package/dist/web/primitives/file-view-action.js +19 -0
- package/dist/web/primitives/files-dropzone.js +20 -9
- package/dist/web/primitives/form-footer-parts.d.ts +0 -1
- package/dist/web/primitives/form.js +0 -1
- package/dist/web/primitives/hint-reason-row.d.ts +32 -0
- package/dist/web/primitives/hint-reason-row.js +45 -0
- package/dist/web/primitives/index.js +6 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +2 -2
- package/dist/web/primitives/metric.js +8 -6
- 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 +29 -18
- package/dist/web/primitives/reason-box.d.ts +20 -0
- package/dist/web/primitives/reason-box.js +13 -0
- package/dist/web/primitives/record-breadcrumb.d.ts +3 -0
- package/dist/web/primitives/record-breadcrumb.js +11 -0
- package/dist/web/primitives/record-steps.d.ts +3 -0
- package/dist/web/primitives/record-steps.js +45 -0
- package/dist/web/primitives/record-summary.d.ts +3 -0
- package/dist/web/primitives/record-summary.js +18 -0
- package/dist/web/primitives/row-actions.d.ts +3 -1
- package/dist/web/primitives/row-actions.js +14 -5
- package/dist/web/primitives/segmented-select.js +5 -7
- package/dist/web/pwa/pwa-support.d.ts +4 -0
- package/dist/web/pwa/pwa-support.js +113 -0
- package/dist/web/sse/live-events.js +2 -2
- package/dist/web/tokens.js +0 -3
- package/dist/web/widgets/chart-parts.d.ts +7 -1
- package/dist/web/widgets/chart-parts.js +10 -4
- package/dist/web/widgets/collapsible-section.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.d.ts +17 -0
- package/dist/web/widgets/dashboard-list-cards.js +54 -0
- package/dist/web/widgets/dashboard-list.d.ts +37 -5
- package/dist/web/widgets/dashboard-list.js +95 -20
- package/dist/web/widgets/drawer-sizing.js +1 -1
- package/dist/web/widgets/floating-panel.js +4 -2
- package/dist/web/widgets/index.d.ts +2 -0
- package/dist/web/widgets/index.js +2 -0
- package/dist/web/widgets/infinity-list.js +18 -11
- package/dist/web/widgets/preview-width-frame.d.ts +7 -0
- package/dist/web/widgets/preview-width-frame.js +10 -0
- package/dist/web/widgets/section-card.d.ts +1 -1
- package/dist/web/widgets/stacked-area-chrome.js +3 -3
- package/dist/web/widgets/stacked-area-tooltip.js +2 -10
- package/dist/web/widgets/stat-box-cell.d.ts +19 -0
- package/dist/web/widgets/stat-box-cell.js +10 -0
- package/dist/web/widgets/stat.d.ts +10 -1
- package/dist/web/widgets/stat.js +14 -5
- package/dist/web/widgets/status-badge.d.ts +7 -5
- package/dist/web/widgets/status-badge.js +2 -2
- package/dist/web/widgets/step-bar.d.ts +1 -1
- package/dist/web/widgets/step-bar.js +37 -7
- package/dist/web/widgets/upload-zone.d.ts +8 -1
- package/dist/web/widgets/upload-zone.js +13 -3
- package/package.json +5 -5
- package/src/changes.json +217 -0
- package/src/web/styles.css +9 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Page widths of a rendered preview live here, inside the Tailwind scan surface, so feature code
|
|
3
|
+
// picks a device instead of carrying its own max-w classes.
|
|
4
|
+
const PREVIEW_WIDTH_CLASS = {
|
|
5
|
+
desktop: "mx-auto w-full max-w-[760px]",
|
|
6
|
+
mobile: "mx-auto w-full max-w-[375px]",
|
|
7
|
+
};
|
|
8
|
+
export function PreviewWidthFrame({ device, children, testId, }) {
|
|
9
|
+
return (_jsx("div", { className: PREVIEW_WIDTH_CLASS[device], "data-testid": testId, "data-device": device, children: children }));
|
|
10
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { ReactNode } from "react";
|
|
|
3
3
|
* replaces repeated `<section className={CARD}>…<h2>` blocks in
|
|
4
4
|
* custom screens. Thin wrapper around the Card primitive. */
|
|
5
5
|
export declare function SectionCard({ title, subtitle, action, footer, children, testId, }: {
|
|
6
|
-
readonly title
|
|
6
|
+
readonly title?: string;
|
|
7
7
|
readonly subtitle?: string;
|
|
8
8
|
readonly action?: ReactNode;
|
|
9
9
|
readonly footer?: ReactNode;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
|
-
import { chartColor, seriesTotal
|
|
3
|
+
import { chartColor, seriesTotal } from "./chart-data.js";
|
|
4
4
|
import { MarkerLegend, markerLegendItems } from "./chart-markers.js";
|
|
5
5
|
import { ChartLegend, YTicks } from "./chart-parts.js";
|
|
6
6
|
import { ModeSwitch } from "./mode-switch.js";
|
|
7
7
|
import { StackedAreaBrush } from "./stacked-area-brush.js";
|
|
8
|
-
import { STACKED_AREA_PLOT_HEIGHT_CLASS } from "./stacked-area-geometry.js";
|
|
8
|
+
import { bucketTotals, STACKED_AREA_PLOT_HEIGHT_CLASS } from "./stacked-area-geometry.js";
|
|
9
9
|
import { renderStackedAreaPlot } from "./stacked-area-plot.js";
|
|
10
10
|
const SCROLLABLE_BUCKET_WIDTH_PX = 48;
|
|
11
11
|
export function renderRangeSwitch(m) {
|
|
@@ -23,7 +23,7 @@ export function renderBrushBar(m) {
|
|
|
23
23
|
const { allTimes, visibleWindow, changeSelection } = m.win;
|
|
24
24
|
if (!brush || allTimes.length < 2)
|
|
25
25
|
return undefined;
|
|
26
|
-
return (_jsx(StackedAreaBrush, { times: allTimes, totals: allTimes
|
|
26
|
+
return (_jsx(StackedAreaBrush, { times: allTimes, totals: bucketTotals(allTimes, allSeries), window: visibleWindow, labels: brushLabels, onChange: (next) => changeSelection({ kind: "brush", startMs: next.startMs, endMs: next.endMs }), testId: `${testId ?? "stacked-area"}-brush` }));
|
|
27
27
|
}
|
|
28
28
|
function renderPlotArea(m, scrollRef) {
|
|
29
29
|
const plot = renderStackedAreaPlot(m);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
import { chartColor, percent, valueAt } from "./chart-data.js";
|
|
4
|
+
import { ChartSwatch } from "./chart-parts.js";
|
|
4
5
|
import { bucketIndexAtFraction } from "./chart-window.js";
|
|
5
6
|
import { STACKED_AREA_PLOT_HEIGHT_CLASS } from "./stacked-area-geometry.js";
|
|
6
7
|
const TOOLTIP_WIDTH_REM = 14;
|
|
@@ -35,15 +36,6 @@ function buildTooltipRows(m, tooltipAtMs) {
|
|
|
35
36
|
}),
|
|
36
37
|
];
|
|
37
38
|
}
|
|
38
|
-
function renderTooltipSwatch(row) {
|
|
39
|
-
if (row.swatch === "area") {
|
|
40
|
-
return (_jsx("span", { "aria-hidden": "true", className: "size-2 shrink-0 rounded-[2px]", style: { backgroundColor: row.color } }));
|
|
41
|
-
}
|
|
42
|
-
return (_jsx("span", { "aria-hidden": "true", className: "w-3 shrink-0 border-t-2", style: {
|
|
43
|
-
borderColor: row.color,
|
|
44
|
-
borderTopStyle: row.swatch === "dashed-line" ? "dashed" : "solid",
|
|
45
|
-
} }));
|
|
46
|
-
}
|
|
47
39
|
function renderTooltipCard(m, tooltipAtMs) {
|
|
48
40
|
const tooltipFraction = m.win.fractionOf(tooltipAtMs);
|
|
49
41
|
const tooltipOnLeft = tooltipFraction > 0.5;
|
|
@@ -51,7 +43,7 @@ function renderTooltipCard(m, tooltipAtMs) {
|
|
|
51
43
|
const tooltipLeft = tooltipOnLeft
|
|
52
44
|
? `max(0px, calc(${tooltipEdge} - ${TOOLTIP_WIDTH_REM}rem))`
|
|
53
45
|
: `max(0px, min(calc(${tooltipEdge}), calc(100% - ${TOOLTIP_WIDTH_REM}rem)))`;
|
|
54
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": "true", className: "pointer-events-none absolute inset-y-0 w-px bg-foreground/40", style: { left: percent(tooltipFraction) } }), _jsxs("div", { "data-testid": "chart-tooltip", "data-side": tooltipOnLeft ? "left" : "right", className: "pointer-events-none absolute top-2 rounded-md border bg-popover p-2 text-xs text-popover-foreground shadow-sm", style: { left: tooltipLeft, width: `min(${TOOLTIP_WIDTH_REM}rem, 100%)` }, children: [_jsx("div", { className: "mb-1 font-medium", children: m.win.formatBucket(tooltipAtMs) }), buildTooltipRows(m, tooltipAtMs).map((row) => (_jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
46
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": "true", className: "pointer-events-none absolute inset-y-0 w-px bg-foreground/40", style: { left: percent(tooltipFraction) } }), _jsxs("div", { "data-testid": "chart-tooltip", "data-side": tooltipOnLeft ? "left" : "right", className: "pointer-events-none absolute top-2 rounded-md border bg-popover p-2 text-xs text-popover-foreground shadow-sm", style: { left: tooltipLeft, width: `min(${TOOLTIP_WIDTH_REM}rem, 100%)` }, children: [_jsx("div", { className: "mb-1 font-medium", children: m.win.formatBucket(tooltipAtMs) }), buildTooltipRows(m, tooltipAtMs).map((row) => (_jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx(ChartSwatch, { color: row.color, swatch: row.swatch, className: "shrink-0" }), _jsx("span", { className: "min-w-0 truncate text-muted-foreground", children: row.label }), _jsx("span", { className: "ml-auto tabular-nums", children: m.props.formatAxisValue(row.value) })] }, row.key)))] })] }));
|
|
55
47
|
}
|
|
56
48
|
function bucketAtMsUnderPointer(m, event) {
|
|
57
49
|
const { times, visibleWindow } = m.win;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type StatDelta, type StatLink, type StatTone } from "./stat.tsx";
|
|
3
|
+
type StatBoxCellProps = {
|
|
4
|
+
readonly label: string;
|
|
5
|
+
/** Replaces `label` in the one-line phone variant. */
|
|
6
|
+
readonly narrowLabel?: string;
|
|
7
|
+
readonly value: string;
|
|
8
|
+
readonly sub?: string;
|
|
9
|
+
readonly tone?: StatTone;
|
|
10
|
+
readonly icon?: ReactNode;
|
|
11
|
+
readonly delta?: StatDelta;
|
|
12
|
+
readonly spark?: readonly number[];
|
|
13
|
+
readonly testId?: string;
|
|
14
|
+
readonly link?: StatLink;
|
|
15
|
+
};
|
|
16
|
+
/** Cell of a titled stat strip. From `sm` a box: the number large on the left, label bold and
|
|
17
|
+
* sub line small beside it. Below `sm` plain text "<number> <label>" that joins the strip's single line. */
|
|
18
|
+
export declare function StatBoxCell({ label, narrowLabel, value, sub, tone, icon, delta, spark, testId, link, }: StatBoxCellProps): ReactNode;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
|
|
4
|
+
import { Sparkline, StatLinkFrame, TONE_VALUE, } from "./stat.js";
|
|
5
|
+
/** Cell of a titled stat strip. From `sm` a box: the number large on the left, label bold and
|
|
6
|
+
* sub line small beside it. Below `sm` plain text "<number> <label>" that joins the strip's single line. */
|
|
7
|
+
export function StatBoxCell({ label, narrowLabel, value, sub, tone = "default", icon, delta, spark, testId, link, }) {
|
|
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-md border border-border bg-background px-3 py-2", 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
|
+
}
|
|
@@ -2,11 +2,17 @@ import type { DashboardStatTone } from "@cosmicdrift/kumiko-types/screen";
|
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
export type StatTone = DashboardStatTone;
|
|
4
4
|
export declare const STAT_CARD_GRID_CLASSES = "grid grid-cols-[repeat(auto-fit,minmax(min(12rem,100%),1fr))] gap-3";
|
|
5
|
+
export declare const TONE_VALUE: Record<StatTone, string>;
|
|
5
6
|
/** Makes a tile a link; `onPress` is the SPA navigation, `href` serves modified clicks and a11y. */
|
|
6
7
|
export type StatLink = {
|
|
7
8
|
readonly href: string;
|
|
8
9
|
readonly onPress: () => void;
|
|
9
10
|
};
|
|
11
|
+
export declare function StatLinkFrame({ link, testId, children, }: {
|
|
12
|
+
readonly link: StatLink | undefined;
|
|
13
|
+
readonly testId: string | undefined;
|
|
14
|
+
readonly children: ReactNode;
|
|
15
|
+
}): ReactNode;
|
|
10
16
|
export type StatDelta = {
|
|
11
17
|
readonly value: string;
|
|
12
18
|
readonly direction: "up" | "down";
|
|
@@ -18,10 +24,11 @@ export declare function Sparkline({ points, className, }: {
|
|
|
18
24
|
}): ReactNode;
|
|
19
25
|
/** Icon-bearing metric tile with an optional delta chip, trend line,
|
|
20
26
|
* and sparkline. `icon` is a ready-made node (the app supplies its SVG). */
|
|
21
|
-
export declare function StatCard({ icon, label, value, sub, tone, accentColor, delta, trend, spark, testId, link, children, }: {
|
|
27
|
+
export declare function StatCard({ icon, label, value, sub, tone, accentColor, delta, trend, spark, testId, link, navigable, children, }: {
|
|
22
28
|
readonly icon?: ReactNode;
|
|
23
29
|
readonly label: string;
|
|
24
30
|
readonly value: string;
|
|
31
|
+
/** Small text on the baseline right behind the value. */
|
|
25
32
|
readonly sub?: string;
|
|
26
33
|
readonly tone?: StatTone;
|
|
27
34
|
readonly accentColor?: string;
|
|
@@ -30,6 +37,8 @@ export declare function StatCard({ icon, label, value, sub, tone, accentColor, d
|
|
|
30
37
|
readonly spark?: readonly number[];
|
|
31
38
|
readonly testId?: string;
|
|
32
39
|
readonly link?: StatLink;
|
|
40
|
+
/** Draws a small arrow top right: the tile leads somewhere. Implied by `link`. */
|
|
41
|
+
readonly navigable?: boolean;
|
|
33
42
|
/** Extra content below the built-in fields (e.g. a usage meter) — kept
|
|
34
43
|
* inside the same card chrome instead of stacking a second bordered box. */
|
|
35
44
|
readonly children?: ReactNode;
|
package/dist/web/widgets/stat.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowUpRight } from "lucide-react";
|
|
2
3
|
import { usePrimitives } from "../../index.js";
|
|
3
4
|
import { cn } from "../lib/cn.js";
|
|
4
5
|
// One grid for every row of StatCards (dashboard stat groups, detail metric tiles), so the
|
|
@@ -11,14 +12,21 @@ const TONE_CHIP = {
|
|
|
11
12
|
warn: "bg-destructive/10 text-destructive",
|
|
12
13
|
negative: "bg-status-bad-surface text-status-bad",
|
|
13
14
|
};
|
|
14
|
-
const TONE_VALUE = {
|
|
15
|
+
export const TONE_VALUE = {
|
|
15
16
|
default: "text-foreground",
|
|
16
17
|
positive: "text-primary",
|
|
17
18
|
ok: "text-status-ok",
|
|
18
19
|
warn: "text-destructive",
|
|
19
20
|
negative: "text-status-bad",
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
+
const TONE_STRIPE = {
|
|
23
|
+
default: "",
|
|
24
|
+
positive: "border-l-[3px] border-l-primary",
|
|
25
|
+
ok: "border-l-[3px] border-l-status-ok",
|
|
26
|
+
warn: "border-l-[3px] border-l-status-warn",
|
|
27
|
+
negative: "border-l-[3px] border-l-status-bad",
|
|
28
|
+
};
|
|
29
|
+
export function StatLinkFrame({ link, testId, children, }) {
|
|
22
30
|
const { Link } = usePrimitives();
|
|
23
31
|
if (link === undefined)
|
|
24
32
|
return children;
|
|
@@ -53,19 +61,20 @@ function StatIconChip({ icon, tone, accentColor, }) {
|
|
|
53
61
|
}
|
|
54
62
|
/** Icon-bearing metric tile with an optional delta chip, trend line,
|
|
55
63
|
* and sparkline. `icon` is a ready-made node (the app supplies its SVG). */
|
|
56
|
-
export function StatCard({ icon, label, value, sub, tone = "default", accentColor, delta, trend, spark, testId, link, children, }) {
|
|
64
|
+
export function StatCard({ icon, label, value, sub, tone = "default", accentColor, delta, trend, spark, testId, link, navigable = false, children, }) {
|
|
57
65
|
const { Card } = usePrimitives();
|
|
66
|
+
const leadsSomewhere = navigable || link !== undefined;
|
|
58
67
|
// StatCard is a reusable small-tile widget (a metrics dashboard grid, not
|
|
59
68
|
// a whole-section frame) — an extension section mounting several of
|
|
60
69
|
// these renders a grid of tiles inside its own host Card, not a
|
|
61
70
|
// duplicate outer frame around the section's full content.
|
|
62
|
-
const tile = (_jsxs(Card, { options: { padded: false }, className: "p-4", testId: testId, children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-x-2 gap-y-1", children: [_jsxs("div", { className: "flex min-w-0 flex-1 basis-[7rem] items-center gap-2 text-muted-foreground", children: [icon !== undefined && _jsx(StatIconChip, { icon: icon, tone: tone, accentColor: accentColor }), _jsx("span", { title: label, className: "min-w-0 line-clamp-2 text-xs font-medium", children: label })] }), delta !== undefined && (_jsxs("span", { className: cn("inline-flex shrink-0 items-center gap-0.5 whitespace-nowrap rounded-full px-1.5 py-0.5 text-xs font-medium tabular-nums", TONE_CHIP[delta.tone ?? tone]), children: [delta.direction === "up" ? "↑" : "↓", delta.value] }))] }),
|
|
71
|
+
const tile = (_jsxs(Card, { options: { padded: false }, className: cn("relative p-4", TONE_STRIPE[tone]), testId: testId, children: [leadsSomewhere && (_jsx(ArrowUpRight, { className: "absolute right-3 top-3 size-3.5 text-muted-foreground", "aria-hidden": "true", "data-kumiko-layout": "stat-card-arrow" })), _jsxs("div", { className: cn("flex flex-wrap items-start justify-between gap-x-2 gap-y-1", leadsSomewhere && "pr-5"), children: [_jsxs("div", { className: "flex min-w-0 flex-1 basis-[7rem] items-center gap-2 text-muted-foreground", children: [icon !== undefined && _jsx(StatIconChip, { icon: icon, tone: tone, accentColor: accentColor }), _jsx("span", { title: label, className: "min-w-0 line-clamp-2 text-xs font-medium", children: label })] }), delta !== undefined && (_jsxs("span", { className: cn("inline-flex shrink-0 items-center gap-0.5 whitespace-nowrap rounded-full px-1.5 py-0.5 text-xs font-medium tabular-nums", TONE_CHIP[delta.tone ?? tone]), children: [delta.direction === "up" ? "↑" : "↓", delta.value] }))] }), _jsxs("div", { className: "mt-1.5 flex flex-wrap items-baseline gap-x-2", children: [_jsx("span", { className: cn("text-xl font-semibold tabular-nums", TONE_VALUE[tone]), children: value }), sub !== undefined && _jsx("span", { className: "text-xs text-muted-foreground", children: sub })] }), trend !== undefined && (_jsx("div", { className: "mt-0.5 text-xs font-medium text-foreground/80", children: trend })), spark !== undefined && (_jsx(Sparkline, { points: spark, className: cn("mt-2 h-7 w-full", TONE_VALUE[tone]) })), children !== undefined && _jsx("div", { className: "mt-3", children: children })] }));
|
|
63
72
|
return (_jsx(StatLinkFrame, { link: link, testId: testId, children: tile }));
|
|
64
73
|
}
|
|
65
74
|
/** Flat KPI cell for a strip (divider instead of card): label, value with
|
|
66
75
|
* sparkline beside it, sub line. */
|
|
67
76
|
export function StatStripCell({ icon, label, value, sub, tone = "default", accentColor, delta, spark, testId, link, }) {
|
|
68
|
-
return (_jsx(StatLinkFrame, { link: link, testId: testId, children: _jsxs("div", { "data-testid": testId, className: "flex min-w-0 flex-col gap-1 px-4 py-3", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-2 gap-y-1", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2 text-xs font-medium text-muted-foreground", children: [icon !== undefined && (_jsx(StatIconChip, { icon: icon, tone: tone, accentColor: accentColor })), _jsx("span", { children: label })] }), delta !== undefined && (_jsxs("span", { className: cn("inline-flex shrink-0 items-center gap-0.5 whitespace-nowrap rounded-full px-1.5 py-0.5 text-xs font-medium tabular-nums", TONE_CHIP[delta.tone ?? tone]), children: [delta.direction === "up" ? "↑" : "↓", delta.value] }))] }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsx("span", { className: cn("text-xl font-semibold tabular-nums", TONE_VALUE[tone]), children: value }), spark !== undefined && (_jsx(Sparkline, { points: spark, className: cn("h-7 w-20 shrink-0", TONE_VALUE[tone]) }))] }), sub !== undefined && _jsx("div", { className: "text-xs text-muted-foreground", children: sub })] }) }));
|
|
77
|
+
return (_jsx(StatLinkFrame, { link: link, testId: testId, children: _jsxs("div", { "data-testid": testId, className: "flex min-w-0 flex-col gap-1 px-4 py-3", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-2 gap-y-1", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2 text-xs font-medium text-muted-foreground", children: [icon !== undefined && (_jsx(StatIconChip, { icon: icon, tone: tone, accentColor: accentColor })), _jsx("span", { children: label })] }), delta !== undefined && (_jsxs("span", { className: cn("inline-flex shrink-0 items-center gap-0.5 whitespace-nowrap rounded-full px-1.5 py-0.5 text-xs font-medium tabular-nums", TONE_CHIP[delta.tone ?? tone]), children: [delta.direction === "up" ? "↑" : "↓", delta.value] }))] }), _jsxs("div", { className: "flex shrink-0 items-center gap-3", children: [_jsx("span", { className: cn("text-xl font-semibold tabular-nums", TONE_VALUE[tone]), children: value }), spark !== undefined && (_jsx(Sparkline, { points: spark, className: cn("h-7 w-20 shrink-0", TONE_VALUE[tone]) }))] }), sub !== undefined && _jsx("div", { className: "text-xs text-muted-foreground", children: sub })] }) }));
|
|
69
78
|
}
|
|
70
79
|
/** Compact metric tile (without an icon) — for dense KPI grids.
|
|
71
80
|
* StatCard is the icon-bearing variant. */
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
|
|
2
|
+
import type { StatusBadgeOptionTone, StatusTone } from "../../status-tone.ts";
|
|
3
|
+
export type { StatusTone };
|
|
3
4
|
export declare const STATUS_TONE_TEXT: Record<StatusTone, string>;
|
|
4
|
-
/** `accent` is a brand
|
|
5
|
-
|
|
6
|
-
export type StatusBadgeTone = StatusTone | "accent";
|
|
5
|
+
/** `accent` is a brand tone select options can request; toasts only use `StatusTone`. */
|
|
6
|
+
export type StatusBadgeTone = StatusBadgeOptionTone;
|
|
7
7
|
export declare const TONE_PILL: Record<StatusBadgeTone, string>;
|
|
8
8
|
/** Pill badge with a status dot. Caller maps domain values to a tone
|
|
9
9
|
* (e.g. operational→ok, investigating→warn) and passes the translated
|
|
10
10
|
* label as children. */
|
|
11
|
-
export declare function StatusBadge({ tone, children, className, testId, }: {
|
|
11
|
+
export declare function StatusBadge({ tone, children, className, testId, dot, }: {
|
|
12
12
|
readonly tone: StatusBadgeTone;
|
|
13
|
+
/** `false` draws the pill without its leading dot. */
|
|
14
|
+
readonly dot?: boolean;
|
|
13
15
|
readonly children: ReactNode;
|
|
14
16
|
readonly className?: string;
|
|
15
17
|
readonly testId?: string;
|
|
@@ -19,8 +19,8 @@ export const TONE_PILL = {
|
|
|
19
19
|
/** Pill badge with a status dot. Caller maps domain values to a tone
|
|
20
20
|
* (e.g. operational→ok, investigating→warn) and passes the translated
|
|
21
21
|
* label as children. */
|
|
22
|
-
export function StatusBadge({ tone, children, className, testId, }) {
|
|
22
|
+
export function StatusBadge({ tone, children, className, testId, dot = true, }) {
|
|
23
23
|
return (_jsxs("span", { "data-testid": testId, className: cn(
|
|
24
24
|
// Px on phones: an app may shrink its root font for desktop density, the phone reading size stays.
|
|
25
|
-
"inline-flex h-5 items-center gap-1.5 whitespace-nowrap rounded-full px-2 text-xs font-medium max-md:h-[20px] max-md:text-[12px]", TONE_PILL[tone], className), children: [_jsx("span", { "aria-hidden": "true", "data-status-dot": true, className: "size-1.5 shrink-0 rounded-full bg-current" }), children] }));
|
|
25
|
+
"inline-flex h-5 items-center gap-1.5 whitespace-nowrap rounded-full px-2 text-xs font-medium max-md:h-[20px] max-md:text-[12px]", TONE_PILL[tone], className), children: [dot && (_jsx("span", { "aria-hidden": "true", "data-status-dot": true, className: "size-1.5 shrink-0 rounded-full bg-current" })), children] }));
|
|
26
26
|
}
|
|
@@ -21,7 +21,7 @@ export declare function StepBar({ steps, currentIndex, compactLabel, onStepSelec
|
|
|
21
21
|
readonly doneSteps?: readonly boolean[];
|
|
22
22
|
readonly selectableSteps?: "done" | "all";
|
|
23
23
|
readonly narrowLayout?: "label" | "steps";
|
|
24
|
-
readonly orientation?: "horizontal" | "vertical";
|
|
24
|
+
readonly orientation?: "horizontal" | "vertical" | "stacked";
|
|
25
25
|
readonly heading?: string;
|
|
26
26
|
readonly description?: string;
|
|
27
27
|
readonly subtitles?: readonly (string | undefined)[];
|
|
@@ -12,6 +12,34 @@ function StepRailRow({ index, label, subtitle, subtitleTestId, rowTestId, state:
|
|
|
12
12
|
const content = (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", className: cn("flex size-[22px] shrink-0 items-center justify-center rounded-full border text-xs font-semibold", isCurrent && "border-primary bg-primary text-primary-foreground", isDone && "border-status-ok-surface bg-status-ok-surface text-status-ok", !isCurrent && !isDone && "border-input bg-card text-foreground-secondary"), children: isDone ? _jsx(Check, { className: "size-3" }) : index + 1 }), isDone && _jsx("span", { className: "sr-only", children: doneLabel }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { children: label }), subtitle !== undefined && (_jsx("span", { "data-testid": subtitleTestId, className: "text-xs font-normal text-foreground-secondary", children: subtitle }))] })] }));
|
|
13
13
|
return isSelectable ? (_jsx("button", { type: "button", onClick: () => onSelect?.(index), "data-testid": rowTestId, className: cn(rowClass, "hover:bg-muted-foreground/10"), children: content })) : (_jsx("span", { "aria-current": isCurrent ? "step" : undefined, "data-testid": rowTestId, className: rowClass, children: content }));
|
|
14
14
|
}
|
|
15
|
+
function RailHeading({ heading, description, }) {
|
|
16
|
+
return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("span", { className: "text-sm font-semibold text-foreground", children: heading }), description !== undefined && (_jsx("span", { className: "text-[13px] text-foreground-secondary", children: description }))] }));
|
|
17
|
+
}
|
|
18
|
+
function UpNextBox({ upNext, testId, }) {
|
|
19
|
+
return (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-up-next` : undefined, className: "mt-2 flex flex-col gap-1 rounded-md border border-border bg-card px-3 py-2.5", children: [_jsx("span", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: upNext.heading }), _jsx("span", { className: "text-sm font-medium text-foreground", children: upNext.title }), upNext.subtitle !== undefined && (_jsx("span", { className: "text-xs text-foreground-secondary", children: upNext.subtitle }))] }));
|
|
20
|
+
}
|
|
21
|
+
// `selectable` is false without an onStepSelect handler, else the selectableSteps mode.
|
|
22
|
+
function stepStateAt(index, { currentIndex, doneSteps, selectable, }) {
|
|
23
|
+
const isCurrent = index === currentIndex;
|
|
24
|
+
const isDone = !isCurrent && (doneSteps !== undefined ? doneSteps[index] === true : index < currentIndex);
|
|
25
|
+
const isSelectable = selectable !== false && !isCurrent && (selectable === "all" || isDone);
|
|
26
|
+
return { isCurrent, isDone, isSelectable };
|
|
27
|
+
}
|
|
28
|
+
function ChainMarker({ state }) {
|
|
29
|
+
const { isCurrent, isDone } = state;
|
|
30
|
+
return (_jsxs("span", { "aria-hidden": "true", className: cn("z-10 mt-0.5 flex size-[18px] shrink-0 items-center justify-center rounded-full border-2 bg-card", isDone && "border-status-ok bg-status-ok text-primary-foreground", isCurrent && "border-status-warn", !isDone && !isCurrent && "border-input"), children: [isDone && _jsx(Check, { className: "size-3", strokeWidth: 3 }), isCurrent && _jsx("span", { className: "size-2 rounded-full bg-status-warn" })] }));
|
|
31
|
+
}
|
|
32
|
+
// Chain look: a vertical connector joins the markers; done is a filled check, current a ring with
|
|
33
|
+
// a dot (title in the warn tone), open an empty ring. No numbers, no box around the current step.
|
|
34
|
+
function StackedStageList({ steps, subtitles, stepState, onSelect, doneLabel, testId, }) {
|
|
35
|
+
const keyed = steps.map((label, index) => ({ label, index, key: `${index}-${label}` }));
|
|
36
|
+
return (_jsx("ol", { "data-testid": testId, className: "m-0 flex list-none flex-col p-0", children: keyed.map(({ label, index, key }) => {
|
|
37
|
+
const state = stepState(index);
|
|
38
|
+
const subtitle = subtitles?.[index];
|
|
39
|
+
const body = (_jsxs(_Fragment, { children: [_jsxs("span", { className: "relative flex flex-col items-center self-stretch", children: [_jsx(ChainMarker, { state: state }), index < keyed.length - 1 && (_jsx("span", { "aria-hidden": "true", "data-kumiko-layout": "step-chain-connector", className: "absolute -bottom-0.5 left-1/2 top-5 w-px -translate-x-1/2 bg-input" }))] }), state.isDone && _jsx("span", { className: "sr-only", children: doneLabel }), _jsxs("span", { className: "flex min-w-0 flex-col pb-3", children: [_jsx("span", { className: cn("text-sm", state.isCurrent ? "font-semibold text-status-warn" : "text-foreground", !state.isCurrent && !state.isDone && "text-foreground-secondary"), children: label }), subtitle !== undefined && (_jsx("span", { "data-testid": testId !== undefined ? `${testId}-subtitle-${index}` : undefined, className: "text-xs text-foreground-secondary", children: subtitle }))] })] }));
|
|
40
|
+
return (_jsx("li", { children: state.isSelectable ? (_jsx("button", { type: "button", onClick: () => onSelect?.(index), "data-testid": chipTestId(testId, index), className: "flex w-full items-stretch gap-2.5 text-left hover:opacity-80", children: body })) : (_jsx("span", { "aria-current": state.isCurrent ? "step" : undefined, "data-testid": chipTestId(testId, index), className: "flex w-full items-stretch gap-2.5", children: body })) }, key));
|
|
41
|
+
}) }));
|
|
42
|
+
}
|
|
15
43
|
function CompactStepPicker({ steps, compactLabel, subtitles, stepState, onStepSelect, compactTestId, doneLabel, }) {
|
|
16
44
|
const [open, setOpen] = useState(false);
|
|
17
45
|
const listId = useId();
|
|
@@ -42,16 +70,18 @@ function CompactStepPicker({ steps, compactLabel, subtitles, stepState, onStepSe
|
|
|
42
70
|
* pattern as embedded-list-input.tsx's desktop/mobile split). */
|
|
43
71
|
export function StepBar({ steps, currentIndex, compactLabel, onStepSelect, doneSteps, selectableSteps = "done", narrowLayout = "label", orientation = "horizontal", heading, description, subtitles, upNext, testId, compactTestId, }) {
|
|
44
72
|
const t = useTranslation();
|
|
45
|
-
const stepState = (i) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
73
|
+
const stepState = (i) => stepStateAt(i, {
|
|
74
|
+
currentIndex,
|
|
75
|
+
doneSteps,
|
|
76
|
+
selectable: onStepSelect !== undefined && selectableSteps,
|
|
77
|
+
});
|
|
51
78
|
const compactPicker = onStepSelect !== undefined && selectableSteps === "all";
|
|
52
79
|
const pickerElement = compactPicker ? (_jsx(CompactStepPicker, { steps: steps, compactLabel: compactLabel, subtitles: subtitles, stepState: stepState, onStepSelect: onStepSelect, compactTestId: compactTestId, doneLabel: t("kumiko.widget.step-bar.done") })) : null;
|
|
80
|
+
if (orientation === "stacked") {
|
|
81
|
+
return (_jsx(StackedStageList, { steps: steps, subtitles: subtitles, stepState: stepState, onSelect: onStepSelect, doneLabel: t("kumiko.widget.step-bar.done"), testId: testId }));
|
|
82
|
+
}
|
|
53
83
|
if (orientation === "vertical") {
|
|
54
|
-
return (_jsxs(_Fragment, { children: [_jsxs("nav", { className: "hidden w-[280px] shrink-0 flex-col gap-4 overflow-y-auto border-r border-border bg-muted px-6 py-7 lg:flex", children: [heading !== undefined &&
|
|
84
|
+
return (_jsxs(_Fragment, { children: [_jsxs("nav", { className: "hidden w-[280px] shrink-0 flex-col gap-4 overflow-y-auto border-r border-border bg-muted px-6 py-7 lg:flex", children: [heading !== undefined && _jsx(RailHeading, { heading: heading, description: description }), _jsx("ol", { "data-testid": testId, className: "m-0 flex list-none flex-col gap-0.5 p-0", children: steps.map((label, i) => (_jsx("li", { children: _jsx(StepRailRow, { index: i, label: label, subtitle: subtitles?.[i], subtitleTestId: testId !== undefined ? `${testId}-subtitle-${i}` : undefined, rowTestId: chipTestId(testId, i), state: stepState(i), onSelect: onStepSelect, doneLabel: t("kumiko.widget.step-bar.done") }) }, `${i}-${label}`))) }), upNext !== undefined && _jsx(UpNextBox, { upNext: upNext, testId: testId })] }), compactPicker ? (_jsx("div", { className: "px-4 pt-3 lg:hidden", children: pickerElement })) : (_jsx("p", { "data-testid": compactTestId, className: "px-4 pt-3 text-sm text-muted-foreground lg:hidden", children: compactLabel }))] }));
|
|
55
85
|
}
|
|
56
86
|
return (_jsxs(_Fragment, { children: [_jsx("ol", { "data-testid": testId, className: cn("items-center gap-2", narrowLayout === "steps" ? "flex flex-wrap" : "hidden sm:flex sm:flex-wrap"), children: steps.map((label, i) => {
|
|
57
87
|
const { isCurrent, isDone, isSelectable } = stepState(i);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import type { TrackFormUpload } from "../../components/form-pending-uploads.tsx";
|
|
2
3
|
export type UploadZoneProps = {
|
|
3
4
|
/** Uploads a single file (POST + optional follow-up mutation). Throws on
|
|
4
5
|
* failure — the message ends up in the row's error line. Runs in
|
|
@@ -23,6 +24,12 @@ export type UploadZoneProps = {
|
|
|
23
24
|
/** The values the owner currently holds. Done rows whose value left the list disappear, and
|
|
24
25
|
* going from some to none (an external reset) clears every row, error rows included. */
|
|
25
26
|
readonly doneValues?: readonly string[];
|
|
27
|
+
/** Wraps the whole per-file work, image resize included, so a surrounding form can hold
|
|
28
|
+
* back submit while the file is still being prepared. */
|
|
29
|
+
readonly trackUpload?: TrackFormUpload;
|
|
30
|
+
/** Row label of a value the owner already held (e.g. a FileRef id resolved to its file name).
|
|
31
|
+
* Default: the value itself. */
|
|
32
|
+
readonly labelForValue?: (value: string) => ReactNode;
|
|
26
33
|
};
|
|
27
34
|
export declare function matchesAccept(file: File, accept?: readonly string[]): boolean;
|
|
28
35
|
/** Drop zone + multi-file picker with a per-file status row (uploading/done/
|
|
@@ -30,4 +37,4 @@ export declare function matchesAccept(file: File, accept?: readonly string[]): b
|
|
|
30
37
|
* independently — unlike `FileField` (single file, FileRef value inside a
|
|
31
38
|
* form field). `onUpload` decides what "upload" means (storage POST, ingest
|
|
32
39
|
* mutation, or both); the zone only tracks uploading/done/error. */
|
|
33
|
-
export declare function UploadZone({ onUpload, title, hint, accept, multiple, capture, disabled, testId, describeError, onRemove, doneValues, }: UploadZoneProps): ReactNode;
|
|
40
|
+
export declare function UploadZone({ onUpload, title, hint, accept, multiple, capture, disabled, testId, describeError, onRemove, doneValues, trackUpload, labelForValue, }: UploadZoneProps): ReactNode;
|
|
@@ -44,7 +44,7 @@ function partitionByAccept(files, accept) {
|
|
|
44
44
|
* independently — unlike `FileField` (single file, FileRef value inside a
|
|
45
45
|
* form field). `onUpload` decides what "upload" means (storage POST, ingest
|
|
46
46
|
* mutation, or both); the zone only tracks uploading/done/error. */
|
|
47
|
-
export function UploadZone({ onUpload, title, hint, accept, multiple = true, capture, disabled, testId, describeError, onRemove, doneValues, }) {
|
|
47
|
+
export function UploadZone({ onUpload, title, hint, accept, multiple = true, capture, disabled, testId, describeError, onRemove, doneValues, trackUpload, labelForValue, }) {
|
|
48
48
|
const t = useTranslation();
|
|
49
49
|
const inputId = useId();
|
|
50
50
|
const inputRef = useRef(null);
|
|
@@ -63,7 +63,12 @@ export function UploadZone({ onUpload, title, hint, accept, multiple = true, cap
|
|
|
63
63
|
setRows([]);
|
|
64
64
|
previousDoneCount.current = doneCount;
|
|
65
65
|
}, [doneCount]);
|
|
66
|
-
|
|
66
|
+
function uploadOne(file) {
|
|
67
|
+
return trackUpload === undefined
|
|
68
|
+
? uploadUntracked(file)
|
|
69
|
+
: trackUpload(() => uploadUntracked(file));
|
|
70
|
+
}
|
|
71
|
+
async function uploadUntracked(file) {
|
|
67
72
|
const rowId = String(nextRowId.current++);
|
|
68
73
|
const uploadFile = await resizeImageBeforeUpload(file);
|
|
69
74
|
setRows((prev) => [...prev, { id: rowId, fileName: uploadFile.name, status: "uploading" }]);
|
|
@@ -121,7 +126,12 @@ export function UploadZone({ onUpload, title, hint, accept, multiple = true, cap
|
|
|
121
126
|
? []
|
|
122
127
|
: doneValues
|
|
123
128
|
.filter((value) => !rows.some((row) => row.value === value))
|
|
124
|
-
.map((value) => ({
|
|
129
|
+
.map((value) => ({
|
|
130
|
+
id: `existing:${value}`,
|
|
131
|
+
fileName: labelForValue?.(value) ?? value,
|
|
132
|
+
status: "done",
|
|
133
|
+
value,
|
|
134
|
+
}));
|
|
125
135
|
const visibleRows = [
|
|
126
136
|
...existingRows,
|
|
127
137
|
...rows.filter((row) => row.value === undefined || doneValues === undefined || doneValues.includes(row.value)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.414.0",
|
|
4
4
|
"description": "React renderer for Kumiko screens. The root export holds the platform-agnostic logic (primitives contract, hooks, KumikoScreen, navigation and SSE abstractions); ./headless the DOM-free UI logic, ./live the HTTP dispatcher, ./web the browser bindings (HTML primitives, history navigation, EventSource live events, createKumikoApp).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
52
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
51
|
+
"@cosmicdrift/kumiko-framework": "0.414.0",
|
|
52
|
+
"@cosmicdrift/kumiko-types": "0.414.0",
|
|
53
53
|
"@types/qrcode": "^1.5.6",
|
|
54
54
|
"class-variance-authority": "^0.7.1",
|
|
55
55
|
"clsx": "^2.1.1",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@cosmicdrift/kumiko-locale-de": "0.
|
|
83
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
82
|
+
"@cosmicdrift/kumiko-locale-de": "0.414.0",
|
|
83
|
+
"@cosmicdrift/kumiko-testing": "0.414.0",
|
|
84
84
|
"@tailwindcss/cli": "^4.3.3",
|
|
85
85
|
"@testing-library/react": "^16.3.3",
|
|
86
86
|
"@testing-library/user-event": "^14.6.8",
|