@slices.sh/ai-chat 0.1.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/LICENSE +21 -0
- package/dist/exports.json +794 -0
- package/dist/fixture/fixture-approval.d.ts +4 -0
- package/dist/fixture/fixture-approval.js +59 -0
- package/dist/fixture/fixture-artifacts.d.ts +2 -0
- package/dist/fixture/fixture-artifacts.js +48 -0
- package/dist/fixture/fixture-question.d.ts +5 -0
- package/dist/fixture/fixture-question.js +93 -0
- package/dist/fixture/fixture-script.d.ts +35 -0
- package/dist/fixture/fixture-script.js +280 -0
- package/dist/fixture/fixture-selection.d.ts +5 -0
- package/dist/fixture/fixture-selection.js +20 -0
- package/dist/fixture/fixture.d.ts +20 -0
- package/dist/fixture/fixture.js +75 -0
- package/dist/fixture/provider.d.ts +15 -0
- package/dist/fixture/provider.js +14 -0
- package/dist/headless/always-allow.d.ts +2 -0
- package/dist/headless/always-allow.js +24 -0
- package/dist/headless/answer.d.ts +6 -0
- package/dist/headless/answer.js +29 -0
- package/dist/headless/approval-error.d.ts +2 -0
- package/dist/headless/approval-error.js +16 -0
- package/dist/headless/approval-reason.d.ts +2 -0
- package/dist/headless/approval-reason.js +13 -0
- package/dist/headless/approval-receipt.d.ts +4 -0
- package/dist/headless/approval-receipt.js +13 -0
- package/dist/headless/approve.d.ts +4 -0
- package/dist/headless/approve.js +15 -0
- package/dist/headless/branch-navigation.d.ts +2 -0
- package/dist/headless/branch-navigation.js +11 -0
- package/dist/headless/branch-next.d.ts +2 -0
- package/dist/headless/branch-next.js +21 -0
- package/dist/headless/branch-page.d.ts +5 -0
- package/dist/headless/branch-page.js +13 -0
- package/dist/headless/branch-previous.d.ts +2 -0
- package/dist/headless/branch-previous.js +21 -0
- package/dist/headless/cancel-edit.d.ts +2 -0
- package/dist/headless/cancel-edit.js +10 -0
- package/dist/headless/cancel-queue-edit.d.ts +2 -0
- package/dist/headless/cancel-queue-edit.js +15 -0
- package/dist/headless/cancel-queued.d.ts +2 -0
- package/dist/headless/cancel-queued.js +15 -0
- package/dist/headless/chat-dictation/confirm.d.ts +2 -0
- package/dist/headless/chat-dictation/confirm.js +14 -0
- package/dist/headless/chat-dictation/index.d.ts +12 -0
- package/dist/headless/chat-dictation/index.js +9 -0
- package/dist/headless/chat-dictation/input.d.ts +3 -0
- package/dist/headless/chat-dictation/input.js +42 -0
- package/dist/headless/chat-dictation/root.d.ts +3 -0
- package/dist/headless/chat-dictation/root.js +42 -0
- package/dist/headless/chat-dictation/text.d.ts +3 -0
- package/dist/headless/chat-dictation/text.js +14 -0
- package/dist/headless/chat-dictation/voice.d.ts +3 -0
- package/dist/headless/chat-dictation/voice.js +35 -0
- package/dist/headless/citation-content.d.ts +3 -0
- package/dist/headless/citation-content.js +19 -0
- package/dist/headless/citation-description.d.ts +2 -0
- package/dist/headless/citation-description.js +12 -0
- package/dist/headless/citation-root.d.ts +2 -0
- package/dist/headless/citation-root.js +13 -0
- package/dist/headless/citation-title.d.ts +2 -0
- package/dist/headless/citation-title.js +12 -0
- package/dist/headless/citation-trigger.d.ts +2 -0
- package/dist/headless/citation-trigger.js +12 -0
- package/dist/headless/clear-answer.d.ts +5 -0
- package/dist/headless/clear-answer.js +19 -0
- package/dist/headless/composer-root.d.ts +14 -0
- package/dist/headless/composer-root.js +12 -0
- package/dist/headless/composer-standalone.d.ts +3 -0
- package/dist/headless/composer-standalone.js +10 -0
- package/dist/headless/composer.d.ts +3 -0
- package/dist/headless/composer.js +24 -0
- package/dist/headless/context-usage.d.ts +3 -0
- package/dist/headless/context-usage.js +13 -0
- package/dist/headless/contexts.d.ts +77 -0
- package/dist/headless/contexts.js +53 -0
- package/dist/headless/continue.d.ts +4 -0
- package/dist/headless/continue.js +26 -0
- package/dist/headless/copy.d.ts +11 -0
- package/dist/headless/copy.js +21 -0
- package/dist/headless/deny.d.ts +4 -0
- package/dist/headless/deny.js +15 -0
- package/dist/headless/edit-queued.d.ts +2 -0
- package/dist/headless/edit-queued.js +15 -0
- package/dist/headless/edit.d.ts +2 -0
- package/dist/headless/edit.js +17 -0
- package/dist/headless/edited-attachments.d.ts +5 -0
- package/dist/headless/edited-attachments.js +11 -0
- package/dist/headless/edited-input.d.ts +2 -0
- package/dist/headless/edited-input.js +28 -0
- package/dist/headless/empty.d.ts +3 -0
- package/dist/headless/empty.js +12 -0
- package/dist/headless/failed.d.ts +15 -0
- package/dist/headless/failed.js +17 -0
- package/dist/headless/feedback-error.d.ts +2 -0
- package/dist/headless/feedback-error.js +11 -0
- package/dist/headless/feedback-root.d.ts +2 -0
- package/dist/headless/feedback-root.js +24 -0
- package/dist/headless/feedback.d.ts +4 -0
- package/dist/headless/feedback.js +18 -0
- package/dist/headless/file-audio.d.ts +2 -0
- package/dist/headless/file-audio.js +16 -0
- package/dist/headless/file-context.d.ts +4 -0
- package/dist/headless/file-context.js +7 -0
- package/dist/headless/file-img.d.ts +2 -0
- package/dist/headless/file-img.js +21 -0
- package/dist/headless/file-kind-gate.d.ts +5 -0
- package/dist/headless/file-kind-gate.js +11 -0
- package/dist/headless/file-link.d.ts +3 -0
- package/dist/headless/file-link.js +14 -0
- package/dist/headless/file-root.d.ts +5 -0
- package/dist/headless/file-root.js +13 -0
- package/dist/headless/file-unavailable.d.ts +2 -0
- package/dist/headless/file-unavailable.js +12 -0
- package/dist/headless/file-video.d.ts +2 -0
- package/dist/headless/file-video.js +16 -0
- package/dist/headless/follow-ups.d.ts +5 -0
- package/dist/headless/follow-ups.js +20 -0
- package/dist/headless/forget-approval.d.ts +2 -0
- package/dist/headless/forget-approval.js +21 -0
- package/dist/headless/gate-content.d.ts +2 -0
- package/dist/headless/gate-content.js +6 -0
- package/dist/headless/index.d.ts +249 -0
- package/dist/headless/index.js +251 -0
- package/dist/headless/input.d.ts +11 -0
- package/dist/headless/input.js +18 -0
- package/dist/headless/jump-to-latest.d.ts +3 -0
- package/dist/headless/jump-to-latest.js +14 -0
- package/dist/headless/message-edit-root.d.ts +2 -0
- package/dist/headless/message-edit-root.js +13 -0
- package/dist/headless/message-editing.d.ts +2 -0
- package/dist/headless/message-editing.js +10 -0
- package/dist/headless/message-editor.d.ts +2 -0
- package/dist/headless/message-editor.js +19 -0
- package/dist/headless/message-footer.d.ts +3 -0
- package/dist/headless/message-footer.js +15 -0
- package/dist/headless/message-reading.d.ts +2 -0
- package/dist/headless/message-reading.js +10 -0
- package/dist/headless/message.d.ts +11 -0
- package/dist/headless/message.js +34 -0
- package/dist/headless/messages.d.ts +9 -0
- package/dist/headless/messages.js +19 -0
- package/dist/headless/model-picker.d.ts +2 -0
- package/dist/headless/model-picker.js +14 -0
- package/dist/headless/model.d.ts +4 -0
- package/dist/headless/model.js +13 -0
- package/dist/headless/models.d.ts +5 -0
- package/dist/headless/models.js +11 -0
- package/dist/headless/optional-tools.d.ts +7 -0
- package/dist/headless/optional-tools.js +12 -0
- package/dist/headless/other-answer.d.ts +5 -0
- package/dist/headless/other-answer.js +32 -0
- package/dist/headless/part-approval.d.ts +2 -0
- package/dist/headless/part-approval.js +33 -0
- package/dist/headless/part-file.d.ts +6 -0
- package/dist/headless/part-file.js +11 -0
- package/dist/headless/part-question.d.ts +2 -0
- package/dist/headless/part-question.js +57 -0
- package/dist/headless/part-reasoning.d.ts +15 -0
- package/dist/headless/part-reasoning.js +26 -0
- package/dist/headless/part-source.d.ts +5 -0
- package/dist/headless/part-source.js +20 -0
- package/dist/headless/part-text.d.ts +16 -0
- package/dist/headless/part-text.js +29 -0
- package/dist/headless/part-tool.d.ts +16 -0
- package/dist/headless/part-tool.js +14 -0
- package/dist/headless/parts.d.ts +11 -0
- package/dist/headless/parts.js +11 -0
- package/dist/headless/question-back.d.ts +2 -0
- package/dist/headless/question-back.js +16 -0
- package/dist/headless/question-error.d.ts +2 -0
- package/dist/headless/question-error.js +14 -0
- package/dist/headless/question-invalid.d.ts +8 -0
- package/dist/headless/question-invalid.js +18 -0
- package/dist/headless/question-item.d.ts +8 -0
- package/dist/headless/question-item.js +51 -0
- package/dist/headless/question-next.d.ts +3 -0
- package/dist/headless/question-next.js +16 -0
- package/dist/headless/question-other.d.ts +5 -0
- package/dist/headless/question-other.js +22 -0
- package/dist/headless/question-progress.d.ts +8 -0
- package/dist/headless/question-progress.js +14 -0
- package/dist/headless/question-receipt.d.ts +11 -0
- package/dist/headless/question-receipt.js +29 -0
- package/dist/headless/questions.d.ts +3 -0
- package/dist/headless/questions.js +13 -0
- package/dist/headless/queue-editing.d.ts +4 -0
- package/dist/headless/queue-editing.js +11 -0
- package/dist/headless/queue-item.d.ts +2 -0
- package/dist/headless/queue-item.js +10 -0
- package/dist/headless/queue-items.d.ts +2 -0
- package/dist/headless/queue-items.js +11 -0
- package/dist/headless/queue-preview.d.ts +6 -0
- package/dist/headless/queue-preview.js +11 -0
- package/dist/headless/queued-input.d.ts +2 -0
- package/dist/headless/queued-input.js +27 -0
- package/dist/headless/queued.d.ts +17 -0
- package/dist/headless/queued.js +16 -0
- package/dist/headless/read-aloud.d.ts +5 -0
- package/dist/headless/read-aloud.js +19 -0
- package/dist/headless/reasoning-disclosure.d.ts +3 -0
- package/dist/headless/reasoning-disclosure.js +17 -0
- package/dist/headless/reasoning-timer.d.ts +5 -0
- package/dist/headless/reasoning-timer.js +13 -0
- package/dist/headless/references.d.ts +6 -0
- package/dist/headless/references.js +13 -0
- package/dist/headless/regenerate.d.ts +3 -0
- package/dist/headless/regenerate.js +22 -0
- package/dist/headless/remembered-approval.d.ts +2 -0
- package/dist/headless/remembered-approval.js +14 -0
- package/dist/headless/root.d.ts +30 -0
- package/dist/headless/root.js +99 -0
- package/dist/headless/save-edit.d.ts +2 -0
- package/dist/headless/save-edit.js +16 -0
- package/dist/headless/save-queued.d.ts +2 -0
- package/dist/headless/save-queued.js +15 -0
- package/dist/headless/send-now.d.ts +2 -0
- package/dist/headless/send-now.js +17 -0
- package/dist/headless/settings.d.ts +2 -0
- package/dist/headless/settings.js +10 -0
- package/dist/headless/skip-questions.d.ts +6 -0
- package/dist/headless/skip-questions.js +18 -0
- package/dist/headless/source-context.d.ts +5 -0
- package/dist/headless/source-context.js +9 -0
- package/dist/headless/source-link.d.ts +2 -0
- package/dist/headless/source-link.js +13 -0
- package/dist/headless/source-primitives.d.ts +1 -0
- package/dist/headless/source-primitives.js +7 -0
- package/dist/headless/source-root.d.ts +5 -0
- package/dist/headless/source-root.js +9 -0
- package/dist/headless/source-sheet-close.d.ts +2 -0
- package/dist/headless/source-sheet-close.js +12 -0
- package/dist/headless/source-sheet-content.d.ts +3 -0
- package/dist/headless/source-sheet-content.js +16 -0
- package/dist/headless/source-sheet-description.d.ts +2 -0
- package/dist/headless/source-sheet-description.js +12 -0
- package/dist/headless/source-sheet-root.d.ts +2 -0
- package/dist/headless/source-sheet-root.js +13 -0
- package/dist/headless/source-sheet-title.d.ts +2 -0
- package/dist/headless/source-sheet-title.js +12 -0
- package/dist/headless/source-sheet-trigger.d.ts +2 -0
- package/dist/headless/source-sheet-trigger.js +12 -0
- package/dist/headless/source-unavailable.d.ts +2 -0
- package/dist/headless/source-unavailable.js +9 -0
- package/dist/headless/sources.d.ts +14 -0
- package/dist/headless/sources.js +12 -0
- package/dist/headless/speaker.d.ts +13 -0
- package/dist/headless/speaker.js +10 -0
- package/dist/headless/step-boundary.d.ts +4 -0
- package/dist/headless/step-boundary.js +16 -0
- package/dist/headless/stop.d.ts +10 -0
- package/dist/headless/stop.js +18 -0
- package/dist/headless/stopped.d.ts +11 -0
- package/dist/headless/stopped.js +17 -0
- package/dist/headless/submit-answers.d.ts +3 -0
- package/dist/headless/submit-answers.js +12 -0
- package/dist/headless/submit.d.ts +23 -0
- package/dist/headless/submit.js +24 -0
- package/dist/headless/suggestion.d.ts +10 -0
- package/dist/headless/suggestion.js +14 -0
- package/dist/headless/suggestions.d.ts +8 -0
- package/dist/headless/suggestions.js +12 -0
- package/dist/headless/thread.d.ts +3 -0
- package/dist/headless/thread.js +25 -0
- package/dist/headless/timing.d.ts +5 -0
- package/dist/headless/timing.js +13 -0
- package/dist/headless/toggle-tool.d.ts +4 -0
- package/dist/headless/toggle-tool.js +15 -0
- package/dist/headless/tool-error.d.ts +4 -0
- package/dist/headless/tool-error.js +13 -0
- package/dist/headless/tool-input.d.ts +4 -0
- package/dist/headless/tool-input.js +13 -0
- package/dist/headless/tool-output.d.ts +4 -0
- package/dist/headless/tool-output.js +13 -0
- package/dist/headless/tool-renderer.d.ts +13 -0
- package/dist/headless/tool-renderer.js +15 -0
- package/dist/headless/transcript.d.ts +23 -0
- package/dist/headless/transcript.js +24 -0
- package/dist/headless/try-again.d.ts +2 -0
- package/dist/headless/try-again.js +24 -0
- package/dist/headless/unavailable.d.ts +8 -0
- package/dist/headless/unavailable.js +9 -0
- package/dist/headless/usage.d.ts +13 -0
- package/dist/headless/usage.js +15 -0
- package/dist/headless/use-merged-ref.d.ts +2 -0
- package/dist/headless/use-merged-ref.js +17 -0
- package/dist/headless/use-question.d.ts +3 -0
- package/dist/headless/use-question.js +9 -0
- package/dist/headless/waiting.d.ts +13 -0
- package/dist/headless/waiting.js +12 -0
- package/dist/headless/writing.d.ts +13 -0
- package/dist/headless/writing.js +12 -0
- package/dist/hooks/chat-refusal.d.ts +18 -0
- package/dist/hooks/chat-refusal.js +44 -0
- package/dist/hooks/turn-mailbox.d.ts +14 -0
- package/dist/hooks/turn-mailbox.js +114 -0
- package/dist/hooks/use-branches.d.ts +10 -0
- package/dist/hooks/use-branches.js +69 -0
- package/dist/hooks/use-chat-instance.d.ts +28 -0
- package/dist/hooks/use-chat-instance.js +44 -0
- package/dist/hooks/use-chat-settings.d.ts +11 -0
- package/dist/hooks/use-chat-settings.js +33 -0
- package/dist/hooks/use-chat-sink.d.ts +19 -0
- package/dist/hooks/use-chat-sink.js +56 -0
- package/dist/hooks/use-composer.d.ts +33 -0
- package/dist/hooks/use-composer.js +45 -0
- package/dist/hooks/use-context-usage.d.ts +8 -0
- package/dist/hooks/use-context-usage.js +14 -0
- package/dist/hooks/use-copied.d.ts +14 -0
- package/dist/hooks/use-copied.js +22 -0
- package/dist/hooks/use-draft.d.ts +6 -0
- package/dist/hooks/use-draft.js +38 -0
- package/dist/hooks/use-feedback.d.ts +8 -0
- package/dist/hooks/use-feedback.js +28 -0
- package/dist/hooks/use-follow.d.ts +15 -0
- package/dist/hooks/use-follow.js +30 -0
- package/dist/hooks/use-media-load.d.ts +5 -0
- package/dist/hooks/use-media-load.js +12 -0
- package/dist/hooks/use-media.d.ts +3 -0
- package/dist/hooks/use-media.js +9 -0
- package/dist/hooks/use-question-check.d.ts +11 -0
- package/dist/hooks/use-question-check.js +29 -0
- package/dist/hooks/use-question-draft.d.ts +34 -0
- package/dist/hooks/use-question-draft.js +57 -0
- package/dist/hooks/use-question-steps.d.ts +18 -0
- package/dist/hooks/use-question-steps.js +31 -0
- package/dist/hooks/use-question-write.d.ts +8 -0
- package/dist/hooks/use-question-write.js +25 -0
- package/dist/hooks/use-read-aloud.d.ts +8 -0
- package/dist/hooks/use-read-aloud.js +60 -0
- package/dist/hooks/use-reasoning.d.ts +8 -0
- package/dist/hooks/use-reasoning.js +32 -0
- package/dist/hooks/use-remembered-approvals.d.ts +9 -0
- package/dist/hooks/use-remembered-approvals.js +40 -0
- package/dist/hooks/use-reply.d.ts +3 -0
- package/dist/hooks/use-reply.js +9 -0
- package/dist/hooks/use-report-missing-configuration.d.ts +9 -0
- package/dist/hooks/use-report-missing-configuration.js +14 -0
- package/dist/hooks/use-retry-delay.d.ts +5 -0
- package/dist/hooks/use-retry-delay.js +17 -0
- package/dist/hooks/use-sent-draft.d.ts +8 -0
- package/dist/hooks/use-sent-draft.js +25 -0
- package/dist/hooks/use-source-disclosure.d.ts +5 -0
- package/dist/hooks/use-source-disclosure.js +9 -0
- package/dist/hooks/use-sources.d.ts +3 -0
- package/dist/hooks/use-sources.js +9 -0
- package/dist/hooks/use-tool-approval-memory.d.ts +8 -0
- package/dist/hooks/use-tool-approval-memory.js +16 -0
- package/dist/hooks/use-tool-approval.d.ts +10 -0
- package/dist/hooks/use-tool-approval.js +26 -0
- package/dist/hooks/use-turn-queue.d.ts +32 -0
- package/dist/hooks/use-turn-queue.js +33 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/next.d.ts +43 -0
- package/dist/next.js +10 -0
- package/dist/services/approval-memory.d.ts +9 -0
- package/dist/services/approval-memory.js +32 -0
- package/dist/services/approval.d.ts +14 -0
- package/dist/services/approval.js +37 -0
- package/dist/services/branches.d.ts +27 -0
- package/dist/services/branches.js +131 -0
- package/dist/services/chat-session.d.ts +20 -0
- package/dist/services/chat-session.js +61 -0
- package/dist/services/choices.d.ts +31 -0
- package/dist/services/choices.js +39 -0
- package/dist/services/continue.d.ts +8 -0
- package/dist/services/continue.js +24 -0
- package/dist/services/errors.d.ts +52 -0
- package/dist/services/errors.js +54 -0
- package/dist/services/media.d.ts +9 -0
- package/dist/services/media.js +19 -0
- package/dist/services/messages.d.ts +44 -0
- package/dist/services/messages.js +0 -0
- package/dist/services/optional.d.ts +7 -0
- package/dist/services/optional.js +7 -0
- package/dist/services/ports.d.ts +31 -0
- package/dist/services/ports.js +0 -0
- package/dist/services/questions.d.ts +67 -0
- package/dist/services/questions.js +119 -0
- package/dist/services/request.d.ts +26 -0
- package/dist/services/request.js +85 -0
- package/dist/services/selection.d.ts +10 -0
- package/dist/services/selection.js +49 -0
- package/dist/services/sources.d.ts +11 -0
- package/dist/services/sources.js +29 -0
- package/dist/services/tools.d.ts +11 -0
- package/dist/services/tools.js +0 -0
- package/dist/services/turn.d.ts +84 -0
- package/dist/services/turn.js +0 -0
- package/dist/services/types.d.ts +23 -0
- package/dist/services/types.js +15 -0
- package/package.json +822 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { definePlainProvider } from "@slices.sh/core";
|
|
2
|
+
import { createAiChatFixture } from "./fixture.js";
|
|
3
|
+
function fixture(options = {}) {
|
|
4
|
+
const { scenario = "ready" } = options;
|
|
5
|
+
return definePlainProvider({
|
|
6
|
+
provider: "fixture",
|
|
7
|
+
package: "@slices.sh/ai-chat/fixture",
|
|
8
|
+
capabilities: { reasoning: true, tools: true, toolApproval: true, toolChoices: true, models: true, sources: true, usage: true },
|
|
9
|
+
client: () => createAiChatFixture(scenario).client
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
fixture
|
|
14
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getToolName, isToolUIPart } from "ai";
|
|
3
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
4
|
+
import { ApprovalContext, ApprovalMemoryContext, PartScope } from "./contexts.js";
|
|
5
|
+
function AlwaysAllow(props) {
|
|
6
|
+
const write = useRequired(ApprovalContext, "Chat.AlwaysAllow requires Chat.PartApproval.");
|
|
7
|
+
const memory = useRequired(ApprovalMemoryContext, "Chat.AlwaysAllow requires Chat.Root.");
|
|
8
|
+
const part = useRequired(PartScope, "Chat.AlwaysAllow requires Chat.Parts.");
|
|
9
|
+
const element = usePart("button", props, {
|
|
10
|
+
defaults: { type: "button" },
|
|
11
|
+
locked: { disabled: write.pending },
|
|
12
|
+
behavior: {
|
|
13
|
+
onClick: () => {
|
|
14
|
+
if (!memory.enabled || !isToolUIPart(part)) return;
|
|
15
|
+
memory.remember(getToolName(part));
|
|
16
|
+
void write.run({ approved: true });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return memory.enabled ? element : null;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
AlwaysAllow
|
|
24
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PartProps } from "@slices.sh/core/part";
|
|
2
|
+
/** One choice: a radio in a single question and a checkbox in a multiple one, so the kind is plain before anything is touched. */
|
|
3
|
+
export declare function Answer({ name, value, ...props }: PartProps<"input"> & {
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}): import("react").ReactNode;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
3
|
+
import { QuestionCheckContext, QuestionDraftContext, QuestionWriteContext } from "./contexts.js";
|
|
4
|
+
import { useQuestion } from "./use-question.js";
|
|
5
|
+
function Answer({ name, value, ...props }) {
|
|
6
|
+
const question = useQuestion(name, "Answer");
|
|
7
|
+
const draft = useRequired(QuestionDraftContext, "Chat.Answer requires Chat.PartQuestion.");
|
|
8
|
+
const check = useRequired(QuestionCheckContext, "Chat.Answer requires Chat.PartQuestion.");
|
|
9
|
+
const write = useRequired(QuestionWriteContext, "Chat.Answer requires Chat.PartQuestion.");
|
|
10
|
+
const multiple = Boolean(question?.multiple);
|
|
11
|
+
const position = question?.choices.findIndex((choice) => choice.value === value) ?? -1;
|
|
12
|
+
return usePart("input", props, {
|
|
13
|
+
behavior: { onChange: () => draft.change(name, { type: "choose", value }) },
|
|
14
|
+
locked: {
|
|
15
|
+
type: multiple ? "checkbox" : "radio",
|
|
16
|
+
name,
|
|
17
|
+
value,
|
|
18
|
+
checked: draft.picked(name, value),
|
|
19
|
+
disabled: write.pending,
|
|
20
|
+
// The number a key press picks it by; the question's own fieldset listens for it.
|
|
21
|
+
"aria-keyshortcuts": position >= 0 ? String(position + 1) : void 0,
|
|
22
|
+
// A radiogroup carries the invalid state itself, so only checkboxes do.
|
|
23
|
+
"aria-invalid": multiple && check.shown(name) ? true : void 0
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
Answer
|
|
29
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { isToolUIPart } from "ai";
|
|
4
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
5
|
+
import { ApprovalContext, ApprovalAutomationContext, PartScope } from "./contexts.js";
|
|
6
|
+
function ApprovalError(props) {
|
|
7
|
+
const { error } = useRequired(ApprovalContext, "Chat.ApprovalError requires Chat.PartApproval.");
|
|
8
|
+
const automatic = useContext(ApprovalAutomationContext)?.failure;
|
|
9
|
+
const part = useRequired(PartScope, "Chat.ApprovalError requires Chat.Parts.");
|
|
10
|
+
const failed = error || isToolUIPart(part) && part.approval?.id === automatic?.id && automatic;
|
|
11
|
+
const element = usePart("p", props, { defaults: { role: "alert" } });
|
|
12
|
+
return failed ? element : null;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
ApprovalError
|
|
16
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isToolUIPart } from "ai";
|
|
3
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
4
|
+
import { PartScope } from "./contexts.js";
|
|
5
|
+
function ApprovalReason(props) {
|
|
6
|
+
const part = useRequired(PartScope, "Chat.ApprovalReason requires Chat.Parts.");
|
|
7
|
+
const reason = isToolUIPart(part) ? part.approval?.requestReason : void 0;
|
|
8
|
+
const element = usePart("p", props, { defaults: { children: reason } });
|
|
9
|
+
return reason ? element : null;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
ApprovalReason
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isToolUIPart } from "ai";
|
|
3
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
4
|
+
import { PartScope } from "./contexts.js";
|
|
5
|
+
function ApprovalReceipt(props) {
|
|
6
|
+
const part = useRequired(PartScope, "Chat.ApprovalReceipt requires Chat.Parts.");
|
|
7
|
+
const approved = isToolUIPart(part) ? part.approval?.approved : void 0;
|
|
8
|
+
const element = usePart("p", props, { state: { approved: approved === true } });
|
|
9
|
+
return typeof approved === "boolean" ? element : null;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
ApprovalReceipt
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
3
|
+
import { ApprovalContext } from "./contexts.js";
|
|
4
|
+
function Approve(props) {
|
|
5
|
+
const write = useRequired(ApprovalContext, "Chat.Approve requires Chat.PartApproval.");
|
|
6
|
+
return usePart("button", props, {
|
|
7
|
+
state: { pending: write.pending },
|
|
8
|
+
defaults: { type: "button" },
|
|
9
|
+
locked: { disabled: write.pending },
|
|
10
|
+
behavior: { onClick: () => void write.run({ approved: true }) }
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
Approve
|
|
15
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRequired } from "@slices.sh/core/part";
|
|
3
|
+
import { BranchContext, MessageScope } from "./contexts.js";
|
|
4
|
+
function BranchNavigation({ children }) {
|
|
5
|
+
const branches = useRequired(BranchContext, "Chat.BranchNavigation requires Chat.Root.");
|
|
6
|
+
const message = useRequired(MessageScope, "Chat.BranchNavigation requires Chat.Messages.");
|
|
7
|
+
return branches.page(message.id) ? children : null;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
BranchNavigation
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
3
|
+
import { BranchContext, MessageScope } from "./contexts.js";
|
|
4
|
+
function BranchNext(props) {
|
|
5
|
+
const branches = useRequired(BranchContext, "Chat.BranchNext requires Chat.Root.");
|
|
6
|
+
const message = useRequired(MessageScope, "Chat.BranchNext requires Chat.Messages.");
|
|
7
|
+
const page = branches.page(message.id);
|
|
8
|
+
const element = usePart("button", props, {
|
|
9
|
+
defaults: { type: "button" },
|
|
10
|
+
locked: { disabled: branches.blocked || !page || page.index >= page.total },
|
|
11
|
+
behavior: {
|
|
12
|
+
onClick: () => {
|
|
13
|
+
if (page) branches.move(page.id, 1);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return page ? element : null;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
BranchNext
|
|
21
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
3
|
+
import { BranchContext, MessageScope } from "./contexts.js";
|
|
4
|
+
function BranchPage(props) {
|
|
5
|
+
const branches = useRequired(BranchContext, "Chat.BranchPage requires Chat.Root.");
|
|
6
|
+
const message = useRequired(MessageScope, "Chat.BranchPage requires Chat.Messages.");
|
|
7
|
+
const page = branches.page(message.id);
|
|
8
|
+
const element = usePart("span", props, { state: { index: page?.index ?? 0, total: page?.total ?? 0 } });
|
|
9
|
+
return page ? element : null;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
BranchPage
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
3
|
+
import { BranchContext, MessageScope } from "./contexts.js";
|
|
4
|
+
function BranchPrevious(props) {
|
|
5
|
+
const branches = useRequired(BranchContext, "Chat.BranchPrevious requires Chat.Root.");
|
|
6
|
+
const message = useRequired(MessageScope, "Chat.BranchPrevious requires Chat.Messages.");
|
|
7
|
+
const page = branches.page(message.id);
|
|
8
|
+
const element = usePart("button", props, {
|
|
9
|
+
defaults: { type: "button" },
|
|
10
|
+
locked: { disabled: branches.blocked || !page || page.index <= 1 },
|
|
11
|
+
behavior: {
|
|
12
|
+
onClick: () => {
|
|
13
|
+
if (page) branches.move(page.id, -1);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return page ? element : null;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
BranchPrevious
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
3
|
+
import { SentDraftContext } from "./contexts.js";
|
|
4
|
+
function CancelEdit(props) {
|
|
5
|
+
const draft = useRequired(SentDraftContext, "Chat.CancelEdit requires Chat.MessageEditRoot.");
|
|
6
|
+
return usePart("button", props, { defaults: { type: "button" }, behavior: { onClick: draft.cancel } });
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
CancelEdit
|
|
10
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
3
|
+
import { QueueContext, QueueScope } from "./contexts.js";
|
|
4
|
+
function CancelQueueEdit(props) {
|
|
5
|
+
const queue = useRequired(QueueContext, "Chat.CancelQueueEdit requires Chat.Root.");
|
|
6
|
+
const item = useRequired(QueueScope, "Chat.CancelQueueEdit requires Chat.QueueItems.");
|
|
7
|
+
return usePart("button", props, {
|
|
8
|
+
defaults: { type: "button" },
|
|
9
|
+
locked: { disabled: false },
|
|
10
|
+
behavior: { onClick: () => queue.change({ type: "cancel-edit", id: item.id }) }
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
CancelQueueEdit
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
3
|
+
import { QueueContext, QueueScope } from "./contexts.js";
|
|
4
|
+
function CancelQueued(props) {
|
|
5
|
+
const queue = useRequired(QueueContext, "Chat.CancelQueued requires Chat.Root.");
|
|
6
|
+
const item = useRequired(QueueScope, "Chat.CancelQueued requires Chat.QueueItems.");
|
|
7
|
+
return usePart("button", props, {
|
|
8
|
+
defaults: { type: "button" },
|
|
9
|
+
locked: { disabled: false },
|
|
10
|
+
behavior: { onClick: () => queue.change({ type: "remove", id: item.id }) }
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
CancelQueued
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DictationContext } from "@slices.sh/transcription/headless/contexts";
|
|
3
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
4
|
+
function Confirm(props) {
|
|
5
|
+
const dictation = useRequired(DictationContext, "ChatDictation.Confirm requires ChatDictation.Root.");
|
|
6
|
+
return usePart("button", props, {
|
|
7
|
+
defaults: { type: "button" },
|
|
8
|
+
locked: { disabled: dictation.state.state !== "listening" },
|
|
9
|
+
behavior: { onClick: dictation.control.stop }
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
Confirm
|
|
14
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Root } from "./root";
|
|
2
|
+
import { Input } from "./input";
|
|
3
|
+
import { Voice } from "./voice";
|
|
4
|
+
import { Text } from "./text";
|
|
5
|
+
import { Confirm } from "./confirm";
|
|
6
|
+
export declare const ChatDictation: {
|
|
7
|
+
Root: typeof Root;
|
|
8
|
+
Input: typeof Input;
|
|
9
|
+
Voice: typeof Voice;
|
|
10
|
+
Text: typeof Text;
|
|
11
|
+
Confirm: typeof Confirm;
|
|
12
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Root } from "./root.js";
|
|
2
|
+
import { Input } from "./input.js";
|
|
3
|
+
import { Voice } from "./voice.js";
|
|
4
|
+
import { Text } from "./text.js";
|
|
5
|
+
import { Confirm } from "./confirm.js";
|
|
6
|
+
const ChatDictation = { Root, Input, Voice, Text, Confirm };
|
|
7
|
+
export {
|
|
8
|
+
ChatDictation
|
|
9
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type PartProps } from "@slices.sh/core/part";
|
|
2
|
+
/** Dictation.Field remains the sole owner of editing and caret restoration. */
|
|
3
|
+
export declare function Input(props: PartProps<"textarea">): string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isValidElement, useRef, useLayoutEffect } from "react";
|
|
4
|
+
import { Dictation } from "@slices.sh/transcription/headless";
|
|
5
|
+
import { DictationContext, FieldContext } from "@slices.sh/transcription/headless/contexts";
|
|
6
|
+
import { ComposerContext } from "../contexts.js";
|
|
7
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
8
|
+
function Input(props) {
|
|
9
|
+
const composer = useRequired(ComposerContext, "ChatDictation.Input requires ChatDictation.Root.");
|
|
10
|
+
const dictation = useRequired(DictationContext, "ChatDictation.Input requires ChatDictation.Root.");
|
|
11
|
+
const field = useRequired(FieldContext, "ChatDictation.Input requires ChatDictation.Root.");
|
|
12
|
+
const node = useRef(null);
|
|
13
|
+
const before = useRef(null);
|
|
14
|
+
const wasActive = useRef(false);
|
|
15
|
+
const active = ["asking", "listening", "finalizing"].includes(dictation.state.state);
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
if (wasActive.current && !active && node.current) {
|
|
18
|
+
node.current.focus();
|
|
19
|
+
const caret = field.at?.end ?? before.current ?? node.current.value.length;
|
|
20
|
+
node.current.setSelectionRange(caret, caret);
|
|
21
|
+
}
|
|
22
|
+
wasActive.current = active;
|
|
23
|
+
}, [active, field.at]);
|
|
24
|
+
const element = usePart(
|
|
25
|
+
"textarea",
|
|
26
|
+
{ ...props, ref: node },
|
|
27
|
+
{
|
|
28
|
+
defaults: { autoComplete: "off", enterKeyHint: "send" },
|
|
29
|
+
behavior: {
|
|
30
|
+
onKeyDown: composer.keyDown,
|
|
31
|
+
onBlur(event) {
|
|
32
|
+
before.current = event.currentTarget.selectionStart;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
locked: { disabled: composer.disabled }
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
return isValidElement(element) ? /* @__PURE__ */ jsx(Dictation.Field, { render: element }) : element;
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
Input
|
|
42
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { Dictation } from "@slices.sh/transcription/headless";
|
|
5
|
+
import { DictationContext, FieldContext } from "@slices.sh/transcription/headless/contexts";
|
|
6
|
+
import { ComposerContext } from "../contexts.js";
|
|
7
|
+
import { Provide, useRequired } from "@slices.sh/core/part";
|
|
8
|
+
function Root({ children }) {
|
|
9
|
+
const composer = useRequired(ComposerContext, "ChatDictation.Root requires Chat.Root.");
|
|
10
|
+
return /* @__PURE__ */ jsx(Dictation.Root, { value: composer.draft, onChange: composer.set, children: /* @__PURE__ */ jsx(Bridge, { children }) });
|
|
11
|
+
}
|
|
12
|
+
function Bridge({ children }) {
|
|
13
|
+
const base = useRequired(ComposerContext, "ChatDictation requires Chat.Root.");
|
|
14
|
+
const dictation = useRequired(DictationContext, "ChatDictation requires Dictation.Root.");
|
|
15
|
+
const field = useRequired(FieldContext, "ChatDictation requires Dictation.Root.");
|
|
16
|
+
const busy = ["asking", "listening", "finalizing"].includes(dictation.state.state);
|
|
17
|
+
const composer = useMemo(
|
|
18
|
+
() => ({
|
|
19
|
+
draft: base.draft,
|
|
20
|
+
set: field.change,
|
|
21
|
+
disabled: base.disabled || busy,
|
|
22
|
+
submit(text) {
|
|
23
|
+
if (!busy) base.submit(text);
|
|
24
|
+
},
|
|
25
|
+
keyDown(event) {
|
|
26
|
+
if (busy) {
|
|
27
|
+
if (event.key === "Escape") {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
dictation.control.abort();
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
base.keyDown(event);
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
[base, field.change, busy, dictation.control]
|
|
37
|
+
);
|
|
38
|
+
return /* @__PURE__ */ jsx(Provide, { values: [[ComposerContext, composer]], children });
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
Root
|
|
42
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DictationContext } from "@slices.sh/transcription/headless/contexts";
|
|
3
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
4
|
+
function Text(props) {
|
|
5
|
+
const dictation = useRequired(DictationContext, "ChatDictation.Text requires ChatDictation.Root.");
|
|
6
|
+
const active = ["asking", "listening", "finalizing"].includes(dictation.state.state);
|
|
7
|
+
return usePart("div", props, {
|
|
8
|
+
attributes: { active },
|
|
9
|
+
locked: { inert: active, "aria-hidden": active }
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
Text
|
|
14
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isValidElement, useRef, useLayoutEffect } from "react";
|
|
4
|
+
import { DictationContext } from "@slices.sh/transcription/headless/contexts";
|
|
5
|
+
import { Presence } from "@slices.sh/core/motion";
|
|
6
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
7
|
+
function Voice(props) {
|
|
8
|
+
const dictation = useRequired(DictationContext, "ChatDictation.Voice requires ChatDictation.Root.");
|
|
9
|
+
const active = ["asking", "listening", "finalizing"].includes(dictation.state.state);
|
|
10
|
+
const node = useRef(null);
|
|
11
|
+
const phase = dictation.state.state;
|
|
12
|
+
useLayoutEffect(() => {
|
|
13
|
+
if (phase === "listening")
|
|
14
|
+
node.current?.querySelector("button:not(:disabled)")?.focus();
|
|
15
|
+
}, [phase]);
|
|
16
|
+
const element = usePart(
|
|
17
|
+
"div",
|
|
18
|
+
{ ...props, ref: node },
|
|
19
|
+
{
|
|
20
|
+
locked: { inert: !active, "aria-hidden": !active },
|
|
21
|
+
behavior: {
|
|
22
|
+
onKeyDown(event) {
|
|
23
|
+
if (event.key === "Escape" && dictation.state.state !== "asking") {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
dictation.control.abort();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
return isValidElement(element) ? /* @__PURE__ */ jsx(Presence, { present: active, children: element }) : null;
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
Voice
|
|
35
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { MotionPopover } from "./source-primitives.js";
|
|
4
|
+
import { usePart, useRequired } from "@slices.sh/core/part";
|
|
5
|
+
import { CitationDisclosureContext } from "./source-context.js";
|
|
6
|
+
function CitationContent(props) {
|
|
7
|
+
const disclosure = useRequired(
|
|
8
|
+
CitationDisclosureContext,
|
|
9
|
+
"Chat.CitationContent requires Chat.CitationRoot."
|
|
10
|
+
);
|
|
11
|
+
return usePart(
|
|
12
|
+
"div",
|
|
13
|
+
{ ...props, render: props.render ?? /* @__PURE__ */ jsx(MotionPopover, {}) },
|
|
14
|
+
{ locked: { open: disclosure.open } }
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
CitationContent
|
|
19
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { type PartProps } from "@slices.sh/core/part";
|
|
2
|
+
export declare function CitationDescription(props: PartProps<"p">): string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isValidElement } from "react";
|
|
4
|
+
import { Popover } from "./source-primitives.js";
|
|
5
|
+
import { usePart } from "@slices.sh/core/part";
|
|
6
|
+
function CitationDescription(props) {
|
|
7
|
+
const element = usePart("p", props);
|
|
8
|
+
return isValidElement(element) ? /* @__PURE__ */ jsx(Popover.Description, { render: element }) : element;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
CitationDescription
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Popover } from "./source-primitives.js";
|
|
4
|
+
import { useSourceDisclosure } from "../hooks/use-source-disclosure.js";
|
|
5
|
+
import { Provide } from "@slices.sh/core/part";
|
|
6
|
+
import { CitationDisclosureContext } from "./source-context.js";
|
|
7
|
+
function CitationRoot({ children }) {
|
|
8
|
+
const disclosure = useSourceDisclosure();
|
|
9
|
+
return /* @__PURE__ */ jsx(Popover.Root, { open: disclosure.open, onOpenChange: disclosure.setOpen, children: /* @__PURE__ */ jsx(Provide, { values: [[CitationDisclosureContext, disclosure]], children }) });
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
CitationRoot
|
|
13
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { type PartProps } from "@slices.sh/core/part";
|
|
2
|
+
export declare function CitationTitle(props: PartProps<"h2">): string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isValidElement } from "react";
|
|
4
|
+
import { Popover } from "./source-primitives.js";
|
|
5
|
+
import { usePart } from "@slices.sh/core/part";
|
|
6
|
+
function CitationTitle(props) {
|
|
7
|
+
const element = usePart("h2", props);
|
|
8
|
+
return isValidElement(element) ? /* @__PURE__ */ jsx(Popover.Title, { render: element }) : element;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
CitationTitle
|
|
12
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { type PartProps } from "@slices.sh/core/part";
|
|
2
|
+
export declare function CitationTrigger(props: PartProps<"button">): string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isValidElement } from "react";
|
|
4
|
+
import { Popover } from "./source-primitives.js";
|
|
5
|
+
import { usePart } from "@slices.sh/core/part";
|
|
6
|
+
function CitationTrigger(props) {
|
|
7
|
+
const element = usePart("button", props);
|
|
8
|
+
return isValidElement(element) ? /* @__PURE__ */ jsx(Popover.Trigger, { render: element }) : element;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
CitationTrigger
|
|
12
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PartProps } from "@slices.sh/core/part";
|
|
2
|
+
/** Takes a pick back, which a radio cannot do by itself. An optional question only: a required one is changed, not emptied. */
|
|
3
|
+
export declare function ClearAnswer({ name, ...props }: PartProps<"button"> & {
|
|
4
|
+
name: string;
|
|
5
|
+
}): import("react").ReactNode;
|