@altertable/data-app 0.64.0 → 0.66.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/AGENTS.md +40 -0
- package/CONTRIBUTING.md +37 -3
- package/README.md +2 -2
- package/dist/chunks/{contract-mwe7gnmh.js → contract-13j5zb3c.js} +110 -216
- package/dist/chunks/contract-13j5zb3c.js.map +13 -0
- package/dist/chunks/contract-19ckn3n7.js +78 -0
- package/dist/chunks/contract-19ckn3n7.js.map +10 -0
- package/dist/chunks/contract-awa2d5b1.js +272 -0
- package/dist/chunks/contract-awa2d5b1.js.map +12 -0
- package/dist/chunks/{contract-xtxza1fy.js → contract-e11m4y7f.js} +35 -71
- package/dist/chunks/contract-e11m4y7f.js.map +12 -0
- package/dist/chunks/{contract-zr3jd7mr.js → contract-h8a6f559.js} +100 -75
- package/dist/chunks/contract-h8a6f559.js.map +12 -0
- package/dist/chunks/contract-havnjmdr.js +13011 -0
- package/dist/chunks/contract-havnjmdr.js.map +99 -0
- package/dist/chunks/{contract-txjy0en2.js → contract-m6n8ctfc.js} +64 -72
- package/dist/chunks/contract-m6n8ctfc.js.map +10 -0
- package/dist/chunks/contract-pk603qj7.js +146 -0
- package/dist/chunks/contract-pk603qj7.js.map +10 -0
- package/dist/chunks/{contract-yxbjea23.js → contract-rfbakka4.js} +179 -2
- package/dist/chunks/contract-rfbakka4.js.map +13 -0
- package/dist/client/index.js +11 -6
- package/dist/client/index.js.map +1 -1
- package/dist/core/appearance.js +1 -1
- package/dist/core/contract.js +13 -3
- package/dist/core/contract.js.map +1 -1
- package/dist/embed/index.js +25 -13
- package/dist/embed/index.js.map +3 -3
- package/dist/local.js +1 -1
- package/dist/local.js.map +2 -2
- package/dist/react/embed/index.js +5 -2
- package/dist/react/embed/index.js.map +3 -3
- package/dist/react/index.js +2532 -11273
- package/dist/react/index.js.map +16 -88
- package/dist/react/ui/index.js +1614 -0
- package/dist/react/ui/index.js.map +22 -0
- package/dist/server.js +1 -1
- package/dist/server.js.map +2 -2
- package/dist/types/client/annotations.d.ts +23 -0
- package/dist/types/client/iframe.d.ts +2 -0
- package/dist/types/client/index.d.ts +2 -0
- package/dist/types/client/logger.d.ts +6 -0
- package/dist/types/core/annotations.d.ts +92 -0
- package/dist/types/core/appearance.d.ts +2 -2
- package/dist/types/core/bridge-endpoint.d.ts +21 -0
- package/dist/types/core/bridge.d.ts +137 -16
- package/dist/types/core/contract.d.ts +2 -0
- package/dist/types/core/logger.d.ts +12 -0
- package/dist/types/core/presentation.d.ts +2 -0
- package/dist/types/core/variables.d.ts +2 -5
- package/dist/types/embed/host.d.ts +6 -2
- package/dist/types/embed/index.d.ts +1 -0
- package/dist/types/embed/source.d.ts +1 -1
- package/dist/types/react/annotations/AnnotationBar.d.ts +24 -0
- package/dist/types/react/annotations/AnnotationControls.d.ts +10 -0
- package/dist/types/react/annotations/AnnotationEditor.d.ts +15 -0
- package/dist/types/react/annotations/AnnotationMarkers.d.ts +19 -0
- package/dist/types/react/annotations/AnnotationSelectionLayer.d.ts +12 -0
- package/dist/types/react/annotations/AnnotationTarget.d.ts +9 -0
- package/dist/types/react/annotations/AnnotationTooltip.d.ts +9 -0
- package/dist/types/react/annotations/AnnotationTrigger.d.ts +10 -0
- package/dist/types/react/annotations/annotation-editor-state.d.ts +56 -0
- package/dist/types/react/annotations/annotation-screenshot.d.ts +4 -0
- package/dist/types/react/annotations/annotation-targets.d.ts +33 -0
- package/dist/types/react/annotations/getAnnotationProps.d.ts +15 -0
- package/dist/types/react/annotations/styles.d.ts +3 -0
- package/dist/types/react/annotations/useAnnotationGeometry.d.ts +22 -0
- package/dist/types/react/annotations/useDataAppAnnotations.d.ts +19 -0
- package/dist/types/react/bindings.d.ts +110 -0
- package/dist/types/react/content.d.ts +24 -11
- package/dist/types/react/embed/bridge.d.ts +1 -1
- package/dist/types/react/hooks.d.ts +29 -787
- package/dist/types/react/index.d.ts +30 -104
- package/dist/types/react/source-owner.d.ts +2 -0
- package/dist/types/react/style-contract.d.ts +60 -0
- package/dist/types/react/style-validation.d.ts +2 -0
- package/dist/types/react/ui/AboutData.d.ts +9 -1
- package/dist/types/react/ui/AppHeader.d.ts +1 -2
- package/dist/types/react/ui/AppLayout.d.ts +3 -9
- package/dist/types/react/ui/AppToolbar.d.ts +6 -7
- package/dist/types/react/ui/AreaChart.d.ts +7 -0
- package/dist/types/react/ui/BarChart.d.ts +6 -0
- package/dist/types/react/ui/{ComparisonVisual.d.ts → Comparison.d.ts} +3 -3
- package/dist/types/react/ui/ContentSkeleton.d.ts +2 -0
- package/dist/types/react/ui/DataApp.d.ts +17 -53
- package/dist/types/react/ui/DataAppFrame.d.ts +42 -0
- package/dist/types/react/ui/DataBoundary.d.ts +4 -5
- package/dist/types/react/ui/DataSection.d.ts +6 -18
- package/dist/types/react/ui/DataSectionBoundary.d.ts +30 -0
- package/dist/types/react/ui/DataValue.d.ts +9 -0
- package/dist/types/react/ui/DataWidget.d.ts +2 -1
- package/dist/types/react/ui/DateTimeTooltip.d.ts +1 -1
- package/dist/types/react/ui/ExportControl.d.ts +4 -0
- package/dist/types/react/ui/HelpPopover.d.ts +3 -4
- package/dist/types/react/ui/InspectionContext.d.ts +2 -0
- package/dist/types/react/ui/InspectionProvider.d.ts +29 -0
- package/dist/types/react/ui/LineChart.d.ts +7 -0
- package/dist/types/react/ui/MetricWidget.d.ts +4 -3
- package/dist/types/react/ui/PieChart.d.ts +8 -0
- package/dist/types/react/ui/PresentStory.d.ts +2 -5
- package/dist/types/react/ui/RefreshControl.d.ts +1 -2
- package/dist/types/react/ui/ScatterChart.d.ts +17 -0
- package/dist/types/react/ui/SearchField.d.ts +1 -2
- package/dist/types/react/ui/SearchInput.d.ts +3 -1
- package/dist/types/react/ui/Sheet.d.ts +2 -1
- package/dist/types/react/ui/Skeleton.d.ts +5 -2
- package/dist/types/react/ui/StaticDataApp.d.ts +4 -0
- package/dist/types/react/ui/TableWidget.d.ts +19 -16
- package/dist/types/react/ui/Tabs.d.ts +6 -2
- package/dist/types/react/ui/TextWidget.d.ts +2 -1
- package/dist/types/react/ui/Toast.d.ts +8 -0
- package/dist/types/react/ui/Tooltip.d.ts +4 -3
- package/dist/types/react/ui/TrendChart.d.ts +5 -0
- package/dist/types/react/ui/UpdatedAt.d.ts +1 -1
- package/dist/types/react/ui/VisualizationWidget.d.ts +12 -13
- package/dist/types/react/ui/WidgetViewTabs.d.ts +1 -1
- package/dist/types/react/ui/chart-data.d.ts +25 -0
- package/dist/types/react/ui/csv-export.d.ts +19 -0
- package/dist/types/react/ui/data-context.d.ts +18 -7
- package/dist/types/react/ui/icons.d.ts +2 -0
- package/dist/types/react/ui/index.d.ts +74 -0
- package/dist/types/react/ui/metric.d.ts +1 -1
- package/dist/types/react/ui/presentation.d.ts +5 -1
- package/dist/types/react/ui/shortcuts.d.ts +7 -1
- package/dist/types/react/view-runtime.d.ts +29 -0
- package/dist/types/react/view.d.ts +21 -4
- package/dist/types/react/widgets.d.ts +79 -0
- package/dist/worker.js +381 -79
- package/docs/app-authoring.md +64 -30
- package/docs/data-context.md +89 -0
- package/docs/embed.md +1 -1
- package/docs/formatting-and-appearance.md +52 -0
- package/docs/hosted-apps.md +2 -15
- package/docs/layout.md +33 -0
- package/docs/local-data-apps.md +1 -1
- package/docs/react-embed.md +2 -2
- package/docs/react.md +20 -254
- package/docs/stories-and-export.md +52 -0
- package/docs/styling.md +55 -0
- package/docs/ui-quality.md +20 -0
- package/docs/ui.md +41 -0
- package/docs/variables.md +98 -0
- package/docs/views.md +127 -0
- package/docs/widgets.md +142 -0
- package/examples/starter-data-app/index.tsx +89 -44
- package/package.json +13 -4
- package/dist/chunks/contract-cxr9t12b.js +0 -18
- package/dist/chunks/contract-cxr9t12b.js.map +0 -10
- package/dist/chunks/contract-mwe7gnmh.js.map +0 -13
- package/dist/chunks/contract-txjy0en2.js.map +0 -10
- package/dist/chunks/contract-xtxza1fy.js.map +0 -12
- package/dist/chunks/contract-yxbjea23.js.map +0 -12
- package/dist/chunks/contract-zr3jd7mr.js.map +0 -12
- package/dist/types/react/ui/RefreshRegion.d.ts +0 -9
- package/dist/types/react/ui/SelectableBarChart.d.ts +0 -15
- package/docs/releasing.md +0 -79
- /package/dist/types/react/ui/{comparison.d.ts → metric-comparison.d.ts} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Host-owned log sink; compatible with console and frontend createLogger(). */
|
|
2
|
+
export type DataAppLogger = {
|
|
3
|
+
log: (...args: unknown[]) => void;
|
|
4
|
+
info: (...args: unknown[]) => void;
|
|
5
|
+
warn: (...args: unknown[]) => void;
|
|
6
|
+
error: (...args: unknown[]) => void;
|
|
7
|
+
};
|
|
8
|
+
export type LogEntry = {
|
|
9
|
+
method: keyof DataAppLogger;
|
|
10
|
+
args: unknown[];
|
|
11
|
+
};
|
|
12
|
+
export declare function isLogEntry(value: unknown): value is LogEntry;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { type DataAppAnnotationPresentation } from './annotations.js';
|
|
1
2
|
import type { Theme } from './appearance.js';
|
|
2
3
|
/** Presentation owned by the parent shell, delivered only over a trusted bridge. */
|
|
3
4
|
export type DataAppPresentation = {
|
|
4
5
|
surface: 'embedded' | 'standalone';
|
|
5
6
|
theme: Theme;
|
|
7
|
+
annotations?: DataAppAnnotationPresentation;
|
|
6
8
|
};
|
|
7
9
|
export declare function isDataAppPresentation(value: unknown): value is DataAppPresentation;
|
|
@@ -50,10 +50,8 @@ export type DateRangeSelection = {
|
|
|
50
50
|
};
|
|
51
51
|
export type DateRangeVariableOptions = {
|
|
52
52
|
label?: string;
|
|
53
|
-
/** URL key for a relative preset; explicit dates use
|
|
53
|
+
/** URL key for a relative preset; explicit dates use start/end for period, otherwise key-prefixed fields. */
|
|
54
54
|
key: string;
|
|
55
|
-
startKey?: string;
|
|
56
|
-
endKey?: string;
|
|
57
55
|
defaultValue: DateRangeSelection & {
|
|
58
56
|
comparison?: never;
|
|
59
57
|
};
|
|
@@ -61,7 +59,6 @@ export type DateRangeVariableOptions = {
|
|
|
61
59
|
history?: HistoryMode;
|
|
62
60
|
/** Opt into a URL-backed comparison with the preceding equal-length range. */
|
|
63
61
|
comparison?: boolean;
|
|
64
|
-
comparisonKey?: string;
|
|
65
62
|
};
|
|
66
63
|
export type DateRangeVariable = AppVariable<DateRangeSelection> & {
|
|
67
64
|
kind: 'dateRange';
|
|
@@ -79,4 +76,4 @@ export type DateRangeVariable = AppVariable<DateRangeSelection> & {
|
|
|
79
76
|
comparisonRange: (selection: DateRangeSelection) => DateRange | null;
|
|
80
77
|
};
|
|
81
78
|
/** A date variable keeps relative presets relative and validates exact dates against source coverage. */
|
|
82
|
-
export declare function dateRangeVariable({ key, label,
|
|
79
|
+
export declare function dateRangeVariable({ key, label, defaultValue, contract, history, comparison, }: DateRangeVariableOptions): DateRangeVariable;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { DataAppPresentation } from '../core/presentation.js';
|
|
2
|
+
import type { DataAppLogger } from '../core/logger.js';
|
|
3
|
+
import { type BridgeMessage } from '../core/bridge.js';
|
|
2
4
|
import { type MessageDispatcher } from '../core/messages.js';
|
|
3
5
|
export type DataAppConnection = {
|
|
4
6
|
type: 'origin';
|
|
@@ -10,15 +12,17 @@ export type DataAppConnection = {
|
|
|
10
12
|
export type DataAppStatus = 'connecting' | 'connected' | 'ready' | 'failed' | 'disconnected';
|
|
11
13
|
export type DataAppDiagnostic = {
|
|
12
14
|
direction: 'send' | 'receive';
|
|
13
|
-
type:
|
|
15
|
+
type: BridgeMessage['type'];
|
|
14
16
|
};
|
|
15
17
|
export type DataAppHost = {
|
|
16
18
|
dispose: () => void;
|
|
17
19
|
setPresentation: (presentation?: DataAppPresentation) => void;
|
|
20
|
+
setLogger: (logger?: DataAppLogger) => void;
|
|
18
21
|
};
|
|
19
22
|
export type DataAppHostOptions = {
|
|
20
23
|
iframe: HTMLIFrameElement;
|
|
21
24
|
presentation?: DataAppPresentation;
|
|
25
|
+
logger?: DataAppLogger;
|
|
22
26
|
onStatusChange?: (status: DataAppStatus) => void;
|
|
23
27
|
onDiagnostic?: (event: DataAppDiagnostic) => void;
|
|
24
28
|
onMessage: MessageDispatcher;
|
|
@@ -29,4 +33,4 @@ export type DataAppConnectionOptions = DataAppHostOptions & {
|
|
|
29
33
|
window?: Window;
|
|
30
34
|
};
|
|
31
35
|
/** The bridge owns delivery and cancellation; the routed handler owns validation, authorization and execution. */
|
|
32
|
-
export declare function attachDataAppConnection({ iframe, connection, javascript, presentation, onStatusChange, onDiagnostic, onMessage, window: host, }: DataAppConnectionOptions): DataAppHost;
|
|
36
|
+
export declare function attachDataAppConnection({ iframe, connection, javascript, presentation, logger, onStatusChange, onDiagnostic, onMessage, window: host, }: DataAppConnectionOptions): DataAppHost;
|
|
@@ -11,3 +11,4 @@ export { startDataAppBootstrap } from './bootstrap.js';
|
|
|
11
11
|
export { createNavigationHandler } from './navigation.js';
|
|
12
12
|
export { createSqlQueryHandler } from './sql.js';
|
|
13
13
|
export type { DataAppPresentation } from '../core/presentation.js';
|
|
14
|
+
export type { DataAppLogger } from '../core/logger.js';
|
|
@@ -12,4 +12,4 @@ export type DataAppSourceOptions = DataAppHostOptions & {
|
|
|
12
12
|
startupTimeoutMs?: number;
|
|
13
13
|
};
|
|
14
14
|
/** Owns loading and sandbox policy. Dispose before replacing the source or retrying. */
|
|
15
|
-
export declare function attachDataAppSource({ iframe, source, presentation, onMessage, onStatusChange, onDiagnostic, startupTimeoutMs, }: DataAppSourceOptions): DataAppHost;
|
|
15
|
+
export declare function attachDataAppSource({ iframe, source, presentation, logger, onMessage, onStatusChange, onDiagnostic, startupTimeoutMs, }: DataAppSourceOptions): DataAppHost;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Theme } from '../../core/appearance.js';
|
|
2
|
+
import { type DataAppAnnotationDraft } from '../../core/annotations.js';
|
|
3
|
+
export type AnnotationBarProps = {
|
|
4
|
+
annotations: readonly DataAppAnnotationDraft[];
|
|
5
|
+
active?: boolean;
|
|
6
|
+
theme?: Theme;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
deletedAnnotationId?: string;
|
|
9
|
+
onUndoDelete?: (id: string) => void;
|
|
10
|
+
onDismissUndo?: () => void;
|
|
11
|
+
hasUnsavedChanges?: boolean;
|
|
12
|
+
pinsVisible: boolean;
|
|
13
|
+
onPinsVisibleChange: (visible: boolean) => void;
|
|
14
|
+
onSelect: (id: string) => void;
|
|
15
|
+
onDelete: (id: string) => void;
|
|
16
|
+
onClear: () => void;
|
|
17
|
+
/** Let host apps use their existing confirmation dialog. */
|
|
18
|
+
requestDiscard?: (discard: () => void) => void;
|
|
19
|
+
/** Resolve only after the outer application's agent API accepts this snapshot. */
|
|
20
|
+
onSend: (annotations: readonly DataAppAnnotationDraft[]) => Promise<void>;
|
|
21
|
+
onClose: () => void;
|
|
22
|
+
};
|
|
23
|
+
/** Host-owned batch controls. Collection changes and agent submission stay with the outer app. */
|
|
24
|
+
export declare function AnnotationBar({ annotations, active, theme, disabled, deletedAnnotationId, onUndoDelete, onDismissUndo, hasUnsavedChanges, pinsVisible, onPinsVisibleChange, onSelect, onDelete, onClear, requestDiscard, onSend, onClose, }: AnnotationBarProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ComponentRef, type RefObject } from 'react';
|
|
2
|
+
import type { DataAppAnnotationPresentation } from '../../core/annotations.js';
|
|
3
|
+
type AnnotationControlsProps = {
|
|
4
|
+
rootRef: RefObject<ComponentRef<'div'> | null>;
|
|
5
|
+
presentation: DataAppAnnotationPresentation;
|
|
6
|
+
displayedInput?: unknown;
|
|
7
|
+
view?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function AnnotationControls({ rootRef, presentation, displayedInput, view, }: AnnotationControlsProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentRef, CSSProperties, Ref } from 'react';
|
|
2
|
+
import type { AnnotationEditorState } from './annotation-editor-state.js';
|
|
3
|
+
type AnnotationEditorProps = {
|
|
4
|
+
editor: AnnotationEditorState;
|
|
5
|
+
editorRef: Ref<ComponentRef<'section'>>;
|
|
6
|
+
textareaRef: Ref<ComponentRef<'textarea'>>;
|
|
7
|
+
style: CSSProperties;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
onCommentChange: (comment: string) => void;
|
|
10
|
+
onSubmit: () => void;
|
|
11
|
+
onRetryScreenshot: () => void;
|
|
12
|
+
onShakeEnd: () => void;
|
|
13
|
+
};
|
|
14
|
+
export declare function AnnotationEditor({ editor, editorRef, textareaRef, style, disabled, onCommentChange, onSubmit, onRetryScreenshot, onShakeEnd, }: AnnotationEditorProps): import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AnnotationPoint, AnnotationRect } from './annotation-targets.js';
|
|
2
|
+
export type AnnotationPin = {
|
|
3
|
+
id: string;
|
|
4
|
+
number: number;
|
|
5
|
+
anchor: AnnotationPoint;
|
|
6
|
+
rect: AnnotationRect;
|
|
7
|
+
};
|
|
8
|
+
type AnnotationMarkersProps = {
|
|
9
|
+
outline?: AnnotationRect;
|
|
10
|
+
rounded: boolean;
|
|
11
|
+
pins: AnnotationPin[];
|
|
12
|
+
pinsVisible: boolean;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
showHint: boolean;
|
|
15
|
+
hasDuplicateIds: boolean;
|
|
16
|
+
onOpenAnnotation: (id: string) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare function AnnotationMarkers({ outline, rounded, pins, pinsVisible, disabled, showHint, hasDuplicateIds, onOpenAnnotation, }: AnnotationMarkersProps): import("react").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AnnotationTargetElement, AnnotationPoint, AnnotationRect } from './annotation-targets.js';
|
|
2
|
+
type AnnotationSelectionLayerProps = {
|
|
3
|
+
scope: HTMLElement;
|
|
4
|
+
targets: AnnotationTargetElement[];
|
|
5
|
+
onHover: (target: AnnotationTargetElement | undefined) => void;
|
|
6
|
+
onSelect: (target: AnnotationTargetElement, point?: AnnotationPoint, region?: AnnotationRect) => void;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
editing: boolean;
|
|
9
|
+
};
|
|
10
|
+
/** Own pointer selection and keyboard focus while the app underneath is inert. */
|
|
11
|
+
export declare function AnnotationSelectionLayer({ scope, targets, onHover, onSelect, disabled, editing, }: AnnotationSelectionLayerProps): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import type { WidgetEvidence } from '../ui/WidgetEvidence.js';
|
|
3
|
+
export type AnnotationTargetProps = ComponentPropsWithRef<'div'> & {
|
|
4
|
+
annotationId: string;
|
|
5
|
+
label: string;
|
|
6
|
+
evidence?: WidgetEvidence;
|
|
7
|
+
};
|
|
8
|
+
/** A stable feedback target for app-owned content outside the built-in widgets. */
|
|
9
|
+
export declare function AnnotationTarget({ annotationId, label, evidence, ...props }: AnnotationTargetProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Theme } from '../../core/appearance.js';
|
|
3
|
+
type AnnotationTooltipProps = {
|
|
4
|
+
content: ReactNode;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
theme?: Theme;
|
|
7
|
+
};
|
|
8
|
+
export declare function AnnotationTooltip({ content, children, theme, }: AnnotationTooltipProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentRef, Ref } from 'react';
|
|
2
|
+
type AnnotationTriggerProps = {
|
|
3
|
+
buttonRef: Ref<ComponentRef<'button'>>;
|
|
4
|
+
active: boolean;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
count: number;
|
|
7
|
+
onToggle: () => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function AnnotationTrigger({ buttonRef, active, disabled, count, onToggle, }: AnnotationTriggerProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { DataAppAnnotationDraft } from '../../core/annotations.js';
|
|
2
|
+
import type { AnnotationTargetElement } from './annotation-targets.js';
|
|
3
|
+
export type AnnotationEditorState = {
|
|
4
|
+
target: AnnotationTargetElement;
|
|
5
|
+
draft: DataAppAnnotationDraft;
|
|
6
|
+
annotationId?: string;
|
|
7
|
+
comment: string;
|
|
8
|
+
captureStatus: 'capturing' | 'ready' | 'failed';
|
|
9
|
+
error: string;
|
|
10
|
+
discardArmed: boolean;
|
|
11
|
+
shaking: boolean;
|
|
12
|
+
};
|
|
13
|
+
type AnnotationControlsState = {
|
|
14
|
+
annotationModeActive: boolean;
|
|
15
|
+
observedActive: boolean;
|
|
16
|
+
hoveredTarget?: AnnotationTargetElement;
|
|
17
|
+
editor?: AnnotationEditorState;
|
|
18
|
+
saving: boolean;
|
|
19
|
+
};
|
|
20
|
+
type AnnotationControlsAction = {
|
|
21
|
+
type: 'annotationModeChanged';
|
|
22
|
+
active: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'externalModeObserved';
|
|
25
|
+
active: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'targetHovered';
|
|
28
|
+
target?: AnnotationTargetElement;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'editorOpened';
|
|
31
|
+
editor: AnnotationEditorState;
|
|
32
|
+
} | {
|
|
33
|
+
type: 'editorClosed';
|
|
34
|
+
} | {
|
|
35
|
+
type: 'commentChanged';
|
|
36
|
+
comment: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'captureCompleted';
|
|
39
|
+
draftId: string;
|
|
40
|
+
succeeded: boolean;
|
|
41
|
+
} | {
|
|
42
|
+
type: 'editorEscaped';
|
|
43
|
+
hasUnsavedChanges: boolean;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'shakeFinished';
|
|
46
|
+
} | {
|
|
47
|
+
type: 'saveStarted';
|
|
48
|
+
} | {
|
|
49
|
+
type: 'saveFailed';
|
|
50
|
+
error: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'saveFinished';
|
|
53
|
+
};
|
|
54
|
+
export declare function createAnnotationControlsState(active: boolean): AnnotationControlsState;
|
|
55
|
+
export declare function annotationControlsReducer(state: AnnotationControlsState, action: AnnotationControlsAction): AnnotationControlsState;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnnotationRect } from './annotation-targets.js';
|
|
2
|
+
import type { DataAppAnnotationDraft } from '../../core/annotations.js';
|
|
3
|
+
/** Capture the visible target at selection time; never include annotation controls. */
|
|
4
|
+
export declare function captureAnnotationScreenshot(element: HTMLElement, region?: AnnotationRect): Promise<NonNullable<DataAppAnnotationDraft['context']['screenshot']>>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type AnnotationPoint = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
};
|
|
5
|
+
export type AnnotationRect = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
export type AnnotationTargetElement = {
|
|
12
|
+
element: HTMLElement;
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
kind: 'widget' | 'element' | 'app';
|
|
16
|
+
};
|
|
17
|
+
export declare function discoverAnnotationTargets(root: HTMLElement | null): {
|
|
18
|
+
targets: AnnotationTargetElement[];
|
|
19
|
+
hasDuplicateIds: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare function annotationGeometry(element: HTMLElement): AnnotationRect;
|
|
22
|
+
export declare function annotationPoint(rect: AnnotationRect, point?: AnnotationPoint): {
|
|
23
|
+
cursor: AnnotationPoint;
|
|
24
|
+
anchor: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/** The iframe document is a crop surface, never a selectable global-layout target. */
|
|
30
|
+
export declare function annotationRoot(root: HTMLElement | null): AnnotationTargetElement | undefined;
|
|
31
|
+
export declare function findAnnotationTarget(root: HTMLElement | null, id: string | undefined): AnnotationTargetElement | undefined;
|
|
32
|
+
export declare function normalizeAnnotationRect(area: AnnotationRect, target: AnnotationRect): AnnotationRect;
|
|
33
|
+
export declare function projectAnnotationRect(area: AnnotationRect, target: AnnotationRect): AnnotationRect;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WidgetEvidence } from '../ui/WidgetEvidence.js';
|
|
2
|
+
type AnnotationPropsOptions = {
|
|
3
|
+
id?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
evidence?: WidgetEvidence;
|
|
6
|
+
kind?: 'widget' | 'element';
|
|
7
|
+
};
|
|
8
|
+
export declare function getAnnotationProps({ id, label, evidence, kind, }: AnnotationPropsOptions): {
|
|
9
|
+
'data-annotation-id': string | undefined;
|
|
10
|
+
'data-annotation-label': string | undefined;
|
|
11
|
+
'data-annotation-kind': "element" | "widget";
|
|
12
|
+
'data-annotation-queries': string;
|
|
13
|
+
'data-annotation-glossary': string;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ComponentRef, type RefObject } from 'react';
|
|
2
|
+
import type { DataAppAnnotationPresentation } from '../../core/annotations.js';
|
|
3
|
+
import { type AnnotationRect, type AnnotationTargetElement } from './annotation-targets.js';
|
|
4
|
+
import type { AnnotationPin } from './AnnotationMarkers.js';
|
|
5
|
+
type AnnotationRootRef = RefObject<ComponentRef<'div'> | null>;
|
|
6
|
+
export declare function useAnnotationTargets(rootRef: AnnotationRootRef, active: boolean): {
|
|
7
|
+
targets: AnnotationTargetElement[];
|
|
8
|
+
hasDuplicateIds: boolean;
|
|
9
|
+
} & {
|
|
10
|
+
scope?: HTMLElement;
|
|
11
|
+
};
|
|
12
|
+
type AnnotationGeometryOptions = {
|
|
13
|
+
rootRef: AnnotationRootRef;
|
|
14
|
+
target?: AnnotationTargetElement;
|
|
15
|
+
region?: AnnotationRect;
|
|
16
|
+
targets: DataAppAnnotationPresentation['targets'];
|
|
17
|
+
};
|
|
18
|
+
export declare function useAnnotationGeometry({ rootRef, target, region, targets, }: AnnotationGeometryOptions): {
|
|
19
|
+
pins: AnnotationPin[];
|
|
20
|
+
outline?: AnnotationRect;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Bind annotation delivery to this app's current iframe bridge. The host owns storage and submission. */
|
|
2
|
+
export declare function useDataAppAnnotations(): {
|
|
3
|
+
reportAnnotationEditorState(state: {
|
|
4
|
+
hasUnsavedChanges: boolean;
|
|
5
|
+
}, options?: {
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}): Promise<null>;
|
|
8
|
+
addAnnotation(draft: import("../../core/annotations.js").DataAppAnnotationDraft, options?: {
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}): Promise<null>;
|
|
11
|
+
updateAnnotation(id: string, comment: string, options?: {
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}): Promise<null>;
|
|
14
|
+
requestAnnotationModeChange(request: {
|
|
15
|
+
active: boolean;
|
|
16
|
+
}, options?: {
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}): Promise<null>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { EvidenceDeclaration } from './ui/data-context.js';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { DateRangeRequest } from '../core/contract.js';
|
|
4
|
+
import type { DataView, DisplayedSnapshot } from '../core/data-view.js';
|
|
5
|
+
import type { MetricFormat } from '../core/format.js';
|
|
6
|
+
import type { DataReading, MetricValues } from '../core/reading.js';
|
|
7
|
+
import type { CsvCell, CsvTable, CsvExport } from './ui/csv-export.js';
|
|
8
|
+
import type { MetricDefinition } from './ui/metric.js';
|
|
9
|
+
import type { EmptyContent } from './ui/presentation.js';
|
|
10
|
+
import type { TableWidgetColumn } from './ui/TableWidget.js';
|
|
11
|
+
import type { WidgetEvidence } from './ui/WidgetEvidence.js';
|
|
12
|
+
/** Displayed data, or an initial loading reading. Pending filter values are never a source. */
|
|
13
|
+
export type ViewSource<Data, Input> = {
|
|
14
|
+
loading: true;
|
|
15
|
+
} | {
|
|
16
|
+
loading?: false;
|
|
17
|
+
data: Data;
|
|
18
|
+
input: Input;
|
|
19
|
+
};
|
|
20
|
+
type SourceReading<Source, Value> = Source extends {
|
|
21
|
+
loading: true;
|
|
22
|
+
} ? {
|
|
23
|
+
loading: true;
|
|
24
|
+
} : {
|
|
25
|
+
loading: false;
|
|
26
|
+
value: Value;
|
|
27
|
+
};
|
|
28
|
+
/** Keys supply IDs; accessors supply raw CSV values. Formats affect display only. */
|
|
29
|
+
export type DatasetColumn<Row> = {
|
|
30
|
+
label?: string;
|
|
31
|
+
} & ({
|
|
32
|
+
value: (row: Row) => CsvCell;
|
|
33
|
+
format?: (row: Row) => ReactNode;
|
|
34
|
+
} | {
|
|
35
|
+
value: (row: Row) => number | null | undefined;
|
|
36
|
+
format: MetricFormat;
|
|
37
|
+
});
|
|
38
|
+
export type DatasetDefinition<Data, Input, Row, Evidence = WidgetEvidence> = {
|
|
39
|
+
name: string;
|
|
40
|
+
select: (data: Data, input: Input) => readonly Row[];
|
|
41
|
+
columns: Record<string, DatasetColumn<NoInfer<Row>>>;
|
|
42
|
+
rowKey: (row: NoInfer<Row>) => string | number;
|
|
43
|
+
evidence: Evidence;
|
|
44
|
+
emptyFallback?: EmptyContent;
|
|
45
|
+
};
|
|
46
|
+
/** Authoring references are registered by the owning view. */
|
|
47
|
+
export type DatasetDeclaration<Data, Input, Row> = DatasetDefinition<Data, Input, Row, EvidenceDeclaration>;
|
|
48
|
+
/** Real view ownership and registered references, shared by metrics and datasets. */
|
|
49
|
+
export declare class RegisteredBinding {
|
|
50
|
+
#private;
|
|
51
|
+
constructor(owner?: object, evidence?: WidgetEvidence);
|
|
52
|
+
protected assertSource(source: object): void;
|
|
53
|
+
static evidence(binding: RegisteredBinding, owner: object): WidgetEvidence;
|
|
54
|
+
}
|
|
55
|
+
export declare function registeredEvidence(binding: RegisteredBinding, owner: object): WidgetEvidence;
|
|
56
|
+
export declare class ExportDataset<Data, Input> extends RegisteredBinding {
|
|
57
|
+
#private;
|
|
58
|
+
readonly name: string;
|
|
59
|
+
constructor(name: string, csv: (snapshot: DisplayedSnapshot<Data, Input>) => CsvTable, owner?: object, evidence?: WidgetEvidence);
|
|
60
|
+
static csv<Data, Input>(dataset: ExportDataset<Data, Input>, snapshot: DisplayedSnapshot<Data, Input>): CsvTable;
|
|
61
|
+
}
|
|
62
|
+
export declare class Dataset<Data, Input, Row> extends ExportDataset<Data, Input> {
|
|
63
|
+
#private;
|
|
64
|
+
readonly evidence: WidgetEvidence;
|
|
65
|
+
constructor(definition: DatasetDefinition<Data, Input, Row>, owner?: object);
|
|
66
|
+
read: <Source extends ViewSource<Data, Input>>(source: Source) => SourceReading<Source, readonly Row[]>;
|
|
67
|
+
static table<Data, Input, Row>(dataset: Dataset<Data, Input, Row>, source: ViewSource<Data, Input>): {
|
|
68
|
+
title: string;
|
|
69
|
+
columns: [TableWidgetColumn<Row>, ...TableWidgetColumn<Row>[]];
|
|
70
|
+
rowKey: (row: Row) => string | number;
|
|
71
|
+
evidence: WidgetEvidence;
|
|
72
|
+
emptyFallback: EmptyContent;
|
|
73
|
+
reading: {
|
|
74
|
+
loading: true;
|
|
75
|
+
} | {
|
|
76
|
+
loading: false;
|
|
77
|
+
value: readonly Row[];
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export declare function bindDataset<Data, Input, Row>(definition: DatasetDefinition<Data, Input, Row>, owner?: object): Dataset<Data, Input, Row>;
|
|
82
|
+
export declare function datasetTable<Data, Input, Row>(dataset: Dataset<Data, Input, Row>, source: ViewSource<Data, Input>): {
|
|
83
|
+
title: string;
|
|
84
|
+
columns: [TableWidgetColumn<Row>, ...TableWidgetColumn<Row>[]];
|
|
85
|
+
rowKey: (row: Row) => string | number;
|
|
86
|
+
evidence: WidgetEvidence;
|
|
87
|
+
emptyFallback: EmptyContent;
|
|
88
|
+
reading: {
|
|
89
|
+
loading: true;
|
|
90
|
+
} | {
|
|
91
|
+
loading: false;
|
|
92
|
+
value: readonly Row[];
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export declare function datasetCsv<Data, Input>(dataset: ExportDataset<Data, Input>, snapshot: DisplayedSnapshot<Data, Input>): CsvTable;
|
|
96
|
+
export declare class Metric<Data, Input> extends RegisteredBinding {
|
|
97
|
+
#private;
|
|
98
|
+
readonly definition: MetricDefinition;
|
|
99
|
+
constructor(definition: MetricDefinition, select: (data: Data, input: Input) => MetricValues, date?: (input: Input) => DateRangeRequest, owner?: object);
|
|
100
|
+
read: <Source extends ViewSource<Data, Input>>(source: Source) => SourceReading<Source, MetricValues & {
|
|
101
|
+
period?: DateRangeRequest;
|
|
102
|
+
}>;
|
|
103
|
+
}
|
|
104
|
+
export declare function bindMetric<Data, Input>(definition: MetricDefinition, select: (data: Data, input: Input) => MetricValues, date?: (input: Input) => DateRangeRequest, owner?: object): Metric<Data, Input>;
|
|
105
|
+
export declare function displayedScope<Data, Input>(view: DataView<Data, Input>, describeInput: (input: Input) => string): DataReading<string>;
|
|
106
|
+
export declare function exportDatasets<Data, Input>(datasets: readonly [
|
|
107
|
+
ExportDataset<Data, Input>,
|
|
108
|
+
...ExportDataset<Data, Input>[]
|
|
109
|
+
], snapshot: DisplayedSnapshot<Data, Input>, scope: string, appTitle: string): CsvExport;
|
|
110
|
+
export {};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import type { DeclaredView } from './view-runtime.js';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { DataReading
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
metric: (select: (data: Data) => MetricValues) => MetricReading;
|
|
7
|
-
};
|
|
8
|
-
export type DataContentState<Data, Input> = DataContentHelpers<Data, Input> & ({
|
|
3
|
+
import type { DataReading } from '../core/reading.js';
|
|
4
|
+
export type DataContentState<Data, Input> = {
|
|
5
|
+
scope: DataReading<string>;
|
|
6
|
+
} & ({
|
|
9
7
|
loading: true;
|
|
10
8
|
data?: never;
|
|
11
9
|
input?: never;
|
|
@@ -14,10 +12,25 @@ export type DataContentState<Data, Input> = DataContentHelpers<Data, Input> & ({
|
|
|
14
12
|
data: Data;
|
|
15
13
|
input: Input;
|
|
16
14
|
});
|
|
17
|
-
/**
|
|
15
|
+
/** Content receives only displayed data, its original input, and the derived scope. */
|
|
18
16
|
export declare function defineDataContent<Data, Input>(render: (state: DataContentState<Data, Input>) => ReactNode, options?: {
|
|
19
|
-
|
|
17
|
+
describeInput?: (input: Input) => string;
|
|
20
18
|
}): {
|
|
21
|
-
|
|
22
|
-
children(data: Data, input: Input): ReactNode;
|
|
19
|
+
loadingFallback: ReactNode;
|
|
20
|
+
children(this: void, data: Data, input: Input): ReactNode;
|
|
21
|
+
};
|
|
22
|
+
/** A section's request owner and render layout are declared together. */
|
|
23
|
+
export declare class ViewContent<Data, Input> {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(view: DeclaredView<Data, Input>, render: (source: DataContentState<Data, Input>) => ReactNode, describeInput: (input: Input) => string);
|
|
26
|
+
static section<Data, Input>(content: ViewContent<Data, Input>): {
|
|
27
|
+
loadingFallback: ReactNode;
|
|
28
|
+
children(this: void, data: Data, input: Input): ReactNode;
|
|
29
|
+
view: DeclaredView<Data, Input, unknown>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export declare function sectionContent<Data, Input>(content: ViewContent<Data, Input>): {
|
|
33
|
+
loadingFallback: ReactNode;
|
|
34
|
+
children(this: void, data: Data, input: Input): ReactNode;
|
|
35
|
+
view: DeclaredView<Data, Input, unknown>;
|
|
23
36
|
};
|
|
@@ -2,7 +2,7 @@ import { type ComponentRef, type ComponentPropsWithoutRef } from 'react';
|
|
|
2
2
|
import { type DataAppBridgeOptions } from '../../embed/bridge.js';
|
|
3
3
|
import type { DataAppConnection } from '../../embed/host.js';
|
|
4
4
|
import type { DataAppSource } from '../../embed/source.js';
|
|
5
|
-
export type DataAppBridgeProps = Pick<DataAppBridgeOptions, 'onMessage' | 'onStatusChange' | 'onDiagnostic' | 'presentation'> & ({
|
|
5
|
+
export type DataAppBridgeProps = Pick<DataAppBridgeOptions, 'onMessage' | 'onStatusChange' | 'onDiagnostic' | 'presentation' | 'logger'> & ({
|
|
6
6
|
source: DataAppSource;
|
|
7
7
|
title: string;
|
|
8
8
|
startupTimeoutMs?: number;
|