rift-ds 1.30.0 → 1.31.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.
Files changed (89) hide show
  1. package/README.md +6 -4
  2. package/behaviors/locale.d.ts +7 -0
  3. package/behaviors/locale.js +5 -0
  4. package/behaviors/shell.css +33 -0
  5. package/bin/rift-ds.mjs +35 -9
  6. package/bin/templates/blocks/app/planner/PlannerGrid.tsx +58 -0
  7. package/bin/templates/blocks/app/planner/Requests.tsx +42 -0
  8. package/bin/templates/blocks/app/planner/page.module.css +17 -0
  9. package/bin/templates/blocks/app/planner/page.tsx +32 -0
  10. package/bin/templates/blocks/registry.json +14 -0
  11. package/bin/templates/chat/app/api/chat/route.actions.ts +108 -0
  12. package/bin/templates/chat/components/chat/ChatMount.actions.tsx +55 -0
  13. package/bin/templates/chat/components/chat/ChatMount.tsx +14 -1
  14. package/bin/templates/chat/components/chat/proposals/ProposalCard.tsx +81 -0
  15. package/bin/templates/chat/components/chat/proposals/actions.ts +60 -0
  16. package/bin/templates/chat/components/chat/proposals/confirmation.ts +9 -0
  17. package/bin/templates/chat/components/chat/proposals/renderers.tsx +9 -0
  18. package/chat/ChatLauncher.d.ts +4 -1
  19. package/chat/ChatLauncher.js +6 -1
  20. package/chat/ChatProvider.d.ts +19 -2
  21. package/chat/ChatProvider.js +26 -3
  22. package/chat/ChatWidget.css +10 -0
  23. package/chat/ChatWidget.d.ts +2 -1
  24. package/chat/ChatWidget.js +8 -6
  25. package/chat/actions.d.ts +52 -6
  26. package/chat/actions.js +53 -5
  27. package/chat/contextSchema.d.ts +76 -0
  28. package/chat/contextSchema.js +58 -0
  29. package/chat/index.d.ts +2 -2
  30. package/chat/index.js +5 -1
  31. package/chat/registry.json.d.ts +2 -2
  32. package/chat/registry.json.js +1 -1
  33. package/chat/server.d.ts +18 -2
  34. package/chat/server.js +10 -1
  35. package/chat/suggestions.d.ts +7 -0
  36. package/chat/suggestions.js +13 -1
  37. package/chat/types.d.ts +23 -0
  38. package/chat/useChat.d.ts +2 -2
  39. package/chat/useChat.js +15 -1
  40. package/components/AppSidebar/AppSidebar.css +12 -0
  41. package/components/ButtonGroup/ButtonGroup.css +10 -1
  42. package/components/Chart/RadarChart.js +24 -10
  43. package/components/DataTable/DataTable.css +17 -2
  44. package/components/DataTable/DataTable.d.ts +14 -2
  45. package/components/DataTable/DataTable.js +13 -2
  46. package/components/DataTable/periodColumns.d.ts +37 -0
  47. package/components/DataTable/periodColumns.js +48 -0
  48. package/components/DatePicker/DatePicker.css +22 -6
  49. package/components/DatePicker/DatePicker.d.ts +2 -1
  50. package/components/DatePicker/DatePicker.js +2 -2
  51. package/components/DateRangePicker/DateRangePicker.js +2 -2
  52. package/components/DecisionRow/DecisionRow.css +46 -0
  53. package/components/DecisionRow/DecisionRow.d.ts +62 -0
  54. package/components/DecisionRow/DecisionRow.js +93 -0
  55. package/components/EventCalendar/EventCalendar.css +54 -0
  56. package/components/EventCalendar/EventCalendar.d.ts +27 -5
  57. package/components/EventCalendar/EventCalendar.js +50 -15
  58. package/components/FunnelChart/FunnelChart.js +33 -22
  59. package/components/Globe/Globe.css +7 -0
  60. package/components/Globe/Globe.js +1 -1
  61. package/components/Table/Table.css +7 -0
  62. package/components/Table/Table.js +1 -1
  63. package/components/Tabs/Tabs.css +21 -3
  64. package/components/Timeline/Timeline.css +8 -0
  65. package/components/Widget/Widget.css +2 -0
  66. package/components/WorldMap/WorldMap.css +15 -0
  67. package/components/WorldMap/WorldMap.js +56 -1
  68. package/components/registry.json +20 -3
  69. package/components/registry.json.d.ts +20 -3
  70. package/components/registry.json.js +1 -1
  71. package/index.d.ts +1 -0
  72. package/index.js +6 -0
  73. package/package.json +1 -1
  74. package/tokens/presets/blueprint.css +9 -0
  75. package/tokens/presets/bubblegum.css +9 -0
  76. package/tokens/presets/contrast.css +3 -3
  77. package/tokens/presets/coral.css +3 -3
  78. package/tokens/presets/ember.css +9 -0
  79. package/tokens/presets/getaway.css +9 -0
  80. package/tokens/presets/gold.css +3 -3
  81. package/tokens/presets/mono.css +3 -3
  82. package/tokens/presets/pink.css +3 -3
  83. package/tokens/presets/plum.css +3 -3
  84. package/tokens/presets/signal.css +9 -0
  85. package/tokens/presets/smoke.css +9 -0
  86. package/tokens/presets/velvet.css +9 -0
  87. package/tokens/presets/violet.css +3 -3
  88. package/tokens/presets/volt.css +9 -0
  89. package/tokens/presets/warm.css +3 -3
@@ -0,0 +1,58 @@
1
+ const MAX_CONTEXT_CHARS = 4e3;
2
+ const MAX_ID_CHARS = 128;
3
+ const PATH = /^\/(?:[a-z0-9-]+(?:\/[a-z0-9-]+){0,7})?$/;
4
+ const isId = (pattern, value) => typeof value === "string" && value.length <= MAX_ID_CHARS && new RegExp(`^(?:${pattern.source})$`, pattern.flags.replace("g", "")).test(value);
5
+ function cleanField(field, value) {
6
+ switch (field.kind) {
7
+ case "path":
8
+ return typeof value === "string" && value.length <= 128 && PATH.test(value) ? value : void 0;
9
+ case "oneOf":
10
+ return typeof value === "string" && field.values.includes(value) ? value : void 0;
11
+ case "id":
12
+ return isId(field.pattern, value) ? value : void 0;
13
+ case "ids": {
14
+ if (!Array.isArray(value)) return void 0;
15
+ const kept = [...new Set(value.filter((item) => isId(field.pattern, item)))].slice(0, field.max ?? 50);
16
+ return kept.length ? kept : void 0;
17
+ }
18
+ case "number":
19
+ return typeof value === "number" && Number.isFinite(value) && (field.min === void 0 || value >= field.min) && (field.max === void 0 || value <= field.max) ? value : void 0;
20
+ case "flag":
21
+ return typeof value === "boolean" ? value : void 0;
22
+ }
23
+ }
24
+ function clean(shape, values) {
25
+ const kept = {};
26
+ if (typeof values !== "object" || values === null || Array.isArray(values)) return kept;
27
+ for (const [key, field] of Object.entries(shape)) {
28
+ const value = cleanField(field, values[key]);
29
+ if (value !== void 0) kept[key] = value;
30
+ }
31
+ return kept;
32
+ }
33
+ const encode = (values) => Object.keys(values).length ? JSON.stringify(values) : null;
34
+ function defineContext(shape) {
35
+ return {
36
+ shape,
37
+ write: (values) => encode(clean(shape, values)),
38
+ sanitise: (raw) => {
39
+ if (typeof raw !== "string" || raw.length > MAX_CONTEXT_CHARS) return null;
40
+ try {
41
+ return encode(clean(shape, JSON.parse(raw)));
42
+ } catch {
43
+ return null;
44
+ }
45
+ },
46
+ read: (context) => {
47
+ if (!context) return {};
48
+ try {
49
+ return clean(shape, JSON.parse(context));
50
+ } catch {
51
+ return {};
52
+ }
53
+ }
54
+ };
55
+ }
56
+ export {
57
+ defineContext
58
+ };
package/chat/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export { ChatWidget, type ChatWidgetProps, type ChatAgentOptions, type ChatBackd
18
18
  export { useSelectionFocus, useHeldHighlight, readSelection, describeSelection, CHAT_SOURCE_ATTRIBUTE, HELD_HIGHLIGHT_NAME, type SelectedText, type DescribeSelectionOptions } from './selection';
19
19
  export { sanitiseSelection, selectionLines, DEFAULT_SELECTION_LIMITS, type ChatSelection, type SelectionKind, type SelectionLimits, type SelectionLinesOptions } from './selectionContext';
20
20
  export { useGeneratedStarters, type GeneratedStarters, type GeneratedStartersOptions } from './generatedStarters';
21
- export { defineAction, planAction, skippedText, createConfirmationMark, sanitiseConfirmation, confirmationLine, type ChatAction, type ActionPlan, type ActionConfirmation, type ConfirmationMark, type SanitiseConfirmationOptions, type ConfirmationLineOptions, } from './actions';
21
+ export { defineAction, planAction, skippedText, createConfirmationMark, sanitiseConfirmation, confirmationLine, planSequence, confirmSequence, defineContext, type ChatAction, type ActionPlan, type ActionConfirmation, type ConfirmationMark, type SanitiseConfirmationOptions, type ConfirmationLineOptions, type SequenceStep, type SequencePlan, type ConfirmedStep, type ContextField, type ContextShape, type ContextValues, type ContextSchema, } from './actions';
22
22
  export { ChatLauncher, CHAT_PANEL_ID, type ChatLauncherProps } from './ChatLauncher';
23
23
  export { useChatAgentState } from './agentState';
24
24
  export { ChatThreads, type ChatThreadsProps } from './ChatThreads';
@@ -39,5 +39,5 @@ export { STARTER_COUNT, pickStarters, namedStarter, hashString, mulberry32, } fr
39
39
  export { greetingFor, readGreeting, serverGreeting, subscribeClock, DEFAULT_GREETING_COPY, type GreetingCopy, } from './greeting';
40
40
  export { CHAT_PLACEMENTS, chatPlacement, DOCK_MIN_WIDTH, DOCK_MAX_WIDTH, DOCK_PAGE_MIN_WIDTH, dockFits, FLOAT_MAX_SCALE, FLOAT_EDGE_GAP, dockWidthFromDrag, isFloatDragStart, clampFloatPosition, type ChatPlacement, type ChatSide, } from './placement';
41
41
  export { artifactCard, cardArtifact } from './artifacts';
42
- export { ARTIFACT_CARD_KIND, CHAT_EVENT_KINDS, type ChatArtifact, type ChatCard, type ChatEvent, type ChatQuestion, type ChatQuestionAnswer, type ChatQuestionSet, type ChatReply, type ChatTransport, type ChatTransportMessage, type ChatTurn, type ChatModelOption, type ChatFeedbackVerdict, type LivePhase, type LiveResponse, type Starter, } from './types';
42
+ export { ARTIFACT_CARD_KIND, CHAT_EVENT_KINDS, type ChatArtifact, type ChatCard, type ChatEvent, type ChatQuestion, type ChatQuestionAnswer, type ChatQuestionSet, type ChatPageAction, type ChatReply, type ChatTransport, type ChatTransportMessage, type ChatTurn, type ChatModelOption, type ChatFeedbackVerdict, type LivePhase, type LiveResponse, type Starter, } from './types';
43
43
  export { chatWidget, chatWidgetRegistry, WIDGET_COUNT, type ChatWidgetMeta } from './registry';
package/chat/index.js CHANGED
@@ -3,7 +3,7 @@ import { ChatWidget } from "./ChatWidget.js";
3
3
  import { CHAT_SOURCE_ATTRIBUTE, HELD_HIGHLIGHT_NAME, describeSelection, readSelection, useHeldHighlight, useSelectionFocus } from "./selection.js";
4
4
  import { DEFAULT_SELECTION_LIMITS, sanitiseSelection, selectionLines } from "./selectionContext.js";
5
5
  import { useGeneratedStarters } from "./generatedStarters.js";
6
- import { confirmationLine, createConfirmationMark, defineAction, planAction, sanitiseConfirmation, skippedText } from "./actions.js";
6
+ import { confirmSequence, confirmationLine, createConfirmationMark, defineAction, planAction, planSequence, sanitiseConfirmation, skippedText } from "./actions.js";
7
7
  import { CHAT_PANEL_ID, ChatLauncher } from "./ChatLauncher.js";
8
8
  import { useChatAgentState } from "./agentState.js";
9
9
  import { ChatThreads } from "./ChatThreads.js";
@@ -26,6 +26,7 @@ import { CHAT_PLACEMENTS, DOCK_MAX_WIDTH, DOCK_MIN_WIDTH, DOCK_PAGE_MIN_WIDTH, F
26
26
  import { artifactCard, cardArtifact } from "./artifacts.js";
27
27
  import { ARTIFACT_CARD_KIND, CHAT_EVENT_KINDS } from "./types.js";
28
28
  import { WIDGET_COUNT, chatWidget, chatWidgetRegistry } from "./registry.js";
29
+ import { defineContext } from "./contextSchema.js";
29
30
  export {
30
31
  ARTIFACT_CARD_KIND,
31
32
  ARTIFACT_MIN_COLUMN_WIDTH,
@@ -79,6 +80,7 @@ export {
79
80
  chatWidget,
80
81
  chatWidgetRegistry,
81
82
  clampFloatPosition,
83
+ confirmSequence,
82
84
  confirmationLine,
83
85
  createConfirmationMark,
84
86
  createFeedbackPoster,
@@ -87,6 +89,7 @@ export {
87
89
  createSimTransport,
88
90
  defaultFilesReply,
89
91
  defineAction,
92
+ defineContext,
90
93
  describeAnswers,
91
94
  describeSelection,
92
95
  dockFits,
@@ -103,6 +106,7 @@ export {
103
106
  pickFallbackFollowups,
104
107
  pickStarters,
105
108
  planAction,
109
+ planSequence,
106
110
  readGreeting,
107
111
  readSelection,
108
112
  sanitiseConfirmation,
@@ -10,8 +10,8 @@ declare const _default: {
10
10
  "command": "init chat",
11
11
  "subpaths": {
12
12
  "./chat": "The widget, the provider, the launcher and the engine under them, with the hooks that let it follow the reader and write starters for what they picked.",
13
- "./chat/server": "The streaming chat handler, with an opt-in tool for asking the visitor questions, its follow-ups, starters and feedback siblings, and the checks for what a reader highlighted, for any web-standard route.",
14
- "./chat/actions": "The action definitions a page and its route share, their dry run and the mark that says a change was confirmed on its card, with no dependencies.",
13
+ "./chat/server": "The streaming chat handler, with an opt-in tool for asking the visitor questions, the cards a reply opens with, the page actions a tool returns, its follow-ups, starters and feedback siblings, and the checks for what a reader highlighted, for any web-standard route.",
14
+ "./chat/actions": "The action definitions a page and its route share, their dry run alone or in a sequence, the mark that says a change was confirmed on its card, and the declared shape of a page's context, with no dependencies.",
15
15
  "./chat/upstash": "Rate limits, a daily budget and the exchange log over Upstash Redis, as the handlers' guardrails.",
16
16
  "./chat/demo": "A scripted conversation with rich cards and fixtures, for a preview that needs no key.",
17
17
  "./chat/chat.css": "The widget's stylesheet."
@@ -1,5 +1,5 @@
1
1
  const $comment = "The widget registry: the fourth kind of thing the package ships, between the components and the templates. One member by design. `parts` names the library components the widget composes (held to src/components/registry.json by scripts/validate-chat-widget.mjs), `subpaths` the package exports it occupies (held to scripts/package-manifest.mjs), `category` the component category whose section and sidebar group its page joins (held to src/components/registry.json), `peers` the optional peer dependencies each subpath needs (held to package.json). The widget's page under /components, the /docs/chat page, the chat corpus and the MCP tools read this file; never type its facts elsewhere.";
2
- const widgets = [{ "name": "ChatWidget", "slug": "ai-chat", "label": "AI chat", "category": "ai", "description": "The whole AI chat: the panel, or the page itself in an app shell mode, the streaming replies, the history, the cards and questions a reply can carry and the server handlers, set up with props.", "command": "init chat", "subpaths": { "./chat": "The widget, the provider, the launcher and the engine under them, with the hooks that let it follow the reader and write starters for what they picked.", "./chat/server": "The streaming chat handler, with an opt-in tool for asking the visitor questions, its follow-ups, starters and feedback siblings, and the checks for what a reader highlighted, for any web-standard route.", "./chat/actions": "The action definitions a page and its route share, their dry run and the mark that says a change was confirmed on its card, with no dependencies.", "./chat/upstash": "Rate limits, a daily budget and the exchange log over Upstash Redis, as the handlers' guardrails.", "./chat/demo": "A scripted conversation with rich cards and fixtures, for a preview that needs no key.", "./chat/chat.css": "The widget's stylesheet." }, "peers": { "./chat": ["react-markdown", "remark-gfm"], "./chat/server": ["@anthropic-ai/sdk"], "./chat/upstash": ["@upstash/ratelimit", "@upstash/redis"], "./chat/demo": ["recharts"] }, "parts": ["AgentRail", "AgentStatus", "AiButton", "ArtifactCard", "ArtifactPanel", "AttachmentDropZone", "AttachmentGroup", "ChatHeader", "ChatMessage", "ChatThread", "CircularButton", "CodeBlock", "Composer", "DocumentChip", "DropdownMenu", "EmptyState", "Mention", "ModelPicker", "PixelAvatar", "PromptSuggestions", "Prose", "QuestionCard", "Reasoning", "ThreadPanel", "ThreadTabs"], "documented": ["ChatWidget", "ChatProvider", "ChatLauncher", "ChatThreads", "ChatTabs", "ChatAgentPane", "ChatArtifactPane", "ChatArtifactCard"] }];
2
+ const widgets = [{ "name": "ChatWidget", "slug": "ai-chat", "label": "AI chat", "category": "ai", "description": "The whole AI chat: the panel, or the page itself in an app shell mode, the streaming replies, the history, the cards and questions a reply can carry and the server handlers, set up with props.", "command": "init chat", "subpaths": { "./chat": "The widget, the provider, the launcher and the engine under them, with the hooks that let it follow the reader and write starters for what they picked.", "./chat/server": "The streaming chat handler, with an opt-in tool for asking the visitor questions, the cards a reply opens with, the page actions a tool returns, its follow-ups, starters and feedback siblings, and the checks for what a reader highlighted, for any web-standard route.", "./chat/actions": "The action definitions a page and its route share, their dry run alone or in a sequence, the mark that says a change was confirmed on its card, and the declared shape of a page's context, with no dependencies.", "./chat/upstash": "Rate limits, a daily budget and the exchange log over Upstash Redis, as the handlers' guardrails.", "./chat/demo": "A scripted conversation with rich cards and fixtures, for a preview that needs no key.", "./chat/chat.css": "The widget's stylesheet." }, "peers": { "./chat": ["react-markdown", "remark-gfm"], "./chat/server": ["@anthropic-ai/sdk"], "./chat/upstash": ["@upstash/ratelimit", "@upstash/redis"], "./chat/demo": ["recharts"] }, "parts": ["AgentRail", "AgentStatus", "AiButton", "ArtifactCard", "ArtifactPanel", "AttachmentDropZone", "AttachmentGroup", "ChatHeader", "ChatMessage", "ChatThread", "CircularButton", "CodeBlock", "Composer", "DocumentChip", "DropdownMenu", "EmptyState", "Mention", "ModelPicker", "PixelAvatar", "PromptSuggestions", "Prose", "QuestionCard", "Reasoning", "ThreadPanel", "ThreadTabs"], "documented": ["ChatWidget", "ChatProvider", "ChatLauncher", "ChatThreads", "ChatTabs", "ChatAgentPane", "ChatArtifactPane", "ChatArtifactCard"] }];
3
3
  const registry = {
4
4
  $comment,
5
5
  widgets
package/chat/server.d.ts CHANGED
@@ -1,13 +1,21 @@
1
1
  import { default as Anthropic } from '@anthropic-ai/sdk';
2
- import { ChatCard, ChatFeedbackVerdict, ChatModelOption } from './types';
2
+ import { ChatCard, ChatFeedbackVerdict, ChatModelOption, ChatPageAction } from './types';
3
3
  /** What a tool hands back: text for the model, and optionally a card for the visitor. */
4
- export { defineAction, planAction, skippedText, createConfirmationMark, sanitiseConfirmation, confirmationLine, type ChatAction, type ActionPlan, type ActionConfirmation, type ConfirmationMark, type SanitiseConfirmationOptions, type ConfirmationLineOptions, } from './actions';
4
+ export { defineAction, planAction, skippedText, createConfirmationMark, sanitiseConfirmation, confirmationLine, planSequence, confirmSequence, defineContext, type ChatAction, type ActionPlan, type ActionConfirmation, type ConfirmationMark, type SanitiseConfirmationOptions, type ConfirmationLineOptions, type SequenceStep, type SequencePlan, type ConfirmedStep, type ContextField, type ContextShape, type ContextValues, type ContextSchema, } from './actions';
5
5
  export { sanitiseSelection, selectionLines, DEFAULT_SELECTION_LIMITS, type ChatSelection, type SelectionKind, type SelectionLimits, type SelectionLinesOptions } from './selectionContext';
6
6
  export interface ChatToolResult {
7
7
  /** The tool result the model reads. */
8
8
  text: string;
9
9
  /** Rich content streamed to the widget as a `card` event, drawn by the provider's renderers. */
10
10
  card?: ChatCard;
11
+ /**
12
+ * Changes for the page to make in the browser, streamed as `action` events
13
+ * after the card and run once each by the provider's `pageActions`. An
14
+ * action with no `id` is given one.
15
+ */
16
+ actions?: (Omit<ChatPageAction, 'id'> & {
17
+ id?: string;
18
+ })[];
11
19
  }
12
20
  /** What a tool is told about the request it runs in. */
13
21
  export interface ChatToolContext {
@@ -179,6 +187,14 @@ export interface ChatHandlerOptions {
179
187
  copy?: Partial<ChatHandlerCopy>;
180
188
  /** Turns the request's raw `path` into context, or null to drop it. The default accepts lowercase slug paths only. */
181
189
  sanitiseContext?: (value: unknown) => string | null;
190
+ /**
191
+ * Cards the reply opens with, sent before the model is called and marked
192
+ * `lead`, so they hold still under the thinking line: the record of a
193
+ * change the reader just confirmed, worked out from the sanitised context.
194
+ * Return none for a request that needs none. A failure sends no lead and
195
+ * the reply goes on.
196
+ */
197
+ lead?: (context: ChatToolContext) => ChatCard[] | Promise<ChatCard[]>;
182
198
  /** Keeps a fire-and-forget promise alive on platforms that end work with the response. */
183
199
  waitUntil?: (promise: Promise<unknown>) => void;
184
200
  }
package/chat/server.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import Anthropic from "@anthropic-ai/sdk";
2
2
  import { ASK_USER_INPUT_SCHEMA, sanitizeQuestionSet } from "./questions.js";
3
3
  import { SUGGESTION_MAX_CHARS, fitsChip } from "./suggestions.js";
4
- import { confirmationLine, createConfirmationMark, defineAction, planAction, sanitiseConfirmation, skippedText } from "./actions.js";
4
+ import { confirmSequence, confirmationLine, createConfirmationMark, defineAction, planAction, planSequence, sanitiseConfirmation, skippedText } from "./actions.js";
5
5
  import { DEFAULT_SELECTION_LIMITS, sanitiseSelection, selectionLines } from "./selectionContext.js";
6
+ import { defineContext } from "./contextSchema.js";
6
7
  const ASK_USER_TOOL_NAME = "ask_user";
7
8
  const DEFAULT_ASK_USER_DESCRIPTION = [
8
9
  "Offer the person answers to pick for a question your reply has just asked in words.",
@@ -244,6 +245,8 @@ function createChatHandler(options) {
244
245
  send({ type: "status", label: copy.reading });
245
246
  send({ type: "model", label: serving.label });
246
247
  send({ type: "models", default: tierDefault, locked: lockedValues });
248
+ const leads = options.lead ? await Promise.resolve(options.lead(toolContext)).catch(() => []) : [];
249
+ for (const card of leads) send({ type: "card", card: { ...card, lead: true } });
247
250
  const reasoning = createReasoningBuffer(
248
251
  limits.maxTracePoints,
249
252
  (point) => send({ type: "status", label: copy.thinking, point })
@@ -332,6 +335,9 @@ function createChatHandler(options) {
332
335
  });
333
336
  const result = await runTool(block.name, block.input, toolContext);
334
337
  if (result.card) send({ type: "card", card: result.card });
338
+ for (const action of result.actions ?? []) {
339
+ send({ type: "action", action: { ...action, id: action.id ?? crypto.randomUUID() } });
340
+ }
335
341
  results.push({ type: "tool_result", tool_use_id: block.id, content: result.text });
336
342
  }
337
343
  working.push(
@@ -614,6 +620,7 @@ export {
614
620
  DEFAULT_CHAT_COPY,
615
621
  DEFAULT_CHAT_LIMITS,
616
622
  DEFAULT_SELECTION_LIMITS,
623
+ confirmSequence,
617
624
  confirmationLine,
618
625
  createChatHandler,
619
626
  createConfirmationMark,
@@ -621,9 +628,11 @@ export {
621
628
  createFollowupsHandler,
622
629
  createStartersHandler,
623
630
  defineAction,
631
+ defineContext,
624
632
  followupsSystemPrompt,
625
633
  parseFollowups,
626
634
  planAction,
635
+ planSequence,
627
636
  sanitiseConfirmation,
628
637
  sanitisePath,
629
638
  sanitiseSelection,
@@ -36,3 +36,10 @@
36
36
  export declare const SUGGESTION_MAX_CHARS = 30;
37
37
  /** Whether a suggestion label is one the chip row can actually show. */
38
38
  export declare function fitsChip(label: string): boolean;
39
+ /**
40
+ * Keeps the suggestions a host wrote that fit the chip row, and warns once in
41
+ * development about each one it drops, naming where it came from. A host's
42
+ * own copy running long is a mistake worth pointing at; a model's suggestion
43
+ * running long is not, so the producers of model output call `fitsChip` alone.
44
+ */
45
+ export declare function keepFittingSuggestions<T>(items: readonly T[], labelOf: (item: T) => string, where: string): T[];
@@ -1,9 +1,21 @@
1
+ import { warnOnce } from "../behaviors/devWarning.js";
1
2
  const SUGGESTION_MAX_CHARS = 30;
2
3
  function fitsChip(label) {
3
4
  const trimmed = label.trim();
4
5
  return trimmed !== "" && trimmed.length <= SUGGESTION_MAX_CHARS;
5
6
  }
7
+ function keepFittingSuggestions(items, labelOf, where) {
8
+ return items.filter((item) => {
9
+ const label = labelOf(item);
10
+ if (fitsChip(label)) return true;
11
+ warnOnce(
12
+ `${where}: "${label}" was dropped. A suggestion is one chip and a chip never wraps, so it must fit in ${SUGGESTION_MAX_CHARS} characters (SUGGESTION_MAX_CHARS).`
13
+ );
14
+ return false;
15
+ });
16
+ }
6
17
  export {
7
18
  SUGGESTION_MAX_CHARS,
8
- fitsChip
19
+ fitsChip,
20
+ keepFittingSuggestions
9
21
  };
package/chat/types.d.ts CHANGED
@@ -78,6 +78,22 @@ export interface ChatReply {
78
78
  answers: string[];
79
79
  }[];
80
80
  }
81
+ /**
82
+ * A change for the page itself, which lives in the browser where a server
83
+ * tool cannot reach: navigation, a table's view, the open tab, the theme. A
84
+ * tool returns it and the handler streams it; the provider runs the
85
+ * `pageActions` handler of the same `name` once, as the event arrives. The
86
+ * page owns what each name may do and checks `input` itself, since it came
87
+ * from the model.
88
+ */
89
+ export interface ChatPageAction {
90
+ /** Unique within the conversation: the provider runs each id once. */
91
+ id: string;
92
+ /** Which of the provider's `pageActions` runs it. An unknown name is ignored. */
93
+ name: string;
94
+ /** What the handler is handed. Must survive JSON. */
95
+ input?: unknown;
96
+ }
81
97
  export type ChatEvent =
82
98
  /** A live status step: the AgentStatus label, with an optional reasoning trace point. */
83
99
  {
@@ -143,6 +159,13 @@ export type ChatEvent =
143
159
  type: 'question';
144
160
  set: ChatQuestionSet;
145
161
  }
162
+ /** Something for the page to do in the browser (go to a page, set a
163
+ table's view, open a tab), run once by the provider's `pageActions` as
164
+ it arrives. Never re-run when the thread redraws or the panel reopens. */
165
+ | {
166
+ type: 'action';
167
+ action: ChatPageAction;
168
+ }
146
169
  /** Terminal: the response is complete. */
147
170
  | {
148
171
  type: 'done';
package/chat/useChat.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { AttachmentItem } from '../components/Attachment/fileTypes';
3
- import { ChatQuestionAnswer, ChatReply, ChatTransport, ChatTurn, LiveResponse } from './types';
3
+ import { ChatPageAction, ChatQuestionAnswer, ChatReply, ChatTransport, ChatTurn, LiveResponse } from './types';
4
4
  /** The copy the hook writes itself: the status line of a reply that has not started, and the reply it shows when a transport ends a turn with nothing to show. */
5
5
  export interface ChatPlaceholderCopy {
6
6
  /** A completion that produced no text. */
@@ -82,4 +82,4 @@ export interface ChatState {
82
82
  * streamed-text choreography. It knows nothing about rendering or about
83
83
  * where events come from; the transport decides that.
84
84
  */
85
- export declare function useChat(transport: ChatTransport, placeholders?: ChatPlaceholderCopy): ChatState;
85
+ export declare function useChat(transport: ChatTransport, placeholders?: ChatPlaceholderCopy, onAction?: (action: ChatPageAction) => void): ChatState;
package/chat/useChat.js CHANGED
@@ -11,13 +11,18 @@ const DEFAULT_PLACEHOLDER_COPY = {
11
11
  failed: "Something went wrong while replying. Try sending that again.",
12
12
  thinking: "Thinking"
13
13
  };
14
- function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY) {
14
+ function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY, onAction) {
15
15
  const [turns, setTurns] = useState([]);
16
16
  const [live, setLive] = useState(null);
17
17
  const [modelLabel, setModelLabel] = useState(null);
18
18
  const [modelPolicy, setModelPolicy] = useState(null);
19
19
  const abortRef = useRef(null);
20
20
  const busyRef = useRef(false);
21
+ const onActionRef = useRef(onAction);
22
+ useEffect(() => {
23
+ onActionRef.current = onAction;
24
+ }, [onAction]);
25
+ const ranActionsRef = useRef(/* @__PURE__ */ new Set());
21
26
  const historyRef = useRef([]);
22
27
  const generationRef = useRef(0);
23
28
  useEffect(() => () => abortRef.current?.abort(), []);
@@ -138,6 +143,15 @@ function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY) {
138
143
  if (set) current = { ...current, question: set };
139
144
  break;
140
145
  }
146
+ case "action":
147
+ if (typeof event.action?.id === "string" && typeof event.action.name === "string" && !ranActionsRef.current.has(event.action.id)) {
148
+ ranActionsRef.current.add(event.action.id);
149
+ try {
150
+ onActionRef.current?.(event.action);
151
+ } catch {
152
+ }
153
+ }
154
+ break;
141
155
  case "status":
142
156
  update({
143
157
  ...current,
@@ -82,6 +82,18 @@
82
82
  border-inline-end-color: transparent;
83
83
  }
84
84
 
85
+ /* The inset rail and its side panel are the plane's own colour, so on a
86
+ wide screen they are drawn clear and the plane shows through. Filled,
87
+ they stack above the page and paint over the side of the raised
88
+ surface's shadow that falls on them, leaving a straight cut beside the
89
+ surface. The phone drawer keeps its fill (its own rule below). */
90
+ @media not (max-width: 768px) {
91
+ .ds-app-sidebar--inset:not(.ds-app-sidebar--mobile-open),
92
+ .ds-app-sidebar__panel--inset {
93
+ background-color: transparent;
94
+ }
95
+ }
96
+
85
97
  /* ============================================
86
98
  TOP SECTION — logo + nav
87
99
  ============================================ */
@@ -7,7 +7,12 @@
7
7
  /* Layout */
8
8
  display: inline-flex; /* Hug content instead of stretch */
9
9
  width: auto; /* Don't stretch to full width */
10
- overflow: hidden;
10
+ max-width: 100%;
11
+ }
12
+
13
+ /* A button never shrinks to fit: a label cut mid-word is unreadable. */
14
+ .ds-button-group > * {
15
+ flex: none;
11
16
  }
12
17
 
13
18
  /* ============================================
@@ -19,6 +24,10 @@
19
24
  flex-direction: row;
20
25
  gap: var(--gap-500); /* Figma: --gap/lg (20px) */
21
26
  align-items: flex-start;
27
+ /* A row wider than its container wraps onto a second line at the tight
28
+ step, so it still reads as one group. */
29
+ flex-wrap: wrap;
30
+ row-gap: var(--gap-200);
22
31
  }
23
32
 
24
33
  /* ============================================
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import React, { useCallback, useId } from "react";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import React, { useCallback, useId, useState } from "react";
4
4
  import { ResponsiveContainer, RadarChart as RadarChart$1, PolarGrid, PolarAngleAxis, PolarRadiusAxis, Tooltip, Radar, Legend } from "recharts";
5
5
  import { readTokenPx, getChartSeriesColors } from "./palette.js";
6
6
  import { useChartAnimation } from "./useChartAnimation.js";
@@ -48,6 +48,26 @@ const RadarChart = React.forwardRef(({
48
48
  const textSize = readTokenPx("--font-caption-size", "12px");
49
49
  const gridColor = getCSSVar("--color-divider", "rgba(214, 214, 214, 0.8)");
50
50
  const seriesColors = getChartSeriesColors();
51
+ const [bodyWidth, setBodyWidth] = useState(0);
52
+ const charWidth = textSize * 0.6;
53
+ const labelRoom = Math.ceil(Math.max(0, ...data.map((d) => String(d[categoryKey] ?? "").length)) * charWidth) + 12;
54
+ const half = Math.min(bodyWidth, height) / 2;
55
+ const outerRadius = bodyWidth > 0 ? Math.min(half * 0.7, Math.max(half * 0.45, bodyWidth / 2 - labelRoom)) : "70%";
56
+ const renderAngleTick = useCallback(
57
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
58
+ (props) => {
59
+ const { x, y, payload, textAnchor } = props;
60
+ const full = String(payload?.value ?? "");
61
+ const room = bodyWidth <= 0 ? Infinity : textAnchor === "end" ? x - 2 : textAnchor === "start" ? bodyWidth - x - 2 : 2 * Math.min(x, bodyWidth - x) - 4;
62
+ const fits = Math.max(1, Math.floor(room / charWidth));
63
+ const text = full.length > fits ? `${full.slice(0, Math.max(1, fits - 1))}…` : full;
64
+ return /* @__PURE__ */ jsxs("text", { x, y, textAnchor, dominantBaseline: "central", fill: textSecondary, fontSize: textSize, children: [
65
+ text !== full && /* @__PURE__ */ jsx("title", { children: full }),
66
+ text
67
+ ] });
68
+ },
69
+ [bodyWidth, charWidth, textSecondary, textSize]
70
+ );
51
71
  const renderTooltip = useCallback(
52
72
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
53
73
  (props) => /* @__PURE__ */ jsx(RadarTooltip, { ...props, locale }),
@@ -73,15 +93,9 @@ const RadarChart = React.forwardRef(({
73
93
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? formatNumber(item.value, locale) : item.value })
74
94
  ] }, i)) })
75
95
  ] }),
76
- /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(RadarChart$1, { data, cx: "50%", cy: "50%", outerRadius: "70%", children: [
96
+ /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, onResize: (width) => setBodyWidth(width), children: /* @__PURE__ */ jsxs(RadarChart$1, { data, cx: "50%", cy: "50%", outerRadius, children: [
77
97
  /* @__PURE__ */ jsx(PolarGrid, { stroke: gridColor }),
78
- /* @__PURE__ */ jsx(
79
- PolarAngleAxis,
80
- {
81
- dataKey: categoryKey,
82
- tick: { fill: textSecondary, fontSize: textSize }
83
- }
84
- ),
98
+ /* @__PURE__ */ jsx(PolarAngleAxis, { dataKey: categoryKey, tick: renderAngleTick }),
85
99
  /* @__PURE__ */ jsx(
86
100
  PolarRadiusAxis,
87
101
  {
@@ -153,6 +153,15 @@
153
153
  overflow: hidden;
154
154
  }
155
155
 
156
+ /* A word wider than its fixed column wraps before the clip, so it is never
157
+ cut mid-word with nothing to say so. `anywhere` rather than
158
+ `break-word`: the cell content is a flex box, and its text's automatic
159
+ minimum is the longest word unless the break counts toward it. The
160
+ widths here are already fixed, so nothing else is resized by it. */
161
+ .ds-data-table__grid--fixed .ds-table__cell-content {
162
+ overflow-wrap: anywhere;
163
+ }
164
+
156
165
  .ds-data-table__filler {
157
166
  padding: 0;
158
167
  }
@@ -1057,16 +1066,22 @@
1057
1066
  rotate: 90deg;
1058
1067
  }
1059
1068
 
1069
+ /* The group's value gives way first in a narrow column (a pinned row
1070
+ header on a phone): it ends in an ellipsis rather than running under its
1071
+ count and past the column's edge. The group toggle names it in full. */
1060
1072
  .ds-data-table__group-value {
1061
- display: inline-flex;
1062
- align-items: center;
1073
+ display: block;
1074
+ flex: 0 1 auto;
1063
1075
  min-width: 0;
1076
+ overflow: hidden;
1077
+ text-overflow: ellipsis;
1064
1078
  font-family: var(--font-paragraph-emphasis-family);
1065
1079
  font-weight: var(--font-paragraph-emphasis-weight);
1066
1080
  }
1067
1081
 
1068
1082
  .ds-data-table__group-count,
1069
1083
  .ds-data-table__group-total {
1084
+ flex: none;
1070
1085
  font-family: var(--font-caption-family);
1071
1086
  font-size: var(--font-caption-size);
1072
1087
  font-weight: var(--font-caption-weight);
@@ -425,6 +425,18 @@ type DataTableOwnProps<R extends DataTableRow = DataTableRow> = {
425
425
  expandMode?: 'multiple' | 'single';
426
426
  /** Fires with the table's setup as a view whenever any part of it changes, so a host can keep the reader's last view. */
427
427
  onViewChange?: (view: DataTableView) => void;
428
+ /**
429
+ * The whole setup in one value (sorts, filters, search, grouping, hidden and
430
+ * ordered columns, pins, widths, density, page size), for controlled use:
431
+ * whenever it changes the table shows it, so one piece of state outside the
432
+ * table, a chat's card or a saved link, can set every part at once. A part it
433
+ * leaves out falls back to the table's opening setup. Pair with
434
+ * `onViewChange`, and hand back what it reports, so the reader's own changes
435
+ * stay.
436
+ */
437
+ view?: DataTableView;
438
+ /** The setup to start with, for uncontrolled use: the table's first render, the server's HTML too, is already this view. */
439
+ defaultView?: DataTableView;
428
440
  /** The column keys the rows are grouped by, for controlled use; this milestone draws the first. Pair with `onGroupingChange`. */
429
441
  grouping?: string[];
430
442
  /** The grouping to start with, for uncontrolled use. */
@@ -606,7 +618,7 @@ type DataTableOwnProps<R extends DataTableRow = DataTableRow> = {
606
618
  };
607
619
  export interface DataTableProps<R extends DataTableRow = DataTableRow> extends DataTableOwnProps<R>, Omit<React.ComponentPropsWithRef<'div'>, keyof DataTableOwnProps<R>> {
608
620
  }
609
- export declare function DataTable<R extends DataTableRow = DataTableRow>({ columns: columnsProp, rows: rowsProp, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, pageSizeOptions, page: pageProp, defaultPage, onPageChange, pageSizeLabel, phoneLayout, selectable, selectedIds, defaultSelectedIds, onSelectionChange, sort, defaultSort, onSortChange, sorts: sortsProp, defaultSorts, onSortsChange, multiSort, onViewChange, virtualize, onLoadMore, hasMore, renderDetail, expandedIds: expandedProp, defaultExpandedIds, onExpandedIdsChange, expandMode, grouping: groupingProp, defaultGrouping, onGroupingChange, totalsRow, totals: totalsProp, defaultTotals, onTotalsChange, linkComponent, rowHref, onRowClick, searchable, searchPlaceholder, toolbar, size: sizeProp, defaultSize, onSizeChange, filters: filtersProp, defaultFilters, onFiltersChange, search: searchProp, defaultSearch, onSearchChange, filterLabels: filterLabelsProp, striped, caption, emptyState, selectAllLabel, selectRowLabel, sortLabel, sortRankLabel, sortAnnouncement, pageAnnouncement, resultsLabel, selectedLabel, paginationLabels, emptyStateLabels, resizableColumns, reorderableColumns, columnMenu, reorderableRows, stickyHeader, maxHeight, navigation, columnWidths, defaultColumnWidths, onColumnWidthsChange, columnOrder, defaultColumnOrder, onColumnOrderChange, columnPinning, defaultColumnPinning, onColumnPinningChange, hiddenColumns, defaultHiddenColumns, onHiddenColumnsChange, rowOrder, defaultRowOrder, onRowOrderChange, columnLabels, columnDividers, cellText, rowActions, rowActionsVisibility, editMode, onCellEdit, onRowEdit, manual, rowCount: rowCountProp, loading, error, onRetry, loadLabels, locale: localeProp, className, ref, ...rest }: DataTableProps<R>): React.JSX.Element;
621
+ export declare function DataTable<R extends DataTableRow = DataTableRow>({ columns: columnsProp, rows: rowsProp, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, pageSizeOptions, page: pageProp, defaultPage, onPageChange, pageSizeLabel, phoneLayout, selectable, selectedIds, defaultSelectedIds, onSelectionChange, sort, defaultSort, onSortChange, sorts: sortsProp, defaultSorts, onSortsChange, multiSort, onViewChange, view: viewProp, defaultView, virtualize, onLoadMore, hasMore, renderDetail, expandedIds: expandedProp, defaultExpandedIds, onExpandedIdsChange, expandMode, grouping: groupingProp, defaultGrouping, onGroupingChange, totalsRow, totals: totalsProp, defaultTotals, onTotalsChange, linkComponent, rowHref, onRowClick, searchable, searchPlaceholder, toolbar, size: sizeProp, defaultSize, onSizeChange, filters: filtersProp, defaultFilters, onFiltersChange, search: searchProp, defaultSearch, onSearchChange, filterLabels: filterLabelsProp, striped, caption, emptyState, selectAllLabel, selectRowLabel, sortLabel, sortRankLabel, sortAnnouncement, pageAnnouncement, resultsLabel, selectedLabel, paginationLabels, emptyStateLabels, resizableColumns, reorderableColumns, columnMenu, reorderableRows, stickyHeader, maxHeight, navigation, columnWidths, defaultColumnWidths, onColumnWidthsChange, columnOrder, defaultColumnOrder, onColumnOrderChange, columnPinning, defaultColumnPinning, onColumnPinningChange, hiddenColumns, defaultHiddenColumns, onHiddenColumnsChange, rowOrder, defaultRowOrder, onRowOrderChange, columnLabels, columnDividers, cellText, rowActions, rowActionsVisibility, editMode, onCellEdit, onRowEdit, manual, rowCount: rowCountProp, loading, error, onRetry, loadLabels, locale: localeProp, className, ref, ...rest }: DataTableProps<R>): React.JSX.Element;
610
622
  /**
611
623
  * A stored view made safe for a table's columns as they are now: columns
612
624
  * that no longer exist drop out of every part of it, a filter whose
@@ -616,4 +628,4 @@ export declare function DataTable<R extends DataTableRow = DataTableRow>({ colum
616
628
  * read from storage before showing it anywhere else.
617
629
  */
618
630
  export declare function reconcileDataTableView<R extends DataTableRow = DataTableRow>(view: DataTableView, columns: DataTableColumn<R>[]): DataTableView;
619
- export {};
631
+ export { periodColumns, periodsOf, totalOf, type PeriodColumnsOptions, type PeriodUnit, type Period } from './periodColumns';
@@ -191,6 +191,8 @@ function DataTable({
191
191
  onSortsChange,
192
192
  multiSort = false,
193
193
  onViewChange,
194
+ view: viewProp,
195
+ defaultView,
194
196
  virtualize = "auto",
195
197
  onLoadMore,
196
198
  hasMore = false,
@@ -293,7 +295,7 @@ function DataTable({
293
295
  const locale = useLocale(localeProp);
294
296
  const collator = useMemo(() => textCollator(locale), [locale]);
295
297
  const compareValues = useMemo(() => valueComparator(collator), [collator]);
296
- const [startingView] = useState(() => slotStartingView(toolbar));
298
+ const [startingView] = useState(() => viewProp ?? defaultView ?? slotStartingView(toolbar));
297
299
  const startsWith = (key, controlled) => controlled === void 0 && startingView?.[key] !== void 0;
298
300
  const [size, setSize] = useControllable(
299
301
  sizeProp,
@@ -1133,6 +1135,13 @@ function DataTable({
1133
1135
  if (next.pageSize !== void 0) setPageSize(next.pageSize);
1134
1136
  setPage(1);
1135
1137
  };
1138
+ const viewPropKey = viewProp ? viewKey(fullView(viewProp)) : null;
1139
+ const appliedViewKey = useRef(viewPropKey);
1140
+ useEffect(() => {
1141
+ if (!viewProp || viewPropKey === appliedViewKey.current) return;
1142
+ appliedViewKey.current = viewPropKey;
1143
+ if (viewPropKey !== currentKey) applyView(viewProp);
1144
+ }, [viewPropKey]);
1136
1145
  const viewCallback = useRef(onViewChange);
1137
1146
  useEffect(() => {
1138
1147
  viewCallback.current = onViewChange;
@@ -1474,8 +1483,10 @@ function DataTable({
1474
1483
  return String(result.value);
1475
1484
  };
1476
1485
  const groupTotal = (col, groupRows) => {
1477
- if (!col.aggregate) return null;
1478
1486
  const values = groupRows.map((row) => row.values[col.key]);
1487
+ const picked = totalsState[col.key];
1488
+ if (picked && picked !== "none") return resultText(col, calculate(picked, values));
1489
+ if (!col.aggregate) return null;
1479
1490
  if (typeof col.aggregate === "function") return col.aggregate(values, groupRows);
1480
1491
  return resultText(col, calculate(col.aggregate, values));
1481
1492
  };
@@ -0,0 +1,37 @@
1
+ import { DataTableColumn, DataTableRow, DataTableValue } from './DataTable';
2
+ /** The length of one period column. */
3
+ export type PeriodUnit = 'day' | 'week' | 'month';
4
+ export interface PeriodColumnsOptions<R extends DataTableRow = DataTableRow> {
5
+ /** The first period's date, as `YYYY-MM-DD`. A week starts on this day; a month column is the month this day falls in. */
6
+ start: string;
7
+ /** How many periods, one column each. */
8
+ count: number;
9
+ /** How long each period is. */
10
+ unit: PeriodUnit;
11
+ /** The locale the headers are written in. */
12
+ locale?: string;
13
+ /** Prepended to each period's date to make its column key: `"d:2026-03-02"`. Defaults to `""`. */
14
+ keyPrefix?: string;
15
+ /** The header for a period, given its first day and its unit. Defaults to the weekday and day ("Mon 2") for a day, the first day ("Mar 2") for a week, and the month ("Mar") for a month, in `locale`. */
16
+ header?: (date: Date, unit: PeriodUnit) => string;
17
+ /** What every period column shares (its type, alignment, editability, aggregate), laid under the key and header. */
18
+ column?: Omit<DataTableColumn<R>, 'key' | 'header'>;
19
+ }
20
+ /** One period: its column key and its first day, as `YYYY-MM-DD`. */
21
+ export interface Period {
22
+ key: string;
23
+ date: string;
24
+ }
25
+ /** The periods a run covers, first first: each one's column key and first day. Dates are calendar dates, never moved by a time zone. */
26
+ export declare function periodsOf({ start, count, unit, keyPrefix }: Pick<PeriodColumnsOptions, 'start' | 'count' | 'unit' | 'keyPrefix'>): Period[];
27
+ /**
28
+ * Columns for a run of periods: one per day, week or month, for a table whose
29
+ * rows are measured across time (hours by day, a budget by month, stock by
30
+ * week). Each column's key is its first day, so a row's values are keyed the
31
+ * same way, and every column takes what `column` shares, so the run is
32
+ * edited, aggregated and aligned as one. Pair it with a computed total column
33
+ * (`totalOf`) and the totals row for the sums across and down.
34
+ */
35
+ export declare function periodColumns<R extends DataTableRow = DataTableRow>({ locale, header, column, ...run }: PeriodColumnsOptions<R>): DataTableColumn<R>[];
36
+ /** A computed column's `compute`: the sum of the number values under these keys, for a total across a row. A value that is not a number counts as nothing. */
37
+ export declare const totalOf: (keys: readonly string[]) => (values: Record<string, DataTableValue>) => number;