@f-ewald/components 1.42.2 → 1.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/custom-elements.json +597 -3
- package/dist/autocomplete-input.d.ts +16 -3
- package/dist/autocomplete-input.d.ts.map +1 -1
- package/dist/autocomplete-input.js +69 -4
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/data-table.d.ts +11 -2
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +31 -3
- package/dist/data-table.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/kind-icon.d.ts +38 -0
- package/dist/kind-icon.d.ts.map +1 -0
- package/dist/kind-icon.js +87 -0
- package/dist/kind-icon.js.map +1 -0
- package/dist/ui-tooltip.d.ts +49 -0
- package/dist/ui-tooltip.d.ts.map +1 -0
- package/dist/ui-tooltip.js +317 -0
- package/dist/ui-tooltip.js.map +1 -0
- package/docs/autocomplete-input.md +14 -3
- package/docs/data-table.md +18 -0
- package/docs/kind-icon.md +53 -0
- package/docs/ui-tooltip.md +70 -0
- package/llms.txt +97 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -49,6 +49,7 @@ export { LoadingDots } from "./loading-dots.js";
|
|
|
49
49
|
export { ChatMessage, } from "./chat-message.js";
|
|
50
50
|
export { ChevronPanel } from "./chevron-panel.js";
|
|
51
51
|
export { UiCheckbox } from "./ui-checkbox.js";
|
|
52
|
+
export { UiTooltip } from "./ui-tooltip.js";
|
|
52
53
|
export { FormField } from "./form-field.js";
|
|
53
54
|
export { FormSelect } from "./form-select.js";
|
|
54
55
|
export { MultiSelect, } from "./multi-select.js";
|
|
@@ -59,6 +60,7 @@ export { PopoverPanel } from "./popover-panel.js";
|
|
|
59
60
|
export { DropdownButton, } from "./dropdown-button.js";
|
|
60
61
|
export { IconButton } from "./icon-button.js";
|
|
61
62
|
export { KbdHint } from "./kbd-hint.js";
|
|
63
|
+
export { KindIcon } from "./kind-icon.js";
|
|
62
64
|
export { FrameBox } from "./frame-box.js";
|
|
63
65
|
export { AppShell } from "./app-shell.js";
|
|
64
66
|
export { AppSidebar } from "./app-sidebar.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EACL,YAAY,GAIb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAwB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,GAEd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,UAAU,GAIX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAA+B,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,E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yBAAyB,CAAC;AACjC,OAAO,EACL,cAAc,EACd,mBAAmB,GAEpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,WAAW,EACX,eAAe,EACf,UAAU,EACV,YAAY,EACZ,SAAS,GAMV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAuB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,aAAa,GAGd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAA4C,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { AnimateConfetti } from \"./animate-confetti.js\";\nexport { GalleryItem } from \"./gallery-item.js\";\nexport { GalleryItemVariant } from \"./gallery-item-variant.js\";\nexport {\n PhotoGallery,\n type PhotoGalleryChangeReason,\n type PhotoGalleryObjectFit,\n type PhotoGallerySlideChangeDetail,\n} from \"./photo-gallery.js\";\nexport { RevealButton } from \"./reveal-button.js\";\nexport { RomanNumeral } from \"./roman-numeral.js\";\nexport { ConfirmDialog } from \"./confirm-dialog.js\";\nexport { ModalDialog, type ModalDialogSize } from \"./modal-dialog.js\";\nexport { ContentDivider } from \"./content-divider.js\";\nexport {\n ToastNotification,\n notifySuccess,\n notifyError,\n notifyInfo,\n notifyWarning,\n type ToastVariant,\n} from \"./toast-notification.js\";\nexport { ScrollToBottom } from \"./scroll-to-bottom.js\";\nexport {\n ScrollDots,\n type DotSelectDetail,\n type ScrollDotItem,\n type ScrollDotsItem,\n} from \"./scroll-dots.js\";\nexport { ScrollToTop } from \"./scroll-to-top.js\";\nexport { FullscreenButton, type FullscreenChangeDetail } from \"./fullscreen-button.js\";\nexport { SkipLink } from \"./skip-link.js\";\nexport { SlidePanel } from \"./slide-panel.js\";\nexport { CopyLinkButton } from \"./copy-link-button.js\";\nexport { RelativeTime } from \"./relative-time.js\";\nexport { DistanceValue } from \"./distance-value.js\";\nexport { PriceHistoryChart, type PricePoint } from \"./price-history-chart.js\";\nexport { DistributionChart, type DistributionValue } from \"./distribution-chart.js\";\nexport { PercentBarChart, type PercentBarGroup } from \"./percent-bar-chart.js\";\nexport { WeightBarChart, type WeightBarItem } from \"./weight-bar-chart.js\";\nexport {\n DagGraph,\n type DagControl,\n type DagDirection,\n type DagDirectionChangeDetail,\n type DagEdge,\n type DagNode,\n type DagNodeKind,\n type DagNodeSelectDetail,\n} from \"./dag-graph.js\";\nexport {\n AddressAutocomplete,\n type AddressSuggestion,\n} from \"./address-autocomplete.js\";\nexport {\n AutocompleteInput,\n type AutocompleteOption,\n} from \"./autocomplete-input.js\";\nexport { UserAvatar } from \"./user-avatar.js\";\nexport { MapPin } from \"./map-pin.js\";\nexport { MapCircle } from \"./map-circle.js\";\nexport { MapboxMap } from \"./mapbox-map.js\";\nexport { RadioCards, type RadioCardOption } from \"./radio-cards.js\";\nexport { RadioPills, type RadioPillOption } from \"./radio-pills.js\";\nexport { RangeSlider } from \"./range-slider.js\";\nexport { BreadcrumbNav, type BreadcrumbItem, type BreadcrumbNavigateDetail } from \"./breadcrumb-nav.js\";\nexport { ButtonGroup, type ButtonGroupOption } from \"./button-group.js\";\nexport { UiButton, type ButtonVariant } from \"./ui-button.js\";\nexport { StatMeter } from \"./stat-meter.js\";\nexport { ProgressBar } from \"./progress-bar.js\";\nexport { StatusBanner, type StatusBannerVariant } from \"./status-banner.js\";\nexport { UiAdmonition, type AdmonitionVariant } from \"./ui-admonition.js\";\nexport { StatusPill, type StatusPillColor } from \"./status-pill.js\";\nexport { EditableText } from \"./editable-text.js\";\nexport { EmptyState } from \"./empty-state.js\";\nexport { LiveTimer } from \"./live-timer.js\";\nexport { CountdownTimer } from \"./countdown-timer.js\";\nexport { LoadMore } from \"./load-more.js\";\nexport { LoadingSpinner } from \"./loading-spinner.js\";\nexport { LoadingDots } from \"./loading-dots.js\";\nexport {\n ChatMessage,\n type ChatMessageRole,\n type ChatMessageVariant,\n} from \"./chat-message.js\";\nexport { ChevronPanel } from \"./chevron-panel.js\";\nexport { UiCheckbox } from \"./ui-checkbox.js\";\nexport { FormField } from \"./form-field.js\";\nexport { FormSelect, type SelectOption } from \"./form-select.js\";\nexport {\n MultiSelect,\n type MultiSelectOption,\n type MultiSelectVariant,\n} from \"./multi-select.js\";\nexport { DataTable, type DataTableColumn } from \"./data-table.js\";\nexport { TileGrid } from \"./tile-grid.js\";\nexport { TreeView, type TreeNode } from \"./tree-view.js\";\nexport { PopoverPanel } from \"./popover-panel.js\";\nexport {\n DropdownButton,\n type DropdownButtonVariant,\n type DropdownOption,\n} from \"./dropdown-button.js\";\nexport { IconButton } from \"./icon-button.js\";\nexport { KbdHint, type KbdPlatform } from \"./kbd-hint.js\";\nexport { FrameBox } from \"./frame-box.js\";\nexport { AppShell, type SidebarToggleDetail } from \"./app-shell.js\";\nexport { AppSidebar } from \"./app-sidebar.js\";\nexport { ActionBar } from \"./action-bar.js\";\nexport { PageHeader } from \"./page-header.js\";\nexport { PaginationNav, type PageChangeDetail } from \"./pagination-nav.js\";\nexport { FormActions } from \"./form-actions.js\";\nexport { TimelineContainer, type TimelineLayout } from \"./timeline-container.js\";\nexport { TimelineEntry } from \"./timeline-entry.js\";\nexport { CalendarDay } from \"./calendar-day.js\";\nexport { CalendarEntry } from \"./calendar-entry.js\";\nexport { CalendarMonth } from \"./calendar-month.js\";\nexport { CalendarWeek } from \"./calendar-week.js\";\nexport { CalendarYear } from \"./calendar-year.js\";\nexport {\n KanbanBoard,\n type KanbanCardData,\n type KanbanColumnData,\n type KanbanCardMoveDetail,\n type KanbanCardOpenDetail,\n} from \"./kanban-board.js\";\nexport { KanbanColumn } from \"./kanban-column.js\";\nexport { KanbanCard } from \"./kanban-card.js\";\nexport { TextArea } from \"./text-area.js\";\nexport { LinkCard, type LinkCardStatus } from \"./link-card.js\";\nexport { CardGrid } from \"./card-grid.js\";\nexport { MarkdownView } from \"./markdown-view.js\";\nexport { AutoScroll } from \"./auto-scroll.js\";\nexport { SpecList, type SpecListItem } from \"./spec-list.js\";\nexport { SplitHero } from \"./split-hero.js\";\nexport { TabBar, type TabChangeDetail } from \"./tab-bar.js\";\nexport { TabItem } from \"./tab-item.js\";\nexport { MarkdownEditor } from \"./markdown-editor.js\";\nexport {\n parseFrontMatter,\n formatFrontMatterValue,\n type FrontMatterResult,\n} from \"./utils/front-matter.js\";\nexport {\n formatDuration,\n formatClockDuration,\n type DurationFormat,\n} from \"./utils/duration.js\";\nexport { AudioPlayer } from \"./audio-player.js\";\nexport { VideoPlayer } from \"./video-player.js\";\nexport { VoteControl } from \"./vote-control.js\";\nexport { CommentComposer } from \"./comment-composer.js\";\nexport { CronSchedule } from \"./cron-schedule.js\";\nexport {\n CRON_ALIASES,\n CRON_FIELD_BOUNDS,\n CRON_FIELD_LABELS,\n CRON_FIELD_NAMES,\n MONTH_ABBREVIATIONS,\n MONTH_NAMES,\n WEEKDAY_ABBREVIATIONS,\n WEEKDAY_NAMES,\n describeCron,\n detectFrequency,\n expandField,\n fieldFromValues,\n formatCron,\n isEveryValue,\n parseCron,\n type CronExpression,\n type CronField,\n type CronFieldName,\n type CronFrequency,\n type CronTerm,\n} from \"./utils/cron.js\";\nexport {\n tokens,\n tokenValues,\n darkTokenValues,\n gradientTokenValues,\n metroTokenValues,\n blueprintTokenValues,\n developerDarkTokenValues,\n developerLightTokenValues,\n} from \"./tokens.js\";\nexport * from \"./icons.js\";\nexport { BlinkCursor } from \"./blink-cursor.js\";\nexport { CommentLabel } from \"./comment-label.js\";\nexport { StatStrip, type StatStripItem } from \"./stat-strip.js\";\nexport { StepLadder, type StepLadderItem } from \"./step-ladder.js\";\nexport {\n TerminalBlock,\n type TerminalLine,\n type TerminalLineType,\n} from \"./terminal-block.js\";\nexport { CodeDiff, type CodeDiffLine, type CodeDiffLineType } from \"./code-diff.js\";\nexport { WindowChrome } from \"./window-chrome.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EACL,YAAY,GAIb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAwB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,GAEd,MAAM,yBAAy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,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAuB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,aAAa,GAGd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAA4C,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { AnimateConfetti } from \"./animate-confetti.js\";\nexport { GalleryItem } from \"./gallery-item.js\";\nexport { GalleryItemVariant } from \"./gallery-item-variant.js\";\nexport {\n PhotoGallery,\n type PhotoGalleryChangeReason,\n type PhotoGalleryObjectFit,\n type PhotoGallerySlideChangeDetail,\n} from \"./photo-gallery.js\";\nexport { RevealButton } from \"./reveal-button.js\";\nexport { RomanNumeral } from \"./roman-numeral.js\";\nexport { ConfirmDialog } from \"./confirm-dialog.js\";\nexport { ModalDialog, type ModalDialogSize } from \"./modal-dialog.js\";\nexport { ContentDivider } from \"./content-divider.js\";\nexport {\n ToastNotification,\n notifySuccess,\n notifyError,\n notifyInfo,\n notifyWarning,\n type ToastVariant,\n} from \"./toast-notification.js\";\nexport { ScrollToBottom } from \"./scroll-to-bottom.js\";\nexport {\n ScrollDots,\n type DotSelectDetail,\n type ScrollDotItem,\n type ScrollDotsItem,\n} from \"./scroll-dots.js\";\nexport { ScrollToTop } from \"./scroll-to-top.js\";\nexport { FullscreenButton, type FullscreenChangeDetail } from \"./fullscreen-button.js\";\nexport { SkipLink } from \"./skip-link.js\";\nexport { SlidePanel } from \"./slide-panel.js\";\nexport { CopyLinkButton } from \"./copy-link-button.js\";\nexport { RelativeTime } from \"./relative-time.js\";\nexport { DistanceValue } from \"./distance-value.js\";\nexport { PriceHistoryChart, type PricePoint } from \"./price-history-chart.js\";\nexport { DistributionChart, type DistributionValue } from \"./distribution-chart.js\";\nexport { PercentBarChart, type PercentBarGroup } from \"./percent-bar-chart.js\";\nexport { WeightBarChart, type WeightBarItem } from \"./weight-bar-chart.js\";\nexport {\n DagGraph,\n type DagControl,\n type DagDirection,\n type DagDirectionChangeDetail,\n type DagEdge,\n type DagNode,\n type DagNodeKind,\n type DagNodeSelectDetail,\n} from \"./dag-graph.js\";\nexport {\n AddressAutocomplete,\n type AddressSuggestion,\n} from \"./address-autocomplete.js\";\nexport {\n AutocompleteInput,\n type AutocompleteOption,\n} from \"./autocomplete-input.js\";\nexport { UserAvatar } from \"./user-avatar.js\";\nexport { MapPin } from \"./map-pin.js\";\nexport { MapCircle } from \"./map-circle.js\";\nexport { MapboxMap } from \"./mapbox-map.js\";\nexport { RadioCards, type RadioCardOption } from \"./radio-cards.js\";\nexport { RadioPills, type RadioPillOption } from \"./radio-pills.js\";\nexport { RangeSlider } from \"./range-slider.js\";\nexport { BreadcrumbNav, type BreadcrumbItem, type BreadcrumbNavigateDetail } from \"./breadcrumb-nav.js\";\nexport { ButtonGroup, type ButtonGroupOption } from \"./button-group.js\";\nexport { UiButton, type ButtonVariant } from \"./ui-button.js\";\nexport { StatMeter } from \"./stat-meter.js\";\nexport { ProgressBar } from \"./progress-bar.js\";\nexport { StatusBanner, type StatusBannerVariant } from \"./status-banner.js\";\nexport { UiAdmonition, type AdmonitionVariant } from \"./ui-admonition.js\";\nexport { StatusPill, type StatusPillColor } from \"./status-pill.js\";\nexport { EditableText } from \"./editable-text.js\";\nexport { EmptyState } from \"./empty-state.js\";\nexport { LiveTimer } from \"./live-timer.js\";\nexport { CountdownTimer } from \"./countdown-timer.js\";\nexport { LoadMore } from \"./load-more.js\";\nexport { LoadingSpinner } from \"./loading-spinner.js\";\nexport { LoadingDots } from \"./loading-dots.js\";\nexport {\n ChatMessage,\n type ChatMessageRole,\n type ChatMessageVariant,\n} from \"./chat-message.js\";\nexport { ChevronPanel } from \"./chevron-panel.js\";\nexport { UiCheckbox } from \"./ui-checkbox.js\";\nexport { UiTooltip, type UiTooltipPlacement } from \"./ui-tooltip.js\";\nexport { FormField } from \"./form-field.js\";\nexport { FormSelect, type SelectOption } from \"./form-select.js\";\nexport {\n MultiSelect,\n type MultiSelectOption,\n type MultiSelectVariant,\n} from \"./multi-select.js\";\nexport { DataTable, type DataTableAlign, type DataTableColumn } from \"./data-table.js\";\nexport { TileGrid } from \"./tile-grid.js\";\nexport { TreeView, type TreeNode } from \"./tree-view.js\";\nexport { PopoverPanel } from \"./popover-panel.js\";\nexport {\n DropdownButton,\n type DropdownButtonVariant,\n type DropdownOption,\n} from \"./dropdown-button.js\";\nexport { IconButton } from \"./icon-button.js\";\nexport { KbdHint, type KbdPlatform } from \"./kbd-hint.js\";\nexport { KindIcon, type KindIconStyle } from \"./kind-icon.js\";\nexport { FrameBox } from \"./frame-box.js\";\nexport { AppShell, type SidebarToggleDetail } from \"./app-shell.js\";\nexport { AppSidebar } from \"./app-sidebar.js\";\nexport { ActionBar } from \"./action-bar.js\";\nexport { PageHeader } from \"./page-header.js\";\nexport { PaginationNav, type PageChangeDetail } from \"./pagination-nav.js\";\nexport { FormActions } from \"./form-actions.js\";\nexport { TimelineContainer, type TimelineLayout } from \"./timeline-container.js\";\nexport { TimelineEntry } from \"./timeline-entry.js\";\nexport { CalendarDay } from \"./calendar-day.js\";\nexport { CalendarEntry } from \"./calendar-entry.js\";\nexport { CalendarMonth } from \"./calendar-month.js\";\nexport { CalendarWeek } from \"./calendar-week.js\";\nexport { CalendarYear } from \"./calendar-year.js\";\nexport {\n KanbanBoard,\n type KanbanCardData,\n type KanbanColumnData,\n type KanbanCardMoveDetail,\n type KanbanCardOpenDetail,\n} from \"./kanban-board.js\";\nexport { KanbanColumn } from \"./kanban-column.js\";\nexport { KanbanCard } from \"./kanban-card.js\";\nexport { TextArea } from \"./text-area.js\";\nexport { LinkCard, type LinkCardStatus } from \"./link-card.js\";\nexport { CardGrid } from \"./card-grid.js\";\nexport { MarkdownView } from \"./markdown-view.js\";\nexport { AutoScroll } from \"./auto-scroll.js\";\nexport { SpecList, type SpecListItem } from \"./spec-list.js\";\nexport { SplitHero } from \"./split-hero.js\";\nexport { TabBar, type TabChangeDetail } from \"./tab-bar.js\";\nexport { TabItem } from \"./tab-item.js\";\nexport { MarkdownEditor } from \"./markdown-editor.js\";\nexport {\n parseFrontMatter,\n formatFrontMatterValue,\n type FrontMatterResult,\n} from \"./utils/front-matter.js\";\nexport {\n formatDuration,\n formatClockDuration,\n type DurationFormat,\n} from \"./utils/duration.js\";\nexport { AudioPlayer } from \"./audio-player.js\";\nexport { VideoPlayer } from \"./video-player.js\";\nexport { VoteControl } from \"./vote-control.js\";\nexport { CommentComposer } from \"./comment-composer.js\";\nexport { CronSchedule } from \"./cron-schedule.js\";\nexport {\n CRON_ALIASES,\n CRON_FIELD_BOUNDS,\n CRON_FIELD_LABELS,\n CRON_FIELD_NAMES,\n MONTH_ABBREVIATIONS,\n MONTH_NAMES,\n WEEKDAY_ABBREVIATIONS,\n WEEKDAY_NAMES,\n describeCron,\n detectFrequency,\n expandField,\n fieldFromValues,\n formatCron,\n isEveryValue,\n parseCron,\n type CronExpression,\n type CronField,\n type CronFieldName,\n type CronFrequency,\n type CronTerm,\n} from \"./utils/cron.js\";\nexport {\n tokens,\n tokenValues,\n darkTokenValues,\n gradientTokenValues,\n metroTokenValues,\n blueprintTokenValues,\n developerDarkTokenValues,\n developerLightTokenValues,\n} from \"./tokens.js\";\nexport * from \"./icons.js\";\nexport { BlinkCursor } from \"./blink-cursor.js\";\nexport { CommentLabel } from \"./comment-label.js\";\nexport { StatStrip, type StatStripItem } from \"./stat-strip.js\";\nexport { StepLadder, type StepLadderItem } from \"./step-ladder.js\";\nexport {\n TerminalBlock,\n type TerminalLine,\n type TerminalLineType,\n} from \"./terminal-block.js\";\nexport { CodeDiff, type CodeDiffLine, type CodeDiffLineType } from \"./code-diff.js\";\nexport { WindowChrome } from \"./window-chrome.js\";\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement, nothing, type SVGTemplateResult } from "lit";
|
|
2
|
+
/** Presentation of one kind. `dag-graph`'s `DagNodeKind` satisfies this, so one map can drive both. */
|
|
3
|
+
export interface KindIconStyle {
|
|
4
|
+
/** Name of the kind: the visible label with `show-label`, otherwise the icon's accessible name. */
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Icon color (any CSS color); defaults to `--ui-primary`. */
|
|
7
|
+
color?: string;
|
|
8
|
+
/** Icon factory, called with `size` — e.g. one of the package's `icon*` exports. */
|
|
9
|
+
icon?: (size: number) => SVGTemplateResult;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Inline icon for a named kind (e.g. a service, a library, an external
|
|
13
|
+
* package), looked up in a shared `kinds` map so tables, lists, and search
|
|
14
|
+
* results show the same icon and color as a `dag-graph` legend. With
|
|
15
|
+
* `show-label` the kind's label follows the icon as text; otherwise the
|
|
16
|
+
* icon alone is exposed as an image named by the label. Renders nothing for
|
|
17
|
+
* a kind missing from `kinds`.
|
|
18
|
+
*
|
|
19
|
+
* @element kind-icon
|
|
20
|
+
*/
|
|
21
|
+
export declare class KindIcon extends LitElement {
|
|
22
|
+
static styles: import("lit").CSSResult[];
|
|
23
|
+
/** Key of the kind to show, looked up in `kinds`. */
|
|
24
|
+
kind: string;
|
|
25
|
+
/** Presentation per kind: label, color, and icon. Shareable with `dag-graph`'s `kinds`. */
|
|
26
|
+
kinds: Record<string, KindIconStyle>;
|
|
27
|
+
/** Square icon size in pixels: 14 inline, 18 standalone. */
|
|
28
|
+
size: 14 | 18;
|
|
29
|
+
/** Shows the kind's label as text after the icon. */
|
|
30
|
+
showLabel: boolean;
|
|
31
|
+
render(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
"kind-icon": KindIcon;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=kind-icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind-icon.d.ts","sourceRoot":"","sources":["../src/kind-icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,KAAK,CAAC;AAI7E,uGAAuG;AACvG,MAAM,WAAW,aAAa;IAC5B,mGAAmG;IACnG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,CAAC;CAC5C;AAED;;;;;;;;;GASG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,OAAgB,MAAM,4BAmBpB;IAEF,qDAAqD;IACxB,IAAI,SAAM;IACvC,2FAA2F;IAC3D,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAM;IAC1E,4DAA4D;IAChC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAM;IAC/C,qDAAqD;IACgB,SAAS,UAAS;IAE9E,MAAM,0DAgBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, css, html, nothing } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { tokens } from "./tokens.js";
|
|
10
|
+
/**
|
|
11
|
+
* Inline icon for a named kind (e.g. a service, a library, an external
|
|
12
|
+
* package), looked up in a shared `kinds` map so tables, lists, and search
|
|
13
|
+
* results show the same icon and color as a `dag-graph` legend. With
|
|
14
|
+
* `show-label` the kind's label follows the icon as text; otherwise the
|
|
15
|
+
* icon alone is exposed as an image named by the label. Renders nothing for
|
|
16
|
+
* a kind missing from `kinds`.
|
|
17
|
+
*
|
|
18
|
+
* @element kind-icon
|
|
19
|
+
*/
|
|
20
|
+
let KindIcon = class KindIcon extends LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
/** Key of the kind to show, looked up in `kinds`. */
|
|
24
|
+
this.kind = "";
|
|
25
|
+
/** Presentation per kind: label, color, and icon. Shareable with `dag-graph`'s `kinds`. */
|
|
26
|
+
this.kinds = {};
|
|
27
|
+
/** Square icon size in pixels: 14 inline, 18 standalone. */
|
|
28
|
+
this.size = 14;
|
|
29
|
+
/** Shows the kind's label as text after the icon. */
|
|
30
|
+
this.showLabel = false;
|
|
31
|
+
}
|
|
32
|
+
static { this.styles = [
|
|
33
|
+
tokens,
|
|
34
|
+
css `
|
|
35
|
+
:host {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: 0.25rem;
|
|
39
|
+
vertical-align: middle;
|
|
40
|
+
}
|
|
41
|
+
:host([hidden]) {
|
|
42
|
+
display: none;
|
|
43
|
+
}
|
|
44
|
+
.icon {
|
|
45
|
+
display: inline-flex;
|
|
46
|
+
flex: 0 0 auto;
|
|
47
|
+
line-height: 0;
|
|
48
|
+
color: var(--kind-icon-color, var(--ui-primary, #4f46e5));
|
|
49
|
+
}
|
|
50
|
+
`,
|
|
51
|
+
]; }
|
|
52
|
+
render() {
|
|
53
|
+
const style = this.kinds[this.kind];
|
|
54
|
+
if (!style)
|
|
55
|
+
return nothing;
|
|
56
|
+
const label = style.label ?? "";
|
|
57
|
+
const visibleLabel = this.showLabel && label;
|
|
58
|
+
const named = !visibleLabel && label;
|
|
59
|
+
return html `${style.icon
|
|
60
|
+
? html `<span
|
|
61
|
+
class="icon"
|
|
62
|
+
style=${style.color ? `--kind-icon-color: ${style.color}` : nothing}
|
|
63
|
+
role=${named ? "img" : nothing}
|
|
64
|
+
aria-label=${named ? label : nothing}
|
|
65
|
+
aria-hidden=${named ? nothing : "true"}
|
|
66
|
+
>${style.icon(this.size)}</span
|
|
67
|
+
>`
|
|
68
|
+
: nothing}${visibleLabel ? html `<span class="label">${label}</span>` : nothing}`;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
__decorate([
|
|
72
|
+
property({ reflect: true })
|
|
73
|
+
], KindIcon.prototype, "kind", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
property({ attribute: false })
|
|
76
|
+
], KindIcon.prototype, "kinds", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
property({ type: Number })
|
|
79
|
+
], KindIcon.prototype, "size", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
property({ type: Boolean, reflect: true, attribute: "show-label" })
|
|
82
|
+
], KindIcon.prototype, "showLabel", void 0);
|
|
83
|
+
KindIcon = __decorate([
|
|
84
|
+
customElement("kind-icon")
|
|
85
|
+
], KindIcon);
|
|
86
|
+
export { KindIcon };
|
|
87
|
+
//# sourceMappingURL=kind-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind-icon.js","sourceRoot":"","sources":["../src/kind-icon.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAA0B,MAAM,KAAK,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,E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AC,CAAC,OAAO,EAAE,CAAC;IACrF,CAAC;CACF,CAAA;AAzB8B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCAAW;AAEP;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uCAA2C;AAE9C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAoB;AAEsB;IAApE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;2CAAmB;AA7B5E,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAgDpB","sourcesContent":["import { LitElement, css, html, nothing, type SVGTemplateResult } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** Presentation of one kind. `dag-graph`'s `DagNodeKind` satisfies this, so one map can drive both. */\nexport interface KindIconStyle {\n /** Name of the kind: the visible label with `show-label`, otherwise the icon's accessible name. */\n label?: string;\n /** Icon color (any CSS color); defaults to `--ui-primary`. */\n color?: string;\n /** Icon factory, called with `size` — e.g. one of the package's `icon*` exports. */\n icon?: (size: number) => SVGTemplateResult;\n}\n\n/**\n * Inline icon for a named kind (e.g. a service, a library, an external\n * package), looked up in a shared `kinds` map so tables, lists, and search\n * results show the same icon and color as a `dag-graph` legend. With\n * `show-label` the kind's label follows the icon as text; otherwise the\n * icon alone is exposed as an image named by the label. Renders nothing for\n * a kind missing from `kinds`.\n *\n * @element kind-icon\n */\n@customElement(\"kind-icon\")\nexport class KindIcon extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n vertical-align: middle;\n }\n :host([hidden]) {\n display: none;\n }\n .icon {\n display: inline-flex;\n flex: 0 0 auto;\n line-height: 0;\n color: var(--kind-icon-color, var(--ui-primary, #4f46e5));\n }\n `,\n ];\n\n /** Key of the kind to show, looked up in `kinds`. */\n @property({ reflect: true }) kind = \"\";\n /** Presentation per kind: label, color, and icon. Shareable with `dag-graph`'s `kinds`. */\n @property({ attribute: false }) kinds: Record<string, KindIconStyle> = {};\n /** Square icon size in pixels: 14 inline, 18 standalone. */\n @property({ type: Number }) size: 14 | 18 = 14;\n /** Shows the kind's label as text after the icon. */\n @property({ type: Boolean, reflect: true, attribute: \"show-label\" }) showLabel = false;\n\n override render() {\n const style = this.kinds[this.kind];\n if (!style) return nothing;\n const label = style.label ?? \"\";\n const visibleLabel = this.showLabel && label;\n const named = !visibleLabel && label;\n return html`${style.icon\n ? html`<span\n class=\"icon\"\n style=${style.color ? `--kind-icon-color: ${style.color}` : nothing}\n role=${named ? \"img\" : nothing}\n aria-label=${named ? label : nothing}\n aria-hidden=${named ? nothing : \"true\"}\n >${style.icon(this.size)}</span\n >`\n : nothing}${visibleLabel ? html`<span class=\"label\">${label}</span>` : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kind-icon\": KindIcon;\n }\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues } from "lit";
|
|
2
|
+
/** Preferred side of the trigger; the tooltip flips when that side lacks room. */
|
|
3
|
+
export type UiTooltipPlacement = "top" | "bottom";
|
|
4
|
+
/**
|
|
5
|
+
* Hover and focus tooltip for its default-slot trigger. The `content` slot
|
|
6
|
+
* holds the tooltip body — plain text or rich markup such as a list. It
|
|
7
|
+
* appears after `show-delay` on hover and at once on keyboard focus, stays
|
|
8
|
+
* open while the pointer is over the tooltip itself, and closes on Escape,
|
|
9
|
+
* blur, or when the pointer leaves. It renders in the top layer, so
|
|
10
|
+
* scrolling or `overflow: hidden` ancestors never clip it.
|
|
11
|
+
*
|
|
12
|
+
* The trigger is described by the content (`aria-describedby`). A trigger
|
|
13
|
+
* with nothing focusable inside (e.g. plain text) makes the tooltip host
|
|
14
|
+
* focusable so keyboard users can reach the description too. ARIA references
|
|
15
|
+
* can't cross shadow roots, so when the trigger is a custom element whose
|
|
16
|
+
* focusable control lives in its own shadow root, screen readers won't
|
|
17
|
+
* announce the description on focus; prefer a native trigger such as
|
|
18
|
+
* `<button>` when that matters.
|
|
19
|
+
*
|
|
20
|
+
* @element ui-tooltip
|
|
21
|
+
* @slot - The trigger the tooltip describes.
|
|
22
|
+
* @slot content - The tooltip body.
|
|
23
|
+
* @csspart tooltip - The floating tooltip surface.
|
|
24
|
+
*/
|
|
25
|
+
export declare class UiTooltip extends LitElement {
|
|
26
|
+
#private;
|
|
27
|
+
static styles: import("lit").CSSResult[];
|
|
28
|
+
/** Preferred side of the trigger; flips to the other side when this one lacks room. */
|
|
29
|
+
placement: UiTooltipPlacement;
|
|
30
|
+
/** Hover delay in milliseconds before the tooltip appears; keyboard focus shows it at once. */
|
|
31
|
+
showDelay: number;
|
|
32
|
+
/** Suppresses the tooltip and closes it if open. */
|
|
33
|
+
disabled: boolean;
|
|
34
|
+
private _open;
|
|
35
|
+
private _tooltip;
|
|
36
|
+
constructor();
|
|
37
|
+
/** Whether the tooltip is currently showing. */
|
|
38
|
+
get open(): boolean;
|
|
39
|
+
disconnectedCallback(): void;
|
|
40
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
41
|
+
protected updated(changed: PropertyValues): void;
|
|
42
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
43
|
+
}
|
|
44
|
+
declare global {
|
|
45
|
+
interface HTMLElementTagNameMap {
|
|
46
|
+
"ui-tooltip": UiTooltip;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=ui-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-tooltip.d.ts","sourceRoot":"","sources":["../src/ui-tooltip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAMjE,kFAAkF;AAClF,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAmBlD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,SAAU,SAAQ,UAAU;;IACvC,OAAgB,MAAM,4BAoDpB;IAEF,uFAAuF;IAC1D,SAAS,EAAE,kBAAkB,CAAS;IACnE,+FAA+F;IAC1C,SAAS,SAAO;IACrE,oDAAoD;IACR,QAAQ,UAAS;IAEpD,OAAO,CAAC,KAAK,CAAS;IAEZ,OAAO,CAAC,QAAQ,CAAe;IAUlD,cAMC;IAED,gDAAgD;IAChD,IAAI,IAAI,IAAI,OAAO,CAElB;IAEQ,oBAAoB,IAAI,IAAI,CAIpC;IAED,UAAmB,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI,CAKjE;IAED,UAAmB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAQxD;IAoIQ,MAAM,yCAOd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, css, html } from "lit";
|
|
8
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
|
9
|
+
import { tokens } from "./tokens.js";
|
|
10
|
+
let instanceCount = 0;
|
|
11
|
+
/** Space kept between the trigger, the tooltip, and the viewport edges, in pixels. */
|
|
12
|
+
const GAP = 6;
|
|
13
|
+
const EDGE = 4;
|
|
14
|
+
/** Grace period that lets the pointer cross from the trigger onto the tooltip. */
|
|
15
|
+
const HIDE_DELAY = 100;
|
|
16
|
+
const FOCUSABLE = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [contenteditable], [tabindex]:not([tabindex='-1'])";
|
|
17
|
+
/** Whether `root` is or contains a focusable element, looking inside open shadow roots. */
|
|
18
|
+
function containsFocusable(root) {
|
|
19
|
+
if (root instanceof Element && root.matches(FOCUSABLE))
|
|
20
|
+
return true;
|
|
21
|
+
if (root.querySelector(FOCUSABLE))
|
|
22
|
+
return true;
|
|
23
|
+
const hosts = root instanceof Element ? [root, ...root.querySelectorAll("*")] : [...root.querySelectorAll("*")];
|
|
24
|
+
return hosts.some((el) => el.shadowRoot !== null && containsFocusable(el.shadowRoot));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Hover and focus tooltip for its default-slot trigger. The `content` slot
|
|
28
|
+
* holds the tooltip body — plain text or rich markup such as a list. It
|
|
29
|
+
* appears after `show-delay` on hover and at once on keyboard focus, stays
|
|
30
|
+
* open while the pointer is over the tooltip itself, and closes on Escape,
|
|
31
|
+
* blur, or when the pointer leaves. It renders in the top layer, so
|
|
32
|
+
* scrolling or `overflow: hidden` ancestors never clip it.
|
|
33
|
+
*
|
|
34
|
+
* The trigger is described by the content (`aria-describedby`). A trigger
|
|
35
|
+
* with nothing focusable inside (e.g. plain text) makes the tooltip host
|
|
36
|
+
* focusable so keyboard users can reach the description too. ARIA references
|
|
37
|
+
* can't cross shadow roots, so when the trigger is a custom element whose
|
|
38
|
+
* focusable control lives in its own shadow root, screen readers won't
|
|
39
|
+
* announce the description on focus; prefer a native trigger such as
|
|
40
|
+
* `<button>` when that matters.
|
|
41
|
+
*
|
|
42
|
+
* @element ui-tooltip
|
|
43
|
+
* @slot - The trigger the tooltip describes.
|
|
44
|
+
* @slot content - The tooltip body.
|
|
45
|
+
* @csspart tooltip - The floating tooltip surface.
|
|
46
|
+
*/
|
|
47
|
+
let UiTooltip = class UiTooltip extends LitElement {
|
|
48
|
+
static { this.styles = [
|
|
49
|
+
tokens,
|
|
50
|
+
css `
|
|
51
|
+
:host {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
}
|
|
54
|
+
:host(:focus-visible) {
|
|
55
|
+
outline: none;
|
|
56
|
+
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
57
|
+
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
58
|
+
}
|
|
59
|
+
.tooltip {
|
|
60
|
+
position: fixed;
|
|
61
|
+
inset: auto;
|
|
62
|
+
margin: 0;
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
max-width: min(20rem, calc(100vw - 0.5rem));
|
|
65
|
+
padding: 0.25rem 0.5rem;
|
|
66
|
+
border: 0;
|
|
67
|
+
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
68
|
+
background: var(--ui-tooltip, #0f172a);
|
|
69
|
+
color: var(--ui-tooltip-text, #ffffff);
|
|
70
|
+
box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
|
|
71
|
+
font-family: var(
|
|
72
|
+
--ui-font,
|
|
73
|
+
ui-sans-serif,
|
|
74
|
+
system-ui,
|
|
75
|
+
sans-serif,
|
|
76
|
+
"Apple Color Emoji",
|
|
77
|
+
"Segoe UI Emoji",
|
|
78
|
+
"Segoe UI Symbol",
|
|
79
|
+
"Noto Color Emoji"
|
|
80
|
+
);
|
|
81
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
82
|
+
font-weight: var(--ui-font-weight-regular, 400);
|
|
83
|
+
line-height: var(--ui-line-height-tight, 1.25);
|
|
84
|
+
text-align: start;
|
|
85
|
+
overflow-wrap: anywhere;
|
|
86
|
+
}
|
|
87
|
+
@media (forced-colors: active) {
|
|
88
|
+
:host(:focus-visible) {
|
|
89
|
+
outline: 2px solid CanvasText;
|
|
90
|
+
outline-offset: 2px;
|
|
91
|
+
box-shadow: none;
|
|
92
|
+
}
|
|
93
|
+
.tooltip {
|
|
94
|
+
border: 1px solid CanvasText;
|
|
95
|
+
background: Canvas;
|
|
96
|
+
color: CanvasText;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`,
|
|
100
|
+
]; }
|
|
101
|
+
#showTimer;
|
|
102
|
+
#hideTimer;
|
|
103
|
+
#describedTarget;
|
|
104
|
+
#describedId;
|
|
105
|
+
#content;
|
|
106
|
+
#madeFocusable;
|
|
107
|
+
#contentId;
|
|
108
|
+
constructor() {
|
|
109
|
+
super();
|
|
110
|
+
/** Preferred side of the trigger; flips to the other side when this one lacks room. */
|
|
111
|
+
this.placement = "top";
|
|
112
|
+
/** Hover delay in milliseconds before the tooltip appears; keyboard focus shows it at once. */
|
|
113
|
+
this.showDelay = 300;
|
|
114
|
+
/** Suppresses the tooltip and closes it if open. */
|
|
115
|
+
this.disabled = false;
|
|
116
|
+
this._open = false;
|
|
117
|
+
this.#showTimer = null;
|
|
118
|
+
this.#hideTimer = null;
|
|
119
|
+
this.#describedTarget = null;
|
|
120
|
+
this.#describedId = null;
|
|
121
|
+
this.#content = null;
|
|
122
|
+
this.#madeFocusable = false;
|
|
123
|
+
this.#contentId = `ui-tooltip-content-${++instanceCount}`;
|
|
124
|
+
/** Escape closes the tooltip without dismissing anything else (WCAG 1.4.13). */
|
|
125
|
+
this.#onDocumentKeydown = (event) => {
|
|
126
|
+
if (event.key !== "Escape" || !this._open)
|
|
127
|
+
return;
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
this.#clearTimers();
|
|
131
|
+
this.#setOpen(false);
|
|
132
|
+
};
|
|
133
|
+
this.#onViewportChange = () => {
|
|
134
|
+
if (this._open)
|
|
135
|
+
this.#position();
|
|
136
|
+
};
|
|
137
|
+
this.addEventListener("pointerenter", () => this.#scheduleShow(this.showDelay));
|
|
138
|
+
this.addEventListener("pointerleave", () => this.#scheduleHide(HIDE_DELAY, ":focus-within"));
|
|
139
|
+
this.addEventListener("focusin", () => this.#scheduleShow(0));
|
|
140
|
+
this.addEventListener("focusout", () => this.#scheduleHide(0, ":hover"));
|
|
141
|
+
}
|
|
142
|
+
/** Whether the tooltip is currently showing. */
|
|
143
|
+
get open() {
|
|
144
|
+
return this._open;
|
|
145
|
+
}
|
|
146
|
+
disconnectedCallback() {
|
|
147
|
+
super.disconnectedCallback();
|
|
148
|
+
this.#clearTimers();
|
|
149
|
+
this.#setOpen(false);
|
|
150
|
+
}
|
|
151
|
+
willUpdate(changed) {
|
|
152
|
+
if (changed.has("disabled") && this.disabled) {
|
|
153
|
+
this.#clearTimers();
|
|
154
|
+
this.#setOpen(false);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
updated(changed) {
|
|
158
|
+
if (!changed.has("_open"))
|
|
159
|
+
return;
|
|
160
|
+
if (this._open) {
|
|
161
|
+
this._tooltip.showPopover();
|
|
162
|
+
this.#position();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (this._tooltip.matches(":popover-open"))
|
|
166
|
+
this._tooltip.hidePopover();
|
|
167
|
+
}
|
|
168
|
+
#scheduleShow(delay) {
|
|
169
|
+
if (this.disabled || !this.#content)
|
|
170
|
+
return;
|
|
171
|
+
this.#clearTimers();
|
|
172
|
+
if (this._open)
|
|
173
|
+
return;
|
|
174
|
+
if (delay <= 0) {
|
|
175
|
+
this.#setOpen(true);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this.#showTimer = setTimeout(() => this.#setOpen(true), delay);
|
|
179
|
+
}
|
|
180
|
+
/** Hides after `delay` unless the host still matches `keepOpenWhile` (still hovered or focused). */
|
|
181
|
+
#scheduleHide(delay, keepOpenWhile) {
|
|
182
|
+
this.#clearTimers();
|
|
183
|
+
if (!this._open)
|
|
184
|
+
return;
|
|
185
|
+
const hide = () => {
|
|
186
|
+
if (!this.matches(keepOpenWhile))
|
|
187
|
+
this.#setOpen(false);
|
|
188
|
+
};
|
|
189
|
+
if (delay <= 0) {
|
|
190
|
+
hide();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
this.#hideTimer = setTimeout(hide, delay);
|
|
194
|
+
}
|
|
195
|
+
#clearTimers() {
|
|
196
|
+
if (this.#showTimer)
|
|
197
|
+
clearTimeout(this.#showTimer);
|
|
198
|
+
if (this.#hideTimer)
|
|
199
|
+
clearTimeout(this.#hideTimer);
|
|
200
|
+
this.#showTimer = null;
|
|
201
|
+
this.#hideTimer = null;
|
|
202
|
+
}
|
|
203
|
+
#setOpen(open) {
|
|
204
|
+
if (this._open === open)
|
|
205
|
+
return;
|
|
206
|
+
this._open = open;
|
|
207
|
+
if (open) {
|
|
208
|
+
document.addEventListener("keydown", this.#onDocumentKeydown, true);
|
|
209
|
+
window.addEventListener("scroll", this.#onViewportChange, true);
|
|
210
|
+
window.addEventListener("resize", this.#onViewportChange);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
document.removeEventListener("keydown", this.#onDocumentKeydown, true);
|
|
214
|
+
window.removeEventListener("scroll", this.#onViewportChange, true);
|
|
215
|
+
window.removeEventListener("resize", this.#onViewportChange);
|
|
216
|
+
}
|
|
217
|
+
/** Escape closes the tooltip without dismissing anything else (WCAG 1.4.13). */
|
|
218
|
+
#onDocumentKeydown;
|
|
219
|
+
#onViewportChange;
|
|
220
|
+
/** Places the tooltip beside the host, flipping sides and clamping it inside the viewport. */
|
|
221
|
+
#position() {
|
|
222
|
+
const anchor = this.getBoundingClientRect();
|
|
223
|
+
const tip = this._tooltip.getBoundingClientRect();
|
|
224
|
+
const above = anchor.top - GAP - tip.height;
|
|
225
|
+
const below = anchor.bottom + GAP;
|
|
226
|
+
const fitsAbove = above >= EDGE;
|
|
227
|
+
const fitsBelow = below + tip.height <= window.innerHeight - EDGE;
|
|
228
|
+
const top = this.placement === "top" ? (fitsAbove || !fitsBelow ? above : below) : fitsBelow || !fitsAbove ? below : above;
|
|
229
|
+
const centered = anchor.left + anchor.width / 2 - tip.width / 2;
|
|
230
|
+
const left = Math.min(Math.max(centered, EDGE), Math.max(EDGE, window.innerWidth - EDGE - tip.width));
|
|
231
|
+
this._tooltip.style.top = `${Math.round(top)}px`;
|
|
232
|
+
this._tooltip.style.left = `${Math.round(left)}px`;
|
|
233
|
+
this._tooltip.dataset.side = top === above ? "top" : "bottom";
|
|
234
|
+
}
|
|
235
|
+
async #onTriggerSlotChange(event) {
|
|
236
|
+
const slot = event.target;
|
|
237
|
+
const trigger = slot.assignedElements()[0];
|
|
238
|
+
// A Lit trigger renders its (possibly focusable) shadow content after it is slotted.
|
|
239
|
+
await trigger?.updateComplete;
|
|
240
|
+
if (trigger !== slot.assignedElements()[0])
|
|
241
|
+
return;
|
|
242
|
+
const target = trigger && containsFocusable(trigger) ? trigger : this;
|
|
243
|
+
this.#updateFocusability(target === this);
|
|
244
|
+
this.#describe(target);
|
|
245
|
+
}
|
|
246
|
+
#onContentSlotChange(event) {
|
|
247
|
+
const content = event.target.assignedElements()[0];
|
|
248
|
+
this.#content = content ?? null;
|
|
249
|
+
if (content && !content.id)
|
|
250
|
+
content.id = this.#contentId;
|
|
251
|
+
if (!content)
|
|
252
|
+
this.#setOpen(false);
|
|
253
|
+
this.#describe(this.#describedTarget);
|
|
254
|
+
}
|
|
255
|
+
/** Points the trigger's `aria-describedby` at the content, replacing this tooltip's previous reference. */
|
|
256
|
+
#describe(target) {
|
|
257
|
+
if (this.#describedTarget && this.#describedId) {
|
|
258
|
+
this.#setDescribedBy(this.#describedTarget, this.#describedIds(this.#describedTarget));
|
|
259
|
+
}
|
|
260
|
+
this.#describedTarget = target;
|
|
261
|
+
this.#describedId = this.#content?.id ?? null;
|
|
262
|
+
if (!target || !this.#describedId)
|
|
263
|
+
return;
|
|
264
|
+
this.#setDescribedBy(target, [...this.#describedIds(target), this.#describedId]);
|
|
265
|
+
}
|
|
266
|
+
/** The target's `aria-describedby` ids, minus the one this tooltip added. */
|
|
267
|
+
#describedIds(target) {
|
|
268
|
+
return (target.getAttribute("aria-describedby") ?? "")
|
|
269
|
+
.split(/\s+/)
|
|
270
|
+
.filter((value) => value && value !== this.#describedId);
|
|
271
|
+
}
|
|
272
|
+
#setDescribedBy(target, ids) {
|
|
273
|
+
if (ids.length)
|
|
274
|
+
target.setAttribute("aria-describedby", ids.join(" "));
|
|
275
|
+
else
|
|
276
|
+
target.removeAttribute("aria-describedby");
|
|
277
|
+
}
|
|
278
|
+
#updateFocusability(needed) {
|
|
279
|
+
if (needed && !this.hasAttribute("tabindex")) {
|
|
280
|
+
this.tabIndex = 0;
|
|
281
|
+
this.#madeFocusable = true;
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (!needed && this.#madeFocusable) {
|
|
285
|
+
this.removeAttribute("tabindex");
|
|
286
|
+
this.#madeFocusable = false;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
render() {
|
|
290
|
+
return html `
|
|
291
|
+
<slot @slotchange=${this.#onTriggerSlotChange}></slot>
|
|
292
|
+
<div class="tooltip" part="tooltip" role="tooltip" popover="manual">
|
|
293
|
+
<slot name="content" @slotchange=${this.#onContentSlotChange}></slot>
|
|
294
|
+
</div>
|
|
295
|
+
`;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
__decorate([
|
|
299
|
+
property({ reflect: true })
|
|
300
|
+
], UiTooltip.prototype, "placement", void 0);
|
|
301
|
+
__decorate([
|
|
302
|
+
property({ type: Number, attribute: "show-delay" })
|
|
303
|
+
], UiTooltip.prototype, "showDelay", void 0);
|
|
304
|
+
__decorate([
|
|
305
|
+
property({ type: Boolean, reflect: true })
|
|
306
|
+
], UiTooltip.prototype, "disabled", void 0);
|
|
307
|
+
__decorate([
|
|
308
|
+
state()
|
|
309
|
+
], UiTooltip.prototype, "_open", void 0);
|
|
310
|
+
__decorate([
|
|
311
|
+
query(".tooltip")
|
|
312
|
+
], UiTooltip.prototype, "_tooltip", void 0);
|
|
313
|
+
UiTooltip = __decorate([
|
|
314
|
+
customElement("ui-tooltip")
|
|
315
|
+
], UiTooltip);
|
|
316
|
+
export { UiTooltip };
|
|
317
|
+
//# sourceMappingURL=ui-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-tooltip.js","sourceRoot":"","sources":["../src/ui-tooltip.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,IAAI,aAAa,GAAG,CAAC,CAAC;AAKtB,sFAAsF;AACtF,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,kFAAkF;AAClF,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,SAAS,GACb,uKAAuK,CAAC;AAE1K,2FAA2F;AAC3F,SAAS,iBAAiB,CAAC,IAA0B;IACnD,IAAI,IAAI,YAAY,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IACpE,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/C,MAAM,KAAK,GAAG,IAAI,YAAY,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;IAChH,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,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,SAAS,EAAE,YAAY,EAAE,CAAC;4CAAiB;AAEzB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAkB;AAE5C;IAAhB,KAAK,EAAE;wCAAuB;AAEJ;IAA1B,KAAK,CAAC,UAAU,CAAC;2CAAgC;AAhEvC,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAwPrB","sourcesContent":["import { LitElement, css, html, type PropertyValues } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\nlet instanceCount = 0;\n\n/** Preferred side of the trigger; the tooltip flips when that side lacks room. */\nexport type UiTooltipPlacement = \"top\" | \"bottom\";\n\n/** Space kept between the trigger, the tooltip, and the viewport edges, in pixels. */\nconst GAP = 6;\nconst EDGE = 4;\n/** Grace period that lets the pointer cross from the trigger onto the tooltip. */\nconst HIDE_DELAY = 100;\n\nconst FOCUSABLE =\n \"a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [contenteditable], [tabindex]:not([tabindex='-1'])\";\n\n/** Whether `root` is or contains a focusable element, looking inside open shadow roots. */\nfunction containsFocusable(root: Element | ShadowRoot): boolean {\n if (root instanceof Element && root.matches(FOCUSABLE)) return true;\n if (root.querySelector(FOCUSABLE)) return true;\n const hosts = root instanceof Element ? [root, ...root.querySelectorAll(\"*\")] : [...root.querySelectorAll(\"*\")];\n return hosts.some((el) => el.shadowRoot !== null && containsFocusable(el.shadowRoot));\n}\n\n/**\n * Hover and focus tooltip for its default-slot trigger. The `content` slot\n * holds the tooltip body — plain text or rich markup such as a list. It\n * appears after `show-delay` on hover and at once on keyboard focus, stays\n * open while the pointer is over the tooltip itself, and closes on Escape,\n * blur, or when the pointer leaves. It renders in the top layer, so\n * scrolling or `overflow: hidden` ancestors never clip it.\n *\n * The trigger is described by the content (`aria-describedby`). A trigger\n * with nothing focusable inside (e.g. plain text) makes the tooltip host\n * focusable so keyboard users can reach the description too. ARIA references\n * can't cross shadow roots, so when the trigger is a custom element whose\n * focusable control lives in its own shadow root, screen readers won't\n * announce the description on focus; prefer a native trigger such as\n * `<button>` when that matters.\n *\n * @element ui-tooltip\n * @slot - The trigger the tooltip describes.\n * @slot content - The tooltip body.\n * @csspart tooltip - The floating tooltip surface.\n */\n@customElement(\"ui-tooltip\")\nexport class UiTooltip extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\n }\n :host(:focus-visible) {\n outline: none;\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .tooltip {\n position: fixed;\n inset: auto;\n margin: 0;\n box-sizing: border-box;\n max-width: min(20rem, calc(100vw - 0.5rem));\n padding: 0.25rem 0.5rem;\n border: 0;\n border-radius: var(--ui-radius-sm, 0.25rem);\n background: var(--ui-tooltip, #0f172a);\n color: var(--ui-tooltip-text, #ffffff);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-tight, 1.25);\n text-align: start;\n overflow-wrap: anywhere;\n }\n @media (forced-colors: active) {\n :host(:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .tooltip {\n border: 1px solid CanvasText;\n background: Canvas;\n color: CanvasText;\n }\n }\n `,\n ];\n\n /** Preferred side of the trigger; flips to the other side when this one lacks room. */\n @property({ reflect: true }) placement: UiTooltipPlacement = \"top\";\n /** Hover delay in milliseconds before the tooltip appears; keyboard focus shows it at once. */\n @property({ type: Number, attribute: \"show-delay\" }) showDelay = 300;\n /** Suppresses the tooltip and closes it if open. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n @state() private _open = false;\n\n @query(\".tooltip\") private _tooltip!: HTMLElement;\n\n #showTimer: ReturnType<typeof setTimeout> | null = null;\n #hideTimer: ReturnType<typeof setTimeout> | null = null;\n #describedTarget: HTMLElement | null = null;\n #describedId: string | null = null;\n #content: HTMLElement | null = null;\n #madeFocusable = false;\n readonly #contentId = `ui-tooltip-content-${++instanceCount}`;\n\n constructor() {\n super();\n this.addEventListener(\"pointerenter\", () => this.#scheduleShow(this.showDelay));\n this.addEventListener(\"pointerleave\", () => this.#scheduleHide(HIDE_DELAY, \":focus-within\"));\n this.addEventListener(\"focusin\", () => this.#scheduleShow(0));\n this.addEventListener(\"focusout\", () => this.#scheduleHide(0, \":hover\"));\n }\n\n /** Whether the tooltip is currently showing. */\n get open(): boolean {\n return this._open;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#clearTimers();\n this.#setOpen(false);\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has(\"disabled\") && this.disabled) {\n this.#clearTimers();\n this.#setOpen(false);\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n if (!changed.has(\"_open\")) return;\n if (this._open) {\n this._tooltip.showPopover();\n this.#position();\n return;\n }\n if (this._tooltip.matches(\":popover-open\")) this._tooltip.hidePopover();\n }\n\n #scheduleShow(delay: number): void {\n if (this.disabled || !this.#content) return;\n this.#clearTimers();\n if (this._open) return;\n if (delay <= 0) {\n this.#setOpen(true);\n return;\n }\n this.#showTimer = setTimeout(() => this.#setOpen(true), delay);\n }\n\n /** Hides after `delay` unless the host still matches `keepOpenWhile` (still hovered or focused). */\n #scheduleHide(delay: number, keepOpenWhile: string): void {\n this.#clearTimers();\n if (!this._open) return;\n const hide = () => {\n if (!this.matches(keepOpenWhile)) this.#setOpen(false);\n };\n if (delay <= 0) {\n hide();\n return;\n }\n this.#hideTimer = setTimeout(hide, delay);\n }\n\n #clearTimers(): void {\n if (this.#showTimer) clearTimeout(this.#showTimer);\n if (this.#hideTimer) clearTimeout(this.#hideTimer);\n this.#showTimer = null;\n this.#hideTimer = null;\n }\n\n #setOpen(open: boolean): void {\n if (this._open === open) return;\n this._open = open;\n if (open) {\n document.addEventListener(\"keydown\", this.#onDocumentKeydown, true);\n window.addEventListener(\"scroll\", this.#onViewportChange, true);\n window.addEventListener(\"resize\", this.#onViewportChange);\n return;\n }\n document.removeEventListener(\"keydown\", this.#onDocumentKeydown, true);\n window.removeEventListener(\"scroll\", this.#onViewportChange, true);\n window.removeEventListener(\"resize\", this.#onViewportChange);\n }\n\n /** Escape closes the tooltip without dismissing anything else (WCAG 1.4.13). */\n #onDocumentKeydown = (event: KeyboardEvent): void => {\n if (event.key !== \"Escape\" || !this._open) return;\n event.preventDefault();\n event.stopPropagation();\n this.#clearTimers();\n this.#setOpen(false);\n };\n\n #onViewportChange = (): void => {\n if (this._open) this.#position();\n };\n\n /** Places the tooltip beside the host, flipping sides and clamping it inside the viewport. */\n #position(): void {\n const anchor = this.getBoundingClientRect();\n const tip = this._tooltip.getBoundingClientRect();\n const above = anchor.top - GAP - tip.height;\n const below = anchor.bottom + GAP;\n const fitsAbove = above >= EDGE;\n const fitsBelow = below + tip.height <= window.innerHeight - EDGE;\n const top =\n this.placement === \"top\" ? (fitsAbove || !fitsBelow ? above : below) : fitsBelow || !fitsAbove ? below : above;\n const centered = anchor.left + anchor.width / 2 - tip.width / 2;\n const left = Math.min(Math.max(centered, EDGE), Math.max(EDGE, window.innerWidth - EDGE - tip.width));\n this._tooltip.style.top = `${Math.round(top)}px`;\n this._tooltip.style.left = `${Math.round(left)}px`;\n this._tooltip.dataset.side = top === above ? \"top\" : \"bottom\";\n }\n\n async #onTriggerSlotChange(event: Event): Promise<void> {\n const slot = event.target as HTMLSlotElement;\n const trigger = slot.assignedElements()[0] as (HTMLElement & { updateComplete?: Promise<unknown> }) | undefined;\n // A Lit trigger renders its (possibly focusable) shadow content after it is slotted.\n await trigger?.updateComplete;\n if (trigger !== slot.assignedElements()[0]) return;\n const target = trigger && containsFocusable(trigger) ? trigger : this;\n this.#updateFocusability(target === this);\n this.#describe(target);\n }\n\n #onContentSlotChange(event: Event): void {\n const content = (event.target as HTMLSlotElement).assignedElements()[0] as HTMLElement | undefined;\n this.#content = content ?? null;\n if (content && !content.id) content.id = this.#contentId;\n if (!content) this.#setOpen(false);\n this.#describe(this.#describedTarget);\n }\n\n /** Points the trigger's `aria-describedby` at the content, replacing this tooltip's previous reference. */\n #describe(target: HTMLElement | null): void {\n if (this.#describedTarget && this.#describedId) {\n this.#setDescribedBy(this.#describedTarget, this.#describedIds(this.#describedTarget));\n }\n this.#describedTarget = target;\n this.#describedId = this.#content?.id ?? null;\n if (!target || !this.#describedId) return;\n this.#setDescribedBy(target, [...this.#describedIds(target), this.#describedId]);\n }\n\n /** The target's `aria-describedby` ids, minus the one this tooltip added. */\n #describedIds(target: HTMLElement): string[] {\n return (target.getAttribute(\"aria-describedby\") ?? \"\")\n .split(/\\s+/)\n .filter((value) => value && value !== this.#describedId);\n }\n\n #setDescribedBy(target: HTMLElement, ids: string[]): void {\n if (ids.length) target.setAttribute(\"aria-describedby\", ids.join(\" \"));\n else target.removeAttribute(\"aria-describedby\");\n }\n\n #updateFocusability(needed: boolean): void {\n if (needed && !this.hasAttribute(\"tabindex\")) {\n this.tabIndex = 0;\n this.#madeFocusable = true;\n return;\n }\n if (!needed && this.#madeFocusable) {\n this.removeAttribute(\"tabindex\");\n this.#madeFocusable = false;\n }\n }\n\n override render() {\n return html`\n <slot @slotchange=${this.#onTriggerSlotChange}></slot>\n <div class=\"tooltip\" part=\"tooltip\" role=\"tooltip\" popover=\"manual\">\n <slot name=\"content\" @slotchange=${this.#onContentSlotChange}></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"ui-tooltip\": UiTooltip;\n }\n}\n"]}
|