@adea-ai/ui 0.159.5 → 0.159.7

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.
@@ -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,eA+L5F"}
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;AAkDD,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,GAAG,QAAQ,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,eAiM5F"}
@@ -21,15 +21,23 @@ function chainedHandler(handler, before) {
21
21
  invokeHandler(handler(), event);
22
22
  };
23
23
  }
24
+ /**
25
+ * Reads props from an event handler. A handler has no owner, and a caller's conditional prop
26
+ * (`tooltip={open() ? 'Close' : 'Open'}`) compiles to a getter that creates a memo on each read, so
27
+ * read it under a root that is disposed right after.
28
+ */
29
+ function readOwned(read) {
30
+ return createRoot((dispose) => {
31
+ try {
32
+ return read();
33
+ } finally {
34
+ dispose();
35
+ }
36
+ });
37
+ }
24
38
  function guardedClick(handler, disabled, onActivate = () => {}) {
25
39
  return (event) => {
26
- if (createRoot((dispose) => {
27
- try {
28
- return disabled();
29
- } finally {
30
- dispose();
31
- }
32
- })) {
40
+ if (readOwned(disabled)) {
33
41
  event.preventDefault();
34
42
  event.stopImmediatePropagation();
35
43
  return;
@@ -57,12 +65,13 @@ function ActionButton(props) {
57
65
  "href"
58
66
  ]);
59
67
  const busy = () => local.busy ?? false;
68
+ const hasTooltip = () => readOwned(() => !!local.tooltip);
60
69
  const disabled = () => busy() || !!local.disabled;
61
70
  const busyStatus = () => local.busyLabel ?? "Working";
62
71
  const [tooltipOpen, setTooltipOpen] = createSignal(false);
63
72
  const tooltipId = `action-button-tooltip-${createUniqueId()}`;
64
73
  const deferred = createDeferredTooltip({
65
- enabled: () => !!local.tooltip,
74
+ enabled: hasTooltip,
66
75
  onPointerEnter: () => rest.onPointerEnter,
67
76
  onFocus: () => rest.onFocus
68
77
  });
@@ -114,7 +123,7 @@ function ActionButton(props) {
114
123
  onPointerEnter: deferred.onPointerEnter,
115
124
  onFocus: deferred.onFocus,
116
125
  onClick: guardedClick(() => rest.onClick, disabled, (event) => {
117
- if (!local.tooltip) return;
126
+ if (!hasTooltip()) return;
118
127
  setTooltipSuppression(event.detail > 0 ? "pointer" : "focus");
119
128
  setTooltipOpen(false);
120
129
  }),
@@ -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","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;AAEA,SAASG,aACPJ,SACAK,UACAC,mBAAgD,CAAC,GACjD;CACA,QAAQL,UAAsB;EAU5B,IAPmBxB,YAAY+B,YAAY;GACzC,IAAI;IACF,OAAOH,SAAS;GAClB,UAAU;IACRG,QAAQ;GACV;EACF,CACID,GAAY;GACdN,MAAMQ,eAAe;GACrBR,MAAMS,yBAAyB;GAC/B;EACF;EAEAJ,WAAWL,KAAK;EAChBF,cAAcC,QAAQ,GAAGC,KAAK;CAChC;AACF;AAEA,SAAgBU,aAAkDC,OAA6B;CAC7F,MAAM,CAACC,OAAOC,QAAQjC,WAAW+B,OAAgD;EAC/E;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;CAAM,CACP;CACD,MAAMf,aAAagB,MAAMhB,QAAQ;CACjC,MAAMQ,iBAAiBR,KAAK,KAAK,CAAC,CAACgB,MAAMR;CACzC,MAAMW,mBAAmBH,MAAMf,aAAa;CAC5C,MAAM,CAACmB,aAAaC,kBAAkBvC,aAAa,KAAK;CACxD,MAAMwC,YAAY,yBAAyBvC,eAAe;CAG1D,MAAMwC,WAAW/B,sBAAsB;EACrCgC,eAAe,CAAC,CAACR,MAAMpB;EACvB6B,sBAAsBR,KAAKQ;EAC3BC,eAAeT,KAAKS;CACtB,CAAC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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"}
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","readOwned","read","dispose","guardedClick","disabled","onActivate","isDisabled","preventDefault","stopImmediatePropagation","ActionButton","props","local","rest","href","hasTooltip","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\n/**\n * Reads props from an event handler. A handler has no owner, and a caller's conditional prop\n * (`tooltip={open() ? 'Close' : 'Open'}`) compiles to a getter that creates a memo on each read, so\n * read it under a root that is disposed right after.\n */\nfunction readOwned<T>(read: () => T): T {\n return createRoot((dispose) => {\n try {\n return read()\n } finally {\n dispose()\n }\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 const isDisabled = readOwned(disabled)\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 // Also read from the pointer, focus and click handlers, so read owned there.\n const hasTooltip = () => readOwned(() => !!local.tooltip)\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: hasTooltip,\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 (!hasTooltip()) 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;;;;;;AAOA,SAASG,UAAaC,MAAkB;CACtC,OAAO5B,YAAY6B,YAAY;EAC7B,IAAI;GACF,OAAOD,KAAK;EACd,UAAU;GACRC,QAAQ;EACV;CACF,CAAC;AACH;AAEA,SAASC,aACPP,SACAQ,UACAC,mBAAgD,CAAC,GACjD;CACA,QAAQR,UAAsB;EAG5B,IADmBG,UAAUI,QACzBE,GAAY;GACdT,MAAMU,eAAe;GACrBV,MAAMW,yBAAyB;GAC/B;EACF;EAEAH,WAAWR,KAAK;EAChBF,cAAcC,QAAQ,GAAGC,KAAK;CAChC;AACF;AAEA,SAAgBY,aAAkDC,OAA6B;CAC7F,MAAM,CAACC,OAAOC,QAAQnC,WAAWiC,OAAgD;EAC/E;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;CAAM,CACP;CACD,MAAMjB,aAAakB,MAAMlB,QAAQ;CAEjC,MAAMqB,mBAAmBd,gBAAgB,CAAC,CAACW,MAAMtB,OAAO;CACxD,MAAMe,iBAAiBX,KAAK,KAAK,CAAC,CAACkB,MAAMP;CACzC,MAAMW,mBAAmBJ,MAAMjB,aAAa;CAC5C,MAAM,CAACsB,aAAaC,kBAAkB1C,aAAa,KAAK;CACxD,MAAM2C,YAAY,yBAAy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AMnB;YAAe;YAAA0D,WAAIqB,QAAGvB,gBAAMlE,KAAG,EAAAoE,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,gBAEF5E,MAAI;GAAA,IAAC6E,OAAI;IAAA,OAAExD,KAAK;GAAC;GAAA,IAAAyD,WAAA;IAAA,IAAAsB,QAAAC,QAAA;IAAAf,OAAAc,OAEbzD,UAAU;IAAA,OAAAyD;GAAA;EAAA,CAAA;CAAA;AAKrB"}
@@ -72,6 +72,21 @@ function chainedHandler(handler: () => unknown, before: (event: Event) => void)
72
72
  }
73
73
  }
74
74
 
75
+ /**
76
+ * Reads props from an event handler. A handler has no owner, and a caller's conditional prop
77
+ * (`tooltip={open() ? 'Close' : 'Open'}`) compiles to a getter that creates a memo on each read, so
78
+ * read it under a root that is disposed right after.
79
+ */
80
+ function readOwned<T>(read: () => T): T {
81
+ return createRoot((dispose) => {
82
+ try {
83
+ return read()
84
+ } finally {
85
+ dispose()
86
+ }
87
+ })
88
+ }
89
+
75
90
  function guardedClick(
76
91
  handler: () => unknown,
77
92
  disabled: () => boolean,
@@ -79,14 +94,7 @@ function guardedClick(
79
94
  ) {
80
95
  return (event: MouseEvent) => {
81
96
  // A polymorphic trigger can provide a getter that creates reactive work.
82
- // Event callbacks have no owner, so dispose any such work after the read.
83
- const isDisabled = createRoot((dispose) => {
84
- try {
85
- return disabled()
86
- } finally {
87
- dispose()
88
- }
89
- })
97
+ const isDisabled = readOwned(disabled)
90
98
  if (isDisabled) {
91
99
  event.preventDefault()
92
100
  event.stopImmediatePropagation()
@@ -119,6 +127,8 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
119
127
  'href',
120
128
  ])
121
129
  const busy = () => local.busy ?? false
130
+ // Also read from the pointer, focus and click handlers, so read owned there.
131
+ const hasTooltip = () => readOwned(() => !!local.tooltip)
122
132
  const disabled = () => busy() || !!local.disabled
123
133
  const busyStatus = () => local.busyLabel ?? 'Working'
124
134
  const [tooltipOpen, setTooltipOpen] = createSignal(false)
@@ -126,7 +136,7 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
126
136
  // The tooltip mounts on the first hover or keyboard focus; until then the
127
137
  // button renders alone (see createDeferredTooltip).
128
138
  const deferred = createDeferredTooltip({
129
- enabled: () => !!local.tooltip,
139
+ enabled: hasTooltip,
130
140
  onPointerEnter: () => rest.onPointerEnter,
131
141
  onFocus: () => rest.onFocus,
132
142
  })
@@ -206,7 +216,7 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
206
216
  () => rest.onClick,
207
217
  disabled,
208
218
  (event) => {
209
- if (!local.tooltip) return
219
+ if (!hasTooltip()) return
210
220
  setTooltipSuppression(event.detail > 0 ? 'pointer' : 'focus')
211
221
  setTooltipOpen(false)
212
222
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/ui",
3
- "version": "0.159.5",
3
+ "version": "0.159.7",
4
4
  "description": "The Adea design system: Kobalte-backed Solid components, semantic OKLCH tokens, and the app-shell layout primitives shared by Adea and Cortana.",
5
5
  "keywords": [
6
6
  "adea",
@@ -72,6 +72,21 @@ function chainedHandler(handler: () => unknown, before: (event: Event) => void)
72
72
  }
73
73
  }
74
74
 
75
+ /**
76
+ * Reads props from an event handler. A handler has no owner, and a caller's conditional prop
77
+ * (`tooltip={open() ? 'Close' : 'Open'}`) compiles to a getter that creates a memo on each read, so
78
+ * read it under a root that is disposed right after.
79
+ */
80
+ function readOwned<T>(read: () => T): T {
81
+ return createRoot((dispose) => {
82
+ try {
83
+ return read()
84
+ } finally {
85
+ dispose()
86
+ }
87
+ })
88
+ }
89
+
75
90
  function guardedClick(
76
91
  handler: () => unknown,
77
92
  disabled: () => boolean,
@@ -79,14 +94,7 @@ function guardedClick(
79
94
  ) {
80
95
  return (event: MouseEvent) => {
81
96
  // A polymorphic trigger can provide a getter that creates reactive work.
82
- // Event callbacks have no owner, so dispose any such work after the read.
83
- const isDisabled = createRoot((dispose) => {
84
- try {
85
- return disabled()
86
- } finally {
87
- dispose()
88
- }
89
- })
97
+ const isDisabled = readOwned(disabled)
90
98
  if (isDisabled) {
91
99
  event.preventDefault()
92
100
  event.stopImmediatePropagation()
@@ -119,6 +127,8 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
119
127
  'href',
120
128
  ])
121
129
  const busy = () => local.busy ?? false
130
+ // Also read from the pointer, focus and click handlers, so read owned there.
131
+ const hasTooltip = () => readOwned(() => !!local.tooltip)
122
132
  const disabled = () => busy() || !!local.disabled
123
133
  const busyStatus = () => local.busyLabel ?? 'Working'
124
134
  const [tooltipOpen, setTooltipOpen] = createSignal(false)
@@ -126,7 +136,7 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
126
136
  // The tooltip mounts on the first hover or keyboard focus; until then the
127
137
  // button renders alone (see createDeferredTooltip).
128
138
  const deferred = createDeferredTooltip({
129
- enabled: () => !!local.tooltip,
139
+ enabled: hasTooltip,
130
140
  onPointerEnter: () => rest.onPointerEnter,
131
141
  onFocus: () => rest.onFocus,
132
142
  })
@@ -206,7 +216,7 @@ export function ActionButton<T extends ValidComponent = 'button'>(props: ActionB
206
216
  () => rest.onClick,
207
217
  disabled,
208
218
  (event) => {
209
- if (!local.tooltip) return
219
+ if (!hasTooltip()) return
210
220
  setTooltipSuppression(event.detail > 0 ? 'pointer' : 'focus')
211
221
  setTooltipOpen(false)
212
222
  }