@kitn.ai/ui 0.28.0 → 0.29.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/README.md +1 -1
- package/dist/agent-tooling/construct/public.d.ts +15 -0
- package/dist/agent-tooling/construct/schema.d.ts +111 -0
- package/dist/construct-cli.es.js +3 -3
- package/dist/construct.d.ts +5 -0
- package/dist/construct.js +327 -0
- package/dist/core-C8fzo39E.js +1 -12
- package/dist/engine-javascript-C1x7zo1_.js +1 -141
- package/dist/mcp.es.js +1 -1
- package/package.json +16 -16
- package/bin/route.test.js +0 -58
- package/src/agent-tooling/README.md +0 -192
- package/src/agent-tooling/archetypes.ts +0 -205
- package/src/agent-tooling/catalog/README.md +0 -676
- package/src/agent-tooling/catalog/catalog-types.ts +0 -231
- package/src/agent-tooling/catalog/fabrications.ts +0 -96
- package/src/agent-tooling/catalog/invariants.ts +0 -284
- package/src/agent-tooling/catalog/labs-titles.ts +0 -114
- package/src/agent-tooling/catalog/scenarios.ts +0 -87
- package/src/agent-tooling/catalog/surfaces.ts +0 -347
- package/src/agent-tooling/construct/cli-entry.ts +0 -8
- package/src/agent-tooling/construct/cli.ts +0 -147
- package/src/agent-tooling/construct/codegen.ts +0 -1635
- package/src/agent-tooling/construct/construct.v1.schema.json +0 -319
- package/src/agent-tooling/construct/dev.ts +0 -148
- package/src/agent-tooling/construct/fixtures/demo-widget.construct.json +0 -7
- package/src/agent-tooling/construct/fixtures/ops-console.construct.json +0 -44
- package/src/agent-tooling/construct/fixtures/owner-widget.construct.json +0 -32
- package/src/agent-tooling/construct/schema.ts +0 -452
- package/src/agent-tooling/integrations/anthropic.ts +0 -442
- package/src/agent-tooling/integrations/cloudflare.ts +0 -218
- package/src/agent-tooling/integrations/langgraph.ts +0 -133
- package/src/agent-tooling/integrations/mastra.ts +0 -182
- package/src/agent-tooling/integrations/mock.ts +0 -148
- package/src/agent-tooling/integrations/ollama.ts +0 -97
- package/src/agent-tooling/integrations/openai.ts +0 -95
- package/src/agent-tooling/integrations/openrouter.ts +0 -82
- package/src/agent-tooling/integrations/pi.ts +0 -176
- package/src/agent-tooling/integrations/pydantic-ai.ts +0 -108
- package/src/agent-tooling/integrations/vercel-ai-sdk.ts +0 -398
- package/src/agent-tooling/mcp/css-raw.d.ts +0 -12
- package/src/agent-tooling/mcp/manifest.ts +0 -422
- package/src/agent-tooling/mcp/server.ts +0 -116
- package/src/agent-tooling/mcp/stdio.ts +0 -18
- package/src/agent-tooling/mcp/tools/construct.ts +0 -130
- package/src/agent-tooling/mcp/tools/debug.ts +0 -621
- package/src/agent-tooling/mcp/tools/reference.ts +0 -980
- package/src/agent-tooling/mcp/tools/scaffold.ts +0 -6708
- package/src/agent-tooling/mcp/tools/theme.ts +0 -456
- package/src/agent-tooling/mcp/tools/types.ts +0 -14
- package/src/agent-tooling/mcp/validate-args.ts +0 -141
- package/src/agent-tooling/recipes/composed-thread.ts +0 -714
- package/src/agent-tooling/recipes/index.ts +0 -22
- package/src/agent-tooling/recipes/types.ts +0 -32
- package/src/agent-tooling/registry.ts +0 -132
- package/src/agent-tooling/route-emit.ts +0 -305
- package/src/agent-tooling/types.ts +0 -390
- package/src/components/artifact-card.tsx +0 -120
- package/src/components/artifact.tsx +0 -914
- package/src/components/attachment-types.ts +0 -66
- package/src/components/attachments.tsx +0 -536
- package/src/components/audio-visualizer/audio-visualizer.voice-fixture.ts +0 -257
- package/src/components/audio-visualizer/aurora.glsl.ts +0 -330
- package/src/components/audio-visualizer/fit-scale.ts +0 -112
- package/src/components/audio-visualizer/index.tsx +0 -528
- package/src/components/audio-visualizer/labs/lab-choreography.ts +0 -187
- package/src/components/audio-visualizer/labs/lab-shaders.ts +0 -363
- package/src/components/audio-visualizer/labs/lab-visualizer.tsx +0 -102
- package/src/components/audio-visualizer/shader-canvas.tsx +0 -876
- package/src/components/audio-visualizer/sizes.ts +0 -54
- package/src/components/audio-visualizer/variant-aurora.tsx +0 -305
- package/src/components/audio-visualizer/variant-bar.tsx +0 -175
- package/src/components/audio-visualizer/variant-custom.tsx +0 -344
- package/src/components/audio-visualizer/variant-grid.tsx +0 -175
- package/src/components/audio-visualizer/variant-radial.tsx +0 -163
- package/src/components/audio-visualizer/variant-wave.tsx +0 -130
- package/src/components/audio-visualizer/wave.glsl.ts +0 -130
- package/src/components/card-fallback.tsx +0 -60
- package/src/components/card-renderer.tsx +0 -220
- package/src/components/card.tsx +0 -212
- package/src/components/chain-of-thought.tsx +0 -348
- package/src/components/chat-container.tsx +0 -89
- package/src/components/chat-scope-picker.tsx +0 -57
- package/src/components/chat-thread.tsx +0 -1014
- package/src/components/checkpoint.tsx +0 -88
- package/src/components/choice-card.tsx +0 -743
- package/src/components/coachmark.tsx +0 -249
- package/src/components/code-block.tsx +0 -181
- package/src/components/composer-dom.ts +0 -159
- package/src/components/composer-highlight.ts +0 -242
- package/src/components/composer-history.ts +0 -82
- package/src/components/composer.tsx +0 -1075
- package/src/components/confirm-card.tsx +0 -402
- package/src/components/context.tsx +0 -377
- package/src/components/conversation-item.tsx +0 -241
- package/src/components/conversation-list.tsx +0 -429
- package/src/components/conversation-panel.tsx +0 -118
- package/src/components/dismissed-stub.tsx +0 -80
- package/src/components/embed.tsx +0 -200
- package/src/components/empty.tsx +0 -177
- package/src/components/feedback-bar.tsx +0 -166
- package/src/components/file-tree.tsx +0 -530
- package/src/components/file-upload.tsx +0 -167
- package/src/components/form-widgets.tsx +0 -525
- package/src/components/form.tsx +0 -1296
- package/src/components/home-panel.tsx +0 -159
- package/src/components/image.tsx +0 -65
- package/src/components/link-preview.tsx +0 -195
- package/src/components/loader.tsx +0 -367
- package/src/components/markdown.tsx +0 -162
- package/src/components/message-skills.tsx +0 -40
- package/src/components/message.tsx +0 -765
- package/src/components/model-switcher.tsx +0 -132
- package/src/components/prompt-input.tsx +0 -188
- package/src/components/prompt-suggestion.tsx +0 -150
- package/src/components/reasoning.tsx +0 -293
- package/src/components/response-compare-types.ts +0 -152
- package/src/components/response-compare.tsx +0 -455
- package/src/components/response-stream.tsx +0 -109
- package/src/components/screen.tsx +0 -181
- package/src/components/scroll-button.tsx +0 -93
- package/src/components/source.tsx +0 -192
- package/src/components/tasks-card.tsx +0 -801
- package/src/components/text-shimmer.tsx +0 -37
- package/src/components/thinking-bar.tsx +0 -50
- package/src/components/thread.tsx +0 -228
- package/src/components/toast.tsx +0 -503
- package/src/components/tool-classify.ts +0 -26
- package/src/components/tool-types.ts +0 -49
- package/src/components/tool.tsx +0 -190
- package/src/components/use-card-resolution.ts +0 -44
- package/src/components/voice-input.tsx +0 -222
- package/src/components/voice-output.tsx +0 -242
- package/src/components/widget-tab-bar.tsx +0 -73
- package/src/components/workspace-shell.tsx +0 -285
- package/src/diagnostics/hook.ts +0 -352
- package/src/diagnostics/index.ts +0 -82
- package/src/diagnostics/report-request.ts +0 -296
- package/src/elements/agent-card.tsx +0 -67
- package/src/elements/artifact.tsx +0 -194
- package/src/elements/attachments.tsx +0 -140
- package/src/elements/audio-visualizer.tsx +0 -227
- package/src/elements/autoloader.ts +0 -89
- package/src/elements/avatar.tsx +0 -33
- package/src/elements/badge.tsx +0 -32
- package/src/elements/button.tsx +0 -149
- package/src/elements/card.tsx +0 -133
- package/src/elements/cards.tsx +0 -266
- package/src/elements/chain-of-thought.tsx +0 -141
- package/src/elements/chat-scope-picker.tsx +0 -65
- package/src/elements/chat-types.ts +0 -102
- package/src/elements/chat-workspace.tsx +0 -188
- package/src/elements/chat.tsx +0 -304
- package/src/elements/checkbox-group.tsx +0 -164
- package/src/elements/checkbox.tsx +0 -134
- package/src/elements/checkpoint.tsx +0 -47
- package/src/elements/choice.tsx +0 -100
- package/src/elements/coachmark.tsx +0 -90
- package/src/elements/code-block.tsx +0 -60
- package/src/elements/command.tsx +0 -197
- package/src/elements/compare.tsx +0 -111
- package/src/elements/compiled.css +0 -2
- package/src/elements/composer.tsx +0 -162
- package/src/elements/confirm-card.tsx +0 -76
- package/src/elements/context-meter.tsx +0 -107
- package/src/elements/conversation-item.tsx +0 -120
- package/src/elements/conversation-list.tsx +0 -203
- package/src/elements/css.ts +0 -5
- package/src/elements/default-input.tsx +0 -392
- package/src/elements/define-entry.ts +0 -12
- package/src/elements/define.tsx +0 -563
- package/src/elements/diagnostic-events.ts +0 -114
- package/src/elements/dialog.tsx +0 -145
- package/src/elements/disclosure.ts +0 -95
- package/src/elements/dock.tsx +0 -215
- package/src/elements/dropdown.tsx +0 -123
- package/src/elements/editable-label.tsx +0 -140
- package/src/elements/element-data-types.ts +0 -152
- package/src/elements/element-diagnostics.ts +0 -392
- package/src/elements/element-manifest.json +0 -354
- package/src/elements/element-nonscalar.json +0 -187
- package/src/elements/element-types.d.ts +0 -4353
- package/src/elements/embed.tsx +0 -35
- package/src/elements/empty.tsx +0 -29
- package/src/elements/feedback-bar.tsx +0 -66
- package/src/elements/file-tree.tsx +0 -62
- package/src/elements/file-upload.tsx +0 -44
- package/src/elements/form.tsx +0 -94
- package/src/elements/hover-card.tsx +0 -80
- package/src/elements/icon.tsx +0 -41
- package/src/elements/image.tsx +0 -32
- package/src/elements/input.tsx +0 -492
- package/src/elements/kbd.tsx +0 -45
- package/src/elements/link-preview.tsx +0 -34
- package/src/elements/loader.tsx +0 -25
- package/src/elements/markdown.tsx +0 -38
- package/src/elements/menu.tsx +0 -241
- package/src/elements/message-skills.tsx +0 -83
- package/src/elements/message.tsx +0 -361
- package/src/elements/model-switcher.tsx +0 -121
- package/src/elements/nav.tsx +0 -87
- package/src/elements/notice.tsx +0 -53
- package/src/elements/pane-grid.tsx +0 -111
- package/src/elements/pane-group.tsx +0 -119
- package/src/elements/pane.tsx +0 -129
- package/src/elements/popover.tsx +0 -81
- package/src/elements/progress-bar.tsx +0 -39
- package/src/elements/prompt-dock.tsx +0 -82
- package/src/elements/prompt-input.tsx +0 -240
- package/src/elements/prompt-suggestions.tsx +0 -113
- package/src/elements/radio-group.tsx +0 -129
- package/src/elements/reasoning.tsx +0 -71
- package/src/elements/register-impl.ts +0 -148
- package/src/elements/register.ts +0 -76
- package/src/elements/remote.tsx +0 -225
- package/src/elements/resizable.globals.d.ts +0 -36
- package/src/elements/resizable.tsx +0 -704
- package/src/elements/response-stream.tsx +0 -40
- package/src/elements/screen.tsx +0 -90
- package/src/elements/scroll-area.tsx +0 -33
- package/src/elements/scroll-button.tsx +0 -179
- package/src/elements/search.tsx +0 -185
- package/src/elements/segmented.tsx +0 -129
- package/src/elements/select.tsx +0 -165
- package/src/elements/separator.tsx +0 -36
- package/src/elements/setting-item.tsx +0 -50
- package/src/elements/settings-group.tsx +0 -37
- package/src/elements/skeleton.tsx +0 -45
- package/src/elements/slider.tsx +0 -171
- package/src/elements/slot-text.ts +0 -73
- package/src/elements/slots.ts +0 -787
- package/src/elements/source.tsx +0 -126
- package/src/elements/status.tsx +0 -42
- package/src/elements/styles.css +0 -328
- package/src/elements/switch.tsx +0 -118
- package/src/elements/tabs.tsx +0 -95
- package/src/elements/tasks.tsx +0 -103
- package/src/elements/text-shimmer.tsx +0 -28
- package/src/elements/thinking-bar.tsx +0 -43
- package/src/elements/thread.tsx +0 -139
- package/src/elements/toast.tsx +0 -106
- package/src/elements/tool.tsx +0 -78
- package/src/elements/tooltip.tsx +0 -85
- package/src/elements/validate-messages.ts +0 -76
- package/src/elements/voice-input.tsx +0 -100
- package/src/elements/voice-output.tsx +0 -82
- package/src/index.ts +0 -430
- package/src/primitives/audio-bands.ts +0 -174
- package/src/primitives/card-component-types.ts +0 -63
- package/src/primitives/card-contract.ts +0 -80
- package/src/primitives/card-data-types.ts +0 -361
- package/src/primitives/card-host.tsx +0 -37
- package/src/primitives/card-recovery.ts +0 -160
- package/src/primitives/card-registry.tsx +0 -78
- package/src/primitives/card-resolution.ts +0 -36
- package/src/primitives/card-routing.ts +0 -85
- package/src/primitives/card-schemas/artifact.schema.json +0 -92
- package/src/primitives/card-schemas/card-envelope.schema.json +0 -14
- package/src/primitives/card-schemas/card-event.schema.json +0 -12
- package/src/primitives/card-schemas/choice.schema.json +0 -75
- package/src/primitives/card-schemas/confirm.schema.json +0 -65
- package/src/primitives/card-schemas/embed.schema.json +0 -63
- package/src/primitives/card-schemas/form.result.schema.json +0 -7
- package/src/primitives/card-schemas/form.schema.json +0 -53
- package/src/primitives/card-schemas/link.schema.json +0 -54
- package/src/primitives/card-schemas/tasks.result.schema.json +0 -16
- package/src/primitives/card-schemas/tasks.schema.json +0 -83
- package/src/primitives/card-tags.ts +0 -61
- package/src/primitives/card-validate-cards.ts +0 -255
- package/src/primitives/card-validate-schemas.ts +0 -58
- package/src/primitives/card-validate.ts +0 -131
- package/src/primitives/chat-config.tsx +0 -103
- package/src/primitives/composer-model.ts +0 -49
- package/src/primitives/composer-triggers.ts +0 -35
- package/src/primitives/controllable.ts +0 -21
- package/src/primitives/conversation-store.ts +0 -248
- package/src/primitives/create-kai-chat.ts +0 -66
- package/src/primitives/create-tween.ts +0 -266
- package/src/primitives/embed-providers.ts +0 -254
- package/src/primitives/field-mask.ts +0 -256
- package/src/primitives/field-semantics.ts +0 -115
- package/src/primitives/highlighter.ts +0 -157
- package/src/primitives/input-mask.ts +0 -853
- package/src/primitives/link-preview.ts +0 -87
- package/src/primitives/message-feedback.ts +0 -124
- package/src/primitives/pdf-preview.ts +0 -121
- package/src/primitives/toast-store.ts +0 -338
- package/src/primitives/url-scheme-policy.ts +0 -70
- package/src/primitives/use-audio-analysis.ts +0 -340
- package/src/primitives/use-auto-resize.ts +0 -31
- package/src/primitives/use-resize-observer.ts +0 -45
- package/src/primitives/use-sequencer.ts +0 -72
- package/src/primitives/use-speech-recognition.ts +0 -146
- package/src/primitives/use-stick-to-bottom.ts +0 -75
- package/src/primitives/use-text-stream.ts +0 -143
- package/src/primitives/use-voice-recorder.ts +0 -62
- package/src/primitives/visualizer-sequences.ts +0 -350
- package/src/remote/host-embed.ts +0 -345
- package/src/remote/index.ts +0 -2
- package/src/remote/origin.ts +0 -30
- package/src/remote/provider-runtime.ts +0 -262
- package/src/remote/provider.ts +0 -2
- package/src/remote/validate.ts +0 -22
- package/src/remote/version.ts +0 -12
- package/src/remote/wire.ts +0 -48
- package/src/schemas/from-tool-call.ts +0 -151
- package/src/schemas/index.ts +0 -341
- package/src/schemas/provider-subsets.ts +0 -538
- package/src/schemas/registry.ts +0 -355
- package/src/schemas/tool-defs.ts +0 -793
- package/src/solid.ts +0 -173
- package/src/state/index.ts +0 -44
- package/src/state/messages.ts +0 -53
- package/src/state/mock.ts +0 -297
- package/src/state/parts.ts +0 -295
- package/src/state/persistence.ts +0 -180
- package/src/state/stream.ts +0 -246
- package/src/state/suggestions.ts +0 -9
- package/src/state/threads.ts +0 -142
- package/src/test-utils/fake-clock.ts +0 -88
- package/src/types.ts +0 -95
- package/src/ui/action-icons.ts +0 -53
- package/src/ui/agent-card.tsx +0 -218
- package/src/ui/avatar.tsx +0 -23
- package/src/ui/badge.tsx +0 -21
- package/src/ui/button.tsx +0 -49
- package/src/ui/card.tsx +0 -245
- package/src/ui/checkbox-group.tsx +0 -153
- package/src/ui/checkbox.tsx +0 -63
- package/src/ui/collapsible.tsx +0 -163
- package/src/ui/command.tsx +0 -103
- package/src/ui/dialog.tsx +0 -223
- package/src/ui/dock.tsx +0 -630
- package/src/ui/dropdown.tsx +0 -636
- package/src/ui/editable-label.tsx +0 -112
- package/src/ui/hover-card.tsx +0 -345
- package/src/ui/icon.tsx +0 -167
- package/src/ui/input.tsx +0 -391
- package/src/ui/kbd.tsx +0 -118
- package/src/ui/nav.tsx +0 -282
- package/src/ui/notice.tsx +0 -84
- package/src/ui/overlay.tsx +0 -277
- package/src/ui/pane-grid.tsx +0 -117
- package/src/ui/pane-group.tsx +0 -291
- package/src/ui/pane.tsx +0 -193
- package/src/ui/popover.tsx +0 -106
- package/src/ui/progress-bar.tsx +0 -83
- package/src/ui/prompt-dock.tsx +0 -145
- package/src/ui/radio.tsx +0 -150
- package/src/ui/resizable.tsx +0 -693
- package/src/ui/scroll-area.tsx +0 -26
- package/src/ui/segmented.tsx +0 -109
- package/src/ui/select.tsx +0 -168
- package/src/ui/separator.tsx +0 -10
- package/src/ui/settings-group.tsx +0 -67
- package/src/ui/skeleton.tsx +0 -73
- package/src/ui/slider.tsx +0 -178
- package/src/ui/status.tsx +0 -48
- package/src/ui/switch.tsx +0 -119
- package/src/ui/tabs.tsx +0 -168
- package/src/ui/textarea.tsx +0 -21
- package/src/ui/tooltip.tsx +0 -118
- package/src/utils/cn.ts +0 -30
- package/src/wire/chunk.ts +0 -248
- package/src/wire/consume.ts +0 -599
- package/src/wire/diagnostics.ts +0 -727
- package/src/wire/encode-probe.ts +0 -214
- package/src/wire/encode.ts +0 -947
- package/src/wire/files.ts +0 -342
- package/src/wire/formats/anthropic.ts +0 -274
- package/src/wire/formats/openai.ts +0 -228
- package/src/wire/index.ts +0 -95
- package/src/wire/media-types.ts +0 -344
- package/src/wire/read.ts +0 -396
- package/src/wire/sink-helpers.ts +0 -50
- package/src/wire/sse.ts +0 -153
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { Index, type JSX } from 'solid-js';
|
|
2
|
-
import { cn } from '../../utils/cn';
|
|
3
|
-
import { normalizeVolumeBands } from '../../primitives/audio-bands';
|
|
4
|
-
import { useSequencer } from '../../primitives/use-sequencer';
|
|
5
|
-
import { radialSequence, radialInterval } from '../../primitives/visualizer-sequences';
|
|
6
|
-
import { CONTAINER_HEIGHT, RADIAL_RADIUS, defaultRadialBarCount } from './sizes';
|
|
7
|
-
import { amplitudeRenderState, type VariantProps } from './variant-bar';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Bars arranged around a circle, growing outward with the audio.
|
|
11
|
-
*
|
|
12
|
-
* Ported from livekit/components-js
|
|
13
|
-
* `packages/shadcn/components/agents-ui/agent-audio-visualizer-radial.tsx`
|
|
14
|
-
* (Apache License 2.0).
|
|
15
|
-
*/
|
|
16
|
-
export function RadialVisualizer(
|
|
17
|
-
props: VariantProps & { barCount?: number; radius?: number },
|
|
18
|
-
): JSX.Element {
|
|
19
|
-
// Floored at 1: at barCount 0, dotSize below divides by zero (Infinity),
|
|
20
|
-
// and 0 % 4 === 0 slips past the divisibility warning silently. The
|
|
21
|
-
// dispatcher only ever passes positive counts today, but the element
|
|
22
|
-
// facade exposes `bar-count` as a consumer-facing attribute next.
|
|
23
|
-
const count = () => Math.max(1, props.barCount ?? defaultRadialBarCount(props.size));
|
|
24
|
-
const radius = () => props.radius ?? RADIAL_RADIUS[props.size];
|
|
25
|
-
|
|
26
|
-
// Upstream warns when the ring cannot split into four even quadrants -- not
|
|
27
|
-
// a hard requirement (any count still renders), just a symmetry hint. This
|
|
28
|
-
// is a plain statement, not inside a `createEffect`: a Solid component body
|
|
29
|
-
// runs once per mount (unlike React, there is no re-render to guard
|
|
30
|
-
// against), so it already fires exactly once for this instance and never
|
|
31
|
-
// again, including across unrelated reactive updates to other props.
|
|
32
|
-
if (count() % 4 !== 0) {
|
|
33
|
-
console.warn(
|
|
34
|
-
`<kai-audio-visualizer variant="radial">: barCount ${count()} is not divisible by 4. ` +
|
|
35
|
-
`The ring will look asymmetric.`,
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Chord length at this radius: keeps neighbouring dots from touching however
|
|
40
|
-
// many bars are on the ring.
|
|
41
|
-
const dotSize = () => (radius() * Math.PI) / count();
|
|
42
|
-
|
|
43
|
-
// The state the rendering follows: `listeningAmplitude` folds `listening`
|
|
44
|
-
// into the speaking presentation. See amplitudeRenderState in variant-bar.
|
|
45
|
-
const renderState = () => amplitudeRenderState(props.state, props.listeningAmplitude);
|
|
46
|
-
|
|
47
|
-
// Frozen (reduced motion) parks the sequence on frame 0 rather than stopping
|
|
48
|
-
// the component: the shape still reads, it just does not move.
|
|
49
|
-
const tick = useSequencer(() => (props.frozen ? Infinity : radialInterval(renderState())));
|
|
50
|
-
const sequence = () => radialSequence(renderState(), count());
|
|
51
|
-
|
|
52
|
-
// `thinking` parks the sequencer itself (radialInterval returns Infinity)
|
|
53
|
-
// and spins the whole ring in CSS instead, so every bar reads as lit rather
|
|
54
|
-
// than following the scripted highlight groups meant for `listening`
|
|
55
|
-
// (radialSequence's `thinking` case reuses those groups for a different
|
|
56
|
-
// purpose: they interleave the ring so it still looks even while rotating,
|
|
57
|
-
// not so a subset blinks).
|
|
58
|
-
const highlighted = () =>
|
|
59
|
-
renderState() === 'thinking'
|
|
60
|
-
? Array.from({ length: count() }, (_, i) => i)
|
|
61
|
-
: (sequence()[tick() % sequence().length] ?? []);
|
|
62
|
-
|
|
63
|
-
// Bands only mean anything while speaking (or listening under the
|
|
64
|
-
// `listeningAmplitude` opt-in, folded in by renderState). Everywhere else
|
|
65
|
-
// the sequence is the whole story, so a stale level never leaks into a
|
|
66
|
-
// scripted state (same guard as the other two variants, so the
|
|
67
|
-
// render-prop's `value` means one thing across every variant).
|
|
68
|
-
const levels = () =>
|
|
69
|
-
renderState() === 'speaking'
|
|
70
|
-
? normalizeVolumeBands(props.bands, count())
|
|
71
|
-
: new Array(count()).fill(0);
|
|
72
|
-
|
|
73
|
-
const spinning = () => renderState() === 'thinking' && !props.frozen;
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<div
|
|
77
|
-
data-kai-state={props.state}
|
|
78
|
-
class={cn('relative flex items-center justify-center', spinning() && 'animate-spin', props.class)}
|
|
79
|
-
style={{
|
|
80
|
-
height: `${CONTAINER_HEIGHT[props.size]}px`,
|
|
81
|
-
'aspect-ratio': '1',
|
|
82
|
-
...(spinning() ? { 'animation-duration': '5s' } : {}),
|
|
83
|
-
...(props.color ? { color: props.color } : {}),
|
|
84
|
-
}}
|
|
85
|
-
>
|
|
86
|
-
{/*
|
|
87
|
-
<Index>, not <For>, matching the other two variants: Solid's <For>
|
|
88
|
-
keys nodes by `===` on the array VALUE, and `levels()` is an array of
|
|
89
|
-
plain numbers that changes on nearly every frame while speaking. That
|
|
90
|
-
would tear down and recreate every spoke each frame instead of
|
|
91
|
-
patching it in place, defeating the height/colour transition below
|
|
92
|
-
right at the listening -> speaking boundary. <Index> maps by POSITION
|
|
93
|
-
instead, so each spoke's DOM node is created once and its `level`
|
|
94
|
-
accessor updates in place. See the note in variant-bar.tsx.
|
|
95
|
-
*/}
|
|
96
|
-
<Index each={levels()}>
|
|
97
|
-
{(level, i) => {
|
|
98
|
-
// `i` is a plain number here (stable per position under <Index>),
|
|
99
|
-
// not an accessor -- do not call it as `i()`. `highlighted`/`value`
|
|
100
|
-
// ARE live accessors: this callback runs once per position, so
|
|
101
|
-
// anything a consumer's render-prop wants to stay current must call
|
|
102
|
-
// these itself rather than close over a one-time snapshot.
|
|
103
|
-
const item = {
|
|
104
|
-
index: i,
|
|
105
|
-
highlighted: () => highlighted().includes(i),
|
|
106
|
-
value: () => level(),
|
|
107
|
-
};
|
|
108
|
-
return (
|
|
109
|
-
<div
|
|
110
|
-
data-kai-spoke
|
|
111
|
-
class="absolute top-1/2 left-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2"
|
|
112
|
-
style={{
|
|
113
|
-
'transform-origin': 'center',
|
|
114
|
-
transform: `rotate(${(i / count()) * Math.PI * 2}rad) translateY(${radius()}px)`,
|
|
115
|
-
}}
|
|
116
|
-
>
|
|
117
|
-
{/*
|
|
118
|
-
Unlike bar/grid, the render-prop's output does NOT become the
|
|
119
|
-
positioned element itself: it renders INSIDE this wrapper's
|
|
120
|
-
rotate+translateY placement, since something has to place the
|
|
121
|
-
spoke on the ring even when the caller owns its markup. See
|
|
122
|
-
the `children` doc on VariantProps in variant-bar.tsx.
|
|
123
|
-
*/}
|
|
124
|
-
{props.children?.(item) ?? (
|
|
125
|
-
// The lit state is a SECOND part TOKEN (`part(bar highlighted)`),
|
|
126
|
-
// not a `data-*` attribute selector on `::part(bar)`: a CSS
|
|
127
|
-
// attribute selector cannot follow a pseudo-element, so
|
|
128
|
-
// `::part(bar)[data-kai-highlighted="true"]` never matches
|
|
129
|
-
// anything from outside the shadow root. `data-kai-highlighted`
|
|
130
|
-
// stays on the element for the render-prop and for styling
|
|
131
|
-
// from inside the shadow root; `part` is the external seam.
|
|
132
|
-
<div
|
|
133
|
-
part={item.highlighted() ? 'bar highlighted' : 'bar'}
|
|
134
|
-
data-kai-index={item.index}
|
|
135
|
-
data-kai-highlighted={item.highlighted()}
|
|
136
|
-
class={cn(
|
|
137
|
-
'origin-bottom rounded-full bg-current/10',
|
|
138
|
-
'data-[kai-highlighted=true]:bg-current',
|
|
139
|
-
)}
|
|
140
|
-
style={{
|
|
141
|
-
width: `${dotSize()}px`,
|
|
142
|
-
'min-height': `${dotSize()}px`,
|
|
143
|
-
// x10 so a mid-level band reaches a readable length; upstream's factor.
|
|
144
|
-
height: `${dotSize() * 10 * level()}px`,
|
|
145
|
-
// Deliberate, approved divergence from upstream: see the
|
|
146
|
-
// matching comment in variant-bar.tsx. `150ms` for
|
|
147
|
-
// colour is unchanged from upstream's constant; only the
|
|
148
|
-
// new `100ms` height transition is our addition, and
|
|
149
|
-
// `frozen` disables both together rather than leaving
|
|
150
|
-
// colour still animating for a reduced-motion user.
|
|
151
|
-
transition: props.frozen
|
|
152
|
-
? 'none'
|
|
153
|
-
: 'height 100ms ease-linear, background-color 150ms ease-linear',
|
|
154
|
-
}}
|
|
155
|
-
/>
|
|
156
|
-
)}
|
|
157
|
-
</div>
|
|
158
|
-
);
|
|
159
|
-
}}
|
|
160
|
-
</Index>
|
|
161
|
-
</div>
|
|
162
|
-
);
|
|
163
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { createEffect, type JSX } from 'solid-js';
|
|
2
|
-
import { ShaderCanvas, hexToRgb, DEFAULT_SHADER_COLOR } from './shader-canvas';
|
|
3
|
-
import { createTween } from '../../primitives/create-tween';
|
|
4
|
-
import { waveTargets } from '../../primitives/visualizer-sequences';
|
|
5
|
-
import { CONTAINER_HEIGHT } from './sizes';
|
|
6
|
-
import { amplitudeRenderState } from './variant-bar';
|
|
7
|
-
import type { ShaderVariantProps } from './index';
|
|
8
|
-
import waveShader from './wave.glsl';
|
|
9
|
-
|
|
10
|
-
// Upstream defaults that aren't exposed as public props anywhere in this
|
|
11
|
-
// component's contract (`ShaderVariantProps` has no `blur`/`colorShift`
|
|
12
|
-
// field, and the dispatcher never forwards either) -- so they stay fixed
|
|
13
|
-
// rather than becoming half-wired knobs nothing can reach.
|
|
14
|
-
const BLUR = 0.5;
|
|
15
|
-
const COLOR_SHIFT = 0.05;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* A flowing oscilloscope line.
|
|
19
|
-
*
|
|
20
|
-
* Ported from livekit/components-js `agent-audio-visualizer-wave.tsx`
|
|
21
|
-
* (Apache License 2.0). The shader itself (`wave.glsl.ts`) is copied
|
|
22
|
-
* verbatim; this wrapper replaces upstream's React component and its
|
|
23
|
-
* `motion` dependency with Solid signals and `createTween`.
|
|
24
|
-
*/
|
|
25
|
-
export default function WaveVisualizer(props: ShaderVariantProps): JSX.Element {
|
|
26
|
-
const amplitude = createTween(0);
|
|
27
|
-
const frequency = createTween(0);
|
|
28
|
-
const opacity = createTween(1);
|
|
29
|
-
|
|
30
|
-
// The state the rendering follows: `listeningAmplitude` folds `listening`
|
|
31
|
-
// into the speaking presentation (live-volume amplitude/frequency). See
|
|
32
|
-
// amplitudeRenderState in variant-bar. `data-kai-state` keeps the real state.
|
|
33
|
-
const renderState = () => amplitudeRenderState(props.state, props.listeningAmplitude);
|
|
34
|
-
const targets = () => waveTargets(renderState());
|
|
35
|
-
|
|
36
|
-
// Reduced motion: land on the target immediately and skip every pulse.
|
|
37
|
-
const transition = () =>
|
|
38
|
-
props.frozen ? { duration: 0 } : { duration: 0.2, ease: 'easeOut' as const };
|
|
39
|
-
|
|
40
|
-
// Opacity alone: it only follows state/frozen, so a volume tick (nearly
|
|
41
|
-
// every animation frame while speaking) never restarts the pulse's tween.
|
|
42
|
-
createEffect(() => {
|
|
43
|
-
const t = targets();
|
|
44
|
-
// A pulse is an array target ([from, to], see createTween's ping-pong).
|
|
45
|
-
// Reduced motion collapses it to its first value so the line holds
|
|
46
|
-
// still instead of breathing.
|
|
47
|
-
const fade = Array.isArray(t.opacity) && props.frozen ? t.opacity[0] : t.opacity;
|
|
48
|
-
opacity.to(fade, props.frozen ? { duration: 0 } : { duration: t.pulseDuration || 0.2 });
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Amplitude and frequency share ONE effect -- a single writer -- on
|
|
52
|
-
// purpose. They used to be split like opacity above: a state effect
|
|
53
|
-
// tweening toward the base target over 0.2s, plus a separate effect
|
|
54
|
-
// applying the live-volume override instantly while speaking. Both re-run
|
|
55
|
-
// on a state flip, and Solid re-runs sibling effects in the order they sit
|
|
56
|
-
// in the signal's observer list, which REORDERS as effects re-subscribe
|
|
57
|
-
// over their lifetimes -- so whichever happened to run last won. Under a
|
|
58
|
-
// loaded main thread the base tween could land AFTER the override,
|
|
59
|
-
// parking a speaking line at the 0.025 baseline until the next volume
|
|
60
|
-
// change; with live audio that self-heals within one ~33ms tick, but
|
|
61
|
-
// static drive (a pinned `bands`/`volume` override, upstream's #1399 prop
|
|
62
|
-
// mode) never ticks again, so it stalled visibly (measured on the parity
|
|
63
|
-
// harness, 2/2 under load). This is NOT the benign two-effect shape the
|
|
64
|
-
// Task 12 review ruled acceptable elsewhere -- that ruling covered
|
|
65
|
-
// effects with DISJOINT writers; these two wrote the same tweens. One
|
|
66
|
-
// effect, one writer, ordering can no longer matter. Same effect-race
|
|
67
|
-
// class as b5795ac's shared() finding.
|
|
68
|
-
createEffect(() => {
|
|
69
|
-
if (renderState() === 'speaking') {
|
|
70
|
-
// Live volume drives amplitude and frequency instantly while
|
|
71
|
-
// speaking, so the line never lags the audio -- and lands at the
|
|
72
|
-
// override immediately on re-entry, matching upstream's same-commit
|
|
73
|
-
// effect ordering. `volume` is only tracked in this branch, so
|
|
74
|
-
// volume ticks do not re-run the state-target path below.
|
|
75
|
-
const v = props.volume;
|
|
76
|
-
amplitude.to(0.015 + 0.4 * v, { duration: 0 });
|
|
77
|
-
frequency.to(20 + 60 * v, { duration: 0 });
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const t = targets();
|
|
81
|
-
amplitude.to(t.amplitude, transition());
|
|
82
|
-
frequency.to(t.frequency, transition());
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const lineWidth = () => (props.size === 'icon' || props.size === 'sm' ? 2 : 1);
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<div
|
|
89
|
-
data-kai-state={props.state}
|
|
90
|
-
class={props.class}
|
|
91
|
-
style={{
|
|
92
|
-
height: `${CONTAINER_HEIGHT[props.size]}px`,
|
|
93
|
-
'aspect-ratio': '1',
|
|
94
|
-
'mask-image':
|
|
95
|
-
'linear-gradient(90deg, transparent 0%, black 20%, black 80%, transparent 100%)',
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
98
|
-
<ShaderCanvas
|
|
99
|
-
fragment={waveShader}
|
|
100
|
-
// Shaders are expensive on phones; mediump halves the cost with no
|
|
101
|
-
// visible difference on a line this thin.
|
|
102
|
-
precision={props.size === 'icon' || props.size === 'sm' ? 'mediump' : 'highp'}
|
|
103
|
-
uniforms={{
|
|
104
|
-
// uSpeed drives the shader's own time-based phase animation, not a
|
|
105
|
-
// tween -- so frozen (prefers-reduced-motion) must zero it directly
|
|
106
|
-
// rather than relying on any tween's instant-landing logic. uAmplitude
|
|
107
|
-
// and uFrequency stay as their frozen-collapsed values: they shape a
|
|
108
|
-
// static wave, they do not move it, so the result is a still picture
|
|
109
|
-
// of the wave rather than a flat line.
|
|
110
|
-
uSpeed: { type: '1f', value: props.frozen ? 0 : targets().speed },
|
|
111
|
-
uAmplitude: { type: '1f', value: amplitude.value() },
|
|
112
|
-
uFrequency: { type: '1f', value: frequency.value() },
|
|
113
|
-
uMix: { type: '1f', value: opacity.value() },
|
|
114
|
-
uLineWidth: { type: '1f', value: lineWidth() },
|
|
115
|
-
uSmoothing: { type: '1f', value: BLUR },
|
|
116
|
-
uColor: { type: '3fv', value: hexToRgb(props.color ?? DEFAULT_SHADER_COLOR) },
|
|
117
|
-
uColorShift: { type: '1f', value: COLOR_SHIFT },
|
|
118
|
-
}}
|
|
119
|
-
animateWhenNotVisible={props.animateWhenNotVisible}
|
|
120
|
-
onError={(message) => {
|
|
121
|
-
console.warn('<kai-audio-visualizer variant="wave">: shader error', message);
|
|
122
|
-
// A missing WebGL context and a compile/link failure both mean
|
|
123
|
-
// this shader cannot render at all -- no branching, both fall
|
|
124
|
-
// back to the dispatcher's bar visualizer.
|
|
125
|
-
props.onUnavailable();
|
|
126
|
-
}}
|
|
127
|
-
/>
|
|
128
|
-
</div>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Oscilloscope wave fragment shader.
|
|
3
|
-
*
|
|
4
|
-
* Copied verbatim from livekit/components-js
|
|
5
|
-
* `packages/shadcn/components/agents-ui/agent-audio-visualizer-wave.tsx`
|
|
6
|
-
* (Apache License 2.0). Unmodified apart from being extracted to its own
|
|
7
|
-
* module: no GLSL lines were added, removed, or reformatted. The source
|
|
8
|
-
* contained no `uniform ...;` declarations to strip -- `uFrequency`,
|
|
9
|
-
* `uSpeed`, `uAmplitude`, `uLineWidth`, `uSmoothing`, `uColor`,
|
|
10
|
-
* `uColorShift`, and `uMix` are all bound by the caller (see uses of
|
|
11
|
-
* `ShaderCanvas` below), which is what declares them.
|
|
12
|
-
*
|
|
13
|
-
* Uniforms are declared by ShaderCanvas. Do not declare them here.
|
|
14
|
-
*/
|
|
15
|
-
export default `
|
|
16
|
-
const float TAU = 6.28318530718;
|
|
17
|
-
|
|
18
|
-
// Noise for dithering
|
|
19
|
-
vec2 randFibo(vec2 p) {
|
|
20
|
-
p = fract(p * vec2(443.897, 441.423));
|
|
21
|
-
p += dot(p, p.yx + 19.19);
|
|
22
|
-
return fract((p.xx + p.yx) * p.xy);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Luma for alpha
|
|
26
|
-
float luma(vec3 color) {
|
|
27
|
-
return dot(color, vec3(0.299, 0.587, 0.114));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// RGB to HSV
|
|
31
|
-
vec3 rgb2hsv(vec3 c) {
|
|
32
|
-
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
|
33
|
-
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
|
34
|
-
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
|
35
|
-
float d = q.x - min(q.w, q.y);
|
|
36
|
-
float e = 1.0e-10;
|
|
37
|
-
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// HSV to RGB
|
|
41
|
-
vec3 hsv2rgb(vec3 c) {
|
|
42
|
-
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
43
|
-
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
44
|
-
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Bell curve function for attenuation from center with rounded top
|
|
48
|
-
float bellCurve(float distanceFromCenter, float maxDistance) {
|
|
49
|
-
float normalizedDistance = distanceFromCenter / maxDistance;
|
|
50
|
-
// Use cosine with high power for smooth rounded top
|
|
51
|
-
return pow(cos(normalizedDistance * (3.14159265359 / 4.0)), 16.0);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Calculate the sine wave
|
|
55
|
-
float oscilloscopeWave(float x, float centerX, float time) {
|
|
56
|
-
float relativeX = x - centerX;
|
|
57
|
-
float maxDistance = centerX;
|
|
58
|
-
float distanceFromCenter = abs(relativeX);
|
|
59
|
-
|
|
60
|
-
// Apply bell curve for amplitude attenuation
|
|
61
|
-
float bell = bellCurve(distanceFromCenter, maxDistance);
|
|
62
|
-
|
|
63
|
-
// Calculate wave with uniforms and bell curve attenuation
|
|
64
|
-
float wave = sin(relativeX * uFrequency + time * uSpeed) * uAmplitude * bell;
|
|
65
|
-
|
|
66
|
-
return wave;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
70
|
-
vec2 uv = fragCoord / iResolution.xy;
|
|
71
|
-
vec2 pos = uv - 0.5;
|
|
72
|
-
|
|
73
|
-
// Calculate center and positions
|
|
74
|
-
float centerX = 0.5;
|
|
75
|
-
float centerY = 0.5;
|
|
76
|
-
float x = uv.x;
|
|
77
|
-
float y = uv.y;
|
|
78
|
-
|
|
79
|
-
// Convert line width from pixels to UV space
|
|
80
|
-
// Use the average of width and height to handle aspect ratio
|
|
81
|
-
float pixelSize = 2.0 / (iResolution.x + iResolution.y);
|
|
82
|
-
float lineWidthUV = uLineWidth * pixelSize;
|
|
83
|
-
float smoothingUV = uSmoothing * pixelSize;
|
|
84
|
-
|
|
85
|
-
// Find minimum distance to the wave by sampling nearby points
|
|
86
|
-
// This gives us consistent line width without high-frequency artifacts
|
|
87
|
-
const int NUM_SAMPLES = 50; // Must be const for GLSL loop
|
|
88
|
-
float minDist = 1000.0;
|
|
89
|
-
float sampleRange = 0.02; // Range to search for closest point
|
|
90
|
-
|
|
91
|
-
for(int i = 0; i < NUM_SAMPLES; i++) {
|
|
92
|
-
float offset = (float(i) / float(NUM_SAMPLES - 1) - 0.5) * sampleRange;
|
|
93
|
-
float sampleX = x + offset;
|
|
94
|
-
float waveY = centerY + oscilloscopeWave(sampleX, centerX, iTime);
|
|
95
|
-
|
|
96
|
-
// Calculate distance from current pixel to this point on the wave
|
|
97
|
-
vec2 wavePoint = vec2(sampleX, waveY);
|
|
98
|
-
vec2 currentPoint = vec2(x, y);
|
|
99
|
-
float dist = distance(currentPoint, wavePoint);
|
|
100
|
-
|
|
101
|
-
minDist = min(minDist, dist);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Solid line with smooth edges using minimum distance
|
|
105
|
-
float line = smoothstep(lineWidthUV + smoothingUV, lineWidthUV - smoothingUV, minDist);
|
|
106
|
-
|
|
107
|
-
vec3 color = uColor;
|
|
108
|
-
if(abs(uColorShift) > 0.01) {
|
|
109
|
-
// Keep the center 50% at base color, then ramp shift across outer 25% on each side.
|
|
110
|
-
float centerBandHalfWidth = 0.2;
|
|
111
|
-
float edgeBandWidth = 0.5;
|
|
112
|
-
float distanceFromCenter = abs(x - centerX);
|
|
113
|
-
float edgeFactor = clamp((distanceFromCenter - centerBandHalfWidth) / edgeBandWidth, 0.0, 1.0);
|
|
114
|
-
vec3 hsv = rgb2hsv(color);
|
|
115
|
-
// Hue shift is zero in the center band and strongest at far edges.
|
|
116
|
-
hsv.x = fract(hsv.x + edgeFactor * uColorShift * 0.3);
|
|
117
|
-
color = hsv2rgb(hsv);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Apply line intensity
|
|
121
|
-
color *= line;
|
|
122
|
-
|
|
123
|
-
// Add dithering for smoother gradients
|
|
124
|
-
// color += (randFibo(fragCoord).x - 0.5) / 255.0;
|
|
125
|
-
|
|
126
|
-
// Calculate alpha based on line intensity
|
|
127
|
-
float alpha = line * uMix;
|
|
128
|
-
|
|
129
|
-
fragColor = vec4(color * uMix, alpha);
|
|
130
|
-
}`;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// src/components/card-fallback.tsx
|
|
2
|
-
// Rendered by the dispatcher when an envelope cannot be rendered: its `type` has no
|
|
3
|
-
// registered card, or its `data` failed HARD validation against the built-in schema
|
|
4
|
-
// for that type (see primitives/card-validate-cards.ts for what "hard" means).
|
|
5
|
-
// Visual: reuses the Card chrome so it sits naturally in a card stream.
|
|
6
|
-
import { Show, type JSX } from 'solid-js';
|
|
7
|
-
import { Card } from './card';
|
|
8
|
-
import { AlertTriangle } from 'lucide-solid';
|
|
9
|
-
|
|
10
|
-
export interface CardFallbackProps {
|
|
11
|
-
/** The envelope type, shown to aid debugging. */
|
|
12
|
-
type: string;
|
|
13
|
-
/** The envelope id (for parity with cards; not displayed). */
|
|
14
|
-
cardId?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Why this card could not render, when the type WAS known but the data was not
|
|
17
|
-
* usable. Carries the failing field paths verbatim, e.g.
|
|
18
|
-
* `(root).actions: fewer than minItems 1`.
|
|
19
|
-
*
|
|
20
|
-
* Absent means the older case: an unrecognized type. The two are told apart by
|
|
21
|
-
* this prop rather than by a mode flag so a caller cannot ask for the diagnostic
|
|
22
|
-
* and forget to supply the diagnosis.
|
|
23
|
-
*/
|
|
24
|
-
reason?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Inert, themed fallback for a card that cannot render. Emits nothing itself:
|
|
28
|
-
* the dispatcher emits the contract `error` event alongside rendering this. */
|
|
29
|
-
export function CardFallback(props: CardFallbackProps): JSX.Element {
|
|
30
|
-
return (
|
|
31
|
-
<Card>
|
|
32
|
-
<Show
|
|
33
|
-
when={props.reason}
|
|
34
|
-
fallback={
|
|
35
|
-
<div data-card-fallback role="alert" class="flex items-center gap-2 p-4 text-sm text-muted-foreground">
|
|
36
|
-
<AlertTriangle class="size-4 shrink-0 text-destructive dark:text-red-400" aria-hidden="true" />
|
|
37
|
-
<span>
|
|
38
|
-
Unsupported card type: <code class="font-mono">{props.type}</code>
|
|
39
|
-
</span>
|
|
40
|
-
</div>
|
|
41
|
-
}
|
|
42
|
-
>
|
|
43
|
-
{(reason) => (
|
|
44
|
-
<div
|
|
45
|
-
data-card-fallback
|
|
46
|
-
data-card-invalid
|
|
47
|
-
role="alert"
|
|
48
|
-
class="flex items-start gap-2 p-4 text-sm text-muted-foreground"
|
|
49
|
-
>
|
|
50
|
-
<AlertTriangle class="size-4 shrink-0 translate-y-0.5 text-destructive dark:text-red-400" aria-hidden="true" />
|
|
51
|
-
<span class="min-w-0">
|
|
52
|
-
Invalid <code class="font-mono">{props.type}</code> card:{' '}
|
|
53
|
-
<code data-card-invalid-reason class="font-mono break-words">{reason()}</code>
|
|
54
|
-
</span>
|
|
55
|
-
</div>
|
|
56
|
-
)}
|
|
57
|
-
</Show>
|
|
58
|
-
</Card>
|
|
59
|
-
);
|
|
60
|
-
}
|