@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,61 @@
|
|
|
1
|
+
import '@kerf-js/veneer-core/styles/rich/body.css'
|
|
2
|
+
import '@kerf-js/veneer-core/styles/rich/rich-text.css'
|
|
3
|
+
import '@kerf-js/veneer-core/styles/rich/listbox.css'
|
|
4
|
+
import '@kerf-js/veneer-core/styles/rich/popover.css'
|
|
5
|
+
import '@kerf-js/veneer-core/styles/rich/helpers.css'
|
|
6
|
+
import { SLASH } from './tools'
|
|
7
|
+
import type { RichTextEditorProps } from './tools'
|
|
8
|
+
import { EditorBody } from './view'
|
|
9
|
+
import { editorState } from './controller'
|
|
10
|
+
import { Field } from '../Field'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A rich text field (04 RichTextEditor; inputs-rich.html:1522): the editor frame is the field. The toolbar is an APG
|
|
14
|
+
* Toolbar, one tab stop with ←/→ inside. Markdown shortcuts open a block at the start of a line; `/` on an empty line and
|
|
15
|
+
* `@` open a list at the caret. Everything that enters the editor, a value or a paste, goes through veneer-core's allow-list.
|
|
16
|
+
*/
|
|
17
|
+
export function RichTextEditor({
|
|
18
|
+
value,
|
|
19
|
+
defaultValue,
|
|
20
|
+
onValueChange,
|
|
21
|
+
format = 'html',
|
|
22
|
+
toolbar = 'fixed',
|
|
23
|
+
marks = ['bold', 'italic', 'strike', 'code', 'link'],
|
|
24
|
+
blocks = ['h2', 'ul', 'ol', 'quote'],
|
|
25
|
+
commands = SLASH,
|
|
26
|
+
mentions,
|
|
27
|
+
placeholder = 'Write, or type / for blocks…',
|
|
28
|
+
minRows,
|
|
29
|
+
maxRows,
|
|
30
|
+
name,
|
|
31
|
+
hint,
|
|
32
|
+
...rest
|
|
33
|
+
}: RichTextEditorProps) {
|
|
34
|
+
const { held, menuOpen, view } = editorState({
|
|
35
|
+
value: () => value,
|
|
36
|
+
defaultValue: () => defaultValue,
|
|
37
|
+
onValueChange: () => onValueChange,
|
|
38
|
+
format: () => format,
|
|
39
|
+
toolbar: () => toolbar,
|
|
40
|
+
marks: () => marks,
|
|
41
|
+
blocks: () => blocks,
|
|
42
|
+
commands: () => commands,
|
|
43
|
+
mentions: () => mentions,
|
|
44
|
+
placeholder: () => placeholder,
|
|
45
|
+
minRows: () => minRows,
|
|
46
|
+
maxRows: () => maxRows,
|
|
47
|
+
name: () => name,
|
|
48
|
+
})
|
|
49
|
+
return (
|
|
50
|
+
<Field
|
|
51
|
+
{...rest}
|
|
52
|
+
hint={hint ?? 'Markdown shortcuts work at the start of a line. Esc closes menus.'}
|
|
53
|
+
group
|
|
54
|
+
filled
|
|
55
|
+
reset={held.reset}
|
|
56
|
+
hold={menuOpen.value}
|
|
57
|
+
attrs={{ 'data-multiline': '' }}
|
|
58
|
+
control={(p) => <EditorBody view={view} p={p} />}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { RichTextHandle, MentionItem } from '@kerf-js/veneer-core'
|
|
2
|
+
import type { FieldShell } from '../Field'
|
|
3
|
+
import type { Bindable } from '../bind'
|
|
4
|
+
import {
|
|
5
|
+
CodeIcon,
|
|
6
|
+
LinkIcon,
|
|
7
|
+
ListIcon,
|
|
8
|
+
ListOrderedIcon,
|
|
9
|
+
QuoteIcon,
|
|
10
|
+
CodeBlockIcon,
|
|
11
|
+
} from '@kerf-js/veneer-icons'
|
|
12
|
+
|
|
13
|
+
/** An entry in the editor's slash menu. */
|
|
14
|
+
export type SlashCommand = {
|
|
15
|
+
id: string
|
|
16
|
+
label: string
|
|
17
|
+
hint?: string
|
|
18
|
+
shortcut?: string
|
|
19
|
+
run: (editor: RichTextHandle) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Mark = 'bold' | 'italic' | 'strike' | 'code' | 'link'
|
|
23
|
+
|
|
24
|
+
type Block = 'h2' | 'h3' | 'ul' | 'ol' | 'quote' | 'codeblock'
|
|
25
|
+
|
|
26
|
+
/** Props for RichTextEditor. */
|
|
27
|
+
export type RichTextEditorProps = FieldShell &
|
|
28
|
+
Bindable<string> & {
|
|
29
|
+
format?: 'html' | 'markdown' | undefined
|
|
30
|
+
/** fixed (default) in the frame, bubble over a selection, or none. A phone docks either above the keyboard. */
|
|
31
|
+
toolbar?: 'fixed' | 'bubble' | 'none'
|
|
32
|
+
marks?: Mark[]
|
|
33
|
+
blocks?: Block[]
|
|
34
|
+
commands?: SlashCommand[]
|
|
35
|
+
mentions?: { search: (q: string, signal: AbortSignal) => Promise<MentionItem[]> }
|
|
36
|
+
placeholder?: string
|
|
37
|
+
minRows?: number
|
|
38
|
+
maxRows?: number
|
|
39
|
+
name?: string | undefined
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type Tool = {
|
|
43
|
+
cmd: string
|
|
44
|
+
label: string
|
|
45
|
+
tip: string
|
|
46
|
+
glyph: () => unknown
|
|
47
|
+
style?: string
|
|
48
|
+
toggles?: boolean
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const TOOLS: Record<Mark | Block, Tool> = {
|
|
52
|
+
h2: { cmd: 'h2', label: 'H2 heading', tip: 'Heading · # ', glyph: () => 'H2', toggles: true },
|
|
53
|
+
h3: {
|
|
54
|
+
cmd: 'h3',
|
|
55
|
+
label: 'H3 subheading',
|
|
56
|
+
tip: 'Subheading · ### ',
|
|
57
|
+
glyph: () => 'H3',
|
|
58
|
+
toggles: true,
|
|
59
|
+
},
|
|
60
|
+
bold: {
|
|
61
|
+
cmd: 'bold',
|
|
62
|
+
label: 'Bold',
|
|
63
|
+
tip: 'Bold · ⌘B',
|
|
64
|
+
glyph: () => 'B',
|
|
65
|
+
style: 'font-weight:700',
|
|
66
|
+
toggles: true,
|
|
67
|
+
},
|
|
68
|
+
italic: {
|
|
69
|
+
cmd: 'italic',
|
|
70
|
+
label: 'Italic',
|
|
71
|
+
tip: 'Italic · ⌘I',
|
|
72
|
+
glyph: () => 'I',
|
|
73
|
+
style: 'font-style:italic;font-family:Georgia,serif;font-weight:400;font-size:16px',
|
|
74
|
+
toggles: true,
|
|
75
|
+
},
|
|
76
|
+
strike: {
|
|
77
|
+
cmd: 'strikeThrough',
|
|
78
|
+
label: 'Strikethrough',
|
|
79
|
+
tip: 'Strikethrough',
|
|
80
|
+
glyph: () => 'S',
|
|
81
|
+
style: 'text-decoration:line-through;font-weight:500',
|
|
82
|
+
toggles: true,
|
|
83
|
+
},
|
|
84
|
+
code: {
|
|
85
|
+
cmd: 'code',
|
|
86
|
+
label: 'Inline code',
|
|
87
|
+
tip: 'Code · `text`',
|
|
88
|
+
glyph: () => <CodeIcon />,
|
|
89
|
+
toggles: true,
|
|
90
|
+
},
|
|
91
|
+
link: { cmd: 'link', label: 'Link', tip: 'Link · ⌘K', glyph: () => <LinkIcon />, toggles: true },
|
|
92
|
+
ul: {
|
|
93
|
+
cmd: 'insertUnorderedList',
|
|
94
|
+
label: 'Bulleted list',
|
|
95
|
+
tip: 'Bullets · - ',
|
|
96
|
+
glyph: () => <ListIcon />,
|
|
97
|
+
toggles: true,
|
|
98
|
+
},
|
|
99
|
+
ol: {
|
|
100
|
+
cmd: 'insertOrderedList',
|
|
101
|
+
label: 'Numbered list',
|
|
102
|
+
tip: 'Numbers · 1. ',
|
|
103
|
+
glyph: () => <ListOrderedIcon />,
|
|
104
|
+
toggles: true,
|
|
105
|
+
},
|
|
106
|
+
quote: {
|
|
107
|
+
cmd: 'blockquote',
|
|
108
|
+
label: 'Quote',
|
|
109
|
+
tip: 'Quote · > ',
|
|
110
|
+
glyph: () => <QuoteIcon />,
|
|
111
|
+
toggles: true,
|
|
112
|
+
},
|
|
113
|
+
codeblock: {
|
|
114
|
+
cmd: 'pre',
|
|
115
|
+
label: 'Code block',
|
|
116
|
+
tip: 'Code block · ```',
|
|
117
|
+
glyph: () => <CodeBlockIcon />,
|
|
118
|
+
toggles: true,
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const SLASH: SlashCommand[] = [
|
|
123
|
+
{ id: 'h2', label: 'Heading', hint: '#', run: (e) => e.run('h2') },
|
|
124
|
+
{ id: 'h3', label: 'Subheading', hint: '###', run: (e) => e.run('h3') },
|
|
125
|
+
{ id: 'ul', label: 'Bulleted list', hint: '-', run: (e) => e.run('insertUnorderedList') },
|
|
126
|
+
{ id: 'ol', label: 'Numbered list', hint: '1.', run: (e) => e.run('insertOrderedList') },
|
|
127
|
+
{ id: 'quote', label: 'Quote', hint: '>', run: (e) => e.run('blockquote') },
|
|
128
|
+
{ id: 'code', label: 'Code block', hint: '```', run: (e) => e.run('pre') },
|
|
129
|
+
{ id: 'divider', label: 'Divider', hint: '---', run: (e) => e.run('insertHorizontalRule') },
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
export type MenuRow = { id: string; main: string; meta?: string | undefined; run: () => void }
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { RichTextHandle } from '@kerf-js/veneer-core'
|
|
2
|
+
import type { State } from '@kerf-js/core'
|
|
3
|
+
import { UndoIcon } from '@kerf-js/veneer-icons'
|
|
4
|
+
import { Button } from '../Button'
|
|
5
|
+
import type { Control } from '../Field'
|
|
6
|
+
import { Tooltip } from '../Tooltip'
|
|
7
|
+
import type { RichTextEditorProps, Tool, MenuRow } from './tools'
|
|
8
|
+
|
|
9
|
+
export type EditorView = {
|
|
10
|
+
id: string
|
|
11
|
+
toolbar: NonNullable<RichTextEditorProps['toolbar']>
|
|
12
|
+
placeholder: string
|
|
13
|
+
name: string | undefined
|
|
14
|
+
held: { readonly value: string }
|
|
15
|
+
start: string
|
|
16
|
+
tools: { readonly value: Tool[][] }
|
|
17
|
+
flat: { readonly value: Tool[] }
|
|
18
|
+
pressed: State<Record<string, boolean>>
|
|
19
|
+
stop: State<number>
|
|
20
|
+
linking: State<boolean>
|
|
21
|
+
url: State<string>
|
|
22
|
+
items: State<MenuRow[]>
|
|
23
|
+
active: State<number>
|
|
24
|
+
menuOpen: State<boolean>
|
|
25
|
+
said: State<string>
|
|
26
|
+
handle(): RichTextHandle | undefined
|
|
27
|
+
setEditor(n: HTMLDivElement): void
|
|
28
|
+
setBar(n: HTMLDivElement): void
|
|
29
|
+
setPop(n: HTMLDivElement): void
|
|
30
|
+
setMark(n: HTMLSpanElement): void
|
|
31
|
+
setLink(n: HTMLInputElement): void
|
|
32
|
+
rows(): string | undefined
|
|
33
|
+
onToolKey: (e: KeyboardEvent) => void
|
|
34
|
+
onMenuKey: (e: KeyboardEvent) => void
|
|
35
|
+
startLink(): void
|
|
36
|
+
endLink(apply: boolean): void
|
|
37
|
+
choose(at: number): void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function EditorBody({ view, p }: { view: EditorView; p: Parameters<Control>[0] }) {
|
|
41
|
+
return (
|
|
42
|
+
<div data-scope="rte">
|
|
43
|
+
<div data-part="frame">
|
|
44
|
+
{view.toolbar !== 'none' && <EditorToolbar view={view} />}
|
|
45
|
+
{view.linking.value && <EditorLinkBar view={view} />}
|
|
46
|
+
<EditorContent view={view} p={p} />
|
|
47
|
+
</div>
|
|
48
|
+
<span
|
|
49
|
+
ref={(n) => view.setMark(n)}
|
|
50
|
+
data-part="caret-anchor"
|
|
51
|
+
style="position:fixed"
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
></span>
|
|
54
|
+
<EditorMenu view={view} />
|
|
55
|
+
<span data-part="sr-only" role="status">
|
|
56
|
+
{view.said.value}
|
|
57
|
+
</span>
|
|
58
|
+
{view.name && <input type="hidden" name={view.name} value={view.held.value} />}
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function EditorToolbar({ view }: { view: EditorView }) {
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
ref={(n) => view.setBar(n)}
|
|
67
|
+
role="toolbar"
|
|
68
|
+
aria-label="Formatting"
|
|
69
|
+
aria-controls={`${view.id}-c`}
|
|
70
|
+
popover={view.toolbar === 'bubble' ? 'manual' : undefined}
|
|
71
|
+
data-bubble={view.toolbar === 'bubble' ? '' : undefined}
|
|
72
|
+
onKeyDown={view.onToolKey}
|
|
73
|
+
onPointerDown={(e) => {
|
|
74
|
+
if ((e.target as Element).closest?.('[data-part="tool"]')) e.preventDefault()
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{view.tools.value.map((g, i) => (
|
|
78
|
+
<span key={g[0]!.cmd} style="display:contents">
|
|
79
|
+
{i > 0 && <span data-part="sep"></span>}
|
|
80
|
+
{g.map((t) => (
|
|
81
|
+
<EditorTool key={t.cmd} tool={t} view={view} />
|
|
82
|
+
))}
|
|
83
|
+
</span>
|
|
84
|
+
))}
|
|
85
|
+
<span data-part="sep"></span>
|
|
86
|
+
<Tooltip content="Undo" kbd="⌘Z">
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
data-part="tool"
|
|
90
|
+
tabindex="-1"
|
|
91
|
+
aria-label="Undo"
|
|
92
|
+
onClick={() => view.handle()!.run('undo')}
|
|
93
|
+
>
|
|
94
|
+
<UndoIcon />
|
|
95
|
+
</button>
|
|
96
|
+
</Tooltip>
|
|
97
|
+
</div>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function EditorTool({ tool: t, view }: { tool: Tool; view: EditorView }) {
|
|
102
|
+
return (
|
|
103
|
+
<Tooltip content={t.tip}>
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
data-part="tool"
|
|
107
|
+
tabindex={view.flat.value[view.stop.value] === t ? '0' : '-1'}
|
|
108
|
+
aria-label={t.label}
|
|
109
|
+
aria-pressed={view.pressed.get(t.cmd) ? 'true' : 'false'}
|
|
110
|
+
style={t.style}
|
|
111
|
+
onClick={() =>
|
|
112
|
+
t.cmd === 'link' ? (view.handle()!.save(), view.startLink()) : view.handle()!.run(t.cmd)
|
|
113
|
+
}
|
|
114
|
+
>
|
|
115
|
+
{t.glyph()}
|
|
116
|
+
</button>
|
|
117
|
+
</Tooltip>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function EditorLinkBar({ view }: { view: EditorView }) {
|
|
122
|
+
return (
|
|
123
|
+
<div data-part="linkbar">
|
|
124
|
+
<label data-part="sr-only" for={`${view.id}-url`}>
|
|
125
|
+
Link address
|
|
126
|
+
</label>
|
|
127
|
+
<input
|
|
128
|
+
ref={(n) => view.setLink(n)}
|
|
129
|
+
type="url"
|
|
130
|
+
id={`${view.id}-url`}
|
|
131
|
+
placeholder="https://"
|
|
132
|
+
value={view.url.value}
|
|
133
|
+
onInput={(e: Event) => (view.url.value = (e.currentTarget as HTMLInputElement).value)}
|
|
134
|
+
onKeyDown={(e: KeyboardEvent) => {
|
|
135
|
+
if (e.key === 'Enter') {
|
|
136
|
+
e.preventDefault()
|
|
137
|
+
view.endLink(true)
|
|
138
|
+
} else if (e.key === 'Escape') {
|
|
139
|
+
e.preventDefault()
|
|
140
|
+
e.stopPropagation()
|
|
141
|
+
view.endLink(false)
|
|
142
|
+
}
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
<Button size="sm" onClick={() => view.endLink(true)}>
|
|
146
|
+
Apply
|
|
147
|
+
</Button>
|
|
148
|
+
<Button emphasis="ghost" tone="neutral" size="sm" onClick={() => view.endLink(false)}>
|
|
149
|
+
Cancel
|
|
150
|
+
</Button>
|
|
151
|
+
</div>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function EditorContent({ view, p }: { view: EditorView; p: Parameters<Control>[0] }) {
|
|
156
|
+
return (
|
|
157
|
+
<div
|
|
158
|
+
ref={(n) => view.setEditor(n)}
|
|
159
|
+
data-part="content"
|
|
160
|
+
id={`${view.id}-c`}
|
|
161
|
+
contenteditable="true"
|
|
162
|
+
tabindex="0"
|
|
163
|
+
role="textbox"
|
|
164
|
+
aria-multiline="true"
|
|
165
|
+
aria-labelledby={`${p.id}-l`}
|
|
166
|
+
aria-describedby={p.describedby}
|
|
167
|
+
aria-invalid={p.invalid ? 'true' : undefined}
|
|
168
|
+
aria-autocomplete="list"
|
|
169
|
+
aria-controls={`${view.id}-menu`}
|
|
170
|
+
aria-activedescendant={view.menuOpen.value ? `${view.id}-${view.active.value}` : undefined}
|
|
171
|
+
data-placeholder={view.placeholder}
|
|
172
|
+
spellcheck
|
|
173
|
+
style={view.rows()}
|
|
174
|
+
onKeyDown={view.onMenuKey}
|
|
175
|
+
// oxlint-disable-next-line kerf/no-html-sink -- `start` went through toHtml, which sanitizes
|
|
176
|
+
innerHTML={view.start}
|
|
177
|
+
></div>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function EditorMenu({ view }: { view: EditorView }) {
|
|
182
|
+
return (
|
|
183
|
+
<div
|
|
184
|
+
ref={(n) => view.setPop(n)}
|
|
185
|
+
data-scope="popover"
|
|
186
|
+
data-kind="combo"
|
|
187
|
+
data-sweep=""
|
|
188
|
+
popover="manual"
|
|
189
|
+
role="presentation"
|
|
190
|
+
onPointerDown={(e) => e.preventDefault()}
|
|
191
|
+
>
|
|
192
|
+
<span data-part="sweep" aria-hidden="true"></span>
|
|
193
|
+
<ul data-part="listbox" role="listbox" id={`${view.id}-menu`} aria-label="Insert">
|
|
194
|
+
{view.items.value.map((r, n) => (
|
|
195
|
+
<li
|
|
196
|
+
key={r.id}
|
|
197
|
+
role="option"
|
|
198
|
+
id={`${view.id}-${n}`}
|
|
199
|
+
aria-selected={n === view.active.value ? 'true' : 'false'}
|
|
200
|
+
data-active={n === view.active.value ? '' : undefined}
|
|
201
|
+
onClick={() => view.choose(n)}
|
|
202
|
+
>
|
|
203
|
+
<span>{r.main}</span>
|
|
204
|
+
{r.meta && <span data-part="opt-meta">{r.meta}</span>}
|
|
205
|
+
</li>
|
|
206
|
+
))}
|
|
207
|
+
</ul>
|
|
208
|
+
</div>
|
|
209
|
+
)
|
|
210
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '@kerf-js/veneer-core/styles/rich/body.css'
|
|
2
|
+
import '@kerf-js/veneer-core/styles/rich/rich-text.css'
|
|
3
|
+
import '@kerf-js/veneer-core/styles/rich/listbox.css'
|
|
4
|
+
import '@kerf-js/veneer-core/styles/rich/popover.css'
|
|
5
|
+
import '@kerf-js/veneer-core/styles/rich/helpers.css'
|
|
6
|
+
|
|
7
|
+
export { RichTextEditor } from './RichTextEditor/editor'
|
|
8
|
+
export type { SlashCommand } from './RichTextEditor/tools'
|
|
9
|
+
export type { RichTextEditorProps } from './RichTextEditor/tools'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { measureEngine } from '@kerf-js/core/text'
|
|
2
|
+
import { slices } from '@kerf-js/veneer-core'
|
|
3
|
+
import type { GridRuntime } from '../ScrollGrid'
|
|
4
|
+
import { LEADING } from './parts'
|
|
5
|
+
|
|
6
|
+
export function measureWrapped({
|
|
7
|
+
runtime,
|
|
8
|
+
rows,
|
|
9
|
+
size,
|
|
10
|
+
count,
|
|
11
|
+
}: {
|
|
12
|
+
runtime: GridRuntime
|
|
13
|
+
rows: { value: number[] }
|
|
14
|
+
size: (row: number) => number
|
|
15
|
+
count: number
|
|
16
|
+
}) {
|
|
17
|
+
void measureEngine().then((e) => {
|
|
18
|
+
if (!e || !runtime.el) return
|
|
19
|
+
const c = getComputedStyle(runtime.el)
|
|
20
|
+
runtime.font = `${c.fontWeight} ${c.fontSize} ${c.fontFamily}`
|
|
21
|
+
runtime.line = parseFloat(c.fontSize) * LEADING
|
|
22
|
+
runtime.engine = e
|
|
23
|
+
runtime.ys!.refresh(rows.value[0] ?? 0, (rows.value.at(-1) ?? 0) + 1)
|
|
24
|
+
let at = 0,
|
|
25
|
+
lo = 0
|
|
26
|
+
runtime.stop = slices(() => {
|
|
27
|
+
if (at >= count) {
|
|
28
|
+
runtime.ys!.refresh(lo, at)
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
size(at++)
|
|
32
|
+
if (at - lo >= 256) {
|
|
33
|
+
runtime.ys!.refresh(lo, at)
|
|
34
|
+
lo = at
|
|
35
|
+
}
|
|
36
|
+
return true
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { untrack } from '@kerf-js/core'
|
|
2
|
+
import type { GridColumn, ScrollGridProps } from '../ScrollGrid'
|
|
3
|
+
|
|
4
|
+
export const CW = 104,
|
|
5
|
+
LEADING = 1.4,
|
|
6
|
+
PAD = 12
|
|
7
|
+
|
|
8
|
+
type GridWatch = (node: () => HTMLElement, axis: 'x' | 'y', key: number) => void
|
|
9
|
+
export function makeCell({
|
|
10
|
+
props,
|
|
11
|
+
watch,
|
|
12
|
+
active,
|
|
13
|
+
cellId,
|
|
14
|
+
focusCell,
|
|
15
|
+
hw,
|
|
16
|
+
}: {
|
|
17
|
+
props: ScrollGridProps
|
|
18
|
+
watch: GridWatch
|
|
19
|
+
active: { readonly value: [number, number] }
|
|
20
|
+
cellId: (row: number, column: number) => string
|
|
21
|
+
focusCell: (cell: [number, number], align?: boolean) => void
|
|
22
|
+
hw: number
|
|
23
|
+
}) {
|
|
24
|
+
function Cell(p: { r: number; entry: { c: number; col: GridColumn } }) {
|
|
25
|
+
let node: HTMLElement | undefined
|
|
26
|
+
const c = untrack(() => p.entry.c)
|
|
27
|
+
watch(() => node!, 'x', c)
|
|
28
|
+
const on = () => active.value[0] === p.r && active.value[1] === c
|
|
29
|
+
const wrap = () => p.entry.col.wrap
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
ref={(n) => (node = n)}
|
|
33
|
+
id={cellId(p.r, c)}
|
|
34
|
+
data-part="cell"
|
|
35
|
+
role="gridcell"
|
|
36
|
+
aria-colindex={c + 2}
|
|
37
|
+
aria-selected={on() ? 'true' : undefined}
|
|
38
|
+
data-active={on() ? '' : undefined}
|
|
39
|
+
data-neg={props.negative?.(p.r, p.entry.col) ? '' : undefined}
|
|
40
|
+
style={`inline-size:${p.entry.col.width ?? CW}px;block-size:100%;transform:translateX(${hw + c * CW}px)${wrap() ? `;white-space:normal;line-height:${LEADING};justify-content:start;align-items:start;padding-block:${PAD / 2}px` : ''}`}
|
|
41
|
+
onPointerDown={() => focusCell([p.r, c], false)}
|
|
42
|
+
>
|
|
43
|
+
{props.cell(p.r, p.entry.col)}
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
return Cell
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function makeHead(watch: GridWatch, hw: number) {
|
|
51
|
+
function Head(p: { entry: { c: number; col: GridColumn } }) {
|
|
52
|
+
let node: HTMLElement | undefined
|
|
53
|
+
const c = untrack(() => p.entry.c)
|
|
54
|
+
watch(() => node!, 'x', c)
|
|
55
|
+
return (
|
|
56
|
+
<div
|
|
57
|
+
ref={(n) => (node = n)}
|
|
58
|
+
data-part="col-head"
|
|
59
|
+
role="columnheader"
|
|
60
|
+
aria-colindex={c + 2}
|
|
61
|
+
style={`inline-size:${p.entry.col.width ?? CW}px;transform:translateX(${hw + c * CW}px)`}
|
|
62
|
+
>
|
|
63
|
+
{p.entry.col.header}
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
return Head
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function makeRow({
|
|
71
|
+
props,
|
|
72
|
+
watch,
|
|
73
|
+
shownCols,
|
|
74
|
+
hw,
|
|
75
|
+
rh,
|
|
76
|
+
Cell,
|
|
77
|
+
}: {
|
|
78
|
+
props: ScrollGridProps
|
|
79
|
+
watch: GridWatch
|
|
80
|
+
shownCols: { readonly value: { c: number; col: GridColumn }[] }
|
|
81
|
+
hw: number
|
|
82
|
+
rh: number
|
|
83
|
+
Cell: ReturnType<typeof makeCell>
|
|
84
|
+
}) {
|
|
85
|
+
function Row(p: { r: number }) {
|
|
86
|
+
let node: HTMLElement | undefined
|
|
87
|
+
const r = untrack(() => p.r)
|
|
88
|
+
watch(() => node!, 'y', r)
|
|
89
|
+
return (
|
|
90
|
+
<div
|
|
91
|
+
ref={(n) => (node = n)}
|
|
92
|
+
data-part="row"
|
|
93
|
+
role="row"
|
|
94
|
+
aria-rowindex={r + 2}
|
|
95
|
+
style={`inline-size:${hw}px;min-inline-size:100%;transform:translateY(${rh + r * rh}px)`}
|
|
96
|
+
>
|
|
97
|
+
<div
|
|
98
|
+
data-part="row-head"
|
|
99
|
+
role="rowheader"
|
|
100
|
+
aria-colindex="1"
|
|
101
|
+
style={`position:sticky;inset-inline-start:0;inline-size:${hw}px;block-size:100%`}
|
|
102
|
+
>
|
|
103
|
+
{props.rowHeader(r)}
|
|
104
|
+
</div>
|
|
105
|
+
{shownCols.value.map((e) => (
|
|
106
|
+
<Cell key={e.c} r={r} entry={e} />
|
|
107
|
+
))}
|
|
108
|
+
</div>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
return Row
|
|
112
|
+
}
|