@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,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bellCount,
|
|
3
|
+
bellLabel,
|
|
4
|
+
bump,
|
|
5
|
+
popover,
|
|
6
|
+
uid,
|
|
7
|
+
type Align,
|
|
8
|
+
type Side,
|
|
9
|
+
} from '@kerf-js/veneer-core'
|
|
10
|
+
import { derived, onMount, state, untrack, watch, type State } from '@kerf-js/core'
|
|
11
|
+
import { Button } from '../Button'
|
|
12
|
+
import { Badge } from '../Badge'
|
|
13
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
14
|
+
import { G, val } from './shared'
|
|
15
|
+
import '../styles'
|
|
16
|
+
import '@kerf-js/veneer-core/styles/components/popover.css'
|
|
17
|
+
import '@kerf-js/veneer-core/styles/app/bell.css'
|
|
18
|
+
import '@kerf-js/veneer-core/styles/app/badge.css'
|
|
19
|
+
|
|
20
|
+
/** Props for Bell. */
|
|
21
|
+
export interface BellProps {
|
|
22
|
+
/** Unread count: a number, a State or a getter. */
|
|
23
|
+
count?: number | { value: number } | (() => number | undefined)
|
|
24
|
+
onOpen?: () => void
|
|
25
|
+
/** The panel, usually `open => <Inbox variant="popover" open={open.value} … />`, shown in a Popover from the bell. */
|
|
26
|
+
inbox?: (open: State<boolean>) => unknown
|
|
27
|
+
/** On a phone the inbox is a page, not a popover (07 §4.3): below 600px the bell calls this instead of opening. */
|
|
28
|
+
route?: () => void
|
|
29
|
+
side?: Side | undefined
|
|
30
|
+
align?: Align
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Bell (07 §4.1): icon button and count badge, which bumps once per batch; its name says the count (§4.5). */
|
|
34
|
+
export function Bell({ count, onOpen, inbox, route, side = 'bottom', align = 'end' }: BellProps) {
|
|
35
|
+
const id = uid('bell')
|
|
36
|
+
const n = derived(() => Number(val<unknown>(count) ?? 0))
|
|
37
|
+
const open = state(false)
|
|
38
|
+
const panel = untrack(() => inbox)
|
|
39
|
+
let button: HTMLButtonElement | undefined
|
|
40
|
+
let box: HTMLDivElement | undefined
|
|
41
|
+
let badge: HTMLElement | undefined
|
|
42
|
+
use(
|
|
43
|
+
popover,
|
|
44
|
+
() => box,
|
|
45
|
+
() => ({
|
|
46
|
+
open: open.value,
|
|
47
|
+
trigger: button!,
|
|
48
|
+
side,
|
|
49
|
+
align,
|
|
50
|
+
onClose: () => (open.value = false),
|
|
51
|
+
}),
|
|
52
|
+
)
|
|
53
|
+
onMount(() =>
|
|
54
|
+
watch(
|
|
55
|
+
() => n.value,
|
|
56
|
+
(v, prev) => {
|
|
57
|
+
if (prev !== undefined && v > prev && badge) bump(badge)
|
|
58
|
+
},
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
const press = () => {
|
|
62
|
+
const toPage =
|
|
63
|
+
route && button!.ownerDocument.defaultView!.matchMedia?.('(max-width: 599.98px)').matches
|
|
64
|
+
onOpen?.()
|
|
65
|
+
if (toPage) route()
|
|
66
|
+
else if (panel) open.value = !open.value
|
|
67
|
+
}
|
|
68
|
+
return (
|
|
69
|
+
<span data-scope="bell">
|
|
70
|
+
<Button
|
|
71
|
+
emphasis="ghost"
|
|
72
|
+
tone="neutral"
|
|
73
|
+
data-icon-only=""
|
|
74
|
+
ref={(el: HTMLButtonElement) => (button = el)}
|
|
75
|
+
id={`${id}-b`}
|
|
76
|
+
aria-label={bellLabel(n.value)}
|
|
77
|
+
aria-haspopup={panel ? 'dialog' : undefined}
|
|
78
|
+
aria-expanded={panel ? (open.value ? 'true' : 'false') : undefined}
|
|
79
|
+
aria-controls={panel ? id : undefined}
|
|
80
|
+
onClick={press}
|
|
81
|
+
>
|
|
82
|
+
<G name="bell" />
|
|
83
|
+
</Button>
|
|
84
|
+
<Badge
|
|
85
|
+
emphasis="solid"
|
|
86
|
+
count
|
|
87
|
+
ref={(el: HTMLElement) => (badge = el)}
|
|
88
|
+
hidden={n.value === 0}
|
|
89
|
+
aria-hidden="true"
|
|
90
|
+
>
|
|
91
|
+
{bellCount(n.value)}
|
|
92
|
+
</Badge>
|
|
93
|
+
{panel && (
|
|
94
|
+
<div
|
|
95
|
+
ref={(el) => (box = el)}
|
|
96
|
+
data-scope="popover"
|
|
97
|
+
data-part="content"
|
|
98
|
+
role="dialog"
|
|
99
|
+
popover="manual"
|
|
100
|
+
id={id}
|
|
101
|
+
aria-label="Notifications"
|
|
102
|
+
>
|
|
103
|
+
{panel(open)}
|
|
104
|
+
</div>
|
|
105
|
+
)}
|
|
106
|
+
</span>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { announce, connectionAnnouncement, liveState, type LiveState } from '@kerf-js/veneer-core'
|
|
2
|
+
import { derived, onCleanup, onMount, state, untrack, watch } from '@kerf-js/core'
|
|
3
|
+
import { Banner, LiveStatus } from '../parts'
|
|
4
|
+
import { Button } from '../Button'
|
|
5
|
+
import { val } from './shared'
|
|
6
|
+
|
|
7
|
+
const TEXT: Record<LiveState, string> = {
|
|
8
|
+
connecting: 'Connecting…',
|
|
9
|
+
live: 'Live',
|
|
10
|
+
reconnecting: 'Reconnecting…',
|
|
11
|
+
offline: 'Offline',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Status = string | undefined | { value: string } | (() => string | undefined)
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The one pill (07 §0, §4.4): `state` is `.live`, `stream().status` or `channel.status`, mapped to the four states. It
|
|
18
|
+
* announces each change once; `queued` is the count in "Back online. 4 updates."
|
|
19
|
+
*/
|
|
20
|
+
export function ConnectionPill({
|
|
21
|
+
state: status,
|
|
22
|
+
label = 'Connection',
|
|
23
|
+
queued = 0,
|
|
24
|
+
}: {
|
|
25
|
+
state: Status
|
|
26
|
+
label?: string | undefined
|
|
27
|
+
queued?: number
|
|
28
|
+
}) {
|
|
29
|
+
const now = derived(() => liveState(val<string | undefined>(status)))
|
|
30
|
+
const words = derived(() => TEXT[now.value])
|
|
31
|
+
let root: HTMLSpanElement | undefined
|
|
32
|
+
onMount(() =>
|
|
33
|
+
watch(
|
|
34
|
+
() => now.value,
|
|
35
|
+
(next, prev) => {
|
|
36
|
+
const say = connectionAnnouncement(
|
|
37
|
+
prev,
|
|
38
|
+
next,
|
|
39
|
+
untrack(() => queued),
|
|
40
|
+
)
|
|
41
|
+
if (say && root) announce(root.ownerDocument, say.text, say.assertive)
|
|
42
|
+
},
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
return (
|
|
46
|
+
<span ref={(n) => (root = n)}>
|
|
47
|
+
<LiveStatus state={now.value} label={label}>
|
|
48
|
+
{words.value}
|
|
49
|
+
</LiveStatus>
|
|
50
|
+
</span>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The trouble banner (07 §4.4): nothing while live or connecting, after `delay` ms of reconnecting (data stays, edits
|
|
56
|
+
* queue), at once when offline, with Retry. Quiet for assistive tech: the pill does the announcing.
|
|
57
|
+
*/
|
|
58
|
+
export function ConnectionBanner({
|
|
59
|
+
state: status,
|
|
60
|
+
delay = 3000,
|
|
61
|
+
onRetry,
|
|
62
|
+
offline = "You're offline. Showing what was saved; new notifications will arrive when you reconnect.",
|
|
63
|
+
reconnecting = 'Reconnecting… changes you make are queued.',
|
|
64
|
+
}: {
|
|
65
|
+
state: Status
|
|
66
|
+
delay?: number
|
|
67
|
+
onRetry?: (() => void) | undefined
|
|
68
|
+
offline?: unknown
|
|
69
|
+
reconnecting?: unknown
|
|
70
|
+
}) {
|
|
71
|
+
const now = derived(() => liveState(val<string | undefined>(status)))
|
|
72
|
+
const late = state(false)
|
|
73
|
+
const retry = untrack(() => onRetry)
|
|
74
|
+
onMount(() => {
|
|
75
|
+
let t: ReturnType<typeof setTimeout> | undefined
|
|
76
|
+
watch(
|
|
77
|
+
() => now.value,
|
|
78
|
+
(next) => {
|
|
79
|
+
clearTimeout(t)
|
|
80
|
+
if (next !== 'reconnecting') {
|
|
81
|
+
late.value = false
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
t = setTimeout(
|
|
85
|
+
() => (late.value = true),
|
|
86
|
+
untrack(() => delay),
|
|
87
|
+
)
|
|
88
|
+
},
|
|
89
|
+
)
|
|
90
|
+
onCleanup(() => clearTimeout(t))
|
|
91
|
+
})
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
{now.value === 'offline' && (
|
|
95
|
+
<Banner
|
|
96
|
+
tone="critical"
|
|
97
|
+
actions={
|
|
98
|
+
retry
|
|
99
|
+
? () => (
|
|
100
|
+
<Button emphasis="outline" tone="neutral" size="sm" onClick={retry}>
|
|
101
|
+
Retry now
|
|
102
|
+
</Button>
|
|
103
|
+
)
|
|
104
|
+
: undefined
|
|
105
|
+
}
|
|
106
|
+
>
|
|
107
|
+
{offline}
|
|
108
|
+
</Banner>
|
|
109
|
+
)}
|
|
110
|
+
{now.value === 'reconnecting' && late.value && <Banner tone="caution">{reconnecting}</Banner>}
|
|
111
|
+
</>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { InboxTab } from '@kerf-js/veneer-core'
|
|
2
|
+
import type { LiveState } from '../parts'
|
|
3
|
+
import { Button } from '../Button'
|
|
4
|
+
import { inboxModel } from './InboxModel'
|
|
5
|
+
import { InboxHeader, InboxTabs } from './InboxHeader'
|
|
6
|
+
import { InboxFeed } from './InboxFeed'
|
|
7
|
+
import '../styles'
|
|
8
|
+
import '@kerf-js/veneer-core/styles/components/tabs.css'
|
|
9
|
+
import '@kerf-js/veneer-core/styles/components/link.css'
|
|
10
|
+
import '@kerf-js/veneer-core/styles/app/inbox.css'
|
|
11
|
+
import '@kerf-js/veneer-core/styles/app/notification.css'
|
|
12
|
+
|
|
13
|
+
/** What a notification is about, which picks its glyph. */
|
|
14
|
+
export type NoteKind = 'mention' | 'comment' | 'assign' | 'approve' | 'system' | 'invite'
|
|
15
|
+
/** A button on a notification. */
|
|
16
|
+
export interface NoteAction {
|
|
17
|
+
id: string
|
|
18
|
+
label: string
|
|
19
|
+
emphasis?: 'solid' | 'outline'
|
|
20
|
+
}
|
|
21
|
+
/** One notification. */
|
|
22
|
+
export interface Note {
|
|
23
|
+
id: string
|
|
24
|
+
actor: string
|
|
25
|
+
kind: NoteKind
|
|
26
|
+
verb: string
|
|
27
|
+
object?: string | undefined
|
|
28
|
+
detail?: string | undefined
|
|
29
|
+
/** Already formatted: the caller owns the clock. */
|
|
30
|
+
time: string
|
|
31
|
+
/** "Today", "Yesterday": see `dayLabel`. */
|
|
32
|
+
day?: string | undefined
|
|
33
|
+
source?: string | undefined
|
|
34
|
+
quote?: string | undefined
|
|
35
|
+
read?: boolean | undefined
|
|
36
|
+
actions?: NoteAction[] | undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Props for Inbox. */
|
|
40
|
+
export interface InboxProps {
|
|
41
|
+
/** Newest first. Undefined while the first load runs: skeletons, once. */
|
|
42
|
+
items: Note[] | undefined | { value: Note[] | undefined } | (() => Note[] | undefined)
|
|
43
|
+
/** The connection's state, shown in the foot as "Up to date" or "Connecting…". */
|
|
44
|
+
live?: (LiveState | (() => LiveState)) | undefined
|
|
45
|
+
/** The filter tabs, in order. Default all, unread and mentions. */
|
|
46
|
+
tabs?: InboxTab[] | undefined
|
|
47
|
+
title?: string | undefined
|
|
48
|
+
variant?: 'popover' | undefined
|
|
49
|
+
/** Is the inbox on screen? Rows are read after 2 s visible only while it is. */
|
|
50
|
+
open?: boolean | undefined
|
|
51
|
+
/** Updates waiting to sync (offline, reconnecting). */
|
|
52
|
+
queued?: number | undefined
|
|
53
|
+
viewAll?: string | undefined
|
|
54
|
+
/** Adds a settings button to the header, and is called when it is pressed. */
|
|
55
|
+
settings?: (() => void) | undefined
|
|
56
|
+
/** Called with a row's id once it has been seen or opened. */
|
|
57
|
+
onRead?: ((id: string) => void) | undefined
|
|
58
|
+
/** Called when Mark all as read is pressed. */
|
|
59
|
+
onReadAll?: (() => void) | undefined
|
|
60
|
+
/** Called with a row's id when it is dismissed. */
|
|
61
|
+
onDismiss?: ((id: string) => void) | undefined
|
|
62
|
+
/** Undo a dismiss: put the row back. */
|
|
63
|
+
onRestore?: ((note: Note) => void) | undefined
|
|
64
|
+
onAction?: ((note: Note, action: string) => void) | undefined
|
|
65
|
+
/** The row is a link to its object. */
|
|
66
|
+
onOpen?: ((note: Note) => void) | undefined
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Inbox (07 §4.1, §4.2, §4.5): tabs filter one panel; a role=feed list grouped by day, rendered by key, so a read or an
|
|
71
|
+
* approval patches the row in place. New rows arrive; with the list scrolled, an "n new" pill shows instead of moving
|
|
72
|
+
* it. A dismissed row slides out and Undo is in the toast. Needs a mounted Toaster for Undo and announcements.
|
|
73
|
+
*/
|
|
74
|
+
export function Inbox(props: InboxProps) {
|
|
75
|
+
const model = inboxModel(() => props)
|
|
76
|
+
return (
|
|
77
|
+
<section
|
|
78
|
+
ref={model.setRoot}
|
|
79
|
+
data-scope="inbox"
|
|
80
|
+
data-part="root"
|
|
81
|
+
data-variant={props.variant}
|
|
82
|
+
aria-labelledby={`${model.id}-t`}
|
|
83
|
+
>
|
|
84
|
+
<InboxHeader
|
|
85
|
+
title={props.title === undefined ? 'Notifications' : props.title}
|
|
86
|
+
settings={props.settings}
|
|
87
|
+
model={model}
|
|
88
|
+
/>
|
|
89
|
+
<InboxTabs
|
|
90
|
+
tabs={props.tabs === undefined ? ['all', 'unread', 'mentions'] : props.tabs}
|
|
91
|
+
model={model}
|
|
92
|
+
/>
|
|
93
|
+
{model.fresh.value > 0 && (
|
|
94
|
+
<Button size="sm" data-part="new-pill" onClick={model.toTop}>
|
|
95
|
+
{model.fresh.value} new
|
|
96
|
+
</Button>
|
|
97
|
+
)}
|
|
98
|
+
<InboxFeed
|
|
99
|
+
title={props.title === undefined ? 'Notifications' : props.title}
|
|
100
|
+
model={model}
|
|
101
|
+
onAction={(note, action) => props.onAction?.(note, action)}
|
|
102
|
+
/>
|
|
103
|
+
<div data-part="footer">
|
|
104
|
+
<span>{model.sync.value}</span>
|
|
105
|
+
{model.page.value && (
|
|
106
|
+
<a href={model.page.value} data-scope="link">
|
|
107
|
+
View all
|
|
108
|
+
</a>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
</section>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Skeleton } from '../Skeleton'
|
|
2
|
+
import { Row } from './InboxRow'
|
|
3
|
+
import type { Note } from './Inbox'
|
|
4
|
+
import type { inboxModel } from './InboxModel'
|
|
5
|
+
|
|
6
|
+
export function InboxFeed({
|
|
7
|
+
title,
|
|
8
|
+
model,
|
|
9
|
+
onAction,
|
|
10
|
+
}: {
|
|
11
|
+
title: string
|
|
12
|
+
model: ReturnType<typeof inboxModel>
|
|
13
|
+
onAction: ((n: Note, a: string) => void) | undefined
|
|
14
|
+
}) {
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
role="tabpanel"
|
|
18
|
+
id={`${model.id}-panel`}
|
|
19
|
+
aria-labelledby={model.tabId(model.tab.value)}
|
|
20
|
+
data-part="panel"
|
|
21
|
+
>
|
|
22
|
+
<div
|
|
23
|
+
ref={model.setList}
|
|
24
|
+
data-part="list"
|
|
25
|
+
role="feed"
|
|
26
|
+
aria-label={title}
|
|
27
|
+
aria-busy={model.data.value === undefined ? 'true' : 'false'}
|
|
28
|
+
tabindex={model.shown.value.length ? undefined : '0'}
|
|
29
|
+
onScroll={model.onScroll}
|
|
30
|
+
>
|
|
31
|
+
{model.data.value === undefined && (
|
|
32
|
+
<div data-part="group" aria-hidden="true">
|
|
33
|
+
<Skeleton lines={3} />
|
|
34
|
+
</div>
|
|
35
|
+
)}
|
|
36
|
+
{model.days.value.map((g) => (
|
|
37
|
+
<div key={g.day} role="none">
|
|
38
|
+
<div data-part="group" aria-hidden="true">
|
|
39
|
+
{g.day}
|
|
40
|
+
</div>
|
|
41
|
+
{g.rows.map((n) => (
|
|
42
|
+
<Row
|
|
43
|
+
key={n.id}
|
|
44
|
+
n={n}
|
|
45
|
+
at={model.shown.value.indexOf(n) + 1}
|
|
46
|
+
size={model.shown.value.length}
|
|
47
|
+
leaving={model.leaving.value.includes(n.id)}
|
|
48
|
+
stop={model.stop.value === n.id}
|
|
49
|
+
onKey={model.onRowKey}
|
|
50
|
+
onPress={model.pressRow}
|
|
51
|
+
onFocus={() => (model.focused.value = n.id)}
|
|
52
|
+
onDismiss={model.dismiss}
|
|
53
|
+
onAction={(x: Note, a: string) => onAction?.(x, a)}
|
|
54
|
+
/>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
))}
|
|
58
|
+
</div>
|
|
59
|
+
{model.data.value !== undefined && model.shown.value.length === 0 && (
|
|
60
|
+
<div data-scope="empty-state">
|
|
61
|
+
<p data-part="title">You're all caught up</p>
|
|
62
|
+
<p data-part="description">New mentions, invites and approvals show up here.</p>
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { arrivals, feed, indicator, readOnView, type InboxTab } from '@kerf-js/veneer-core'
|
|
2
|
+
import type { State } from '@kerf-js/core'
|
|
3
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
4
|
+
import type { Note } from './Inbox'
|
|
5
|
+
import type { InboxInputs } from './InboxModel'
|
|
6
|
+
|
|
7
|
+
export function inboxGestures({
|
|
8
|
+
p,
|
|
9
|
+
tab,
|
|
10
|
+
all,
|
|
11
|
+
fresh,
|
|
12
|
+
tablist,
|
|
13
|
+
list,
|
|
14
|
+
}: {
|
|
15
|
+
p: () => InboxInputs
|
|
16
|
+
tab: State<InboxTab>
|
|
17
|
+
all: { readonly value: Note[] }
|
|
18
|
+
fresh: State<number>
|
|
19
|
+
tablist: () => HTMLDivElement | undefined
|
|
20
|
+
list: () => HTMLDivElement | undefined
|
|
21
|
+
}) {
|
|
22
|
+
use(indicator, tablist, () => ({
|
|
23
|
+
selected: '[aria-selected="true"]',
|
|
24
|
+
x: '--_ix',
|
|
25
|
+
w: '--_iw',
|
|
26
|
+
at: tab.value,
|
|
27
|
+
}))
|
|
28
|
+
use(feed, list, () => ({ items: '[data-scope="notification"]' }))
|
|
29
|
+
use(readOnView, list, () => ({
|
|
30
|
+
items: '[data-scope="notification"]',
|
|
31
|
+
active: !!(p().open === undefined ? true : p().open),
|
|
32
|
+
onRead: (rid: string) => p().onRead?.(rid),
|
|
33
|
+
}))
|
|
34
|
+
use(arrivals, list, () => ({
|
|
35
|
+
items: '[data-scope="notification"]',
|
|
36
|
+
ids: all.value.map((n) => n.id),
|
|
37
|
+
onArrive: (ids: string[]) => {
|
|
38
|
+
if (list() && list()!.scrollTop > 0) fresh.value += ids.length
|
|
39
|
+
},
|
|
40
|
+
}))
|
|
41
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { announce, nextIndex, type InboxTab } from '@kerf-js/veneer-core'
|
|
2
|
+
import type { State } from '@kerf-js/core'
|
|
3
|
+
import { toast } from '../Toast'
|
|
4
|
+
import { sentence } from './InboxRow'
|
|
5
|
+
import type { Note } from './Inbox'
|
|
6
|
+
import type { InboxInputs } from './InboxModel'
|
|
7
|
+
|
|
8
|
+
function dismissRow({
|
|
9
|
+
n,
|
|
10
|
+
row,
|
|
11
|
+
p,
|
|
12
|
+
list,
|
|
13
|
+
leaving,
|
|
14
|
+
}: {
|
|
15
|
+
n: Note
|
|
16
|
+
row: HTMLElement
|
|
17
|
+
p: () => InboxInputs
|
|
18
|
+
list: () => HTMLDivElement | undefined
|
|
19
|
+
leaving: State<string[]>
|
|
20
|
+
}) {
|
|
21
|
+
const rest = [...list()!.querySelectorAll<HTMLElement>('[data-scope="notification"]')].filter(
|
|
22
|
+
(r) => r !== row && r.dataset.state !== 'dismissed',
|
|
23
|
+
)
|
|
24
|
+
const at = [...list()!.querySelectorAll('[data-scope="notification"]')].indexOf(row)
|
|
25
|
+
leaving.value = [...leaving.value, n.id]
|
|
26
|
+
;(rest[at] ?? rest[at - 1])?.focus()
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
p().onDismiss?.(n.id)
|
|
29
|
+
leaving.value = leaving.value.filter((x) => x !== n.id)
|
|
30
|
+
}, 240)
|
|
31
|
+
toast.show({
|
|
32
|
+
title: 'Notification dismissed',
|
|
33
|
+
description: sentence(n),
|
|
34
|
+
action: { label: 'Undo', onClick: () => p().onRestore?.(n) },
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function inboxHandlers({
|
|
39
|
+
p,
|
|
40
|
+
tab,
|
|
41
|
+
fresh,
|
|
42
|
+
leaving,
|
|
43
|
+
list,
|
|
44
|
+
tablist,
|
|
45
|
+
doc,
|
|
46
|
+
}: {
|
|
47
|
+
p: () => InboxInputs
|
|
48
|
+
tab: State<InboxTab>
|
|
49
|
+
fresh: State<number>
|
|
50
|
+
leaving: State<string[]>
|
|
51
|
+
list: () => HTMLDivElement | undefined
|
|
52
|
+
tablist: () => HTMLDivElement | undefined
|
|
53
|
+
doc: () => Document
|
|
54
|
+
}) {
|
|
55
|
+
const pick = (t: InboxTab) => {
|
|
56
|
+
tab.value = t
|
|
57
|
+
fresh.value = 0
|
|
58
|
+
}
|
|
59
|
+
const tabs = () =>
|
|
60
|
+
p().tabs === undefined ? (['all', 'unread', 'mentions'] as InboxTab[]) : p().tabs!
|
|
61
|
+
const onTabKey = (e: KeyboardEvent) => {
|
|
62
|
+
const at = tabs().indexOf(tab.value)
|
|
63
|
+
const rtl = getComputedStyle(e.currentTarget as Element).direction === 'rtl'
|
|
64
|
+
const to = nextIndex(e.key, at, tabs().length, { rtl })
|
|
65
|
+
if (to < 0) return
|
|
66
|
+
e.preventDefault()
|
|
67
|
+
pick(tabs()[to]!)
|
|
68
|
+
tablist()!.querySelectorAll<HTMLElement>('[role="tab"]')[to]?.focus()
|
|
69
|
+
}
|
|
70
|
+
const dismiss = (n: Note, row: HTMLElement) => dismissRow({ n, row, p, list, leaving })
|
|
71
|
+
const readAll = () => {
|
|
72
|
+
p().onReadAll?.()
|
|
73
|
+
announce(doc(), 'All notifications marked as read')
|
|
74
|
+
}
|
|
75
|
+
const open1 = (n: Note) => {
|
|
76
|
+
if (!n.read) p().onRead?.(n.id)
|
|
77
|
+
p().onOpen?.(n)
|
|
78
|
+
}
|
|
79
|
+
const onRowKey = (e: KeyboardEvent, n: Note) => {
|
|
80
|
+
if (e.target !== e.currentTarget) return
|
|
81
|
+
if (e.key === 'Enter') {
|
|
82
|
+
e.preventDefault()
|
|
83
|
+
open1(n)
|
|
84
|
+
}
|
|
85
|
+
if (e.key === 'Delete') {
|
|
86
|
+
e.preventDefault()
|
|
87
|
+
dismiss(n, e.currentTarget as HTMLElement)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const pressRow = (e: MouseEvent, n: Note) => {
|
|
91
|
+
if (!(e.target as Element).closest?.('button, a')) open1(n)
|
|
92
|
+
}
|
|
93
|
+
const toTop = () => {
|
|
94
|
+
list()?.scrollTo?.({ top: 0 })
|
|
95
|
+
if (list()) list()!.scrollTop = 0
|
|
96
|
+
fresh.value = 0
|
|
97
|
+
}
|
|
98
|
+
const onScroll = () => {
|
|
99
|
+
if (list()!.scrollTop <= 0) fresh.value = 0
|
|
100
|
+
}
|
|
101
|
+
return { pick, onTabKey, dismiss, readAll, onRowKey, pressRow, toTop, onScroll }
|
|
102
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { InboxTab } from '@kerf-js/veneer-core'
|
|
2
|
+
import { Badge } from '../Badge'
|
|
3
|
+
import { Button } from '../Button'
|
|
4
|
+
import { G } from './shared'
|
|
5
|
+
import type { inboxModel } from './InboxModel'
|
|
6
|
+
|
|
7
|
+
const TABS: Record<InboxTab, string> = { all: 'All', unread: 'Unread', mentions: 'Mentions' }
|
|
8
|
+
|
|
9
|
+
export function InboxHeader({
|
|
10
|
+
title,
|
|
11
|
+
settings,
|
|
12
|
+
model,
|
|
13
|
+
}: {
|
|
14
|
+
title: string
|
|
15
|
+
settings: (() => void) | undefined
|
|
16
|
+
model: ReturnType<typeof inboxModel>
|
|
17
|
+
}) {
|
|
18
|
+
return (
|
|
19
|
+
<div data-part="header">
|
|
20
|
+
<h3 id={`${model.id}-t`}>{title}</h3>
|
|
21
|
+
<Button emphasis="ghost" tone="neutral" size="sm" onClick={model.readAll}>
|
|
22
|
+
Mark all as read
|
|
23
|
+
</Button>
|
|
24
|
+
{settings && (
|
|
25
|
+
<Button
|
|
26
|
+
emphasis="ghost"
|
|
27
|
+
tone="neutral"
|
|
28
|
+
size="sm"
|
|
29
|
+
data-icon-only=""
|
|
30
|
+
aria-label="Notification settings"
|
|
31
|
+
onClick={settings}
|
|
32
|
+
>
|
|
33
|
+
<G name="more" />
|
|
34
|
+
</Button>
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function InboxTabs({
|
|
41
|
+
tabs,
|
|
42
|
+
model,
|
|
43
|
+
}: {
|
|
44
|
+
tabs: InboxTab[]
|
|
45
|
+
model: ReturnType<typeof inboxModel>
|
|
46
|
+
}) {
|
|
47
|
+
return (
|
|
48
|
+
<div data-scope="tabs" data-part="root">
|
|
49
|
+
<div
|
|
50
|
+
ref={model.setTablist}
|
|
51
|
+
data-part="list"
|
|
52
|
+
role="tablist"
|
|
53
|
+
aria-label="Filter"
|
|
54
|
+
onKeyDown={model.onTabKey}
|
|
55
|
+
>
|
|
56
|
+
{tabs.map((t) => (
|
|
57
|
+
<button
|
|
58
|
+
key={t}
|
|
59
|
+
data-part="trigger"
|
|
60
|
+
role="tab"
|
|
61
|
+
type="button"
|
|
62
|
+
id={model.tabId(t)}
|
|
63
|
+
aria-controls={`${model.id}-panel`}
|
|
64
|
+
aria-selected={t === model.tab.value ? 'true' : 'false'}
|
|
65
|
+
tabindex={t === model.tab.value ? undefined : '-1'}
|
|
66
|
+
onClick={() => model.pick(t)}
|
|
67
|
+
>
|
|
68
|
+
{TABS[t]}
|
|
69
|
+
{t === 'unread' && (
|
|
70
|
+
<>
|
|
71
|
+
{' '}
|
|
72
|
+
<Badge count>{model.unread.value}</Badge>
|
|
73
|
+
</>
|
|
74
|
+
)}
|
|
75
|
+
</button>
|
|
76
|
+
))}
|
|
77
|
+
<span data-part="indicator" aria-hidden="true" data-instant=""></span>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
}
|