@sanity/ui 4.4.2 → 4.4.4

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.
Files changed (47) hide show
  1. package/dist/{arrow-A3jQ7LS0.js → arrow-MMVAW3Ew.js} +2 -2
  2. package/dist/{arrow-A3jQ7LS0.js.map → arrow-MMVAW3Ew.js.map} +1 -1
  3. package/dist/autocomplete.js +5 -5
  4. package/dist/breadcrumbs.js +4 -4
  5. package/dist/{button-dhq4ViVg.js → button-Bp0udHV9.js} +50 -47
  6. package/dist/button-Bp0udHV9.js.map +1 -0
  7. package/dist/button-dnqMFkWg.d.ts.map +1 -1
  8. package/dist/code.d.ts.map +1 -1
  9. package/dist/code.js +12 -6
  10. package/dist/code.js.map +1 -1
  11. package/dist/{flex-BqQXaSxS.js → flex-ohP2jG9d.js} +2 -2
  12. package/dist/{flex-BqQXaSxS.js.map → flex-ohP2jG9d.js.map} +1 -1
  13. package/dist/{grid-Bpb2bIJ6.js → grid-D-gOpN8z.js} +2 -2
  14. package/dist/{grid-Bpb2bIJ6.js.map → grid-D-gOpN8z.js.map} +1 -1
  15. package/dist/{hotkeys-Caqg1W-_.js → hotkeys-BPJuQ-gO.js} +9 -10
  16. package/dist/{hotkeys-Caqg1W-_.js.map → hotkeys-BPJuQ-gO.js.map} +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +157 -127
  19. package/dist/index.js.map +1 -1
  20. package/dist/{layer-AWzYcY_j.js → layer-DP8gT1ex.js} +2 -2
  21. package/dist/{layer-AWzYcY_j.js.map → layer-DP8gT1ex.js.map} +1 -1
  22. package/dist/menu.d.ts +3 -3
  23. package/dist/menu.js +30 -19
  24. package/dist/menu.js.map +1 -1
  25. package/dist/{popover-CEDyHcBi.js → popover-BVbv1K3z.js} +4 -4
  26. package/dist/{popover-CEDyHcBi.js.map → popover-BVbv1K3z.js.map} +1 -1
  27. package/dist/popover.js +1 -1
  28. package/dist/responsiveFont-Cyvxxz-G.js +81 -0
  29. package/dist/responsiveFont-Cyvxxz-G.js.map +1 -0
  30. package/dist/{stack-Cv-WM-7p.js → stack-CPdFknrG.js} +22 -16
  31. package/dist/stack-CPdFknrG.js.map +1 -0
  32. package/dist/styles.css +137 -16
  33. package/dist/{textInput-Ddxi4mkC.js → textInput-CTqkq5UQ.js} +38 -17
  34. package/dist/textInput-CTqkq5UQ.js.map +1 -0
  35. package/dist/toast.js +5 -5
  36. package/dist/tooltip.js +3 -3
  37. package/dist/{useLayer-B0i19TTM.js → useLayer-D_TnC6On.js} +43 -28
  38. package/dist/useLayer-D_TnC6On.js.map +1 -0
  39. package/package.json +1 -1
  40. package/dist/button-dhq4ViVg.js.map +0 -1
  41. package/dist/codeFontStyle-B-bhR3hF.js +0 -11
  42. package/dist/codeFontStyle-B-bhR3hF.js.map +0 -1
  43. package/dist/responsiveFont-B08q0jwm.js +0 -57
  44. package/dist/responsiveFont-B08q0jwm.js.map +0 -1
  45. package/dist/stack-Cv-WM-7p.js.map +0 -1
  46. package/dist/textInput-Ddxi4mkC.js.map +0 -1
  47. package/dist/useLayer-B0i19TTM.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { c as EMPTY_RECORD } from "./helpers-XThPpWje.js";
2
2
  import { a as isHTMLElement, n as containsOrEqualsElement } from "./element-BYgCE_iK.js";
3
- import { n as LayerProvider, t as useLayer } from "./useLayer-B0i19TTM.js";
3
+ import { n as LayerProvider, t as useLayer } from "./useLayer-D_TnC6On.js";
4
4
  import { c } from "react/compiler-runtime";
5
5
  import { clsx } from "clsx/lite";
6
6
  import { useEffect, useImperativeHandle, useRef } from "react";
@@ -58,4 +58,4 @@ function Layer(props) {
58
58
  }
59
59
  export { Layer as t };
60
60
 
61
- //# sourceMappingURL=layer-AWzYcY_j.js.map
61
+ //# sourceMappingURL=layer-DP8gT1ex.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layer-AWzYcY_j.js","names":["as = 'div'","style = EMPTY_RECORD","() => ref.current","() => {\n const becameTopLayer = isTopLayerRef.current !== isTopLayer && isTopLayer\n\n if (becameTopLayer) {\n onActivate?.({activeElement: lastFocusedRef.current})\n }\n\n isTopLayerRef.current = isTopLayer\n }","[isTopLayer, onActivate]","(event: FocusEvent<HTMLDivElement, Element>) => {\n // Call the user-provided onFocus handler if any\n onFocus?.(event)\n\n const rootElement = ref.current\n const target = document.activeElement\n\n if (!isTopLayer || !rootElement || !target) return\n\n if (isHTMLElement(target) && containsOrEqualsElement(rootElement, target)) {\n lastFocusedRef.current = target\n }\n }","useCallback(\n // oxlint-disable-next-line no-unnecessary-type-arguments\n (event: FocusEvent<HTMLDivElement, Element>) => {\n // Call the user-provided onFocus handler if any\n onFocus?.(event)\n\n const rootElement = ref.current\n const target = document.activeElement\n\n if (!isTopLayer || !rootElement || !target) return\n\n if (isHTMLElement(target) && containsOrEqualsElement(rootElement, target)) {\n lastFocusedRef.current = target\n }\n },\n [isTopLayer, onFocus],\n )","clsx(layer, className)","{...style, zIndex}","<Component\n data-ui=\"Layer\"\n {...restProps}\n className={clsx(layer, className)}\n onFocus={handleFocus}\n ref={ref}\n style={{...style, zIndex}}\n >\n {children}\n </Component>","zOffset = 1","<LayerChildren {...restProps}>{children}</LayerChildren>","<LayerProvider zOffset={zOffset}>\n <LayerChildren {...restProps}>{children}</LayerChildren>\n </LayerProvider>","_c"],"sources":["../src/core/utils/layer/layer.css.ts","../src/core/utils/layer/layer.tsx"],"sourcesContent":["import {style} from '@vanilla-extract/css'\n\nexport const layer = style({\n position: 'relative',\n})\n","import {clsx} from 'clsx/lite'\nimport {FocusEvent, useCallback, useEffect, useImperativeHandle, useRef} from 'react'\n\nimport {EMPTY_RECORD} from '../../constants'\nimport {containsOrEqualsElement, isHTMLElement} from '../../helpers/element'\nimport {LayerProvider} from './layerProvider'\nimport {useLayer} from './useLayer'\n\nimport {layer} from './layer.css'\n\n/**\n * @public\n */\nexport interface LayerProps {\n as?: React.ElementType | keyof React.JSX.IntrinsicElements\n /** A callback that fires when the layer becomes the top layer when it was not the top layer before. */\n onActivate?: (props: {activeElement: HTMLElement | null}) => void\n zOffset?: number | number[]\n}\n\ninterface LayerChildrenProps {\n as?: React.ElementType | keyof React.JSX.IntrinsicElements\n onActivate?: LayerProps['onActivate']\n}\n\nfunction LayerChildren(props: LayerChildrenProps & Omit<React.HTMLProps<HTMLDivElement>, 'as'>) {\n const {\n as = 'div',\n children,\n className,\n onActivate,\n onFocus,\n ref: forwardedRef,\n style = EMPTY_RECORD,\n ...restProps\n } = props\n const {zIndex, isTopLayer} = useLayer()\n const lastFocusedRef = useRef<HTMLElement | null>(null)\n const ref = useRef<HTMLDivElement | null>(null)\n const isTopLayerRef = useRef<boolean>(isTopLayer)\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current)\n\n // When the layer very first mounts, it will be the top layer, but we don't want to fire\n // the callback in that case. We use a ref to track the previous value of isTopLayer to\n // determine if the layer has become the top layer since the last render.\n useEffect(() => {\n const becameTopLayer = isTopLayerRef.current !== isTopLayer && isTopLayer\n\n if (becameTopLayer) {\n onActivate?.({activeElement: lastFocusedRef.current})\n }\n\n isTopLayerRef.current = isTopLayer\n }, [isTopLayer, onActivate])\n\n const handleFocus = useCallback(\n // oxlint-disable-next-line no-unnecessary-type-arguments\n (event: FocusEvent<HTMLDivElement, Element>) => {\n // Call the user-provided onFocus handler if any\n onFocus?.(event)\n\n const rootElement = ref.current\n const target = document.activeElement\n\n if (!isTopLayer || !rootElement || !target) return\n\n if (isHTMLElement(target) && containsOrEqualsElement(rootElement, target)) {\n lastFocusedRef.current = target\n }\n },\n [isTopLayer, onFocus],\n )\n\n // Rendering the polymorphic `as` needs one concrete element type for JSX to\n // type-check the div-flavored props (the same widening styled-components'\n // `as` prop performed here before).\n // oxlint-disable-next-line no-unsafe-type-assertion\n const Component = as as 'div'\n\n return (\n <Component\n data-ui=\"Layer\"\n {...restProps}\n className={clsx(layer, className)}\n onFocus={handleFocus}\n ref={ref}\n style={{...style, zIndex}}\n >\n {children}\n </Component>\n )\n}\n\n/**\n * @public\n */\nexport function Layer(props: LayerProps & Omit<React.HTMLProps<HTMLDivElement>, 'as'>) {\n const {children, zOffset = 1, ...restProps} = props\n\n return (\n <LayerProvider zOffset={zOffset}>\n <LayerChildren {...restProps}>{children}</LayerChildren>\n </LayerProvider>\n )\n}\n"],"mappings":";;;;;;;;ACyBA,SAAS,cAAc,OAAyE;gBAG5F,UACA,WAGK,cAFL,YACA,SAGG,WAPHA,IAMAC;CAEE,AAAA,EAAA,OAAA,+IATE,CACJ,IAAA,IACA,UACA,WACA,YACA,SACA,KAAK,cACL,OAAA,IACA,GAAA,aACE;CARF,IAAA,KAAA,OAAA,KAAA,IAAK,QAALD,IAMA,QAAA,OAAA,KAAA,IAAQ,eAARC,IAGI,EAAC,QAAQ,eAAc,SAAS,GAChC,iBAAiB,OAA2B,IAAI,GAChD,MAAM,OAA8B,IAAI,GACxC,gBAAgB,OAAgB,UAAU,GAEgCC;CAAhF,oDAAsF,WAAA,IAAI,iCAA1F,oBAAkE,cAAcA,EAAiB;CAKvFC,IAAAA,IAQPC;CARH,AACmD,EAAA,QAAA,cAAA,EAAA,QAG/C,cAJM,WAAM;EAOd,AANuB,cAAc,YAAY,cAAc,cAG7D,aAAa,EAAC,eAAe,eAAe,QAAO,CAAC,GAGtD,cAAc,UAAU;CAC1B,GAAG,KAAA,CAAC,YAAY,UAAU,GAPyB,EAAA,MAAA,YAG/C,EAAA,MAAA,gEAJJ,UAAUD,IAQPC,EAAwB;CAIzBC,IAAAA;CAOO,AAAA,EAAA,QAAA,cAAA,EAAA,QALL,WAFF,MAAC,UAA+C;EAE9C,UAAU,KAAK;EAEf,IAAM,cAAc,IAAI,SAClB,SAAS,SAAS;EAExB,AAAK,cAAe,eAAgB,UAEhC,cAAc,MAAM,KAAK,wBAAwB,aAAa,MAAM,MACtE,eAAe,UAAU;CAE7B,GALO,EAAA,MAAA,YALL,EAAA,MAAA;CAJJ,IAAM,cAAcC,IAsBd,YAAY,IAMHC;CAAY,AAAA,EAAA,QAAA,0BAAZ,KAAA,KAAK,OAAO,SAAS,GAAT,EAAA,MAAA;CAGhBC,IAAAA;CAAI,AAAA,EAAA,QAAA,SAAA,EAAA,QAAO,UAAX,KAAA;EAAC,GAAG;EAAO;CAAM,GAAb,EAAA,MAAA,OAAO,EAAA,MAAA;CANpBC,IAAAA;CADF,OACG,EAAA,QAAA,aAAA,EAAA,QAQE,YAAA,EAAA,QAJQ,eAAA,EAAA,QAFL,aAAA,EAAA,QACOF,MAAAA,EAAAA,QAGJC,MANT,KAAA,oBAAC,WAAD;EACE,WAAQ;EACR,GAAI;EACJ,WAAWD;EACX,SAAS;EACJ;EACL,OAAOC;EAEN;CACQ,CAAA,GATV,EAAA,MAAA,WAQE,EAAA,MAAA,UAJQ,EAAA,MAAA,aAFL,EAAA,MAAA,WACOD,EAAAA,MAAAA,IAGJC,EAAAA,MAAAA,8BANTC;AAWJ;;;;AAKA,SAAgB,MAAM,OAAiE;gBAC9E,UAA0B,WAAhBC;CAA6B,AAAA,EAAA,OAAA,0DAAxC,CAAC,UAAU,SAAA,IAAa,GAAA,aAAgB;CAA7B,IAAA,UAAA,OAAA,KAAA,IAAU,IAAVA,IAIbC;CAA+B,AAAA,EAAA,OAAA,YAAA,EAAA,OAAZ,aAAnB,KAAA,oBAAC,eAAD;EAAe,GAAI;EAAY;CAAwB,CAAA,GAAxB,EAAA,KAAA,UAAZ,EAAA,KAAA;CADrBC,IAAAA;CADF,OAEID,EAAAA,OAAAA,MAAAA,EAAAA,OADsB,WAAxB,KAAA,oBAAC,eAAD;EAAwB;EACtBA,UAAAA;CACa,CAAA,GADbA,EAAAA,KAAAA,IADsB,EAAA,KAAA,iCAAxBC;AAIJ"}
1
+ {"version":3,"file":"layer-DP8gT1ex.js","names":["as = 'div'","style = EMPTY_RECORD","() => ref.current","() => {\n const becameTopLayer = isTopLayerRef.current !== isTopLayer && isTopLayer\n\n if (becameTopLayer) {\n onActivate?.({activeElement: lastFocusedRef.current})\n }\n\n isTopLayerRef.current = isTopLayer\n }","[isTopLayer, onActivate]","(event: FocusEvent<HTMLDivElement, Element>) => {\n // Call the user-provided onFocus handler if any\n onFocus?.(event)\n\n const rootElement = ref.current\n const target = document.activeElement\n\n if (!isTopLayer || !rootElement || !target) return\n\n if (isHTMLElement(target) && containsOrEqualsElement(rootElement, target)) {\n lastFocusedRef.current = target\n }\n }","useCallback(\n // oxlint-disable-next-line no-unnecessary-type-arguments\n (event: FocusEvent<HTMLDivElement, Element>) => {\n // Call the user-provided onFocus handler if any\n onFocus?.(event)\n\n const rootElement = ref.current\n const target = document.activeElement\n\n if (!isTopLayer || !rootElement || !target) return\n\n if (isHTMLElement(target) && containsOrEqualsElement(rootElement, target)) {\n lastFocusedRef.current = target\n }\n },\n [isTopLayer, onFocus],\n )","clsx(layer, className)","{...style, zIndex}","<Component\n data-ui=\"Layer\"\n {...restProps}\n className={clsx(layer, className)}\n onFocus={handleFocus}\n ref={ref}\n style={{...style, zIndex}}\n >\n {children}\n </Component>","zOffset = 1","<LayerChildren {...restProps}>{children}</LayerChildren>","<LayerProvider zOffset={zOffset}>\n <LayerChildren {...restProps}>{children}</LayerChildren>\n </LayerProvider>","_c"],"sources":["../src/core/utils/layer/layer.css.ts","../src/core/utils/layer/layer.tsx"],"sourcesContent":["import {style} from '@vanilla-extract/css'\n\nexport const layer = style({\n position: 'relative',\n})\n","import {clsx} from 'clsx/lite'\nimport {FocusEvent, useCallback, useEffect, useImperativeHandle, useRef} from 'react'\n\nimport {EMPTY_RECORD} from '../../constants'\nimport {containsOrEqualsElement, isHTMLElement} from '../../helpers/element'\nimport {LayerProvider} from './layerProvider'\nimport {useLayer} from './useLayer'\n\nimport {layer} from './layer.css'\n\n/**\n * @public\n */\nexport interface LayerProps {\n as?: React.ElementType | keyof React.JSX.IntrinsicElements\n /** A callback that fires when the layer becomes the top layer when it was not the top layer before. */\n onActivate?: (props: {activeElement: HTMLElement | null}) => void\n zOffset?: number | number[]\n}\n\ninterface LayerChildrenProps {\n as?: React.ElementType | keyof React.JSX.IntrinsicElements\n onActivate?: LayerProps['onActivate']\n}\n\nfunction LayerChildren(props: LayerChildrenProps & Omit<React.HTMLProps<HTMLDivElement>, 'as'>) {\n const {\n as = 'div',\n children,\n className,\n onActivate,\n onFocus,\n ref: forwardedRef,\n style = EMPTY_RECORD,\n ...restProps\n } = props\n const {zIndex, isTopLayer} = useLayer()\n const lastFocusedRef = useRef<HTMLElement | null>(null)\n const ref = useRef<HTMLDivElement | null>(null)\n const isTopLayerRef = useRef<boolean>(isTopLayer)\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current)\n\n // When the layer very first mounts, it will be the top layer, but we don't want to fire\n // the callback in that case. We use a ref to track the previous value of isTopLayer to\n // determine if the layer has become the top layer since the last render.\n useEffect(() => {\n const becameTopLayer = isTopLayerRef.current !== isTopLayer && isTopLayer\n\n if (becameTopLayer) {\n onActivate?.({activeElement: lastFocusedRef.current})\n }\n\n isTopLayerRef.current = isTopLayer\n }, [isTopLayer, onActivate])\n\n const handleFocus = useCallback(\n // oxlint-disable-next-line no-unnecessary-type-arguments\n (event: FocusEvent<HTMLDivElement, Element>) => {\n // Call the user-provided onFocus handler if any\n onFocus?.(event)\n\n const rootElement = ref.current\n const target = document.activeElement\n\n if (!isTopLayer || !rootElement || !target) return\n\n if (isHTMLElement(target) && containsOrEqualsElement(rootElement, target)) {\n lastFocusedRef.current = target\n }\n },\n [isTopLayer, onFocus],\n )\n\n // Rendering the polymorphic `as` needs one concrete element type for JSX to\n // type-check the div-flavored props (the same widening styled-components'\n // `as` prop performed here before).\n // oxlint-disable-next-line no-unsafe-type-assertion\n const Component = as as 'div'\n\n return (\n <Component\n data-ui=\"Layer\"\n {...restProps}\n className={clsx(layer, className)}\n onFocus={handleFocus}\n ref={ref}\n style={{...style, zIndex}}\n >\n {children}\n </Component>\n )\n}\n\n/**\n * @public\n */\nexport function Layer(props: LayerProps & Omit<React.HTMLProps<HTMLDivElement>, 'as'>) {\n const {children, zOffset = 1, ...restProps} = props\n\n return (\n <LayerProvider zOffset={zOffset}>\n <LayerChildren {...restProps}>{children}</LayerChildren>\n </LayerProvider>\n )\n}\n"],"mappings":";;;;;;;;ACyBA,SAAS,cAAc,OAAyE;gBAG5F,UACA,WAGK,cAFL,YACA,SAGG,WAPHA,IAMAC;CAEE,AAAA,EAAA,OAAA,+IATE,CACJ,IAAA,IACA,UACA,WACA,YACA,SACA,KAAK,cACL,OAAA,IACA,GAAA,aACE;CARF,IAAA,KAAA,OAAA,KAAA,IAAK,QAALD,IAMA,QAAA,OAAA,KAAA,IAAQ,eAARC,IAGI,EAAC,QAAQ,eAAc,SAAS,GAChC,iBAAiB,OAA2B,IAAI,GAChD,MAAM,OAA8B,IAAI,GACxC,gBAAgB,OAAgB,UAAU,GAEgCC;CAAhF,oDAAsF,WAAA,IAAI,iCAA1F,oBAAkE,cAAcA,EAAiB;CAKvFC,IAAAA,IAQPC;CARH,AACmD,EAAA,QAAA,cAAA,EAAA,QAG/C,cAJM,WAAM;EAOd,AANuB,cAAc,YAAY,cAAc,cAG7D,aAAa,EAAC,eAAe,eAAe,QAAO,CAAC,GAGtD,cAAc,UAAU;CAC1B,GAAG,KAAA,CAAC,YAAY,UAAU,GAPyB,EAAA,MAAA,YAG/C,EAAA,MAAA,gEAJJ,UAAUD,IAQPC,EAAwB;CAIzBC,IAAAA;CAOO,AAAA,EAAA,QAAA,cAAA,EAAA,QALL,WAFF,MAAC,UAA+C;EAE9C,UAAU,KAAK;EAEf,IAAM,cAAc,IAAI,SAClB,SAAS,SAAS;EAExB,AAAK,cAAe,eAAgB,UAEhC,cAAc,MAAM,KAAK,wBAAwB,aAAa,MAAM,MACtE,eAAe,UAAU;CAE7B,GALO,EAAA,MAAA,YALL,EAAA,MAAA;CAJJ,IAAM,cAAcC,IAsBd,YAAY,IAMHC;CAAY,AAAA,EAAA,QAAA,0BAAZ,KAAA,KAAK,OAAO,SAAS,GAAT,EAAA,MAAA;CAGhBC,IAAAA;CAAI,AAAA,EAAA,QAAA,SAAA,EAAA,QAAO,UAAX,KAAA;EAAC,GAAG;EAAO;CAAM,GAAb,EAAA,MAAA,OAAO,EAAA,MAAA;CANpBC,IAAAA;CADF,OACG,EAAA,QAAA,aAAA,EAAA,QAQE,YAAA,EAAA,QAJQ,eAAA,EAAA,QAFL,aAAA,EAAA,QACOF,MAAAA,EAAAA,QAGJC,MANT,KAAA,oBAAC,WAAD;EACE,WAAQ;EACR,GAAI;EACJ,WAAWD;EACX,SAAS;EACJ;EACL,OAAOC;EAEN;CACQ,CAAA,GATV,EAAA,MAAA,WAQE,EAAA,MAAA,UAJQ,EAAA,MAAA,aAFL,EAAA,MAAA,WACOD,EAAAA,MAAAA,IAGJC,EAAAA,MAAAA,8BANTC;AAWJ;;;;AAKA,SAAgB,MAAM,OAAiE;gBAC9E,UAA0B,WAAhBC;CAA6B,AAAA,EAAA,OAAA,0DAAxC,CAAC,UAAU,SAAA,IAAa,GAAA,aAAgB;CAA7B,IAAA,UAAA,OAAA,KAAA,IAAU,IAAVA,IAIbC;CAA+B,AAAA,EAAA,OAAA,YAAA,EAAA,OAAZ,aAAnB,KAAA,oBAAC,eAAD;EAAe,GAAI;EAAY;CAAwB,CAAA,GAAxB,EAAA,KAAA,UAAZ,EAAA,KAAA;CADrBC,IAAAA;CADF,OAEID,EAAAA,OAAAA,MAAAA,EAAAA,OADsB,WAAxB,KAAA,oBAAC,eAAD;EAAwB;EACtBA,UAAAA;CACa,CAAA,GADbA,EAAAA,KAAAA,IADsB,EAAA,KAAA,iCAAxBC;AAIJ"}
package/dist/menu.d.ts CHANGED
@@ -48,9 +48,9 @@ interface MenuButtonProps {
48
48
  */
49
49
  boundaryElement?: never;
50
50
  /**
51
- * Its `onClick`, `onKeyDown` and `onMouseDown` run before `MenuButton`'s handlers, and calling
52
- * `event.preventDefault()` in them stops `MenuButton` from acting on the event. Enter and Space
53
- * open the menu on `keydown` and don't trigger `onClick`.
51
+ * Its `onClick`, `onKeyDown` and `onMouseDown` run before `MenuButton`'s handlers, which act on
52
+ * the event even when those called `event.preventDefault()`. Disable the button to keep its
53
+ * menu closed. Enter and Space open the menu on `keydown` and don't trigger `onClick`.
54
54
  */
55
55
  button: React.JSX.Element;
56
56
  id: string;
package/dist/menu.js CHANGED
@@ -2,13 +2,13 @@
2
2
  import { n as _getArrayProp } from "./helpers-XThPpWje.js";
3
3
  import { i as isHTMLButtonElement, r as isHTMLAnchorElement } from "./element-BYgCE_iK.js";
4
4
  import { t as getTheme_v2 } from "./getTheme_v2-y09KqtEb.js";
5
- import { d as createGlobalScopedContext, h as _cardColorStyle, l as useRootTheme, r as isRecord, t as useLayer, v as responsiveRadiusStyle, y as Box } from "./useLayer-B0i19TTM.js";
6
- import { t as Flex } from "./flex-BqQXaSxS.js";
7
- import { n as Text, t as Stack } from "./stack-Cv-WM-7p.js";
5
+ import { d as createGlobalScopedContext, h as _cardColorStyle, l as useRootTheme, r as isRecord, t as useLayer, v as responsiveRadiusStyle, y as Box } from "./useLayer-D_TnC6On.js";
6
+ import { t as Flex } from "./flex-ohP2jG9d.js";
7
+ import { n as Text, t as Stack } from "./stack-CPdFknrG.js";
8
8
  import { o as attachRef } from "./getElementRef-BLVMlHTn.js";
9
- import { t as Popover } from "./popover-CEDyHcBi.js";
9
+ import { t as Popover } from "./popover-BVbv1K3z.js";
10
10
  import { t as useClickOutsideEvent } from "./useClickOutsideEvent-CC1zgOmv.js";
11
- import { i as useGlobalKeyDown, t as Hotkeys } from "./hotkeys-Caqg1W-_.js";
11
+ import { i as useGlobalKeyDown, t as Hotkeys } from "./hotkeys-BPJuQ-gO.js";
12
12
  import { c } from "react/compiler-runtime";
13
13
  import { clsx } from "clsx/lite";
14
14
  import { cloneElement, isValidElement, startTransition, useContext, useEffect, useImperativeHandle, useRef, useState } from "react";
@@ -244,7 +244,7 @@ function MenuButton(props) {
244
244
  $[0] === buttonProp?.props ? t1 = $[1] : (t1 = buttonProp?.props ?? {}, $[0] = buttonProp?.props, $[1] = t1);
245
245
  let { onClick: onButtonClick, onKeyDown: onButtonKeyDown, onMouseDown: onButtonMouseDown } = t1, t2;
246
246
  $[2] !== onButtonClick || $[3] !== setOpen ? (t2 = (event) => {
247
- onButtonClick?.(event), !event.defaultPrevented && (setOpen(_temp2), setShouldFocus(null), setButtonElement(event.currentTarget));
247
+ onButtonClick?.(event), setOpen(_temp2), setShouldFocus(null), setButtonElement(event.currentTarget);
248
248
  }, $[2] = onButtonClick, $[3] = setOpen, $[4] = t2) : t2 = $[4];
249
249
  let handleButtonClick = t2, t3;
250
250
  $[5] !== onButtonMouseDown || $[6] !== open ? (t3 = (event_0) => {
@@ -252,7 +252,7 @@ function MenuButton(props) {
252
252
  }, $[5] = onButtonMouseDown, $[6] = open, $[7] = t3) : t3 = $[7];
253
253
  let handleMouseDown = t3, t4;
254
254
  $[8] !== onButtonKeyDown || $[9] !== setOpen ? (t4 = (event_1) => {
255
- onButtonKeyDown?.(event_1), !event_1.defaultPrevented && (event_1.key === "ArrowDown" || event_1.key === "Enter" || event_1.key === " " ? (event_1.preventDefault(), setOpen(!0), setShouldFocus("first"), setButtonElement(event_1.currentTarget)) : event_1.key === "ArrowUp" && (event_1.preventDefault(), setOpen(!0), setShouldFocus("last"), setButtonElement(event_1.currentTarget)));
255
+ onButtonKeyDown?.(event_1), event_1.key === "ArrowDown" || event_1.key === "Enter" || event_1.key === " " ? (event_1.preventDefault(), setOpen(!0), setShouldFocus("first"), setButtonElement(event_1.currentTarget)) : event_1.key === "ArrowUp" && (event_1.preventDefault(), setOpen(!0), setShouldFocus("last"), setButtonElement(event_1.currentTarget));
256
256
  }, $[8] = onButtonKeyDown, $[9] = setOpen, $[10] = t4) : t4 = $[10];
257
257
  let handleButtonKeyDown = t4, t5;
258
258
  $[11] !== buttonElement || $[12] !== menuElements || $[13] !== setOpen ? (t5 = (event_2) => {
@@ -370,21 +370,32 @@ function MenuDividerComponent(props) {
370
370
  /**
371
371
  * @public
372
372
  */
373
- const MenuDivider = MenuDividerComponent;
374
- function selectableBaseStyle() {
375
- return css`background-color:inherit;color:inherit;&[data-as='button']{-webkit-font-smoothing:inherit;appearance:none;outline:none;font:inherit;text-align:inherit;border:0;width:-moz-available;width:-webkit-fill-available;width:stretch;}&[data-as='a']{text-decoration:none;}`;
376
- }
373
+ const MenuDivider = MenuDividerComponent, selectableBaseStyle = css`background-color:var(--card-bg-color);color:var(--card-fg-color);outline:none;&[data-as='button']{-webkit-font-smoothing:inherit;appearance:none;outline:none;font:inherit;text-align:inherit;border:0;width:-moz-available;width:-webkit-fill-available;width:stretch;}&[data-as='a']{text-decoration:none;}`;
377
374
  function selectableColorStyle(props) {
378
- let { $tone } = props, { color, style } = getTheme_v2(props.theme), tone = color.selectable[$tone];
379
- return css`${_cardColorStyle(color, tone.enabled)} background-color:var(--card-bg-color);color:var(--card-fg-color);outline:none;&[data-as='button']{&:disabled{${_cardColorStyle(color, tone.disabled)}}&:not(:disabled){&[aria-pressed='true']{${_cardColorStyle(color, tone.pressed)}}&[data-selected],&[aria-selected='true'] > &{${_cardColorStyle(color, tone.selected)}}@media (hover:hover){&:not([data-selected]){&[data-hovered],&:hover{${_cardColorStyle(color, tone.hovered)}}&:active{${_cardColorStyle(color, tone.pressed)}}}}}}&[data-as='a']{&[data-disabled]{${_cardColorStyle(color, tone.disabled)}}&:not([data-disabled]){&[data-pressed]{${_cardColorStyle(color, tone.pressed)}}&[data-selected]{${_cardColorStyle(color, tone.selected)}}@media (hover:hover){&:not([data-selected]){&[data-hovered],&:hover{${_cardColorStyle(color, tone.hovered)}}&:active{${_cardColorStyle(color, tone.pressed)}}}}}}${style?.card?.root}`;
375
+ let { $tone } = props, { color } = getTheme_v2(props.theme), tone = color.selectable[$tone];
376
+ return css`${_cardColorStyle(color, tone.enabled)} &[data-as='button']:not(:disabled)[aria-pressed='true'],&[data-as='a']:not([data-disabled])[data-pressed]{${_cardColorStyle(color, tone.pressed)}}&[data-as='button']:not(:disabled)[data-selected],&[data-as='button']:not(:disabled)[aria-selected='true'] > &[data-as='button']:not(:disabled),&[data-as='a']:not([data-disabled])[data-selected]{${_cardColorStyle(color, tone.selected)}}@media (hover:hover){&[data-as='button']:not(:disabled):not([data-selected]),&[data-as='a']:not([data-disabled]):not([data-selected]){&[data-hovered],&:hover{${_cardColorStyle(color, tone.hovered)}}&:active{${_cardColorStyle(color, tone.pressed)}}}}`;
380
377
  }
381
- /**
382
- * @internal
383
- */
384
- const Selectable = /* @__PURE__ */ styled(Box).withConfig({
378
+ function selectableDisabledStyle(props) {
379
+ let { color } = getTheme_v2(props.theme);
380
+ return css`&[data-as='button']:disabled,&[data-as='a'][data-disabled]{${_cardColorStyle(color, color.selectable[props.$tone].disabled)}}`;
381
+ }
382
+ function selectableStyle(props) {
383
+ let { style } = getTheme_v2(props.theme);
384
+ return css`${style?.card?.root}`;
385
+ }
386
+ const SelectableBase = styled(Box).withConfig({
387
+ displayName: "SelectableBase",
388
+ componentId: "sc-81zkz-0"
389
+ })`${selectableBaseStyle}`, Selectable = /* @__PURE__ */ styled(/* @__PURE__ */ styled(/* @__PURE__ */ styled(SelectableBase).withConfig({
390
+ displayName: "SelectableColor",
391
+ componentId: "sc-81zkz-1"
392
+ })(selectableColorStyle)).withConfig({
393
+ displayName: "SelectableDisabled",
394
+ componentId: "sc-81zkz-2"
395
+ })(selectableDisabledStyle)).withConfig({
385
396
  displayName: "Selectable",
386
- componentId: "sc-71o6vd-0"
387
- })(responsiveRadiusStyle, selectableBaseStyle, selectableColorStyle);
397
+ componentId: "sc-81zkz-3"
398
+ })(responsiveRadiusStyle, selectableStyle);
388
399
  function useMenu() {
389
400
  let value = useContext(MenuContext);
390
401
  if (!value) throw Error("useMenu(): missing context value");