@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,368 @@
|
|
|
1
|
+
import { MoreIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import {
|
|
3
|
+
announce,
|
|
4
|
+
edges,
|
|
5
|
+
findCard,
|
|
6
|
+
isSheet,
|
|
7
|
+
kanban,
|
|
8
|
+
moveCard,
|
|
9
|
+
moveLine,
|
|
10
|
+
uid,
|
|
11
|
+
type BoardCard,
|
|
12
|
+
type BoardColumn,
|
|
13
|
+
} from '@kerf-js/veneer-core'
|
|
14
|
+
import { Box } from '@kerf-js/core/internal'
|
|
15
|
+
import { derived, flush, state, untrack, watch, type State } from '@kerf-js/core'
|
|
16
|
+
import { Button } from '../Button'
|
|
17
|
+
import { Drawer } from '../Drawer'
|
|
18
|
+
import { Input } from '../Field'
|
|
19
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
20
|
+
import { VirtualList, type VirtualControl } from '../VirtualList'
|
|
21
|
+
import { cardState, type Ctx } from './Kanban-card'
|
|
22
|
+
import { SWEEP } from './peer'
|
|
23
|
+
import '../styles'
|
|
24
|
+
import '@kerf-js/veneer-core/styles/data/base.css'
|
|
25
|
+
import '@kerf-js/veneer-core/styles/data/kanban.css'
|
|
26
|
+
import '@kerf-js/veneer-core/styles/app/kanban.css'
|
|
27
|
+
import '@kerf-js/veneer-core/styles/layout/edges.css'
|
|
28
|
+
|
|
29
|
+
/** A card on the board, with what Veneer draws on it. */
|
|
30
|
+
export type KanbanCardData = BoardCard & {
|
|
31
|
+
label?: string | undefined
|
|
32
|
+
color?: number | undefined
|
|
33
|
+
assignee?: string | undefined
|
|
34
|
+
/** Footer text: a due date, a count. */ meta?: string | undefined
|
|
35
|
+
}
|
|
36
|
+
/** A board column of Veneer cards. */
|
|
37
|
+
export type KanbanColumn = BoardColumn<KanbanCardData>
|
|
38
|
+
|
|
39
|
+
const hasFooter = (c: KanbanCardData) =>
|
|
40
|
+
c.label !== undefined || c.assignee !== undefined || c.meta !== undefined
|
|
41
|
+
|
|
42
|
+
type CardProps = { card: KanbanCardData; ctx: Ctx }
|
|
43
|
+
type CardModel = ReturnType<typeof cardState>
|
|
44
|
+
|
|
45
|
+
function Card(props: CardProps) {
|
|
46
|
+
const model = cardState(untrack(() => props))
|
|
47
|
+
return cardView(
|
|
48
|
+
untrack(() => props),
|
|
49
|
+
model,
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function cardView(props: CardProps, [open, at, actions, refs]: CardModel) {
|
|
54
|
+
return (
|
|
55
|
+
<div
|
|
56
|
+
ref={(n) => refs.element(n)}
|
|
57
|
+
data-part="card"
|
|
58
|
+
data-virtual=""
|
|
59
|
+
data-focus=""
|
|
60
|
+
data-sweep="surface"
|
|
61
|
+
tabindex="0"
|
|
62
|
+
draggable="true"
|
|
63
|
+
data-id={props.card.id}
|
|
64
|
+
aria-label={props.card.title}
|
|
65
|
+
aria-describedby={props.ctx.hint}
|
|
66
|
+
>
|
|
67
|
+
<SWEEP />
|
|
68
|
+
<h4 data-measure="">{props.card.title}</h4>
|
|
69
|
+
{hasFooter(props.card) && (
|
|
70
|
+
<footer>
|
|
71
|
+
{props.card.meta}
|
|
72
|
+
{props.card.label !== undefined && (
|
|
73
|
+
<span
|
|
74
|
+
data-part="label-chip"
|
|
75
|
+
style={`--_dc:var(--veneer-color-data-${props.card.color ?? 1})`}
|
|
76
|
+
>
|
|
77
|
+
<i></i>
|
|
78
|
+
{props.card.label}
|
|
79
|
+
</span>
|
|
80
|
+
)}
|
|
81
|
+
{props.card.assignee !== undefined && (
|
|
82
|
+
<span data-scope="avatar" data-size="sm" aria-hidden="true">
|
|
83
|
+
{props.card.assignee}
|
|
84
|
+
</span>
|
|
85
|
+
)}
|
|
86
|
+
</footer>
|
|
87
|
+
)}
|
|
88
|
+
<button
|
|
89
|
+
ref={(n) => refs.button(n)}
|
|
90
|
+
type="button"
|
|
91
|
+
data-part="move"
|
|
92
|
+
aria-haspopup="true"
|
|
93
|
+
aria-expanded={open.value ? 'true' : 'false'}
|
|
94
|
+
aria-label={`Move ${props.card.title}`}
|
|
95
|
+
onClick={(e: MouseEvent) => actions.show(e)}
|
|
96
|
+
>
|
|
97
|
+
<MoreIcon />
|
|
98
|
+
</button>
|
|
99
|
+
<div
|
|
100
|
+
ref={(n) => refs.menu(n)}
|
|
101
|
+
data-part="menu"
|
|
102
|
+
hidden={!open.value}
|
|
103
|
+
role="menu"
|
|
104
|
+
aria-label="Move to"
|
|
105
|
+
>
|
|
106
|
+
{open.value &&
|
|
107
|
+
props.ctx.board().map((c) => (
|
|
108
|
+
<button
|
|
109
|
+
key={c.id}
|
|
110
|
+
type="button"
|
|
111
|
+
role="menuitem"
|
|
112
|
+
tabindex="-1"
|
|
113
|
+
aria-disabled={at()?.col === props.ctx.board().indexOf(c) ? 'true' : undefined}
|
|
114
|
+
onClick={() => actions.choose(c)}
|
|
115
|
+
>
|
|
116
|
+
Move to {c.title}
|
|
117
|
+
</button>
|
|
118
|
+
))}
|
|
119
|
+
{open.value && (
|
|
120
|
+
<button type="button" role="menuitem" tabindex="-1" onClick={() => actions.up()}>
|
|
121
|
+
Move up
|
|
122
|
+
</button>
|
|
123
|
+
)}
|
|
124
|
+
{open.value && (
|
|
125
|
+
<button type="button" role="menuitem" tabindex="-1" onClick={() => actions.down()}>
|
|
126
|
+
Move down
|
|
127
|
+
</button>
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function QuickAdd({ column, onAdd }: { column: KanbanColumn; onAdd: (title: string) => void }) {
|
|
135
|
+
const adding = state(false)
|
|
136
|
+
const add = (e: Event) => {
|
|
137
|
+
e.preventDefault()
|
|
138
|
+
const el = (e.currentTarget as HTMLFormElement).querySelector('input')!
|
|
139
|
+
if (el.value.trim()) onAdd(el.value.trim())
|
|
140
|
+
el.value = ''
|
|
141
|
+
}
|
|
142
|
+
return (
|
|
143
|
+
<>
|
|
144
|
+
{adding.value ? (
|
|
145
|
+
<form
|
|
146
|
+
onSubmit={add}
|
|
147
|
+
onKeyDown={(e: KeyboardEvent) => {
|
|
148
|
+
if (e.key === 'Escape') adding.value = false
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
<Input label={`Add a card to ${column.title}`} size="sm" autofocus />
|
|
152
|
+
</form>
|
|
153
|
+
) : (
|
|
154
|
+
<Button emphasis="ghost" tone="neutral" size="sm" onClick={() => (adding.value = true)}>
|
|
155
|
+
Add card
|
|
156
|
+
</Button>
|
|
157
|
+
)}
|
|
158
|
+
</>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function Column({ col, ctx, hint }: { col: () => KanbanColumn; ctx: Ctx; hint: string }) {
|
|
163
|
+
const id = untrack(() => col().id)
|
|
164
|
+
return (
|
|
165
|
+
<section
|
|
166
|
+
data-part="column"
|
|
167
|
+
aria-labelledby={`${hint}-${id}`}
|
|
168
|
+
data-over-limit={
|
|
169
|
+
col().limit !== undefined && col().cards.length > col().limit! ? '' : undefined
|
|
170
|
+
}
|
|
171
|
+
>
|
|
172
|
+
<header data-part="column-head">
|
|
173
|
+
{col().color !== undefined && (
|
|
174
|
+
<i style={`--_dc:var(--veneer-color-data-${col().color})`}></i>
|
|
175
|
+
)}
|
|
176
|
+
<h3 id={`${hint}-${id}`} style="margin-inline-end:auto">
|
|
177
|
+
{col().title}
|
|
178
|
+
</h3>
|
|
179
|
+
<em data-part="count">
|
|
180
|
+
{col().cards.length}
|
|
181
|
+
{col().limit !== undefined ? ` / ${col().limit}` : ''}
|
|
182
|
+
</em>
|
|
183
|
+
</header>
|
|
184
|
+
<VirtualList
|
|
185
|
+
part="cards"
|
|
186
|
+
tag="ol"
|
|
187
|
+
role="list"
|
|
188
|
+
inner
|
|
189
|
+
label={col().title}
|
|
190
|
+
items={col().cards}
|
|
191
|
+
rowKey={(c) => c.id}
|
|
192
|
+
text={(c) => c.title}
|
|
193
|
+
variant={(c) => (hasFooter(c) ? 'footer' : 'plain')}
|
|
194
|
+
estimate={72}
|
|
195
|
+
gap={8}
|
|
196
|
+
onDrift={ctx.drift}
|
|
197
|
+
control={(c) => ctx.window(id, c)}
|
|
198
|
+
>
|
|
199
|
+
{(card) => {
|
|
200
|
+
const c = derived(card)
|
|
201
|
+
return <Card card={c.value} ctx={ctx} />
|
|
202
|
+
}}
|
|
203
|
+
</VirtualList>
|
|
204
|
+
{ctx.adds() && <QuickAdd column={col()} onAdd={(t) => ctx.add(id, t)} />}
|
|
205
|
+
</section>
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
type KanbanProps = {
|
|
210
|
+
columns: State<KanbanColumn[]> | KanbanColumn[]
|
|
211
|
+
onMove?: (id: string, column: string, index: number) => void
|
|
212
|
+
onAdd?: (column: string, title: string) => void
|
|
213
|
+
onDrift?: ((index: number, predicted: number, actual: number) => void) | undefined
|
|
214
|
+
height?: string
|
|
215
|
+
label?: string | undefined
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
type KanbanOptions = {
|
|
219
|
+
columns: () => KanbanProps['columns']
|
|
220
|
+
hasAdd: () => boolean
|
|
221
|
+
onMove: (id: string, next: KanbanColumn[], at: NonNullable<ReturnType<typeof findCard>>) => void
|
|
222
|
+
onAdd: (column: string, title: string) => void
|
|
223
|
+
onDrift: (index: number, predicted: number, actual: number) => void
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function kanbanState(opts: KanbanOptions) {
|
|
227
|
+
const hint = uid('kanban')
|
|
228
|
+
const own = state(
|
|
229
|
+
untrack(() => (opts.columns() instanceof Box ? [] : (opts.columns() as KanbanColumn[]))),
|
|
230
|
+
)
|
|
231
|
+
const board = derived<KanbanColumn[]>(() =>
|
|
232
|
+
opts.columns() instanceof Box ? (opts.columns() as State<KanbanColumn[]>).value : own.value,
|
|
233
|
+
)
|
|
234
|
+
watch(opts.columns, (c) => {
|
|
235
|
+
if (!(c instanceof Box)) own.value = c as KanbanColumn[]
|
|
236
|
+
})
|
|
237
|
+
const adds = derived(() => opts.hasAdd())
|
|
238
|
+
const moving = state<KanbanCardData | null>(null)
|
|
239
|
+
const sheetOpen = state(false)
|
|
240
|
+
const windows = new Map<string, VirtualControl>()
|
|
241
|
+
let host: HTMLDivElement | undefined
|
|
242
|
+
const focus = (id: string) => {
|
|
243
|
+
const at = findCard(board.value, id)
|
|
244
|
+
if (at) queueMicrotask(() => windows.get(board.value[at.col]!.id)?.focus(id)) // focus follows the card
|
|
245
|
+
}
|
|
246
|
+
const move = (id: string, col: number, index: number) => {
|
|
247
|
+
const next = moveCard(board.value, id, col, index)
|
|
248
|
+
if (opts.columns() instanceof Box) (opts.columns() as State<KanbanColumn[]>).value = next
|
|
249
|
+
else own.value = next
|
|
250
|
+
flush()
|
|
251
|
+
const at = findCard(next, id)!
|
|
252
|
+
announce(host!.ownerDocument, moveLine(next, id))
|
|
253
|
+
opts.onMove(id, next, at)
|
|
254
|
+
}
|
|
255
|
+
use(
|
|
256
|
+
kanban,
|
|
257
|
+
() => host,
|
|
258
|
+
() => ({ columns: () => untrack(() => board.value), onMove: move, focus }),
|
|
259
|
+
)
|
|
260
|
+
use(edges, () => host) // a column cut at the stage's edge gets a shadow there, as a wide table's does
|
|
261
|
+
const ctx: Ctx = {
|
|
262
|
+
board: () => board.value,
|
|
263
|
+
move,
|
|
264
|
+
focus,
|
|
265
|
+
hint,
|
|
266
|
+
coarse: (el) =>
|
|
267
|
+
isSheet(el) || !!el.ownerDocument.defaultView?.matchMedia?.('(pointer: coarse)').matches,
|
|
268
|
+
sheet: (c) => {
|
|
269
|
+
moving.value = c
|
|
270
|
+
sheetOpen.value = true
|
|
271
|
+
},
|
|
272
|
+
drift: (i, p, a) => opts.onDrift(i, p, a),
|
|
273
|
+
window: (column, c) => windows.set(column, c),
|
|
274
|
+
adds: () => adds.value,
|
|
275
|
+
add: (column, title) => opts.onAdd(column, title),
|
|
276
|
+
}
|
|
277
|
+
const sheetTo = (col: number, index: number) => {
|
|
278
|
+
const id = moving.value!.id
|
|
279
|
+
sheetOpen.value = false
|
|
280
|
+
move(id, col, index)
|
|
281
|
+
focus(id)
|
|
282
|
+
}
|
|
283
|
+
const place = derived(() => (moving.value ? findCard(board.value, moving.value.id) : null))
|
|
284
|
+
return [
|
|
285
|
+
hint,
|
|
286
|
+
board,
|
|
287
|
+
ctx,
|
|
288
|
+
moving,
|
|
289
|
+
sheetOpen,
|
|
290
|
+
sheetTo,
|
|
291
|
+
place,
|
|
292
|
+
(n: HTMLDivElement) => (host = n),
|
|
293
|
+
] as const
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* The board (07 §6.2, 06 §10). Columns are `section > ol`, each a window, so one with 10,000 cards costs what one with
|
|
298
|
+
* 20 does, with count and WIP limit, caution when over. Three move paths: HTML drag with a placeholder; keyboard
|
|
299
|
+
* (Alt + arrows, or Space, arrows, Space); the Move button, a menu at a fine pointer and a Sheet on a phone. Each move is
|
|
300
|
+
* announced. `columns` is a box, or a list the board follows and `onMove` reports to. `height` defaults to 560px.
|
|
301
|
+
*/
|
|
302
|
+
export function Kanban({ columns, onMove, onAdd, onDrift, height, label = 'Board' }: KanbanProps) {
|
|
303
|
+
const [hint, board, ctx, moving, sheetOpen, sheetTo, place, setHost] = kanbanState({
|
|
304
|
+
columns: () => columns,
|
|
305
|
+
hasAdd: () => onAdd !== undefined,
|
|
306
|
+
onMove: (id, next, at) => onMove?.(id, next[at.col]!.id, at.index),
|
|
307
|
+
onAdd: (column, title) => onAdd?.(column, title),
|
|
308
|
+
onDrift: (index, predicted, actual) => onDrift?.(index, predicted, actual),
|
|
309
|
+
})
|
|
310
|
+
return (
|
|
311
|
+
<>
|
|
312
|
+
<div data-scope="edges">
|
|
313
|
+
<div
|
|
314
|
+
ref={(n) => setHost(n)}
|
|
315
|
+
data-scope="kanban"
|
|
316
|
+
role="group"
|
|
317
|
+
aria-label={label}
|
|
318
|
+
style={`block-size:${height ?? '560px'}`}
|
|
319
|
+
>
|
|
320
|
+
{board.value.map((c) => (
|
|
321
|
+
<Column
|
|
322
|
+
key={c.id}
|
|
323
|
+
col={() => board.value.find((x) => x.id === c.id) ?? c}
|
|
324
|
+
ctx={ctx}
|
|
325
|
+
hint={hint}
|
|
326
|
+
/>
|
|
327
|
+
))}
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
<p data-part="sr-only" id={hint}>
|
|
331
|
+
Alt plus arrow keys move this card. Space picks it up. The move button lists every
|
|
332
|
+
destination.
|
|
333
|
+
</p>
|
|
334
|
+
<Drawer open={sheetOpen} title={`Move ${moving.value?.title ?? ''}`} side="bottom">
|
|
335
|
+
<div style="display:grid;gap:4px">
|
|
336
|
+
{board.value.map((c) => (
|
|
337
|
+
<Button
|
|
338
|
+
key={c.id}
|
|
339
|
+
emphasis="ghost"
|
|
340
|
+
tone="neutral"
|
|
341
|
+
full
|
|
342
|
+
disabled={place.value !== null && board.value[place.value.col]?.id === c.id}
|
|
343
|
+
onClick={() => sheetTo(board.value.indexOf(c), c.cards.length)}
|
|
344
|
+
>
|
|
345
|
+
Move to {c.title}
|
|
346
|
+
</Button>
|
|
347
|
+
))}
|
|
348
|
+
<Button
|
|
349
|
+
emphasis="ghost"
|
|
350
|
+
tone="neutral"
|
|
351
|
+
full
|
|
352
|
+
onClick={() => sheetTo(place.value!.col, place.value!.index - 1)}
|
|
353
|
+
>
|
|
354
|
+
Move up
|
|
355
|
+
</Button>
|
|
356
|
+
<Button
|
|
357
|
+
emphasis="ghost"
|
|
358
|
+
tone="neutral"
|
|
359
|
+
full
|
|
360
|
+
onClick={() => sheetTo(place.value!.col, place.value!.index + 1)}
|
|
361
|
+
>
|
|
362
|
+
Move down
|
|
363
|
+
</Button>
|
|
364
|
+
</div>
|
|
365
|
+
</Drawer>
|
|
366
|
+
</>
|
|
367
|
+
)
|
|
368
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { firstName, peerColor, uid, type Peer } from '@kerf-js/veneer-core'
|
|
2
|
+
import { Input } from '../Field'
|
|
3
|
+
import { PeerAvatar } from './peer'
|
|
4
|
+
import '../styles'
|
|
5
|
+
import '@kerf-js/veneer-core/styles/app/tokens.css'
|
|
6
|
+
import '@kerf-js/veneer-core/styles/app/base.css'
|
|
7
|
+
import '@kerf-js/veneer-core/styles/app/lock.css'
|
|
8
|
+
|
|
9
|
+
/** The chip on a field another peer holds (07 §6.1): "Kofi is editing". */
|
|
10
|
+
export function LockIndicator({ peer, ...rest }: { peer: Peer; [attr: string]: unknown }) {
|
|
11
|
+
return (
|
|
12
|
+
<span data-scope="lock" data-presence-color={peerColor(peer)} {...rest}>
|
|
13
|
+
<PeerAvatar peer={peer} />
|
|
14
|
+
{firstName(peer.name)} is editing
|
|
15
|
+
</span>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A text field held by a peer: `readonly`, not disabled, so it stays readable and focusable; the chip describes it. */
|
|
20
|
+
export function LockedField({
|
|
21
|
+
peer,
|
|
22
|
+
...field
|
|
23
|
+
}: {
|
|
24
|
+
peer: Peer | null
|
|
25
|
+
label: string
|
|
26
|
+
value?: string
|
|
27
|
+
[attr: string]: unknown
|
|
28
|
+
}) {
|
|
29
|
+
const id = uid('lock')
|
|
30
|
+
return (
|
|
31
|
+
<div data-locked-by={peer?.id}>
|
|
32
|
+
<Input {...field} readonly={peer !== null} aria-describedby={peer ? id : undefined} />
|
|
33
|
+
{peer && <LockIndicator peer={peer} id={id} />}
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
announce,
|
|
3
|
+
burst,
|
|
4
|
+
firstName,
|
|
5
|
+
followViewport,
|
|
6
|
+
peerColor,
|
|
7
|
+
popover,
|
|
8
|
+
presenceDelta,
|
|
9
|
+
uid,
|
|
10
|
+
type Peer,
|
|
11
|
+
} from '@kerf-js/veneer-core'
|
|
12
|
+
import { derived, onCleanup, onMount, state, untrack, watch } from '@kerf-js/core'
|
|
13
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
14
|
+
import { PeerAvatar, read, type Live } from './peer'
|
|
15
|
+
import '../styles'
|
|
16
|
+
import '@kerf-js/veneer-core/styles/components/popover.css'
|
|
17
|
+
import '@kerf-js/veneer-core/styles/app/tokens.css'
|
|
18
|
+
import '@kerf-js/veneer-core/styles/app/base.css'
|
|
19
|
+
import '@kerf-js/veneer-core/styles/app/avatar-stack.css'
|
|
20
|
+
import '@kerf-js/veneer-core/styles/app/follow-flag.css'
|
|
21
|
+
|
|
22
|
+
type PresenceStackProps = {
|
|
23
|
+
peers: Live<Peer[]>
|
|
24
|
+
max?: number | undefined
|
|
25
|
+
following?: string | null | undefined
|
|
26
|
+
onFollow?: (p: Peer | null) => void
|
|
27
|
+
label?: string | undefined
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function presenceAnnounce(
|
|
31
|
+
list: { readonly value: Peer[] },
|
|
32
|
+
panel: () => HTMLDivElement | undefined,
|
|
33
|
+
) {
|
|
34
|
+
onMount(() => {
|
|
35
|
+
const told = burst<string>((lines) => announce(panel()!.ownerDocument, lines.join('. ')))
|
|
36
|
+
let was = untrack(() => list.value)
|
|
37
|
+
onCleanup(told.cancel)
|
|
38
|
+
watch(
|
|
39
|
+
() => list.value,
|
|
40
|
+
(now) => {
|
|
41
|
+
const line = presenceDelta(was, now)
|
|
42
|
+
was = now
|
|
43
|
+
if (line) told.push(line)
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Who is here (07 §6.1): avatars with a ring in each peer's colour, `+n` overflow opening the list, joins and leaves
|
|
51
|
+
* announced as one summary. With `onFollow` each avatar is a toggle: `following` is the peer's id.
|
|
52
|
+
*/
|
|
53
|
+
export function PresenceStack({
|
|
54
|
+
peers,
|
|
55
|
+
max = 4,
|
|
56
|
+
following,
|
|
57
|
+
onFollow,
|
|
58
|
+
label = 'People here',
|
|
59
|
+
}: PresenceStackProps) {
|
|
60
|
+
const id = uid('presence')
|
|
61
|
+
const list = derived(() => read(peers))
|
|
62
|
+
const front = derived(() => list.value.slice(0, max))
|
|
63
|
+
const rest = derived(() => list.value.slice(max))
|
|
64
|
+
const open = state(false)
|
|
65
|
+
const canFollow = derived(() => onFollow !== undefined)
|
|
66
|
+
let more: HTMLButtonElement | undefined
|
|
67
|
+
let panel: HTMLDivElement | undefined
|
|
68
|
+
use(
|
|
69
|
+
popover,
|
|
70
|
+
() => panel,
|
|
71
|
+
() => ({ open: open.value, trigger: more!, onClose: () => (open.value = false) }),
|
|
72
|
+
)
|
|
73
|
+
presenceAnnounce(list, () => panel)
|
|
74
|
+
return (
|
|
75
|
+
<span data-scope="avatar-stack" role="group" aria-label={label}>
|
|
76
|
+
{front.value.map((p) =>
|
|
77
|
+
canFollow.value ? (
|
|
78
|
+
<button
|
|
79
|
+
key={p.id}
|
|
80
|
+
type="button"
|
|
81
|
+
data-hit=""
|
|
82
|
+
aria-pressed={following === p.id ? 'true' : 'false'}
|
|
83
|
+
style="all:unset;cursor:pointer;border-radius:99px"
|
|
84
|
+
onClick={() => onFollow!(following === p.id ? null : p)}
|
|
85
|
+
>
|
|
86
|
+
<span data-part="sr-only">Follow {p.name}</span>
|
|
87
|
+
<PeerAvatar peer={p} size="sm" ring />
|
|
88
|
+
</button>
|
|
89
|
+
) : (
|
|
90
|
+
<PeerAvatar key={p.id} peer={p} size="sm" ring />
|
|
91
|
+
),
|
|
92
|
+
)}
|
|
93
|
+
{rest.value.length > 0 && (
|
|
94
|
+
<button
|
|
95
|
+
ref={(n) => (more = n)}
|
|
96
|
+
type="button"
|
|
97
|
+
data-part="more"
|
|
98
|
+
aria-haspopup="dialog"
|
|
99
|
+
aria-expanded={open.value ? 'true' : 'false'}
|
|
100
|
+
aria-controls={id}
|
|
101
|
+
aria-label={`${rest.value.length} more people`}
|
|
102
|
+
style="border:0;margin-inline-start:0;cursor:pointer"
|
|
103
|
+
onClick={() => (open.value = !open.value)}
|
|
104
|
+
>
|
|
105
|
+
+{rest.value.length}
|
|
106
|
+
</button>
|
|
107
|
+
)}
|
|
108
|
+
<div
|
|
109
|
+
ref={(n) => (panel = n)}
|
|
110
|
+
data-scope="popover"
|
|
111
|
+
data-part="content"
|
|
112
|
+
role="dialog"
|
|
113
|
+
popover="manual"
|
|
114
|
+
id={id}
|
|
115
|
+
aria-label={label}
|
|
116
|
+
>
|
|
117
|
+
<ul>
|
|
118
|
+
{list.value.map((p) => (
|
|
119
|
+
<li key={p.id}>{p.name}</li>
|
|
120
|
+
))}
|
|
121
|
+
</ul>
|
|
122
|
+
</div>
|
|
123
|
+
</span>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Following (07 §6.1): wraps the surface that rides the peer's viewport. The frame and the flag take their colour; any
|
|
129
|
+
* scroll of the user's, or Esc, stops. `top` is the peer's viewport top, 0–1.
|
|
130
|
+
*/
|
|
131
|
+
export function Following({
|
|
132
|
+
peer,
|
|
133
|
+
top,
|
|
134
|
+
onStop,
|
|
135
|
+
children,
|
|
136
|
+
...rest
|
|
137
|
+
}: {
|
|
138
|
+
peer: Peer | null
|
|
139
|
+
top?: number | undefined
|
|
140
|
+
onStop: () => void
|
|
141
|
+
children?: unknown
|
|
142
|
+
[attr: string]: unknown
|
|
143
|
+
}) {
|
|
144
|
+
let el: HTMLDivElement | undefined
|
|
145
|
+
const on = derived(() => peer !== null)
|
|
146
|
+
onMount(() =>
|
|
147
|
+
watch(
|
|
148
|
+
() => peer,
|
|
149
|
+
(p, was) => {
|
|
150
|
+
if (p) announce(el!.ownerDocument, `Following ${p.name}`)
|
|
151
|
+
else if (was) announce(el!.ownerDocument, 'Stopped following')
|
|
152
|
+
},
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
use(
|
|
156
|
+
followViewport,
|
|
157
|
+
() => el,
|
|
158
|
+
() => ({ on: on.value, top, onStop }),
|
|
159
|
+
)
|
|
160
|
+
return (
|
|
161
|
+
<div
|
|
162
|
+
ref={(n) => (el = n)}
|
|
163
|
+
data-following={on.value ? '' : undefined}
|
|
164
|
+
data-presence-color={peer ? peerColor(peer) : undefined}
|
|
165
|
+
style="position:relative"
|
|
166
|
+
{...rest}
|
|
167
|
+
>
|
|
168
|
+
{peer && (
|
|
169
|
+
<span data-scope="follow-flag" data-presence-color={peerColor(peer)}>
|
|
170
|
+
Following {firstName(peer.name)} · Esc to stop
|
|
171
|
+
</span>
|
|
172
|
+
)}
|
|
173
|
+
{children}
|
|
174
|
+
</div>
|
|
175
|
+
)
|
|
176
|
+
}
|