@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,113 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { PWA_SERVICE_WORKER_META_NAME } from "../../headless/pwa-service-worker-meta.js";
|
|
4
|
+
import { useTranslation } from "../../index.js";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
export const PWA_INSTALL_HINT_DISMISSED_KEY = "kumiko:pwa-install-hint-dismissed";
|
|
7
|
+
function isBeforeInstallPromptEvent(event) {
|
|
8
|
+
return "prompt" in event && typeof event.prompt === "function";
|
|
9
|
+
}
|
|
10
|
+
export function readPwaServiceWorkerUrl() {
|
|
11
|
+
if (typeof document === "undefined")
|
|
12
|
+
return undefined;
|
|
13
|
+
const content = document
|
|
14
|
+
.querySelector(`meta[name="${PWA_SERVICE_WORKER_META_NAME}"]`)
|
|
15
|
+
?.getAttribute("content");
|
|
16
|
+
return content ? content : undefined;
|
|
17
|
+
}
|
|
18
|
+
function isRunningStandalone() {
|
|
19
|
+
if (typeof window.matchMedia === "function") {
|
|
20
|
+
if (window.matchMedia("(display-mode: standalone)").matches)
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return "standalone" in navigator && navigator.standalone === true;
|
|
24
|
+
}
|
|
25
|
+
// iPadOS reports a desktop Mac user agent; the touch points tell it apart.
|
|
26
|
+
function isIosDevice() {
|
|
27
|
+
const userAgent = navigator.userAgent;
|
|
28
|
+
if (/iPhone|iPad|iPod/.test(userAgent))
|
|
29
|
+
return true;
|
|
30
|
+
return /Macintosh/.test(userAgent) && navigator.maxTouchPoints > 1;
|
|
31
|
+
}
|
|
32
|
+
// Storage can throw (Safari private mode, blocked site data); the hint then just shows again.
|
|
33
|
+
function isInstallHintDismissed() {
|
|
34
|
+
try {
|
|
35
|
+
return window.localStorage.getItem(PWA_INSTALL_HINT_DISMISSED_KEY) === "1";
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function rememberInstallHintDismissed() {
|
|
42
|
+
try {
|
|
43
|
+
window.localStorage.setItem(PWA_INSTALL_HINT_DISMISSED_KEY, "1");
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Not remembered: the hint comes back on the next visit.
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function registerServiceWorker(serviceWorkerUrl) {
|
|
50
|
+
if (!("serviceWorker" in navigator))
|
|
51
|
+
return;
|
|
52
|
+
// Fails on insecure origins and in some private modes; the app works without the worker.
|
|
53
|
+
// The worker may only control its own directory, so the scope follows the worker's URL.
|
|
54
|
+
const scope = new URL("./", new URL(serviceWorkerUrl, window.location.href)).pathname;
|
|
55
|
+
navigator.serviceWorker
|
|
56
|
+
.register(serviceWorkerUrl, { scope, updateViaCache: "none" })
|
|
57
|
+
.catch(() => undefined);
|
|
58
|
+
}
|
|
59
|
+
function useInstallHint(enabled) {
|
|
60
|
+
const [hint, setHint] = useState({ kind: "none" });
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!enabled || isRunningStandalone() || isInstallHintDismissed())
|
|
63
|
+
return;
|
|
64
|
+
if (isIosDevice()) {
|
|
65
|
+
setHint({ kind: "ios" });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const onBeforeInstallPrompt = (event) => {
|
|
69
|
+
if (!isBeforeInstallPromptEvent(event))
|
|
70
|
+
return;
|
|
71
|
+
// Keeps the browser's own mini-infobar away; the hint offers the prompt instead.
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
setHint({ kind: "prompt", event });
|
|
74
|
+
};
|
|
75
|
+
const onAppInstalled = () => {
|
|
76
|
+
rememberInstallHintDismissed();
|
|
77
|
+
setHint({ kind: "none" });
|
|
78
|
+
};
|
|
79
|
+
window.addEventListener("beforeinstallprompt", onBeforeInstallPrompt);
|
|
80
|
+
window.addEventListener("appinstalled", onAppInstalled);
|
|
81
|
+
return () => {
|
|
82
|
+
window.removeEventListener("beforeinstallprompt", onBeforeInstallPrompt);
|
|
83
|
+
window.removeEventListener("appinstalled", onAppInstalled);
|
|
84
|
+
};
|
|
85
|
+
}, [enabled]);
|
|
86
|
+
const dismiss = () => {
|
|
87
|
+
rememberInstallHintDismissed();
|
|
88
|
+
setHint({ kind: "none" });
|
|
89
|
+
};
|
|
90
|
+
return [hint, dismiss];
|
|
91
|
+
}
|
|
92
|
+
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");
|
|
93
|
+
export function PwaSupport() {
|
|
94
|
+
const t = useTranslation();
|
|
95
|
+
const serviceWorkerUrl = readPwaServiceWorkerUrl();
|
|
96
|
+
const [hint, dismiss] = useInstallHint(serviceWorkerUrl !== undefined);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (serviceWorkerUrl !== undefined)
|
|
99
|
+
registerServiceWorker(serviceWorkerUrl);
|
|
100
|
+
}, [serviceWorkerUrl]);
|
|
101
|
+
if (hint.kind === "none")
|
|
102
|
+
return null;
|
|
103
|
+
const install = async (event) => {
|
|
104
|
+
dismiss();
|
|
105
|
+
try {
|
|
106
|
+
await event.prompt();
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// prompt() rejects when the browser already used this event; nothing left to offer.
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return (_jsxs("div", { role: "status", className: cn("fixed inset-x-0 bottom-0 z-[150] flex flex-wrap items-center justify-center gap-3", "border-t bg-background px-4 py-3 text-sm text-foreground shadow-md", "pb-[max(0.75rem,env(safe-area-inset-bottom))]"), children: [_jsx("span", { children: hint.kind === "ios" ? t("kumiko.pwa.install-hint-ios") : t("kumiko.pwa.install-hint") }), hint.kind === "prompt" && (_jsx("button", { type: "button", onClick: () => void install(hint.event), className: cn(HINT_BUTTON_CLASSES, "bg-primary text-primary-foreground"), children: t("kumiko.pwa.install") })), _jsx("button", { type: "button", onClick: dismiss, className: cn(HINT_BUTTON_CLASSES, "border bg-background"), children: t("kumiko.pwa.dismiss") })] }));
|
|
113
|
+
}
|
|
@@ -45,7 +45,6 @@ function hasErrorCode(body) {
|
|
|
45
45
|
async function isSessionEndedRejection(url) {
|
|
46
46
|
const controller = new AbortController();
|
|
47
47
|
try {
|
|
48
|
-
// kumiko-lint-ignore direct-fetch url is the app's own SSE endpoint, probed with same-origin credentials
|
|
49
48
|
const res = await fetch(url, {
|
|
50
49
|
credentials: "same-origin",
|
|
51
50
|
headers: { Accept: "text/event-stream" },
|
|
@@ -166,7 +165,8 @@ export function createEventSourceLiveEvents(options = {}) {
|
|
|
166
165
|
sessionEndedSignalled = true;
|
|
167
166
|
onSessionEnded?.();
|
|
168
167
|
};
|
|
169
|
-
|
|
168
|
+
// Armed on `open`, not here: a scale-from-zero cold start can hold the handshake longer
|
|
169
|
+
// than the stall timeout, and aborting it would restart the cold start on every retry.
|
|
170
170
|
connection.addEventListener("ping", () => armStallWatchdog(connection));
|
|
171
171
|
connection.addEventListener("open", () => {
|
|
172
172
|
armStallWatchdog(connection);
|
package/dist/web/tokens.js
CHANGED
|
@@ -83,11 +83,9 @@ function readCurrentPreference() {
|
|
|
83
83
|
}
|
|
84
84
|
return currentPreference;
|
|
85
85
|
}
|
|
86
|
-
// @wrapper-known semantic-alias
|
|
87
86
|
function notifyThemeChange() {
|
|
88
87
|
themeTick.setState((t) => t + 1);
|
|
89
88
|
}
|
|
90
|
-
// @wrapper-known semantic-alias
|
|
91
89
|
function persistPreference(preference) {
|
|
92
90
|
try {
|
|
93
91
|
window.localStorage.setItem(THEME_STORAGE_KEY, preference);
|
|
@@ -147,7 +145,6 @@ export function useBrowserTokensApi() {
|
|
|
147
145
|
});
|
|
148
146
|
const mode = useSyncExternalStore(themeTick.subscribe, readCurrentMode, () => "dark");
|
|
149
147
|
const preference = useSyncExternalStore(themeTick.subscribe, readCurrentPreference, () => "dark");
|
|
150
|
-
// kumiko-lint-ignore no-raw-hooks listener lifecycle, no data fetching
|
|
151
148
|
useEffect(() => {
|
|
152
149
|
// skip: without matchMedia, auto keeps the mode resolved at apply time
|
|
153
150
|
if (typeof window.matchMedia !== "function")
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
export type ChartSwatchKind = "area" | "line" | "dashed-line";
|
|
3
|
+
export declare function ChartSwatch({ color, swatch, className, }: {
|
|
4
|
+
readonly color: string;
|
|
5
|
+
readonly swatch: ChartSwatchKind;
|
|
6
|
+
readonly className?: string;
|
|
7
|
+
}): ReactNode;
|
|
2
8
|
export declare function ChartLegend({ items, formatValue, }: {
|
|
3
9
|
readonly items: readonly {
|
|
4
10
|
readonly key: string;
|
|
@@ -8,7 +14,7 @@ export declare function ChartLegend({ items, formatValue, }: {
|
|
|
8
14
|
readonly color: string;
|
|
9
15
|
/** Omitted: no sum next to the label. */
|
|
10
16
|
readonly total?: number;
|
|
11
|
-
readonly swatch?:
|
|
17
|
+
readonly swatch?: ChartSwatchKind;
|
|
12
18
|
}[];
|
|
13
19
|
readonly formatValue: (value: number) => string;
|
|
14
20
|
}): ReactNode;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
|
+
export function ChartSwatch({ color, swatch, className, }) {
|
|
4
|
+
if (swatch === "area") {
|
|
5
|
+
return (_jsx("span", { "aria-hidden": "true", className: cn("size-2 rounded-[2px]", className), style: { backgroundColor: color } }));
|
|
6
|
+
}
|
|
7
|
+
return (_jsx("span", { "aria-hidden": "true", className: cn("w-3 border-t-2", className), style: {
|
|
8
|
+
borderColor: color,
|
|
9
|
+
borderTopStyle: swatch === "dashed-line" ? "dashed" : "solid",
|
|
10
|
+
} }));
|
|
11
|
+
}
|
|
3
12
|
export function ChartLegend({ items, formatValue, }) {
|
|
4
|
-
return (_jsx("ul", { className: "flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground", children: items.map((item) => (_jsxs("li", { "data-testid": `chart-legend-${item.testIdKey ?? item.key}`, className: "flex items-center gap-1.5", children: [item.swatch
|
|
5
|
-
borderColor: item.color,
|
|
6
|
-
borderTopStyle: item.swatch === "dashed-line" ? "dashed" : "solid",
|
|
7
|
-
} })), _jsx("span", { children: item.label }), item.total !== undefined && (_jsx("span", { className: "tabular-nums text-foreground", children: formatValue(item.total) }))] }, item.key))) }));
|
|
13
|
+
return (_jsx("ul", { className: "flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground", children: items.map((item) => (_jsxs("li", { "data-testid": `chart-legend-${item.testIdKey ?? item.key}`, className: "flex items-center gap-1.5", children: [_jsx(ChartSwatch, { color: item.color, swatch: item.swatch ?? "area" }), _jsx("span", { children: item.label }), item.total !== undefined && (_jsx("span", { className: "tabular-nums text-foreground", children: formatValue(item.total) }))] }, item.key))) }));
|
|
8
14
|
}
|
|
9
15
|
const Y_TICK_COUNT = 3;
|
|
10
16
|
export function evenYTickValues(max) {
|
|
@@ -13,5 +13,5 @@ export function CollapsibleSection({ title, defaultOpen = false, children, testI
|
|
|
13
13
|
if (defaultOpen)
|
|
14
14
|
setOpen(true);
|
|
15
15
|
}, [defaultOpen]);
|
|
16
|
-
return (_jsxs("details", { "data-testid": testId, className: "group rounded-lg border bg-card", open: open, onToggle: (e) => setOpen(e.currentTarget.open), children: [_jsxs("summary", { className: "flex h-9 cursor-pointer select-none items-center justify-between gap-2 rounded-lg px-4 text-sm font-medium hover:bg-muted/50 [&::-webkit-details-marker]:hidden", children: [_jsx("span", { children: title }), _jsx(ChevronRight, { "aria-hidden": "true", className: "size-4 text-muted-foreground transition-transform group-open:rotate-90" })] }), _jsx("div", { className: "border-t px-4 py-3", children: children })] }));
|
|
16
|
+
return (_jsxs("details", { "data-testid": testId, className: "group rounded-lg border bg-card", open: open, onToggle: (e) => setOpen(e.currentTarget.open), children: [_jsxs("summary", { className: "flex min-h-9 py-1.5 cursor-pointer select-none items-center justify-between gap-2 rounded-lg px-4 text-sm font-medium hover:bg-muted/50 [&::-webkit-details-marker]:hidden", children: [_jsx("span", { children: title }), _jsx(ChevronRight, { "aria-hidden": "true", className: "size-4 text-muted-foreground transition-transform group-open:rotate-90" })] }), _jsx("div", { className: "border-t px-4 py-3", children: children })] }));
|
|
17
17
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type DashboardListColumn, type DashboardListRow } from "./dashboard-list.tsx";
|
|
3
|
+
type CardsProps = {
|
|
4
|
+
readonly columns: readonly DashboardListColumn[];
|
|
5
|
+
readonly rows: readonly DashboardListRow[];
|
|
6
|
+
readonly formatPercent: (fraction: number) => string;
|
|
7
|
+
readonly formatNumber: (value: number) => string;
|
|
8
|
+
readonly formatDateTime: (atMs: number) => string;
|
|
9
|
+
readonly translate: (key: string) => string;
|
|
10
|
+
readonly testId?: string;
|
|
11
|
+
readonly rowToneField?: string;
|
|
12
|
+
/** Row field replacing the hint sentence as card title. */
|
|
13
|
+
readonly titleField?: string;
|
|
14
|
+
};
|
|
15
|
+
/** One card per row for the phone layout of a dashboard list. Row 1: badges and a one-line detail, row 2: the hint sentence, row 3: `showOnNarrowOnly` columns left and the small buttons right. */
|
|
16
|
+
export declare function DashboardListCards({ columns, rows, testId, rowToneField, titleField, ...cellProps }: CardsProps): ReactNode;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isSelectOptionTone } from "../../status-tone.js";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { DIMMED_HINT_SENTENCE_CLASS, HINT_TONE_TEXT_CLASS, isDimmedHintSentence, } from "../primitives/data-table/hint-cell.js";
|
|
5
|
+
import { cardToneClass } from "../primitives/data-table-cell.js";
|
|
6
|
+
import { DashboardListCell, rowToneOf, } from "./dashboard-list.js";
|
|
7
|
+
function nonEmptyText(value) {
|
|
8
|
+
if (typeof value !== "string")
|
|
9
|
+
return undefined;
|
|
10
|
+
const trimmed = value.trim();
|
|
11
|
+
return trimmed === "" ? undefined : trimmed;
|
|
12
|
+
}
|
|
13
|
+
function hasValue(value) {
|
|
14
|
+
return value !== undefined && value !== null && value !== "";
|
|
15
|
+
}
|
|
16
|
+
// The reason toggle of the table is left out on purpose: a phone card shows its facts, not a hidden explanation.
|
|
17
|
+
function CardHeadline({ column, row, titleField, }) {
|
|
18
|
+
const { hint } = column;
|
|
19
|
+
const sentence = (titleField === undefined ? undefined : nonEmptyText(row[titleField])) ??
|
|
20
|
+
nonEmptyText(row[column.field]);
|
|
21
|
+
const toneValue = hint.toneField === undefined ? undefined : row[hint.toneField];
|
|
22
|
+
const tone = isSelectOptionTone(toneValue) ? toneValue : undefined;
|
|
23
|
+
if (sentence === undefined) {
|
|
24
|
+
return (_jsx("span", { "data-hint-empty": "true", className: "text-sm text-muted-foreground", children: hint.emptyLabel }));
|
|
25
|
+
}
|
|
26
|
+
return (_jsx("span", { className: cn("text-sm", isDimmedHintSentence(tone, hint.plainSentence)
|
|
27
|
+
? DIMMED_HINT_SENTENCE_CLASS
|
|
28
|
+
: [
|
|
29
|
+
"font-semibold",
|
|
30
|
+
hint.plainSentence !== true && tone !== undefined && HINT_TONE_TEXT_CLASS[tone],
|
|
31
|
+
]), children: sentence }));
|
|
32
|
+
}
|
|
33
|
+
function detailOf(hint, row) {
|
|
34
|
+
if (hint === undefined)
|
|
35
|
+
return undefined;
|
|
36
|
+
const field = hint.narrowDetailField ?? hint.detailField;
|
|
37
|
+
return field === undefined ? undefined : nonEmptyText(row[field]);
|
|
38
|
+
}
|
|
39
|
+
/** One card per row for the phone layout of a dashboard list. Row 1: badges and a one-line detail, row 2: the hint sentence, row 3: `showOnNarrowOnly` columns left and the small buttons right. */
|
|
40
|
+
export function DashboardListCards({ columns, rows, testId, rowToneField, titleField, ...cellProps }) {
|
|
41
|
+
const hintColumn = columns.find((column) => column.hint !== undefined);
|
|
42
|
+
const plain = columns.filter((column) => column.hint === undefined);
|
|
43
|
+
const badgeColumns = plain.filter((column) => column.display === "badge");
|
|
44
|
+
const buttonColumns = plain.filter((column) => column.display === "button");
|
|
45
|
+
const otherColumns = plain.filter((column) => column.display !== "badge" && column.display !== "button");
|
|
46
|
+
const cell = (column, row) => (_jsx(DashboardListCell, { column: column, row: row, ...cellProps }, column.field));
|
|
47
|
+
return (_jsx("ul", { "data-testid": testId, className: "m-0 flex list-none flex-col gap-2 p-0", children: rows.map((row, index) => {
|
|
48
|
+
const detail = detailOf(hintColumn?.hint, row);
|
|
49
|
+
const badges = badgeColumns.filter((column) => hasValue(row[column.field]));
|
|
50
|
+
const buttons = buttonColumns.filter((column) => hasValue(row[column.field]));
|
|
51
|
+
const others = otherColumns.filter((column) => hasValue(row[column.field]));
|
|
52
|
+
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(rowToneOf(row, rowToneField))), 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 })), (others.length > 0 || buttons.length > 0) && (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("div", { className: "flex min-w-0 flex-col text-xs text-muted-foreground", children: others.map((column) => (_jsx("span", { className: "truncate", children: cell(column, row) }, column.field))) }), 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));
|
|
53
|
+
}) }));
|
|
54
|
+
}
|
|
@@ -1,17 +1,38 @@
|
|
|
1
|
+
import type { DashboardListRowToneMarker, SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
1
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import { type CellLink, type ListColumnHintViewModel, type RuntimeCellLink } from "../../headless/index.ts";
|
|
2
4
|
export type DashboardListColumn = {
|
|
3
5
|
readonly field: string;
|
|
4
6
|
/** Translated by the caller. */
|
|
5
7
|
readonly label: string;
|
|
6
|
-
readonly display?: "bar" | "badge" | "datetime";
|
|
8
|
+
readonly display?: "bar" | "badge" | "datetime" | "button";
|
|
7
9
|
readonly badgeToneField?: string;
|
|
10
|
+
readonly badgeDot?: false;
|
|
8
11
|
/** Resolves the raw cell value to display text, e.g. a reference id to its label. */
|
|
9
12
|
readonly renderValue?: (value: unknown, row: Readonly<Record<string, unknown>>) => string;
|
|
13
|
+
/** Links the rendered text to its target, e.g. a reference cell to the record's detail. */
|
|
14
|
+
readonly linkFor?: RuntimeCellLink;
|
|
15
|
+
/** "To do" cell; owns the rendering, `toneField` already defaulted by the caller. */
|
|
16
|
+
readonly hint?: ListColumnHintViewModel;
|
|
17
|
+
/** `showOnNarrowOnly`: drawn in the phone cards only, never as a table column. */
|
|
18
|
+
readonly narrowOnly?: true;
|
|
10
19
|
};
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
export type DashboardListRow = Readonly<Record<string, unknown>>;
|
|
21
|
+
type Row = DashboardListRow;
|
|
22
|
+
export declare function DashboardListCell({ column, row, formatPercent, formatNumber, formatDateTime, translate, leading, }: {
|
|
23
|
+
/** Only a `hint` column takes it: it stands on the sentence's line, in front of it. */
|
|
24
|
+
readonly leading?: ReactNode;
|
|
25
|
+
readonly column: DashboardListColumn;
|
|
26
|
+
readonly row: Row;
|
|
27
|
+
readonly formatPercent: (fraction: number) => string;
|
|
28
|
+
readonly formatNumber: (value: number) => string;
|
|
29
|
+
readonly formatDateTime: (atMs: number) => string;
|
|
30
|
+
readonly translate: (key: string) => string;
|
|
31
|
+
}): ReactNode;
|
|
32
|
+
export declare function rowToneOf(row: Row, rowToneField: string | undefined): SelectOptionTone | undefined;
|
|
33
|
+
/** Compact table for dashboard lists with optional bar/badge columns. Badge columns in front of a
|
|
34
|
+
* `hint` column join the hint's first line; rows with a tone get 12px of padding above and below. */
|
|
35
|
+
export declare function DashboardListTable({ columns: allColumns, rows, formatPercent, formatNumber, formatDateTime, translate, testId, rowToneField, rowToneMarker, showHeader, rowLink, }: {
|
|
15
36
|
readonly columns: readonly DashboardListColumn[];
|
|
16
37
|
readonly rows: readonly Row[];
|
|
17
38
|
readonly formatPercent: (fraction: number) => string;
|
|
@@ -19,5 +40,16 @@ export declare function DashboardListTable({ columns, rows, formatPercent, forma
|
|
|
19
40
|
readonly formatDateTime: (atMs: number) => string;
|
|
20
41
|
readonly translate: (key: string) => string;
|
|
21
42
|
readonly testId?: string;
|
|
43
|
+
/** Row field holding a SelectOptionTone; tints the row. */
|
|
44
|
+
readonly rowToneField?: string;
|
|
45
|
+
/** "bar" (default): stripe at the row's left edge; "dot": small dot in front of the first cell. */
|
|
46
|
+
readonly rowToneMarker?: DashboardListRowToneMarker;
|
|
47
|
+
/** `false` drops the column header row. */
|
|
48
|
+
readonly showHeader?: boolean;
|
|
49
|
+
/** Row is a link: `linkFor` resolves the target per row, the icon sits in an extra last cell. */
|
|
50
|
+
readonly rowLink?: {
|
|
51
|
+
readonly linkFor: (row: Row) => CellLink | undefined;
|
|
52
|
+
readonly icon: "arrow" | "chevron";
|
|
53
|
+
};
|
|
22
54
|
}): ReactNode;
|
|
23
55
|
export {};
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowUpRight, ChevronRight } from "lucide-react";
|
|
3
|
+
import { EMPTY_VALUE_PLACEHOLDER, } from "../../headless/index.js";
|
|
4
|
+
import { isSelectOptionTone } from "../../status-tone.js";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { HintCell } from "../primitives/data-table/hint-cell.js";
|
|
7
|
+
import { CellTextLink, LINK_BUTTON_CLASS, LIST_BADGE_TONE, rowToneClass, toneDotClass, } from "../primitives/data-table-cell.js";
|
|
8
|
+
import { HintReasonRowScope, hintReasonOf } from "../primitives/hint-reason-row.js";
|
|
3
9
|
import { StatusBadge } from "./status-badge.js";
|
|
4
|
-
const BADGE_TONE = {
|
|
5
|
-
positive: "ok",
|
|
6
|
-
warn: "warn",
|
|
7
|
-
negative: "bad",
|
|
8
|
-
neutral: "muted",
|
|
9
|
-
};
|
|
10
10
|
function fractionOf(raw) {
|
|
11
11
|
return typeof raw === "number" && Number.isFinite(raw) ? Math.max(0, Math.min(1, raw)) : 0;
|
|
12
12
|
}
|
|
13
13
|
// Rows may carry i18n keys (quota labels, failure reasons); translate falls back to the key itself.
|
|
14
14
|
const I18N_KEY_SHAPE = /^[a-z][\w-]*(?:[:.][\w-]+)+$/i;
|
|
15
|
-
function
|
|
15
|
+
export function DashboardListCell({ column, row, formatPercent, formatNumber, formatDateTime, translate, leading, }) {
|
|
16
16
|
const raw = row[column.field];
|
|
17
|
+
if (column.hint !== undefined) {
|
|
18
|
+
return _jsx(HintCell, { value: raw, row: row, hint: column.hint, leading: leading });
|
|
19
|
+
}
|
|
17
20
|
if (column.display === "bar") {
|
|
18
21
|
const fraction = fractionOf(raw);
|
|
19
22
|
return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { role: "progressbar", "aria-valuenow": Math.round(fraction * 100), "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": column.label, className: "h-1 min-w-16 flex-1 overflow-hidden rounded-full bg-border", children: _jsx("div", { className: "h-full rounded-full bg-status-active", style: { width: `${fraction * 100}%` } }) }), _jsx("span", { className: "w-10 shrink-0 text-right tabular-nums text-muted-foreground", children: formatPercent(fraction) })] }));
|
|
@@ -22,8 +25,8 @@ function Cell({ column, row, formatPercent, formatNumber, formatDateTime, transl
|
|
|
22
25
|
if (raw === undefined || raw === null || raw === "")
|
|
23
26
|
return EMPTY_VALUE_PLACEHOLDER;
|
|
24
27
|
const toneKey = column.badgeToneField !== undefined ? row[column.badgeToneField] : undefined;
|
|
25
|
-
const tone = (typeof toneKey === "string" ?
|
|
26
|
-
return _jsx(StatusBadge, { tone: tone, children: String(raw) });
|
|
28
|
+
const tone = (typeof toneKey === "string" ? LIST_BADGE_TONE[toneKey] : undefined) ?? "muted";
|
|
29
|
+
return (_jsx(StatusBadge, { tone: tone, dot: column.badgeDot !== false, children: String(raw) }));
|
|
27
30
|
}
|
|
28
31
|
if (column.display === "datetime") {
|
|
29
32
|
const atMs = typeof raw === "number" ? raw : typeof raw === "string" ? Date.parse(raw) : Number.NaN;
|
|
@@ -31,17 +34,89 @@ function Cell({ column, row, formatPercent, formatNumber, formatDateTime, transl
|
|
|
31
34
|
return EMPTY_VALUE_PLACEHOLDER;
|
|
32
35
|
return _jsx("span", { className: "tabular-nums", children: formatDateTime(atMs) });
|
|
33
36
|
}
|
|
34
|
-
if (column.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
if (column.display === "button") {
|
|
38
|
+
const link = column.linkFor?.(raw, row);
|
|
39
|
+
if (raw === undefined || raw === null || raw === "")
|
|
40
|
+
return EMPTY_VALUE_PLACEHOLDER;
|
|
41
|
+
const text = column.renderValue?.(raw, row) ?? String(raw);
|
|
42
|
+
const label = I18N_KEY_SHAPE.test(text) ? translate(text) : text;
|
|
43
|
+
return link === undefined ? (label) : (_jsx(CellTextLink, { link: link, className: LINK_BUTTON_CLASS, children: label }));
|
|
44
|
+
}
|
|
45
|
+
if (column.renderValue !== undefined) {
|
|
46
|
+
const text = column.renderValue(raw, row);
|
|
47
|
+
const link = column.linkFor?.(raw, row);
|
|
48
|
+
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
49
|
+
}
|
|
50
|
+
const link = column.linkFor?.(raw, row);
|
|
51
|
+
if (typeof raw === "number") {
|
|
52
|
+
const number = _jsx("span", { className: "tabular-nums", children: formatNumber(raw) });
|
|
53
|
+
return link === undefined ? number : _jsx(CellTextLink, { link: link, children: number });
|
|
54
|
+
}
|
|
38
55
|
if (raw === undefined || raw === null || raw === "")
|
|
39
56
|
return EMPTY_VALUE_PLACEHOLDER;
|
|
40
57
|
const text = String(raw);
|
|
41
|
-
|
|
58
|
+
const shown = I18N_KEY_SHAPE.test(text) ? translate(text) : text;
|
|
59
|
+
return link === undefined ? shown : _jsx(CellTextLink, { link: link, children: shown });
|
|
60
|
+
}
|
|
61
|
+
export function rowToneOf(row, rowToneField) {
|
|
62
|
+
const value = rowToneField === undefined ? undefined : row[rowToneField];
|
|
63
|
+
return isSelectOptionTone(value) ? value : undefined;
|
|
64
|
+
}
|
|
65
|
+
function RowLinkIcon({ link, icon, label, }) {
|
|
66
|
+
if (link === undefined)
|
|
67
|
+
return null;
|
|
68
|
+
const Glyph = icon === "chevron" ? ChevronRight : ArrowUpRight;
|
|
69
|
+
return (_jsxs(CellTextLink, { link: link, className: "inline-flex text-muted-foreground hover:text-foreground", children: [_jsx(Glyph, { className: "size-4", "aria-hidden": "true" }), _jsx("span", { className: "sr-only", children: label })] }));
|
|
70
|
+
}
|
|
71
|
+
const INTERACTIVE_DESCENDANT_SELECTOR = "a, button";
|
|
72
|
+
function pressRowLink(event, link) {
|
|
73
|
+
if (link === undefined)
|
|
74
|
+
return;
|
|
75
|
+
if (event.target instanceof Element && event.target.closest(INTERACTIVE_DESCENDANT_SELECTOR)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
link.onPress();
|
|
79
|
+
}
|
|
80
|
+
function ToneDot({ tone }) {
|
|
81
|
+
return (_jsx("span", { "aria-hidden": "true", "data-testid": "dashboard-list-tone-dot", className: cn("inline-block size-2 shrink-0 rounded-full", toneDotClass(tone)) }));
|
|
82
|
+
}
|
|
83
|
+
// Badges in front of the "to do" column belong to its line: they sit inline before the sentence.
|
|
84
|
+
function leadingBadgeColumnsOf(columns) {
|
|
85
|
+
const hintIndex = columns.findIndex((column) => column.hint !== undefined);
|
|
86
|
+
return columns.slice(0, Math.max(hintIndex, 0)).filter((column) => column.display === "badge");
|
|
42
87
|
}
|
|
43
|
-
/** Compact
|
|
44
|
-
*
|
|
45
|
-
export function DashboardListTable({ columns, rows, formatPercent, formatNumber, formatDateTime, translate, testId, }) {
|
|
46
|
-
|
|
88
|
+
/** Compact table for dashboard lists with optional bar/badge columns. Badge columns in front of a
|
|
89
|
+
* `hint` column join the hint's first line; rows with a tone get 12px of padding above and below. */
|
|
90
|
+
export function DashboardListTable({ columns: allColumns, rows, formatPercent, formatNumber, formatDateTime, translate, testId, rowToneField, rowToneMarker = "bar", showHeader = true, rowLink, }) {
|
|
91
|
+
const visibleColumns = allColumns.filter((column) => column.narrowOnly !== true);
|
|
92
|
+
const leadingBadgeColumns = leadingBadgeColumnsOf(visibleColumns);
|
|
93
|
+
const columns = visibleColumns.filter((column) => !leadingBadgeColumns.includes(column));
|
|
94
|
+
const hintColumn = columns.find((column) => column.hint !== undefined);
|
|
95
|
+
const padded = rowToneField !== undefined || leadingBadgeColumns.length > 0;
|
|
96
|
+
const cellProps = { formatPercent, formatNumber, formatDateTime, translate };
|
|
97
|
+
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: "px-4 font-medium", children: column.label }, column.field))), rowLink !== undefined && _jsx("th", { scope: "col", className: "w-8" })] }) })), _jsx("tbody", { children: rows.map((row, index) => {
|
|
98
|
+
const rowTarget = rowLink?.linkFor(row);
|
|
99
|
+
const tone = rowToneOf(row, rowToneField);
|
|
100
|
+
const dot = rowToneMarker === "dot" && tone !== undefined ? _jsx(ToneDot, { tone: tone }) : null;
|
|
101
|
+
const leadingFor = (column, columnIndex) => {
|
|
102
|
+
const badges = column === hintColumn ? leadingBadgeColumns : [];
|
|
103
|
+
const front = columnIndex === 0 ? dot : null;
|
|
104
|
+
if (front === null && badges.length === 0)
|
|
105
|
+
return undefined;
|
|
106
|
+
return (_jsxs(_Fragment, { children: [front, badges.map((badge) => (_jsx(DashboardListCell, { column: badge, row: row, ...cellProps }, badge.field)))] }));
|
|
107
|
+
};
|
|
108
|
+
const rowKey = typeof row["id"] === "string" ? row["id"] : index;
|
|
109
|
+
const rowElement = (_jsxs("tr", { ...(rowTarget !== undefined && {
|
|
110
|
+
onClick: (event) => pressRowLink(event, rowTarget),
|
|
111
|
+
}), className: cn("h-10 border-b border-border-row last:border-b-0 [&:has(+[data-reason-row])]:border-b-0", rowTarget !== undefined && "cursor-pointer", padded && "sm:[&>td]:py-3",
|
|
112
|
+
// Without a header row nothing labels the columns, so narrow screens stack them.
|
|
113
|
+
!showHeader &&
|
|
114
|
+
"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) => {
|
|
115
|
+
const leading = leadingFor(column, columnIndex);
|
|
116
|
+
const cell = (_jsx(DashboardListCell, { column: column, row: row, ...cellProps, ...(column.hint !== undefined && { leading }) }));
|
|
117
|
+
return (_jsx("td", { className: cn("px-4", !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));
|
|
118
|
+
}), 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));
|
|
119
|
+
const reasonHint = columns.find((column) => column.hint !== undefined && hintReasonOf(column.hint, row) !== undefined)?.hint;
|
|
120
|
+
return (_jsx(HintReasonRowScope, { hint: reasonHint, row: row, renderBoxRow: (box) => (_jsx("tr", { "data-reason-row": "true", className: "border-b border-border-row last:border-b-0", children: _jsx("td", { colSpan: columns.length + (rowLink !== undefined ? 1 : 0), className: "px-4 pb-3", children: box }) })), children: rowElement }, rowKey));
|
|
121
|
+
}) })] }) }));
|
|
47
122
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_VIEWPORT_WIDTH } from "./drawer-panel-class.js";
|
|
2
2
|
export const MIN_WIDTH_PX = 320;
|
|
3
3
|
export const MAX_WIDTH_PX = 1000;
|
|
4
|
-
// Must match the static `max(600px,37.5vw)` in
|
|
4
|
+
// Must match the static `max(600px,37.5vw)` in WIDTH_CLASS (drawer-panel-class.ts) — Tailwind's
|
|
5
5
|
// JIT can't read these at runtime, so the two are kept in sync by hand.
|
|
6
6
|
// 600px (vs. the old 520px floor) gives a two-column field row (e.g.
|
|
7
7
|
// street/number, zip/city) room to breathe, while staying well under half
|
|
@@ -172,8 +172,10 @@ export function FloatingPanel({ title, headerActions, children, storageKey, defa
|
|
|
172
172
|
return createPortal(_jsxs("div", { role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, "data-testid": testId, className: cn("fixed z-50 flex flex-col overflow-hidden rounded-lg border text-foreground shadow-2xl", aiSurface ? "bg-ai-surface" : "bg-background"), style: {
|
|
173
173
|
right: fixedPlacement.rightPx,
|
|
174
174
|
bottom: fixedPlacement.bottomPx,
|
|
175
|
-
width:
|
|
176
|
-
|
|
175
|
+
width: fixedPlacement.widthPx,
|
|
176
|
+
maxWidth: `calc(100vw - ${fixedPlacement.rightPx + FLOATING_PANEL_MARGIN_PX}px)`,
|
|
177
|
+
height: fixedPlacement.heightPx,
|
|
178
|
+
maxHeight: `calc(100vh - ${fixedPlacement.bottomPx + FLOATING_PANEL_MARGIN_PX}px)`,
|
|
177
179
|
}, children: [_jsxs("div", { className: cn("flex shrink-0 items-center gap-2 border-b px-3 py-2", aiSurface ? "bg-ai-surface" : "bg-muted"), children: [_jsx("div", { id: titleId, className: "min-w-0 flex-1 truncate font-medium", children: title }), headerActions] }), _jsx("div", { className: bodyClass, children: children })] }), document.body);
|
|
178
180
|
}
|
|
179
181
|
const limits = getLimits();
|
|
@@ -14,6 +14,7 @@ export { Drawer, type DrawerProps } from "./drawer.tsx";
|
|
|
14
14
|
export { FeedList, type FeedRow } from "./feed-list.tsx";
|
|
15
15
|
export { FloatingPanel, type FloatingPanelGeometry, type FloatingPanelPlacement, type FloatingPanelProps, } from "./floating-panel.tsx";
|
|
16
16
|
export { BooleanField, type BooleanFieldProps, DateField, type DateFieldProps, FileField, type FileFieldProps, MoneyField, NumberField, type NumberFieldProps, PercentField, RangeField, type RangeFieldProps, SelectField, type SelectFieldProps, TextareaField, type TextareaFieldProps, TextField, type TextFieldProps, } from "./form-fields.tsx";
|
|
17
|
+
export { HtmlMailFrame } from "./html-mail-frame.tsx";
|
|
17
18
|
export { InfinityList, type InfinityListProps, type InfinityListSelection, } from "./infinity-list.tsx";
|
|
18
19
|
export { MessageReader } from "./message-reader.tsx";
|
|
19
20
|
export { type MessageAttachment, type MessageBody, type MessageReaderProps, type MessageReaderTab, MessageThread, type MessageThreadProps, type ThreadMessage, } from "./message-thread.tsx";
|
|
@@ -22,6 +23,7 @@ export { ModeSwitch, type ModeSwitchVariant } from "./mode-switch.tsx";
|
|
|
22
23
|
export { type PdfMatchInfo, PdfPreview, type PdfPreviewProps, type PdfPreviewSource, } from "./pdf-preview.tsx";
|
|
23
24
|
export { type PhotoSlotSpec, PhotoSlots, type PhotoSlotsProps } from "./photo-slots.tsx";
|
|
24
25
|
export { PlanCard, type PlanCardActionSlot, type PlanCardLinkSlot, type PlanCardPrice, type PlanCardProps, PlanGrid, type PlanGridProps, } from "./plan-card.tsx";
|
|
26
|
+
export { type PreviewDevice, PreviewWidthFrame } from "./preview-width-frame.tsx";
|
|
25
27
|
export { ProgressBar } from "./progress-bar.tsx";
|
|
26
28
|
export { ProgressList, type ProgressListRow } from "./progress-list.tsx";
|
|
27
29
|
export { PublicShell, type PublicShellProps, type PublicShellVariant } from "./public-shell.tsx";
|
|
@@ -16,6 +16,7 @@ export { Drawer } from "./drawer.js";
|
|
|
16
16
|
export { FeedList } from "./feed-list.js";
|
|
17
17
|
export { FloatingPanel, } from "./floating-panel.js";
|
|
18
18
|
export { BooleanField, DateField, FileField, MoneyField, NumberField, PercentField, RangeField, SelectField, TextareaField, TextField, } from "./form-fields.js";
|
|
19
|
+
export { HtmlMailFrame } from "./html-mail-frame.js";
|
|
19
20
|
export { InfinityList, } from "./infinity-list.js";
|
|
20
21
|
export { MessageReader } from "./message-reader.js";
|
|
21
22
|
export { MessageThread, } from "./message-thread.js";
|
|
@@ -24,6 +25,7 @@ export { ModeSwitch } from "./mode-switch.js";
|
|
|
24
25
|
export { PdfPreview, } from "./pdf-preview.js";
|
|
25
26
|
export { PhotoSlots } from "./photo-slots.js";
|
|
26
27
|
export { PlanCard, PlanGrid, } from "./plan-card.js";
|
|
28
|
+
export { PreviewWidthFrame } from "./preview-width-frame.js";
|
|
27
29
|
export { ProgressBar } from "./progress-bar.js";
|
|
28
30
|
export { ProgressList } from "./progress-list.js";
|
|
29
31
|
export { PublicShell } from "./public-shell.js";
|
|
@@ -88,8 +88,6 @@ export function InfinityList({ query, payload, pageSize = 50, rows, nextCursor,
|
|
|
88
88
|
// into one query per event. A refresh already running schedules
|
|
89
89
|
// exactly one trailing pass after it settles.
|
|
90
90
|
const liveTimerRef = useRef(null);
|
|
91
|
-
const liveInFlightRef = useRef(false);
|
|
92
|
-
const liveTrailingRef = useRef(false);
|
|
93
91
|
// Live-mode: on an SSE event for the query's entity, refetch only the
|
|
94
92
|
// first page and merge it in — rows the fresh page still contains move
|
|
95
93
|
// to the front (newest-first feeds), rows it dropped (edited/deleted
|
|
@@ -97,7 +95,7 @@ export function InfinityList({ query, payload, pageSize = 50, rows, nextCursor,
|
|
|
97
95
|
// A full reload would collapse already-accumulated pages and jump the
|
|
98
96
|
// scroll position.
|
|
99
97
|
// biome-ignore lint/correctness/useExhaustiveDependencies: payload goes through payloadKey
|
|
100
|
-
const refreshFirstPage = useCallback(async () => {
|
|
98
|
+
const refreshFirstPage = useCallback(async (onSuperseded) => {
|
|
101
99
|
// Read, don't bump at the start: a concurrent load() (e.g. the mount
|
|
102
100
|
// fetch still in flight) must not be discarded by a refresh that then
|
|
103
101
|
// fails or is superseded. Only a refresh that actually delivers fresh
|
|
@@ -107,7 +105,7 @@ export function InfinityList({ query, payload, pageSize = 50, rows, nextCursor,
|
|
|
107
105
|
if (seqAtStart !== requestSeq.current) {
|
|
108
106
|
// A load-more bumps the sequence without covering page 1, so the signal that
|
|
109
107
|
// triggered this refresh would otherwise be lost.
|
|
110
|
-
|
|
108
|
+
onSuperseded();
|
|
111
109
|
return;
|
|
112
110
|
}
|
|
113
111
|
// skip: background live refresh failed, keep showing the current rows
|
|
@@ -154,12 +152,20 @@ export function InfinityList({ query, payload, pageSize = 50, rows, nextCursor,
|
|
|
154
152
|
// skip: no entity to listen on, nothing to subscribe to
|
|
155
153
|
if (liveEntities.length === 0)
|
|
156
154
|
return;
|
|
155
|
+
// In-flight and trailing flags belong to this effect: a payload change starts a fresh pair, so
|
|
156
|
+
// an event for the new payload is never parked behind the old payload's refresh, and a torn-down
|
|
157
|
+
// effect never runs a pass through its stale refreshFirstPage.
|
|
158
|
+
let disposed = false;
|
|
159
|
+
let inFlight = false;
|
|
160
|
+
let trailing = false;
|
|
157
161
|
const runRefresh = () => {
|
|
158
|
-
|
|
159
|
-
void refreshFirstPage(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
inFlight = true;
|
|
163
|
+
void refreshFirstPage(() => {
|
|
164
|
+
trailing = true;
|
|
165
|
+
}).finally(() => {
|
|
166
|
+
inFlight = false;
|
|
167
|
+
if (!disposed && trailing) {
|
|
168
|
+
trailing = false;
|
|
163
169
|
runRefresh();
|
|
164
170
|
}
|
|
165
171
|
});
|
|
@@ -169,8 +175,8 @@ export function InfinityList({ query, payload, pageSize = 50, rows, nextCursor,
|
|
|
169
175
|
clearTimeout(liveTimerRef.current);
|
|
170
176
|
liveTimerRef.current = setTimeout(() => {
|
|
171
177
|
liveTimerRef.current = null;
|
|
172
|
-
if (
|
|
173
|
-
|
|
178
|
+
if (inFlight) {
|
|
179
|
+
trailing = true;
|
|
174
180
|
return;
|
|
175
181
|
}
|
|
176
182
|
runRefresh();
|
|
@@ -178,6 +184,7 @@ export function InfinityList({ query, payload, pageSize = 50, rows, nextCursor,
|
|
|
178
184
|
};
|
|
179
185
|
const unsubscribe = subscribeToEntities(subscribeLive, liveEntities, scheduleRefresh);
|
|
180
186
|
return () => {
|
|
187
|
+
disposed = true;
|
|
181
188
|
unsubscribe();
|
|
182
189
|
if (liveTimerRef.current !== null) {
|
|
183
190
|
clearTimeout(liveTimerRef.current);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type PreviewDevice = "desktop" | "mobile";
|
|
3
|
+
export declare function PreviewWidthFrame({ device, children, testId, }: {
|
|
4
|
+
readonly device: PreviewDevice;
|
|
5
|
+
readonly children: ReactNode;
|
|
6
|
+
readonly testId?: string;
|
|
7
|
+
}): ReactNode;
|