rift-ds 1.43.0 → 1.43.1
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/README.md +1 -1
- package/behaviors/framePacer.d.ts +5 -0
- package/behaviors/framePacer.js +44 -0
- package/behaviors/useFocusScope.js +4 -2
- package/behaviors/useLayer.d.ts +16 -0
- package/behaviors/useLayer.js +12 -2
- package/bin/rift-ds.mjs +24 -5
- package/chat/ResponseActions.js +3 -1
- package/chat/server.d.ts +1 -1
- package/chat/server.js +6 -1
- package/chat/upstash.js +13 -1
- package/components/AiButton/AiButton.js +1 -1
- package/components/AppLayout/AppLayout.css +1 -0
- package/components/AppSidebar/AppSidebar.js +5 -2
- package/components/Attachment/Attachment.css +1 -0
- package/components/Attachment/AttachmentDropZone.js +1 -1
- package/components/ColorPicker/ColorPicker.css +1 -0
- package/components/Combobox/Combobox.css +8 -0
- package/components/CommandPalette/CommandPalette.css +1 -0
- package/components/Composer/Composer.css +1 -0
- package/components/ContextMenu/ContextMenu.css +1 -0
- package/components/CurrencyInput/CurrencyInput.d.ts +1 -1
- package/components/CurrencyInput/CurrencyInput.js +2 -1
- package/components/DataTable/DataTable.d.ts +2 -2
- package/components/DataTable/DataTable.js +8 -6
- package/components/DataTable/columnTypes.js +1 -0
- package/components/DateInput/DateInput.css +7 -0
- package/components/DatePicker/calendar.d.ts +5 -1
- package/components/DatePicker/calendar.js +3 -3
- package/components/DateRangePicker/DateRangePicker.js +77 -73
- package/components/Dialog/Dialog.css +1 -0
- package/components/Drawer/Drawer.css +1 -0
- package/components/Dropdown/Dropdown.css +7 -0
- package/components/Dropdown/Dropdown.js +1 -0
- package/components/EntitySwitcher/EntitySwitcher.js +1 -0
- package/components/ErrorSummary/ErrorSummary.js +5 -0
- package/components/EventCalendar/EventCalendar.js +29 -23
- package/components/Globe/Globe.js +32 -3
- package/components/Inspector/Inspector.css +2 -0
- package/components/Lightbox/Lightbox.css +1 -0
- package/components/Menubar/Menubar.css +1 -0
- package/components/NumberInput/NumberInput.css +8 -0
- package/components/Popover/Popover.js +5 -1
- package/components/QuestionCard/QuestionCard.css +1 -0
- package/components/RadioButton/RadioButton.js +1 -0
- package/components/RichDropdown/RichDropdown.css +7 -0
- package/components/RichDropdown/RichDropdown.js +1 -0
- package/components/ShaderField/useShaderField.js +4 -2
- package/components/ShaderScene/ShaderScene.js +5 -2
- package/components/SiteLayout/SiteLayout.css +1 -0
- package/components/Slider/Slider.css +12 -0
- package/components/Slider/Slider.js +1 -1
- package/components/TableToolbar/TableToolbar.css +1 -0
- package/components/TableToolbar/TableToolbar.js +18 -1
- package/components/TagInput/TagInput.css +8 -0
- package/components/Textarea/Textarea.css +7 -0
- package/components/ThreadHistory/ThreadHistory.css +1 -0
- package/components/TimePicker/TimePicker.css +7 -0
- package/components/TimePicker/TimePicker.js +1 -0
- package/components/registry.d.ts +8 -0
- package/components/registry.json +19 -0
- package/components/registry.json.d.ts +19 -0
- package/components/registry.json.js +1 -1
- package/package.json +1 -1
- package/tokens/motion.d.ts +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<!-- npm-badge:end -->
|
|
10
10
|
[](LICENSE)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
The open-source, AI-native design system for React, built for AI products and coding agents: components on a three-tier token architecture, complete theme presets that restyle everything with one attribute, and machine surfaces (an MCP endpoint, per-component contracts as markdown and JSON schema, the tokens as DTCG files, installable agent skills) so your coding agent knows the library as well as you do.
|
|
13
13
|
|
|
14
14
|
## Why Rift DS
|
|
15
15
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type FramePacer = {
|
|
2
|
+
/** Whether a frame is due at `now`, given the last was drawn at `last`, for a loop that wants one every `interval` ms. */
|
|
3
|
+
due: (now: number, last: number, interval: number) => boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function createFramePacer(): FramePacer;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { MOTION_SHADER_FRAME_SLACK_MS } from "../tokens/motion.js";
|
|
2
|
+
const SAMPLES = 24;
|
|
3
|
+
const MIN_SAMPLES = 6;
|
|
4
|
+
const SLOWEST_TICK_MS = 1e3 / 30 + 2;
|
|
5
|
+
const FASTEST_TICK_MS = 1e3 / 360 - 0.5;
|
|
6
|
+
const COMMON_RATES_HZ = [30, 48, 50, 60, 72, 75, 90, 100, 120, 144, 165, 180, 200, 240, 300, 360];
|
|
7
|
+
const SNAP = 0.04;
|
|
8
|
+
function tickFrom(gaps) {
|
|
9
|
+
const sorted = [...gaps].sort((a, b) => a - b);
|
|
10
|
+
const base = sorted[Math.floor(sorted.length / 4)];
|
|
11
|
+
const singles = sorted.filter((gap) => gap >= base * 0.5 && gap <= base * 1.5);
|
|
12
|
+
const measured = singles[Math.floor(singles.length / 2)];
|
|
13
|
+
for (const hz of COMMON_RATES_HZ) {
|
|
14
|
+
const exact = 1e3 / hz;
|
|
15
|
+
if (Math.abs(measured - exact) / exact <= SNAP) return exact;
|
|
16
|
+
}
|
|
17
|
+
return measured;
|
|
18
|
+
}
|
|
19
|
+
function createFramePacer() {
|
|
20
|
+
const gaps = [];
|
|
21
|
+
let next = 0;
|
|
22
|
+
let previous = 0;
|
|
23
|
+
let tick = 0;
|
|
24
|
+
const learn = (now) => {
|
|
25
|
+
const gap = now - previous;
|
|
26
|
+
previous = now;
|
|
27
|
+
if (gap < FASTEST_TICK_MS || gap > SLOWEST_TICK_MS) return;
|
|
28
|
+
gaps[next] = gap;
|
|
29
|
+
next = (next + 1) % SAMPLES;
|
|
30
|
+
if (gaps.length >= MIN_SAMPLES) tick = tickFrom(gaps);
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
due(now, last, interval) {
|
|
34
|
+
learn(now);
|
|
35
|
+
const elapsed = now - last;
|
|
36
|
+
if (tick === 0) return elapsed >= interval - MOTION_SHADER_FRAME_SLACK_MS;
|
|
37
|
+
const ticks = Math.max(1, Math.round(interval / tick));
|
|
38
|
+
return elapsed >= (ticks - 0.5) * tick;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
createFramePacer
|
|
44
|
+
};
|
|
@@ -28,9 +28,11 @@ const activeModalPanel = () => inertScopes[inertScopes.length - 1]?.panel ?? nul
|
|
|
28
28
|
const isVisible = (el) => el.getClientRects().length > 0;
|
|
29
29
|
const restoreTarget = (previous) => {
|
|
30
30
|
if (!document.contains(previous)) return null;
|
|
31
|
-
if (isVisible(previous)) return previous;
|
|
31
|
+
if (isVisible(previous) && !previous.matches(":disabled")) return previous;
|
|
32
32
|
for (let el = previous.parentElement; el && el !== document.body; el = el.parentElement) {
|
|
33
|
-
if (isVisible(el))
|
|
33
|
+
if (!isVisible(el)) continue;
|
|
34
|
+
const standIn = getFocusable(el)[0];
|
|
35
|
+
if (standIn) return standIn;
|
|
34
36
|
}
|
|
35
37
|
return null;
|
|
36
38
|
};
|
package/behaviors/useLayer.d.ts
CHANGED
|
@@ -28,6 +28,13 @@
|
|
|
28
28
|
* press on the backdrop closed the open menu at pointerdown and then the
|
|
29
29
|
* Dialog on click, two layers for one press.
|
|
30
30
|
*
|
|
31
|
+
* - **Focus goes back to the opener.** A popup that closes while focus is
|
|
32
|
+
* inside it would drop focus to the page, and the next Tab would start
|
|
33
|
+
* from the top. A layer that names its opener (`returnFocus`) has focus
|
|
34
|
+
* handed back to it, quietly, when the stack dismisses the layer while
|
|
35
|
+
* focus is inside its elements. A modal does not need it: the focus scope
|
|
36
|
+
* restores focus when it closes.
|
|
37
|
+
*
|
|
31
38
|
* Exactly two document listeners exist while any layer is open, and none
|
|
32
39
|
* while the stack is empty. Registration order is stack order: overlays open
|
|
33
40
|
* in the order they are stacked, so stack order and paint order agree
|
|
@@ -62,6 +69,15 @@ type LayerOptions = {
|
|
|
62
69
|
* from closing it. Escape still reaches it first while it is on top.
|
|
63
70
|
*/
|
|
64
71
|
passive?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The control that opened this layer, for a non-modal popup that takes
|
|
74
|
+
* focus inside itself. When the stack dismisses the layer (Escape, or an
|
|
75
|
+
* outside press) while focus is inside `getElements()` and not already on
|
|
76
|
+
* the opener, focus is handed to it before `onDismiss` runs, quietly, so a
|
|
77
|
+
* Tooltip on the opener stays down. An outside press that lands on
|
|
78
|
+
* something focusable still moves focus there afterwards, as any press does.
|
|
79
|
+
*/
|
|
80
|
+
returnFocus?: () => HTMLElement | null | undefined;
|
|
65
81
|
};
|
|
66
82
|
export type LayerHandle = {
|
|
67
83
|
/**
|
package/behaviors/useLayer.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useRef, useEffect, useCallback } from "react";
|
|
3
|
+
import { focusQuietly } from "./quietFocus.js";
|
|
3
4
|
const layers = [];
|
|
4
5
|
let listenersInstalled = false;
|
|
5
6
|
let pressOwner = null;
|
|
6
7
|
const contains = (layer, target) => (layer.optionsRef.current.getElements?.() ?? []).some((el) => el?.contains(target));
|
|
8
|
+
const dismiss = (layer) => {
|
|
9
|
+
const options = layer.optionsRef.current;
|
|
10
|
+
const opener = options.returnFocus?.();
|
|
11
|
+
const focused = document.activeElement;
|
|
12
|
+
if (opener && focused && focused !== document.body && !opener.contains(focused) && contains(layer, focused)) {
|
|
13
|
+
focusQuietly(opener);
|
|
14
|
+
}
|
|
15
|
+
options.onDismiss?.();
|
|
16
|
+
};
|
|
7
17
|
const openLayerContains = (node) => layers.some((layer) => contains(layer, node));
|
|
8
18
|
const hasOpenLayer = () => layers.length > 0;
|
|
9
19
|
const handleLayerEscape = (event) => {
|
|
@@ -13,7 +23,7 @@ const handleLayerEscape = (event) => {
|
|
|
13
23
|
const options = top.optionsRef.current;
|
|
14
24
|
event.preventDefault();
|
|
15
25
|
if (options.dismissOnEscape === false) return;
|
|
16
|
-
|
|
26
|
+
dismiss(top);
|
|
17
27
|
};
|
|
18
28
|
const handlePointerDown = (event) => {
|
|
19
29
|
pressOwner = [...layers].reverse().find((layer) => !layer.optionsRef.current.passive) ?? null;
|
|
@@ -23,7 +33,7 @@ const handlePointerDown = (event) => {
|
|
|
23
33
|
const options = layer.optionsRef.current;
|
|
24
34
|
if (options.passive) continue;
|
|
25
35
|
if (!options.dismissOnOutsidePress || contains(layer, target)) break;
|
|
26
|
-
|
|
36
|
+
dismiss(layer);
|
|
27
37
|
}
|
|
28
38
|
};
|
|
29
39
|
const syncListeners = () => {
|
package/bin/rift-ds.mjs
CHANGED
|
@@ -65,6 +65,7 @@ const PACKAGE_NAME = 'rift-ds';
|
|
|
65
65
|
const CHAT_SLUG = 'ai-chat';
|
|
66
66
|
const MANIFEST_URL = `${SITE_ORIGIN}/skill/manifest.json`;
|
|
67
67
|
const DEFAULT_DIR = join('.claude', 'skills');
|
|
68
|
+
const FETCH_TIMEOUT_MS = 20000;
|
|
68
69
|
const TEMPLATES_ROOT = join(dirname(fileURLToPath(import.meta.url)), 'templates');
|
|
69
70
|
const TEMPLATES_DIR = join(TEMPLATES_ROOT, 'chat');
|
|
70
71
|
/*
|
|
@@ -157,9 +158,11 @@ function fail(message) {
|
|
|
157
158
|
async function get(url) {
|
|
158
159
|
let response;
|
|
159
160
|
try {
|
|
160
|
-
|
|
161
|
+
/* A stalled connection would otherwise hang the command with no word. */
|
|
162
|
+
response = await fetch(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
161
163
|
} catch (error) {
|
|
162
|
-
|
|
164
|
+
const why = error?.name === 'TimeoutError' ? `no answer in ${FETCH_TIMEOUT_MS / 1000}s` : (error?.message ?? error);
|
|
165
|
+
fail(`could not reach ${url} (${why}). Check your network and retry.`);
|
|
163
166
|
}
|
|
164
167
|
if (!response.ok) {
|
|
165
168
|
fail(`${url} answered ${response.status}. The site may be mid-deploy; retry in a minute.`);
|
|
@@ -401,7 +404,8 @@ function initBlock({ name, app, dryRun }) {
|
|
|
401
404
|
const { blocks } = JSON.parse(readFileSync(registryFile, 'utf8'));
|
|
402
405
|
if (!name) {
|
|
403
406
|
console.log('Blocks:\n');
|
|
404
|
-
|
|
407
|
+
const width = Math.max(...blocks.map((block) => block.name.length));
|
|
408
|
+
for (const block of blocks) console.log(` ${block.name.padEnd(width)} ${block.description}`);
|
|
405
409
|
console.log(`\nAdd one with: npx ${PACKAGE_NAME} init block <name>`);
|
|
406
410
|
console.log(`See them: ${SITE_ORIGIN}/docs/blocks`);
|
|
407
411
|
return;
|
|
@@ -415,7 +419,9 @@ function initBlock({ name, app, dryRun }) {
|
|
|
415
419
|
console.log(
|
|
416
420
|
dryRun
|
|
417
421
|
? `\n✓ Dry run: ${written.length} files would be written, ${skipped.length} left alone.`
|
|
418
|
-
:
|
|
422
|
+
: written.length === 0
|
|
423
|
+
? `\n· ${block.label} block already in place: 0 files written, ${skipped.length} left alone.`
|
|
424
|
+
: `\n✓ ${block.label} block added: ${written.length} files written, ${skipped.length} left alone.`
|
|
419
425
|
);
|
|
420
426
|
console.log(`\nNext:`);
|
|
421
427
|
console.log(` 1. If you have not, run npx ${PACKAGE_NAME} init app and make your root layout the one it prints,`);
|
|
@@ -443,12 +449,25 @@ function option(flag, what) {
|
|
|
443
449
|
return value;
|
|
444
450
|
}
|
|
445
451
|
|
|
452
|
+
/*
|
|
453
|
+
* A flag this command does not know is refused, never ignored: a mistyped
|
|
454
|
+
* --dry-run would otherwise write the files it was asked only to list.
|
|
455
|
+
*/
|
|
456
|
+
const VALUE_FLAGS = ['--app', '--skill', '--dir', '--out'];
|
|
457
|
+
const BOOLEAN_FLAGS = ['--dry-run', '--actions'];
|
|
458
|
+
const unknownFlag = args.find(
|
|
459
|
+
(arg) => arg.startsWith('-') && !VALUE_FLAGS.includes(arg) && !BOOLEAN_FLAGS.includes(arg)
|
|
460
|
+
);
|
|
461
|
+
if (unknownFlag) fail(`unknown option "${unknownFlag}"\n\n${USAGE}`);
|
|
462
|
+
/** What follows the init target, less every flag and the value a flag takes. */
|
|
463
|
+
const positionals = args.slice(2).filter((arg, at, rest) => !arg.startsWith('-') && !VALUE_FLAGS.includes(rest[at - 1]));
|
|
464
|
+
|
|
446
465
|
if (args[1] === 'chat' || args[1] === 'app' || args[1] === 'block') {
|
|
447
466
|
const appFlag = option('--app', 'a directory');
|
|
448
467
|
const scaffoldArgs = { app: appFlag ? resolve(appFlag) : undefined, dryRun: args.includes('--dry-run') };
|
|
449
468
|
if (args[1] === 'chat') initChat({ ...scaffoldArgs, actions: args.includes('--actions') });
|
|
450
469
|
else if (args[1] === 'app') initApp(scaffoldArgs);
|
|
451
|
-
else initBlock({ ...scaffoldArgs, name:
|
|
470
|
+
else initBlock({ ...scaffoldArgs, name: positionals[0] });
|
|
452
471
|
} else {
|
|
453
472
|
if (args[1] && !args[1].startsWith('--')) fail(`unknown init target "${args[1]}"\n\n${USAGE}`);
|
|
454
473
|
const only = option('--skill', 'a skill name');
|
package/chat/ResponseActions.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext, useState, useRef, useEffect } from "react";
|
|
4
4
|
import { MOTION_FEEDBACK_RESET_MS } from "../tokens/motion.js";
|
|
5
|
+
import { writeClipboard } from "../behaviors/clipboard.js";
|
|
5
6
|
import { useChatWidget } from "./context.js";
|
|
6
7
|
import "../behaviors/visually-hidden.css";
|
|
7
8
|
const ResponseActionsLabelsContext = createContext({
|
|
@@ -24,7 +25,8 @@ function ResponseActions({ turn }) {
|
|
|
24
25
|
);
|
|
25
26
|
const copy = async () => {
|
|
26
27
|
try {
|
|
27
|
-
await navigator.clipboard.writeText(turn.text);
|
|
28
|
+
if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(turn.text);
|
|
29
|
+
else writeClipboard(turn.text);
|
|
28
30
|
} catch {
|
|
29
31
|
return;
|
|
30
32
|
}
|
package/chat/server.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export interface ChatGuardrails {
|
|
|
94
94
|
onUsage?: (usage: TokenUsage, modelId: string) => Promise<void>;
|
|
95
95
|
/** Called once per exchange. Its presence is what makes the handler stream an `exchange` id, and so what shows the thumbs. */
|
|
96
96
|
onExchange?: (entry: ExchangeLog) => Promise<void>;
|
|
97
|
-
/**
|
|
97
|
+
/** The follow-ups and starters handlers' gate: a per-visitor limit, and in the Upstash guardrails the day's spend cap too. */
|
|
98
98
|
checkFollowups?: (request: Request) => Promise<boolean>;
|
|
99
99
|
/** Per-visitor limit for the feedback handler. */
|
|
100
100
|
checkFeedback?: (request: Request) => Promise<boolean>;
|
package/chat/server.js
CHANGED
|
@@ -13,6 +13,7 @@ const DEFAULT_ASK_USER_DESCRIPTION = [
|
|
|
13
13
|
"Prefer one question. Use several (at most 4) only when you need all the answers before you can continue. mode is single when one answer fits and multi when several can be true together.",
|
|
14
14
|
"Set other to true when the options may not cover every answer."
|
|
15
15
|
].join(" ");
|
|
16
|
+
const NOTICE_QUESTION_CHARS = 300;
|
|
16
17
|
const DEFAULT_CHAT_LIMITS = {
|
|
17
18
|
maxTurns: 10,
|
|
18
19
|
maxMessageChars: 4e3,
|
|
@@ -74,6 +75,9 @@ function parseBody(payload, limits, models, sanitise) {
|
|
|
74
75
|
if (typeof content !== "string") {
|
|
75
76
|
return { ok: false, status: 400, reason: "content must be a string" };
|
|
76
77
|
}
|
|
78
|
+
if (role === "user" && content.length > limits.maxMessageChars && entry !== messages[messages.length - 1]) {
|
|
79
|
+
return { ok: false, status: 413, reason: "conversation is too large" };
|
|
80
|
+
}
|
|
77
81
|
if (content.trim()) parsed.push({ role, content });
|
|
78
82
|
}
|
|
79
83
|
if (parsed.length === 0) return { ok: false, status: 400, reason: "no messages with content" };
|
|
@@ -204,7 +208,8 @@ function createChatHandler(options) {
|
|
|
204
208
|
if (!verdict.allowed) {
|
|
205
209
|
const logged = log({
|
|
206
210
|
id: exchangeId,
|
|
207
|
-
|
|
211
|
+
// Cut short: a refused request is the one a loop repeats, and its log must stay small.
|
|
212
|
+
question: question.slice(0, NOTICE_QUESTION_CHARS),
|
|
208
213
|
answer: verdict.notice,
|
|
209
214
|
path: parsed.path,
|
|
210
215
|
latencyMs: Date.now() - startedAt,
|
package/chat/upstash.js
CHANGED
|
@@ -119,6 +119,18 @@ function createUpstashGuardrails(options = {}) {
|
|
|
119
119
|
return true;
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
+
const followupsLimit = perVisitorLimit("followups", followupsPerMinute);
|
|
123
|
+
const checkFollowups = async (request) => {
|
|
124
|
+
if (!await followupsLimit(request)) return false;
|
|
125
|
+
const instance = getRedis();
|
|
126
|
+
if (!instance) return true;
|
|
127
|
+
try {
|
|
128
|
+
return (await instance.get(spendKey()) ?? 0) < dailySpendCapTenths;
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error("[chat] followups budget check failed, allowing:", error);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
122
134
|
const onFeedback = async (id, verdict, visitor) => {
|
|
123
135
|
const instance = getRedis();
|
|
124
136
|
if (!instance) return;
|
|
@@ -135,7 +147,7 @@ function createUpstashGuardrails(options = {}) {
|
|
|
135
147
|
visitorKey,
|
|
136
148
|
onUsage,
|
|
137
149
|
onExchange,
|
|
138
|
-
checkFollowups
|
|
150
|
+
checkFollowups,
|
|
139
151
|
checkFeedback: perVisitorLimit("feedback", feedbackPerMinute),
|
|
140
152
|
onFeedback
|
|
141
153
|
};
|
|
@@ -177,7 +177,7 @@ const AiButton = React.forwardRef(
|
|
|
177
177
|
className
|
|
178
178
|
].filter(Boolean).join(" ");
|
|
179
179
|
const iconClass = `${baseClass}__icon`;
|
|
180
|
-
const restingIcon = typeof icon === "string" ? /* @__PURE__ */ jsx("span", { className: `${iconClass}-glyph material-symbols-rounded ${mirrorClass(icon)}`, children: icon }) : icon;
|
|
180
|
+
const restingIcon = typeof icon === "string" ? /* @__PURE__ */ jsx("span", { className: `${iconClass}-glyph material-symbols-rounded ${mirrorClass(icon)}`, "aria-hidden": "true", children: icon }) : icon;
|
|
181
181
|
const shownIcon = shownStatus === "idle" ? restingIcon : /* @__PURE__ */ jsx(AgentStatusMark, { state: shownStatus });
|
|
182
182
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
183
183
|
(icon || status !== void 0) && /* @__PURE__ */ jsx("span", { className: iconClass, "aria-hidden": "true", children: /* @__PURE__ */ jsx(
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
/* The skip link lands here: the region takes the focus without a ring of
|
|
24
24
|
its own around the whole page. */
|
|
25
25
|
.ds-app-layout__main:focus {
|
|
26
|
+
/* ds-allow(focus): never a tab stop: the skip link lands here, and a ring round the whole page would mark nothing */
|
|
26
27
|
outline: none;
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -511,7 +511,7 @@ const AppSidebar = React.forwardRef(function AppSidebar2({
|
|
|
511
511
|
"aria-label": toggleLabel,
|
|
512
512
|
tabIndex: isExpanded || mobileOpen ? void 0 : -1,
|
|
513
513
|
"aria-hidden": isExpanded || mobileOpen ? void 0 : true,
|
|
514
|
-
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded ds-mirror-rtl", children: mobileOpen ? "close" : isExpanded ? "left_panel_close" : "left_panel_open" })
|
|
514
|
+
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded ds-mirror-rtl", "aria-hidden": "true", children: mobileOpen ? "close" : isExpanded ? "left_panel_close" : "left_panel_open" })
|
|
515
515
|
}
|
|
516
516
|
) })
|
|
517
517
|
] }),
|
|
@@ -605,6 +605,7 @@ const AppSidebar = React.forwardRef(function AppSidebar2({
|
|
|
605
605
|
"span",
|
|
606
606
|
{
|
|
607
607
|
className: `${baseClass}__btn-icon${typeof item.icon === "string" ? ` material-symbols-rounded ${mirrorClass(item.icon)}` : ` ${baseClass}__btn-icon--node`}`,
|
|
608
|
+
"aria-hidden": typeof item.icon === "string" ? true : void 0,
|
|
608
609
|
children: item.icon
|
|
609
610
|
}
|
|
610
611
|
),
|
|
@@ -623,6 +624,7 @@ const AppSidebar = React.forwardRef(function AppSidebar2({
|
|
|
623
624
|
`${baseClass}__btn-chevron material-symbols-rounded ds-mirror-rtl`,
|
|
624
625
|
isOpen && !isPanelMode ? `${baseClass}__btn-chevron--open` : ""
|
|
625
626
|
].filter(Boolean).join(" "),
|
|
627
|
+
"aria-hidden": "true",
|
|
626
628
|
children: "chevron_right"
|
|
627
629
|
}
|
|
628
630
|
)
|
|
@@ -671,6 +673,7 @@ const AppSidebar = React.forwardRef(function AppSidebar2({
|
|
|
671
673
|
`${baseClass}__sub-items`,
|
|
672
674
|
isOpen && isExpanded ? `${baseClass}__sub-items--open` : ""
|
|
673
675
|
].filter(Boolean).join(" "),
|
|
676
|
+
inert: !(isOpen && isExpanded) || void 0,
|
|
674
677
|
children: item.children.map((sub) => {
|
|
675
678
|
const subHasChildren = Boolean(sub.children?.length);
|
|
676
679
|
const subIsSource = subHasChildren && sub.key === panelSourceKey;
|
|
@@ -785,7 +788,7 @@ const AppSidebar = React.forwardRef(function AppSidebar2({
|
|
|
785
788
|
className: `${baseClass}__profile-more`,
|
|
786
789
|
onClick: onProfileMore,
|
|
787
790
|
"aria-label": profileMoreLabel,
|
|
788
|
-
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded", children: "more_horiz" })
|
|
791
|
+
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded", "aria-hidden": "true", children: "more_horiz" })
|
|
789
792
|
}
|
|
790
793
|
)
|
|
791
794
|
] }),
|
|
@@ -730,6 +730,7 @@ button.ds-attachment-group__single:focus-visible {
|
|
|
730
730
|
background-color: var(--color-bg-page-primary);
|
|
731
731
|
box-shadow: var(--shadow-modal);
|
|
732
732
|
overflow: hidden;
|
|
733
|
+
/* ds-allow(focus): never a tab stop: script moves focus here (tabindex -1) and the controls inside show their own */
|
|
733
734
|
outline: none;
|
|
734
735
|
transform: scale(0.96);
|
|
735
736
|
transition: transform var(--motion-duration-base) var(--motion-ease-standard);
|
|
@@ -62,7 +62,7 @@ const AttachmentDropZone = React.forwardRef(
|
|
|
62
62
|
children: [
|
|
63
63
|
children,
|
|
64
64
|
/* @__PURE__ */ jsx("div", { className: `${baseClass}__overlay`, "aria-hidden": "true", children: /* @__PURE__ */ jsxs("div", { className: `${baseClass}__message`, children: [
|
|
65
|
-
icon !== null && icon !== void 0 && /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon`, children: typeof icon === "string" ? /* @__PURE__ */ jsx("span", { className: `material-symbols-rounded ${mirrorClass(icon)}`, children: icon }) : icon }),
|
|
65
|
+
icon !== null && icon !== void 0 && /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon`, children: typeof icon === "string" ? /* @__PURE__ */ jsx("span", { className: `material-symbols-rounded ${mirrorClass(icon)}`, "aria-hidden": "true", children: icon }) : icon }),
|
|
66
66
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: label }),
|
|
67
67
|
hint && /* @__PURE__ */ jsx("span", { className: `${baseClass}__hint`, children: hint })
|
|
68
68
|
] }) })
|
|
@@ -253,6 +253,7 @@
|
|
|
253
253
|
min-width: 0;
|
|
254
254
|
border: none;
|
|
255
255
|
background: transparent;
|
|
256
|
+
/* ds-allow(focus): a bare text run: .ds-colorpicker__inputs draws the active border through :focus-within */
|
|
256
257
|
outline: none;
|
|
257
258
|
padding: 0;
|
|
258
259
|
font-family: var(--font-paragraph-sm-family);
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
flex: 1;
|
|
75
75
|
min-width: 0;
|
|
76
76
|
border: none;
|
|
77
|
+
/* ds-allow(focus): a bare text run: .ds-combobox__control draws the active border through :focus-within */
|
|
77
78
|
outline: none;
|
|
78
79
|
background-color: transparent;
|
|
79
80
|
padding: 0;
|
|
@@ -356,6 +357,13 @@
|
|
|
356
357
|
border-color: var(--color-status-error-border);
|
|
357
358
|
}
|
|
358
359
|
|
|
360
|
+
/* The border is the error's already, so it cannot also say "you are here":
|
|
361
|
+
a field in error takes the system ring while it holds the focus. */
|
|
362
|
+
.ds-combobox--error .ds-combobox__control:has(input:focus-visible) {
|
|
363
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
364
|
+
outline-offset: 2px;
|
|
365
|
+
}
|
|
366
|
+
|
|
359
367
|
/* ============================================
|
|
360
368
|
DISABLED STATE
|
|
361
369
|
============================================ */
|
|
@@ -4,7 +4,7 @@ import { DecimalString } from '../../format/money';
|
|
|
4
4
|
type CurrencyInputOwnProps = {
|
|
5
5
|
/** Label text above the field. */
|
|
6
6
|
label?: string;
|
|
7
|
-
/** The amount as a decimal string (`"1234.50"`), or `null` for none (controlled). Pair with `onValueChange`. */
|
|
7
|
+
/** The amount as a decimal string (`"1234.50"`), or `null` for none (controlled). An empty string, as a form library holds it, reads as none too. Pair with `onValueChange`. */
|
|
8
8
|
value?: DecimalString | null;
|
|
9
9
|
/** The amount the field starts with (uncontrolled). */
|
|
10
10
|
defaultValue?: DecimalString | null;
|
|
@@ -53,7 +53,8 @@ function CurrencyInput({
|
|
|
53
53
|
const digits = fractionDigits ?? currencyFractionDigits(currency);
|
|
54
54
|
const controlled = valueProp !== void 0;
|
|
55
55
|
const [uncontrolled, setUncontrolled] = useState(defaultValue);
|
|
56
|
-
const
|
|
56
|
+
const held = controlled ? valueProp : uncontrolled;
|
|
57
|
+
const value = typeof held === "string" && held.trim() === "" ? null : held;
|
|
57
58
|
const [focused, setFocused] = useState(false);
|
|
58
59
|
const [text, setText] = useState(() => restingText(value, locale, digits));
|
|
59
60
|
const affix = useMemo(() => affixFor(currency, locale, currencyDisplay), [currency, locale, currencyDisplay]);
|
|
@@ -333,7 +333,7 @@ type DataTableOwnProps<R extends DataTableRow = DataTableRow> = {
|
|
|
333
333
|
onPageSizeChange?: (pageSize: number) => void;
|
|
334
334
|
/** The page sizes the footer offers in a Rows per page picker. Leave unset for no picker. */
|
|
335
335
|
pageSizeOptions?: number[];
|
|
336
|
-
/** The current page, counting from 1, for controlled use. Pair with `onPageChange`. A page past the last shows the last. */
|
|
336
|
+
/** The current page, counting from 1, for controlled use. Pair with `onPageChange`. A page past the last shows the last, and one below 1 shows the first. */
|
|
337
337
|
page?: number;
|
|
338
338
|
/** The page to start on, counting from 1, for uncontrolled use. */
|
|
339
339
|
defaultPage?: number;
|
|
@@ -414,7 +414,7 @@ type DataTableOwnProps<R extends DataTableRow = DataTableRow> = {
|
|
|
414
414
|
rowCount?: number;
|
|
415
415
|
/** Whether rows are being fetched. With no rows yet the body shows skeleton rows; with rows on screen they stay, dimmed and inert, under a thin progress line, so the table never blanks. */
|
|
416
416
|
loading?: boolean;
|
|
417
|
-
/** A failed load's message. With no rows it replaces the body with an error state; over rows already on screen it shows as a Banner above them. Pair with `onRetry`. */
|
|
417
|
+
/** A failed load's message. With no rows it replaces the body with an error state and the footer's count and paging are left out; over rows already on screen it shows as a Banner above them. Pair with `onRetry`. */
|
|
418
418
|
error?: string;
|
|
419
419
|
/** Called by the error state's Try again button. Without it the error shows with no button. */
|
|
420
420
|
onRetry?: () => void;
|
|
@@ -615,7 +615,7 @@ function DataTable({
|
|
|
615
615
|
const [collapsedGroups, setCollapsedGroups] = useState([]);
|
|
616
616
|
const toggleGroup = (key) => setCollapsedGroups((current) => current.includes(key) ? current.filter((k) => k !== key) : [...current, key]);
|
|
617
617
|
const pageCount = pageSize ? Math.max(1, Math.ceil((manual ? matchCount : rowsInOrder.length) / pageSize)) : 1;
|
|
618
|
-
const clampedPage = Math.min(page, pageCount);
|
|
618
|
+
const clampedPage = Math.min(Math.max(page, 1), pageCount);
|
|
619
619
|
const pageRows = pageSize && !manual ? rowsInOrder.slice((clampedPage - 1) * pageSize, clampedPage * pageSize) : rowsInOrder;
|
|
620
620
|
const visibleRows = groups ? pageRows.filter((row) => !collapsedGroups.includes(groupByRow.get(row.id)?.key ?? "")) : pageRows;
|
|
621
621
|
const searched = useRef(false);
|
|
@@ -1632,6 +1632,7 @@ function DataTable({
|
|
|
1632
1632
|
onFocus: () => setActive({ row, col })
|
|
1633
1633
|
} : {};
|
|
1634
1634
|
const innerTab = gridMode ? -1 : void 0;
|
|
1635
|
+
const headerTab = stacked ? -1 : innerTab;
|
|
1635
1636
|
const justify = (align) => align === "center" ? "center" : align === "end" ? "flex-end" : align === "right" ? "right" : align === "left" ? "left" : "flex-start";
|
|
1636
1637
|
const alignsEnd = (align) => align === "end" || align === "right";
|
|
1637
1638
|
const utilityHeader = (key) => {
|
|
@@ -1668,7 +1669,7 @@ function DataTable({
|
|
|
1668
1669
|
indeterminate: someVisibleSelected,
|
|
1669
1670
|
onCheckedChange: toggleAllVisible,
|
|
1670
1671
|
"aria-label": selectAllLabel,
|
|
1671
|
-
tabIndex:
|
|
1672
|
+
tabIndex: headerTab,
|
|
1672
1673
|
"data-cell-control": ""
|
|
1673
1674
|
}
|
|
1674
1675
|
) })
|
|
@@ -1719,7 +1720,7 @@ function DataTable({
|
|
|
1719
1720
|
"aria-label": ranked && sortRank > 0 ? sortRankLabel(sortLabel(text, sortDirection(key)), sortRank + 1, sortDirection(key)) : sortLabel(text, sortDirection(key)),
|
|
1720
1721
|
onClick: (event) => cycleSort(key, event.shiftKey),
|
|
1721
1722
|
onMouseDown: multiSort ? (event) => event.shiftKey && event.preventDefault() : void 0,
|
|
1722
|
-
tabIndex:
|
|
1723
|
+
tabIndex: headerTab,
|
|
1723
1724
|
"data-cell-control": "",
|
|
1724
1725
|
children: [
|
|
1725
1726
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: col.header }),
|
|
@@ -1782,7 +1783,7 @@ function DataTable({
|
|
|
1782
1783
|
size: "compact",
|
|
1783
1784
|
tooltip: false,
|
|
1784
1785
|
label: labels.menu(text),
|
|
1785
|
-
tabIndex:
|
|
1786
|
+
tabIndex: headerTab
|
|
1786
1787
|
}
|
|
1787
1788
|
)
|
|
1788
1789
|
}
|
|
@@ -2358,6 +2359,7 @@ function DataTable({
|
|
|
2358
2359
|
const firstLoad = (loading && rows.length === 0 || commandLanding) && !error;
|
|
2359
2360
|
const refreshing = loading && rows.length > 0;
|
|
2360
2361
|
const searching = !manual && rows.length > 0 && search.trim().toLowerCase() !== needle;
|
|
2362
|
+
const failedEmpty = Boolean(error) && rows.length === 0;
|
|
2361
2363
|
const retryButton = onRetry && /* @__PURE__ */ jsx(Button, { variant: "secondary", tone: "neutral", size: "compact", iconLeft: "refresh", label: loadWords.retry, onClick: onRetry });
|
|
2362
2364
|
const skeletonRows = Array.from({ length: pageSize ?? 5 }, (_, index) => /* @__PURE__ */ jsxs("tr", { className: `ds-table__row ${baseClass}__skeleton-row`, "aria-hidden": "true", children: [
|
|
2363
2365
|
utilityKeys.map((key) => /* @__PURE__ */ jsx("td", { className: "ds-table__cell" }, key)),
|
|
@@ -2527,8 +2529,8 @@ function DataTable({
|
|
|
2527
2529
|
}
|
|
2528
2530
|
),
|
|
2529
2531
|
(pageSize !== void 0 || selectable) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__footer`, children: [
|
|
2530
|
-
/* @__PURE__ */ jsx("span", { className: `${baseClass}__count`, children: firstLoad ? null : selectable && currentSelection.length > 0 && !selectionClaimed ? selectedLabel(allMatching ? matchCount - exceptIds.length : currentSelection.length) : countClaimed ? null : resultsLabel(matchCount) }),
|
|
2531
|
-
pageSize !== void 0 && (pageCount > 1 || (pageSizeOptions?.length ?? 0) > 0) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__paging`, children: [
|
|
2532
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__count`, children: firstLoad ? null : selectable && currentSelection.length > 0 && !selectionClaimed ? selectedLabel(allMatching ? matchCount - exceptIds.length : currentSelection.length) : countClaimed || failedEmpty ? null : resultsLabel(matchCount) }),
|
|
2533
|
+
pageSize !== void 0 && !failedEmpty && (pageCount > 1 || (pageSizeOptions?.length ?? 0) > 0) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__paging`, children: [
|
|
2532
2534
|
pageSizeOptions && pageSizeOptions.length > 0 && /* @__PURE__ */ jsxs("span", { className: `${baseClass}__page-size`, children: [
|
|
2533
2535
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__page-size-label`, "aria-hidden": "true", children: pageSizeLabel }),
|
|
2534
2536
|
/* @__PURE__ */ jsx(
|
|
@@ -27,6 +27,7 @@ const relativeDate = (date, format, now) => formatRelative(date, { now, locale:
|
|
|
27
27
|
const formatNumber = (type, value, format) => {
|
|
28
28
|
const locale = format?.locale ?? DEFAULT_LOCALE;
|
|
29
29
|
const digits = format?.fractionDigits;
|
|
30
|
+
if (!Number.isFinite(value)) return String(value);
|
|
30
31
|
if (type === "currency")
|
|
31
32
|
return formatMoney(value, { currency: format?.currency ?? "USD", locale, fractionDigits: digits });
|
|
32
33
|
if (type === "progress")
|
|
@@ -158,4 +158,11 @@
|
|
|
158
158
|
padding-inline-start: calc(var(--padding-200) + 20px + var(--gap-200)); /* 8px + 20px icon + 8px gap */
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
/* The border is the error's already, so it cannot also say "you are here":
|
|
162
|
+
a field in error takes the system ring while it holds the focus. */
|
|
163
|
+
.ds-date-input--error .ds-date-input__field:focus-visible {
|
|
164
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
165
|
+
outline-offset: 2px;
|
|
166
|
+
}
|
|
167
|
+
|
|
161
168
|
} /* @layer rift.components */
|
|
@@ -4,7 +4,11 @@ import { Weekday } from '../../behaviors/locale';
|
|
|
4
4
|
export declare const EN_DAYS: string[];
|
|
5
5
|
/** A consumer's weekday list when it has the seven entries the grid needs, else the default. */
|
|
6
6
|
export declare const weekdaysOr: (labels: string[] | undefined, fallback: string[]) => string[];
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* A `YYYY-MM-DD` string as a local date, or null. Anything else (a full ISO
|
|
9
|
+
* timestamp, a locale's own date) is null too: an invalid date would throw
|
|
10
|
+
* in the first label that formats it and take the picker down.
|
|
11
|
+
*/
|
|
8
12
|
export declare function parseDate(str?: string | null): Date | null;
|
|
9
13
|
/** A local date as `YYYY-MM-DD`. */
|
|
10
14
|
export declare function formatDate(date: Date): string;
|
|
@@ -3,9 +3,9 @@ import { logicalArrowKey } from "../../behaviors/direction.js";
|
|
|
3
3
|
const EN_DAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
4
4
|
const weekdaysOr = (labels, fallback) => labels && labels.length === 7 ? labels : fallback;
|
|
5
5
|
function parseDate(str) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return new Date(
|
|
6
|
+
const parts = str ? /^(\d{4})-(\d{2})-(\d{2})$/.exec(str) : null;
|
|
7
|
+
if (!parts) return null;
|
|
8
|
+
return new Date(Number(parts[1]), Number(parts[2]) - 1, Number(parts[3]));
|
|
9
9
|
}
|
|
10
10
|
function formatDate(date) {
|
|
11
11
|
const y = date.getFullYear();
|