@signalcore/ui 0.1.0 → 1.0.0-beta.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 +896 -513
- package/dist/AgentAbout.d.ts +186 -0
- package/dist/AgentAbout.js +1020 -0
- package/dist/AgentAbout.js.map +1 -0
- package/dist/AgentCard.d.ts +49 -0
- package/dist/AgentCard.js +77 -0
- package/dist/AgentCard.js.map +1 -0
- package/dist/AgentChat.d.ts +233 -0
- package/dist/AgentChat.js +1119 -0
- package/dist/AgentChat.js.map +1 -0
- package/dist/AgentSpace.d.ts +112 -0
- package/dist/AgentSpace.js +339 -0
- package/dist/AgentSpace.js.map +1 -0
- package/dist/AgentTasks.d.ts +48 -0
- package/dist/AgentTasks.js +120 -0
- package/dist/AgentTasks.js.map +1 -0
- package/dist/BrowserView.d.ts +52 -0
- package/dist/BrowserView.js +328 -0
- package/dist/BrowserView.js.map +1 -0
- package/dist/FileView.d.ts +63 -0
- package/dist/FileView.js +449 -0
- package/dist/FileView.js.map +1 -0
- package/dist/Modes.d.ts +13 -0
- package/dist/Modes.js +75 -0
- package/dist/Modes.js.map +1 -0
- package/dist/VoiceCall.d.ts +91 -0
- package/dist/VoiceCall.js +302 -0
- package/dist/VoiceCall.js.map +1 -0
- package/dist/about.d.ts +212 -0
- package/dist/about.js +136 -0
- package/dist/about.js.map +1 -0
- package/dist/agentIcons.d.ts +33 -0
- package/dist/agentIcons.js +36 -0
- package/dist/agentIcons.js.map +1 -0
- package/dist/automation/Automation.d.ts +35 -0
- package/dist/automation/Automation.js +268 -0
- package/dist/automation/Automation.js.map +1 -0
- package/dist/automation/RunView.d.ts +25 -0
- package/dist/automation/RunView.js +187 -0
- package/dist/automation/RunView.js.map +1 -0
- package/dist/automation/cron.d.ts +41 -0
- package/dist/automation/cron.js +169 -0
- package/dist/automation/cron.js.map +1 -0
- package/dist/automation/marks.js +121 -0
- package/dist/automation/marks.js.map +1 -0
- package/dist/automation/messages.d.ts +113 -0
- package/dist/automation/messages.js +113 -0
- package/dist/automation/messages.js.map +1 -0
- package/dist/automation/record.d.ts +47 -0
- package/dist/automation/record.js +177 -0
- package/dist/automation/record.js.map +1 -0
- package/dist/automation/types.d.ts +143 -0
- package/dist/automation/when.d.ts +36 -0
- package/dist/automation/when.js +168 -0
- package/dist/automation/when.js.map +1 -0
- package/dist/blocks.d.ts +185 -0
- package/dist/browser.js +292 -0
- package/dist/browser.js.map +1 -0
- package/dist/call.d.ts +89 -0
- package/dist/call.js +218 -0
- package/dist/call.js.map +1 -0
- package/dist/channelParts.js +26 -0
- package/dist/channelParts.js.map +1 -0
- package/dist/classes.js +8 -3
- package/dist/classes.js.map +1 -0
- package/dist/client.d.ts +146 -54
- package/dist/client.js +204 -1
- package/dist/client.js.map +1 -0
- package/dist/conversationFiles.js +46 -0
- package/dist/conversationFiles.js.map +1 -0
- package/dist/credentials.d.ts +45 -0
- package/dist/credentials.js +98 -0
- package/dist/credentials.js.map +1 -0
- package/dist/dev.js +17 -0
- package/dist/dev.js.map +1 -0
- package/dist/es.d.ts +17 -0
- package/dist/es.js +382 -0
- package/dist/es.js.map +1 -0
- package/dist/files.d.ts +21 -0
- package/dist/files.js +214 -0
- package/dist/files.js.map +1 -0
- package/dist/frames.d.ts +115 -0
- package/dist/frames.js +219 -0
- package/dist/frames.js.map +1 -0
- package/dist/icons.js +29 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +63 -60
- package/dist/index.js +59 -45
- package/dist/kit/AudioPlayer.d.ts +20 -0
- package/dist/kit/AudioPlayer.js +116 -0
- package/dist/kit/AudioPlayer.js.map +1 -0
- package/dist/kit/Button.d.ts +29 -0
- package/dist/kit/Button.js +59 -0
- package/dist/kit/Button.js.map +1 -0
- package/dist/kit/Card.d.ts +16 -0
- package/dist/kit/Card.js +36 -0
- package/dist/kit/Card.js.map +1 -0
- package/dist/kit/Chart.js +152 -0
- package/dist/kit/Chart.js.map +1 -0
- package/dist/kit/Choices.d.ts +21 -0
- package/dist/kit/Choices.js +99 -0
- package/dist/kit/Choices.js.map +1 -0
- package/dist/kit/Combobox.d.ts +26 -0
- package/dist/kit/Combobox.js +190 -0
- package/dist/kit/Combobox.js.map +1 -0
- package/dist/kit/DateField.d.ts +17 -0
- package/dist/kit/DateField.js +133 -0
- package/dist/kit/DateField.js.map +1 -0
- package/dist/kit/Field.d.ts +40 -0
- package/dist/kit/Field.js +98 -0
- package/dist/kit/Field.js.map +1 -0
- package/dist/kit/FileField.d.ts +113 -0
- package/dist/kit/FileField.js +341 -0
- package/dist/kit/FileField.js.map +1 -0
- package/dist/kit/FileMark.d.ts +15 -0
- package/dist/kit/FileMark.js +39 -0
- package/dist/kit/FileMark.js.map +1 -0
- package/dist/kit/Inputs.d.ts +59 -0
- package/dist/kit/Inputs.js +205 -0
- package/dist/kit/Inputs.js.map +1 -0
- package/dist/kit/List.d.ts +47 -0
- package/dist/kit/List.js +85 -0
- package/dist/kit/List.js.map +1 -0
- package/dist/kit/Mark.d.ts +30 -0
- package/dist/kit/Mark.js +27 -0
- package/dist/kit/Mark.js.map +1 -0
- package/dist/kit/MarkStack.d.ts +15 -0
- package/dist/kit/MarkStack.js +26 -0
- package/dist/kit/MarkStack.js.map +1 -0
- package/dist/kit/Note.d.ts +11 -0
- package/dist/kit/Note.js +31 -0
- package/dist/kit/Note.js.map +1 -0
- package/dist/kit/Popover.js +90 -0
- package/dist/kit/Popover.js.map +1 -0
- package/dist/kit/RangeField.d.ts +14 -0
- package/dist/kit/RangeField.js +47 -0
- package/dist/kit/RangeField.js.map +1 -0
- package/dist/kit/RatingField.d.ts +14 -0
- package/dist/kit/RatingField.js +50 -0
- package/dist/kit/RatingField.js.map +1 -0
- package/dist/kit/Stat.d.ts +26 -0
- package/dist/kit/Stat.js +46 -0
- package/dist/kit/Stat.js.map +1 -0
- package/dist/kit/Switch.d.ts +14 -0
- package/dist/kit/Switch.js +21 -0
- package/dist/kit/Switch.js.map +1 -0
- package/dist/kit/Tag.d.ts +16 -0
- package/dist/kit/Tag.js +20 -0
- package/dist/kit/Tag.js.map +1 -0
- package/dist/kit/Tile.d.ts +34 -0
- package/dist/kit/Tile.js +52 -0
- package/dist/kit/Tile.js.map +1 -0
- package/dist/kit/TimeField.d.ts +31 -0
- package/dist/kit/TimeField.js +109 -0
- package/dist/kit/TimeField.js.map +1 -0
- package/dist/kit/context.d.ts +22 -0
- package/dist/kit/context.js +46 -0
- package/dist/kit/context.js.map +1 -0
- package/dist/kit/dates.d.ts +14 -0
- package/dist/kit/dates.js +129 -0
- package/dist/kit/dates.js.map +1 -0
- package/dist/kit/messages.d.ts +99 -0
- package/dist/kit/messages.js +66 -0
- package/dist/kit/messages.js.map +1 -0
- package/dist/kit/numbers.d.ts +12 -0
- package/dist/kit/numbers.js +40 -0
- package/dist/kit/numbers.js.map +1 -0
- package/dist/kit/options.d.ts +10 -0
- package/dist/kit/options.js +23 -0
- package/dist/kit/options.js.map +1 -0
- package/dist/kit/uploads.d.ts +42 -0
- package/dist/kit/uploads.js +165 -0
- package/dist/kit/uploads.js.map +1 -0
- package/dist/kit/waveform.js +76 -0
- package/dist/kit/waveform.js.map +1 -0
- package/dist/locale.d.ts +1 -0
- package/dist/locale.js +1 -0
- package/dist/markdown.js +84 -0
- package/dist/markdown.js.map +1 -0
- package/dist/marks.js +217 -0
- package/dist/marks.js.map +1 -0
- package/dist/reveal.js +48 -0
- package/dist/reveal.js.map +1 -0
- package/dist/stepGlyphs.js +62 -0
- package/dist/stepGlyphs.js.map +1 -0
- package/dist/surface/Form.js +264 -0
- package/dist/surface/Form.js.map +1 -0
- package/dist/surface/Markdown.js +42 -0
- package/dist/surface/Markdown.js.map +1 -0
- package/dist/surface/Surface.d.ts +31 -17
- package/dist/surface/Surface.js +480 -57
- package/dist/surface/Surface.js.map +1 -0
- package/dist/surface/scope.d.ts +32 -0
- package/dist/surface/scope.js +23 -0
- package/dist/surface/scope.js.map +1 -0
- package/dist/surface/values.d.ts +44 -0
- package/dist/surface/values.js +237 -0
- package/dist/surface/values.js.map +1 -0
- package/dist/tint.d.ts +10 -0
- package/dist/tint.js +19 -0
- package/dist/tint.js.map +1 -0
- package/dist/types.d.ts +534 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/useAgentFace.d.ts +18 -0
- package/dist/useAgentFace.js +45 -0
- package/dist/useAgentFace.js.map +1 -0
- package/dist/useCall.d.ts +39 -0
- package/dist/useCall.js +273 -0
- package/dist/useCall.js.map +1 -0
- package/dist/useConversation.d.ts +77 -0
- package/dist/useConversation.js +523 -0
- package/dist/useConversation.js.map +1 -0
- package/dist/useDictation.d.ts +17 -0
- package/dist/useDictation.js +68 -0
- package/dist/useDictation.js.map +1 -0
- package/dist/useLive.d.ts +26 -0
- package/dist/useLive.js +88 -0
- package/dist/useLive.js.map +1 -0
- package/dist/usePolled.js +68 -0
- package/dist/usePolled.js.map +1 -0
- package/dist/voice/Orb.d.ts +10 -9
- package/dist/voice/Orb.js +43 -39
- package/dist/voice/Orb.js.map +1 -0
- package/dist/voice/StillOrb.js +33 -0
- package/dist/voice/StillOrb.js.map +1 -0
- package/dist/voice/WebGLOrb.js +98 -0
- package/dist/voice/WebGLOrb.js.map +1 -0
- package/dist/voice/fluidDots.js +161 -0
- package/dist/voice/fluidDots.js.map +1 -0
- package/dist/voice/motion.js +84 -0
- package/dist/voice/motion.js.map +1 -0
- package/dist/voice/orbs.d.ts +32 -0
- package/dist/voice/orbs.js +16 -0
- package/dist/voice/orbs.js.map +1 -0
- package/dist/voice/useReducedMotion.js +16 -16
- package/dist/voice/useReducedMotion.js.map +1 -0
- package/dist/voice/wave.js +116 -0
- package/dist/voice/wave.js.map +1 -0
- package/dist/voice/webgl.js +177 -0
- package/dist/voice/webgl.js.map +1 -0
- package/dist/widget.js +284 -8
- package/package.json +49 -39
- package/src/AgentAbout.tsx +1621 -0
- package/src/AgentCard.tsx +123 -0
- package/src/AgentChat.tsx +1795 -0
- package/src/AgentSpace.tsx +540 -0
- package/src/AgentTasks.tsx +163 -0
- package/src/BrowserView.tsx +442 -0
- package/src/FileView.tsx +620 -0
- package/src/Modes.tsx +112 -0
- package/src/VoiceCall.tsx +411 -0
- package/src/about.ts +355 -0
- package/src/agentIcons.ts +56 -0
- package/src/automation/Automation.tsx +308 -0
- package/src/automation/RunView.tsx +213 -0
- package/src/automation/cron.ts +196 -0
- package/src/automation/marks.tsx +144 -0
- package/src/automation/messages.ts +231 -0
- package/src/automation/record.ts +206 -0
- package/src/automation/types.ts +146 -0
- package/src/automation/when.ts +195 -0
- package/src/blocks.ts +249 -0
- package/src/browser.ts +334 -0
- package/src/call.ts +300 -0
- package/src/channelParts.ts +17 -0
- package/src/classes.ts +10 -0
- package/src/client.ts +397 -0
- package/src/conversationFiles.ts +54 -0
- package/src/credentials.ts +158 -0
- package/src/dev.ts +20 -0
- package/src/es.ts +423 -0
- package/src/files.ts +238 -0
- package/src/frames.ts +291 -0
- package/src/icons.tsx +49 -0
- package/src/index.ts +270 -0
- package/src/kit/AudioPlayer.tsx +129 -0
- package/src/kit/Button.tsx +97 -0
- package/src/kit/Card.tsx +47 -0
- package/src/kit/Chart.tsx +129 -0
- package/src/kit/Choices.tsx +131 -0
- package/src/kit/Combobox.tsx +247 -0
- package/src/kit/DateField.tsx +156 -0
- package/src/kit/Field.tsx +137 -0
- package/src/kit/FileField.tsx +492 -0
- package/src/kit/FileMark.tsx +56 -0
- package/src/kit/Inputs.tsx +250 -0
- package/src/kit/List.tsx +135 -0
- package/src/kit/Mark.tsx +64 -0
- package/src/kit/MarkStack.tsx +29 -0
- package/src/kit/Note.tsx +42 -0
- package/src/kit/Popover.tsx +121 -0
- package/src/kit/RangeField.tsx +53 -0
- package/src/kit/RatingField.tsx +62 -0
- package/src/kit/Stat.tsx +60 -0
- package/src/kit/Switch.tsx +28 -0
- package/src/kit/Tag.tsx +32 -0
- package/src/kit/Tile.tsx +74 -0
- package/src/kit/TimeField.tsx +157 -0
- package/src/kit/context.tsx +246 -0
- package/src/kit/dates.ts +150 -0
- package/src/kit/messages.ts +160 -0
- package/src/kit/numbers.ts +44 -0
- package/src/kit/options.ts +30 -0
- package/src/kit/uploads.ts +244 -0
- package/src/kit/waveform.ts +84 -0
- package/src/locale.ts +6 -0
- package/src/markdown.ts +69 -0
- package/src/marks.tsx +328 -0
- package/src/reveal.ts +52 -0
- package/src/stepGlyphs.ts +83 -0
- package/src/styles.css +6961 -0
- package/src/surface/Form.tsx +299 -0
- package/src/surface/Markdown.tsx +55 -0
- package/src/surface/Surface.tsx +605 -0
- package/src/surface/scope.ts +82 -0
- package/src/surface/values.ts +361 -0
- package/src/tint.ts +14 -0
- package/src/types.ts +596 -0
- package/src/useAgentFace.ts +47 -0
- package/src/useCall.ts +292 -0
- package/src/useConversation.ts +627 -0
- package/src/useDictation.ts +83 -0
- package/src/useLive.ts +115 -0
- package/src/usePolled.ts +60 -0
- package/src/voice/Orb.tsx +45 -0
- package/src/voice/StillOrb.tsx +29 -0
- package/src/voice/WebGLOrb.tsx +98 -0
- package/src/voice/fluidDots.tsx +171 -0
- package/src/voice/motion.ts +112 -0
- package/src/voice/orbs.ts +39 -0
- package/src/voice/useReducedMotion.ts +24 -0
- package/src/voice/wave.tsx +129 -0
- package/src/voice/webgl.ts +209 -0
- package/src/widget/css.d.ts +5 -0
- package/src/widget/element.tsx +535 -0
- package/src/widget/index.ts +10 -0
- package/src/widget/mount.ts +27 -0
- package/src/widget/widget.css +253 -0
- package/dist/SignalcoreProvider.d.ts +0 -113
- package/dist/SignalcoreProvider.js +0 -84
- package/dist/automations/AppMarks.d.ts +0 -11
- package/dist/automations/AppMarks.js +0 -18
- package/dist/automations/AutomationCard.d.ts +0 -27
- package/dist/automations/AutomationCard.js +0 -53
- package/dist/automations/AutomationsWindow.d.ts +0 -38
- package/dist/automations/AutomationsWindow.js +0 -57
- package/dist/automations/Card.d.ts +0 -46
- package/dist/automations/Card.js +0 -45
- package/dist/automations/ScheduleMarks.d.ts +0 -13
- package/dist/automations/ScheduleMarks.js +0 -24
- package/dist/automations/presentationIcons.d.ts +0 -7
- package/dist/automations/presentationIcons.js +0 -67
- package/dist/automations/schedule.d.ts +0 -25
- package/dist/automations/schedule.js +0 -59
- package/dist/automations/time.d.ts +0 -3
- package/dist/automations/time.js +0 -25
- package/dist/browser/BrowserView.d.ts +0 -43
- package/dist/browser/BrowserView.js +0 -94
- package/dist/browser/room.d.ts +0 -21
- package/dist/browser/room.js +0 -33
- package/dist/browser/useBrowserSession.d.ts +0 -17
- package/dist/browser/useBrowserSession.js +0 -67
- package/dist/builder/BuilderChat.d.ts +0 -32
- package/dist/builder/BuilderChat.js +0 -41
- package/dist/builder/BuilderTranscript.d.ts +0 -49
- package/dist/builder/BuilderTranscript.js +0 -62
- package/dist/builder/StatusLine.d.ts +0 -8
- package/dist/builder/StatusLine.js +0 -17
- package/dist/builder/answer.d.ts +0 -7
- package/dist/builder/answer.js +0 -8
- package/dist/builder/blocks.d.ts +0 -31
- package/dist/builder/blocks.js +0 -74
- package/dist/builder/items.d.ts +0 -15
- package/dist/builder/items.js +0 -21
- package/dist/builder/steps.d.ts +0 -20
- package/dist/builder/steps.js +0 -120
- package/dist/builder/time.d.ts +0 -4
- package/dist/builder/time.js +0 -24
- package/dist/builder/useBuildSession.d.ts +0 -36
- package/dist/builder/useBuildSession.js +0 -130
- package/dist/builder/workingOn.d.ts +0 -7
- package/dist/builder/workingOn.js +0 -15
- package/dist/chat/AgentChat.d.ts +0 -37
- package/dist/chat/AgentChat.js +0 -21
- package/dist/chat/ChatView.d.ts +0 -25
- package/dist/chat/ChatView.js +0 -34
- package/dist/chat/Composer.d.ts +0 -20
- package/dist/chat/Composer.js +0 -22
- package/dist/chat/MessageRow.d.ts +0 -22
- package/dist/chat/MessageRow.js +0 -32
- package/dist/chat/arrival.d.ts +0 -15
- package/dist/chat/arrival.js +0 -25
- package/dist/chat/history.d.ts +0 -24
- package/dist/chat/history.js +0 -45
- package/dist/chat/moments.d.ts +0 -25
- package/dist/chat/moments.js +0 -72
- package/dist/chat/types.d.ts +0 -12
- package/dist/chat/types.js +0 -1
- package/dist/chat/useComposer.d.ts +0 -46
- package/dist/chat/useComposer.js +0 -62
- package/dist/chat/useConversation.d.ts +0 -35
- package/dist/chat/useConversation.js +0 -71
- package/dist/chat/useStickToBottom.d.ts +0 -9
- package/dist/chat/useStickToBottom.js +0 -33
- package/dist/chat/useTurns.d.ts +0 -49
- package/dist/chat/useTurns.js +0 -111
- package/dist/classes.d.ts +0 -2
- package/dist/development.d.ts +0 -5
- package/dist/development.js +0 -8
- package/dist/flow/FlowWindow.d.ts +0 -42
- package/dist/flow/FlowWindow.js +0 -126
- package/dist/flow/index.d.ts +0 -16
- package/dist/flow/index.js +0 -16
- package/dist/flow/kinds.d.ts +0 -23
- package/dist/flow/kinds.js +0 -48
- package/dist/flow/map.d.ts +0 -44
- package/dist/flow/map.js +0 -225
- package/dist/flow/nodePaths.d.ts +0 -7
- package/dist/flow/nodePaths.js +0 -17
- package/dist/flow/relations.d.ts +0 -42
- package/dist/flow/relations.js +0 -174
- package/dist/host.d.ts +0 -124
- package/dist/host.js +0 -1
- package/dist/live/LiveView.d.ts +0 -28
- package/dist/live/LiveView.js +0 -55
- package/dist/live/capture.d.ts +0 -20
- package/dist/live/capture.js +0 -100
- package/dist/live/follow.d.ts +0 -26
- package/dist/live/follow.js +0 -72
- package/dist/live/paint.d.ts +0 -13
- package/dist/live/paint.js +0 -77
- package/dist/live/useLiveStream.d.ts +0 -16
- package/dist/live/useLiveStream.js +0 -57
- package/dist/look.d.ts +0 -33
- package/dist/look.js +0 -241
- package/dist/messages/en.d.ts +0 -3
- package/dist/messages/en.js +0 -251
- package/dist/messages/es.d.ts +0 -3
- package/dist/messages/es.js +0 -251
- package/dist/messages/index.d.ts +0 -16
- package/dist/messages/index.js +0 -33
- package/dist/messages/types.d.ts +0 -246
- package/dist/messages/types.js +0 -1
- package/dist/parts/Button.d.ts +0 -18
- package/dist/parts/Button.js +0 -17
- package/dist/parts/Icon.d.ts +0 -39
- package/dist/parts/Icon.js +0 -37
- package/dist/parts/Input.d.ts +0 -6
- package/dist/parts/Input.js +0 -11
- package/dist/parts/Spinner.d.ts +0 -2
- package/dist/parts/Spinner.js +0 -7
- package/dist/patterns.d.ts +0 -15
- package/dist/patterns.js +0 -5
- package/dist/presets.d.ts +0 -82
- package/dist/presets.js +0 -81
- package/dist/primitives.d.ts +0 -22
- package/dist/primitives.js +0 -58
- package/dist/request/RequestCard.d.ts +0 -34
- package/dist/request/RequestCard.js +0 -101
- package/dist/request/approval/ApprovalPreview.d.ts +0 -5
- package/dist/request/approval/ApprovalPreview.js +0 -27
- package/dist/request/approval/shapes.d.ts +0 -32
- package/dist/request/approval/shapes.js +0 -68
- package/dist/request/apps.d.ts +0 -11
- package/dist/request/apps.js +0 -27
- package/dist/request/cards.d.ts +0 -12
- package/dist/request/cards.js +0 -24
- package/dist/request/deliver.d.ts +0 -12
- package/dist/request/deliver.js +0 -21
- package/dist/request/handOver.d.ts +0 -18
- package/dist/request/handOver.js +0 -33
- package/dist/request/kinds/Approval.d.ts +0 -3
- package/dist/request/kinds/Approval.js +0 -9
- package/dist/request/kinds/Choice.d.ts +0 -3
- package/dist/request/kinds/Choice.js +0 -8
- package/dist/request/kinds/Connect.d.ts +0 -9
- package/dist/request/kinds/Connect.js +0 -119
- package/dist/request/kinds/FreeText.d.ts +0 -3
- package/dist/request/kinds/FreeText.js +0 -20
- package/dist/request/kinds/HandOver.d.ts +0 -13
- package/dist/request/kinds/HandOver.js +0 -20
- package/dist/request/kinds/Secret.d.ts +0 -7
- package/dist/request/kinds/Secret.js +0 -49
- package/dist/request/kinds/Upload.d.ts +0 -6
- package/dist/request/kinds/Upload.js +0 -47
- package/dist/request/types.d.ts +0 -83
- package/dist/request/types.js +0 -1
- package/dist/safeUrl.d.ts +0 -6
- package/dist/safeUrl.js +0 -8
- package/dist/stream/builder.d.ts +0 -176
- package/dist/stream/builder.js +0 -202
- package/dist/stream/reduce.d.ts +0 -51
- package/dist/stream/reduce.js +0 -58
- package/dist/stream/untilAborted.d.ts +0 -7
- package/dist/stream/untilAborted.js +0 -32
- package/dist/stream/useRunStream.d.ts +0 -26
- package/dist/stream/useRunStream.js +0 -137
- package/dist/styles.css +0 -2318
- package/dist/surface/HostNode.d.ts +0 -14
- package/dist/surface/HostNode.js +0 -30
- package/dist/surface/Node.d.ts +0 -7
- package/dist/surface/Node.js +0 -49
- package/dist/surface/SurfaceBoundary.d.ts +0 -26
- package/dist/surface/SurfaceBoundary.js +0 -20
- package/dist/surface/bindings.d.ts +0 -14
- package/dist/surface/bindings.js +0 -37
- package/dist/surface/check.d.ts +0 -27
- package/dist/surface/check.js +0 -102
- package/dist/surface/format.d.ts +0 -10
- package/dist/surface/format.js +0 -32
- package/dist/surface/hosts.d.ts +0 -6
- package/dist/surface/hosts.js +0 -11
- package/dist/surface/scene.d.ts +0 -21
- package/dist/surface/scene.js +0 -8
- package/dist/surface/templates/Browser.d.ts +0 -6
- package/dist/surface/templates/Browser.js +0 -11
- package/dist/surface/templates/Chart.d.ts +0 -6
- package/dist/surface/templates/Chart.js +0 -13
- package/dist/surface/templates/Choices.d.ts +0 -3
- package/dist/surface/templates/Choices.js +0 -12
- package/dist/surface/templates/Form.d.ts +0 -3
- package/dist/surface/templates/Form.js +0 -44
- package/dist/surface/templates/KeyValue.d.ts +0 -3
- package/dist/surface/templates/KeyValue.js +0 -7
- package/dist/surface/templates/Layout.d.ts +0 -5
- package/dist/surface/templates/Layout.js +0 -16
- package/dist/surface/templates/Live.d.ts +0 -6
- package/dist/surface/templates/Live.js +0 -9
- package/dist/surface/templates/Media.d.ts +0 -5
- package/dist/surface/templates/Media.js +0 -13
- package/dist/surface/templates/Slots.d.ts +0 -3
- package/dist/surface/templates/Slots.js +0 -19
- package/dist/surface/templates/Table.d.ts +0 -3
- package/dist/surface/templates/Table.js +0 -12
- package/dist/surface/templates/Text.d.ts +0 -4
- package/dist/surface/templates/Text.js +0 -15
- package/dist/surface/templates/index.d.ts +0 -7
- package/dist/surface/templates/index.js +0 -32
- package/dist/surface/types.d.ts +0 -68
- package/dist/surface/types.js +0 -6
- package/dist/theme.d.ts +0 -62
- package/dist/theme.js +0 -9
- package/dist/useTokens.d.ts +0 -7
- package/dist/useTokens.js +0 -41
- package/dist/voice/VoiceWindow.d.ts +0 -18
- package/dist/voice/VoiceWindow.js +0 -35
- package/dist/voice/index.d.ts +0 -13
- package/dist/voice/index.js +0 -12
- package/dist/voice/meter.d.ts +0 -16
- package/dist/voice/meter.js +0 -52
- package/dist/voice/orbColors.d.ts +0 -16
- package/dist/voice/orbColors.js +0 -75
- package/dist/voice/pushable.d.ts +0 -16
- package/dist/voice/pushable.js +0 -56
- package/dist/voice/useDictation.d.ts +0 -24
- package/dist/voice/useDictation.js +0 -60
- package/dist/voice/useReducedMotion.d.ts +0 -5
- package/dist/voice/useVoice.d.ts +0 -70
- package/dist/voice/useVoice.js +0 -197
- package/dist/voice/useVoicePrimitives.d.ts +0 -7
- package/dist/voice/useVoicePrimitives.js +0 -11
- package/dist/voice/voice.d.ts +0 -55
- package/dist/voice/voice.js +0 -9
- package/dist/voice/webSpeech.d.ts +0 -33
- package/dist/voice/webSpeech.js +0 -258
- package/dist/widget.js.map +0 -1
- package/dist/windows/AgentSpace.d.ts +0 -78
- package/dist/windows/AgentSpace.js +0 -135
- package/dist/windows/Captions.d.ts +0 -13
- package/dist/windows/Captions.js +0 -22
- package/dist/windows/Dock.d.ts +0 -37
- package/dist/windows/Dock.js +0 -22
- package/dist/windows/Journal.d.ts +0 -15
- package/dist/windows/Journal.js +0 -19
- package/dist/windows/KindMark.d.ts +0 -7
- package/dist/windows/KindMark.js +0 -31
- package/dist/windows/Pending.d.ts +0 -8
- package/dist/windows/Pending.js +0 -17
- package/dist/windows/Stage.d.ts +0 -18
- package/dist/windows/Stage.js +0 -21
- package/dist/windows/StatusLabel.d.ts +0 -9
- package/dist/windows/StatusLabel.js +0 -7
- package/dist/windows/Strip.d.ts +0 -17
- package/dist/windows/Strip.js +0 -42
- package/dist/windows/SurfaceWindow.d.ts +0 -20
- package/dist/windows/SurfaceWindow.js +0 -12
- package/dist/windows/WindowFrame.d.ts +0 -23
- package/dist/windows/WindowFrame.js +0 -22
- package/dist/windows/hearing.d.ts +0 -11
- package/dist/windows/hearing.js +0 -26
- package/dist/windows/kinds.d.ts +0 -47
- package/dist/windows/kinds.js +0 -28
- package/dist/windows/reduce.d.ts +0 -98
- package/dist/windows/reduce.js +0 -151
- package/dist/windows/registry.d.ts +0 -18
- package/dist/windows/registry.js +0 -61
- package/dist/windows/reveal.d.ts +0 -9
- package/dist/windows/reveal.js +0 -6
- package/dist/windows/space.d.ts +0 -21
- package/dist/windows/space.js +0 -6
- package/dist/windows/status.d.ts +0 -11
- package/dist/windows/status.js +0 -30
- package/dist/windows/types.d.ts +0 -15
- package/dist/windows/types.js +0 -1
- package/dist/windows/useLoaded.d.ts +0 -44
- package/dist/windows/useLoaded.js +0 -58
- package/dist/windows/useUnread.d.ts +0 -7
- package/dist/windows/useUnread.js +0 -21
- package/dist/windows/useWindows.d.ts +0 -70
- package/dist/windows/useWindows.js +0 -60
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { PauseIcon, PlayIcon } from "@phosphor-icons/react";
|
|
2
|
+
import { useRef, useState, type ReactEventHandler } from "react";
|
|
3
|
+
|
|
4
|
+
import { joined, useKit, useParts } from "./context";
|
|
5
|
+
import { useWaveform } from "./waveform";
|
|
6
|
+
|
|
7
|
+
export interface AudioPlayerProps {
|
|
8
|
+
src: string | undefined;
|
|
9
|
+
/** What it is, for screen readers: a voice note, a call's recording, a file's name. */
|
|
10
|
+
label: string;
|
|
11
|
+
onError?: ReactEventHandler<HTMLAudioElement> | undefined;
|
|
12
|
+
/** In a bar, beside other tools: a smaller play, a shorter waveform. */
|
|
13
|
+
compact?: boolean | undefined;
|
|
14
|
+
className?: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** How many bars the waveform draws, and how high an even one stands while it is read. */
|
|
18
|
+
const BARS = { full: 44, compact: 24 } as const;
|
|
19
|
+
const EVEN = 0.35;
|
|
20
|
+
/** The quietest bar still shows: silence reads as a line, not as nothing. */
|
|
21
|
+
const LEAST = 0.12;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Audio, played the kit's way: a quiet round play and pause, the audio's own waveform (its bars
|
|
25
|
+
* light up as it plays; dragging through it seeks), and its time (how long it is until it plays,
|
|
26
|
+
* then how far it is). The browser's own element plays it, never shown; a length the file
|
|
27
|
+
* doesn't tell yet is learnt as it plays.
|
|
28
|
+
*/
|
|
29
|
+
export function AudioPlayer({ src, label, onError, compact, className }: AudioPlayerProps) {
|
|
30
|
+
const part = useParts();
|
|
31
|
+
const { messages: words } = useKit();
|
|
32
|
+
const audio = useRef<HTMLAudioElement>(null);
|
|
33
|
+
const [playing, setPlaying] = useState(false);
|
|
34
|
+
const [at, setAt] = useState(0);
|
|
35
|
+
const [length, setLength] = useState<number | null>(null);
|
|
36
|
+
const bars = compact ? BARS.compact : BARS.full;
|
|
37
|
+
const wave = useWaveform(src, bars);
|
|
38
|
+
const learn = () => {
|
|
39
|
+
const seconds = audio.current?.duration;
|
|
40
|
+
if (seconds !== undefined && Number.isFinite(seconds)) setLength(seconds);
|
|
41
|
+
};
|
|
42
|
+
// The element's length, else the decoded one (an Ogg tells it only once played through).
|
|
43
|
+
const seconds = length ?? wave?.seconds ?? null;
|
|
44
|
+
const played = seconds ? Math.min(1, at / seconds) : 0;
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
role="group"
|
|
48
|
+
aria-label={label}
|
|
49
|
+
className={joined(
|
|
50
|
+
part("sc-audio", ...(compact ? (["sc-audio--compact"] as const) : [])),
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
53
|
+
>
|
|
54
|
+
<audio
|
|
55
|
+
ref={audio}
|
|
56
|
+
src={src}
|
|
57
|
+
preload="metadata"
|
|
58
|
+
onLoadedMetadata={learn}
|
|
59
|
+
onDurationChange={learn}
|
|
60
|
+
onPlay={() => {
|
|
61
|
+
setPlaying(true);
|
|
62
|
+
}}
|
|
63
|
+
onPause={() => {
|
|
64
|
+
setPlaying(false);
|
|
65
|
+
}}
|
|
66
|
+
onEnded={() => {
|
|
67
|
+
setPlaying(false);
|
|
68
|
+
setAt(0);
|
|
69
|
+
}}
|
|
70
|
+
onTimeUpdate={() => {
|
|
71
|
+
learn();
|
|
72
|
+
setAt(audio.current?.currentTime ?? 0);
|
|
73
|
+
}}
|
|
74
|
+
onError={onError}
|
|
75
|
+
/>
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
className={part("sc-audio__play")}
|
|
79
|
+
aria-label={playing ? words.pause : words.play}
|
|
80
|
+
disabled={src === undefined}
|
|
81
|
+
onClick={() => {
|
|
82
|
+
const element = audio.current;
|
|
83
|
+
if (element === null) return;
|
|
84
|
+
if (element.paused) void element.play();
|
|
85
|
+
else element.pause();
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
{playing ? <PauseIcon weight="fill" /> : <PlayIcon weight="fill" />}
|
|
89
|
+
</button>
|
|
90
|
+
<div className={part("sc-audio__wave")}>
|
|
91
|
+
{Array.from({ length: bars }, (_, index) => (
|
|
92
|
+
<span
|
|
93
|
+
key={index}
|
|
94
|
+
aria-hidden
|
|
95
|
+
data-played={index / bars < played ? "" : undefined}
|
|
96
|
+
style={{ height: `${Math.max(LEAST, wave?.heights[index] ?? EVEN) * 100}%` }}
|
|
97
|
+
/>
|
|
98
|
+
))}
|
|
99
|
+
<input
|
|
100
|
+
type="range"
|
|
101
|
+
min={0}
|
|
102
|
+
max={seconds ?? 0}
|
|
103
|
+
step="any"
|
|
104
|
+
value={Math.min(at, seconds ?? 0)}
|
|
105
|
+
disabled={seconds === null}
|
|
106
|
+
aria-label={words.position}
|
|
107
|
+
aria-valuetext={clock(at)}
|
|
108
|
+
onChange={(event) => {
|
|
109
|
+
const seconds = Number(event.target.value);
|
|
110
|
+
if (audio.current !== null) audio.current.currentTime = seconds;
|
|
111
|
+
setAt(seconds);
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
<span className={part("sc-audio__time")}>
|
|
116
|
+
{clock(playing || at > 0 ? at : (seconds ?? 0))}
|
|
117
|
+
</span>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Seconds as a player says them: 0:07, 1:42, 1:02:05. */
|
|
123
|
+
export function clock(seconds: number): string {
|
|
124
|
+
const whole = Math.max(0, Math.floor(seconds));
|
|
125
|
+
const hours = Math.floor(whole / 3600);
|
|
126
|
+
const minutes = Math.floor((whole % 3600) / 60);
|
|
127
|
+
const rest = String(whole % 60).padStart(2, "0");
|
|
128
|
+
return hours > 0 ? `${hours}:${String(minutes).padStart(2, "0")}:${rest}` : `${minutes}:${rest}`;
|
|
129
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ArrowUpRightIcon, type Icon } from "@phosphor-icons/react";
|
|
2
|
+
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import { joined, useParts } from "./context";
|
|
5
|
+
|
|
6
|
+
export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
7
|
+
/**
|
|
8
|
+
* primary: the ink, for the one that matters; neutral: a hairline; danger: what can't be
|
|
9
|
+
* undone; ghost: bare until the pointer is on it (a row's ⋯).
|
|
10
|
+
*/
|
|
11
|
+
tone?: "primary" | "neutral" | "danger" | "ghost" | undefined;
|
|
12
|
+
/** sm: 28px, for a row or a line of words. */
|
|
13
|
+
size?: "md" | "sm" | undefined;
|
|
14
|
+
/** A glyph before the words; alone, the button is a square and `aria-label` names it. */
|
|
15
|
+
icon?: Icon | undefined;
|
|
16
|
+
/** A page to open apart instead: the button is a link, an arrow after its words. */
|
|
17
|
+
href?: string | undefined;
|
|
18
|
+
/** With `href`, the link saves what it points at under this name instead of opening it. */
|
|
19
|
+
download?: string | undefined;
|
|
20
|
+
/** It was the one pressed: ringed in the accent. */
|
|
21
|
+
pressed?: boolean | undefined;
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A pill to press: a hairline by default, filled with the ink for the main action, the danger
|
|
27
|
+
* tone for what can't be undone, bare for a quiet control. With `href` it is a link that opens
|
|
28
|
+
* its page apart, never sending this page's address along; with `download` too, one that saves.
|
|
29
|
+
*/
|
|
30
|
+
export function Button({
|
|
31
|
+
tone = "neutral",
|
|
32
|
+
size = "md",
|
|
33
|
+
icon: Glyph,
|
|
34
|
+
href,
|
|
35
|
+
download,
|
|
36
|
+
pressed,
|
|
37
|
+
className,
|
|
38
|
+
children,
|
|
39
|
+
type = "button",
|
|
40
|
+
part: own,
|
|
41
|
+
...rest
|
|
42
|
+
}: ButtonProps) {
|
|
43
|
+
const part = useParts();
|
|
44
|
+
// Its part names for a page's `::part()`: the caller's own, then the kit's.
|
|
45
|
+
const named = joined(own, "button", `button-${tone}`);
|
|
46
|
+
const classes = joined(
|
|
47
|
+
part(
|
|
48
|
+
"sc-button",
|
|
49
|
+
`sc-button--${tone}`,
|
|
50
|
+
...(size === "sm" ? (["sc-button--sm"] as const) : []),
|
|
51
|
+
...(children === undefined ? (["sc-button--icon"] as const) : []),
|
|
52
|
+
),
|
|
53
|
+
className,
|
|
54
|
+
);
|
|
55
|
+
if (href !== undefined && download !== undefined) {
|
|
56
|
+
return (
|
|
57
|
+
<a
|
|
58
|
+
href={href}
|
|
59
|
+
download={download}
|
|
60
|
+
aria-label={rest["aria-label"]}
|
|
61
|
+
part={named}
|
|
62
|
+
className={classes}
|
|
63
|
+
>
|
|
64
|
+
{Glyph && <Glyph aria-hidden weight="bold" />}
|
|
65
|
+
{children}
|
|
66
|
+
</a>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (href !== undefined) {
|
|
70
|
+
return (
|
|
71
|
+
<a
|
|
72
|
+
href={href}
|
|
73
|
+
target="_blank"
|
|
74
|
+
rel="noopener noreferrer"
|
|
75
|
+
aria-label={rest["aria-label"]}
|
|
76
|
+
part={named}
|
|
77
|
+
className={classes}
|
|
78
|
+
>
|
|
79
|
+
{Glyph && <Glyph aria-hidden weight="bold" />}
|
|
80
|
+
{children}
|
|
81
|
+
<ArrowUpRightIcon aria-hidden weight="bold" />
|
|
82
|
+
</a>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return (
|
|
86
|
+
<button
|
|
87
|
+
type={type}
|
|
88
|
+
aria-pressed={pressed || undefined}
|
|
89
|
+
part={named}
|
|
90
|
+
className={classes}
|
|
91
|
+
{...rest}
|
|
92
|
+
>
|
|
93
|
+
{Glyph && <Glyph aria-hidden weight="bold" />}
|
|
94
|
+
{children}
|
|
95
|
+
</button>
|
|
96
|
+
);
|
|
97
|
+
}
|
package/src/kit/Card.tsx
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { joined, useParts } from "./context";
|
|
4
|
+
import { Mark } from "./Mark";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Things under a title and a quieter line, set apart in one hairline box lifted a hair. With
|
|
8
|
+
* `image`, the head starts with it, bare, as `Mark` draws a logo.
|
|
9
|
+
*/
|
|
10
|
+
export function Card({
|
|
11
|
+
title,
|
|
12
|
+
subtitle,
|
|
13
|
+
image,
|
|
14
|
+
className,
|
|
15
|
+
children,
|
|
16
|
+
}: {
|
|
17
|
+
title?: ReactNode;
|
|
18
|
+
subtitle?: ReactNode;
|
|
19
|
+
/** A logo or a picture at the head's start. */
|
|
20
|
+
image?: string | undefined;
|
|
21
|
+
className?: string | undefined;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}) {
|
|
24
|
+
const part = useParts();
|
|
25
|
+
const words = (title !== undefined || subtitle !== undefined) && (
|
|
26
|
+
<div className={part("sc-panel__heading")}>
|
|
27
|
+
{title !== undefined && <h3 className={part("sc-panel__title")}>{title}</h3>}
|
|
28
|
+
{subtitle !== undefined && <p className={part("sc-panel__subtitle")}>{subtitle}</p>}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
return (
|
|
32
|
+
<section part="card" className={joined(part("sc-panel"), className)}>
|
|
33
|
+
{(words !== false || image !== undefined) && (
|
|
34
|
+
<header
|
|
35
|
+
className={part(
|
|
36
|
+
"sc-panel__head",
|
|
37
|
+
...(image !== undefined ? (["sc-panel__head--image"] as const) : []),
|
|
38
|
+
)}
|
|
39
|
+
>
|
|
40
|
+
{image !== undefined && <Mark src={image} size={44} />}
|
|
41
|
+
{words}
|
|
42
|
+
</header>
|
|
43
|
+
)}
|
|
44
|
+
{children}
|
|
45
|
+
</section>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useId, useState, type PointerEvent } from "react";
|
|
2
|
+
|
|
3
|
+
import type { ChartPoint } from "../blocks";
|
|
4
|
+
import { useKit, useParts } from "./context";
|
|
5
|
+
import { formatNumber } from "./numbers";
|
|
6
|
+
|
|
7
|
+
/** The line's drawing box: wide and short; it stretches to the chart's width. */
|
|
8
|
+
const WIDTH = 600;
|
|
9
|
+
const HEIGHT = 160;
|
|
10
|
+
/** Room above the highest point, so its dot is never cut. */
|
|
11
|
+
const HEADROOM = 8;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Figures over a few labels, one series in the chart's ink: `bar`, a row a label, its bar from
|
|
15
|
+
* one baseline and its figure at the tip; `line`, the labels in their order (days, weeks) as one
|
|
16
|
+
* line over a wash, its extremes on the axis and the point under the pointer told in full.
|
|
17
|
+
*/
|
|
18
|
+
export function Chart({ kind, points }: { kind: "bar" | "line"; points: ChartPoint[] }) {
|
|
19
|
+
return kind === "line" ? <Line points={points} /> : <Bars points={points} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function Bars({ points }: { points: ChartPoint[] }) {
|
|
23
|
+
const part = useParts();
|
|
24
|
+
const { code } = useKit();
|
|
25
|
+
const most = Math.max(...points.map((point) => point.value), 0);
|
|
26
|
+
return (
|
|
27
|
+
<ul part="chart" className={part("sc-chart", "sc-chart--bar")}>
|
|
28
|
+
{points.map((point, index) => (
|
|
29
|
+
<li key={index} className={part("sc-chart__row")}>
|
|
30
|
+
<span className={part("sc-chart__label")}>{point.label}</span>
|
|
31
|
+
<span className={part("sc-chart__track")}>
|
|
32
|
+
<span
|
|
33
|
+
className={part("sc-chart__bar")}
|
|
34
|
+
style={{ width: most > 0 ? `${(Math.max(point.value, 0) / most) * 100}%` : 0 }}
|
|
35
|
+
/>
|
|
36
|
+
</span>
|
|
37
|
+
<span className={part("sc-chart__value")}>{formatNumber(point.value, code)}</span>
|
|
38
|
+
</li>
|
|
39
|
+
))}
|
|
40
|
+
</ul>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function Line({ points }: { points: ChartPoint[] }) {
|
|
45
|
+
const part = useParts();
|
|
46
|
+
const { code } = useKit();
|
|
47
|
+
const wash = useId();
|
|
48
|
+
const [shown, setShown] = useState<number | null>(null);
|
|
49
|
+
const values = points.map((point) => point.value);
|
|
50
|
+
const most = Math.max(...values, 0);
|
|
51
|
+
const least = Math.min(...values, 0);
|
|
52
|
+
const span = most - least || 1;
|
|
53
|
+
const x = (index: number) =>
|
|
54
|
+
points.length === 1 ? WIDTH / 2 : (index / (points.length - 1)) * WIDTH;
|
|
55
|
+
const y = (value: number) => HEADROOM + (1 - (value - least) / span) * (HEIGHT - HEADROOM);
|
|
56
|
+
const line = points.map((point, index) => `${x(index)},${y(point.value)}`).join(" ");
|
|
57
|
+
const area = `${x(0)},${y(least)} ${line} ${x(points.length - 1)},${y(least)}`;
|
|
58
|
+
const first = points[0];
|
|
59
|
+
const last = points.at(-1);
|
|
60
|
+
const hovered = shown === null ? undefined : points[shown];
|
|
61
|
+
|
|
62
|
+
const onPointerMove = (event: PointerEvent<HTMLDivElement>) => {
|
|
63
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
64
|
+
const at = (event.clientX - box.left) / box.width;
|
|
65
|
+
setShown(Math.min(points.length - 1, Math.max(0, Math.round(at * (points.length - 1)))));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<figure part="chart" className={part("sc-chart", "sc-chart--line")}>
|
|
70
|
+
<span className={part("sc-chart__top")}>{formatNumber(most, code)}</span>
|
|
71
|
+
<div
|
|
72
|
+
className={part("sc-chart__plot")}
|
|
73
|
+
onPointerMove={onPointerMove}
|
|
74
|
+
onPointerLeave={() => {
|
|
75
|
+
setShown(null);
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<svg viewBox={`0 0 ${WIDTH} ${HEIGHT}`} preserveAspectRatio="none" aria-hidden>
|
|
79
|
+
<defs>
|
|
80
|
+
<linearGradient id={wash} x1="0" x2="0" y1="0" y2="1">
|
|
81
|
+
<stop offset="0" className={part("sc-chart__wash")} />
|
|
82
|
+
<stop offset="1" className={part("sc-chart__wash")} stopOpacity={0} />
|
|
83
|
+
</linearGradient>
|
|
84
|
+
</defs>
|
|
85
|
+
<line x1={0} x2={WIDTH} y1={HEIGHT} y2={HEIGHT} className={part("sc-chart__axis")} />
|
|
86
|
+
<polygon points={area} fill={`url(#${wash})`} />
|
|
87
|
+
<polyline points={line} className={part("sc-chart__line")} />
|
|
88
|
+
</svg>
|
|
89
|
+
{hovered !== undefined && shown !== null && (
|
|
90
|
+
<>
|
|
91
|
+
<span
|
|
92
|
+
className={part("sc-chart__dot")}
|
|
93
|
+
style={{
|
|
94
|
+
left: `${(x(shown) / WIDTH) * 100}%`,
|
|
95
|
+
top: `${(y(hovered.value) / HEIGHT) * 100}%`,
|
|
96
|
+
}}
|
|
97
|
+
/>
|
|
98
|
+
<span
|
|
99
|
+
role="status"
|
|
100
|
+
className={part("sc-chart__tip")}
|
|
101
|
+
style={{
|
|
102
|
+
left: `${(x(shown) / WIDTH) * 100}%`,
|
|
103
|
+
// Kept inside the chart at its ends.
|
|
104
|
+
translate: shown === 0 ? "0" : shown === points.length - 1 ? "-100%" : "-50%",
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<span>{hovered.label}</span>
|
|
108
|
+
<strong>{formatNumber(hovered.value, code)}</strong>
|
|
109
|
+
</span>
|
|
110
|
+
</>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
<figcaption className={part("sc-chart__ends")}>
|
|
114
|
+
<span>{first?.label}</span>
|
|
115
|
+
{points.length > 1 && <span>{last?.label}</span>}
|
|
116
|
+
</figcaption>
|
|
117
|
+
<table className={part("sc-chart__data")}>
|
|
118
|
+
<tbody>
|
|
119
|
+
{points.map((point, index) => (
|
|
120
|
+
<tr key={index}>
|
|
121
|
+
<th scope="row">{point.label}</th>
|
|
122
|
+
<td>{formatNumber(point.value, code)}</td>
|
|
123
|
+
</tr>
|
|
124
|
+
))}
|
|
125
|
+
</tbody>
|
|
126
|
+
</table>
|
|
127
|
+
</figure>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { CheckIcon } from "@phosphor-icons/react";
|
|
2
|
+
import { useRef, type KeyboardEvent } from "react";
|
|
3
|
+
|
|
4
|
+
import { useParts } from "./context";
|
|
5
|
+
import { ariaOf, type ControlBase } from "./Field";
|
|
6
|
+
import { toggled, type Option } from "./options";
|
|
7
|
+
|
|
8
|
+
const MOVES: Readonly<Record<string, 1 | -1>> = {
|
|
9
|
+
ArrowRight: 1,
|
|
10
|
+
ArrowDown: 1,
|
|
11
|
+
ArrowLeft: -1,
|
|
12
|
+
ArrowUp: -1,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A group of radios as native ones behave: one stop for Tab (the one checked, else the first),
|
|
17
|
+
* the arrows move to the next or the previous one and check it, Home and End to the ends.
|
|
18
|
+
*/
|
|
19
|
+
export function useRadios(count: number, checked: number, check: (index: number) => void) {
|
|
20
|
+
const items = useRef<(HTMLElement | null)[]>([]);
|
|
21
|
+
return {
|
|
22
|
+
ref: (index: number) => (element: HTMLElement | null) => {
|
|
23
|
+
items.current[index] = element;
|
|
24
|
+
},
|
|
25
|
+
tabIndex: (index: number) => (index === Math.max(0, checked) ? 0 : -1),
|
|
26
|
+
onKeyDown: (event: KeyboardEvent, index: number) => {
|
|
27
|
+
const move = MOVES[event.key];
|
|
28
|
+
const next =
|
|
29
|
+
event.key === "Home"
|
|
30
|
+
? 0
|
|
31
|
+
: event.key === "End"
|
|
32
|
+
? count - 1
|
|
33
|
+
: move !== undefined
|
|
34
|
+
? (index + move + count) % count
|
|
35
|
+
: null;
|
|
36
|
+
if (next === null) return;
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
items.current[next]?.focus();
|
|
39
|
+
check(next);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Few short options with no hints sit side by side in one bar; any other few are cards. */
|
|
45
|
+
export function segmented(options: Option[]): boolean {
|
|
46
|
+
const length = options.reduce((sum, option) => sum + option.label.length, 0);
|
|
47
|
+
return options.length <= 4 && length <= 32 && options.every((option) => !option.hint);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* One of a few options, all in sight, as a group of radios: one bar of segments when they are
|
|
52
|
+
* short, else a card each with its hint under its label and a dot that fills when picked.
|
|
53
|
+
*/
|
|
54
|
+
export function Choices({
|
|
55
|
+
options,
|
|
56
|
+
value,
|
|
57
|
+
onChange,
|
|
58
|
+
...control
|
|
59
|
+
}: ControlBase & {
|
|
60
|
+
options: Option[];
|
|
61
|
+
value: string | null;
|
|
62
|
+
onChange: (id: string) => void;
|
|
63
|
+
}) {
|
|
64
|
+
const part = useParts();
|
|
65
|
+
const checked = options.findIndex((option) => option.id === value);
|
|
66
|
+
const radios = useRadios(options.length, checked, (index) => {
|
|
67
|
+
const option = options[index];
|
|
68
|
+
if (option) onChange(option.id);
|
|
69
|
+
});
|
|
70
|
+
const bar = segmented(options);
|
|
71
|
+
return (
|
|
72
|
+
<div role="radiogroup" {...ariaOf(control)} className={part(bar ? "sc-segments" : "sc-picks")}>
|
|
73
|
+
{options.map((option, index) => (
|
|
74
|
+
<button
|
|
75
|
+
key={option.id}
|
|
76
|
+
ref={radios.ref(index)}
|
|
77
|
+
type="button"
|
|
78
|
+
role="radio"
|
|
79
|
+
aria-checked={index === checked}
|
|
80
|
+
tabIndex={radios.tabIndex(index)}
|
|
81
|
+
disabled={control.disabled}
|
|
82
|
+
onKeyDown={(event) => radios.onKeyDown(event, index)}
|
|
83
|
+
onClick={() => onChange(option.id)}
|
|
84
|
+
className={part("sc-pick")}
|
|
85
|
+
>
|
|
86
|
+
{!bar && <i aria-hidden />}
|
|
87
|
+
<span>
|
|
88
|
+
{option.label}
|
|
89
|
+
{option.hint !== undefined && <small>{option.hint}</small>}
|
|
90
|
+
</span>
|
|
91
|
+
</button>
|
|
92
|
+
))}
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Several of a few options: a chip each, ticked on and off, a check on those picked. */
|
|
98
|
+
export function Chips({
|
|
99
|
+
options,
|
|
100
|
+
value,
|
|
101
|
+
onChange,
|
|
102
|
+
...control
|
|
103
|
+
}: ControlBase & {
|
|
104
|
+
options: Option[];
|
|
105
|
+
value: string[];
|
|
106
|
+
onChange: (ids: string[]) => void;
|
|
107
|
+
}) {
|
|
108
|
+
const part = useParts();
|
|
109
|
+
return (
|
|
110
|
+
<div role="group" {...ariaOf(control)} aria-required={undefined} className={part("sc-chips")}>
|
|
111
|
+
{options.map((option) => {
|
|
112
|
+
const on = value.includes(option.id);
|
|
113
|
+
return (
|
|
114
|
+
<button
|
|
115
|
+
key={option.id}
|
|
116
|
+
type="button"
|
|
117
|
+
role="checkbox"
|
|
118
|
+
aria-checked={on}
|
|
119
|
+
title={option.hint}
|
|
120
|
+
disabled={control.disabled}
|
|
121
|
+
onClick={() => onChange(toggled(options, value, option.id))}
|
|
122
|
+
className={part("sc-chip")}
|
|
123
|
+
>
|
|
124
|
+
{on && <CheckIcon aria-hidden weight="bold" />}
|
|
125
|
+
{option.label}
|
|
126
|
+
</button>
|
|
127
|
+
);
|
|
128
|
+
})}
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
}
|