@k2b/ui 0.59.0 → 0.61.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/dist/browser/actions/CommandList.js +67 -74
- package/dist/browser/actions/CommandList.js.map +1 -1
- package/dist/browser/actions/ContextMenu.js +11 -2
- package/dist/browser/actions/ContextMenu.js.map +1 -1
- package/dist/browser/actions/Dropdown.js +187 -169
- package/dist/browser/actions/Dropdown.js.map +1 -1
- package/dist/browser/actions/GestureMenu.js +18 -7
- package/dist/browser/actions/GestureMenu.js.map +1 -1
- package/dist/browser/actions/SelectionAction.js +232 -0
- package/dist/browser/actions/SelectionAction.js.map +1 -0
- package/dist/browser/actions/command-items.js.map +1 -1
- package/dist/browser/actions/index.js +1 -0
- package/dist/browser/actions/index.js.map +1 -1
- package/dist/browser/actions/menu-sheet-open.js +19 -0
- package/dist/browser/actions/menu-sheet-open.js.map +1 -0
- package/dist/browser/charts/core/line-details.js +2 -2
- package/dist/browser/charts/core/line-details.js.map +1 -1
- package/dist/browser/charts/core/render.js +2 -1
- package/dist/browser/charts/core/render.js.map +1 -1
- package/dist/browser/chat/ChatActivityWords.js +142 -0
- package/dist/browser/chat/ChatActivityWords.js.map +1 -0
- package/dist/browser/chat/ChatComposer.js +540 -515
- package/dist/browser/chat/ChatComposer.js.map +1 -1
- package/dist/browser/chat/ChatComposerQuotes.js +56 -0
- package/dist/browser/chat/ChatComposerQuotes.js.map +1 -0
- package/dist/browser/chat/ChatPrimitives.js +440 -389
- package/dist/browser/chat/ChatPrimitives.js.map +1 -1
- package/dist/browser/chat/ChatTasks.js +78 -73
- package/dist/browser/chat/ChatTasks.js.map +1 -1
- package/dist/browser/chat/ChatTimeline.js +3 -0
- package/dist/browser/chat/ChatTimeline.js.map +1 -1
- package/dist/browser/chat/index.js +4 -1
- package/dist/browser/chat/index.js.map +1 -1
- package/dist/browser/content/ActivityList.js +789 -0
- package/dist/browser/content/ActivityList.js.map +1 -0
- package/dist/browser/content/DataTableTools.js +3 -0
- package/dist/browser/content/DataTableTools.js.map +1 -1
- package/dist/browser/content/Lightbox.js +33 -11
- package/dist/browser/content/Lightbox.js.map +1 -1
- package/dist/browser/content/MessageQuote.js +57 -0
- package/dist/browser/content/MessageQuote.js.map +1 -0
- package/dist/browser/content/MessageRow.js +413 -391
- package/dist/browser/content/MessageRow.js.map +1 -1
- package/dist/browser/content/PdfPages.js +26 -1
- package/dist/browser/content/PdfPages.js.map +1 -1
- package/dist/browser/content/RunLog.js +719 -0
- package/dist/browser/content/RunLog.js.map +1 -0
- package/dist/browser/content/VirtualFeed.js +29 -2
- package/dist/browser/content/VirtualFeed.js.map +1 -1
- package/dist/browser/content/activity-messages.js +47 -0
- package/dist/browser/content/activity-messages.js.map +1 -0
- package/dist/browser/content/activity-timeline.js +144 -0
- package/dist/browser/content/activity-timeline.js.map +1 -0
- package/dist/browser/content/chart-time-calendar.js +12 -18
- package/dist/browser/content/chart-time-calendar.js.map +1 -1
- package/dist/browser/content/find-text.js +47 -0
- package/dist/browser/content/find-text.js.map +1 -0
- package/dist/browser/content/index.js +2 -0
- package/dist/browser/content/index.js.map +1 -1
- package/dist/browser/content/quote-messages.js +25 -0
- package/dist/browser/content/quote-messages.js.map +1 -0
- package/dist/browser/content/run-log-messages.js +134 -0
- package/dist/browser/content/run-log-messages.js.map +1 -0
- package/dist/browser/feedback/dialog-core.js +118 -14
- package/dist/browser/feedback/dialog-core.js.map +1 -1
- package/dist/browser/feedback/dialog-frame-motion.js +274 -0
- package/dist/browser/feedback/dialog-frame-motion.js.map +1 -0
- package/dist/browser/feedback/prompt-sheet-view.js +2 -1
- package/dist/browser/feedback/prompt-sheet-view.js.map +1 -1
- package/dist/browser/feedback/prompts.js +49 -53
- package/dist/browser/feedback/prompts.js.map +1 -1
- package/dist/browser/feedback/toast.js +11 -1
- package/dist/browser/feedback/toast.js.map +1 -1
- package/dist/browser/hover-card.js +6 -0
- package/dist/browser/hover-card.js.map +1 -0
- package/dist/browser/inputs/AutocompleteEditor.js +2 -1
- package/dist/browser/inputs/AutocompleteEditor.js.map +1 -1
- package/dist/browser/inputs/AutocompleteSelect.js +3 -12
- package/dist/browser/inputs/AutocompleteSelect.js.map +1 -1
- package/dist/browser/inputs/ChoiceList.js +131 -127
- package/dist/browser/inputs/ChoiceList.js.map +1 -1
- package/dist/browser/inputs/Combobox.js +6 -15
- package/dist/browser/inputs/Combobox.js.map +1 -1
- package/dist/browser/inputs/MultiSelectInput.js +7 -16
- package/dist/browser/inputs/MultiSelectInput.js.map +1 -1
- package/dist/browser/inputs/PeriodPicker.js +475 -252
- package/dist/browser/inputs/PeriodPicker.js.map +1 -1
- package/dist/browser/inputs/RichSelect.js +431 -431
- package/dist/browser/inputs/RichSelect.js.map +1 -1
- package/dist/browser/inputs/Select.js +3 -12
- package/dist/browser/inputs/Select.js.map +1 -1
- package/dist/browser/inputs/SelectChip.js +1 -0
- package/dist/browser/inputs/SelectChip.js.map +1 -1
- package/dist/browser/inputs/TimeInput.js +181 -0
- package/dist/browser/inputs/TimeInput.js.map +1 -0
- package/dist/browser/inputs/choice.js.map +1 -1
- package/dist/browser/inputs/date-picker.js +2 -1
- package/dist/browser/inputs/date-picker.js.map +1 -1
- package/dist/browser/inputs/file-drop.js +2 -0
- package/dist/browser/inputs/file-drop.js.map +1 -1
- package/dist/browser/inputs/index.js +1 -0
- package/dist/browser/inputs/index.js.map +1 -1
- package/dist/browser/inputs/input-messages.js +20 -2
- package/dist/browser/inputs/input-messages.js.map +1 -1
- package/dist/browser/inputs/period-picker-messages.js +20 -2
- package/dist/browser/inputs/period-picker-messages.js.map +1 -1
- package/dist/browser/inputs/period.js +83 -0
- package/dist/browser/inputs/period.js.map +1 -1
- package/dist/browser/inputs/time-input.js +93 -0
- package/dist/browser/inputs/time-input.js.map +1 -0
- package/dist/browser/internal/exit-motion.js +23 -0
- package/dist/browser/internal/exit-motion.js.map +1 -0
- package/dist/browser/internal/option-description.js +47 -0
- package/dist/browser/internal/option-description.js.map +1 -0
- package/dist/browser/internal/scroll-places.js +15 -0
- package/dist/browser/internal/scroll-places.js.map +1 -0
- package/dist/browser/internal/step-row.js +78 -0
- package/dist/browser/internal/step-row.js.map +1 -0
- package/dist/browser/layout/AppWorkspace.js +572 -495
- package/dist/browser/layout/AppWorkspace.js.map +1 -1
- package/dist/browser/layout/BottomSheet.js +2 -14
- package/dist/browser/layout/BottomSheet.js.map +1 -1
- package/dist/browser/layout/Navigation.js +7 -2
- package/dist/browser/layout/Navigation.js.map +1 -1
- package/dist/browser/layout/PullToRefresh.js +76 -23
- package/dist/browser/layout/PullToRefresh.js.map +1 -1
- package/dist/browser/layout/SidebarSwitcher.js +28 -37
- package/dist/browser/layout/SidebarSwitcher.js.map +1 -1
- package/dist/browser/layout/app-workspace-controller.js +5 -1
- package/dist/browser/layout/app-workspace-controller.js.map +1 -1
- package/dist/browser/layout/bottom-sheet-load.js +17 -0
- package/dist/browser/layout/bottom-sheet-load.js.map +1 -0
- package/dist/browser/layout/bottom-sheet-options.js +27 -0
- package/dist/browser/layout/bottom-sheet-options.js.map +1 -0
- package/dist/browser/layout/index.js +2 -1
- package/dist/browser/layout/index.js.map +1 -1
- package/dist/browser/layout/refresh-messages.js +4 -2
- package/dist/browser/layout/refresh-messages.js.map +1 -1
- package/dist/browser/layout/sheet-motion.js +10 -11
- package/dist/browser/layout/sheet-motion.js.map +1 -1
- package/dist/browser/layout/sidebar-scroll-memory.js +30 -0
- package/dist/browser/layout/sidebar-scroll-memory.js.map +1 -1
- package/dist/browser/surfaces/AvatarStack.js +59 -43
- package/dist/browser/surfaces/AvatarStack.js.map +1 -1
- package/dist/browser/surfaces/LinkCard.js.map +1 -1
- package/dist/browser/surfaces/Section.js +4 -2
- package/dist/browser/surfaces/Section.js.map +1 -1
- package/dist/browser/surfaces/StatCell.js +56 -28
- package/dist/browser/surfaces/StatCell.js.map +1 -1
- package/dist/browser/surfaces/StatGrid.js +17 -8
- package/dist/browser/surfaces/StatGrid.js.map +1 -1
- package/dist/browser/surfaces/index.js.map +1 -1
- package/dist/ssr/actions/CommandList.js +23 -26
- package/dist/ssr/actions/CommandList.js.map +1 -1
- package/dist/ssr/actions/ContextMenu.js +8 -2
- package/dist/ssr/actions/ContextMenu.js.map +1 -1
- package/dist/ssr/actions/Dropdown.js +79 -55
- package/dist/ssr/actions/Dropdown.js.map +1 -1
- package/dist/ssr/actions/GestureMenu.js +18 -7
- package/dist/ssr/actions/GestureMenu.js.map +1 -1
- package/dist/ssr/actions/SelectionAction.js +212 -0
- package/dist/ssr/actions/SelectionAction.js.map +1 -0
- package/dist/ssr/actions/command-items.js.map +1 -1
- package/dist/ssr/actions/index.js +1 -0
- package/dist/ssr/actions/index.js.map +1 -1
- package/dist/ssr/actions/menu-sheet-open.js +19 -0
- package/dist/ssr/actions/menu-sheet-open.js.map +1 -0
- package/dist/ssr/charts/core/line-details.js +2 -2
- package/dist/ssr/charts/core/line-details.js.map +1 -1
- package/dist/ssr/charts/core/render.js +2 -1
- package/dist/ssr/charts/core/render.js.map +1 -1
- package/dist/ssr/chat/ChatActivityWords.js +126 -0
- package/dist/ssr/chat/ChatActivityWords.js.map +1 -0
- package/dist/ssr/chat/ChatComposer.js +24 -3
- package/dist/ssr/chat/ChatComposer.js.map +1 -1
- package/dist/ssr/chat/ChatComposerQuotes.js +26 -0
- package/dist/ssr/chat/ChatComposerQuotes.js.map +1 -0
- package/dist/ssr/chat/ChatPrimitives.js +121 -77
- package/dist/ssr/chat/ChatPrimitives.js.map +1 -1
- package/dist/ssr/chat/ChatTasks.js +31 -16
- package/dist/ssr/chat/ChatTasks.js.map +1 -1
- package/dist/ssr/chat/ChatTimeline.js +3 -0
- package/dist/ssr/chat/ChatTimeline.js.map +1 -1
- package/dist/ssr/chat/index.js +4 -1
- package/dist/ssr/chat/index.js.map +1 -1
- package/dist/ssr/content/ActivityList.js +553 -0
- package/dist/ssr/content/ActivityList.js.map +1 -0
- package/dist/ssr/content/DataTableTools.js +3 -0
- package/dist/ssr/content/DataTableTools.js.map +1 -1
- package/dist/ssr/content/Lightbox.js +33 -11
- package/dist/ssr/content/Lightbox.js.map +1 -1
- package/dist/ssr/content/MessageQuote.js +36 -0
- package/dist/ssr/content/MessageQuote.js.map +1 -0
- package/dist/ssr/content/MessageRow.js +112 -95
- package/dist/ssr/content/MessageRow.js.map +1 -1
- package/dist/ssr/content/PdfPages.js +26 -1
- package/dist/ssr/content/PdfPages.js.map +1 -1
- package/dist/ssr/content/RunLog.js +471 -0
- package/dist/ssr/content/RunLog.js.map +1 -0
- package/dist/ssr/content/VirtualFeed.js +29 -2
- package/dist/ssr/content/VirtualFeed.js.map +1 -1
- package/dist/ssr/content/activity-messages.js +47 -0
- package/dist/ssr/content/activity-messages.js.map +1 -0
- package/dist/ssr/content/activity-timeline.js +144 -0
- package/dist/ssr/content/activity-timeline.js.map +1 -0
- package/dist/ssr/content/chart-time-calendar.js +12 -18
- package/dist/ssr/content/chart-time-calendar.js.map +1 -1
- package/dist/ssr/content/find-text.js +47 -0
- package/dist/ssr/content/find-text.js.map +1 -0
- package/dist/ssr/content/index.js +2 -0
- package/dist/ssr/content/index.js.map +1 -1
- package/dist/ssr/content/quote-messages.js +25 -0
- package/dist/ssr/content/quote-messages.js.map +1 -0
- package/dist/ssr/content/run-log-messages.js +134 -0
- package/dist/ssr/content/run-log-messages.js.map +1 -0
- package/dist/ssr/feedback/dialog-core.js +118 -14
- package/dist/ssr/feedback/dialog-core.js.map +1 -1
- package/dist/ssr/feedback/dialog-frame-motion.js +274 -0
- package/dist/ssr/feedback/dialog-frame-motion.js.map +1 -0
- package/dist/ssr/feedback/prompt-sheet-view.js +2 -1
- package/dist/ssr/feedback/prompt-sheet-view.js.map +1 -1
- package/dist/ssr/feedback/prompts.js +16 -16
- package/dist/ssr/feedback/prompts.js.map +1 -1
- package/dist/ssr/feedback/toast.js +11 -1
- package/dist/ssr/feedback/toast.js.map +1 -1
- package/dist/ssr/hover-card.js +6 -0
- package/dist/ssr/hover-card.js.map +1 -0
- package/dist/ssr/inputs/AutocompleteEditor.js +2 -1
- package/dist/ssr/inputs/AutocompleteEditor.js.map +1 -1
- package/dist/ssr/inputs/AutocompleteSelect.js +3 -8
- package/dist/ssr/inputs/AutocompleteSelect.js.map +1 -1
- package/dist/ssr/inputs/ChoiceList.js +25 -25
- package/dist/ssr/inputs/ChoiceList.js.map +1 -1
- package/dist/ssr/inputs/Combobox.js +4 -9
- package/dist/ssr/inputs/Combobox.js.map +1 -1
- package/dist/ssr/inputs/MultiSelectInput.js +4 -9
- package/dist/ssr/inputs/MultiSelectInput.js.map +1 -1
- package/dist/ssr/inputs/PeriodPicker.js +241 -46
- package/dist/ssr/inputs/PeriodPicker.js.map +1 -1
- package/dist/ssr/inputs/RichSelect.js +135 -121
- package/dist/ssr/inputs/RichSelect.js.map +1 -1
- package/dist/ssr/inputs/Select.js +3 -8
- package/dist/ssr/inputs/Select.js.map +1 -1
- package/dist/ssr/inputs/SelectChip.js +1 -0
- package/dist/ssr/inputs/SelectChip.js.map +1 -1
- package/dist/ssr/inputs/TimeInput.js +145 -0
- package/dist/ssr/inputs/TimeInput.js.map +1 -0
- package/dist/ssr/inputs/choice.js.map +1 -1
- package/dist/ssr/inputs/date-picker.js +2 -1
- package/dist/ssr/inputs/date-picker.js.map +1 -1
- package/dist/ssr/inputs/file-drop.js +2 -0
- package/dist/ssr/inputs/file-drop.js.map +1 -1
- package/dist/ssr/inputs/index.js +1 -0
- package/dist/ssr/inputs/index.js.map +1 -1
- package/dist/ssr/inputs/input-messages.js +20 -2
- package/dist/ssr/inputs/input-messages.js.map +1 -1
- package/dist/ssr/inputs/period-picker-messages.js +20 -2
- package/dist/ssr/inputs/period-picker-messages.js.map +1 -1
- package/dist/ssr/inputs/period.js +83 -0
- package/dist/ssr/inputs/period.js.map +1 -1
- package/dist/ssr/inputs/time-input.js +93 -0
- package/dist/ssr/inputs/time-input.js.map +1 -0
- package/dist/ssr/internal/exit-motion.js +23 -0
- package/dist/ssr/internal/exit-motion.js.map +1 -0
- package/dist/ssr/internal/option-description.js +27 -0
- package/dist/ssr/internal/option-description.js.map +1 -0
- package/dist/ssr/internal/scroll-places.js +15 -0
- package/dist/ssr/internal/scroll-places.js.map +1 -0
- package/dist/ssr/internal/step-row.js +35 -0
- package/dist/ssr/internal/step-row.js.map +1 -0
- package/dist/ssr/layout/AppWorkspace.js +191 -121
- package/dist/ssr/layout/AppWorkspace.js.map +1 -1
- package/dist/ssr/layout/BottomSheet.js +2 -14
- package/dist/ssr/layout/BottomSheet.js.map +1 -1
- package/dist/ssr/layout/Navigation.js +7 -2
- package/dist/ssr/layout/Navigation.js.map +1 -1
- package/dist/ssr/layout/PullToRefresh.js +67 -16
- package/dist/ssr/layout/PullToRefresh.js.map +1 -1
- package/dist/ssr/layout/SidebarSwitcher.js +8 -13
- package/dist/ssr/layout/SidebarSwitcher.js.map +1 -1
- package/dist/ssr/layout/app-workspace-controller.js +5 -1
- package/dist/ssr/layout/app-workspace-controller.js.map +1 -1
- package/dist/ssr/layout/bottom-sheet-load.js +17 -0
- package/dist/ssr/layout/bottom-sheet-load.js.map +1 -0
- package/dist/ssr/layout/bottom-sheet-options.js +27 -0
- package/dist/ssr/layout/bottom-sheet-options.js.map +1 -0
- package/dist/ssr/layout/index.js +2 -1
- package/dist/ssr/layout/index.js.map +1 -1
- package/dist/ssr/layout/refresh-messages.js +4 -2
- package/dist/ssr/layout/refresh-messages.js.map +1 -1
- package/dist/ssr/layout/sheet-motion.js +10 -11
- package/dist/ssr/layout/sheet-motion.js.map +1 -1
- package/dist/ssr/layout/sidebar-scroll-memory.js +30 -0
- package/dist/ssr/layout/sidebar-scroll-memory.js.map +1 -1
- package/dist/ssr/surfaces/AvatarStack.js +56 -40
- package/dist/ssr/surfaces/AvatarStack.js.map +1 -1
- package/dist/ssr/surfaces/LinkCard.js.map +1 -1
- package/dist/ssr/surfaces/Section.js +4 -2
- package/dist/ssr/surfaces/Section.js.map +1 -1
- package/dist/ssr/surfaces/StatCell.js +24 -12
- package/dist/ssr/surfaces/StatCell.js.map +1 -1
- package/dist/ssr/surfaces/StatGrid.js +12 -6
- package/dist/ssr/surfaces/StatGrid.js.map +1 -1
- package/dist/ssr/surfaces/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/actions/Dropdown.d.ts +10 -0
- package/dist/types/actions/SelectionAction.d.ts +34 -0
- package/dist/types/actions/command-items.d.ts +5 -0
- package/dist/types/actions/index.d.ts +2 -0
- package/dist/types/actions/menu-sheet-open.d.ts +13 -0
- package/dist/types/charts/core/line-details.d.ts +1 -1
- package/dist/types/chat/ChatActivityWords.d.ts +31 -0
- package/dist/types/chat/ChatComposer.d.ts +17 -1
- package/dist/types/chat/ChatComposerQuotes.d.ts +10 -0
- package/dist/types/chat/ChatPrimitives.d.ts +23 -1
- package/dist/types/chat/ChatTimeline.d.ts +2 -0
- package/dist/types/chat/index.d.ts +6 -2
- package/dist/types/content/ActivityList.d.ts +166 -0
- package/dist/types/content/DataTableTools.d.ts +2 -0
- package/dist/types/content/Lightbox.d.ts +7 -5
- package/dist/types/content/MessageQuote.d.ts +9 -0
- package/dist/types/content/MessageRow.d.ts +5 -0
- package/dist/types/content/RunLog.d.ts +53 -0
- package/dist/types/content/VirtualFeed.d.ts +6 -0
- package/dist/types/content/activity-messages.d.ts +22 -0
- package/dist/types/content/activity-timeline.d.ts +52 -0
- package/dist/types/content/chart-time-calendar.d.ts +6 -0
- package/dist/types/content/find-text.d.ts +10 -0
- package/dist/types/content/index.d.ts +2 -0
- package/dist/types/content/quote-messages.d.ts +6 -0
- package/dist/types/content/run-log-messages.d.ts +61 -0
- package/dist/types/feedback/dialog-core.d.ts +2 -0
- package/dist/types/feedback/dialog-frame-motion.d.ts +37 -0
- package/dist/types/feedback/prompts.d.ts +5 -0
- package/dist/types/feedback/toast.d.ts +9 -1
- package/dist/types/hover-card.d.ts +5 -0
- package/dist/types/inputs/ChoiceList.d.ts +12 -5
- package/dist/types/inputs/Combobox.d.ts +5 -0
- package/dist/types/inputs/MultiSelectInput.d.ts +1 -0
- package/dist/types/inputs/PeriodPicker.d.ts +10 -0
- package/dist/types/inputs/RichSelect.d.ts +5 -0
- package/dist/types/inputs/Select.d.ts +1 -0
- package/dist/types/inputs/SelectChip.d.ts +5 -0
- package/dist/types/inputs/TimeInput.d.ts +16 -0
- package/dist/types/inputs/choice.d.ts +6 -1
- package/dist/types/inputs/index.d.ts +2 -0
- package/dist/types/inputs/input-messages.d.ts +9 -0
- package/dist/types/inputs/period-picker-messages.d.ts +9 -0
- package/dist/types/inputs/period.d.ts +41 -0
- package/dist/types/inputs/time-input.d.ts +43 -0
- package/dist/types/internal/exit-motion.d.ts +10 -0
- package/dist/types/internal/option-description.d.ts +20 -0
- package/dist/types/internal/scroll-places.d.ts +2 -0
- package/dist/types/internal/step-row.d.ts +19 -0
- package/dist/types/layout/AppWorkspace.d.ts +10 -0
- package/dist/types/layout/BottomSheet.d.ts +1 -14
- package/dist/types/layout/PullToRefresh.d.ts +2 -2
- package/dist/types/layout/SidebarSwitcher.d.ts +5 -0
- package/dist/types/layout/bottom-sheet-load.d.ts +9 -0
- package/dist/types/layout/bottom-sheet-options.d.ts +18 -0
- package/dist/types/layout/index.d.ts +3 -2
- package/dist/types/layout/refresh-messages.d.ts +1 -0
- package/dist/types/layout/sheet-motion.d.ts +0 -5
- package/dist/types/layout/sidebar-scroll-memory.d.ts +6 -0
- package/dist/types/surfaces/LinkCard.d.ts +2 -1
- package/dist/types/surfaces/StatCell.d.ts +7 -2
- package/dist/types/surfaces/StatGrid.d.ts +15 -3
- package/dist/types/surfaces/index.d.ts +1 -1
- package/package.json +17 -8
|
@@ -11,7 +11,7 @@ import { prefersReducedMotion } from "../motion";
|
|
|
11
11
|
import { ContextMenuBase } from "./ContextMenu";
|
|
12
12
|
import { DropdownItems } from "./Dropdown";
|
|
13
13
|
import { onPointerDragStart } from "./drag-and-drop";
|
|
14
|
-
import { openMenuSheet } from "./menu-sheet";
|
|
14
|
+
import { openMenuSheet } from "./menu-sheet-open";
|
|
15
15
|
|
|
16
16
|
/** A finger held this long without moving opens the menu, as the platforms' own long press does. */
|
|
17
17
|
const LONG_PRESS_MS = 500;
|
|
@@ -76,8 +76,8 @@ export function GestureMenu(props) {
|
|
|
76
76
|
const active = () => props.items.length > 0;
|
|
77
77
|
const wide = () => window.matchMedia?.("(min-width: 48rem)").matches ?? false;
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
79
|
+
* Inside a modal dialog the hold keeps the sheet: it opens as a level of the same dialog stack, so Escape and Back
|
|
80
|
+
* close it before the dialog. An engine without `:modal` gets the sheet too.
|
|
81
81
|
*/
|
|
82
82
|
const inModal = () => {
|
|
83
83
|
const dialog = surface.closest("dialog[open]");
|
|
@@ -96,7 +96,10 @@ export function GestureMenu(props) {
|
|
|
96
96
|
const found = target instanceof Element ? target.closest(IGNORE) : null;
|
|
97
97
|
return found !== null && found !== surface && surface.contains(found);
|
|
98
98
|
};
|
|
99
|
-
|
|
99
|
+
|
|
100
|
+
/** Set while the menu opens in place of a sheet whose code did not load; `onOpen` already ran for it. */
|
|
101
|
+
let announcedOpen = false;
|
|
102
|
+
const openSheet = (x, y) => {
|
|
100
103
|
if (sheetOpen || !active()) return;
|
|
101
104
|
sheetOpen = true;
|
|
102
105
|
const controller = new AbortController();
|
|
@@ -113,6 +116,14 @@ export function GestureMenu(props) {
|
|
|
113
116
|
locale: locale(),
|
|
114
117
|
top: props.sheetTop,
|
|
115
118
|
signal: controller.signal
|
|
119
|
+
}, error => {
|
|
120
|
+
globalThis.reportError(error);
|
|
121
|
+
// The sheet's code did not load: the person still chooses, from the menu beside the finger, and the next
|
|
122
|
+
// hold tries the sheet again.
|
|
123
|
+
if (controller.signal.aborted) return;
|
|
124
|
+
announcedOpen = true;
|
|
125
|
+
openMenuAt?.(x, y);
|
|
126
|
+
announcedOpen = false;
|
|
116
127
|
}).finally(() => {
|
|
117
128
|
disposed.signal.removeEventListener("abort", abortSheet);
|
|
118
129
|
if (sheetController === controller) {
|
|
@@ -169,7 +180,7 @@ export function GestureMenu(props) {
|
|
|
169
180
|
if (!press) return;
|
|
170
181
|
press.long = true;
|
|
171
182
|
lastTap = undefined;
|
|
172
|
-
if (wide() && !inModal()) openMenuAt?.(press.x, press.y);else openSheet();
|
|
183
|
+
if (wide() && !inModal()) openMenuAt?.(press.x, press.y);else openSheet(press.x, press.y);
|
|
173
184
|
};
|
|
174
185
|
const onPointerDown = event => {
|
|
175
186
|
lastPointer = event.pointerType;
|
|
@@ -364,8 +375,8 @@ export function GestureMenu(props) {
|
|
|
364
375
|
get disabled() {
|
|
365
376
|
return !active();
|
|
366
377
|
},
|
|
367
|
-
|
|
368
|
-
|
|
378
|
+
onOpen: () => {
|
|
379
|
+
if (!announcedOpen) props.onOpen?.();
|
|
369
380
|
},
|
|
370
381
|
get ["class"]() {
|
|
371
382
|
return props.class;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["actions/GestureMenu.tsx"],"sourcesContent":["import { createSignal, type JSX, onCleanup, onMount, Show } from \"solid-js\";\nimport { useLocale } from \"../intl/locale\";\nimport { prefersReducedMotion } from \"../motion\";\nimport { ContextMenuBase } from \"./ContextMenu\";\nimport { type DropdownAction, type DropdownActionBase, type DropdownChoice, DropdownItems, type DropdownSection } from \"./Dropdown\";\nimport { onPointerDragStart } from \"./drag-and-drop\";\nimport { openMenuSheet } from \"./menu-sheet\";\n\n/** A finger held this long without moving opens the menu, as the platforms' own long press does. */\nconst LONG_PRESS_MS = 500;\n/** A second tap that starts this soon after the first ended makes a double tap. */\nconst DOUBLE_TAP_MS = 300;\n/** The second tap lands at most this far from the first. */\nconst DOUBLE_TAP_DISTANCE = 32;\n/** Movement up to this is still a tap or a long press. */\nconst SLOP = 10;\n/** A swipe must be this many times wider than tall; anything steeper belongs to the page's scrolling. */\nconst SWIPE_RATIO = 1.5;\n/** Travel at which a released swipe runs its action. */\nconst SWIPE_THRESHOLD = 64;\n/** The content follows the finger up to the threshold, then at a quarter of its travel, up to this. */\nconst SWIPE_MAX = 96;\nconst SWIPE_RESISTANCE = 0.25;\n/** Swipes do not start this close to the screen's side edges, where the system's back and forward gestures are. */\nconst EDGE = 20;\n/** Duration of the snap back in `.k2b-gesture-menu[data-settling]`. */\nconst SETTLE_MS = 160;\n\n/**\n * Gestures never start on these elements: links, controls, fields, code blocks, and anything marked\n * `data-gesture-ignore` keep their own touch and mouse behavior.\n */\nconst IGNORE = [\n \"a[href]\",\n \"button\",\n \"input\",\n \"textarea\",\n \"select\",\n \"summary\",\n \"label\",\n \"audio\",\n \"video\",\n \"pre\",\n \"[contenteditable]:not([contenteditable='false'])\",\n \"[role='button']\",\n \"[role='link']\",\n \"[role='checkbox']\",\n \"[role='switch']\",\n \"[role='slider']\",\n \"[role='tab']\",\n \"[role^='menuitem']\",\n \"[data-gesture-ignore]\",\n].join(\", \");\n\nexport type GestureKind = \"swipe-right\" | \"swipe-left\" | \"double-tap\";\n\n/** A menu action that a gesture runs as well. */\nexport type GestureMenuAction = DropdownActionBase & {\n action: () => void;\n /** The gesture that runs this action. Give each gesture to at most one item; a disabled item disables its gesture. */\n gesture?: GestureKind;\n};\n\nexport type GestureMenuSection = Omit<DropdownSection, \"items\"> & {\n items: readonly (GestureMenuAction | DropdownAction | DropdownChoice)[];\n};\n\nexport type GestureMenuItem = GestureMenuAction | DropdownAction | DropdownChoice | GestureMenuSection;\n\nexport type GestureMenuProps = {\n /**\n * The menu. A long press opens a BottomSheet below 48rem and the same menu at the finger from 48rem.\n * Right-click opens it at the pointer; the Context Menu key and Shift+F10 open it beside the focused element.\n * An item with `gesture` is also run by that gesture, so every gesture has its entry here.\n */\n items: readonly GestureMenuItem[];\n /** Names the element and its menu, for example \"Message from Nora, 10:42\". */\n label: string;\n children: JSX.Element;\n /** Shown only above the menu in the phone sheet, for example a row of quick reactions. `close` closes the sheet. */\n sheetTop?: (close: () => void) => JSX.Element;\n /** Tab order of the element. A list that moves focus between its rows itself passes -1. */\n tabIndex?: number;\n /** Runs before the menu or the sheet shows its items, for example to select what was pressed. */\n onOpen?: () => void;\n class?: string;\n};\n\ntype SwipeDirection = \"right\" | \"left\";\n\ntype Swipe = {\n direction: SwipeDirection;\n icon?: string;\n /** How far the content is moved, in pixels; always 0 with reduced motion. */\n offset: number;\n /** Travel relative to the threshold, from 0 to 1. */\n progress: number;\n armed: boolean;\n settling: boolean;\n};\n\ntype Press = {\n id: number;\n x: number;\n y: number;\n timer?: ReturnType<typeof setTimeout>;\n /** The finger left the slop: no tap or long press any more. */\n moved: boolean;\n /** The long press opened the menu or the sheet. */\n long: boolean;\n /** The press started soon after a tap nearby. */\n second: boolean;\n /** The press started at a side edge of the screen. */\n edge: boolean;\n direction?: SwipeDirection;\n};\n\nconst gestureAction = (items: readonly GestureMenuItem[], kind: GestureKind): GestureMenuAction | undefined => {\n for (const item of items)\n for (const entry of \"items\" in item ? item.items : [item])\n if (\"gesture\" in entry && entry.gesture === kind) return entry.disabled ? undefined : entry;\n return undefined;\n};\n\nconst swipeKind = (direction: SwipeDirection): GestureKind => (direction === \"right\" ? \"swipe-right\" : \"swipe-left\");\n\n/**\n * Touch gestures for an element, each the shortcut of an entry in its menu: a horizontal swipe, a double tap, and a\n * long press that opens a `BottomSheet` below 48rem and the same menu at the finger from 48rem. A mouse double-click\n * runs the double-tap action; right-click opens the menu at the pointer, the keyboard beside the focused element.\n * Vertical scrolling never turns into a swipe.\n */\nexport function GestureMenu(props: GestureMenuProps): JSX.Element {\n const locale = useLocale();\n const [swipe, setSwipe] = createSignal<Swipe>();\n let surface!: HTMLDivElement;\n let openMenuAt: ((x: number, y: number) => void) | undefined;\n let closeMenu: (() => void) | undefined;\n let sheetController: AbortController | undefined;\n let press: Press | undefined;\n let lastTap: { x: number; y: number; at: number } | undefined;\n let lastPointer = \"mouse\";\n /**\n * The touch or pen press that just ended did something: its `touchend` is cancelled, so no click or mouse events\n * follow, and a pen's click, which comes without touch events, is cancelled itself.\n */\n let consumed = false;\n let sheetOpen = false;\n /** Closes an open sheet when the element goes, for example when its message is deleted. */\n const disposed = new AbortController();\n let reduced = false;\n let settleTimer: ReturnType<typeof setTimeout> | undefined;\n\n const active = () => props.items.length > 0;\n const wide = () => window.matchMedia?.(\"(min-width: 48rem)\").matches ?? false;\n /**\n * A modal dialog makes everything outside it inert, also ContextMenu's menu on the body, so inside one the hold\n * keeps the sheet, which opens on the same dialog stack. An engine without `:modal` gets the sheet too.\n */\n const inModal = () => {\n const dialog = surface.closest(\"dialog[open]\");\n if (!dialog) return false;\n try {\n return dialog.matches(\":modal\");\n } catch {\n return true;\n }\n };\n const action = (kind: GestureKind) => gestureAction(props.items, kind);\n const touchAction = () => (action(\"swipe-right\") || action(\"swipe-left\") ? \"swipe\" : action(\"double-tap\") ? \"tap\" : undefined);\n\n /** Whether the event started on something with a meaning of its own, inside this element. */\n const ignored = (target: EventTarget | null) => {\n const found = target instanceof Element ? target.closest(IGNORE) : null;\n return found !== null && found !== surface && surface.contains(found);\n };\n\n const openSheet = () => {\n if (sheetOpen || !active()) return;\n sheetOpen = true;\n const controller = new AbortController();\n sheetController = controller;\n const abortSheet = () => controller.abort();\n disposed.signal.addEventListener(\"abort\", abortSheet, { once: true });\n props.onOpen?.();\n void openMenuSheet({\n Items: DropdownItems,\n items: props.items,\n label: props.label,\n locale: locale(),\n top: props.sheetTop,\n signal: controller.signal,\n }).finally(() => {\n disposed.signal.removeEventListener(\"abort\", abortSheet);\n if (sheetController === controller) {\n sheetController = undefined;\n sheetOpen = false;\n }\n });\n };\n\n /** Another pointer that goes down anywhere while a finger presses, as in a pinch, ends the gesture. */\n const onOtherPointer = (event: PointerEvent) => {\n if (!press || event.pointerId === press.id) return;\n if (press.direction) settle();\n endPress();\n };\n\n const endPress = () => {\n clearTimeout(press?.timer);\n press = undefined;\n document.removeEventListener(\"pointerdown\", onOtherPointer, true);\n delete surface.dataset.pressing;\n };\n\n const settle = () => {\n const current = swipe();\n if (!current) return;\n clearTimeout(settleTimer);\n if (reduced || current.offset === 0) {\n setSwipe(undefined);\n return;\n }\n setSwipe({ ...current, offset: 0, progress: 0, armed: false, settling: true });\n settleTimer = setTimeout(() => setSwipe(undefined), SETTLE_MS);\n };\n\n const moveSwipe = (current: Press, direction: SwipeDirection, dx: number) => {\n const travel = Math.max(0, direction === \"right\" ? dx : -dx);\n const moved = travel <= SWIPE_THRESHOLD ? travel : SWIPE_THRESHOLD + (travel - SWIPE_THRESHOLD) * SWIPE_RESISTANCE;\n const offset = reduced ? 0 : Math.min(SWIPE_MAX, moved) * (direction === \"right\" ? 1 : -1);\n current.direction = direction;\n setSwipe({\n direction,\n icon: action(swipeKind(direction))?.icon,\n offset,\n progress: Math.min(1, travel / SWIPE_THRESHOLD),\n armed: travel >= SWIPE_THRESHOLD,\n settling: false,\n });\n };\n\n const longPress = () => {\n if (!press) return;\n press.long = true;\n lastTap = undefined;\n if (wide() && !inModal()) openMenuAt?.(press.x, press.y);\n else openSheet();\n };\n\n const onPointerDown = (event: PointerEvent) => {\n lastPointer = event.pointerType;\n consumed = false;\n // Any press in between, on a link, with a mouse, or with another finger, ends a pending double tap.\n const previous = lastTap;\n lastTap = undefined;\n // Another finger ends the gesture through `onOtherPointer` and starts none.\n if (event.pointerType === \"mouse\" || !event.isPrimary) return;\n endPress();\n if (!active() || ignored(event.target)) return;\n const second =\n previous !== undefined &&\n performance.now() - previous.at <= DOUBLE_TAP_MS &&\n Math.hypot(event.clientX - previous.x, event.clientY - previous.y) <= DOUBLE_TAP_DISTANCE;\n press = {\n id: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n moved: false,\n long: false,\n second,\n edge: event.clientX < EDGE || event.clientX > window.innerWidth - EDGE,\n timer: setTimeout(longPress, LONG_PRESS_MS),\n };\n document.addEventListener(\"pointerdown\", onOtherPointer, true);\n // Hybrid devices keep text selection for the mouse; a finger on the element selects nothing.\n surface.dataset.pressing = \"\";\n };\n\n const onPointerMove = (event: PointerEvent) => {\n const current = press;\n if (!current || event.pointerId !== current.id) return;\n // Hold-then-drag hands this press to DragSource through onPointerDragStart.\n if (current.long) return;\n const dx = event.clientX - current.x;\n const dy = event.clientY - current.y;\n if (current.direction) {\n moveSwipe(current, current.direction, dx);\n return;\n }\n if (current.moved || Math.hypot(dx, dy) < SLOP) return;\n current.moved = true;\n clearTimeout(current.timer);\n if (current.edge || Math.abs(dx) < Math.abs(dy) * SWIPE_RATIO) return;\n const direction: SwipeDirection = dx > 0 ? \"right\" : \"left\";\n if (!action(swipeKind(direction))) return;\n clearTimeout(settleTimer);\n reduced = prefersReducedMotion();\n moveSwipe(current, direction, dx);\n };\n\n const onPointerUp = (event: PointerEvent) => {\n const current = press;\n if (!current || event.pointerId !== current.id) return;\n endPress();\n if (current.long) {\n consumed = true;\n return;\n }\n if (current.direction) {\n // Where the finger lifts decides, and the item as it is now.\n moveSwipe(current, current.direction, event.clientX - current.x);\n const swipeAction = swipe()?.armed ? action(swipeKind(current.direction)) : undefined;\n settle();\n if (swipeAction) {\n consumed = true;\n swipeAction.action();\n }\n return;\n }\n if (current.moved) return;\n const doubleTap = action(\"double-tap\");\n if (!doubleTap) return;\n if (current.second) {\n consumed = true;\n doubleTap.action();\n return;\n }\n lastTap = { x: event.clientX, y: event.clientY, at: performance.now() };\n };\n\n // The browser took the touch, for example to scroll the page.\n const onPointerCancel = (event: PointerEvent) => {\n if (!press || event.pointerId !== press.id) return;\n if (press.direction) settle();\n endPress();\n lastTap = undefined;\n };\n\n // Once the hold opens the menu or sheet, further movement must not scroll the page underneath it.\n const onTouchMove = (event: TouchEvent) => {\n if (press?.long && event.cancelable) event.preventDefault();\n };\n\n const onTouchEnd = (event: TouchEvent) => {\n if (!consumed) return;\n consumed = false;\n if (event.cancelable) event.preventDefault();\n };\n\n // A pen sends no touch events; the click after its gesture is cancelled here. A keyboard's click has no detail.\n const onClick = (event: MouseEvent) => {\n if (!consumed || event.detail === 0) return;\n consumed = false;\n event.preventDefault();\n event.stopPropagation();\n };\n\n const onContextMenu = (event: MouseEvent) => {\n // Without items the element has no menu, and the browser keeps its own.\n if (!active()) return;\n // Links, fields, and code keep the browser's own menu.\n if (ignored(event.target)) {\n event.stopPropagation();\n return;\n }\n // A mouse or the keyboard opens the menu beside the element through ContextMenu.\n if (!press && !(\"pointerType\" in event && (event.pointerType === \"touch\" || event.pointerType === \"pen\"))) return;\n // Android and touch screens report a long press as a context-menu event, sometimes before the timer.\n event.preventDefault();\n event.stopPropagation();\n if (press && !press.long && !press.moved) {\n clearTimeout(press.timer);\n longPress();\n }\n };\n\n // The second press of a mouse double-click would select a word; in this element it runs the double-tap action.\n const onMouseDown = (event: MouseEvent) => {\n if (event.button === 0 && event.detail >= 2 && lastPointer === \"mouse\" && action(\"double-tap\") && !ignored(event.target))\n event.preventDefault();\n };\n\n const onDoubleClick = (event: MouseEvent) => {\n if (lastPointer !== \"mouse\" || ignored(event.target)) return;\n const doubleTap = action(\"double-tap\");\n if (!doubleTap) return;\n event.preventDefault();\n doubleTap.action();\n };\n\n onMount(() => {\n const unsubscribeDrag = onPointerDragStart((pointerId) => {\n if (press?.id !== pointerId) return;\n consumed = true;\n lastTap = undefined;\n closeMenu?.();\n sheetController?.abort();\n endPress();\n });\n surface.addEventListener(\"pointerdown\", onPointerDown);\n surface.addEventListener(\"pointermove\", onPointerMove);\n surface.addEventListener(\"pointerup\", onPointerUp);\n surface.addEventListener(\"pointercancel\", onPointerCancel);\n surface.addEventListener(\"touchmove\", onTouchMove, { passive: false });\n surface.addEventListener(\"touchend\", onTouchEnd, { passive: false });\n surface.addEventListener(\"click\", onClick, true);\n surface.addEventListener(\"contextmenu\", onContextMenu);\n surface.addEventListener(\"mousedown\", onMouseDown);\n surface.addEventListener(\"dblclick\", onDoubleClick);\n onCleanup(() => {\n unsubscribeDrag();\n disposed.abort();\n endPress();\n clearTimeout(settleTimer);\n surface.removeEventListener(\"pointerdown\", onPointerDown);\n surface.removeEventListener(\"pointermove\", onPointerMove);\n surface.removeEventListener(\"pointerup\", onPointerUp);\n surface.removeEventListener(\"pointercancel\", onPointerCancel);\n surface.removeEventListener(\"touchmove\", onTouchMove);\n surface.removeEventListener(\"touchend\", onTouchEnd);\n surface.removeEventListener(\"click\", onClick, true);\n surface.removeEventListener(\"contextmenu\", onContextMenu);\n surface.removeEventListener(\"mousedown\", onMouseDown);\n surface.removeEventListener(\"dblclick\", onDoubleClick);\n });\n });\n\n return (\n <ContextMenuBase\n openAt={(open) => (openMenuAt = open)}\n closeWith={(close) => (closeMenu = close)}\n title={props.label}\n items={props.items}\n label={props.label}\n tabIndex={props.tabIndex}\n disabled={!active()}\n onOpen={props.onOpen}\n class={props.class}\n >\n <div\n ref={surface}\n class=\"k2b-gesture-menu\"\n data-active={active() ? \"\" : undefined}\n data-touch={touchAction()}\n data-swipe={swipe()?.direction}\n data-armed={swipe()?.armed ? \"\" : undefined}\n data-settling={swipe()?.settling ? \"\" : undefined}\n style={{\n \"--k2b-gesture-menu-offset\": `${swipe()?.offset ?? 0}px`,\n \"--k2b-gesture-menu-progress\": String(swipe()?.progress ?? 0),\n }}\n >\n <Show when={swipe()}>\n {(current) => (\n <span class=\"k2b-gesture-menu__swipe\" aria-hidden=\"true\">\n <i class={current().icon ?? (current().direction === \"right\" ? \"ti ti-arrow-right\" : \"ti ti-arrow-left\")} />\n </span>\n )}\n </Show>\n <div class=\"k2b-gesture-menu__content\">{props.children}</div>\n </div>\n </ContextMenuBase>\n );\n}\n\nexport default GestureMenu;\n"],"mappings":";;;;;;;AAAA,SAAS,YAAY,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AAC3E,SAAS,SAAS,QAAQ,gBAAgB;AAC1C,SAAS,oBAAoB,QAAQ,WAAW;AAChD,SAAS,eAAe,QAAQ,eAAe;AAC/C,SAA4E,aAAa,QAA8B,YAAY;AACnI,SAAS,kBAAkB,QAAQ,iBAAiB;AACpD,SAAS,aAAa,QAAQ,cAAc;;AAE5C;AACA,MAAM,aAAa,GAAG,GAAG;AACzB;AACA,MAAM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AQ;IAAA;IAAA,IACxB,QAAQ;MAAA,OAAE,CAAC,MAAM,CAAC,CAAC;IAAA;IAAA,IACnB,MAAM;MAAA,OAAE,KAAK,CAAC,MAAM;IAAA;IAAA;MAAA,OACb,KAAK,CAAC,KAAK;IAAA;IAAA;MAAA,mDAKH,MAAM,CAAC,CAAC,GAAG,EAAE,YAAG,SAAS,wDAC1B,WAAW,CAAC,CAAC,wDACb,KAAK,CAAC,CAAC,EAAE,SAAS,+CAClB,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,EAAE,YAAG,SAAS,kDAC5B,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,EAAE,YAAG,SAAS,kEAElB,YAAG,KAAK,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,WAAI,iEACzB,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,IAAI,CAAC,CAAC,qCAG9D,IAAI;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,CAAC;QAAA;QAAA,UACf,OAAO,oDAEK,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;MAE3G,cAEqC,KAAK,CAAC,QAAQ;IAAA;EAAA;AAI9D;AAEA,eAAe,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["actions/GestureMenu.tsx"],"sourcesContent":["import { createSignal, type JSX, onCleanup, onMount, Show } from \"solid-js\";\nimport { useLocale } from \"../intl/locale\";\nimport { prefersReducedMotion } from \"../motion\";\nimport { ContextMenuBase } from \"./ContextMenu\";\nimport { type DropdownAction, type DropdownActionBase, type DropdownChoice, DropdownItems, type DropdownSection } from \"./Dropdown\";\nimport { onPointerDragStart } from \"./drag-and-drop\";\nimport { openMenuSheet } from \"./menu-sheet-open\";\n\n/** A finger held this long without moving opens the menu, as the platforms' own long press does. */\nconst LONG_PRESS_MS = 500;\n/** A second tap that starts this soon after the first ended makes a double tap. */\nconst DOUBLE_TAP_MS = 300;\n/** The second tap lands at most this far from the first. */\nconst DOUBLE_TAP_DISTANCE = 32;\n/** Movement up to this is still a tap or a long press. */\nconst SLOP = 10;\n/** A swipe must be this many times wider than tall; anything steeper belongs to the page's scrolling. */\nconst SWIPE_RATIO = 1.5;\n/** Travel at which a released swipe runs its action. */\nconst SWIPE_THRESHOLD = 64;\n/** The content follows the finger up to the threshold, then at a quarter of its travel, up to this. */\nconst SWIPE_MAX = 96;\nconst SWIPE_RESISTANCE = 0.25;\n/** Swipes do not start this close to the screen's side edges, where the system's back and forward gestures are. */\nconst EDGE = 20;\n/** Duration of the snap back in `.k2b-gesture-menu[data-settling]`. */\nconst SETTLE_MS = 160;\n\n/**\n * Gestures never start on these elements: links, controls, fields, code blocks, and anything marked\n * `data-gesture-ignore` keep their own touch and mouse behavior.\n */\nconst IGNORE = [\n \"a[href]\",\n \"button\",\n \"input\",\n \"textarea\",\n \"select\",\n \"summary\",\n \"label\",\n \"audio\",\n \"video\",\n \"pre\",\n \"[contenteditable]:not([contenteditable='false'])\",\n \"[role='button']\",\n \"[role='link']\",\n \"[role='checkbox']\",\n \"[role='switch']\",\n \"[role='slider']\",\n \"[role='tab']\",\n \"[role^='menuitem']\",\n \"[data-gesture-ignore]\",\n].join(\", \");\n\nexport type GestureKind = \"swipe-right\" | \"swipe-left\" | \"double-tap\";\n\n/** A menu action that a gesture runs as well. */\nexport type GestureMenuAction = DropdownActionBase & {\n action: () => void;\n /** The gesture that runs this action. Give each gesture to at most one item; a disabled item disables its gesture. */\n gesture?: GestureKind;\n};\n\nexport type GestureMenuSection = Omit<DropdownSection, \"items\"> & {\n items: readonly (GestureMenuAction | DropdownAction | DropdownChoice)[];\n};\n\nexport type GestureMenuItem = GestureMenuAction | DropdownAction | DropdownChoice | GestureMenuSection;\n\nexport type GestureMenuProps = {\n /**\n * The menu. A long press opens a BottomSheet below 48rem and the same menu at the finger from 48rem.\n * Right-click opens it at the pointer; the Context Menu key and Shift+F10 open it beside the focused element.\n * An item with `gesture` is also run by that gesture, so every gesture has its entry here.\n */\n items: readonly GestureMenuItem[];\n /** Names the element and its menu, for example \"Message from Nora, 10:42\". */\n label: string;\n children: JSX.Element;\n /** Shown only above the menu in the phone sheet, for example a row of quick reactions. `close` closes the sheet. */\n sheetTop?: (close: () => void) => JSX.Element;\n /** Tab order of the element. A list that moves focus between its rows itself passes -1. */\n tabIndex?: number;\n /** Runs before the menu or the sheet shows its items, for example to select what was pressed. */\n onOpen?: () => void;\n class?: string;\n};\n\ntype SwipeDirection = \"right\" | \"left\";\n\ntype Swipe = {\n direction: SwipeDirection;\n icon?: string;\n /** How far the content is moved, in pixels; always 0 with reduced motion. */\n offset: number;\n /** Travel relative to the threshold, from 0 to 1. */\n progress: number;\n armed: boolean;\n settling: boolean;\n};\n\ntype Press = {\n id: number;\n x: number;\n y: number;\n timer?: ReturnType<typeof setTimeout>;\n /** The finger left the slop: no tap or long press any more. */\n moved: boolean;\n /** The long press opened the menu or the sheet. */\n long: boolean;\n /** The press started soon after a tap nearby. */\n second: boolean;\n /** The press started at a side edge of the screen. */\n edge: boolean;\n direction?: SwipeDirection;\n};\n\nconst gestureAction = (items: readonly GestureMenuItem[], kind: GestureKind): GestureMenuAction | undefined => {\n for (const item of items)\n for (const entry of \"items\" in item ? item.items : [item])\n if (\"gesture\" in entry && entry.gesture === kind) return entry.disabled ? undefined : entry;\n return undefined;\n};\n\nconst swipeKind = (direction: SwipeDirection): GestureKind => (direction === \"right\" ? \"swipe-right\" : \"swipe-left\");\n\n/**\n * Touch gestures for an element, each the shortcut of an entry in its menu: a horizontal swipe, a double tap, and a\n * long press that opens a `BottomSheet` below 48rem and the same menu at the finger from 48rem. A mouse double-click\n * runs the double-tap action; right-click opens the menu at the pointer, the keyboard beside the focused element.\n * Vertical scrolling never turns into a swipe.\n */\nexport function GestureMenu(props: GestureMenuProps): JSX.Element {\n const locale = useLocale();\n const [swipe, setSwipe] = createSignal<Swipe>();\n let surface!: HTMLDivElement;\n let openMenuAt: ((x: number, y: number) => void) | undefined;\n let closeMenu: (() => void) | undefined;\n let sheetController: AbortController | undefined;\n let press: Press | undefined;\n let lastTap: { x: number; y: number; at: number } | undefined;\n let lastPointer = \"mouse\";\n /**\n * The touch or pen press that just ended did something: its `touchend` is cancelled, so no click or mouse events\n * follow, and a pen's click, which comes without touch events, is cancelled itself.\n */\n let consumed = false;\n let sheetOpen = false;\n /** Closes an open sheet when the element goes, for example when its message is deleted. */\n const disposed = new AbortController();\n let reduced = false;\n let settleTimer: ReturnType<typeof setTimeout> | undefined;\n\n const active = () => props.items.length > 0;\n const wide = () => window.matchMedia?.(\"(min-width: 48rem)\").matches ?? false;\n /**\n * Inside a modal dialog the hold keeps the sheet: it opens as a level of the same dialog stack, so Escape and Back\n * close it before the dialog. An engine without `:modal` gets the sheet too.\n */\n const inModal = () => {\n const dialog = surface.closest(\"dialog[open]\");\n if (!dialog) return false;\n try {\n return dialog.matches(\":modal\");\n } catch {\n return true;\n }\n };\n const action = (kind: GestureKind) => gestureAction(props.items, kind);\n const touchAction = () => (action(\"swipe-right\") || action(\"swipe-left\") ? \"swipe\" : action(\"double-tap\") ? \"tap\" : undefined);\n\n /** Whether the event started on something with a meaning of its own, inside this element. */\n const ignored = (target: EventTarget | null) => {\n const found = target instanceof Element ? target.closest(IGNORE) : null;\n return found !== null && found !== surface && surface.contains(found);\n };\n\n /** Set while the menu opens in place of a sheet whose code did not load; `onOpen` already ran for it. */\n let announcedOpen = false;\n\n const openSheet = (x: number, y: number) => {\n if (sheetOpen || !active()) return;\n sheetOpen = true;\n const controller = new AbortController();\n sheetController = controller;\n const abortSheet = () => controller.abort();\n disposed.signal.addEventListener(\"abort\", abortSheet, { once: true });\n props.onOpen?.();\n void openMenuSheet(\n {\n Items: DropdownItems,\n items: props.items,\n label: props.label,\n locale: locale(),\n top: props.sheetTop,\n signal: controller.signal,\n },\n (error) => {\n globalThis.reportError(error);\n // The sheet's code did not load: the person still chooses, from the menu beside the finger, and the next\n // hold tries the sheet again.\n if (controller.signal.aborted) return;\n announcedOpen = true;\n openMenuAt?.(x, y);\n announcedOpen = false;\n },\n ).finally(() => {\n disposed.signal.removeEventListener(\"abort\", abortSheet);\n if (sheetController === controller) {\n sheetController = undefined;\n sheetOpen = false;\n }\n });\n };\n\n /** Another pointer that goes down anywhere while a finger presses, as in a pinch, ends the gesture. */\n const onOtherPointer = (event: PointerEvent) => {\n if (!press || event.pointerId === press.id) return;\n if (press.direction) settle();\n endPress();\n };\n\n const endPress = () => {\n clearTimeout(press?.timer);\n press = undefined;\n document.removeEventListener(\"pointerdown\", onOtherPointer, true);\n delete surface.dataset.pressing;\n };\n\n const settle = () => {\n const current = swipe();\n if (!current) return;\n clearTimeout(settleTimer);\n if (reduced || current.offset === 0) {\n setSwipe(undefined);\n return;\n }\n setSwipe({ ...current, offset: 0, progress: 0, armed: false, settling: true });\n settleTimer = setTimeout(() => setSwipe(undefined), SETTLE_MS);\n };\n\n const moveSwipe = (current: Press, direction: SwipeDirection, dx: number) => {\n const travel = Math.max(0, direction === \"right\" ? dx : -dx);\n const moved = travel <= SWIPE_THRESHOLD ? travel : SWIPE_THRESHOLD + (travel - SWIPE_THRESHOLD) * SWIPE_RESISTANCE;\n const offset = reduced ? 0 : Math.min(SWIPE_MAX, moved) * (direction === \"right\" ? 1 : -1);\n current.direction = direction;\n setSwipe({\n direction,\n icon: action(swipeKind(direction))?.icon,\n offset,\n progress: Math.min(1, travel / SWIPE_THRESHOLD),\n armed: travel >= SWIPE_THRESHOLD,\n settling: false,\n });\n };\n\n const longPress = () => {\n if (!press) return;\n press.long = true;\n lastTap = undefined;\n if (wide() && !inModal()) openMenuAt?.(press.x, press.y);\n else openSheet(press.x, press.y);\n };\n\n const onPointerDown = (event: PointerEvent) => {\n lastPointer = event.pointerType;\n consumed = false;\n // Any press in between, on a link, with a mouse, or with another finger, ends a pending double tap.\n const previous = lastTap;\n lastTap = undefined;\n // Another finger ends the gesture through `onOtherPointer` and starts none.\n if (event.pointerType === \"mouse\" || !event.isPrimary) return;\n endPress();\n if (!active() || ignored(event.target)) return;\n const second =\n previous !== undefined &&\n performance.now() - previous.at <= DOUBLE_TAP_MS &&\n Math.hypot(event.clientX - previous.x, event.clientY - previous.y) <= DOUBLE_TAP_DISTANCE;\n press = {\n id: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n moved: false,\n long: false,\n second,\n edge: event.clientX < EDGE || event.clientX > window.innerWidth - EDGE,\n timer: setTimeout(longPress, LONG_PRESS_MS),\n };\n document.addEventListener(\"pointerdown\", onOtherPointer, true);\n // Hybrid devices keep text selection for the mouse; a finger on the element selects nothing.\n surface.dataset.pressing = \"\";\n };\n\n const onPointerMove = (event: PointerEvent) => {\n const current = press;\n if (!current || event.pointerId !== current.id) return;\n // Hold-then-drag hands this press to DragSource through onPointerDragStart.\n if (current.long) return;\n const dx = event.clientX - current.x;\n const dy = event.clientY - current.y;\n if (current.direction) {\n moveSwipe(current, current.direction, dx);\n return;\n }\n if (current.moved || Math.hypot(dx, dy) < SLOP) return;\n current.moved = true;\n clearTimeout(current.timer);\n if (current.edge || Math.abs(dx) < Math.abs(dy) * SWIPE_RATIO) return;\n const direction: SwipeDirection = dx > 0 ? \"right\" : \"left\";\n if (!action(swipeKind(direction))) return;\n clearTimeout(settleTimer);\n reduced = prefersReducedMotion();\n moveSwipe(current, direction, dx);\n };\n\n const onPointerUp = (event: PointerEvent) => {\n const current = press;\n if (!current || event.pointerId !== current.id) return;\n endPress();\n if (current.long) {\n consumed = true;\n return;\n }\n if (current.direction) {\n // Where the finger lifts decides, and the item as it is now.\n moveSwipe(current, current.direction, event.clientX - current.x);\n const swipeAction = swipe()?.armed ? action(swipeKind(current.direction)) : undefined;\n settle();\n if (swipeAction) {\n consumed = true;\n swipeAction.action();\n }\n return;\n }\n if (current.moved) return;\n const doubleTap = action(\"double-tap\");\n if (!doubleTap) return;\n if (current.second) {\n consumed = true;\n doubleTap.action();\n return;\n }\n lastTap = { x: event.clientX, y: event.clientY, at: performance.now() };\n };\n\n // The browser took the touch, for example to scroll the page.\n const onPointerCancel = (event: PointerEvent) => {\n if (!press || event.pointerId !== press.id) return;\n if (press.direction) settle();\n endPress();\n lastTap = undefined;\n };\n\n // Once the hold opens the menu or sheet, further movement must not scroll the page underneath it.\n const onTouchMove = (event: TouchEvent) => {\n if (press?.long && event.cancelable) event.preventDefault();\n };\n\n const onTouchEnd = (event: TouchEvent) => {\n if (!consumed) return;\n consumed = false;\n if (event.cancelable) event.preventDefault();\n };\n\n // A pen sends no touch events; the click after its gesture is cancelled here. A keyboard's click has no detail.\n const onClick = (event: MouseEvent) => {\n if (!consumed || event.detail === 0) return;\n consumed = false;\n event.preventDefault();\n event.stopPropagation();\n };\n\n const onContextMenu = (event: MouseEvent) => {\n // Without items the element has no menu, and the browser keeps its own.\n if (!active()) return;\n // Links, fields, and code keep the browser's own menu.\n if (ignored(event.target)) {\n event.stopPropagation();\n return;\n }\n // A mouse or the keyboard opens the menu beside the element through ContextMenu.\n if (!press && !(\"pointerType\" in event && (event.pointerType === \"touch\" || event.pointerType === \"pen\"))) return;\n // Android and touch screens report a long press as a context-menu event, sometimes before the timer.\n event.preventDefault();\n event.stopPropagation();\n if (press && !press.long && !press.moved) {\n clearTimeout(press.timer);\n longPress();\n }\n };\n\n // The second press of a mouse double-click would select a word; in this element it runs the double-tap action.\n const onMouseDown = (event: MouseEvent) => {\n if (event.button === 0 && event.detail >= 2 && lastPointer === \"mouse\" && action(\"double-tap\") && !ignored(event.target))\n event.preventDefault();\n };\n\n const onDoubleClick = (event: MouseEvent) => {\n if (lastPointer !== \"mouse\" || ignored(event.target)) return;\n const doubleTap = action(\"double-tap\");\n if (!doubleTap) return;\n event.preventDefault();\n doubleTap.action();\n };\n\n onMount(() => {\n const unsubscribeDrag = onPointerDragStart((pointerId) => {\n if (press?.id !== pointerId) return;\n consumed = true;\n lastTap = undefined;\n closeMenu?.();\n sheetController?.abort();\n endPress();\n });\n surface.addEventListener(\"pointerdown\", onPointerDown);\n surface.addEventListener(\"pointermove\", onPointerMove);\n surface.addEventListener(\"pointerup\", onPointerUp);\n surface.addEventListener(\"pointercancel\", onPointerCancel);\n surface.addEventListener(\"touchmove\", onTouchMove, { passive: false });\n surface.addEventListener(\"touchend\", onTouchEnd, { passive: false });\n surface.addEventListener(\"click\", onClick, true);\n surface.addEventListener(\"contextmenu\", onContextMenu);\n surface.addEventListener(\"mousedown\", onMouseDown);\n surface.addEventListener(\"dblclick\", onDoubleClick);\n onCleanup(() => {\n unsubscribeDrag();\n disposed.abort();\n endPress();\n clearTimeout(settleTimer);\n surface.removeEventListener(\"pointerdown\", onPointerDown);\n surface.removeEventListener(\"pointermove\", onPointerMove);\n surface.removeEventListener(\"pointerup\", onPointerUp);\n surface.removeEventListener(\"pointercancel\", onPointerCancel);\n surface.removeEventListener(\"touchmove\", onTouchMove);\n surface.removeEventListener(\"touchend\", onTouchEnd);\n surface.removeEventListener(\"click\", onClick, true);\n surface.removeEventListener(\"contextmenu\", onContextMenu);\n surface.removeEventListener(\"mousedown\", onMouseDown);\n surface.removeEventListener(\"dblclick\", onDoubleClick);\n });\n });\n\n return (\n <ContextMenuBase\n openAt={(open) => (openMenuAt = open)}\n closeWith={(close) => (closeMenu = close)}\n title={props.label}\n items={props.items}\n label={props.label}\n tabIndex={props.tabIndex}\n disabled={!active()}\n onOpen={() => {\n if (!announcedOpen) props.onOpen?.();\n }}\n class={props.class}\n >\n <div\n ref={surface}\n class=\"k2b-gesture-menu\"\n data-active={active() ? \"\" : undefined}\n data-touch={touchAction()}\n data-swipe={swipe()?.direction}\n data-armed={swipe()?.armed ? \"\" : undefined}\n data-settling={swipe()?.settling ? \"\" : undefined}\n style={{\n \"--k2b-gesture-menu-offset\": `${swipe()?.offset ?? 0}px`,\n \"--k2b-gesture-menu-progress\": String(swipe()?.progress ?? 0),\n }}\n >\n <Show when={swipe()}>\n {(current) => (\n <span class=\"k2b-gesture-menu__swipe\" aria-hidden=\"true\">\n <i class={current().icon ?? (current().direction === \"right\" ? \"ti ti-arrow-right\" : \"ti ti-arrow-left\")} />\n </span>\n )}\n </Show>\n <div class=\"k2b-gesture-menu__content\">{props.children}</div>\n </div>\n </ContextMenuBase>\n );\n}\n\nexport default GestureMenu;\n"],"mappings":";;;;;;;AAAA,SAAS,YAAY,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AAC3E,SAAS,SAAS,QAAQ,gBAAgB;AAC1C,SAAS,oBAAoB,QAAQ,WAAW;AAChD,SAAS,eAAe,QAAQ,eAAe;AAC/C,SAA4E,aAAa,QAA8B,YAAY;AACnI,SAAS,kBAAkB,QAAQ,iBAAiB;AACpD,SAAS,aAAa,QAAQ,mBAAmB;;AAEjD;AACA,MAAM,aAAa,GAAG,GAAG;AACzB;AACA,MAAM,aAAa,GAAG,GAAG;AACzB;AACA,MAAM,mBAAmB,GAAG,EAAE;AAC9B;AACA,MAAM,IAAI,GAAG,EAAE;AACf;AACA,MAAM,WAAW,GAAG,GAAG;AACvB;AACA,MAAM,eAAe,GAAG,EAAE;AAC1B;AACA,MAAM,SAAS,GAAG,EAAE;AACpB,MAAM,gBAAgB,GAAG,IAAI;AAC7B;AACA,MAAM,IAAI,GAAG,EAAE;AACf;AACA,MAAM,SAAS,GAAG,GAAG;;AAErB;AACA;AACA;AACA;AACA,MAAM,MAAM,GAAG,CACb,SAAS,EACT,QAAQ,EACR,OAAO,EACP,UAAU,EACV,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAO,EACP,OAAO,EACP,KAAK,EACL,kDAAkD,EAClD,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,uBAAuB,CACxB,CAAC,IAAI,CAAC,IAAI,CAAC;;AAIZ;;AA6DA,MAAM,aAAa,GAAG,CAAC,KAAiC,EAAE,IAAiB,KAAoC;EAC7G,KAAK,MAAM,IAAI,IAAI,K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AS,kDAC5B,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,EAAE,YAAG,SAAS,kEAElB,YAAG,KAAK,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,WAAI,iEACzB,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,IAAI,CAAC,CAAC,qCAG9D,IAAI;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,CAAC;QAAA;QAAA,UACf,OAAO,oDAEK,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;MAE3G,cAEqC,KAAK,CAAC,QAAQ;IAAA;EAAA;AAI9D;AAEA,eAAe,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { ssr as _$ssr } from "solid-js/web";
|
|
3
|
+
import { ssrAttribute as _$ssrAttribute } from "solid-js/web";
|
|
4
|
+
import { escape as _$escape } from "solid-js/web";
|
|
5
|
+
import { ssrStyleProperty as _$ssrStyleProperty } from "solid-js/web";
|
|
6
|
+
import { memo as _$memo } from "solid-js/web";
|
|
7
|
+
var _tmpl$ = ["<i", " aria-hidden=\"true\"></i>"],
|
|
8
|
+
_tmpl$2 = ["<div style=\"", "\">", "</div>"];
|
|
9
|
+
import { batch, createSignal, onCleanup, onMount } from "solid-js";
|
|
10
|
+
import { Button } from "./Button";
|
|
11
|
+
import { SelectionToolbar } from "./SelectionToolbar";
|
|
12
|
+
|
|
13
|
+
/** A selection's text as the action receives it: each run of whitespace as one space, trimmed. */
|
|
14
|
+
|
|
15
|
+
const selectionActionText = text => text.replace(/\s+/gu, " ").trim();
|
|
16
|
+
const coarse = () => typeof window !== "undefined" && window.matchMedia("(pointer: coarse)").matches;
|
|
17
|
+
|
|
18
|
+
/** The box of a range's first line, or of its last line for a pill below it. */
|
|
19
|
+
const lineBox = (range, last) => {
|
|
20
|
+
const rects = Array.from(range.getClientRects()).filter(rect => rect.width > 0 || rect.height > 0);
|
|
21
|
+
const edge = last ? rects.at(-1) : rects[0];
|
|
22
|
+
if (!edge) return null;
|
|
23
|
+
const line = rects.filter(rect => Math.abs(rect.top - edge.top) < 4);
|
|
24
|
+
const left = Math.min(...line.map(rect => rect.left));
|
|
25
|
+
const right = Math.max(...line.map(rect => rect.right));
|
|
26
|
+
return new DOMRect(left, edge.top, Math.max(1, right - left), edge.height);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* One action for selected text, such as "Quote", as a small pill at the selection. It lies in the top layer, so it
|
|
31
|
+
* never moves the page, and pressing it keeps the selection. It appears once the pointer lets go of a selection inside
|
|
32
|
+
* `root`, or at once for a selection made with the keyboard. Tab right after the selection moves the focus to the pill,
|
|
33
|
+
* Enter runs it, and Tab or Escape returns the focus. Escape also closes the pill for that selection. On touch screens
|
|
34
|
+
* it sits below the selection, clear of the system's own selection menu above it.
|
|
35
|
+
*
|
|
36
|
+
* It listens to the document's selection only while it is mounted, so an application can load it on the first
|
|
37
|
+
* selection and keep its code out of the first page.
|
|
38
|
+
*/
|
|
39
|
+
export function SelectionAction(props) {
|
|
40
|
+
const [revision, setRevision] = createSignal(0);
|
|
41
|
+
const [pressed, setPressed] = createSignal(false);
|
|
42
|
+
const [dismissed, setDismissed] = createSignal();
|
|
43
|
+
let pill;
|
|
44
|
+
let returnFocus = null;
|
|
45
|
+
/**
|
|
46
|
+
* The selection as Tab took it into the pill. Moving the focus to a button clears the selection in WebKit, so the
|
|
47
|
+
* pill keeps this copy while it has the focus.
|
|
48
|
+
*/
|
|
49
|
+
let held = null;
|
|
50
|
+
|
|
51
|
+
/** The selection and its part, while it lies in one part of the root. */
|
|
52
|
+
const current = () => {
|
|
53
|
+
const selection = document.getSelection();
|
|
54
|
+
if (!selection || selection.isCollapsed || selection.rangeCount === 0) return null;
|
|
55
|
+
let range = selection.getRangeAt(0);
|
|
56
|
+
const part = node => {
|
|
57
|
+
if (!props.root.contains(node)) return null;
|
|
58
|
+
return props.within ? props.within(node) ?? null : props.root;
|
|
59
|
+
};
|
|
60
|
+
const element = part(range.startContainer);
|
|
61
|
+
if (!element) return null;
|
|
62
|
+
let text = selection.toString();
|
|
63
|
+
if (part(range.endContainer) !== element) {
|
|
64
|
+
// A triple click selects a paragraph up to the start of the next block. When nothing but whitespace lies past the
|
|
65
|
+
// part, the selection ends with the part; a selection into another part offers nothing.
|
|
66
|
+
const end = document.createRange();
|
|
67
|
+
end.selectNodeContents(element);
|
|
68
|
+
if (range.compareBoundaryPoints(Range.END_TO_END, end) < 0) return null;
|
|
69
|
+
const rest = document.createRange();
|
|
70
|
+
rest.setStart(end.endContainer, end.endOffset);
|
|
71
|
+
rest.setEnd(range.endContainer, range.endOffset);
|
|
72
|
+
if (rest.toString().trim()) return null;
|
|
73
|
+
range = range.cloneRange();
|
|
74
|
+
range.setEnd(end.endContainer, end.endOffset);
|
|
75
|
+
text = range.toString();
|
|
76
|
+
}
|
|
77
|
+
text = selectionActionText(text);
|
|
78
|
+
return text ? {
|
|
79
|
+
range,
|
|
80
|
+
element,
|
|
81
|
+
text
|
|
82
|
+
} : null;
|
|
83
|
+
};
|
|
84
|
+
const sameRange = (a, b) => !!a && a.startContainer === b.startContainer && a.startOffset === b.startOffset && a.endContainer === b.endContainer && a.endOffset === b.endOffset;
|
|
85
|
+
const selected = () => current() ?? (held && pill?.contains(document.activeElement) ? held : null);
|
|
86
|
+
const anchor = () => {
|
|
87
|
+
revision();
|
|
88
|
+
if (pressed()) return null;
|
|
89
|
+
const chosen = selected();
|
|
90
|
+
if (!chosen || sameRange(dismissed(), chosen.range)) return null;
|
|
91
|
+
const below = coarse();
|
|
92
|
+
const box = lineBox(chosen.range, below);
|
|
93
|
+
// Below on touch also clears the selection handles under the last line.
|
|
94
|
+
return box && below ? new DOMRect(box.left, box.top, box.width, box.height + 16) : box;
|
|
95
|
+
};
|
|
96
|
+
const open = () => !!anchor();
|
|
97
|
+
const close = restore => {
|
|
98
|
+
const chosen = selected();
|
|
99
|
+
held = null;
|
|
100
|
+
batch(() => {
|
|
101
|
+
if (chosen) setDismissed(chosen.range.cloneRange());
|
|
102
|
+
setRevision(value => value + 1);
|
|
103
|
+
});
|
|
104
|
+
if (restore) returnFocus?.focus({
|
|
105
|
+
preventScroll: true
|
|
106
|
+
});
|
|
107
|
+
returnFocus = null;
|
|
108
|
+
};
|
|
109
|
+
const run = () => {
|
|
110
|
+
const chosen = selected();
|
|
111
|
+
held = null;
|
|
112
|
+
if (!chosen) return;
|
|
113
|
+
props.onAction({
|
|
114
|
+
text: chosen.text,
|
|
115
|
+
element: chosen.element
|
|
116
|
+
});
|
|
117
|
+
document.getSelection()?.removeAllRanges();
|
|
118
|
+
returnFocus?.focus({
|
|
119
|
+
preventScroll: true
|
|
120
|
+
});
|
|
121
|
+
returnFocus = null;
|
|
122
|
+
setRevision(value => value + 1);
|
|
123
|
+
};
|
|
124
|
+
onMount(() => {
|
|
125
|
+
const changed = () => {
|
|
126
|
+
// A new selection forgets an earlier Escape.
|
|
127
|
+
const selected = current();
|
|
128
|
+
if (!selected || !sameRange(dismissed(), selected.range)) setDismissed(undefined);
|
|
129
|
+
setRevision(value => value + 1);
|
|
130
|
+
};
|
|
131
|
+
const press = event => {
|
|
132
|
+
if (pill?.contains(event.target)) return;
|
|
133
|
+
setPressed(true);
|
|
134
|
+
};
|
|
135
|
+
const release = () => {
|
|
136
|
+
if (!pressed()) return;
|
|
137
|
+
setPressed(false);
|
|
138
|
+
};
|
|
139
|
+
const key = event => {
|
|
140
|
+
if (event.isComposing || !open()) return;
|
|
141
|
+
const inside = !!pill && pill.contains(document.activeElement);
|
|
142
|
+
// Keys belong to the pill only while the focus is on the page, in the root or in the pill: a dialog or a
|
|
143
|
+
// field elsewhere keeps its own Tab and Escape.
|
|
144
|
+
const active = document.activeElement;
|
|
145
|
+
if (!inside && active && active !== document.body && active !== document.documentElement && !props.root.contains(active)) return;
|
|
146
|
+
// A field, a dialog or an open menu inside the root keeps its keys too.
|
|
147
|
+
if (!inside && active?.closest("input, textarea, select, [contenteditable]:not([contenteditable='false']), dialog, [popover]")) return;
|
|
148
|
+
if (event.key === "Escape") {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
event.stopPropagation();
|
|
151
|
+
close(inside);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (event.key !== "Tab" || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
155
|
+
if (inside) {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
close(true);
|
|
158
|
+
} else if (!event.shiftKey) {
|
|
159
|
+
const button = pill?.querySelector("button");
|
|
160
|
+
if (!button) return;
|
|
161
|
+
const before = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
162
|
+
const chosen = current();
|
|
163
|
+
held = chosen && {
|
|
164
|
+
...chosen,
|
|
165
|
+
range: chosen.range.cloneRange()
|
|
166
|
+
};
|
|
167
|
+
button.focus({
|
|
168
|
+
preventScroll: true
|
|
169
|
+
});
|
|
170
|
+
// Only a pill that took the focus takes the key; an inert page leaves Tab to the browser.
|
|
171
|
+
if (document.activeElement !== button) {
|
|
172
|
+
held = null;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
returnFocus = before;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
document.addEventListener("selectionchange", changed);
|
|
180
|
+
document.addEventListener("pointerdown", press, true);
|
|
181
|
+
document.addEventListener("pointerup", release, true);
|
|
182
|
+
document.addEventListener("pointercancel", release, true);
|
|
183
|
+
document.addEventListener("keydown", key, true);
|
|
184
|
+
onCleanup(() => {
|
|
185
|
+
document.removeEventListener("selectionchange", changed);
|
|
186
|
+
document.removeEventListener("pointerdown", press, true);
|
|
187
|
+
document.removeEventListener("pointerup", release, true);
|
|
188
|
+
document.removeEventListener("pointercancel", release, true);
|
|
189
|
+
document.removeEventListener("keydown", key, true);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
return _$createComponent(SelectionToolbar, {
|
|
193
|
+
get label() {
|
|
194
|
+
return props.label;
|
|
195
|
+
},
|
|
196
|
+
anchor: anchor,
|
|
197
|
+
get placement() {
|
|
198
|
+
return coarse() ? "below" : "above";
|
|
199
|
+
},
|
|
200
|
+
get children() {
|
|
201
|
+
return _$ssr(_tmpl$2, _$ssrStyleProperty("display:", "contents"), _$escape(_$createComponent(Button, {
|
|
202
|
+
size: "sm",
|
|
203
|
+
variant: "ghost",
|
|
204
|
+
onClick: run,
|
|
205
|
+
get children() {
|
|
206
|
+
return [_$ssr(_tmpl$, _$ssrAttribute("class", _$escape(props.icon, true), false)), props.label];
|
|
207
|
+
}
|
|
208
|
+
})));
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=SelectionAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["actions/SelectionAction.tsx"],"sourcesContent":["import { batch, createSignal, type JSX, onCleanup, onMount } from \"solid-js\";\nimport { Button } from \"./Button\";\nimport { SelectionToolbar } from \"./SelectionToolbar\";\n\nexport type SelectionActionSelection = {\n /** The selected text, with each run of whitespace as one space and trimmed. */\n text: string;\n /** The part of the root that holds the whole selection, as `within` returned it. */\n element: HTMLElement;\n};\n\nexport type SelectionActionProps = {\n /** The element whose text selections offer the action, such as a message history. */\n root: HTMLElement;\n /**\n * The part one selection may lie in, such as the text of one message. It receives the selection's start and end\n * nodes and returns their part, or nothing. A selection whose start and end lie in different parts, or outside every\n * part, offers nothing. Without it, the whole root is one part.\n */\n within?: (node: Node) => HTMLElement | null | undefined;\n /** The action's name, shown beside its icon, such as \"Quote\". */\n label: string;\n /** The action's icon class, such as \"ti ti-quote\". */\n icon: string;\n /** Runs with the selection when the person presses the action; the selection is cleared afterwards. */\n onAction: (selection: SelectionActionSelection) => void;\n};\n\n/** A selection's text as the action receives it: each run of whitespace as one space, trimmed. */\ntype Selected = { range: Range; element: HTMLElement; text: string };\n\nconst selectionActionText = (text: string) => text.replace(/\\s+/gu, \" \").trim();\n\nconst coarse = () => typeof window !== \"undefined\" && window.matchMedia(\"(pointer: coarse)\").matches;\n\n/** The box of a range's first line, or of its last line for a pill below it. */\nconst lineBox = (range: Range, last: boolean): DOMRect | null => {\n const rects = Array.from(range.getClientRects()).filter((rect) => rect.width > 0 || rect.height > 0);\n const edge = last ? rects.at(-1) : rects[0];\n if (!edge) return null;\n const line = rects.filter((rect) => Math.abs(rect.top - edge.top) < 4);\n const left = Math.min(...line.map((rect) => rect.left));\n const right = Math.max(...line.map((rect) => rect.right));\n return new DOMRect(left, edge.top, Math.max(1, right - left), edge.height);\n};\n\n/**\n * One action for selected text, such as \"Quote\", as a small pill at the selection. It lies in the top layer, so it\n * never moves the page, and pressing it keeps the selection. It appears once the pointer lets go of a selection inside\n * `root`, or at once for a selection made with the keyboard. Tab right after the selection moves the focus to the pill,\n * Enter runs it, and Tab or Escape returns the focus. Escape also closes the pill for that selection. On touch screens\n * it sits below the selection, clear of the system's own selection menu above it.\n *\n * It listens to the document's selection only while it is mounted, so an application can load it on the first\n * selection and keep its code out of the first page.\n */\nexport function SelectionAction(props: SelectionActionProps): JSX.Element {\n const [revision, setRevision] = createSignal(0);\n const [pressed, setPressed] = createSignal(false);\n const [dismissed, setDismissed] = createSignal<Range>();\n let pill: HTMLDivElement | undefined;\n let returnFocus: HTMLElement | null = null;\n /**\n * The selection as Tab took it into the pill. Moving the focus to a button clears the selection in WebKit, so the\n * pill keeps this copy while it has the focus.\n */\n let held: Selected | null = null;\n\n /** The selection and its part, while it lies in one part of the root. */\n const current = (): Selected | null => {\n const selection = document.getSelection();\n if (!selection || selection.isCollapsed || selection.rangeCount === 0) return null;\n let range = selection.getRangeAt(0);\n const part = (node: Node) => {\n if (!props.root.contains(node)) return null;\n return props.within ? (props.within(node) ?? null) : props.root;\n };\n const element = part(range.startContainer);\n if (!element) return null;\n let text = selection.toString();\n if (part(range.endContainer) !== element) {\n // A triple click selects a paragraph up to the start of the next block. When nothing but whitespace lies past the\n // part, the selection ends with the part; a selection into another part offers nothing.\n const end = document.createRange();\n end.selectNodeContents(element);\n if (range.compareBoundaryPoints(Range.END_TO_END, end) < 0) return null;\n const rest = document.createRange();\n rest.setStart(end.endContainer, end.endOffset);\n rest.setEnd(range.endContainer, range.endOffset);\n if (rest.toString().trim()) return null;\n range = range.cloneRange();\n range.setEnd(end.endContainer, end.endOffset);\n text = range.toString();\n }\n text = selectionActionText(text);\n return text ? { range, element, text } : null;\n };\n\n const sameRange = (a: Range | undefined, b: Range) =>\n !!a &&\n a.startContainer === b.startContainer &&\n a.startOffset === b.startOffset &&\n a.endContainer === b.endContainer &&\n a.endOffset === b.endOffset;\n\n const selected = () => current() ?? (held && pill?.contains(document.activeElement) ? held : null);\n\n const anchor = () => {\n revision();\n if (pressed()) return null;\n const chosen = selected();\n if (!chosen || sameRange(dismissed(), chosen.range)) return null;\n const below = coarse();\n const box = lineBox(chosen.range, below);\n // Below on touch also clears the selection handles under the last line.\n return box && below ? new DOMRect(box.left, box.top, box.width, box.height + 16) : box;\n };\n const open = () => !!anchor();\n\n const close = (restore: boolean) => {\n const chosen = selected();\n held = null;\n batch(() => {\n if (chosen) setDismissed(chosen.range.cloneRange());\n setRevision((value) => value + 1);\n });\n if (restore) returnFocus?.focus({ preventScroll: true });\n returnFocus = null;\n };\n\n const run = () => {\n const chosen = selected();\n held = null;\n if (!chosen) return;\n props.onAction({ text: chosen.text, element: chosen.element });\n document.getSelection()?.removeAllRanges();\n returnFocus?.focus({ preventScroll: true });\n returnFocus = null;\n setRevision((value) => value + 1);\n };\n\n onMount(() => {\n const changed = () => {\n // A new selection forgets an earlier Escape.\n const selected = current();\n if (!selected || !sameRange(dismissed(), selected.range)) setDismissed(undefined);\n setRevision((value) => value + 1);\n };\n const press = (event: PointerEvent) => {\n if (pill?.contains(event.target as Node)) return;\n setPressed(true);\n };\n const release = () => {\n if (!pressed()) return;\n setPressed(false);\n };\n const key = (event: KeyboardEvent) => {\n if (event.isComposing || !open()) return;\n const inside = !!pill && pill.contains(document.activeElement);\n // Keys belong to the pill only while the focus is on the page, in the root or in the pill: a dialog or a\n // field elsewhere keeps its own Tab and Escape.\n const active = document.activeElement;\n if (!inside && active && active !== document.body && active !== document.documentElement && !props.root.contains(active)) return;\n // A field, a dialog or an open menu inside the root keeps its keys too.\n if (!inside && active?.closest(\"input, textarea, select, [contenteditable]:not([contenteditable='false']), dialog, [popover]\"))\n return;\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n close(inside);\n return;\n }\n if (event.key !== \"Tab\" || event.altKey || event.ctrlKey || event.metaKey) return;\n if (inside) {\n event.preventDefault();\n close(true);\n } else if (!event.shiftKey) {\n const button = pill?.querySelector<HTMLButtonElement>(\"button\");\n if (!button) return;\n const before = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n const chosen = current();\n held = chosen && { ...chosen, range: chosen.range.cloneRange() };\n button.focus({ preventScroll: true });\n // Only a pill that took the focus takes the key; an inert page leaves Tab to the browser.\n if (document.activeElement !== button) {\n held = null;\n return;\n }\n event.preventDefault();\n returnFocus = before;\n }\n };\n document.addEventListener(\"selectionchange\", changed);\n document.addEventListener(\"pointerdown\", press, true);\n document.addEventListener(\"pointerup\", release, true);\n document.addEventListener(\"pointercancel\", release, true);\n document.addEventListener(\"keydown\", key, true);\n onCleanup(() => {\n document.removeEventListener(\"selectionchange\", changed);\n document.removeEventListener(\"pointerdown\", press, true);\n document.removeEventListener(\"pointerup\", release, true);\n document.removeEventListener(\"pointercancel\", release, true);\n document.removeEventListener(\"keydown\", key, true);\n });\n });\n\n return (\n <SelectionToolbar label={props.label} anchor={anchor} placement={coarse() ? \"below\" : \"above\"}>\n <div\n ref={pill}\n style={{ display: \"contents\" }}\n onFocusOut={(event) => {\n // The focus leaving the pill drops the copy of the selection it took along.\n if (event.relatedTarget instanceof Node && pill?.contains(event.relatedTarget)) return;\n held = null;\n setRevision((value) => value + 1);\n }}\n >\n <Button size=\"sm\" variant=\"ghost\" onClick={run}>\n <i class={props.icon} aria-hidden=\"true\" />\n {props.label}\n </Button>\n </div>\n </SelectionToolbar>\n );\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,KAAK,EAAE,YAAY,EAAY,SAAS,EAAE,OAAO,QAAQ,UAAU;AAC5E,SAAS,MAAM,QAAQ,UAAU;AACjC,SAAS,gBAAgB,QAAQ,oBAAoB;;AA0BrD;;AAGA,MAAM,mBAAmB,GAAI,IAAY,IAAK,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AAE/E,MAAM,MAAM,GAAG,MAAM,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC,OAAO;;AAEpG;AACA,MAAM,OAAO,GAAG,CAAC,KAAY,EAAE,IAAa,KAAqB;EAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAE,IAAI,IAAK,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;EACpG,MAAM,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;EAC3C,IAAI,CAAC,IAAI,EAAE,OAAO,IAAI;EACtB,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAE,IAAI,IAAK,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;EACtE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAE,IAAI,IAAK,IAAI,CAAC,IAAI,CAAC,CAAC;EACvD,MAA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import type { JSX } from \"solid-js\";\n\n/**\n * One entry of a command list: the slash menu of `MarkdownEditor` and `CommandMenu` read the same entries, so a\n * composer's `/`, its \"+\" button, and a chip offer one list.\n */\n/** Where a slash at `start` stands in `value`: the text before it and whether only whitespace precedes it, overall or on its line. */\nexport const commandPlace = (value: string, start: number, end: number) => {\n const before = value.slice(0, start);\n return {\n text: before + value.slice(end),\n before,\n atStart: before.trim() === \"\",\n lineStart: before.slice(before.lastIndexOf(\"\\n\") + 1).trim() === \"\",\n };\n};\n\nexport type CommandItem = {\n label: string;\n /** Heading above the entry. Entries of one group stand together, in the order the groups first appear. */\n group?: string;\n /** One quiet line of what the entry does, after the label on the same line, such as \"Preis aus dem Text prüfen\". */\n description?: string;\n /** Quiet text at the end of the row, such as what a person can type: `/telefonat`. It is searched, too. */\n hint?: string;\n /** Tabler icon class, such as `ti ti-phone`. */\n icon?: string;\n /**\n * An image at icon size in place of the icon, such as a service's logo: a URL, or one for each theme when the logo\n * needs a light variant on dark surfaces. It is decorative; the label names the entry.\n */\n image?: string | { light: string; dark: string };\n /**\n * Renders the start of the row in place of the icon, such as an avatar or a tag's color. A function, so each row\n * gets its own element.\n */\n leading?: () => JSX.Element;\n /** Further words that find the entry, such as \"anruf\" for \"Phone call\". */\n keywords?: readonly string[];\n /** Unavailable now: the entry stays in the list, greyed, with this one-line reason, and cannot be chosen. */\n disabled?: string;\n /** Stable key, when two entries share group and label. */\n id?: string;\n} & (\n | {\n /**\n * Runs when the entry is chosen, with the text it acts on. In the editor, the typed `/query` has left the text\n * first. A returned promise keeps the list open with the entry busy; any other result counts as done; a rejection shows its message on the entry,\n * which can then run again, and Escape aborts `context.signal`.\n */\n onSelect: (context: CommandContext) => unknown;\n text?: never;\n next?: never;\n }\n | {\n /** Text that takes the place of the typed `/query`; `CommandMenu` hands it to `onInsert`. */\n text: string;\n onSelect?: never;\n next?: never;\n }\n | {\n /** A second list in the same popover, such as people to assign. */\n next: CommandStep;\n onSelect?: never;\n text?: never;\n }\n);\n\n/**\n * Where a command list is and what it acts on: one context for the entries of every level and for `onSelect`. In\n * `SlashCommands` the text is the editor's, without the typed `/query`; in `CommandMenu` it is the text of its `target`\n * field, or empty without one.\n */\nexport type CommandContext = {\n /** What the person typed after `/`, or into the menu's search field. */\n query: string;\n /** The whole text without the typed `/query`. */\n text: string;\n /** The text before the slash, or before the caret in `CommandMenu`. */\n before: string;\n /** Whether the slash is the first character of the text, leading whitespace aside. */\n atStart: boolean;\n /** Whether the slash starts a line, leading whitespace aside. */\n lineStart: boolean;\n /** The selection in `text`; `start === end` is the caret. */\n selection: { start: number; end: number };\n /** The entries chosen so far on the way to this level, such as `[assign, person]` on the third. */\n path: readonly CommandItem[];\n /**\n * Puts text at the caret in place of the selection, as typing would, so undo keeps working. Without a `target`,\n * `CommandMenu` hands it to `onInsert`. Meant for `onSelect`.\n */\n insert: (text: string) => void;\n /**\n * Reports what a command did, such as \"Valentin Brandt zugewiesen\": after the command finished, the list gives way to\n * a short confirmation in the same place. Meant for `onSelect`; an entry source has its own loading and failure.\n */\n success: (message: string) => void;\n /**\n * Reports why a command could not do it, such as \"Keine Artikelnummer im Text\"; it stays until the person types on\n * or presses Escape. A command that throws or rejects reports its error itself, with a way to try again.\n */\n error: (message: string) => void;\n /**\n * Aborts when the result is no longer wanted: a new query replaces a pending list, or the person closes the list\n * with Escape before a command's promise settled.\n */\n signal: AbortSignal;\n};\n\n/**\n * The entries of a list: a list, or a function of the context that decides which entries there are in this place, at\n * once or as a promise, such as templates only at the start of the text or people from a server search. Either way the\n * list filters them by the query; give server matches the words they matched on as `keywords`.\n */\nexport type CommandSource =\n | readonly CommandItem[]\n | ((context: CommandContext) => readonly CommandItem[] | Promise<readonly CommandItem[]>);\n\n/** A further list in the same place, as deep as needed. Escape, or Backspace on an empty query, goes back. */\nexport type CommandStep = {\n /** Names the list and is the search hint, such as \"Search person\". */\n label: string;\n items: CommandSource;\n};\n\nexport type CommandGroup = { label?: string; entries: { item: CommandItem; index: number }[] };\n\nconst marks = /\\p{M}/gu;\nconst fold = (text: string) => text.normalize(\"NFD\").replace(marks, \"\").toLowerCase().replace(/ß/g, \"ss\");\n// German writes ä as ae where umlauts are missing, so \"zustaendig\" finds \"zuständig\" as well as \"zustandig\" does.\nconst spellOut = (text: string) => text.normalize(\"NFC\").toLowerCase().replace(/ä/g, \"ae\").replace(/ö/g, \"oe\").replace(/ü/g, \"ue\");\n\n// Built on every search, not cached by entry: an application may change an entry in place, such as its label.\nconst haystackOf = (item: CommandItem): string => {\n const text = [item.label, item.description, item.hint?.replace(/^\\//, \"\"), ...(item.keywords ?? [])].filter(Boolean).join(\" \");\n return `${fold(text)} ${fold(spellOut(text))}`;\n};\n\n/**\n * The entries whose label, hint, or keywords contain every word of the query, ignoring case and accents, in their\n * order. A blank query keeps all.\n */\nexport const filterCommandItems = (items: readonly CommandItem[], query: string): readonly CommandItem[] => {\n const words = fold(query).trim().split(/\\s+/).filter(Boolean);\n if (words.length === 0) return items;\n return items.filter((item) => {\n const haystack = haystackOf(item);\n return words.every((word) => haystack.includes(word));\n });\n};\n\n/** The entries of a source in a context, filtered by its query; a promise resolves to the filtered entries. */\nexport const resolveCommandSource = (\n source: CommandSource,\n context: CommandContext,\n): readonly CommandItem[] | Promise<readonly CommandItem[]> => {\n const result = typeof source === \"function\" ? source(context) : source;\n return result instanceof Promise\n ? result.then((items) => filterCommandItems(items, context.query))\n : filterCommandItems(result, context.query);\n};\n\n/** Groups in the order they first appear; `index` is the entry's place in the order the list shows. */\nexport const groupCommandItems = (items: readonly CommandItem[]): CommandGroup[] => {\n const groups: CommandGroup[] = [];\n const byLabel = new Map<string | undefined, CommandGroup>();\n for (const item of items) {\n let group = byLabel.get(item.group);\n if (!group) {\n group = { label: item.group, entries: [] };\n byLabel.set(item.group, group);\n groups.push(group);\n }\n group.entries.push({ item, index: 0 });\n }\n let index = 0;\n for (const group of groups) for (const entry of group.entries) entry.index = index++;\n return groups;\n};\n\nexport const commandKey = (item: CommandItem): string => item.id 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,IAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;IACnC,IAAI,CAAC,KAAK,EAAE;MACV,KAAK,GAAG;QAAE,KAAK,EAAE,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE;MAAG,CAAC;MAC1C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC;MAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IACpB;IACA,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;MAAE,IAAI;MAAE,KAAK,EAAE;IAAE,CAAC,CAAC;EACxC;EACA,IAAI,KAAK,GAAG,CAAC;EACb,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,EAAE;EACpF,OAAO,MAAM;AACf,CAAC;AAED,OAAO,MAAM,UAAU,GAAI,IAAiB,IAAa,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["actions/command-items.ts"],"sourcesContent":["import type { JSX } from \"solid-js\";\n\n/**\n * One entry of a command list: the slash menu of `MarkdownEditor` and `CommandMenu` read the same entries, so a\n * composer's `/`, its \"+\" button, and a chip offer one list.\n */\n/** Where a slash at `start` stands in `value`: the text before it and whether only whitespace precedes it, overall or on its line. */\nexport const commandPlace = (value: string, start: number, end: number) => {\n const before = value.slice(0, start);\n return {\n text: before + value.slice(end),\n before,\n atStart: before.trim() === \"\",\n lineStart: before.slice(before.lastIndexOf(\"\\n\") + 1).trim() === \"\",\n };\n};\n\nexport type CommandItem = {\n label: string;\n /** Heading above the entry. Entries of one group stand together, in the order the groups first appear. */\n group?: string;\n /** One quiet line of what the entry does, after the label on the same line, such as \"Preis aus dem Text prüfen\". */\n description?: string;\n /**\n * Shown in place of `description`, such as a colored `Tag`. A function, so each place gets its own element.\n * It shows only with a `description`, which stays the text that search and screen readers use.\n */\n descriptionVisual?: () => JSX.Element;\n /** Quiet text at the end of the row, such as what a person can type: `/telefonat`. It is searched, too. */\n hint?: string;\n /** Tabler icon class, such as `ti ti-phone`. */\n icon?: string;\n /**\n * An image at icon size in place of the icon, such as a service's logo: a URL, or one for each theme when the logo\n * needs a light variant on dark surfaces. It is decorative; the label names the entry.\n */\n image?: string | { light: string; dark: string };\n /**\n * Renders the start of the row in place of the icon, such as an avatar or a tag's color. A function, so each row\n * gets its own element.\n */\n leading?: () => JSX.Element;\n /** Further words that find the entry, such as \"anruf\" for \"Phone call\". */\n keywords?: readonly string[];\n /** Unavailable now: the entry stays in the list, greyed, with this one-line reason, and cannot be chosen. */\n disabled?: string;\n /** Stable key, when two entries share group and label. */\n id?: string;\n} & (\n | {\n /**\n * Runs when the entry is chosen, with the text it acts on. In the editor, the typed `/query` has left the text\n * first. A returned promise keeps the list open with the entry busy; any other result counts as done; a rejection shows its message on the entry,\n * which can then run again, and Escape aborts `context.signal`.\n */\n onSelect: (context: CommandContext) => unknown;\n text?: never;\n next?: never;\n }\n | {\n /** Text that takes the place of the typed `/query`; `CommandMenu` hands it to `onInsert`. */\n text: string;\n onSelect?: never;\n next?: never;\n }\n | {\n /** A second list in the same popover, such as people to assign. */\n next: CommandStep;\n onSelect?: never;\n text?: never;\n }\n);\n\n/**\n * Where a command list is and what it acts on: one context for the entries of every level and for `onSelect`. In\n * `SlashCommands` the text is the editor's, without the typed `/query`; in `CommandMenu` it is the text of its `target`\n * field, or empty without one.\n */\nexport type CommandContext = {\n /** What the person typed after `/`, or into the menu's search field. */\n query: string;\n /** The whole text without the typed `/query`. */\n text: string;\n /** The text before the slash, or before the caret in `CommandMenu`. */\n before: string;\n /** Whether the slash is the first character of the text, leading whitespace aside. */\n atStart: boolean;\n /** Whether the slash starts a line, leading whitespace aside. */\n lineStart: boolean;\n /** The selection in `text`; `start === end` is the caret. */\n selection: { start: number; end: number };\n /** The entries chosen so far on the way to this level, such as `[assign, person]` on the third. */\n path: readonly CommandItem[];\n /**\n * Puts text at the caret in place of the selection, as typing would, so undo keeps working. Without a `target`,\n * `CommandMenu` hands it to `onInsert`. Meant for `onSelect`.\n */\n insert: (text: string) => void;\n /**\n * Reports what a command did, such as \"Valentin Brandt zugewiesen\": after the command finished, the list gives way to\n * a short confirmation in the same place. Meant for `onSelect`; an entry source has its own loading and failure.\n */\n success: (message: string) => void;\n /**\n * Reports why a command could not do it, such as \"Keine Artikelnummer im Text\"; it stays until the person types on\n * or presses Escape. A command that throws or rejects reports its error itself, with a way to try again.\n */\n error: (message: string) => void;\n /**\n * Aborts when the result is no longer wanted: a new query replaces a pending list, or the person closes the list\n * with Escape before a command's promise settled.\n */\n signal: AbortSignal;\n};\n\n/**\n * The entries of a list: a list, or a function of the context that decides which entries there are in this place, at\n * once or as a promise, such as templates only at the start of the text or people from a server search. Either way the\n * list filters them by the query; give server matches the words they matched on as `keywords`.\n */\nexport type CommandSource =\n | readonly CommandItem[]\n | ((context: CommandContext) => readonly CommandItem[] | Promise<readonly CommandItem[]>);\n\n/** A further list in the same place, as deep as needed. Escape, or Backspace on an empty query, goes back. */\nexport type CommandStep = {\n /** Names the list and is the search hint, such as \"Search person\". */\n label: string;\n items: CommandSource;\n};\n\nexport type CommandGroup = { label?: string; entries: { item: CommandItem; index: number }[] };\n\nconst marks = /\\p{M}/gu;\nconst fold = (text: string) => text.normalize(\"NFD\").replace(marks, \"\").toLowerCase().replace(/ß/g, \"ss\");\n// German writes ä as ae where umlauts are missing, so \"zustaendig\" finds \"zuständig\" as well as \"zustandig\" does.\nconst spellOut = (text: string) => text.normalize(\"NFC\").toLowerCase().replace(/ä/g, \"ae\").replace(/ö/g, \"oe\").replace(/ü/g, \"ue\");\n\n// Built on every search, not cached by entry: an application may change an entry in place, such as its label.\nconst haystackOf = (item: CommandItem): string => {\n const text = [item.label, item.description, item.hint?.replace(/^\\//, \"\"), ...(item.keywords ?? [])].filter(Boolean).join(\" \");\n return `${fold(text)} ${fold(spellOut(text))}`;\n};\n\n/**\n * The entries whose label, hint, or keywords contain every word of the query, ignoring case and accents, in their\n * order. A blank query keeps all.\n */\nexport const filterCommandItems = (items: readonly CommandItem[], query: string): readonly CommandItem[] => {\n const words = fold(query).trim().split(/\\s+/).filter(Boolean);\n if (words.length === 0) return items;\n return items.filter((item) => {\n const haystack = haystackOf(item);\n return words.every((word) => haystack.includes(word));\n });\n};\n\n/** The entries of a source in a context, filtered by its query; a promise resolves to the filtered entries. */\nexport const resolveCommandSource = (\n source: CommandSource,\n context: CommandContext,\n): readonly CommandItem[] | Promise<readonly CommandItem[]> => {\n const result = typeof source === \"function\" ? source(context) : source;\n return result instanceof Promise\n ? result.then((items) => filterCommandItems(items, context.query))\n : filterCommandItems(result, context.query);\n};\n\n/** Groups in the order they first appear; `index` is the entry's place in the order the list shows. */\nexport const groupCommandItems = (items: readonly CommandItem[]): CommandGroup[] => {\n const groups: CommandGroup[] = [];\n const byLabel = new Map<string | undefined, CommandGroup>();\n for (const item of items) {\n let group = byLabel.get(item.group);\n if (!group) {\n group = { label: item.group, entries: [] };\n byLabel.set(item.group, group);\n groups.push(group);\n }\n group.entries.push({ item, index: 0 });\n }\n let index = 0;\n for (const group of groups) for (const entry of group.entries) entry.index = index++;\n return groups;\n};\n\nexport const commandKey = (item: CommandItem): string => item.id ?? `${item.group ?? \"\"}\\u0000${item.label}`;\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW,KAAK;EACzE,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;EACpC,OAAO;IACL,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;IAC/B,MAAM;IACN,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC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;MAAE,KAAK,EAAE;IAAE,CAAC,CAAC;EACxC;EACA,IAAI,KAAK,GAAG,CAAC;EACb,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,EAAE;EACpF,OAAO,MAAM;AACf,CAAC;AAED,OAAO,MAAM,UAAU,GAAI,IAAiB,IAAa,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@ export { FilterChip, FilterToggle } from "./FilterChip";
|
|
|
9
9
|
export { GestureMenu } from "./GestureMenu";
|
|
10
10
|
export { RemoveButton } from "./RemoveButton";
|
|
11
11
|
export { SegmentedControl } from "./SegmentedControl";
|
|
12
|
+
export { SelectionAction } from "./SelectionAction";
|
|
12
13
|
export { SelectionToolbar } from "./SelectionToolbar";
|
|
13
14
|
export { SortableList } from "./SortableList";
|
|
14
15
|
export { SplitButton } from "./SplitButton";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["actions/index.ts"],"sourcesContent":["export type { ButtonAlign, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant, IconButtonLinkProps, IconButtonProps } from \"./Button\";\nexport { Button, ButtonLink, IconButton, IconButtonLink } from \"./Button\";\nexport type { CommandMenuProps } from \"./CommandMenu\";\nexport { CommandMenu } from \"./CommandMenu\";\nexport type { ContextMenuProps } from \"./ContextMenu\";\nexport { ContextMenu } from \"./ContextMenu\";\nexport type { CopyButtonProps, CopyButtonValue } from \"./CopyButton\";\nexport { CopyButton } from \"./CopyButton\";\nexport type { CommandContext, CommandItem, CommandSource, CommandStep } from \"./command-items\";\nexport type { DisclosureProps } from \"./Disclosure\";\nexport { Disclosure } from \"./Disclosure\";\nexport type { DragPayload, DragSourceProps, DropTargetProps } from \"./DragAndDrop\";\nexport { activeDrag, DragSource, DropTarget, useKeyboardDrag } from \"./DragAndDrop\";\nexport type {\n DropdownAction,\n DropdownActionBase,\n DropdownAnchor,\n DropdownChoice,\n DropdownItemProps,\n DropdownPosition,\n DropdownProps,\n DropdownReturnFocus,\n DropdownSearch,\n DropdownSection,\n DropdownTriggerProps,\n} from \"./Dropdown\";\nexport { Dropdown, DropdownItem, dropdownPosition } from \"./Dropdown\";\nexport type { FilterChipOption, FilterChipProps, FilterChipSection, FilterToggleProps } from \"./FilterChip\";\nexport { FilterChip, FilterToggle } from \"./FilterChip\";\nexport type { GestureKind, GestureMenuAction, GestureMenuItem, GestureMenuProps, GestureMenuSection } from \"./GestureMenu\";\nexport { GestureMenu } from \"./GestureMenu\";\nexport type { RemoveButtonProps } from \"./RemoveButton\";\nexport { RemoveButton } from \"./RemoveButton\";\nexport type { SegmentedControlProps, SegmentOption } from \"./SegmentedControl\";\nexport { SegmentedControl } from \"./SegmentedControl\";\nexport type { SelectionToolbarProps } from \"./SelectionToolbar\";\nexport { SelectionToolbar } from \"./SelectionToolbar\";\nexport type { SortableListProps } from \"./SortableList\";\nexport { SortableList } from \"./SortableList\";\nexport type { SplitButtonProps } from \"./SplitButton\";\nexport { SplitButton } from \"./SplitButton\";\nexport type {\n SpotlightButtonProps,\n SpotlightButtonVariant,\n SpotlightSearchOptions,\n SpotlightSearchResolver,\n} from \"./SpotlightSearch\";\nexport {\n openSpotlightSearch,\n SpotlightButton,\n} from \"./SpotlightSearch\";\nexport type { TabOption, TabsItemProps, TabsProps } from \"./Tabs\";\nexport { Tabs } from \"./Tabs\";\nexport type {\n ToolbarActionProps,\n ToolbarDockProps,\n ToolbarGroupProps,\n ToolbarLabelProps,\n ToolbarProps,\n ToolbarSeparatorProps,\n} from \"./Toolbar\";\nexport { Toolbar, ToolbarDock } from \"./Toolbar\";\nexport type { ViewTab, ViewTabsProps } from \"./ViewTabs\";\nexport { ViewTabs } from \"./ViewTabs\";\n"],"mappings":"AACA,SAAS,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,QAAQ,UAAU;AAEzE,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,UAAU,QAAQ,cAAc;AAGzC,SAAS,UAAU,QAAQ,cAAc;AAEzC,SAAS,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,QAAQ,eAAe;AAcnF,SAAS,QAAQ,EAAE,YAAY,EAAE,gBAAgB,QAAQ,YAAY;AAErE,SAAS,UAAU,EAAE,YAAY,QAAQ,cAAc;AAEvD,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,gBAAgB,QAAQ,oBAAoB;AAErD,SAAS,gBAAgB,QAAQ,oBAAoB;AAErD,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,WAAW,QAAQ,eAAe;AAO3C,SACE,mBAAmB,EACnB,eAAe,QACV,mBAAmB;AAE1B,SAAS,IAAI,QAAQ,QAAQ;AAS7B,SAAS,OAAO,EAAE,WAAW,QAAQ,WAAW;AAEhD,SAAS,QAAQ,QAAQ,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["actions/index.ts"],"sourcesContent":["export type { ButtonAlign, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant, IconButtonLinkProps, IconButtonProps } from \"./Button\";\nexport { Button, ButtonLink, IconButton, IconButtonLink } from \"./Button\";\nexport type { CommandMenuProps } from \"./CommandMenu\";\nexport { CommandMenu } from \"./CommandMenu\";\nexport type { ContextMenuProps } from \"./ContextMenu\";\nexport { ContextMenu } from \"./ContextMenu\";\nexport type { CopyButtonProps, CopyButtonValue } from \"./CopyButton\";\nexport { CopyButton } from \"./CopyButton\";\nexport type { CommandContext, CommandItem, CommandSource, CommandStep } from \"./command-items\";\nexport type { DisclosureProps } from \"./Disclosure\";\nexport { Disclosure } from \"./Disclosure\";\nexport type { DragPayload, DragSourceProps, DropTargetProps } from \"./DragAndDrop\";\nexport { activeDrag, DragSource, DropTarget, useKeyboardDrag } from \"./DragAndDrop\";\nexport type {\n DropdownAction,\n DropdownActionBase,\n DropdownAnchor,\n DropdownChoice,\n DropdownItemProps,\n DropdownPosition,\n DropdownProps,\n DropdownReturnFocus,\n DropdownSearch,\n DropdownSection,\n DropdownTriggerProps,\n} from \"./Dropdown\";\nexport { Dropdown, DropdownItem, dropdownPosition } from \"./Dropdown\";\nexport type { FilterChipOption, FilterChipProps, FilterChipSection, FilterToggleProps } from \"./FilterChip\";\nexport { FilterChip, FilterToggle } from \"./FilterChip\";\nexport type { GestureKind, GestureMenuAction, GestureMenuItem, GestureMenuProps, GestureMenuSection } from \"./GestureMenu\";\nexport { GestureMenu } from \"./GestureMenu\";\nexport type { RemoveButtonProps } from \"./RemoveButton\";\nexport { RemoveButton } from \"./RemoveButton\";\nexport type { SegmentedControlProps, SegmentOption } from \"./SegmentedControl\";\nexport { SegmentedControl } from \"./SegmentedControl\";\nexport type { SelectionActionProps, SelectionActionSelection } from \"./SelectionAction\";\nexport { SelectionAction } from \"./SelectionAction\";\nexport type { SelectionToolbarProps } from \"./SelectionToolbar\";\nexport { SelectionToolbar } from \"./SelectionToolbar\";\nexport type { SortableListProps } from \"./SortableList\";\nexport { SortableList } from \"./SortableList\";\nexport type { SplitButtonProps } from \"./SplitButton\";\nexport { SplitButton } from \"./SplitButton\";\nexport type {\n SpotlightButtonProps,\n SpotlightButtonVariant,\n SpotlightSearchOptions,\n SpotlightSearchResolver,\n} from \"./SpotlightSearch\";\nexport {\n openSpotlightSearch,\n SpotlightButton,\n} from \"./SpotlightSearch\";\nexport type { TabOption, TabsItemProps, TabsProps } from \"./Tabs\";\nexport { Tabs } from \"./Tabs\";\nexport type {\n ToolbarActionProps,\n ToolbarDockProps,\n ToolbarGroupProps,\n ToolbarLabelProps,\n ToolbarProps,\n ToolbarSeparatorProps,\n} from \"./Toolbar\";\nexport { Toolbar, ToolbarDock } from \"./Toolbar\";\nexport type { ViewTab, ViewTabsProps } from \"./ViewTabs\";\nexport { ViewTabs } from \"./ViewTabs\";\n"],"mappings":"AACA,SAAS,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,QAAQ,UAAU;AAEzE,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,UAAU,QAAQ,cAAc;AAGzC,SAAS,UAAU,QAAQ,cAAc;AAEzC,SAAS,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,QAAQ,eAAe;AAcnF,SAAS,QAAQ,EAAE,YAAY,EAAE,gBAAgB,QAAQ,YAAY;AAErE,SAAS,UAAU,EAAE,YAAY,QAAQ,cAAc;AAEvD,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,gBAAgB,QAAQ,oBAAoB;AAErD,SAAS,eAAe,QAAQ,mBAAmB;AAEnD,SAAS,gBAAgB,QAAQ,oBAAoB;AAErD,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,WAAW,QAAQ,eAAe;AAO3C,SACE,mBAAmB,EACnB,eAAe,QACV,mBAAmB;AAE1B,SAAS,IAAI,QAAQ,QAAQ;AAS7B,SAAS,OAAO,EAAE,WAAW,QAAQ,WAAW;AAEhD,SAAS,QAAQ,QAAQ,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { prefersMenuSheet } from "./phone-sheet";
|
|
2
|
+
let menuSheet;
|
|
3
|
+
|
|
4
|
+
/** Loads the phone menu sheet's code once; a wide screen that never opens a sheet never loads it. */
|
|
5
|
+
export const loadMenuSheet = () => menuSheet ? Promise.resolve(menuSheet) : import("./menu-sheet").then(module => menuSheet = module);
|
|
6
|
+
|
|
7
|
+
/** Whether the sheet's code is here, so a sheet opens at once rather than waiting for it. */
|
|
8
|
+
export const menuSheetReady = () => menuSheet !== undefined;
|
|
9
|
+
|
|
10
|
+
// A phone loads the sheet's code in the background when the menus load, so a tap opens the sheet within the tap.
|
|
11
|
+
if (prefersMenuSheet()) loadMenuSheet().catch(() => {});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Opens a menu as a bottom sheet: at once when its code is loaded, otherwise as soon as it is. When the code does not
|
|
15
|
+
* load, `unavailable` runs instead, so the opener can show its menu another way; the next open tries again. A failure
|
|
16
|
+
* of the chosen action itself still rejects.
|
|
17
|
+
*/
|
|
18
|
+
export const openMenuSheet = (options, unavailable) => menuSheet ? menuSheet.openMenuSheet(options) : loadMenuSheet().then(module => module.openMenuSheet(options), unavailable);
|
|
19
|
+
//# sourceMappingURL=menu-sheet-open.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["actions/menu-sheet-open.ts"],"sourcesContent":["import type { MenuSheetOptions } from \"./menu-sheet\";\nimport { prefersMenuSheet } from \"./phone-sheet\";\n\ntype MenuSheet = typeof import(\"./menu-sheet\");\nlet menuSheet: MenuSheet | undefined;\n\n/** Loads the phone menu sheet's code once; a wide screen that never opens a sheet never loads it. */\nexport const loadMenuSheet = (): Promise<MenuSheet> =>\n menuSheet ? Promise.resolve(menuSheet) : import(\"./menu-sheet\").then((module) => (menuSheet = module));\n\n/** Whether the sheet's code is here, so a sheet opens at once rather than waiting for it. */\nexport const menuSheetReady = (): boolean => menuSheet !== undefined;\n\n// A phone loads the sheet's code in the background when the menus load, so a tap opens the sheet within the tap.\nif (prefersMenuSheet()) loadMenuSheet().catch(() => {});\n\n/**\n * Opens a menu as a bottom sheet: at once when its code is loaded, otherwise as soon as it is. When the code does not\n * load, `unavailable` runs instead, so the opener can show its menu another way; the next open tries again. A failure\n * of the chosen action itself still rejects.\n */\nexport const openMenuSheet = (options: MenuSheetOptions, unavailable: (error: unknown) => void): Promise<void> =>\n menuSheet ? menuSheet.openMenuSheet(options) : loadMenuSheet().then((module) => module.openMenuSheet(options), unavailable);\n"],"mappings":"AACA,SAAS,gBAAgB,QAAQ,eAAe;AAGhD,IAAI,SAAgC;;AAEpC;AACA,OAAO,MAAM,aAAa,GAAG,MAC3B,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,cAAc,CAAC,CAAC,IAAI,CAAE,MAAM,IAAM,SAAS,GAAG,MAAO,CAAC;;AAExG;AACA,OAAO,MAAM,cAAc,GAAG,MAAe,SAAS,KAAK,SAAS;;AAEpE;AACA,IAAI,gBAAgB,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;;AAEvD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,aAAa,GAAG,CAAC,OAAyB,EAAE,WAAqC,KAC5F,SAAS,GAAG,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAE,MAAM,IAAK,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Existing line renderer, separated so detailed drawing stays behind lazy chart boundaries. */
|
|
2
|
-
|
|
2
|
+
import { chartTimeTickBudget } from "../../content/chart-time-calendar";
|
|
3
3
|
import { lineForecastLayout, lineLegendX } from "./line-options";
|
|
4
4
|
import { chartDatumSvg, collectAxisValues, collectSeriesLegend, computeAxisScale, computeDomain, computePlotArea, DEFAULT_HEIGHT, DEFAULT_LINE_STYLES, DEFAULT_WIDTH, emptyChart, escapeXml, fmt, isOnAxis, LINE_DASH_PATTERNS, linePathD, normalizePadding, pickMapper, pointValues, renderErrorBars, renderHeader, renderReferenceLines, renderXAxisNumeric, renderYAxis, resolveErrorY, smoothPathD, stepPathD, svgRoot } from "./svg-common";
|
|
5
5
|
|
|
@@ -58,7 +58,7 @@ export const renderLineDetailsSvg = (opts, time, seriesLabel) => {
|
|
|
58
58
|
...opts.xAxis,
|
|
59
59
|
domain: computeDomain(xValues)
|
|
60
60
|
} : opts.xAxis);
|
|
61
|
-
const timeStep = timeAxis ? chartTimeStep(xAxis.domain[1] - xAxis.domain[0], (opts.xAxis?.ticks
|
|
61
|
+
const timeStep = timeAxis ? chartTimeStep(xAxis.domain[1] - xAxis.domain[0], chartTimeTickBudget(width, opts.xAxis?.ticks)) : undefined;
|
|
62
62
|
if (timeAxis && timeStep) {
|
|
63
63
|
xAxis.ticks = chartTimeTicks(xAxis.domain, timeAxis.timeZone, timeStep);
|
|
64
64
|
xAxis.minorTicks = [];
|