@adea-ai/ui 0.159.4 → 0.159.5
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/components/composites/action-button/action-button.d.ts.map +1 -1
- package/dist/components/composites/action-button/action-button.js +7 -4
- package/dist/components/composites/action-button/action-button.js.map +1 -1
- package/dist/r/src/components/composites/action-button/action-button.tsx +9 -4
- package/package.json +1 -1
- package/src/components/composites/action-button/action-button.tsx +9 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-button.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/action-button/action-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,GAAG,EACR,KAAK,cAAc,EACpB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMlE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,GAAG,QAAQ,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IACpF,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iGAAiG;IACjG,WAAW,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACjD;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,uFAAuF;IACvF,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AA0CD,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,GAAG,QAAQ,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"action-button.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/action-button/action-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,GAAG,EACR,KAAK,cAAc,EACpB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMlE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,GAAG,QAAQ,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IACpF,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iGAAiG;IACjG,WAAW,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACjD;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,uFAAuF;IACvF,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AA0CD,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,GAAG,QAAQ,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,eA+L5F"}
|
|
@@ -68,6 +68,8 @@ function ActionButton(props) {
|
|
|
68
68
|
});
|
|
69
69
|
const [tooltipSuppression, setTooltipSuppression] = createSignal(null);
|
|
70
70
|
const forwarded = rest;
|
|
71
|
+
let element;
|
|
72
|
+
const popupOpen = () => element?.getAttribute("aria-expanded") === "true";
|
|
71
73
|
const buttonProps = mergeProps$1(rest, {
|
|
72
74
|
get "data-slot"() {
|
|
73
75
|
return forwarded["data-slot"] ?? "action-button";
|
|
@@ -103,10 +105,11 @@ function ActionButton(props) {
|
|
|
103
105
|
get "aria-describedby"() {
|
|
104
106
|
return forwarded["aria-describedby"] ?? (local.tooltip && tooltipOpen() ? tooltipId : void 0);
|
|
105
107
|
},
|
|
106
|
-
ref: (
|
|
107
|
-
|
|
108
|
+
ref: (button) => {
|
|
109
|
+
element = button;
|
|
110
|
+
deferred.ref(button);
|
|
108
111
|
const callerRef = forwarded.ref;
|
|
109
|
-
if (typeof callerRef === "function") callerRef(
|
|
112
|
+
if (typeof callerRef === "function") callerRef(button);
|
|
110
113
|
},
|
|
111
114
|
onPointerEnter: deferred.onPointerEnter,
|
|
112
115
|
onFocus: deferred.onFocus,
|
|
@@ -169,7 +172,7 @@ function ActionButton(props) {
|
|
|
169
172
|
return tooltipOpen();
|
|
170
173
|
},
|
|
171
174
|
onOpenChange: (open) => {
|
|
172
|
-
if (open && tooltipSuppression()) return;
|
|
175
|
+
if (open && (tooltipSuppression() || popupOpen())) return;
|
|
173
176
|
setTooltipOpen(open);
|
|
174
177
|
},
|
|
175
178
|
get children() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-button.js","names":["For","Show","createRoot","mergeProps","createSignal","createUniqueId","splitProps","callHandler","Polymorphic","buttonVariants","cn","Kbd","KbdGroup","Spinner","createDeferredTooltip","Tooltip","TooltipContent","TooltipTrigger","tooltip","tooltipSide","tooltipIcon","tooltipShortcut","busy","busyLabel","invokeHandler","handler","event","chainedHandler","before","guardedClick","disabled","onActivate","isDisabled","dispose","preventDefault","stopImmediatePropagation","ActionButton","props","local","rest","href","busyStatus","tooltipOpen","setTooltipOpen","tooltipId","deferred","enabled","onPointerEnter","onFocus","tooltipSuppression","setTooltipSuppression","forwarded","buttonProps","class","variant","size","touchTarget","type","tabIndex","as","undefined","role","ref","element","callerRef","onClick","detail","onPointerLeave","onBlur","onClickCapture","contents","_$createComponent","when","children","label","_$memo","fallback","_$mergeProps","_el$","_tmpl$","_$spread","_$insert","armed","tooltipSlot","placement","open","onOpenChange","Target","id","icon","length","_el$3","_tmpl$3","each","key","_el$2","_tmpl$2"],"sources":["../../../../src/components/composites/action-button/action-button.tsx"],"sourcesContent":["import {\n For,\n Show,\n createRoot,\n mergeProps,\n createSignal,\n createUniqueId,\n splitProps,\n type ComponentProps,\n type JSX,\n type ValidComponent,\n} from 'solid-js'\nimport { callHandler } from '#lib/events'\nimport { Polymorphic } from '@kobalte/core/polymorphic'\nimport { buttonVariants, type ButtonProps } from '../../ui/button'\nimport { cn } from '#lib/utils'\nimport { Kbd, KbdGroup } from '../../ui/kbd'\nimport { Spinner } from '../../ui/spinner'\nimport { createDeferredTooltip, Tooltip, TooltipContent, TooltipTrigger } from '../../ui/tooltip'\n\n/**\n * ActionButton.\n *\n * A Button with optional explanatory tooltip and busy feedback. Use it for a\n * simple action that needs these states; actions with product-specific rules\n * should compose Button directly.\n *\n * The tooltip trigger is the polymorphic Button itself; the tooltip mounts on\n * its first hover or keyboard focus (see createDeferredTooltip). A disabled native\n * control cannot receive pointer or keyboard events. When a tooltip is set,\n * disabled actions therefore use focusable `aria-disabled` semantics and guard\n * activation; without a tooltip, native buttons retain native disabling.\n * Custom polymorphic components must forward aria, event, and href props for\n * these guarantees to apply.\n */\nexport type ActionButtonProps<T extends ValidComponent = 'button'> = ButtonProps<T> & {\n /** A short explanation, also shown on keyboard focus. The Button still needs its own name. */\n tooltip?: string\n /** Placement of the explanation; icon actions live in bars, so it defaults below the control. */\n tooltipSide?: 'top' | 'right' | 'bottom' | 'left'\n /**\n * A leading icon repeated inside the explanation, forwarded to the shared\n * tooltip's `icon` slot so a bar of icon actions gets the icon+label tip\n * without hand-composing Button and Tooltip. Decorative by contract: the tip\n * is never the accessible name, so the icon must not carry meaning the label\n * lacks. Size it by leaving the svg bare; the slot fixes it to control size.\n */\n tooltipIcon?: JSX.Element\n /**\n * The action's keyboard chord, one entry per key (`['⇧', '⌘', 'D']`), drawn as keys after the\n * explanation. Decorative like the rest of the tip: put the parseable chord on the control\n * itself with `aria-keyshortcuts`.\n */\n tooltipShortcut?: readonly string[]\n /** Disables the action and announces the busy label through a polite status region. */\n busy?: boolean\n /** The activity announced while busy. The Button's accessible name stays unchanged. */\n busyLabel?: string\n}\n\ntype ForwardedHandler = JSX.EventHandlerUnion<Element, Event> | undefined\ntype ForwardedEvent = Event & { currentTarget: Element; target: Element }\n\nfunction invokeHandler(handler: unknown, event: Event) {\n callHandler(handler as ForwardedHandler, event as ForwardedEvent)\n}\n\nfunction chainedHandler(handler: () => unknown, before: (event: Event) => void) {\n return (event: Event) => {\n before(event)\n invokeHandler(handler(), event)\n }\n}\n\nfunction guardedClick(\n handler: () => unknown,\n disabled: () => boolean,\n onActivate: (event: MouseEvent) => void = () => {}\n) {\n return (event: MouseEvent) => {\n // A polymorphic trigger can provide a getter that creates reactive work.\n // Event callbacks have no owner, so dispose any such work after the read.\n const isDisabled = createRoot((dispose) => {\n try {\n return disabled()\n } finally {\n dispose()\n }\n })\n if (isDisabled) {\n event.preventDefault()\n event.stopImmediatePropagation()\n return\n }\n\n onActivate(event)\n invokeHandler(handler(), event)\n }\n}\n\nexport function ActionButton<T extends ValidComponent = 'button'>(props: ActionButtonProps<T>) {\n const [local, rest] = splitProps(props as ActionButtonProps & { href?: string }, [\n 'as',\n 'variant',\n 'size',\n 'touchTarget',\n 'class',\n 'children',\n 'disabled',\n 'aria-busy',\n 'tooltip',\n 'tooltipSide',\n 'tooltipIcon',\n 'tooltipShortcut',\n 'busy',\n 'busyLabel',\n // Split, not read from `rest`: mergeProps falls back to an earlier source when a\n // getter returns undefined, so a disabled link could not drop its href otherwise.\n 'href',\n ])\n const busy = () => local.busy ?? false\n const disabled = () => busy() || !!local.disabled\n const busyStatus = () => local.busyLabel ?? 'Working'\n const [tooltipOpen, setTooltipOpen] = createSignal(false)\n const tooltipId = `action-button-tooltip-${createUniqueId()}`\n // The tooltip mounts on the first hover or keyboard focus; until then the\n // button renders alone (see createDeferredTooltip).\n const deferred = createDeferredTooltip({\n enabled: () => !!local.tooltip,\n onPointerEnter: () => rest.onPointerEnter,\n onFocus: () => rest.onFocus,\n })\n const [tooltipSuppression, setTooltipSuppression] = createSignal<'pointer' | 'focus' | null>(null)\n const forwarded = rest as Record<string, unknown>\n\n // One props object for the life of the button. Each value is a getter, so it stays\n // reactive per key, and the handlers are created once and read the caller's handler\n // when they run. (Spreading a function's result instead compiles to a memo that\n // rebuilds every key and handler whenever any prop it reads changes.)\n const buttonProps = mergeProps(rest, {\n // The inner Button would otherwise announce itself as a plain `button`; a\n // caller's own slot still wins.\n get 'data-slot'() {\n return (forwarded['data-slot'] as string | undefined) ?? 'action-button'\n },\n // Button's own class, computed here: rendering Polymorphic directly saves a\n // component layer and a splitProps over every key, on every action button.\n get class() {\n return cn(\n buttonVariants({\n variant: local.variant,\n size: local.size,\n touchTarget: local.touchTarget,\n }),\n local.class,\n local.tooltip && disabled() && 'aria-disabled:pointer-events-auto'\n )\n },\n // As Button sets it: a custom component that renders a native button inside a\n // form must not submit by accident. A caller's own type still wins.\n get type() {\n return (forwarded.type as string | undefined) ?? 'button'\n },\n get disabled() {\n return disabled() && !local.tooltip\n },\n get 'aria-disabled'() {\n return disabled() ? true : rest['aria-disabled']\n },\n // Make tooltip-bearing native controls explicit tab stops in WebKit configurations that\n // otherwise skip implicit button stops. A caller's tabIndex remains authoritative.\n get tabIndex() {\n return (\n rest.tabIndex ??\n (local.as === 'a' && disabled() ? (local.tooltip ? 0 : -1) : local.tooltip ? 0 : undefined)\n )\n },\n get role() {\n return local.as === 'a' && disabled() ? 'link' : rest.role\n },\n get href() {\n return local.as === 'a' && disabled() ? undefined : local.href\n },\n get 'aria-busy'() {\n return busy() || local['aria-busy']\n },\n get 'aria-describedby'() {\n return (\n (forwarded['aria-describedby'] as string | undefined) ??\n (local.tooltip && tooltipOpen() ? tooltipId : undefined)\n )\n },\n ref: (element: HTMLElement) => {\n deferred.ref(element)\n const callerRef = forwarded.ref\n if (typeof callerRef === 'function') callerRef(element)\n },\n onPointerEnter: deferred.onPointerEnter,\n onFocus: deferred.onFocus,\n onClick: guardedClick(\n () => rest.onClick,\n disabled,\n (event) => {\n if (!local.tooltip) return\n setTooltipSuppression(event.detail > 0 ? 'pointer' : 'focus')\n setTooltipOpen(false)\n }\n ),\n onPointerLeave: chainedHandler(\n () => rest.onPointerLeave,\n () => {\n if (tooltipSuppression() === 'pointer') setTooltipSuppression(null)\n }\n ),\n onBlur: chainedHandler(\n () => rest.onBlur,\n () => {\n if (tooltipSuppression() === 'focus') setTooltipSuppression(null)\n }\n ),\n onClickCapture: forwarded.onClickCapture\n ? guardedClick(() => forwarded.onClickCapture, disabled)\n : undefined,\n // Only when the caller uses them: each is a native listener on every button.\n 'on:click': forwarded['on:click']\n ? guardedClick(() => forwarded['on:click'], disabled)\n : undefined,\n 'oncapture:click': forwarded['oncapture:click']\n ? guardedClick(() => forwarded['oncapture:click'], disabled)\n : undefined,\n })\n\n const contents = () => (\n <>\n <Show when={busy()}>\n <Spinner size=\"sm\" label={false} aria-hidden=\"true\" data-icon=\"inline-start\" />\n </Show>\n {local.children}\n </>\n )\n\n return (\n <>\n {/* A native button, the common case, is written directly: Polymorphic goes\n through Dynamic, a memo and a component per button. */}\n <Show\n when={local.as === undefined || local.as === 'button'}\n fallback={\n <Polymorphic as={local.as} {...(buttonProps as ComponentProps<'button'>)}>\n {contents()}\n </Polymorphic>\n }\n >\n <button {...(buttonProps as ComponentProps<'button'>)}>{contents()}</button>\n </Show>\n <Show when={deferred.armed() && local.tooltip}>\n {(tooltipSlot) => (\n <Tooltip\n placement={local.tooltipSide ?? 'bottom'}\n open={tooltipOpen()}\n onOpenChange={(open) => {\n if (open && tooltipSuppression()) return\n setTooltipOpen(open)\n }}\n >\n <TooltipTrigger as={deferred.Target} />\n <TooltipContent id={tooltipId} icon={local.tooltipIcon}>\n <Show when={local.tooltipShortcut?.length} fallback={tooltipSlot()}>\n <span class=\"inline-flex items-center gap-2 whitespace-nowrap\">\n {tooltipSlot()}\n <KbdGroup data-slot=\"action-button-shortcut\" aria-hidden=\"true\">\n <For each={local.tooltipShortcut}>{(key) => <Kbd>{key}</Kbd>}</For>\n </KbdGroup>\n </span>\n </Show>\n </TooltipContent>\n </Tooltip>\n )}\n </Show>\n <Show when={busy()}>\n <span role=\"status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EbtD,UAAU;IAAA,OAAAsD;GAAA;EAAA,CAAA;CAAA;AAKrB"}
|
|
1
|
+
{"version":3,"file":"action-button.js","names":["For","Show","createRoot","mergeProps","createSignal","createUniqueId","splitProps","callHandler","Polymorphic","buttonVariants","cn","Kbd","KbdGroup","Spinner","createDeferredTooltip","Tooltip","TooltipContent","TooltipTrigger","tooltip","tooltipSide","tooltipIcon","tooltipShortcut","busy","busyLabel","invokeHandler","handler","event","chainedHandler","before","guardedClick","disabled","onActivate","isDisabled","dispose","preventDefault","stopImmediatePropagation","ActionButton","props","local","rest","href","busyStatus","tooltipOpen","setTooltipOpen","tooltipId","deferred","enabled","onPointerEnter","onFocus","tooltipSuppression","setTooltipSuppression","forwarded","element","popupOpen","getAttribute","buttonProps","class","variant","size","touchTarget","type","tabIndex","as","undefined","role","ref","button","callerRef","onClick","detail","onPointerLeave","onBlur","onClickCapture","contents","_$createComponent","when","children","label","_$memo","fallback","_$mergeProps","_el$","_tmpl$","_$spread","_$insert","armed","tooltipSlot","placement","open","onOpenChange","Target","id","icon","length","_el$3","_tmpl$3","each","key","_el$2","_tmpl$2"],"sources":["../../../../src/components/composites/action-button/action-button.tsx"],"sourcesContent":["import {\n For,\n Show,\n createRoot,\n mergeProps,\n createSignal,\n createUniqueId,\n splitProps,\n type ComponentProps,\n type JSX,\n type ValidComponent,\n} from 'solid-js'\nimport { callHandler } from '#lib/events'\nimport { Polymorphic } from '@kobalte/core/polymorphic'\nimport { buttonVariants, type ButtonProps } from '../../ui/button'\nimport { cn } from '#lib/utils'\nimport { Kbd, KbdGroup } from '../../ui/kbd'\nimport { Spinner } from '../../ui/spinner'\nimport { createDeferredTooltip, Tooltip, TooltipContent, TooltipTrigger } from '../../ui/tooltip'\n\n/**\n * ActionButton.\n *\n * A Button with optional explanatory tooltip and busy feedback. Use it for a\n * simple action that needs these states; actions with product-specific rules\n * should compose Button directly.\n *\n * The tooltip trigger is the polymorphic Button itself; the tooltip mounts on\n * its first hover or keyboard focus (see createDeferredTooltip). A disabled native\n * control cannot receive pointer or keyboard events. When a tooltip is set,\n * disabled actions therefore use focusable `aria-disabled` semantics and guard\n * activation; without a tooltip, native buttons retain native disabling.\n * Custom polymorphic components must forward aria, event, and href props for\n * these guarantees to apply.\n */\nexport type ActionButtonProps<T extends ValidComponent = 'button'> = ButtonProps<T> & {\n /** A short explanation, also shown on keyboard focus. The Button still needs its own name. */\n tooltip?: string\n /** Placement of the explanation; icon actions live in bars, so it defaults below the control. */\n tooltipSide?: 'top' | 'right' | 'bottom' | 'left'\n /**\n * A leading icon repeated inside the explanation, forwarded to the shared\n * tooltip's `icon` slot so a bar of icon actions gets the icon+label tip\n * without hand-composing Button and Tooltip. Decorative by contract: the tip\n * is never the accessible name, so the icon must not carry meaning the label\n * lacks. Size it by leaving the svg bare; the slot fixes it to control size.\n */\n tooltipIcon?: JSX.Element\n /**\n * The action's keyboard chord, one entry per key (`['⇧', '⌘', 'D']`), drawn as keys after the\n * explanation. Decorative like the rest of the tip: put the parseable chord on the control\n * itself with `aria-keyshortcuts`.\n */\n tooltipShortcut?: readonly string[]\n /** Disables the action and announces the busy label through a polite status region. */\n busy?: boolean\n /** The activity announced while busy. The Button's accessible name stays unchanged. */\n busyLabel?: string\n}\n\ntype ForwardedHandler = JSX.EventHandlerUnion<Element, Event> | undefined\ntype ForwardedEvent = Event & { currentTarget: Element; target: Element }\n\nfunction invokeHandler(handler: unknown, event: Event) {\n callHandler(handler as ForwardedHandler, event as ForwardedEvent)\n}\n\nfunction chainedHandler(handler: () => unknown, before: (event: Event) => void) {\n return (event: Event) => {\n before(event)\n invokeHandler(handler(), event)\n }\n}\n\nfunction guardedClick(\n handler: () => unknown,\n disabled: () => boolean,\n onActivate: (event: MouseEvent) => void = () => {}\n) {\n return (event: MouseEvent) => {\n // A polymorphic trigger can provide a getter that creates reactive work.\n // Event callbacks have no owner, so dispose any such work after the read.\n const isDisabled = createRoot((dispose) => {\n try {\n return disabled()\n } finally {\n dispose()\n }\n })\n if (isDisabled) {\n event.preventDefault()\n event.stopImmediatePropagation()\n return\n }\n\n onActivate(event)\n invokeHandler(handler(), event)\n }\n}\n\nexport function ActionButton<T extends ValidComponent = 'button'>(props: ActionButtonProps<T>) {\n const [local, rest] = splitProps(props as ActionButtonProps & { href?: string }, [\n 'as',\n 'variant',\n 'size',\n 'touchTarget',\n 'class',\n 'children',\n 'disabled',\n 'aria-busy',\n 'tooltip',\n 'tooltipSide',\n 'tooltipIcon',\n 'tooltipShortcut',\n 'busy',\n 'busyLabel',\n // Split, not read from `rest`: mergeProps falls back to an earlier source when a\n // getter returns undefined, so a disabled link could not drop its href otherwise.\n 'href',\n ])\n const busy = () => local.busy ?? false\n const disabled = () => busy() || !!local.disabled\n const busyStatus = () => local.busyLabel ?? 'Working'\n const [tooltipOpen, setTooltipOpen] = createSignal(false)\n const tooltipId = `action-button-tooltip-${createUniqueId()}`\n // The tooltip mounts on the first hover or keyboard focus; until then the\n // button renders alone (see createDeferredTooltip).\n const deferred = createDeferredTooltip({\n enabled: () => !!local.tooltip,\n onPointerEnter: () => rest.onPointerEnter,\n onFocus: () => rest.onFocus,\n })\n const [tooltipSuppression, setTooltipSuppression] = createSignal<'pointer' | 'focus' | null>(null)\n const forwarded = rest as Record<string, unknown>\n let element: HTMLElement | undefined\n // A trigger whose popup is open (a menu, a sheet) names itself already; its tip would sit over\n // that popup and take the first Escape meant for it.\n const popupOpen = () => element?.getAttribute('aria-expanded') === 'true'\n\n // One props object for the life of the button. Each value is a getter, so it stays\n // reactive per key, and the handlers are created once and read the caller's handler\n // when they run. (Spreading a function's result instead compiles to a memo that\n // rebuilds every key and handler whenever any prop it reads changes.)\n const buttonProps = mergeProps(rest, {\n // The inner Button would otherwise announce itself as a plain `button`; a\n // caller's own slot still wins.\n get 'data-slot'() {\n return (forwarded['data-slot'] as string | undefined) ?? 'action-button'\n },\n // Button's own class, computed here: rendering Polymorphic directly saves a\n // component layer and a splitProps over every key, on every action button.\n get class() {\n return cn(\n buttonVariants({\n variant: local.variant,\n size: local.size,\n touchTarget: local.touchTarget,\n }),\n local.class,\n local.tooltip && disabled() && 'aria-disabled:pointer-events-auto'\n )\n },\n // As Button sets it: a custom component that renders a native button inside a\n // form must not submit by accident. A caller's own type still wins.\n get type() {\n return (forwarded.type as string | undefined) ?? 'button'\n },\n get disabled() {\n return disabled() && !local.tooltip\n },\n get 'aria-disabled'() {\n return disabled() ? true : rest['aria-disabled']\n },\n // Make tooltip-bearing native controls explicit tab stops in WebKit configurations that\n // otherwise skip implicit button stops. A caller's tabIndex remains authoritative.\n get tabIndex() {\n return (\n rest.tabIndex ??\n (local.as === 'a' && disabled() ? (local.tooltip ? 0 : -1) : local.tooltip ? 0 : undefined)\n )\n },\n get role() {\n return local.as === 'a' && disabled() ? 'link' : rest.role\n },\n get href() {\n return local.as === 'a' && disabled() ? undefined : local.href\n },\n get 'aria-busy'() {\n return busy() || local['aria-busy']\n },\n get 'aria-describedby'() {\n return (\n (forwarded['aria-describedby'] as string | undefined) ??\n (local.tooltip && tooltipOpen() ? tooltipId : undefined)\n )\n },\n ref: (button: HTMLElement) => {\n element = button\n deferred.ref(button)\n const callerRef = forwarded.ref\n if (typeof callerRef === 'function') callerRef(button)\n },\n onPointerEnter: deferred.onPointerEnter,\n onFocus: deferred.onFocus,\n onClick: guardedClick(\n () => rest.onClick,\n disabled,\n (event) => {\n if (!local.tooltip) return\n setTooltipSuppression(event.detail > 0 ? 'pointer' : 'focus')\n setTooltipOpen(false)\n }\n ),\n onPointerLeave: chainedHandler(\n () => rest.onPointerLeave,\n () => {\n if (tooltipSuppression() === 'pointer') setTooltipSuppression(null)\n }\n ),\n onBlur: chainedHandler(\n () => rest.onBlur,\n () => {\n if (tooltipSuppression() === 'focus') setTooltipSuppression(null)\n }\n ),\n onClickCapture: forwarded.onClickCapture\n ? guardedClick(() => forwarded.onClickCapture, disabled)\n : undefined,\n // Only when the caller uses them: each is a native listener on every button.\n 'on:click': forwarded['on:click']\n ? guardedClick(() => forwarded['on:click'], disabled)\n : undefined,\n 'oncapture:click': forwarded['oncapture:click']\n ? guardedClick(() => forwarded['oncapture:click'], disabled)\n : undefined,\n })\n\n const contents = () => (\n <>\n <Show when={busy()}>\n <Spinner size=\"sm\" label={false} aria-hidden=\"true\" data-icon=\"inline-start\" />\n </Show>\n {local.children}\n </>\n )\n\n return (\n <>\n {/* A native button, the common case, is written directly: Polymorphic goes\n through Dynamic, a memo and a component per button. */}\n <Show\n when={local.as === undefined || local.as === 'button'}\n fallback={\n <Polymorphic as={local.as} {...(buttonProps as ComponentProps<'button'>)}>\n {contents()}\n </Polymorphic>\n }\n >\n <button {...(buttonProps as ComponentProps<'button'>)}>{contents()}</button>\n </Show>\n <Show when={deferred.armed() && local.tooltip}>\n {(tooltipSlot) => (\n <Tooltip\n placement={local.tooltipSide ?? 'bottom'}\n open={tooltipOpen()}\n onOpenChange={(open) => {\n if (open && (tooltipSuppression() || popupOpen())) return\n setTooltipOpen(open)\n }}\n >\n <TooltipTrigger as={deferred.Target} />\n <TooltipContent id={tooltipId} icon={local.tooltipIcon}>\n <Show when={local.tooltipShortcut?.length} fallback={tooltipSlot()}>\n <span class=\"inline-flex items-center gap-2 whitespace-nowrap\">\n {tooltipSlot()}\n <KbdGroup data-slot=\"action-button-shortcut\" aria-hidden=\"true\">\n <For each={local.tooltipShortcut}>{(key) => <Kbd>{key}</Kbd>}</For>\n </KbdGroup>\n </span>\n </Show>\n </TooltipContent>\n </Tooltip>\n )}\n </Show>\n <Show when={busy()}>\n <span role=\"status\" aria-live=\"polite\" class=\"visually-hidden\">\n {busyStatus()}\n </span>\n </Show>\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AA+DA,SAASwB,cAAcC,SAAkBC,OAAc;CACrDnB,YAAYkB,SAA6BC,KAAuB;AAClE;AAEA,SAASC,eAAeF,SAAwBG,QAAgC;CAC9E,QAAQF,UAAiB;EACvBE,OAAOF,KAAK;EACZF,cAAcC,QAAQ,GAAGC,KAAK;CAChC;AACF;AA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Y;IAAC;IACnB+C,eAAeD,SAAS;KACtB,IAAIA,SAASvC,mBAAmB,KAAKI,UAAU,IAAI;KACnDV,eAAe6C,IAAI;IACrB;IAAC,IAAAZ,WAAA;KAAA,OAAA,CAAAF,gBAEAzD,gBAAc,EAAA,IAAC6C,KAAE;MAAA,OAAEjB,SAAS6C;KAAM,EAAA,CAAA,GAAAhB,gBAClC1D,gBAAc;MAAC2E,IAAI/C;MAAS,IAAEgD,OAAI;OAAA,OAAEtD,MAAMlB;MAAW;MAAA,IAAAwD,WAAA;OAAA,OAAAF,gBACnDzE,MAAI;QAAA,IAAC0E,OAAI;SAAA,OAAErC,MAAMjB,iBAAiBwE;QAAM;QAAA,IAAEd,WAAQ;SAAA,OAAEO,YAAY;QAAC;QAAA,IAAAV,WAAA;SAAA,IAAAkB,QAAAC,QAAA;SAAAX,OAAAU,OAE7DR,aAAW,IAAA;SAAAF,OAAAU,OAAApB,gBACX9D,UAAQ;UAAA,aAAA;UAAA,eAAA;UAAA,IAAAgE,WAAA;WAAA,OAAAF,gBACN1E,KAAG;YAAA,IAACgG,OAAI;aAAA,OAAE1D,MAAMjB;YAAe;YAAAuD,WAAIqB,QAAGvB,gBAAM/D,KAAG,EAAAiE,UAAEqB,IAAG,CAAA;WAAO,CAAA;UAAA;SAAA,CAAA,GAAA,IAAA;SAAA,OAAAH;QAAA;OAAA,CAAA;MAAA;KAAA,CAAA,CAAA;IAAA;GAAA,CAAA;EAMvE,CAAA;EAAApB,gBAEFzE,MAAI;GAAA,IAAC0E,OAAI;IAAA,OAAErD,KAAK;GAAC;GAAA,IAAAsD,WAAA;IAAA,IAAAsB,QAAAC,QAAA;IAAAf,OAAAc,OAEbzD,UAAU;IAAA,OAAAyD;GAAA;EAAA,CAAA;CAAA;AAKrB"}
|
|
@@ -132,6 +132,10 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
|
|
|
132
132
|
})
|
|
133
133
|
const [tooltipSuppression, setTooltipSuppression] = createSignal<'pointer' | 'focus' | null>(null)
|
|
134
134
|
const forwarded = rest as Record<string, unknown>
|
|
135
|
+
let element: HTMLElement | undefined
|
|
136
|
+
// A trigger whose popup is open (a menu, a sheet) names itself already; its tip would sit over
|
|
137
|
+
// that popup and take the first Escape meant for it.
|
|
138
|
+
const popupOpen = () => element?.getAttribute('aria-expanded') === 'true'
|
|
135
139
|
|
|
136
140
|
// One props object for the life of the button. Each value is a getter, so it stays
|
|
137
141
|
// reactive per key, and the handlers are created once and read the caller's handler
|
|
@@ -190,10 +194,11 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
|
|
|
190
194
|
(local.tooltip && tooltipOpen() ? tooltipId : undefined)
|
|
191
195
|
)
|
|
192
196
|
},
|
|
193
|
-
ref: (
|
|
194
|
-
|
|
197
|
+
ref: (button: HTMLElement) => {
|
|
198
|
+
element = button
|
|
199
|
+
deferred.ref(button)
|
|
195
200
|
const callerRef = forwarded.ref
|
|
196
|
-
if (typeof callerRef === 'function') callerRef(
|
|
201
|
+
if (typeof callerRef === 'function') callerRef(button)
|
|
197
202
|
},
|
|
198
203
|
onPointerEnter: deferred.onPointerEnter,
|
|
199
204
|
onFocus: deferred.onFocus,
|
|
@@ -259,7 +264,7 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
|
|
|
259
264
|
placement={local.tooltipSide ?? 'bottom'}
|
|
260
265
|
open={tooltipOpen()}
|
|
261
266
|
onOpenChange={(open) => {
|
|
262
|
-
if (open && tooltipSuppression()) return
|
|
267
|
+
if (open && (tooltipSuppression() || popupOpen())) return
|
|
263
268
|
setTooltipOpen(open)
|
|
264
269
|
}}
|
|
265
270
|
>
|
package/package.json
CHANGED
|
@@ -132,6 +132,10 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
|
|
|
132
132
|
})
|
|
133
133
|
const [tooltipSuppression, setTooltipSuppression] = createSignal<'pointer' | 'focus' | null>(null)
|
|
134
134
|
const forwarded = rest as Record<string, unknown>
|
|
135
|
+
let element: HTMLElement | undefined
|
|
136
|
+
// A trigger whose popup is open (a menu, a sheet) names itself already; its tip would sit over
|
|
137
|
+
// that popup and take the first Escape meant for it.
|
|
138
|
+
const popupOpen = () => element?.getAttribute('aria-expanded') === 'true'
|
|
135
139
|
|
|
136
140
|
// One props object for the life of the button. Each value is a getter, so it stays
|
|
137
141
|
// reactive per key, and the handlers are created once and read the caller's handler
|
|
@@ -190,10 +194,11 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
|
|
|
190
194
|
(local.tooltip && tooltipOpen() ? tooltipId : undefined)
|
|
191
195
|
)
|
|
192
196
|
},
|
|
193
|
-
ref: (
|
|
194
|
-
|
|
197
|
+
ref: (button: HTMLElement) => {
|
|
198
|
+
element = button
|
|
199
|
+
deferred.ref(button)
|
|
195
200
|
const callerRef = forwarded.ref
|
|
196
|
-
if (typeof callerRef === 'function') callerRef(
|
|
201
|
+
if (typeof callerRef === 'function') callerRef(button)
|
|
197
202
|
},
|
|
198
203
|
onPointerEnter: deferred.onPointerEnter,
|
|
199
204
|
onFocus: deferred.onFocus,
|
|
@@ -259,7 +264,7 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
|
|
|
259
264
|
placement={local.tooltipSide ?? 'bottom'}
|
|
260
265
|
open={tooltipOpen()}
|
|
261
266
|
onOpenChange={(open) => {
|
|
262
|
-
if (open && tooltipSuppression()) return
|
|
267
|
+
if (open && (tooltipSuppression() || popupOpen())) return
|
|
263
268
|
setTooltipOpen(open)
|
|
264
269
|
}}
|
|
265
270
|
>
|