@kerf-js/veneer 0.0.0-stage → 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 +16 -0
- package/README.md +1338 -2
- package/package.json +56 -3
- package/plugin.d.mts +187 -0
- package/plugin.mjs +399 -0
- package/src/Accordion.tsx +98 -0
- package/src/Alert.tsx +55 -0
- package/src/Badge.tsx +39 -0
- package/src/Button.tsx +175 -0
- package/src/Calendar-month.tsx +140 -0
- package/src/Calendar.tsx +335 -0
- package/src/Canvas.tsx +221 -0
- package/src/Card.tsx +85 -0
- package/src/Chart.tsx +278 -0
- package/src/Charts.tsx +158 -0
- package/src/Chip.tsx +61 -0
- package/src/Choice-checkbox.tsx +53 -0
- package/src/Choice-parts.tsx +7 -0
- package/src/Choice-radio.tsx +78 -0
- package/src/Choice-segmented.tsx +76 -0
- package/src/Choice-switch.tsx +51 -0
- package/src/Choice.tsx +4 -0
- package/src/CloseX.tsx +14 -0
- package/src/CodeBlock.tsx +81 -0
- package/src/CodeInput.tsx +256 -0
- package/src/Combobox.tsx +281 -0
- package/src/CommandPalette-controller.ts +314 -0
- package/src/CommandPalette-rows.tsx +137 -0
- package/src/CommandPalette.tsx +196 -0
- package/src/DataGrid-actions.ts +119 -0
- package/src/DataGrid-body.tsx +58 -0
- package/src/DataGrid-controller.ts +145 -0
- package/src/DataGrid-header.tsx +108 -0
- package/src/DataGrid-model.ts +248 -0
- package/src/DataGrid-pivot.tsx +108 -0
- package/src/DataGrid-rows.tsx +296 -0
- package/src/DataGrid-toolbar.tsx +127 -0
- package/src/DataGrid-tree.ts +149 -0
- package/src/DataGrid-viewport.tsx +37 -0
- package/src/DataGrid.tsx +145 -0
- package/src/DateField-presets.tsx +27 -0
- package/src/DateField-range.tsx +370 -0
- package/src/DateField.tsx +295 -0
- package/src/Dither.tsx +313 -0
- package/src/Drawer.tsx +123 -0
- package/src/DurationField.tsx +227 -0
- package/src/Feed.tsx +78 -0
- package/src/Field/view.tsx +147 -0
- package/src/Field.tsx +238 -0
- package/src/HamburgerMenu.tsx +119 -0
- package/src/Icon.tsx +15 -0
- package/src/Kbd.tsx +6 -0
- package/src/KeyValueEditor/actions.ts +75 -0
- package/src/KeyValueEditor/rows.tsx +104 -0
- package/src/KeyValueEditor.tsx +112 -0
- package/src/Layout.tsx +221 -0
- package/src/Markdown.tsx +127 -0
- package/src/MentionsInput/actions.ts +161 -0
- package/src/MentionsInput/end.tsx +82 -0
- package/src/MentionsInput.tsx +103 -0
- package/src/Menu.tsx +221 -0
- package/src/Modal.tsx +109 -0
- package/src/MonthPicker/month.tsx +117 -0
- package/src/MonthPicker/period.tsx +197 -0
- package/src/MonthPicker/shared.tsx +272 -0
- package/src/MonthPicker/week.tsx +103 -0
- package/src/MonthPicker.tsx +11 -0
- package/src/MultiSelect.tsx +139 -0
- package/src/Nav.tsx +36 -0
- package/src/NumberField.tsx +156 -0
- package/src/Pagination.tsx +335 -0
- package/src/PaymentCard.tsx +111 -0
- package/src/Picker.tsx +228 -0
- package/src/PlaceField.tsx +285 -0
- package/src/Popover.tsx +88 -0
- package/src/Presence.tsx +37 -0
- package/src/Progress.tsx +71 -0
- package/src/RecurrenceField.tsx +372 -0
- package/src/RichSelect/codes.tsx +94 -0
- package/src/RichSelect/list.tsx +380 -0
- package/src/RichSelect/phone-view.tsx +114 -0
- package/src/RichSelect/phone.tsx +305 -0
- package/src/RichSelect/search-keys.ts +28 -0
- package/src/RichSelect/timezone.tsx +53 -0
- package/src/RichSelect.tsx +13 -0
- package/src/RichTextEditor/controller.tsx +305 -0
- package/src/RichTextEditor/editor.tsx +61 -0
- package/src/RichTextEditor/tools.tsx +132 -0
- package/src/RichTextEditor/view.tsx +210 -0
- package/src/RichTextEditor.tsx +9 -0
- package/src/ScrollGrid/measure.ts +39 -0
- package/src/ScrollGrid/parts.tsx +112 -0
- package/src/ScrollGrid.tsx +375 -0
- package/src/ScrollRail.tsx +114 -0
- package/src/ScrollView.tsx +57 -0
- package/src/Segments/controller.tsx +148 -0
- package/src/Segments/events.ts +99 -0
- package/src/Segments/view.tsx +77 -0
- package/src/Segments.tsx +2 -0
- package/src/Select.tsx +343 -0
- package/src/Shape.tsx +41 -0
- package/src/Shell/branches.tsx +108 -0
- package/src/Shell/button.tsx +33 -0
- package/src/Shell/shared.tsx +220 -0
- package/src/Shell/shell.tsx +25 -0
- package/src/Shell/state.ts +138 -0
- package/src/Shell/view.tsx +280 -0
- package/src/Shell.tsx +17 -0
- package/src/SideNav/sections.tsx +50 -0
- package/src/SideNav/state.ts +140 -0
- package/src/SideNav.tsx +130 -0
- package/src/SideNavTitle.tsx +25 -0
- package/src/SignaturePad/state.ts +172 -0
- package/src/SignaturePad/view.tsx +69 -0
- package/src/SignaturePad.tsx +76 -0
- package/src/Skeleton.tsx +46 -0
- package/src/Slider.tsx +81 -0
- package/src/Spinner.tsx +21 -0
- package/src/Stage-director.ts +361 -0
- package/src/Stage-look.ts +75 -0
- package/src/Stage-poster.tsx +62 -0
- package/src/Stage-types.ts +206 -0
- package/src/Stage.tsx +147 -0
- package/src/TabBar.tsx +114 -0
- package/src/Table-actions.tsx +51 -0
- package/src/Table-base.ts +70 -0
- package/src/Table-body.tsx +84 -0
- package/src/Table-columns.tsx +58 -0
- package/src/Table-details.tsx +66 -0
- package/src/Table-editor.tsx +66 -0
- package/src/Table-head.tsx +52 -0
- package/src/Table-model.ts +82 -0
- package/src/Table-notice.ts +39 -0
- package/src/Table-paging.ts +50 -0
- package/src/Table-rows.tsx +308 -0
- package/src/Table-selection.ts +63 -0
- package/src/Table-sortbar.tsx +41 -0
- package/src/Table-source.ts +66 -0
- package/src/Table-toolbar.tsx +71 -0
- package/src/Table-types.ts +115 -0
- package/src/Table-view.tsx +87 -0
- package/src/Table.tsx +31 -0
- package/src/Tabs.tsx +129 -0
- package/src/Tag.tsx +40 -0
- package/src/Ticker.tsx +42 -0
- package/src/TimeField-date-model.ts +77 -0
- package/src/TimeField-date-view.tsx +152 -0
- package/src/TimeField-model.ts +80 -0
- package/src/TimeField-options.tsx +224 -0
- package/src/TimeField-slots.tsx +32 -0
- package/src/TimeField-types.ts +33 -0
- package/src/TimeField-view.tsx +124 -0
- package/src/TimeField.tsx +126 -0
- package/src/Toast.tsx +143 -0
- package/src/Toggle.tsx +75 -0
- package/src/Tooltip.tsx +69 -0
- package/src/Type.tsx +136 -0
- package/src/VirtualList-controls.ts +105 -0
- package/src/VirtualList-data.ts +43 -0
- package/src/VirtualList-measure.ts +169 -0
- package/src/VirtualList-metrics.ts +41 -0
- package/src/VirtualList-mount.ts +145 -0
- package/src/VirtualList-rows.tsx +91 -0
- package/src/VirtualList-types.ts +76 -0
- package/src/VirtualList-view.tsx +123 -0
- package/src/VirtualList.tsx +81 -0
- package/src/admin/ApiKeys-actions.ts +124 -0
- package/src/admin/ApiKeys-form.tsx +64 -0
- package/src/admin/ApiKeys-view.tsx +101 -0
- package/src/admin/ApiKeys.tsx +224 -0
- package/src/admin/Audit.tsx +246 -0
- package/src/admin/Billing.tsx +307 -0
- package/src/admin/Cart.tsx +177 -0
- package/src/admin/Checkout-address.tsx +125 -0
- package/src/admin/Checkout-cart.tsx +78 -0
- package/src/admin/Checkout-coupon.ts +34 -0
- package/src/admin/Checkout-done.tsx +31 -0
- package/src/admin/Checkout-model.ts +33 -0
- package/src/admin/Checkout-navigation.ts +76 -0
- package/src/admin/Checkout-payment-view.tsx +49 -0
- package/src/admin/Checkout-payment.ts +80 -0
- package/src/admin/Checkout-review.tsx +60 -0
- package/src/admin/Checkout-shipping.tsx +47 -0
- package/src/admin/Checkout-state.ts +122 -0
- package/src/admin/Checkout-steps.ts +10 -0
- package/src/admin/Checkout-summary.tsx +97 -0
- package/src/admin/Checkout-types.ts +60 -0
- package/src/admin/Checkout-view.tsx +51 -0
- package/src/admin/Checkout.tsx +72 -0
- package/src/admin/CsvImport-actions.ts +131 -0
- package/src/admin/CsvImport.tsx +379 -0
- package/src/admin/Danger.tsx +240 -0
- package/src/admin/Integrations/Card.tsx +82 -0
- package/src/admin/Integrations/Webhooks.tsx +341 -0
- package/src/admin/Integrations.tsx +169 -0
- package/src/admin/InviteDialog.tsx +153 -0
- package/src/admin/Members/columns.tsx +181 -0
- package/src/admin/Members.tsx +316 -0
- package/src/admin/Order.tsx +115 -0
- package/src/admin/PlainTable.tsx +34 -0
- package/src/admin/Plans.tsx +375 -0
- package/src/admin/SaveBar/actions.ts +86 -0
- package/src/admin/SaveBar.tsx +153 -0
- package/src/admin/Secret.tsx +74 -0
- package/src/admin/Settings.tsx +145 -0
- package/src/admin/StepBar.tsx +66 -0
- package/src/admin/TagsInput/actions.ts +60 -0
- package/src/admin/TagsInput.tsx +95 -0
- package/src/admin/atoms.tsx +73 -0
- package/src/admin/index.ts +67 -0
- package/src/agent/Actions/reasons.tsx +38 -0
- package/src/agent/Actions.tsx +166 -0
- package/src/agent/AgentPlan.tsx +86 -0
- package/src/agent/ArtifactPanel.tsx +299 -0
- package/src/agent/Assistant.tsx +168 -0
- package/src/agent/Checkpoint.tsx +19 -0
- package/src/agent/Cite.tsx +70 -0
- package/src/agent/ContextMeter.tsx +70 -0
- package/src/agent/Conversation.tsx +70 -0
- package/src/agent/Message.tsx +92 -0
- package/src/agent/ModelPicker.tsx +167 -0
- package/src/agent/Prompt-model.ts +118 -0
- package/src/agent/Prompt-view.tsx +246 -0
- package/src/agent/Prompt.tsx +128 -0
- package/src/agent/Prose.tsx +118 -0
- package/src/agent/Question.tsx +137 -0
- package/src/agent/Reasoning.tsx +31 -0
- package/src/agent/Shimmer.tsx +11 -0
- package/src/agent/Sources.tsx +23 -0
- package/src/agent/SpeechInput.tsx +243 -0
- package/src/agent/Suggestions.tsx +36 -0
- package/src/agent/ToolCall.tsx +219 -0
- package/src/agent/TraceViewer.tsx +96 -0
- package/src/agent/bits.tsx +88 -0
- package/src/agent/index.ts +38 -0
- package/src/bind.ts +57 -0
- package/src/collab/AutoTrack.tsx +91 -0
- package/src/collab/Comments.tsx +204 -0
- package/src/collab/Composer/state.ts +125 -0
- package/src/collab/Composer/view.tsx +155 -0
- package/src/collab/Composer.tsx +141 -0
- package/src/collab/ConversationList.tsx +120 -0
- package/src/collab/Cursors.tsx +71 -0
- package/src/collab/DataIntegrity.tsx +103 -0
- package/src/collab/Kanban-card.ts +74 -0
- package/src/collab/Kanban.tsx +368 -0
- package/src/collab/Lock.tsx +36 -0
- package/src/collab/PresenceStack.tsx +176 -0
- package/src/collab/ShareDialog.tsx +273 -0
- package/src/collab/Status.tsx +101 -0
- package/src/collab/SyncedForm.tsx +42 -0
- package/src/collab/Thread/Message.tsx +265 -0
- package/src/collab/Thread/rows.tsx +56 -0
- package/src/collab/Thread.tsx +323 -0
- package/src/collab/VersionHistory.tsx +173 -0
- package/src/collab/ViewportRail.tsx +73 -0
- package/src/collab/index.ts +37 -0
- package/src/collab/peer.tsx +42 -0
- package/src/fields.ts +5 -0
- package/src/flow/AuthScreen.tsx +81 -0
- package/src/flow/AuthSteps.tsx +296 -0
- package/src/flow/Checklist.tsx +211 -0
- package/src/flow/ConnBanner.tsx +304 -0
- package/src/flow/Flow.tsx +97 -0
- package/src/flow/MfaSetup.tsx +244 -0
- package/src/flow/Otp.tsx +243 -0
- package/src/flow/ReauthDialog.tsx +79 -0
- package/src/flow/ShortcutsOverlay.tsx +121 -0
- package/src/flow/SignGate.tsx +184 -0
- package/src/flow/SignIn.tsx +136 -0
- package/src/flow/SignUp.tsx +149 -0
- package/src/flow/Sso.tsx +96 -0
- package/src/flow/SystemPage/accounts.tsx +74 -0
- package/src/flow/SystemPage/art.tsx +113 -0
- package/src/flow/SystemPage.tsx +395 -0
- package/src/flow/Tour.tsx +207 -0
- package/src/flow/index.ts +29 -0
- package/src/flow/kit.tsx +334 -0
- package/src/index.ts +237 -0
- package/src/layout.css +4 -0
- package/src/links.css +4 -0
- package/src/live/ActivityFeed.tsx +88 -0
- package/src/live/Bell.tsx +108 -0
- package/src/live/Connection.tsx +113 -0
- package/src/live/Inbox.tsx +113 -0
- package/src/live/InboxFeed.tsx +67 -0
- package/src/live/InboxGestures.ts +41 -0
- package/src/live/InboxHandlers.ts +102 -0
- package/src/live/InboxHeader.tsx +81 -0
- package/src/live/InboxModel.ts +81 -0
- package/src/live/InboxRow.tsx +125 -0
- package/src/live/MeetingRoom.tsx +22 -0
- package/src/live/MeetingRoomControlBar.tsx +197 -0
- package/src/live/MeetingRoomHandlers.ts +53 -0
- package/src/live/MeetingRoomLayout.tsx +27 -0
- package/src/live/MeetingRoomModel.ts +49 -0
- package/src/live/MeetingRoomMount.ts +49 -0
- package/src/live/MeetingRoomParts.tsx +178 -0
- package/src/live/MeetingRoomPerson.tsx +21 -0
- package/src/live/MeetingRoomState.ts +88 -0
- package/src/live/MeetingRoomTile.tsx +84 -0
- package/src/live/MeetingRoomTypes.ts +68 -0
- package/src/live/MeetingRoomView.tsx +36 -0
- package/src/live/NotificationPreferences.tsx +99 -0
- package/src/live/NotificationPreferencesActions.ts +55 -0
- package/src/live/NotificationPreferencesCell.tsx +26 -0
- package/src/live/NotificationPreferencesCells.tsx +59 -0
- package/src/live/NotificationPreferencesGrid.tsx +129 -0
- package/src/live/NotificationPreferencesModel.tsx +91 -0
- package/src/live/NotificationPreferencesSave.ts +85 -0
- package/src/live/NotificationPreferencesWatch.ts +31 -0
- package/src/live/Prejoin.tsx +238 -0
- package/src/live/PrejoinMeter.tsx +26 -0
- package/src/live/PrejoinPreview.tsx +53 -0
- package/src/live/PushSoftAsk.tsx +63 -0
- package/src/live/TransportPicker.tsx +341 -0
- package/src/live/TransportPickerDetails.tsx +130 -0
- package/src/live/index.ts +31 -0
- package/src/live/notify.tsx +22 -0
- package/src/live/shared.tsx +110 -0
- package/src/parts.tsx +199 -0
- package/src/plugin/catalog.mjs +129 -0
- package/src/plugin/dtcg.mjs +79 -0
- package/src/plugin/icons.mjs +7 -0
- package/src/plugin/seed.mjs +40 -0
- package/src/plugin/theme-context.mjs +44 -0
- package/src/plugin/theme-css.mjs +143 -0
- package/src/plugin/theme-motion.mjs +43 -0
- package/src/plugin/theme-parts.d.mts +41 -0
- package/src/plugin/theme-parts.mjs +224 -0
- package/src/plugin/theme-text.mjs +93 -0
- package/src/plugin/theme-values.mjs +15 -0
- package/src/plugin/theme.d.mts +82 -0
- package/src/plugin/theme.mjs +316 -0
- package/src/schedule/Agenda.tsx +124 -0
- package/src/schedule/AgendaActions.ts +31 -0
- package/src/schedule/AgendaDay.tsx +124 -0
- package/src/schedule/AgendaGestures.ts +27 -0
- package/src/schedule/AgendaKeys.ts +52 -0
- package/src/schedule/AgendaModel.ts +82 -0
- package/src/schedule/AgendaNavigation.ts +38 -0
- package/src/schedule/AgendaPage.tsx +39 -0
- package/src/schedule/AgendaStrip.tsx +55 -0
- package/src/schedule/AvailabilityEditor-actions.ts +146 -0
- package/src/schedule/AvailabilityEditor-day.tsx +119 -0
- package/src/schedule/AvailabilityEditor-view.tsx +205 -0
- package/src/schedule/AvailabilityEditor.tsx +113 -0
- package/src/schedule/BookingCalendar.tsx +121 -0
- package/src/schedule/BookingCalendarActions.ts +85 -0
- package/src/schedule/BookingCalendarModel.ts +86 -0
- package/src/schedule/BookingCalendarParts.tsx +87 -0
- package/src/schedule/Calendar/AgendaView.tsx +45 -0
- package/src/schedule/Calendar/CalendarDialogs.tsx +105 -0
- package/src/schedule/Calendar/CalendarMain.tsx +47 -0
- package/src/schedule/Calendar/CalendarToolbar.tsx +106 -0
- package/src/schedule/Calendar/Column.tsx +129 -0
- package/src/schedule/Calendar/EventBlock.tsx +71 -0
- package/src/schedule/Calendar/MiniMonth.tsx +169 -0
- package/src/schedule/Calendar/MonthGrid.tsx +296 -0
- package/src/schedule/Calendar/TimeGrid.tsx +252 -0
- package/src/schedule/Calendar/Timeline.tsx +287 -0
- package/src/schedule/Calendar/ZoneChip.tsx +73 -0
- package/src/schedule/Calendar/calendar-shell.ts +160 -0
- package/src/schedule/Calendar/calendar-state.ts +30 -0
- package/src/schedule/Calendar/now-spans.tsx +33 -0
- package/src/schedule/Calendar/shared.ts +3 -0
- package/src/schedule/Calendar/state-actions.ts +189 -0
- package/src/schedule/Calendar/state-base.ts +143 -0
- package/src/schedule/Calendar/state-keys.ts +128 -0
- package/src/schedule/Calendar/time-fit.ts +84 -0
- package/src/schedule/Calendar.tsx +182 -0
- package/src/schedule/EventEditor.tsx +267 -0
- package/src/schedule/EventPopover.tsx +190 -0
- package/src/schedule/MeetingPlanner-model.ts +222 -0
- package/src/schedule/MeetingPlanner-view.tsx +310 -0
- package/src/schedule/MeetingPlanner.tsx +122 -0
- package/src/schedule/MoveSheet.tsx +168 -0
- package/src/schedule/YearView-model.ts +164 -0
- package/src/schedule/YearView-parts.tsx +147 -0
- package/src/schedule/YearView.tsx +100 -0
- package/src/schedule/bits.tsx +65 -0
- package/src/schedule/index.ts +25 -0
- package/src/skeleton-css.ts +4 -0
- package/src/styles.ts +13 -0
- package/src/type.css +15 -0
- package/src/ui.ts +41 -0
- package/src/use-ui.ts +10 -0
- package/tailwind.css +38 -0
- package/tokens/color.mjs +87 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { CheckIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import { announce, uid, type AgentQuestion } from '@kerf-js/veneer-core'
|
|
3
|
+
import { derived, onMount, state, untrack, type State } from '@kerf-js/core'
|
|
4
|
+
import { Button } from '../Button'
|
|
5
|
+
import { Checkbox, Radio } from '../Choice'
|
|
6
|
+
import { Input } from '../Field'
|
|
7
|
+
import '../styles'
|
|
8
|
+
import '@kerf-js/veneer-core/styles/app/question.css'
|
|
9
|
+
|
|
10
|
+
type QuestionProps = {
|
|
11
|
+
question: AgentQuestion
|
|
12
|
+
onAnswer?: (answer: string | string[]) => void
|
|
13
|
+
quiet?: boolean | undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Question (07 §1.3): the run pauses and asks. A fieldset with the question as legend, radios or checkboxes, optional
|
|
18
|
+
* free text; Continue is the solid. Once answered it reads back the choice.
|
|
19
|
+
*/
|
|
20
|
+
export function Question({ question, onAnswer, quiet }: QuestionProps) {
|
|
21
|
+
const name = uid('q')
|
|
22
|
+
const type = derived(() => (question.multiple ? 'checkbox' : 'radio'))
|
|
23
|
+
const picks = questionPicks(() => question)
|
|
24
|
+
const free = state('')
|
|
25
|
+
const other = '__other'
|
|
26
|
+
const options = questionOptions(() => question, other)
|
|
27
|
+
const answered = derived(() => question.answer)
|
|
28
|
+
const said = questionSaid(answered)
|
|
29
|
+
let form: HTMLFormElement | undefined
|
|
30
|
+
onMount(() => {
|
|
31
|
+
if (!untrack(() => quiet) && form)
|
|
32
|
+
announce(form.ownerDocument, 'The assistant has a question.', true)
|
|
33
|
+
})
|
|
34
|
+
const toggle = questionToggle(picks, () => question)
|
|
35
|
+
const submit = questionSubmit(
|
|
36
|
+
{ picks, free, other },
|
|
37
|
+
() => question,
|
|
38
|
+
(readAnswer) => onAnswer?.(readAnswer()),
|
|
39
|
+
)
|
|
40
|
+
// one build per phase: a list around this reads its nodes again as siblings arrive, and picks must survive that
|
|
41
|
+
const done = derived(() => answered.value !== undefined)
|
|
42
|
+
const view = derived(() =>
|
|
43
|
+
done.value ? (
|
|
44
|
+
<p>
|
|
45
|
+
<CheckIcon /> You chose: {said.value}
|
|
46
|
+
</p>
|
|
47
|
+
) : (
|
|
48
|
+
untrack(() => (
|
|
49
|
+
<form ref={(n) => (form = n)} data-scope="question" onSubmit={submit}>
|
|
50
|
+
<fieldset disabled={question.closed}>
|
|
51
|
+
<legend>{question.prompt}</legend>
|
|
52
|
+
{options.value.map((o) =>
|
|
53
|
+
type.value === 'radio' ? (
|
|
54
|
+
<Radio
|
|
55
|
+
key={o.value}
|
|
56
|
+
name={name}
|
|
57
|
+
checked={picks.value.includes(o.value)}
|
|
58
|
+
onChange={(e: Event & { currentTarget: HTMLInputElement }) =>
|
|
59
|
+
toggle(o.value, e.currentTarget.checked)
|
|
60
|
+
}
|
|
61
|
+
>
|
|
62
|
+
{o.label}
|
|
63
|
+
</Radio>
|
|
64
|
+
) : (
|
|
65
|
+
<Checkbox
|
|
66
|
+
key={o.value}
|
|
67
|
+
name={name}
|
|
68
|
+
checked={picks.value.includes(o.value)}
|
|
69
|
+
onChange={(e: Event & { currentTarget: HTMLInputElement }) =>
|
|
70
|
+
toggle(o.value, e.currentTarget.checked)
|
|
71
|
+
}
|
|
72
|
+
>
|
|
73
|
+
{o.label}
|
|
74
|
+
</Checkbox>
|
|
75
|
+
),
|
|
76
|
+
)}
|
|
77
|
+
{picks.value.includes(other) && (
|
|
78
|
+
<Input
|
|
79
|
+
label="Your answer"
|
|
80
|
+
value={free.value}
|
|
81
|
+
onInput={(e) => (free.value = e.currentTarget.value)}
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
</fieldset>
|
|
85
|
+
<div>
|
|
86
|
+
<Button size="sm" type="submit" disabled={question.closed}>
|
|
87
|
+
Continue
|
|
88
|
+
</Button>{' '}
|
|
89
|
+
<small>
|
|
90
|
+
{question.closed ? 'The run stopped before this was answered.' : 'Waiting for you'}
|
|
91
|
+
</small>
|
|
92
|
+
</div>
|
|
93
|
+
</form>
|
|
94
|
+
))
|
|
95
|
+
),
|
|
96
|
+
)
|
|
97
|
+
return <>{view.value}</>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function questionOptions(question: () => AgentQuestion, other: string) {
|
|
101
|
+
return derived(() => [
|
|
102
|
+
...question().options.map((o) => ({ value: o, label: o })),
|
|
103
|
+
...(question().free ? [{ value: other, label: 'Something else…' }] : []),
|
|
104
|
+
])
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function questionToggle(picks: State<string[]>, question: () => AgentQuestion) {
|
|
108
|
+
return (v: string, on: boolean) =>
|
|
109
|
+
(picks.value = question().multiple
|
|
110
|
+
? on
|
|
111
|
+
? [...picks.value, v]
|
|
112
|
+
: picks.value.filter((x) => x !== v)
|
|
113
|
+
: [v])
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function questionSubmit(
|
|
117
|
+
{ picks, free, other }: { picks: State<string[]>; free: State<string>; other: string },
|
|
118
|
+
question: () => AgentQuestion,
|
|
119
|
+
onAnswer: (read: () => string | string[]) => void,
|
|
120
|
+
) {
|
|
121
|
+
return (e: Event) => {
|
|
122
|
+
e.preventDefault()
|
|
123
|
+
const chosen = picks.value.map((p) => (p === other ? free.value.trim() : p)).filter(Boolean)
|
|
124
|
+
if (chosen.length) onAnswer(() => (question().multiple ? chosen : chosen[0]!))
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function questionSaid(answered: { readonly value: AgentQuestion['answer'] }) {
|
|
129
|
+
return derived(() => {
|
|
130
|
+
const a = answered.value
|
|
131
|
+
return Array.isArray(a) ? a.join(', ') : a
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function questionPicks(question: () => AgentQuestion) {
|
|
136
|
+
return state<string[]>(untrack(() => (question().multiple ? [] : question().options.slice(0, 1))))
|
|
137
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RightIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import { derived } from '@kerf-js/core'
|
|
3
|
+
import { Shimmer } from './Shimmer'
|
|
4
|
+
import '../styles'
|
|
5
|
+
import '@kerf-js/veneer-core/styles/app/reasoning.css'
|
|
6
|
+
|
|
7
|
+
/** Reasoning (07 §1.2): a native details. "Thinking…" while it streams, open; it folds itself and keeps the duration. */
|
|
8
|
+
export function Reasoning({
|
|
9
|
+
text,
|
|
10
|
+
streaming,
|
|
11
|
+
seconds,
|
|
12
|
+
}: {
|
|
13
|
+
text: string
|
|
14
|
+
streaming?: boolean | undefined
|
|
15
|
+
seconds?: number | undefined
|
|
16
|
+
}) {
|
|
17
|
+
const label = derived(() => (seconds !== undefined ? `Thought for ${seconds} s` : 'Thought'))
|
|
18
|
+
return (
|
|
19
|
+
<details
|
|
20
|
+
data-scope="reasoning"
|
|
21
|
+
data-state={streaming ? 'streaming' : 'done'}
|
|
22
|
+
open={!!streaming}
|
|
23
|
+
>
|
|
24
|
+
<summary>
|
|
25
|
+
<RightIcon data-part="chev" />
|
|
26
|
+
{streaming ? <Shimmer>Thinking…</Shimmer> : <span>{label.value}</span>}
|
|
27
|
+
</summary>
|
|
28
|
+
<div data-part="body">{text}</div>
|
|
29
|
+
</details>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '../styles'
|
|
2
|
+
import '@kerf-js/veneer-core/styles/app/shimmer.css'
|
|
3
|
+
|
|
4
|
+
/** Placeholder text with a light passing over it (07 §1.3); static under reduced motion. */
|
|
5
|
+
export function Shimmer({ children, ...rest }: { children?: unknown; [attr: string]: unknown }) {
|
|
6
|
+
return (
|
|
7
|
+
<span data-scope="shimmer" {...rest}>
|
|
8
|
+
{children}
|
|
9
|
+
</span>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AgentSource } from '@kerf-js/veneer-core'
|
|
2
|
+
import { derived } from '@kerf-js/core'
|
|
3
|
+
import { Sweep, useSweep } from './bits'
|
|
4
|
+
import '../styles'
|
|
5
|
+
import '@kerf-js/veneer-core/styles/app/sources.css'
|
|
6
|
+
|
|
7
|
+
/** Sources (07 §1.1): numbered cards, the same numbers as the cites. `base` ties them to their Cite hrefs. */
|
|
8
|
+
export function Sources({ items, base }: { items: AgentSource[]; base: string }) {
|
|
9
|
+
useSweep()
|
|
10
|
+
const rows = derived(() => items.map((s, i) => ({ s, n: i + 1, id: `${base}-s${i + 1}` })))
|
|
11
|
+
return (
|
|
12
|
+
<div data-scope="sources" role="group" aria-label="Sources">
|
|
13
|
+
{rows.value.map((r) => (
|
|
14
|
+
<a key={r.n} id={r.id} href={r.s.url ?? `#${r.id}`} data-sweep="">
|
|
15
|
+
<Sweep />
|
|
16
|
+
<i>{r.n}</i>
|
|
17
|
+
<b>{r.s.title}</b>
|
|
18
|
+
{r.s.path !== undefined && <small>{r.s.path}</small>}
|
|
19
|
+
</a>
|
|
20
|
+
))}
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { MicIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import {
|
|
3
|
+
announce,
|
|
4
|
+
dictation,
|
|
5
|
+
formatClock,
|
|
6
|
+
listMics,
|
|
7
|
+
speechWave,
|
|
8
|
+
type DictationEngine,
|
|
9
|
+
type DictationEvents,
|
|
10
|
+
type DictationState,
|
|
11
|
+
} from '@kerf-js/veneer-core'
|
|
12
|
+
import { derived, onCleanup, onMount, state, untrack } from '@kerf-js/core'
|
|
13
|
+
import { Alert } from '../Alert'
|
|
14
|
+
import { Button } from '../Button'
|
|
15
|
+
import { Select } from '../Select'
|
|
16
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
17
|
+
import { Sweep, useSweep } from './bits'
|
|
18
|
+
import '../styles'
|
|
19
|
+
import '@kerf-js/veneer-core/styles/app/speech.css'
|
|
20
|
+
|
|
21
|
+
const BARS = Array.from({ length: 40 }, (_, i) => i)
|
|
22
|
+
const DEFAULT_MIC = [{ value: '', label: 'Default microphone' }]
|
|
23
|
+
|
|
24
|
+
/** Props for SpeechInput. */
|
|
25
|
+
export interface SpeechInputProps {
|
|
26
|
+
/** Writes the transcript somewhere: the Prompt's `control.insert`. Nothing is sent until then. */
|
|
27
|
+
onInsert?: (text: string) => void
|
|
28
|
+
mics?: { value: string; label: string }[]
|
|
29
|
+
/** Replaces the browser's speech recognition. */
|
|
30
|
+
engine?: (on: DictationEvents) => DictationEngine
|
|
31
|
+
/** The state and words to start from (a demo, a test). */
|
|
32
|
+
initial?:
|
|
33
|
+
| { state?: DictationState | undefined; final?: string; interim?: string; seconds?: number }
|
|
34
|
+
| undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* SpeechInput + MicSelector (07 §6.4): the mic Select and input level, then Record and Stop on one button. Listening
|
|
39
|
+
* holds the strip's sweep, moves the wave and counts; words arrive grey while they might change and ink once final. A
|
|
40
|
+
* blocked mic is a caution Alert with the fix, not a dead button. Uses the browser's speech recognition unless given an `engine`.
|
|
41
|
+
*/
|
|
42
|
+
export function SpeechInput({ onInsert, mics, engine, initial }: SpeechInputProps) {
|
|
43
|
+
const view = speechState({
|
|
44
|
+
initial: () => initial,
|
|
45
|
+
mics: () => mics,
|
|
46
|
+
engine: () => engine,
|
|
47
|
+
onInsert: (words) => onInsert?.(words()),
|
|
48
|
+
})
|
|
49
|
+
return (
|
|
50
|
+
<div ref={(n) => (view.refs.root = n)} data-scope="speech" data-state={view.mode.value}>
|
|
51
|
+
<Select
|
|
52
|
+
label="Microphone"
|
|
53
|
+
options={view.options.value}
|
|
54
|
+
onChange={(e: Event) => {
|
|
55
|
+
const s = e.currentTarget as HTMLSelectElement
|
|
56
|
+
view.mic.value = s.value
|
|
57
|
+
view.say(`Microphone: ${s.selectedOptions[0]!.textContent}`)
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
<div data-part="mic">
|
|
61
|
+
<span data-part="level" aria-hidden="true" style={`--level:${view.level.value}`}>
|
|
62
|
+
<i></i>
|
|
63
|
+
<i></i>
|
|
64
|
+
<i></i>
|
|
65
|
+
</span>
|
|
66
|
+
<span>{view.mode.value === 'blocked' ? 'Blocked by the browser' : 'Input level'}</span>
|
|
67
|
+
</div>
|
|
68
|
+
<div data-part="strip" data-sweep="" data-pin={view.on.value ? '' : undefined}>
|
|
69
|
+
<Sweep />
|
|
70
|
+
<Button
|
|
71
|
+
data-icon-only=""
|
|
72
|
+
tone={view.on.value ? 'critical' : undefined}
|
|
73
|
+
aria-pressed={view.on.value ? 'true' : 'false'}
|
|
74
|
+
label={view.on.value ? 'Stop dictation' : 'Start dictation'}
|
|
75
|
+
onClick={view.toggle}
|
|
76
|
+
>
|
|
77
|
+
<MicIcon />
|
|
78
|
+
</Button>
|
|
79
|
+
<span ref={(n) => (view.refs.wave = n)} data-part="wave" data-loop="" aria-hidden="true">
|
|
80
|
+
{BARS.map((b) => (
|
|
81
|
+
<i key={b}></i>
|
|
82
|
+
))}
|
|
83
|
+
</span>
|
|
84
|
+
<span data-part="time" role="timer" aria-label="Recording time" data-numeric="">
|
|
85
|
+
{formatClock(view.seconds.value)}
|
|
86
|
+
</span>
|
|
87
|
+
</div>
|
|
88
|
+
<div data-part="transcript" role="log" aria-live="polite" aria-label="Transcript">
|
|
89
|
+
{view.words.value ? (
|
|
90
|
+
<>
|
|
91
|
+
{view.final.value} <span data-part="interim">{view.interim.value}</span>
|
|
92
|
+
</>
|
|
93
|
+
) : (
|
|
94
|
+
<small>Press the mic and speak. Nothing is sent until you insert it.</small>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
<div>
|
|
98
|
+
<Button size="sm" disabled={!view.words.value || view.on.value} onClick={view.insert}>
|
|
99
|
+
Insert into message
|
|
100
|
+
</Button>{' '}
|
|
101
|
+
<Button emphasis="ghost" tone="neutral" size="sm" onClick={view.clear}>
|
|
102
|
+
Clear
|
|
103
|
+
</Button>
|
|
104
|
+
</div>
|
|
105
|
+
{view.mode.value === 'blocked' && (
|
|
106
|
+
<Alert tone="caution" title="The browser is blocking the microphone">
|
|
107
|
+
Click the lock in the address bar, allow Microphone, then press the mic again. Typing
|
|
108
|
+
still works.
|
|
109
|
+
</Alert>
|
|
110
|
+
)}
|
|
111
|
+
{view.mode.value === 'unsupported' && (
|
|
112
|
+
<Alert tone="info" title="This browser has no dictation">
|
|
113
|
+
Typing still works.
|
|
114
|
+
</Alert>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function speechState({
|
|
121
|
+
initial,
|
|
122
|
+
mics,
|
|
123
|
+
engine,
|
|
124
|
+
onInsert,
|
|
125
|
+
}: {
|
|
126
|
+
initial: () => SpeechInputProps['initial']
|
|
127
|
+
mics: () => SpeechInputProps['mics']
|
|
128
|
+
engine: () => SpeechInputProps['engine']
|
|
129
|
+
onInsert: (words: () => string) => void
|
|
130
|
+
}) {
|
|
131
|
+
const start = untrack(initial)
|
|
132
|
+
const mode = state<DictationState>(start?.state ?? 'idle')
|
|
133
|
+
const final = state(start?.final ?? '')
|
|
134
|
+
const interim = state(start?.interim ?? '')
|
|
135
|
+
const seconds = state(start?.seconds ?? 0)
|
|
136
|
+
const level = state(0)
|
|
137
|
+
const found = state<{ value: string; label: string }[]>(DEFAULT_MIC)
|
|
138
|
+
const mic = state('')
|
|
139
|
+
const options = derived(() => mics() ?? found.value)
|
|
140
|
+
const on = derived(() => mode.value === 'listening')
|
|
141
|
+
const words = derived(() => (final.value + ' ' + interim.value).trim())
|
|
142
|
+
const refs: {
|
|
143
|
+
root?: HTMLElement | undefined
|
|
144
|
+
wave?: HTMLElement | undefined
|
|
145
|
+
live?: DictationEngine | undefined
|
|
146
|
+
clock?: ReturnType<typeof setInterval> | undefined
|
|
147
|
+
} = {}
|
|
148
|
+
useSweep()
|
|
149
|
+
use(
|
|
150
|
+
speechWave,
|
|
151
|
+
() => refs.wave,
|
|
152
|
+
() => level.value,
|
|
153
|
+
)
|
|
154
|
+
const data = { mode, final, interim, seconds, level, found, mic, options, on, words, refs }
|
|
155
|
+
const actions = speechControl({ d: data, mics, engine, onInsert })
|
|
156
|
+
return { ...data, ...actions }
|
|
157
|
+
}
|
|
158
|
+
type SpeechData = {
|
|
159
|
+
mode: ReturnType<typeof state<DictationState>>
|
|
160
|
+
final: ReturnType<typeof state<string>>
|
|
161
|
+
interim: ReturnType<typeof state<string>>
|
|
162
|
+
seconds: ReturnType<typeof state<number>>
|
|
163
|
+
level: ReturnType<typeof state<number>>
|
|
164
|
+
found: ReturnType<typeof state<{ value: string; label: string }[]>>
|
|
165
|
+
mic: ReturnType<typeof state<string>>
|
|
166
|
+
on: { readonly value: boolean }
|
|
167
|
+
words: { readonly value: string }
|
|
168
|
+
refs: {
|
|
169
|
+
root?: HTMLElement | undefined
|
|
170
|
+
wave?: HTMLElement | undefined
|
|
171
|
+
live?: DictationEngine | undefined
|
|
172
|
+
clock?: ReturnType<typeof setInterval> | undefined
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function speechControl({
|
|
176
|
+
d,
|
|
177
|
+
mics,
|
|
178
|
+
engine,
|
|
179
|
+
onInsert,
|
|
180
|
+
}: {
|
|
181
|
+
d: SpeechData
|
|
182
|
+
mics: () => SpeechInputProps['mics']
|
|
183
|
+
engine: () => SpeechInputProps['engine']
|
|
184
|
+
onInsert: (words: () => string) => void
|
|
185
|
+
}) {
|
|
186
|
+
const { mode, final, interim, seconds, level, found, mic, on, words, refs } = d
|
|
187
|
+
const say = (text: string, urgent = false) => announce(refs.root!.ownerDocument, text, urgent)
|
|
188
|
+
const tick = (run: boolean) => {
|
|
189
|
+
clearInterval(refs.clock)
|
|
190
|
+
if (run) {
|
|
191
|
+
seconds.value = 0
|
|
192
|
+
refs.clock = setInterval(() => seconds.value++, 1000)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const events: DictationEvents = {
|
|
196
|
+
onState(s) {
|
|
197
|
+
const was = mode.value
|
|
198
|
+
mode.value = s
|
|
199
|
+
tick(s === 'listening')
|
|
200
|
+
if (s === 'listening') say('Listening.')
|
|
201
|
+
if (s === 'blocked')
|
|
202
|
+
say('Microphone blocked. Allow it from the site settings, then try again.', true)
|
|
203
|
+
if (s === 'unsupported') say('This browser has no dictation.', true)
|
|
204
|
+
if (s === 'idle' && was === 'listening') {
|
|
205
|
+
final.value = words.value
|
|
206
|
+
interim.value = ''
|
|
207
|
+
if (final.value) say('Dictation stopped. Transcript ready.')
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
onTranscript(f, i) {
|
|
211
|
+
final.value = f
|
|
212
|
+
interim.value = i
|
|
213
|
+
},
|
|
214
|
+
onLevel(v) {
|
|
215
|
+
level.value = v
|
|
216
|
+
},
|
|
217
|
+
}
|
|
218
|
+
onMount(() => {
|
|
219
|
+
if (!untrack(mics))
|
|
220
|
+
void listMics(window).then((list) => {
|
|
221
|
+
if (list.length) found.value = list
|
|
222
|
+
})
|
|
223
|
+
onCleanup(() => {
|
|
224
|
+
clearInterval(refs.clock)
|
|
225
|
+
refs.live?.stop()
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
const toggle = () => {
|
|
229
|
+
if (on.value) return refs.live?.stop()
|
|
230
|
+
refs.live ??= (untrack(engine) ?? ((e) => dictation(window, e)))(events)
|
|
231
|
+
final.value = interim.value = ''
|
|
232
|
+
refs.live.start(mic.value || undefined)
|
|
233
|
+
}
|
|
234
|
+
const clear = () => {
|
|
235
|
+
if (on.value) refs.live?.stop()
|
|
236
|
+
final.value = interim.value = ''
|
|
237
|
+
}
|
|
238
|
+
const insert = () => {
|
|
239
|
+
onInsert(() => words.value)
|
|
240
|
+
clear()
|
|
241
|
+
}
|
|
242
|
+
return { say, toggle, clear, insert }
|
|
243
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Sweep, useSweep } from './bits'
|
|
2
|
+
import '../styles'
|
|
3
|
+
import '@kerf-js/veneer-core/styles/app/suggestions.css'
|
|
4
|
+
|
|
5
|
+
/** A prompt offered as a starting point. */
|
|
6
|
+
export type Suggestion = { id?: string; title: string; description?: string | undefined }
|
|
7
|
+
|
|
8
|
+
/** Starter prompts (sweep cards) on an empty conversation, chips after a turn (07 §1.3). Picking one sends it. */
|
|
9
|
+
export function Suggestions({
|
|
10
|
+
items,
|
|
11
|
+
variant,
|
|
12
|
+
onPick,
|
|
13
|
+
...rest
|
|
14
|
+
}: {
|
|
15
|
+
items: Suggestion[]
|
|
16
|
+
variant?: 'cards' | 'chips' | undefined
|
|
17
|
+
onPick?: (s: Suggestion) => void
|
|
18
|
+
[attr: string]: unknown
|
|
19
|
+
}) {
|
|
20
|
+
useSweep()
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
data-scope="suggestions"
|
|
24
|
+
data-variant={variant === 'chips' ? 'chips' : undefined}
|
|
25
|
+
{...rest}
|
|
26
|
+
>
|
|
27
|
+
{items.map((s) => (
|
|
28
|
+
<button key={s.id ?? s.title} type="button" data-sweep="" onClick={() => onPick?.(s)}>
|
|
29
|
+
<Sweep />
|
|
30
|
+
<span>{s.title}</span>
|
|
31
|
+
{s.description !== undefined && <small>{s.description}</small>}
|
|
32
|
+
</button>
|
|
33
|
+
))}
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|