@k2b/ui 0.38.0 → 0.39.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/Dropdown.js +42 -6
- package/dist/browser/actions/Dropdown.js.map +1 -1
- package/dist/browser/actions/SelectionToolbar.js +11 -6
- package/dist/browser/actions/SelectionToolbar.js.map +1 -1
- package/dist/browser/actions/Toolbar.js +5 -1
- package/dist/browser/actions/Toolbar.js.map +1 -1
- package/dist/browser/actions/index.js.map +1 -1
- package/dist/browser/chat/ChatComposer.js +11 -2
- package/dist/browser/chat/ChatComposer.js.map +1 -1
- package/dist/browser/text-editor/TextEditor.js +331 -214
- package/dist/browser/text-editor/TextEditor.js.map +1 -1
- package/dist/browser/text-editor/table.js +43 -6
- package/dist/browser/text-editor/table.js.map +1 -1
- package/dist/ssr/actions/Dropdown.js +38 -6
- package/dist/ssr/actions/Dropdown.js.map +1 -1
- package/dist/ssr/actions/SelectionToolbar.js +11 -6
- package/dist/ssr/actions/SelectionToolbar.js.map +1 -1
- package/dist/ssr/actions/Toolbar.js +5 -1
- package/dist/ssr/actions/Toolbar.js.map +1 -1
- package/dist/ssr/actions/index.js.map +1 -1
- package/dist/ssr/chat/ChatComposer.js +10 -2
- package/dist/ssr/chat/ChatComposer.js.map +1 -1
- package/dist/ssr/text-editor/TextEditor.js +225 -96
- package/dist/ssr/text-editor/TextEditor.js.map +1 -1
- package/dist/ssr/text-editor/table.js +43 -6
- package/dist/ssr/text-editor/table.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/actions/Dropdown.d.ts +15 -1
- package/dist/types/actions/Toolbar.d.ts +6 -1
- package/dist/types/actions/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -49,6 +49,10 @@ const closeOnSelectOf = item => "closeOnSelect" in item ? item.closeOnSelect : u
|
|
|
49
49
|
const hrefOf = item => "href" in item ? item.href : undefined;
|
|
50
50
|
const externalOf = item => "external" in item ? item.external : undefined;
|
|
51
51
|
|
|
52
|
+
/** Where a menu opened without its trigger appears: an element, or any box such as a point inside one. */
|
|
53
|
+
|
|
54
|
+
/** Where focus returns as a menu opened by `openAt` closes, read at that moment when it is a function. */
|
|
55
|
+
|
|
52
56
|
/** A second, smaller action at the end of a row, such as "Only" beside a checkbox; it keeps the menu open. */
|
|
53
57
|
|
|
54
58
|
/** Declarative radio or checkbox row for compact action menus. */
|
|
@@ -660,6 +664,10 @@ function DropdownRoot(props) {
|
|
|
660
664
|
const [internalOpen, setInternalOpen] = createSignal(false);
|
|
661
665
|
const [entriesShown, setEntriesShown] = createSignal(!props.lazy);
|
|
662
666
|
let triggerRef;
|
|
667
|
+
/** Set while the menu is open from `openAt`: it appears beside `anchor`, and focus returns to `origin`. */
|
|
668
|
+
let anchor;
|
|
669
|
+
let origin;
|
|
670
|
+
const originElement = () => typeof origin === "function" ? origin() : origin;
|
|
663
671
|
let menuRef;
|
|
664
672
|
let triggerRing = true;
|
|
665
673
|
let mounted = false;
|
|
@@ -670,8 +678,9 @@ function DropdownRoot(props) {
|
|
|
670
678
|
const isOpen = () => props.open ?? internalOpen();
|
|
671
679
|
const position = () => typeof props.position === "function" ? props.position() : props.position ?? (props.align === "end" ? "bottom-left" : "bottom-right");
|
|
672
680
|
const place = () => {
|
|
673
|
-
|
|
674
|
-
|
|
681
|
+
const at = anchor ?? triggerRef;
|
|
682
|
+
if (!at || !menuRef) return;
|
|
683
|
+
const rect = dropdownPosition(at.getBoundingClientRect(), menuRef.getBoundingClientRect(), position(), {
|
|
675
684
|
width: window.innerWidth,
|
|
676
685
|
height: window.innerHeight
|
|
677
686
|
});
|
|
@@ -701,7 +710,7 @@ function DropdownRoot(props) {
|
|
|
701
710
|
};
|
|
702
711
|
const close = (restoreFocus = true) => {
|
|
703
712
|
// Before hiding, so the popover does not return focus on its own.
|
|
704
|
-
if (restoreFocus) returnFocus(triggerRef, triggerRing);
|
|
713
|
+
if (restoreFocus) returnFocus(originElement() ?? triggerRef, triggerRing);
|
|
705
714
|
if (menuRef?.matches(":popover-open")) menuRef.hidePopover();
|
|
706
715
|
// Like `open`, expose the closed state now: the toggle event can arrive after the next key press, and a trigger
|
|
707
716
|
// that still reads as open would ignore Enter (Escape, then Enter at once, must reopen).
|
|
@@ -710,7 +719,7 @@ function DropdownRoot(props) {
|
|
|
710
719
|
};
|
|
711
720
|
const open = (focus = "first") => {
|
|
712
721
|
if (props.disabled || !menuRef || menuRef.matches(":popover-open")) return;
|
|
713
|
-
triggerRing = ringOnReturn(triggerRef);
|
|
722
|
+
triggerRing = ringOnReturn(originElement() ?? triggerRef);
|
|
714
723
|
// A lazy menu's entries exist before it shows, so it places and focuses them as any other.
|
|
715
724
|
setEntriesShown(true);
|
|
716
725
|
menuRef.showPopover();
|
|
@@ -732,6 +741,11 @@ function DropdownRoot(props) {
|
|
|
732
741
|
if (sheet) return;
|
|
733
742
|
const current = new AbortController();
|
|
734
743
|
sheet = current;
|
|
744
|
+
// A sheet opened without its trigger returns focus to its own target, which an entry may have moved,
|
|
745
|
+
// rather than to whatever had focus as it opened.
|
|
746
|
+
const anchored = origin !== undefined;
|
|
747
|
+
const ring = anchored && ringOnReturn(originElement());
|
|
748
|
+
if (anchored && document.activeElement instanceof HTMLElement) document.activeElement.blur();
|
|
735
749
|
// The sheet is this menu's open state: the trigger reports it and the owner hears both ends.
|
|
736
750
|
setInternalOpen(true);
|
|
737
751
|
props.onOpenChange?.(true);
|
|
@@ -744,6 +758,10 @@ function DropdownRoot(props) {
|
|
|
744
758
|
signal: current.signal
|
|
745
759
|
}).finally(() => {
|
|
746
760
|
sheet = undefined;
|
|
761
|
+
// An entry that moved focus elsewhere, such as into a field, keeps it.
|
|
762
|
+
const target = anchored ? originElement() : undefined;
|
|
763
|
+
const focused = document.activeElement;
|
|
764
|
+
if (target?.isConnected && (!focused || focused === document.body)) returnFocus(target, ring);
|
|
747
765
|
setInternalOpen(false);
|
|
748
766
|
props.onOpenChange?.(false);
|
|
749
767
|
props.onClose?.();
|
|
@@ -758,7 +776,7 @@ function DropdownRoot(props) {
|
|
|
758
776
|
event.preventDefault();
|
|
759
777
|
} else if (event.key === "Escape") {
|
|
760
778
|
event.preventDefault();
|
|
761
|
-
returnFocus(triggerRef, triggerRing);
|
|
779
|
+
returnFocus(originElement() ?? triggerRef, triggerRing);
|
|
762
780
|
requestOpen(false);
|
|
763
781
|
} else if (event.key === "Tab") {
|
|
764
782
|
requestOpen(false);
|
|
@@ -771,7 +789,10 @@ function DropdownRoot(props) {
|
|
|
771
789
|
registerTrigger: element => {
|
|
772
790
|
triggerRef = element;
|
|
773
791
|
},
|
|
774
|
-
toggle: () =>
|
|
792
|
+
toggle: () => {
|
|
793
|
+
if (!isOpen()) anchor = origin = undefined;
|
|
794
|
+
requestOpen(!isOpen());
|
|
795
|
+
},
|
|
775
796
|
triggerKeyDown: event => {
|
|
776
797
|
if (!["Enter", " ", "ArrowDown", "ArrowUp"].includes(event.key)) return;
|
|
777
798
|
event.preventDefault();
|
|
@@ -780,6 +801,7 @@ function DropdownRoot(props) {
|
|
|
780
801
|
focusMenuItem(menuRef, event.key === "ArrowUp" ? -1 : 0);
|
|
781
802
|
return;
|
|
782
803
|
}
|
|
804
|
+
anchor = origin = undefined;
|
|
783
805
|
keyFocus = event.key === "ArrowUp" ? "last" : "first";
|
|
784
806
|
requestOpen(true, keyFocus);
|
|
785
807
|
keyFocus = false;
|
|
@@ -796,6 +818,16 @@ function DropdownRoot(props) {
|
|
|
796
818
|
sheet?.abort();
|
|
797
819
|
if (mounted) close(false);
|
|
798
820
|
});
|
|
821
|
+
props.openAt?.((at, focus) => {
|
|
822
|
+
if (isOpen()) return;
|
|
823
|
+
anchor = at;
|
|
824
|
+
origin = focus;
|
|
825
|
+
requestOpen(true);
|
|
826
|
+
});
|
|
827
|
+
props.closeWith?.(() => {
|
|
828
|
+
sheet?.abort();
|
|
829
|
+
if (isOpen()) close();
|
|
830
|
+
});
|
|
799
831
|
onMount(() => {
|
|
800
832
|
mounted = true;
|
|
801
833
|
if (props.open) open(false);
|
|
@@ -817,6 +849,10 @@ function DropdownRoot(props) {
|
|
|
817
849
|
if (nextOpen) setEntriesShown(true);
|
|
818
850
|
if (nextOpen) attachViewportListeners();else detachViewportListeners();
|
|
819
851
|
if (props.open === undefined || props.open !== nextOpen) props.onOpenChange?.(nextOpen);
|
|
852
|
+
// A light dismiss hides the menu with focus inside it; an opener without a trigger takes it back.
|
|
853
|
+
const focused = document.activeElement;
|
|
854
|
+
const target = wasOpen && !nextOpen ? originElement() : undefined;
|
|
855
|
+
if (target?.isConnected && (!focused || focused === document.body || menuRef?.contains(focused))) returnFocus(target, triggerRing);
|
|
820
856
|
if (wasOpen && !nextOpen) props.onClose?.();
|
|
821
857
|
if (!nextOpen && props.open === true) queueMicrotask(() => props.open === true && open(false));
|
|
822
858
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["actions/Dropdown.tsx"],"sourcesContent":["import {\n createContext,\n createEffect,\n createSignal,\n createUniqueId,\n For,\n type JSX,\n mergeProps,\n onCleanup,\n onMount,\n Show,\n splitProps,\n untrack,\n useContext,\n} from \"solid-js\";\nimport { Dynamic } from \"solid-js/web\";\nimport { Tooltip, type TooltipPlacement, useLabelTooltip } from \"../feedback/Tooltip\";\nimport { returnFocus, ringOnReturn } from \"../internal/focus-return\";\nimport { KeyedFor } from \"../internal/keyed-for\";\nimport { useLocale } from \"../intl/locale\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { Button, type ButtonProps, type ButtonSize, type ButtonVariant, iconTitle } from \"./Button\";\nimport { focusMenuRow, focusRowSegment } from \"./menu-rows\";\nimport { openMenuSheet, prefersMenuSheet } from \"./menu-sheet\";\n\n// Resolved outside JSX: a conditional attribute compiles to a lazy memo, which would be created inside the click handler.\nconst selectAction = (item: { action?: () => void }) => item.action;\nconst closeOnSelectOf = (item: DropdownAction) => (\"closeOnSelect\" in item ? item.closeOnSelect : undefined);\nconst hrefOf = (item: DropdownAction) => (\"href\" in item ? item.href : undefined);\nconst externalOf = (item: DropdownAction) => (\"external\" in item ? item.external : undefined);\n\nexport type DropdownPosition = \"bottom-right\" | \"bottom-left\" | \"top-right\" | \"top-left\" | \"right-start\";\n\nexport type DropdownActionBase = {\n class?: string;\n disabled?: boolean;\n icon?: string;\n image?: string;\n label: string;\n /**\n * Accessible name when it must say more than the visible label, such as the current value and what the next\n * activation does. It must contain the visible label.\n */\n ariaLabel?: string;\n description?: string;\n /** Quiet trailing information, such as a count. */\n trailing?: JSX.Element;\n variant?: \"danger\";\n};\n\nexport type DropdownAction =\n | (DropdownActionBase & {\n action: () => void;\n /**\n * Set `false` for an action that changes a value in place, such as cycling a setting: the menu stays open and\n * the focus stays on the row. Defaults to `true`.\n */\n closeOnSelect?: boolean;\n /**\n * In a phone sheet, run while the tap still counts as the person's gesture, before the sheet closes, as browsers\n * require for clipboard writes. Other actions run after the sheet has left the history. Such an action must\n * not navigate or open a dialog.\n */\n immediate?: boolean;\n href?: never;\n external?: never;\n })\n | (DropdownActionBase & {\n href: string;\n external?: boolean;\n /** Runs on a plain click instead of following the link; modified clicks, middle-click, and the link's menu keep it. */\n action?: () => void;\n })\n | (DropdownActionBase & {\n disabled: true;\n action?: never;\n href?: never;\n external?: never;\n });\n\n/** A second, smaller action at the end of a row, such as \"Only\" beside a checkbox; it keeps the menu open. */\nexport type DropdownSecondaryAction = {\n label: string;\n /** Accessible name when the visible label alone does not say what it acts on, such as \"Only Team Logistik\". */\n ariaLabel?: string;\n action: () => void;\n};\n\n/** Declarative radio or checkbox row for compact action menus. */\nexport type DropdownChoice = DropdownActionBase & {\n action: () => void;\n checked: boolean | (() => boolean);\n choice: \"checkbox\" | \"radio\";\n href?: string;\n closeOnSelect?: boolean;\n color?: string;\n /**\n * A second action at the end of the row. It shows while the row is hovered or focused, always on a touch screen,\n * and keeps its place when hidden, so the row never changes width. Right and Left move between the two.\n */\n secondary?: DropdownSecondaryAction;\n};\n\nexport type DropdownSection = {\n sectionLabel?: string;\n /**\n * `row` sets a few short radio choices, such as a sort direction, side by side as one segmented row. Give it a\n * `sectionLabel`: the label names the choice above the row and for screen readers.\n */\n layout?: \"row\";\n /** A quiet action at the end of the section label, such as \"All\"; it needs a `sectionLabel` and keeps the menu open. */\n labelAction?: DropdownSecondaryAction;\n items: readonly (DropdownAction | DropdownChoice)[];\n};\n\nexport type DropdownItem = DropdownAction | DropdownChoice | DropdownSection;\n\nexport type DropdownProps = {\n items: readonly DropdownItem[];\n children: JSX.Element;\n position?: DropdownPosition | (() => DropdownPosition);\n /** Larger menu rows and typography for touch. Defaults to `default`. */\n variant?: \"default\" | \"touch\";\n /**\n * Exact menu width as a CSS length. Without it the menu sizes to its longest\n * entry: at least `12rem` (`18rem` for touch), at most the viewport width\n * less `1rem` per side, where longer entries wrap.\n */\n width?: string;\n class?: string;\n menuClass?: string;\n onClose?: () => void;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n disabled?: boolean;\n label?: string;\n align?: \"start\" | \"end\";\n /**\n * `sheet` opens the same items as a bottom sheet on phones (below 48rem) instead of a menu beside the trigger.\n * Defaults to `menu`. A controlled menu (`open`) always stays a menu.\n */\n phone?: \"menu\" | \"sheet\";\n /** Content above the phone sheet's menu. `close` dismisses it with normal history and focus restoration. */\n sheetTop?: (close: () => void) => JSX.Element;\n /**\n * Renders the entries only once the menu first opens, for a menu repeated on every row of a long list: the page\n * then carries each row's trigger, not each row's entries. Fixed for the menu's lifetime.\n */\n lazy?: boolean;\n};\n\nexport type DropdownTriggerProps = Omit<\n ButtonProps,\n \"aria-controls\" | \"aria-expanded\" | \"aria-haspopup\" | \"children\" | \"disabled\" | \"onClick\" | \"onKeyDown\"\n> & {\n children: JSX.Element;\n /** Use `plain` when a specialized component class owns the complete visual treatment. */\n appearance?: \"button\" | \"plain\";\n disabled?: boolean;\n iconOnly?: boolean;\n label?: string;\n size?: ButtonSize;\n tooltip?: JSX.Element | false;\n tooltipDelay?: number;\n tooltipPlacement?: TooltipPlacement;\n variant?: ButtonVariant;\n};\n\nexport type DropdownItemProps = {\n children: JSX.Element;\n closeOnSelect?: boolean;\n ariaLabel?: string;\n icon?: string;\n image?: string;\n description?: string;\n /** Quiet trailing information, such as a count. */\n trailing?: JSX.Element;\n disabled?: boolean;\n danger?: boolean;\n variant?: \"danger\";\n href?: string;\n external?: boolean;\n /** Runs when the item is chosen. With `href`, a plain click runs it instead of following the link. */\n onSelect?: () => void;\n class?: string;\n};\n\ntype MenuContextValue = {\n close: (restoreFocus?: boolean) => void;\n};\n\ntype DropdownContextValue = {\n disabled: () => boolean;\n menuId: string;\n open: () => boolean;\n registerTrigger: (element: HTMLButtonElement) => void;\n toggle: () => void;\n triggerKeyDown: JSX.EventHandlerUnion<HTMLButtonElement, KeyboardEvent>;\n};\n\nconst MenuContext = createContext<MenuContextValue>();\nconst DropdownContext = createContext<DropdownContextValue>();\n\nconst actionableItems = (menu: HTMLElement | undefined): HTMLElement[] =>\n menu\n ? Array.from(\n menu.querySelectorAll<HTMLElement>(\n [\n \"[role='menuitem']:not([aria-disabled='true'])\",\n \"[role='menuitemcheckbox']:not([aria-disabled='true'])\",\n \"[role='menuitemradio']:not([aria-disabled='true'])\",\n ].join(\", \"),\n ),\n )\n : [];\n\nconst focusMenuItem = (menu: HTMLElement | undefined, index: number): void => {\n const items = actionableItems(menu).filter((item) => !item.classList.contains(\"k2b-dropdown__secondary\"));\n if (items.length === 0) return;\n items[(index + items.length) % items.length]?.focus();\n};\n\nexport const dropdownPosition = (\n trigger: DOMRect,\n menu: Pick<DOMRect, \"width\" | \"height\">,\n position: DropdownPosition,\n viewport: { width: number; height: number },\n gap = 4,\n): { left: number; top: number } => {\n let left = trigger.left;\n let top = trigger.bottom + gap;\n\n if (position === \"bottom-left\" || position === \"top-left\") left = trigger.right - menu.width;\n if (position === \"top-right\" || position === \"top-left\") top = trigger.top - menu.height - gap;\n if (position === \"right-start\") {\n left = trigger.right + gap;\n top = trigger.top;\n }\n\n return {\n left: Math.max(8, Math.min(left, viewport.width - menu.width - 8)),\n top: Math.max(8, Math.min(top, viewport.height - menu.height - 8)),\n };\n};\n\nconst itemContent = (props: {\n description?: string;\n icon?: string;\n image?: string;\n trailing?: JSX.Element;\n children: JSX.Element;\n}): JSX.Element => (\n <>\n <Show when={props.image} fallback={<Show when={props.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>}>\n {(image) => <img class=\"k2b-dropdown__image\" src={image()} alt=\"\" />}\n </Show>\n <span class=\"k2b-dropdown__copy\">\n <span>{props.children}</span>\n <Show when={props.description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n {props.trailing}\n </>\n);\n\nexport function DropdownItem(props: DropdownItemProps): JSX.Element {\n const menu = useContext(MenuContext);\n const danger = () => props.danger || props.variant === \"danger\";\n const content = itemContent(props);\n\n return (\n <Show\n when={!props.disabled ? props.href : undefined}\n fallback={\n <button\n type=\"button\"\n role=\"menuitem\"\n aria-label={props.ariaLabel}\n tabIndex={-1}\n class={`k2b-dropdown__item ${props.class ?? \"\"}`}\n data-danger={danger() ? \"true\" : undefined}\n disabled={props.disabled}\n aria-disabled={props.disabled ? \"true\" : undefined}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n if (props.closeOnSelect !== false) menu?.close();\n props.onSelect?.();\n }}\n >\n {content}\n </button>\n }\n >\n {(href) => (\n <a\n href={href()}\n target={props.external ? \"_blank\" : undefined}\n rel={props.external ? \"noopener noreferrer\" : undefined}\n role=\"menuitem\"\n aria-label={props.ariaLabel}\n tabIndex={-1}\n class={`k2b-dropdown__item ${props.class ?? \"\"}`}\n data-danger={danger() ? \"true\" : undefined}\n onClick={(event) => {\n // With `onSelect`, a plain click runs it in place of the link; a modified click keeps its browser meaning.\n if (props.onSelect && !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {\n event.preventDefault();\n menu?.close();\n props.onSelect();\n return;\n }\n menu?.close(false);\n }}\n >\n {content}\n </a>\n )}\n </Show>\n );\n}\n\nfunction DropdownChoiceItem(props: DropdownChoice): JSX.Element {\n return (\n <Show when={props.secondary} fallback={<DropdownChoiceRow {...props} />}>\n {(secondary) => (\n <div class=\"k2b-dropdown__pair\">\n <DropdownChoiceRow {...props} />\n <DropdownSecondaryButton {...secondary()} class=\"k2b-dropdown__secondary\" />\n </div>\n )}\n </Show>\n );\n}\n\nfunction DropdownSecondaryButton(props: DropdownSecondaryAction & { class: string }): JSX.Element {\n return (\n <button\n type=\"button\"\n role=\"menuitem\"\n tabIndex={-1}\n class={props.class}\n aria-label={props.ariaLabel}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n props.action();\n }}\n >\n {props.label}\n </button>\n );\n}\n\nfunction DropdownChoiceRow(props: DropdownChoice): JSX.Element {\n const menu = useContext(MenuContext);\n const checked = () => (typeof props.checked === \"function\" ? props.checked() : props.checked);\n let element: HTMLElement | undefined;\n return (\n <Dynamic\n ref={(node: HTMLAnchorElement | HTMLButtonElement) => {\n element = node;\n }}\n component={!props.disabled && props.href ? \"a\" : \"button\"}\n href={!props.disabled ? props.href : undefined}\n type={!props.disabled && props.href ? undefined : \"button\"}\n role={props.choice === \"checkbox\" ? \"menuitemcheckbox\" : \"menuitemradio\"}\n aria-label={props.ariaLabel}\n aria-checked={checked()}\n aria-disabled={props.disabled ? \"true\" : undefined}\n tabIndex={-1}\n class={`k2b-dropdown__item ${props.class ?? \"\"}`}\n data-selected={checked() ? \"true\" : undefined}\n disabled={props.disabled}\n onClick={(event: MouseEvent) => {\n if (props.href && (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {\n menu?.close(false);\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n if (props.closeOnSelect !== false) menu?.close();\n props.action();\n }}\n onKeyDown={(event: KeyboardEvent) => {\n // A link answers only Enter; as a menu choice it also answers Space, like the button form.\n if (event.key !== \" \" || props.disabled || !props.href) return;\n event.preventDefault();\n element?.click();\n }}\n >\n <Show when={props.choice === \"checkbox\"}>\n <span class=\"k2b-dropdown__checkbox\" aria-hidden=\"true\">\n <Show when={checked()}>\n <i class=\"ti ti-check\" />\n </Show>\n </span>\n </Show>\n <Show when={props.image} fallback={<Show when={props.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>}>\n {(image) => <img class=\"k2b-dropdown__image\" src={image()} alt=\"\" />}\n </Show>\n <Show when={props.color}>\n {(color) => <span class=\"k2b-dropdown__color\" style={{ \"--k2b-dropdown-color\": color() }} aria-hidden=\"true\" />}\n </Show>\n <span class=\"k2b-dropdown__copy\">\n <span>{props.label}</span>\n <Show when={props.description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n {props.trailing}\n {/* Always present for radios, so selecting the widest entry cannot widen a content-sized menu. */}\n <Show when={props.choice === \"radio\"}>\n <i class=\"ti ti-check k2b-dropdown__check\" data-hidden={checked() ? undefined : \"true\"} aria-hidden=\"true\" />\n </Show>\n </Dynamic>\n );\n}\n\nexport function DropdownItems(props: { items: readonly DropdownItem[]; close: (restoreFocus?: boolean) => void }): JSX.Element {\n const messages = useUiMessages();\n // Rows read their current item: a host that rebuilds equal items while the menu is open keeps each row element (#2140).\n const renderItem = (item: () => DropdownAction | DropdownChoice): JSX.Element => {\n const initial = untrack(item);\n if (\"choice\" in initial) return <DropdownChoiceItem {...mergeProps(() => item() as DropdownChoice)} />;\n const action = () => item() as DropdownAction;\n return (\n <DropdownItem\n ariaLabel={action().ariaLabel}\n closeOnSelect={closeOnSelectOf(action())}\n icon={action().icon}\n image={action().image}\n description={action().description}\n trailing={action().trailing}\n variant={action().variant}\n disabled={action().disabled}\n class={action().class}\n href={hrefOf(action())}\n external={externalOf(action())}\n onSelect={selectAction(action())}\n >\n {action().label}\n </DropdownItem>\n );\n };\n\n return (\n <MenuContext.Provider value={{ close: props.close }}>\n <KeyedFor each={props.items} by={(item) => (\"items\" in item ? `section:${item.sectionLabel ?? \"\"}` : `item:${item.label}`)}>\n {(current, index) => {\n const item = current();\n return (\n <Show when={\"items\" in item} fallback={renderItem(current as () => DropdownAction | DropdownChoice)}>\n <div\n class=\"k2b-dropdown__section\"\n data-divided={index() > 0 ? \"true\" : undefined}\n role=\"group\"\n // A row of choices is no set of actions: without a label it stays unnamed rather than misnamed.\n aria-label={\n (current() as DropdownSection).sectionLabel ??\n ((current() as DropdownSection).layout === \"row\" ? undefined : messages().actions)\n }\n >\n <Show when={(current() as DropdownSection).sectionLabel}>\n {(label) => (\n <Show when={(current() as DropdownSection).labelAction} fallback={<div class=\"k2b-dropdown__label\">{label()}</div>}>\n {(action) => (\n <div class=\"k2b-dropdown__label k2b-dropdown__label--action\">\n <span>{label()}</span>\n <DropdownSecondaryButton {...action()} class=\"k2b-dropdown__label-action\" />\n </div>\n )}\n </Show>\n )}\n </Show>\n <Show\n when={(current() as DropdownSection).layout === \"row\"}\n fallback={\n <KeyedFor each={(current() as DropdownSection).items} by={(row) => row.label}>\n {renderItem}\n </KeyedFor>\n }\n >\n <div class=\"k2b-dropdown__row\">\n <KeyedFor each={(current() as DropdownSection).items} by={(row) => row.label}>\n {renderItem}\n </KeyedFor>\n </div>\n </Show>\n </div>\n </Show>\n );\n }}\n </KeyedFor>\n </MenuContext.Provider>\n );\n}\n\nfunction DropdownTrigger(props: DropdownTriggerProps): JSX.Element {\n const context = useContext(DropdownContext);\n if (!context) throw new Error(\"Dropdown.Trigger must be used inside Dropdown.Root\");\n const [local, rest] = splitProps(props, [\n \"appearance\",\n \"children\",\n \"class\",\n \"disabled\",\n \"iconOnly\",\n \"label\",\n \"ref\",\n \"size\",\n \"tabIndex\",\n \"title\",\n \"tooltip\",\n \"tooltipDelay\",\n \"tooltipPlacement\",\n \"type\",\n \"variant\",\n ]);\n let target: HTMLButtonElement | undefined;\n const disabled = () => Boolean(context.disabled() || local.disabled);\n // An icon-only trigger shows its label as a hint, like IconButton.\n const tooltip = useLabelTooltip(\n () => local.tooltip,\n () => (local.iconOnly ? (local.title ?? local.label) : undefined),\n );\n const register = (element: HTMLButtonElement) => {\n target = element;\n context.registerTrigger(element);\n if (typeof local.ref === \"function\") local.ref(element);\n };\n const click: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> = (event) => {\n event.stopPropagation();\n context.toggle();\n };\n\n if (local.appearance !== \"plain\") {\n return (\n <Button\n {...rest}\n ref={register}\n aria-controls={context.menuId}\n aria-expanded={context.open()}\n aria-haspopup=\"menu\"\n aria-label={local.label}\n disabled={disabled()}\n tabIndex={disabled() ? -1 : local.tabIndex}\n onClick={click}\n onKeyDown={context.triggerKeyDown}\n type={local.type ?? \"button\"}\n class={`${local.iconOnly ? \"k2b-icon-button\" : \"\"} k2b-dropdown__trigger ${local.class ?? \"\"}`}\n size={local.size}\n variant={local.variant ?? (local.iconOnly ? \"ghost\" : undefined)}\n title={iconTitle(local.title, tooltip())}\n tooltip={tooltip()}\n tooltipDelay={local.tooltipDelay}\n tooltipPlacement={local.tooltipPlacement}\n >\n {local.children}\n </Button>\n );\n }\n\n return (\n <>\n <button\n {...rest}\n ref={register}\n aria-controls={context.menuId}\n aria-expanded={context.open()}\n aria-haspopup=\"menu\"\n aria-label={local.label}\n disabled={disabled()}\n tabIndex={disabled() ? -1 : local.tabIndex}\n onClick={click}\n onKeyDown={context.triggerKeyDown}\n type={local.type ?? \"button\"}\n class={`k2b-dropdown__trigger ${local.class ?? \"\"}`}\n title={iconTitle(local.title, tooltip())}\n >\n {local.children}\n </button>\n <Show when={tooltip() !== false && tooltip() !== undefined}>\n <Tooltip\n content={tooltip() as JSX.Element}\n target={() => target}\n delay={local.tooltipDelay}\n disabled={disabled()}\n placement={local.tooltipPlacement}\n />\n </Show>\n </>\n );\n}\n\n/** Accessible top-layer menu with explicit trigger ownership. */\nfunction DropdownRoot(props: DropdownProps): JSX.Element {\n const messages = useUiMessages();\n const locale = useLocale();\n /** The open phone sheet's cancel switch: it closes when the menu goes or is disabled, as the popover does. */\n let sheet: AbortController | undefined;\n const id = createUniqueId().replace(/[^a-zA-Z0-9_-]/g, \"-\");\n const menuId = `k2b-dropdown-${id}`;\n const [internalOpen, setInternalOpen] = createSignal(false);\n const [entriesShown, setEntriesShown] = createSignal(!props.lazy);\n let triggerRef: HTMLButtonElement | undefined;\n let menuRef: HTMLDivElement | undefined;\n let triggerRing = true;\n let mounted = false;\n /** Where a key on the trigger asked the focus to go; a controlled menu opens later, in its owner's update. */\n let keyFocus: \"first\" | \"last\" | false = false;\n let viewportListenersAttached = false;\n let resizeObserver: ResizeObserver | undefined;\n\n const isOpen = () => props.open ?? internalOpen();\n const position = (): DropdownPosition =>\n typeof props.position === \"function\" ? props.position() : (props.position ?? (props.align === \"end\" ? \"bottom-left\" : \"bottom-right\"));\n\n const place = () => {\n if (!triggerRef || !menuRef) return;\n const rect = dropdownPosition(triggerRef.getBoundingClientRect(), menuRef.getBoundingClientRect(), position(), {\n width: window.innerWidth,\n height: window.innerHeight,\n });\n menuRef.style.left = `${rect.left}px`;\n menuRef.style.top = `${rect.top}px`;\n };\n const reposition = () => {\n if (isOpen()) place();\n };\n const attachViewportListeners = () => {\n if (viewportListenersAttached) return;\n viewportListenersAttached = true;\n window.addEventListener(\"resize\", reposition);\n window.addEventListener(\"scroll\", reposition, true);\n // A content-sized menu changes size when its items change while it is open.\n if (menuRef && typeof ResizeObserver !== \"undefined\") {\n resizeObserver ??= new ResizeObserver(reposition);\n resizeObserver.observe(menuRef);\n }\n };\n const detachViewportListeners = () => {\n if (!viewportListenersAttached) return;\n viewportListenersAttached = false;\n window.removeEventListener(\"resize\", reposition);\n window.removeEventListener(\"scroll\", reposition, true);\n resizeObserver?.disconnect();\n };\n const close = (restoreFocus = true) => {\n // Before hiding, so the popover does not return focus on its own.\n if (restoreFocus) returnFocus(triggerRef, triggerRing);\n if (menuRef?.matches(\":popover-open\")) menuRef.hidePopover();\n // Like `open`, expose the closed state now: the toggle event can arrive after the next key press, and a trigger\n // that still reads as open would ignore Enter (Escape, then Enter at once, must reopen).\n setInternalOpen(false);\n detachViewportListeners();\n };\n const open = (focus: \"first\" | \"last\" | false = \"first\") => {\n if (props.disabled || !menuRef || menuRef.matches(\":popover-open\")) return;\n triggerRing = ringOnReturn(triggerRef);\n // A lazy menu's entries exist before it shows, so it places and focuses them as any other.\n setEntriesShown(true);\n menuRef.showPopover();\n // The toggle event arrives a task later; expose the open state before focus moves into the menu.\n setInternalOpen(true);\n attachViewportListeners();\n place();\n queueMicrotask(() => {\n if (focus) focusMenuItem(menuRef, focus === \"first\" ? 0 : -1);\n });\n };\n const requestOpen = (next: boolean, focus: \"first\" | \"last\" | false = \"first\") => {\n if (props.disabled && next) return;\n if (props.open !== undefined) {\n props.onOpenChange?.(next);\n return;\n }\n if (next && props.phone === \"sheet\" && prefersMenuSheet()) {\n if (sheet) return;\n const current = new AbortController();\n sheet = current;\n // The sheet is this menu's open state: the trigger reports it and the owner hears both ends.\n setInternalOpen(true);\n props.onOpenChange?.(true);\n void openMenuSheet({\n Items: DropdownItems,\n items: props.items,\n label: props.label ?? messages().dropdownMenu,\n locale: locale(),\n top: props.sheetTop,\n signal: current.signal,\n }).finally(() => {\n sheet = undefined;\n setInternalOpen(false);\n props.onOpenChange?.(false);\n props.onClose?.();\n });\n return;\n }\n if (next) open(focus);\n else close(false);\n };\n const handleMenuKeyDown = (event: KeyboardEvent) => {\n const items = actionableItems(menuRef);\n if (focusMenuRow(items, event.key) || focusRowSegment(items, event.key)) {\n event.preventDefault();\n } else if (event.key === \"Escape\") {\n event.preventDefault();\n returnFocus(triggerRef, triggerRing);\n requestOpen(false);\n } else if (event.key === \"Tab\") {\n requestOpen(false);\n }\n };\n\n const context: DropdownContextValue = {\n disabled: () => Boolean(props.disabled),\n menuId,\n open: isOpen,\n registerTrigger: (element) => {\n triggerRef = element;\n },\n toggle: () => requestOpen(!isOpen()),\n triggerKeyDown: (event) => {\n if (![\"Enter\", \" \", \"ArrowDown\", \"ArrowUp\"].includes(event.key)) return;\n event.preventDefault();\n event.stopPropagation();\n if (isOpen()) {\n focusMenuItem(menuRef, event.key === \"ArrowUp\" ? -1 : 0);\n return;\n }\n keyFocus = event.key === \"ArrowUp\" ? \"last\" : \"first\";\n requestOpen(true, keyFocus);\n keyFocus = false;\n },\n };\n\n createEffect(() => {\n const controlled = props.open;\n if (!mounted || controlled === undefined || !menuRef) return;\n if (controlled && !menuRef.matches(\":popover-open\")) open(keyFocus);\n if (!controlled && menuRef.matches(\":popover-open\")) close(false);\n });\n createEffect(() => {\n if (!props.disabled) return;\n sheet?.abort();\n if (mounted) close(false);\n });\n onMount(() => {\n mounted = true;\n if (props.open) open(false);\n onCleanup(detachViewportListeners);\n });\n onCleanup(() => sheet?.abort());\n\n return (\n <DropdownContext.Provider value={context}>\n <span class={`k2b-dropdown ${props.class ?? \"\"}`}>\n {props.children}\n <div\n ref={menuRef}\n id={menuId}\n popover=\"auto\"\n role=\"menu\"\n aria-label={props.label ?? messages().dropdownMenu}\n class={`k2b-dropdown__menu ${props.menuClass ?? \"\"}`}\n style={props.width ? { \"--k2b-dropdown-width\": props.width } : undefined}\n data-width={props.width ? \"fixed\" : undefined}\n data-variant={props.variant ?? \"default\"}\n data-position={position()}\n onKeyDown={handleMenuKeyDown}\n onToggle={(event) => {\n const nextOpen = (event as ToggleEvent).newState === \"open\";\n const wasOpen = (event as ToggleEvent).oldState === \"open\";\n setInternalOpen(nextOpen);\n if (nextOpen) setEntriesShown(true);\n if (nextOpen) attachViewportListeners();\n else detachViewportListeners();\n if (props.open === undefined || props.open !== nextOpen) props.onOpenChange?.(nextOpen);\n if (wasOpen && !nextOpen) props.onClose?.();\n if (!nextOpen && props.open === true) queueMicrotask(() => props.open === true && open(false));\n }}\n >\n <Show when={entriesShown()}>\n <DropdownItems items={props.items} close={close} />\n </Show>\n </div>\n </span>\n </DropdownContext.Provider>\n );\n}\n\ntype DropdownComponent = ((props: DropdownProps) => JSX.Element) & {\n Root: (props: DropdownProps) => JSX.Element;\n Trigger: (props: DropdownTriggerProps) => JSX.Element;\n Item: (props: DropdownItemProps) => JSX.Element;\n};\n\nexport const Dropdown = DropdownRoot as DropdownComponent;\nDropdown.Root = DropdownR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GAAG,SAAS;UAAA,QAC/B,KAAK,CAAC,OAAO,IAAI,SAAS;UAAA,QACzB,QAAQ,CAAC,CAAC;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;MAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;MAAA;MAAA;MAAA;IAAA;EAAA;AAqBnC;AAQA,OAAO,MAAM,QAAQ,GAAG,YAAiC;AACzD,QAAQ,CAAC,IAAI,GAAG,YAAY;AAC5B,QAAQ,CAAC,OAAO,GAAG,eAAe;AAClC,QAAQ,CAAC,IAAI,GAAG,YAAY;AAE5B,eAAe,QAAQ;AAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["actions/Dropdown.tsx"],"sourcesContent":["import {\n createContext,\n createEffect,\n createSignal,\n createUniqueId,\n For,\n type JSX,\n mergeProps,\n onCleanup,\n onMount,\n Show,\n splitProps,\n untrack,\n useContext,\n} from \"solid-js\";\nimport { Dynamic } from \"solid-js/web\";\nimport { Tooltip, type TooltipPlacement, useLabelTooltip } from \"../feedback/Tooltip\";\nimport { returnFocus, ringOnReturn } from \"../internal/focus-return\";\nimport { KeyedFor } from \"../internal/keyed-for\";\nimport { useLocale } from \"../intl/locale\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { Button, type ButtonProps, type ButtonSize, type ButtonVariant, iconTitle } from \"./Button\";\nimport { focusMenuRow, focusRowSegment } from \"./menu-rows\";\nimport { openMenuSheet, prefersMenuSheet } from \"./menu-sheet\";\n\n// Resolved outside JSX: a conditional attribute compiles to a lazy memo, which would be created inside the click handler.\nconst selectAction = (item: { action?: () => void }) => item.action;\nconst closeOnSelectOf = (item: DropdownAction) => (\"closeOnSelect\" in item ? item.closeOnSelect : undefined);\nconst hrefOf = (item: DropdownAction) => (\"href\" in item ? item.href : undefined);\nconst externalOf = (item: DropdownAction) => (\"external\" in item ? item.external : undefined);\n\nexport type DropdownPosition = \"bottom-right\" | \"bottom-left\" | \"top-right\" | \"top-left\" | \"right-start\";\n/** Where a menu opened without its trigger appears: an element, or any box such as a point inside one. */\nexport type DropdownAnchor = { getBoundingClientRect(): Pick<DOMRect, \"left\" | \"top\" | \"right\" | \"bottom\"> };\n/** Where focus returns as a menu opened by `openAt` closes, read at that moment when it is a function. */\nexport type DropdownReturnFocus = HTMLElement | (() => HTMLElement | undefined);\n\nexport type DropdownActionBase = {\n class?: string;\n disabled?: boolean;\n icon?: string;\n image?: string;\n label: string;\n /**\n * Accessible name when it must say more than the visible label, such as the current value and what the next\n * activation does. It must contain the visible label.\n */\n ariaLabel?: string;\n description?: string;\n /** Quiet trailing information, such as a count. */\n trailing?: JSX.Element;\n variant?: \"danger\";\n};\n\nexport type DropdownAction =\n | (DropdownActionBase & {\n action: () => void;\n /**\n * Set `false` for an action that changes a value in place, such as cycling a setting: the menu stays open and\n * the focus stays on the row. Defaults to `true`.\n */\n closeOnSelect?: boolean;\n /**\n * In a phone sheet, run while the tap still counts as the person's gesture, before the sheet closes, as browsers\n * require for clipboard writes. Other actions run after the sheet has left the history. Such an action must\n * not navigate or open a dialog.\n */\n immediate?: boolean;\n href?: never;\n external?: never;\n })\n | (DropdownActionBase & {\n href: string;\n external?: boolean;\n /** Runs on a plain click instead of following the link; modified clicks, middle-click, and the link's menu keep it. */\n action?: () => void;\n })\n | (DropdownActionBase & {\n disabled: true;\n action?: never;\n href?: never;\n external?: never;\n });\n\n/** A second, smaller action at the end of a row, such as \"Only\" beside a checkbox; it keeps the menu open. */\nexport type DropdownSecondaryAction = {\n label: string;\n /** Accessible name when the visible label alone does not say what it acts on, such as \"Only Team Logistik\". */\n ariaLabel?: string;\n action: () => void;\n};\n\n/** Declarative radio or checkbox row for compact action menus. */\nexport type DropdownChoice = DropdownActionBase & {\n action: () => void;\n checked: boolean | (() => boolean);\n choice: \"checkbox\" | \"radio\";\n href?: string;\n closeOnSelect?: boolean;\n color?: string;\n /**\n * A second action at the end of the row. It shows while the row is hovered or focused, always on a touch screen,\n * and keeps its place when hidden, so the row never changes width. Right and Left move between the two.\n */\n secondary?: DropdownSecondaryAction;\n};\n\nexport type DropdownSection = {\n sectionLabel?: string;\n /**\n * `row` sets a few short radio choices, such as a sort direction, side by side as one segmented row. Give it a\n * `sectionLabel`: the label names the choice above the row and for screen readers.\n */\n layout?: \"row\";\n /** A quiet action at the end of the section label, such as \"All\"; it needs a `sectionLabel` and keeps the menu open. */\n labelAction?: DropdownSecondaryAction;\n items: readonly (DropdownAction | DropdownChoice)[];\n};\n\nexport type DropdownItem = DropdownAction | DropdownChoice | DropdownSection;\n\nexport type DropdownProps = {\n items: readonly DropdownItem[];\n children: JSX.Element;\n position?: DropdownPosition | (() => DropdownPosition);\n /** Larger menu rows and typography for touch. Defaults to `default`. */\n variant?: \"default\" | \"touch\";\n /**\n * Exact menu width as a CSS length. Without it the menu sizes to its longest\n * entry: at least `12rem` (`18rem` for touch), at most the viewport width\n * less `1rem` per side, where longer entries wrap.\n */\n width?: string;\n class?: string;\n menuClass?: string;\n onClose?: () => void;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n disabled?: boolean;\n label?: string;\n align?: \"start\" | \"end\";\n /**\n * `sheet` opens the same items as a bottom sheet on phones (below 48rem) instead of a menu beside the trigger.\n * Defaults to `menu`. A controlled menu (`open`) always stays a menu.\n */\n phone?: \"menu\" | \"sheet\";\n /** Content above the phone sheet's menu. `close` dismisses it with normal history and focus restoration. */\n sheetTop?: (close: () => void) => JSX.Element;\n /**\n * Renders the entries only once the menu first opens, for a menu repeated on every row of a long list: the page\n * then carries each row's trigger, not each row's entries. Fixed for the menu's lifetime.\n */\n lazy?: boolean;\n /**\n * Receives `open`, which shows the menu without its trigger beside `anchor`, as for a context menu, a key or a\n * grip. Focus returns to `returnFocus` when the menu or sheet closes; pass a function when an entry can move the\n * place focus belongs to. Phones get the sheet as from the trigger.\n */\n openAt?: (open: (anchor: DropdownAnchor, returnFocus?: DropdownReturnFocus) => void) => void;\n /** Receives `close`, which closes the menu or sheet and returns focus. */\n closeWith?: (close: () => void) => void;\n};\n\nexport type DropdownTriggerProps = Omit<\n ButtonProps,\n \"aria-controls\" | \"aria-expanded\" | \"aria-haspopup\" | \"children\" | \"disabled\" | \"onClick\" | \"onKeyDown\"\n> & {\n children: JSX.Element;\n /** Use `plain` when a specialized component class owns the complete visual treatment. */\n appearance?: \"button\" | \"plain\";\n disabled?: boolean;\n iconOnly?: boolean;\n label?: string;\n size?: ButtonSize;\n tooltip?: JSX.Element | false;\n tooltipDelay?: number;\n tooltipPlacement?: TooltipPlacement;\n variant?: ButtonVariant;\n};\n\nexport type DropdownItemProps = {\n children: JSX.Element;\n closeOnSelect?: boolean;\n ariaLabel?: string;\n icon?: string;\n image?: string;\n description?: string;\n /** Quiet trailing information, such as a count. */\n trailing?: JSX.Element;\n disabled?: boolean;\n danger?: boolean;\n variant?: \"danger\";\n href?: string;\n external?: boolean;\n /** Runs when the item is chosen. With `href`, a plain click runs it instead of following the link. */\n onSelect?: () => void;\n class?: string;\n};\n\ntype MenuContextValue = {\n close: (restoreFocus?: boolean) => void;\n};\n\ntype DropdownContextValue = {\n disabled: () => boolean;\n menuId: string;\n open: () => boolean;\n registerTrigger: (element: HTMLButtonElement) => void;\n toggle: () => void;\n triggerKeyDown: JSX.EventHandlerUnion<HTMLButtonElement, KeyboardEvent>;\n};\n\nconst MenuContext = createContext<MenuContextValue>();\nconst DropdownContext = createContext<DropdownContextValue>();\n\nconst actionableItems = (menu: HTMLElement | undefined): HTMLElement[] =>\n menu\n ? Array.from(\n menu.querySelectorAll<HTMLElement>(\n [\n \"[role='menuitem']:not([aria-disabled='true'])\",\n \"[role='menuitemcheckbox']:not([aria-disabled='true'])\",\n \"[role='menuitemradio']:not([aria-disabled='true'])\",\n ].join(\", \"),\n ),\n )\n : [];\n\nconst focusMenuItem = (menu: HTMLElement | undefined, index: number): void => {\n const items = actionableItems(menu).filter((item) => !item.classList.contains(\"k2b-dropdown__secondary\"));\n if (items.length === 0) return;\n items[(index + items.length) % items.length]?.focus();\n};\n\nexport const dropdownPosition = (\n trigger: Pick<DOMRect, \"left\" | \"top\" | \"right\" | \"bottom\">,\n menu: Pick<DOMRect, \"width\" | \"height\">,\n position: DropdownPosition,\n viewport: { width: number; height: number },\n gap = 4,\n): { left: number; top: number } => {\n let left = trigger.left;\n let top = trigger.bottom + gap;\n\n if (position === \"bottom-left\" || position === \"top-left\") left = trigger.right - menu.width;\n if (position === \"top-right\" || position === \"top-left\") top = trigger.top - menu.height - gap;\n if (position === \"right-start\") {\n left = trigger.right + gap;\n top = trigger.top;\n }\n\n return {\n left: Math.max(8, Math.min(left, viewport.width - menu.width - 8)),\n top: Math.max(8, Math.min(top, viewport.height - menu.height - 8)),\n };\n};\n\nconst itemContent = (props: {\n description?: string;\n icon?: string;\n image?: string;\n trailing?: JSX.Element;\n children: JSX.Element;\n}): JSX.Element => (\n <>\n <Show when={props.image} fallback={<Show when={props.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>}>\n {(image) => <img class=\"k2b-dropdown__image\" src={image()} alt=\"\" />}\n </Show>\n <span class=\"k2b-dropdown__copy\">\n <span>{props.children}</span>\n <Show when={props.description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n {props.trailing}\n </>\n);\n\nexport function DropdownItem(props: DropdownItemProps): JSX.Element {\n const menu = useContext(MenuContext);\n const danger = () => props.danger || props.variant === \"danger\";\n const content = itemContent(props);\n\n return (\n <Show\n when={!props.disabled ? props.href : undefined}\n fallback={\n <button\n type=\"button\"\n role=\"menuitem\"\n aria-label={props.ariaLabel}\n tabIndex={-1}\n class={`k2b-dropdown__item ${props.class ?? \"\"}`}\n data-danger={danger() ? \"true\" : undefined}\n disabled={props.disabled}\n aria-disabled={props.disabled ? \"true\" : undefined}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n if (props.closeOnSelect !== false) menu?.close();\n props.onSelect?.();\n }}\n >\n {content}\n </button>\n }\n >\n {(href) => (\n <a\n href={href()}\n target={props.external ? \"_blank\" : undefined}\n rel={props.external ? \"noopener noreferrer\" : undefined}\n role=\"menuitem\"\n aria-label={props.ariaLabel}\n tabIndex={-1}\n class={`k2b-dropdown__item ${props.class ?? \"\"}`}\n data-danger={danger() ? \"true\" : undefined}\n onClick={(event) => {\n // With `onSelect`, a plain click runs it in place of the link; a modified click keeps its browser meaning.\n if (props.onSelect && !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {\n event.preventDefault();\n menu?.close();\n props.onSelect();\n return;\n }\n menu?.close(false);\n }}\n >\n {content}\n </a>\n )}\n </Show>\n );\n}\n\nfunction DropdownChoiceItem(props: DropdownChoice): JSX.Element {\n return (\n <Show when={props.secondary} fallback={<DropdownChoiceRow {...props} />}>\n {(secondary) => (\n <div class=\"k2b-dropdown__pair\">\n <DropdownChoiceRow {...props} />\n <DropdownSecondaryButton {...secondary()} class=\"k2b-dropdown__secondary\" />\n </div>\n )}\n </Show>\n );\n}\n\nfunction DropdownSecondaryButton(props: DropdownSecondaryAction & { class: string }): JSX.Element {\n return (\n <button\n type=\"button\"\n role=\"menuitem\"\n tabIndex={-1}\n class={props.class}\n aria-label={props.ariaLabel}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n props.action();\n }}\n >\n {props.label}\n </button>\n );\n}\n\nfunction DropdownChoiceRow(props: DropdownChoice): JSX.Element {\n const menu = useContext(MenuContext);\n const checked = () => (typeof props.checked === \"function\" ? props.checked() : props.checked);\n let element: HTMLElement | undefined;\n return (\n <Dynamic\n ref={(node: HTMLAnchorElement | HTMLButtonElement) => {\n element = node;\n }}\n component={!props.disabled && props.href ? \"a\" : \"button\"}\n href={!props.disabled ? props.href : undefined}\n type={!props.disabled && props.href ? undefined : \"button\"}\n role={props.choice === \"checkbox\" ? \"menuitemcheckbox\" : \"menuitemradio\"}\n aria-label={props.ariaLabel}\n aria-checked={checked()}\n aria-disabled={props.disabled ? \"true\" : undefined}\n tabIndex={-1}\n class={`k2b-dropdown__item ${props.class ?? \"\"}`}\n data-selected={checked() ? \"true\" : undefined}\n disabled={props.disabled}\n onClick={(event: MouseEvent) => {\n if (props.href && (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {\n menu?.close(false);\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n if (props.closeOnSelect !== false) menu?.close();\n props.action();\n }}\n onKeyDown={(event: KeyboardEvent) => {\n // A link answers only Enter; as a menu choice it also answers Space, like the button form.\n if (event.key !== \" \" || props.disabled || !props.href) return;\n event.preventDefault();\n element?.click();\n }}\n >\n <Show when={props.choice === \"checkbox\"}>\n <span class=\"k2b-dropdown__checkbox\" aria-hidden=\"true\">\n <Show when={checked()}>\n <i class=\"ti ti-check\" />\n </Show>\n </span>\n </Show>\n <Show when={props.image} fallback={<Show when={props.icon}>{(icon) => <i class={icon()} aria-hidden=\"true\" />}</Show>}>\n {(image) => <img class=\"k2b-dropdown__image\" src={image()} alt=\"\" />}\n </Show>\n <Show when={props.color}>\n {(color) => <span class=\"k2b-dropdown__color\" style={{ \"--k2b-dropdown-color\": color() }} aria-hidden=\"true\" />}\n </Show>\n <span class=\"k2b-dropdown__copy\">\n <span>{props.label}</span>\n <Show when={props.description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n {props.trailing}\n {/* Always present for radios, so selecting the widest entry cannot widen a content-sized menu. */}\n <Show when={props.choice === \"radio\"}>\n <i class=\"ti ti-check k2b-dropdown__check\" data-hidden={checked() ? undefined : \"true\"} aria-hidden=\"true\" />\n </Show>\n </Dynamic>\n );\n}\n\nexport function DropdownItems(props: { items: readonly DropdownItem[]; close: (restoreFocus?: boolean) => void }): JSX.Element {\n const messages = useUiMessages();\n // Rows read their current item: a host that rebuilds equal items while the menu is open keeps each row element (#2140).\n const renderItem = (item: () => DropdownAction | DropdownChoice): JSX.Element => {\n const initial = untrack(item);\n if (\"choice\" in initial) return <DropdownChoiceItem {...mergeProps(() => item() as DropdownChoice)} />;\n const action = () => item() as DropdownAction;\n return (\n <DropdownItem\n ariaLabel={action().ariaLabel}\n closeOnSelect={closeOnSelectOf(action())}\n icon={action().icon}\n image={action().image}\n description={action().description}\n trailing={action().trailing}\n variant={action().variant}\n disabled={action().disabled}\n class={action().class}\n href={hrefOf(action())}\n external={externalOf(action())}\n onSelect={selectAction(action())}\n >\n {action().label}\n </DropdownItem>\n );\n };\n\n return (\n <MenuContext.Provider value={{ close: props.close }}>\n <KeyedFor each={props.items} by={(item) => (\"items\" in item ? `section:${item.sectionLabel ?? \"\"}` : `item:${item.label}`)}>\n {(current, index) => {\n const item = current();\n return (\n <Show when={\"items\" in item} fallback={renderItem(current as () => DropdownAction | DropdownChoice)}>\n <div\n class=\"k2b-dropdown__section\"\n data-divided={index() > 0 ? \"true\" : undefined}\n role=\"group\"\n // A row of choices is no set of actions: without a label it stays unnamed rather than misnamed.\n aria-label={\n (current() as DropdownSection).sectionLabel ??\n ((current() as DropdownSection).layout === \"row\" ? undefined : messages().actions)\n }\n >\n <Show when={(current() as DropdownSection).sectionLabel}>\n {(label) => (\n <Show when={(current() as DropdownSection).labelAction} fallback={<div class=\"k2b-dropdown__label\">{label()}</div>}>\n {(action) => (\n <div class=\"k2b-dropdown__label k2b-dropdown__label--action\">\n <span>{label()}</span>\n <DropdownSecondaryButton {...action()} class=\"k2b-dropdown__label-action\" />\n </div>\n )}\n </Show>\n )}\n </Show>\n <Show\n when={(current() as DropdownSection).layout === \"row\"}\n fallback={\n <KeyedFor each={(current() as DropdownSection).items} by={(row) => row.label}>\n {renderItem}\n </KeyedFor>\n }\n >\n <div class=\"k2b-dropdown__row\">\n <KeyedFor each={(current() as DropdownSection).items} by={(row) => row.label}>\n {renderItem}\n </KeyedFor>\n </div>\n </Show>\n </div>\n </Show>\n );\n }}\n </KeyedFor>\n </MenuContext.Provider>\n );\n}\n\nfunction DropdownTrigger(props: DropdownTriggerProps): JSX.Element {\n const context = useContext(DropdownContext);\n if (!context) throw new Error(\"Dropdown.Trigger must be used inside Dropdown.Root\");\n const [local, rest] = splitProps(props, [\n \"appearance\",\n \"children\",\n \"class\",\n \"disabled\",\n \"iconOnly\",\n \"label\",\n \"ref\",\n \"size\",\n \"tabIndex\",\n \"title\",\n \"tooltip\",\n \"tooltipDelay\",\n \"tooltipPlacement\",\n \"type\",\n \"variant\",\n ]);\n let target: HTMLButtonElement | undefined;\n const disabled = () => Boolean(context.disabled() || local.disabled);\n // An icon-only trigger shows its label as a hint, like IconButton.\n const tooltip = useLabelTooltip(\n () => local.tooltip,\n () => (local.iconOnly ? (local.title ?? local.label) : undefined),\n );\n const register = (element: HTMLButtonElement) => {\n target = element;\n context.registerTrigger(element);\n if (typeof local.ref === \"function\") local.ref(element);\n };\n const click: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> = (event) => {\n event.stopPropagation();\n context.toggle();\n };\n\n if (local.appearance !== \"plain\") {\n return (\n <Button\n {...rest}\n ref={register}\n aria-controls={context.menuId}\n aria-expanded={context.open()}\n aria-haspopup=\"menu\"\n aria-label={local.label}\n disabled={disabled()}\n tabIndex={disabled() ? -1 : local.tabIndex}\n onClick={click}\n onKeyDown={context.triggerKeyDown}\n type={local.type ?? \"button\"}\n class={`${local.iconOnly ? \"k2b-icon-button\" : \"\"} k2b-dropdown__trigger ${local.class ?? \"\"}`}\n size={local.size}\n variant={local.variant ?? (local.iconOnly ? \"ghost\" : undefined)}\n title={iconTitle(local.title, tooltip())}\n tooltip={tooltip()}\n tooltipDelay={local.tooltipDelay}\n tooltipPlacement={local.tooltipPlacement}\n >\n {local.children}\n </Button>\n );\n }\n\n return (\n <>\n <button\n {...rest}\n ref={register}\n aria-controls={context.menuId}\n aria-expanded={context.open()}\n aria-haspopup=\"menu\"\n aria-label={local.label}\n disabled={disabled()}\n tabIndex={disabled() ? -1 : local.tabIndex}\n onClick={click}\n onKeyDown={context.triggerKeyDown}\n type={local.type ?? \"button\"}\n class={`k2b-dropdown__trigger ${local.class ?? \"\"}`}\n title={iconTitle(local.title, tooltip())}\n >\n {local.children}\n </button>\n <Show when={tooltip() !== false && tooltip() !== undefined}>\n <Tooltip\n content={tooltip() as JSX.Element}\n target={() => target}\n delay={local.tooltipDelay}\n disabled={disabled()}\n placement={local.tooltipPlacement}\n />\n </Show>\n </>\n );\n}\n\n/** Accessible top-layer menu with explicit trigger ownership. */\nfunction DropdownRoot(props: DropdownProps): JSX.Element {\n const messages = useUiMessages();\n const locale = useLocale();\n /** The open phone sheet's cancel switch: it closes when the menu goes or is disabled, as the popover does. */\n let sheet: AbortController | undefined;\n const id = createUniqueId().replace(/[^a-zA-Z0-9_-]/g, \"-\");\n const menuId = `k2b-dropdown-${id}`;\n const [internalOpen, setInternalOpen] = createSignal(false);\n const [entriesShown, setEntriesShown] = createSignal(!props.lazy);\n let triggerRef: HTMLButtonElement | undefined;\n /** Set while the menu is open from `openAt`: it appears beside `anchor`, and focus returns to `origin`. */\n let anchor: DropdownAnchor | undefined;\n let origin: DropdownReturnFocus | undefined;\n const originElement = () => (typeof origin === \"function\" ? origin() : origin);\n let menuRef: HTMLDivElement | undefined;\n let triggerRing = true;\n let mounted = false;\n /** Where a key on the trigger asked the focus to go; a controlled menu opens later, in its owner's update. */\n let keyFocus: \"first\" | \"last\" | false = false;\n let viewportListenersAttached = false;\n let resizeObserver: ResizeObserver | undefined;\n\n const isOpen = () => props.open ?? internalOpen();\n const position = (): DropdownPosition =>\n typeof props.position === \"function\" ? props.position() : (props.position ?? (props.align === \"end\" ? \"bottom-left\" : \"bottom-right\"));\n\n const place = () => {\n const at = anchor ?? triggerRef;\n if (!at || !menuRef) return;\n const rect = dropdownPosition(at.getBoundingClientRect(), menuRef.getBoundingClientRect(), position(), {\n width: window.innerWidth,\n height: window.innerHeight,\n });\n menuRef.style.left = `${rect.left}px`;\n menuRef.style.top = `${rect.top}px`;\n };\n const reposition = () => {\n if (isOpen()) place();\n };\n const attachViewportListeners = () => {\n if (viewportListenersAttached) return;\n viewportListenersAttached = true;\n window.addEventListener(\"resize\", reposition);\n window.addEventListener(\"scroll\", reposition, true);\n // A content-sized menu changes size when its items change while it is open.\n if (menuRef && typeof ResizeObserver !== \"undefined\") {\n resizeObserver ??= new ResizeObserver(reposition);\n resizeObserver.observe(menuRef);\n }\n };\n const detachViewportListeners = () => {\n if (!viewportListenersAttached) return;\n viewportListenersAttached = false;\n window.removeEventListener(\"resize\", reposition);\n window.removeEventListener(\"scroll\", reposition, true);\n resizeObserver?.disconnect();\n };\n const close = (restoreFocus = true) => {\n // Before hiding, so the popover does not return focus on its own.\n if (restoreFocus) returnFocus(originElement() ?? triggerRef, triggerRing);\n if (menuRef?.matches(\":popover-open\")) menuRef.hidePopover();\n // Like `open`, expose the closed state now: the toggle event can arrive after the next key press, and a trigger\n // that still reads as open would ignore Enter (Escape, then Enter at once, must reopen).\n setInternalOpen(false);\n detachViewportListeners();\n };\n const open = (focus: \"first\" | \"last\" | false = \"first\") => {\n if (props.disabled || !menuRef || menuRef.matches(\":popover-open\")) return;\n triggerRing = ringOnReturn(originElement() ?? triggerRef);\n // A lazy menu's entries exist before it shows, so it places and focuses them as any other.\n setEntriesShown(true);\n menuRef.showPopover();\n // The toggle event arrives a task later; expose the open state before focus moves into the menu.\n setInternalOpen(true);\n attachViewportListeners();\n place();\n queueMicrotask(() => {\n if (focus) focusMenuItem(menuRef, focus === \"first\" ? 0 : -1);\n });\n };\n const requestOpen = (next: boolean, focus: \"first\" | \"last\" | false = \"first\") => {\n if (props.disabled && next) return;\n if (props.open !== undefined) {\n props.onOpenChange?.(next);\n return;\n }\n if (next && props.phone === \"sheet\" && prefersMenuSheet()) {\n if (sheet) return;\n const current = new AbortController();\n sheet = current;\n // A sheet opened without its trigger returns focus to its own target, which an entry may have moved,\n // rather than to whatever had focus as it opened.\n const anchored = origin !== undefined;\n const ring = anchored && ringOnReturn(originElement());\n if (anchored && document.activeElement instanceof HTMLElement) document.activeElement.blur();\n // The sheet is this menu's open state: the trigger reports it and the owner hears both ends.\n setInternalOpen(true);\n props.onOpenChange?.(true);\n void openMenuSheet({\n Items: DropdownItems,\n items: props.items,\n label: props.label ?? messages().dropdownMenu,\n locale: locale(),\n top: props.sheetTop,\n signal: current.signal,\n }).finally(() => {\n sheet = undefined;\n // An entry that moved focus elsewhere, such as into a field, keeps it.\n const target = anchored ? originElement() : undefined;\n const focused = document.activeElement;\n if (target?.isConnected && (!focused || focused === document.body)) returnFocus(target, ring);\n setInternalOpen(false);\n props.onOpenChange?.(false);\n props.onClose?.();\n });\n return;\n }\n if (next) open(focus);\n else close(false);\n };\n const handleMenuKeyDown = (event: KeyboardEvent) => {\n const items = actionableItems(menuRef);\n if (focusMenuRow(items, event.key) || focusRowSegment(items, event.key)) {\n event.preventDefault();\n } else if (event.key === \"Escape\") {\n event.preventDefault();\n returnFocus(originElement() ?? triggerRef, triggerRing);\n requestOpen(false);\n } else if (event.key === \"Tab\") {\n requestOpen(false);\n }\n };\n\n const context: DropdownContextValue = {\n disabled: () => Boolean(props.disabled),\n menuId,\n open: isOpen,\n registerTrigger: (element) => {\n triggerRef = element;\n },\n toggle: () => {\n if (!isOpen()) anchor = origin = undefined;\n requestOpen(!isOpen());\n },\n triggerKeyDown: (event) => {\n if (![\"Enter\", \" \", \"ArrowDown\", \"ArrowUp\"].includes(event.key)) return;\n event.preventDefault();\n event.stopPropagation();\n if (isOpen()) {\n focusMenuItem(menuRef, event.key === \"ArrowUp\" ? -1 : 0);\n return;\n }\n anchor = origin = undefined;\n keyFocus = event.key === \"ArrowUp\" ? \"last\" : \"first\";\n requestOpen(true, keyFocus);\n keyFocus = false;\n },\n };\n\n createEffect(() => {\n const controlled = props.open;\n if (!mounted || controlled === undefined || !menuRef) return;\n if (controlled && !menuRef.matches(\":popover-open\")) open(keyFocus);\n if (!controlled && menuRef.matches(\":popover-open\")) close(false);\n });\n createEffect(() => {\n if (!props.disabled) return;\n sheet?.abort();\n if (mounted) close(false);\n });\n props.openAt?.((at, focus) => {\n if (isOpen()) return;\n anchor = at;\n origin = focus;\n requestOpen(true);\n });\n props.closeWith?.(() => {\n sheet?.abort();\n if (isOpen()) close();\n });\n onMount(() => {\n mounted = true;\n if (props.open) open(false);\n onCleanup(detachViewportListeners);\n });\n onCleanup(() => sheet?.abort());\n\n return (\n <DropdownContext.Provider value={context}>\n <span class={`k2b-dropdown ${props.class ?? \"\"}`}>\n {props.children}\n <div\n ref={menuRef}\n id={menuId}\n popover=\"auto\"\n role=\"menu\"\n aria-label={props.label ?? messages().dropdownMenu}\n class={`k2b-dropdown__menu ${props.menuClass ?? \"\"}`}\n style={props.width ? { \"--k2b-dropdown-width\": props.width } : undefined}\n data-width={props.width ? \"fixed\" : undefined}\n data-variant={props.variant ?? \"default\"}\n data-position={position()}\n onKeyDown={handleMenuKeyDown}\n onToggle={(event) => {\n const nextOpen = (event as ToggleEvent).newState === \"open\";\n const wasOpen = (event as ToggleEvent).oldState === \"open\";\n setInternalOpen(nextOpen);\n if (nextOpen) setEntriesShown(true);\n if (nextOpen) attachViewportListeners();\n else detachViewportListeners();\n if (props.open === undefined || props.open !== nextOpen) props.onOpenChange?.(nextOpen);\n // A light dismiss hides the menu with focus inside it; an opener without a trigger takes it back.\n const focused = document.activeElement;\n const target = wasOpen && !nextOpen ? originElement() : undefined;\n if (target?.isConnected && (!focused || focused === document.body || menuRef?.contains(focused)))\n returnFocus(target, triggerRing);\n if (wasOpen && !nextOpen) props.onClose?.();\n if (!nextOpen && props.open === true) queueMicrotask(() => props.open === true && open(false));\n }}\n >\n <Show when={entriesShown()}>\n <DropdownItems items={props.items} close={close} />\n </Show>\n </div>\n </span>\n </DropdownContext.Provider>\n );\n}\n\ntype DropdownComponent = ((props: DropdownProps) => JSX.Element) & {\n Root: (props: DropdownProps) => JSX.Element;\n Trigger: (props: DropdownTriggerProps) => JSX.Element;\n Item: (props: DropdownItemProps) => JSX.Element;\n};\n\nexport const Dropdown = DropdownRoot as DropdownComponent;\nDropdown.Root = DropdownRoot;\nDropdown.Trigger = DropdownTrigger;\nDropdown.Item = DropdownItem;\n\nexport default Dropdown;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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AAsB,KAAK,CAAC,SAAS,IAAI,EAAE,EAAE;UAAA,QAC7C,KAAK,CAAC,KAAK,GAAG;YAAE,sBAAsB,EAAE,KAAK,CAAC;UAAM,CAAC,GAAG,SAAS;UAAA,QAC5D,KAAK,CAAC,KAAK,GAAG,OAAO,GAAG,SAAS;UAAA,QAC/B,KAAK,CAAC,OAAO,IAAI,SAAS;UAAA,QACzB,QAAQ,CAAC,CAAC;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;MAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;MAAA;MAAA;MAAA;IAAA;EAAA;AA0BnC;AAQA,OAAO,MAAM,QAAQ,GAAG,YAAiC;AACzD,QAAQ,CAAC,IAAI,GAAG,YAAY;AAC5B,QAAQ,CAAC,OAAO,GAAG,eAAe;AAClC,QAAQ,CAAC,IAAI,GAAG,YAAY;AAE5B,eAAe,QAAQ;AAAC","ignoreList":[]}
|
|
@@ -10,7 +10,7 @@ import { use as _$use } from "solid-js/web";
|
|
|
10
10
|
var _tmpl$ = /*#__PURE__*/_$template(`<div popover=manual>`);
|
|
11
11
|
import { createEffect, onCleanup } from "solid-js";
|
|
12
12
|
import { isServer } from "solid-js/web";
|
|
13
|
-
import { Toolbar } from "./Toolbar";
|
|
13
|
+
import { Toolbar, ToolbarHintsContext } from "./Toolbar";
|
|
14
14
|
const GAP = 8;
|
|
15
15
|
const EDGE = 8;
|
|
16
16
|
|
|
@@ -111,12 +111,17 @@ export function SelectionToolbar(props) {
|
|
|
111
111
|
};
|
|
112
112
|
var _ref$ = root;
|
|
113
113
|
typeof _ref$ === "function" ? _$use(_ref$, _el$) : root = _el$;
|
|
114
|
-
_$insert(_el$, _$createComponent(
|
|
115
|
-
|
|
116
|
-
return props.label;
|
|
117
|
-
},
|
|
114
|
+
_$insert(_el$, _$createComponent(ToolbarHintsContext.Provider, {
|
|
115
|
+
value: false,
|
|
118
116
|
get children() {
|
|
119
|
-
return
|
|
117
|
+
return _$createComponent(Toolbar, {
|
|
118
|
+
get label() {
|
|
119
|
+
return props.label;
|
|
120
|
+
},
|
|
121
|
+
get children() {
|
|
122
|
+
return props.children;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
120
125
|
}
|
|
121
126
|
}));
|
|
122
127
|
_$effect(() => _$className(_el$, `k2b-selection-toolbar ${props.class ?? ""}`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["actions/SelectionToolbar.tsx"],"sourcesContent":["import { createEffect, type JSX, onCleanup } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { Toolbar } from \"./Toolbar\";\n\nexport type SelectionToolbarProps = {\n /**\n * The selection's box in viewport coordinates, or nothing while the toolbar is closed. It is read again on every\n * scroll and resize while the toolbar is open, so a function that measures the selection keeps it attached.\n */\n anchor: () => DOMRect | null | undefined;\n label: string;\n /**\n * `above` (default) places the toolbar over the selection and below it when the space above is too small. `below`\n * always places it below, for touch, where the system's own selection menu sits above.\n */\n placement?: \"above\" | \"below\";\n /** The area the toolbar stays in, such as the editor's scroll area under its toolbar: it goes below the selection when the space above inside this area is too small. */\n boundary?: () => HTMLElement | null | undefined;\n /** Escape inside the toolbar; the application closes it and returns focus to the text. */\n onEscape?: () => void;\n children: JSX.Element;\n class?: string;\n};\n\nconst GAP = 8;\nconst EDGE = 8;\n\n/** Where the toolbar goes for a selection box: centered on its first line, inside the viewport. */\nexport const selectionToolbarPosition = (\n anchor: Pick<DOMRect, \"top\" | \"bottom\" | \"left\" | \"width\">,\n toolbar: { width: number; height: number },\n viewport: { width: number; height: number; top?: number },\n placement: \"above\" | \"below\" = \"above\",\n): { left: number; top: number; side: \"above\" | \"below\" } => {\n const left = Math.max(EDGE, Math.min(anchor.left + anchor.width / 2 - toolbar.width / 2, viewport.width - toolbar.width - EDGE));\n // A boundary scrolled above the window still leaves the window's top edge as the limit.\n const upper = Math.max(0, viewport.top ?? 0) + EDGE;\n const above = anchor.top - toolbar.height - GAP;\n const below = anchor.bottom + GAP;\n const fitsAbove = above >= upper;\n const fitsBelow = below + toolbar.height <= viewport.height - EDGE;\n // The preferred side when it fits, the other side when only that fits; never on the selected text otherwise.\n const side = placement === \"below\" ? (fitsBelow || !fitsAbove ? \"below\" : \"above\") : fitsAbove || !fitsBelow ? \"above\" : \"below\";\n if (side === \"above\") return { left, top: fitsAbove ? above : upper, side };\n return { left, top: fitsBelow ? below : Math.max(upper, viewport.height - EDGE - toolbar.height), side };\n};\n\nconst keepsFocus = (target: EventTarget | null) =>\n target instanceof Element && !!target.closest(\"input, textarea, select, [contenteditable='true']\");\n\n/**\n * A toolbar that floats at a text selection, such as formatting and comment actions over selected text. It lies in\n * the top layer, so no scroll container clips it, and pressing its buttons keeps the selection.\n */\nexport function SelectionToolbar(props: SelectionToolbarProps): JSX.Element {\n let root!: HTMLDivElement;\n const place = () => {\n const anchor = props.anchor();\n if (!anchor) return false;\n const boundary = props.boundary?.()?.getBoundingClientRect();\n const size = root.getBoundingClientRect();\n const { left, top, side } = selectionToolbarPosition(\n anchor,\n size,\n { width: document.documentElement.clientWidth, height: window.innerHeight, top: boundary?.top },\n props.placement,\n );\n root.style.left = `${Math.round(left)}px`;\n root.style.top = `${Math.round(top)}px`;\n root.dataset.side = side;\n return true;\n };\n\n if (!isServer)\n createEffect(() => {\n const open = !!props.anchor();\n if (!open) {\n if (root.matches(\":popover-open\")) root.hidePopover();\n return;\n }\n if (!root.matches(\":popover-open\")) root.showPopover();\n place();\n let frame = 0;\n const follow = () => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(() => {\n if (!place() && root.matches(\":popover-open\")) root.hidePopover();\n });\n };\n window.addEventListener(\"scroll\", follow, { capture: true, passive: true });\n window.addEventListener(\"resize\", follow, { passive: true });\n const observer = new ResizeObserver(follow);\n observer.observe(root);\n onCleanup(() => {\n cancelAnimationFrame(frame);\n window.removeEventListener(\"scroll\", follow, { capture: true });\n window.removeEventListener(\"resize\", follow);\n observer.disconnect();\n });\n });\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: the toolbar inside is the keyboard target; the frame only keeps the selection on press and forwards Escape.\n <div\n ref={root}\n popover=\"manual\"\n class={`k2b-selection-toolbar ${props.class ?? \"\"}`}\n onPointerDown={(event) => {\n // A press on a button would otherwise move focus and clear the selection the actions apply to.\n if (!keepsFocus(event.target)) event.preventDefault();\n }}\n onKeyDown={(event) => {\n if (event.key !== \"Escape\" || !props.onEscape) return;\n event.preventDefault();\n event.stopPropagation();\n props.onEscape();\n }}\n >\n <Toolbar label={props.label}>{props.children}</Toolbar>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,YAAY,EAAY,SAAS,QAAQ,UAAU;AAC5D,SAAS,QAAQ,QAAQ,cAAc;AACvC,SAAS,OAAO,QAAQ,WAAW;
|
|
1
|
+
{"version":3,"names":[],"sources":["actions/SelectionToolbar.tsx"],"sourcesContent":["import { createEffect, type JSX, onCleanup } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { Toolbar, ToolbarHintsContext } from \"./Toolbar\";\n\nexport type SelectionToolbarProps = {\n /**\n * The selection's box in viewport coordinates, or nothing while the toolbar is closed. It is read again on every\n * scroll and resize while the toolbar is open, so a function that measures the selection keeps it attached.\n */\n anchor: () => DOMRect | null | undefined;\n label: string;\n /**\n * `above` (default) places the toolbar over the selection and below it when the space above is too small. `below`\n * always places it below, for touch, where the system's own selection menu sits above.\n */\n placement?: \"above\" | \"below\";\n /** The area the toolbar stays in, such as the editor's scroll area under its toolbar: it goes below the selection when the space above inside this area is too small. */\n boundary?: () => HTMLElement | null | undefined;\n /** Escape inside the toolbar; the application closes it and returns focus to the text. */\n onEscape?: () => void;\n children: JSX.Element;\n class?: string;\n};\n\nconst GAP = 8;\nconst EDGE = 8;\n\n/** Where the toolbar goes for a selection box: centered on its first line, inside the viewport. */\nexport const selectionToolbarPosition = (\n anchor: Pick<DOMRect, \"top\" | \"bottom\" | \"left\" | \"width\">,\n toolbar: { width: number; height: number },\n viewport: { width: number; height: number; top?: number },\n placement: \"above\" | \"below\" = \"above\",\n): { left: number; top: number; side: \"above\" | \"below\" } => {\n const left = Math.max(EDGE, Math.min(anchor.left + anchor.width / 2 - toolbar.width / 2, viewport.width - toolbar.width - EDGE));\n // A boundary scrolled above the window still leaves the window's top edge as the limit.\n const upper = Math.max(0, viewport.top ?? 0) + EDGE;\n const above = anchor.top - toolbar.height - GAP;\n const below = anchor.bottom + GAP;\n const fitsAbove = above >= upper;\n const fitsBelow = below + toolbar.height <= viewport.height - EDGE;\n // The preferred side when it fits, the other side when only that fits; never on the selected text otherwise.\n const side = placement === \"below\" ? (fitsBelow || !fitsAbove ? \"below\" : \"above\") : fitsAbove || !fitsBelow ? \"above\" : \"below\";\n if (side === \"above\") return { left, top: fitsAbove ? above : upper, side };\n return { left, top: fitsBelow ? below : Math.max(upper, viewport.height - EDGE - toolbar.height), side };\n};\n\nconst keepsFocus = (target: EventTarget | null) =>\n target instanceof Element && !!target.closest(\"input, textarea, select, [contenteditable='true']\");\n\n/**\n * A toolbar that floats at a text selection, such as formatting and comment actions over selected text. It lies in\n * the top layer, so no scroll container clips it, and pressing its buttons keeps the selection.\n */\nexport function SelectionToolbar(props: SelectionToolbarProps): JSX.Element {\n let root!: HTMLDivElement;\n const place = () => {\n const anchor = props.anchor();\n if (!anchor) return false;\n const boundary = props.boundary?.()?.getBoundingClientRect();\n const size = root.getBoundingClientRect();\n const { left, top, side } = selectionToolbarPosition(\n anchor,\n size,\n { width: document.documentElement.clientWidth, height: window.innerHeight, top: boundary?.top },\n props.placement,\n );\n root.style.left = `${Math.round(left)}px`;\n root.style.top = `${Math.round(top)}px`;\n root.dataset.side = side;\n return true;\n };\n\n if (!isServer)\n createEffect(() => {\n const open = !!props.anchor();\n if (!open) {\n if (root.matches(\":popover-open\")) root.hidePopover();\n return;\n }\n if (!root.matches(\":popover-open\")) root.showPopover();\n place();\n let frame = 0;\n const follow = () => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(() => {\n if (!place() && root.matches(\":popover-open\")) root.hidePopover();\n });\n };\n window.addEventListener(\"scroll\", follow, { capture: true, passive: true });\n window.addEventListener(\"resize\", follow, { passive: true });\n const observer = new ResizeObserver(follow);\n observer.observe(root);\n onCleanup(() => {\n cancelAnimationFrame(frame);\n window.removeEventListener(\"scroll\", follow, { capture: true });\n window.removeEventListener(\"resize\", follow);\n observer.disconnect();\n });\n });\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: the toolbar inside is the keyboard target; the frame only keeps the selection on press and forwards Escape.\n <div\n ref={root}\n popover=\"manual\"\n class={`k2b-selection-toolbar ${props.class ?? \"\"}`}\n onPointerDown={(event) => {\n // A press on a button would otherwise move focus and clear the selection the actions apply to.\n if (!keepsFocus(event.target)) event.preventDefault();\n }}\n onKeyDown={(event) => {\n if (event.key !== \"Escape\" || !props.onEscape) return;\n event.preventDefault();\n event.stopPropagation();\n props.onEscape();\n }}\n >\n <ToolbarHintsContext.Provider value={false}>\n <Toolbar label={props.label}>{props.children}</Toolbar>\n </ToolbarHintsContext.Provider>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,YAAY,EAAY,SAAS,QAAQ,UAAU;AAC5D,SAAS,QAAQ,QAAQ,cAAc;AACvC,SAAS,OAAO,EAAE,mBAAmB,QAAQ,WAAW;AAsBxD,MAAM,GAAG,GAAG,CAAC;AACb,MAAM,IAAI,GAAG,CAAC;;AAEd;AACA,OAAO,MAAM,wBAAwB,GAAG,CACtC,MAA0D,EAC1D,OAA0C,EAC1C,QAAyD,EACzD,SAA4B,GAAG,OAAO,KACqB;EAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG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AAA,iCAbvC,yBAAyB,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE;MAAA;MAAA;IAAA;EAAA;AAiBzD;AAAC","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ import { use as _$use } from "solid-js/web";
|
|
|
6
6
|
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
7
7
|
import { insert as _$insert } from "solid-js/web";
|
|
8
8
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
9
|
+
import { memo as _$memo } from "solid-js/web";
|
|
9
10
|
import { className as _$className } from "solid-js/web";
|
|
10
11
|
import { effect as _$effect } from "solid-js/web";
|
|
11
12
|
import { getNextElement as _$getNextElement } from "solid-js/web";
|
|
@@ -28,6 +29,8 @@ import { Dropdown } from "./Dropdown";
|
|
|
28
29
|
import { useToolbarMessages } from "./toolbar-messages";
|
|
29
30
|
const defaultToolbarOrientation = () => "horizontal";
|
|
30
31
|
const ToolbarOrientationContext = createContext(defaultToolbarOrientation);
|
|
32
|
+
/** False where actions are icon-sized, such as SelectionToolbar: no room below the icon for a hint. Package-internal. */
|
|
33
|
+
export const ToolbarHintsContext = createContext(true);
|
|
31
34
|
|
|
32
35
|
// `item` is created once per action: the More menu keys its rows by identity, so a remeasure keeps a focused row.
|
|
33
36
|
|
|
@@ -76,6 +79,7 @@ const ariaShortcut = (keys, platform) => {
|
|
|
76
79
|
};
|
|
77
80
|
const ToolbarAction = props => {
|
|
78
81
|
const register = useContext(ToolbarActionsContext);
|
|
82
|
+
const hints = useContext(ToolbarHintsContext);
|
|
79
83
|
const locale = useLocale();
|
|
80
84
|
const [platform, setPlatform] = createSignal(isServer || sharedConfig.context ? "other" : keyboardPlatform());
|
|
81
85
|
onMount(() => setPlatform(keyboardPlatform()));
|
|
@@ -132,7 +136,7 @@ const ToolbarAction = props => {
|
|
|
132
136
|
return _el$;
|
|
133
137
|
})(), _$createComponent(Show, {
|
|
134
138
|
get when() {
|
|
135
|
-
return props.keys;
|
|
139
|
+
return hints && props.keys;
|
|
136
140
|
},
|
|
137
141
|
children: keys => _$createComponent(Kbd, {
|
|
138
142
|
get keys() {
|