@sanity/ui 4.4.0 → 4.4.2

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.
@@ -34,7 +34,7 @@ const PortalContext = createGlobalScopedContext(key, {
34
34
  version: 0,
35
35
  boundaryElement: null,
36
36
  get element() {
37
- return typeof document > "u" ? null : globalScope[elementKey] ? globalScope[elementKey] : (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey]), globalScope[elementKey]);
37
+ return typeof document > "u" ? null : (globalScope[elementKey] || (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey])), globalScope[elementKey]);
38
38
  }
39
39
  });
40
40
  /**
@@ -188,4 +188,4 @@ function Arrow(props) {
188
188
  }
189
189
  export { resolvePortalElement as a, PortalContext as i, Portal as n, useBoundaryElement as o, usePortal as r, BoundaryElementContext as s, Arrow as t };
190
190
 
191
- //# sourceMappingURL=arrow-B8L6YB-v.js.map
191
+ //# sourceMappingURL=arrow-A3jQ7LS0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrow-B8L6YB-v.js","names":["createPortal(children, portalElement)","_c","radius = 0","compileCommands(cmds)","clsx(arrow, className)","assignInlineVars({[arrowSize]: `${w}px`})","`${w}px`","{...style, ...assignInlineVars({[arrowSize]: `${w}px`})}","<rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />","<mask id={strokeMaskId}>\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>","<path\n className={arrowStroke}\n d={strokePath}\n mask={`url(#${strokeMaskId})`}\n strokeWidth={strokeWidth * 2}\n />","strokeWidth * 2","`url(#${strokeMaskId})`","<path className={arrowShape} d={fillPath} />","<svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>\n <mask id={strokeMaskId}>\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>\n <path\n className={arrowStroke}\n d={strokePath}\n mask={`url(#${strokeMaskId})`}\n strokeWidth={strokeWidth * 2}\n />\n <path className={arrowShape} d={fillPath} />\n </svg>","`0 0 ${w} ${w}`","<div\n data-ui=\"Arrow\"\n {...restProps}\n className={clsx(arrow, className)}\n ref={ref}\n style={{...style, ...assignInlineVars({[arrowSize]: `${w}px`})}}\n >\n <svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>\n <mask id={strokeMaskId}>\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>\n <path\n className={arrowStroke}\n d={strokePath}\n mask={`url(#${strokeMaskId})`}\n strokeWidth={strokeWidth * 2}\n />\n <path className={arrowShape} d={fillPath} />\n </svg>\n </div>","_c"],"sources":["../src/core/utils/boundaryElement/boundaryElementContext.ts","../src/core/utils/boundaryElement/useBoundaryElement.ts","../src/core/utils/portal/resolvePortalElement.ts","../src/core/utils/portal/portalContext.ts","../src/core/utils/portal/usePortal.ts","../src/core/utils/portal/portal.ts","../src/core/utils/arrow/cmds.ts","../src/core/utils/arrow/arrow.css.ts","../src/core/utils/arrow/arrow.tsx"],"sourcesContent":["import {createGlobalScopedContext} from '../../lib/createGlobalScopedContext'\nimport {BoundaryElementContextValue} from './types'\n\nexport const BoundaryElementContext = createGlobalScopedContext<BoundaryElementContextValue | null>(\n '@sanity/ui/context/boundaryElement',\n null,\n)\n","import {useContext} from 'react'\n\nimport {isRecord} from '../../lib/isRecord'\nimport {BoundaryElementContext} from './boundaryElementContext'\nimport {BoundaryElementContextValue} from './types'\n\nconst DEFAULT_VALUE: BoundaryElementContextValue = {\n version: 0.0,\n element: null,\n}\n\n/**\n * @public\n */\nexport function useBoundaryElement(): BoundaryElementContextValue {\n const value = useContext(BoundaryElementContext)\n\n // NOTE: This check is for future-compatiblity\n // - If the value is not an object, it’s not compatible with the current version\n // - If the value is an object, but doesn’t have `version: 0.0`, it’s not compatible with the current version\n if (value && (!isRecord(value) || value.version !== 0.0)) {\n throw new Error('useBoundaryElement(): the context value is not compatible')\n }\n\n return value || DEFAULT_VALUE\n}\n","import type {PortalContextValue} from './types'\n\n/**\n * The element a `Portal` renders into: the named element when `name` is given, otherwise the\n * context's element, falling back to the `default` named element in both cases.\n *\n * Components that reason about the portal element (the tooltip caps its width to it, the dialog\n * scopes its click-outside and focus handling to it) resolve it through this function as well, so\n * they cannot disagree with where the portal content ends up.\n */\nexport function resolvePortalElement(\n portal: PortalContextValue,\n name?: string,\n): HTMLElement | null {\n return (name ? portal.elements?.[name] : portal.element) || portal.elements?.default || null\n}\n","import {createGlobalScopedContext} from '../../lib/createGlobalScopedContext'\nimport {globalScope} from '../../lib/globalScope'\nimport {PortalContextValue} from './types'\n\nconst key = '@sanity/ui/context/portal'\nconst elementKey = Symbol.for(`${key}/element`)\n\nglobalScope[elementKey] = null\n\nconst defaultContextValue: PortalContextValue = {\n version: 0.0,\n boundaryElement: null,\n get element() {\n if (typeof document === 'undefined') {\n return null\n }\n\n if (globalScope[elementKey]) {\n return globalScope[elementKey]\n }\n\n globalScope[elementKey] = document.createElement('div')\n globalScope[elementKey].setAttribute('data-portal', '')\n\n document.body.appendChild(globalScope[elementKey])\n\n return globalScope[elementKey]\n },\n}\n\nexport const PortalContext = createGlobalScopedContext<PortalContextValue>(key, defaultContextValue)\n","import {useContext} from 'react'\n\nimport {isRecord} from '../../lib/isRecord'\nimport {PortalContext} from './portalContext'\nimport {PortalContextValue} from './types'\n\n/**\n * @public\n */\nexport function usePortal(): PortalContextValue {\n const value = useContext(PortalContext)\n\n if (!value) {\n throw new Error('usePortal(): missing context value')\n }\n\n // NOTE: This check is for future-compatiblity\n // - If the value is not an object, it’s not compatible with the current version\n // - If the value is an object, but doesn’t have `version: 0.0`, it’s not compatible with the current version\n if (!isRecord(value) || value.version !== 0.0) {\n throw new Error('usePortal(): the context value is not compatible')\n }\n\n return value\n}\n","import {createPortal} from 'react-dom'\n\nimport {resolvePortalElement} from './resolvePortalElement'\nimport {usePortal} from './usePortal'\n\n/**\n * @public\n */\nexport interface PortalProps {\n children: React.ReactNode\n /**\n * @beta This API might change. DO NOT USE IN PRODUCTION.\n */\n __unstable_name?: string\n}\n\n/**\n * @public\n */\nexport function Portal(props: PortalProps): React.ReactPortal | null {\n const {children, __unstable_name: name} = props\n const portal = usePortal()\n const portalElement = resolvePortalElement(portal, name)\n\n if (!portalElement) {\n return null\n }\n\n return createPortal(children, portalElement)\n}\n","interface PointCmd {\n type: 'point'\n x: number\n y: number\n radius?: number\n}\n\ninterface CurveCmd {\n type: 'curve'\n startControl: Point\n endControl: Point\n curveEnd: Point\n}\n\nexport type Cmd = PointCmd | CurveCmd\n\nexport interface Point {\n x: number\n y: number\n radius?: number\n}\n\nfunction moveTowardsLength(movingPoint: Point, targetPoint: Point, amount: number) {\n const width = targetPoint.x - movingPoint.x\n const height = targetPoint.y - movingPoint.y\n\n const distance = Math.sqrt(width * width + height * height)\n\n return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance))\n}\n\nfunction moveTowardsFractional(movingPoint: Point, targetPoint: Point, fraction: number): Point {\n return {\n x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,\n y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction,\n }\n}\n\nexport function getRoundedCommands(points: Point[]): Cmd[] {\n const len = points.length\n\n const cmds: Cmd[] = []\n\n for (let i = 0; i < len; i += 1) {\n const point = points[i]\n const prevPoint = points[i - 1]\n const nextPoint = points[i + 1]\n\n if (prevPoint && point.radius) {\n const curveStart = moveTowardsLength(point, prevPoint, point.radius)\n const curveEnd = moveTowardsLength(point, nextPoint, point.radius)\n const startControl = moveTowardsFractional(curveStart, point, 0.5)\n const endControl = moveTowardsFractional(point, curveEnd, 0.5)\n\n cmds.push({\n type: 'point',\n ...curveStart,\n })\n\n cmds.push({\n type: 'curve',\n curveEnd,\n startControl,\n endControl,\n })\n } else {\n cmds.push({\n type: 'point',\n ...point,\n })\n }\n }\n\n return cmds\n}\n\nexport function compileCommands(cmds: Cmd[]): string {\n return cmds\n .map((n, idx) => {\n if (n.type === 'point') {\n return `${idx === 0 ? 'M' : 'L'} ${n.x} ${n.y}`\n }\n\n if (n.type === 'curve') {\n return `C ${n.startControl.x} ${n.startControl.y} ${n.endControl.x} ${n.endControl.y} ${n.curveEnd.x} ${n.curveEnd.y}`\n }\n\n return ``\n })\n .join(' ')\n}\n","import {createVar, globalStyle, style} from '@vanilla-extract/css'\n\nexport const arrowSize = createVar()\n\nexport const arrow = style({\n position: 'absolute',\n width: arrowSize,\n height: arrowSize,\n selectors: {\n ':empty + &': {display: 'none'},\n \"[data-placement^='top'] > &\": {bottom: `calc(-1 * ${arrowSize})`},\n \"[data-placement^='right'] > &\": {left: `calc(-1 * ${arrowSize})`},\n \"[data-placement^='left'] > &\": {right: `calc(-1 * ${arrowSize})`},\n \"[data-placement^='bottom'] > &\": {top: `calc(-1 * ${arrowSize})`},\n },\n})\n\nglobalStyle(`${arrow} > svg`, {\n display: 'block',\n lineHeight: 0,\n transformOrigin: `calc(${arrowSize} / 2) calc(${arrowSize} / 2)`,\n})\n\nglobalStyle(`[data-placement^='top'] > ${arrow} > svg`, {transform: 'rotate(0)'})\nglobalStyle(`[data-placement^='right'] > ${arrow} > svg`, {transform: 'rotate(90deg)'})\nglobalStyle(`[data-placement^='left'] > ${arrow} > svg`, {transform: 'rotate(-90deg)'})\nglobalStyle(`[data-placement^='bottom'] > ${arrow} > svg`, {transform: 'rotate(180deg)'})\n\nexport const arrowStroke = style({\n stroke: 'var(--card-shadow-outline-color)',\n})\n\nexport const arrowShape = style({\n fill: 'var(--card-bg-color)',\n})\n","import {assignInlineVars} from '@vanilla-extract/dynamic'\nimport {clsx} from 'clsx/lite'\nimport {HTMLProps, useId} from 'react'\n\nimport {useTheme_v2} from '../../theme/useTheme'\nimport {compileCommands, getRoundedCommands, Point} from './cmds'\n\nimport {arrow, arrowShape, arrowSize, arrowStroke} from './arrow.css'\n\n/** @internal */\nexport function Arrow(\n props: {width: number; height: number; radius?: number} & Omit<\n HTMLProps<HTMLDivElement>,\n 'width' | 'height'\n >,\n): React.JSX.Element {\n const {className, width: w, height: h, radius = 0, ref, style, ...restProps} = props\n const {card} = useTheme_v2()\n const strokeMaskId = `stroke-mask-${useId()}`\n const strokeWidth = card.shadow.outline\n\n const center = w / 2\n\n const points: Point[] = [\n {\n x: 0,\n y: 0,\n },\n {\n x: radius,\n y: 0,\n radius,\n },\n {\n x: center,\n y: h - 1,\n radius,\n },\n {\n x: w - radius,\n y: 0,\n radius,\n },\n {\n x: w,\n y: 0,\n },\n ]\n\n const cmds = getRoundedCommands(points)\n const path = compileCommands(cmds)\n\n // oxlint-disable-next-line no-unnecessary-template-expression\n const strokePath = `${path}`\n const fillPath = `${path} M ${w} -1 M 0 -1 Z`\n\n return (\n <div\n data-ui=\"Arrow\"\n {...restProps}\n className={clsx(arrow, className)}\n ref={ref}\n style={{...style, ...assignInlineVars({[arrowSize]: `${w}px`})}}\n >\n <svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>\n <mask id={strokeMaskId}>\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>\n <path\n className={arrowStroke}\n d={strokePath}\n mask={`url(#${strokeMaskId})`}\n strokeWidth={strokeWidth * 2}\n />\n <path className={arrowShape} d={fillPath} />\n </svg>\n </div>\n )\n}\n"],"mappings":";;;;;;;AAGA,MAAa,yBAAyB,0BACpC,sCACA,IACF,GCAM,gBAA6C;CACjD,SAAS;CACT,SAAS;AACX;;;;AAKA,SAAgB,qBAAkD;CAChE,IAAM,QAAQ,WAAW,sBAAsB;CAK/C,IAAI,UAAU,CAAC,SAAS,KAAK,KAAK,MAAM,YAAY,IAClD,MAAU,MAAM,2DAA2D;CAG7E,OAAO,SAAS;AAClB;;;;;;;;;ACfA,SAAgB,qBACd,QACA,MACoB;CACpB,QAAQ,OAAO,OAAO,WAAW,QAAQ,OAAO,YAAY,OAAO,UAAU,WAAW;AAC1F;ACXA,MAAM,MAAM,6BACN,aAAa,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,UAAAA;CACI,CAAA,GAFI,EAAA,MAAA,cACRA,EAAAA,MAAAA;CAKM,IAAA,KAAA,QAAQ,aAAa,IACd,MAAA,cAAc,GAJ7BE;CAEK,AAAA,EAAA,QAAA,cAAA,EAAA,QAEUC,OAAAA,EAAAA,QADPC,MAHR,MAAA,oBAAC,QAAD;EACE,WAAW;EACX,GAAG;EACH,MAAMA;EACN,aAAaD;CACd,CAAA,GAHI,EAAA,MAAA,YAEUA,EAAAA,MAAAA,KADPC,EAAAA,MAAAA;CAGRC,IAAAA;CAAgC,AAAA,EAAA,QAAA,0BAAhC,MAAA,oBAAC,QAAD;EAAM,WAAW;EAAY,GAAG;CAAW,CAAA,GAAX,EAAA,MAAA;CAVlCC,IAAAA;CAIEJ,AAAAA,EAAAA,QAAAA,OAAAA,EAAAA,QAMAG,OAAAA,EAAAA,QAViCE,MAAAA,EAAAA,QACjCN,MAAAA,EAAAA,QADU,KAAZ,MAAA,qBAAC,OAAD;EAAK,OAAO;EAAG,QAAQ;EAAG,SAASM;EAAnC,UAAA;GACEN;GAGAC;GAMAG;EACG;KAPHH,EAAAA,MAAAA,KAMAG,EAAAA,MAAAA,KAViCE,EAAAA,MAAAA,IACjCN,EAAAA,MAAAA,IADU,EAAA,MAAA;CAPdO,IAAAA;CADF,OAKS,EAAA,QAAA,OAAA,EAAA,QAFD,aAAA,EAAA,QAKJF,OAAAA,EAAAA,QAJWV,MAAAA,EAAAA,QAEJG,MALT,MAAA,oBAAC,OAAD;EACE,WAAQ;EACR,GAAI;EACJ,WAAWH;EACN;EACL,OAAOG;EAEPO,UAAAA;CAYG,CAAA,GAfE,EAAA,MAAA,KAFD,EAAA,MAAA,WAKJA,EAAAA,MAAAA,KAJWV,EAAAA,MAAAA,IAEJG,EAAAA,MAAAA,gCALTS;AAqBJ"}
1
+ {"version":3,"file":"arrow-A3jQ7LS0.js","names":["createPortal(children, portalElement)","_c","radius = 0","compileCommands(cmds)","clsx(arrow, className)","assignInlineVars({[arrowSize]: `${w}px`})","`${w}px`","{...style, ...assignInlineVars({[arrowSize]: `${w}px`})}","<rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />","<mask id={strokeMaskId}>\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>","<path\n className={arrowStroke}\n d={strokePath}\n mask={`url(#${strokeMaskId})`}\n strokeWidth={strokeWidth * 2}\n />","strokeWidth * 2","`url(#${strokeMaskId})`","<path className={arrowShape} d={fillPath} />","<svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>\n <mask id={strokeMaskId}>\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>\n <path\n className={arrowStroke}\n d={strokePath}\n mask={`url(#${strokeMaskId})`}\n strokeWidth={strokeWidth * 2}\n />\n <path className={arrowShape} d={fillPath} />\n </svg>","`0 0 ${w} ${w}`","<div\n data-ui=\"Arrow\"\n {...restProps}\n className={clsx(arrow, className)}\n ref={ref}\n style={{...style, ...assignInlineVars({[arrowSize]: `${w}px`})}}\n >\n <svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>\n <mask id={strokeMaskId}>\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>\n <path\n className={arrowStroke}\n d={strokePath}\n mask={`url(#${strokeMaskId})`}\n strokeWidth={strokeWidth * 2}\n />\n <path className={arrowShape} d={fillPath} />\n </svg>\n </div>","_c"],"sources":["../src/core/utils/boundaryElement/boundaryElementContext.ts","../src/core/utils/boundaryElement/useBoundaryElement.ts","../src/core/utils/portal/resolvePortalElement.ts","../src/core/utils/portal/portalContext.ts","../src/core/utils/portal/usePortal.ts","../src/core/utils/portal/portal.ts","../src/core/utils/arrow/cmds.ts","../src/core/utils/arrow/arrow.css.ts","../src/core/utils/arrow/arrow.tsx"],"sourcesContent":["import {createGlobalScopedContext} from '../../lib/createGlobalScopedContext'\nimport {BoundaryElementContextValue} from './types'\n\nexport const BoundaryElementContext = createGlobalScopedContext<BoundaryElementContextValue | null>(\n '@sanity/ui/context/boundaryElement',\n null,\n)\n","import {useContext} from 'react'\n\nimport {isRecord} from '../../lib/isRecord'\nimport {BoundaryElementContext} from './boundaryElementContext'\nimport {BoundaryElementContextValue} from './types'\n\nconst DEFAULT_VALUE: BoundaryElementContextValue = {\n version: 0.0,\n element: null,\n}\n\n/**\n * @public\n */\nexport function useBoundaryElement(): BoundaryElementContextValue {\n const value = useContext(BoundaryElementContext)\n\n // NOTE: This check is for future-compatiblity\n // - If the value is not an object, it’s not compatible with the current version\n // - If the value is an object, but doesn’t have `version: 0.0`, it’s not compatible with the current version\n if (value && (!isRecord(value) || value.version !== 0.0)) {\n throw new Error('useBoundaryElement(): the context value is not compatible')\n }\n\n return value || DEFAULT_VALUE\n}\n","import type {PortalContextValue} from './types'\n\n/**\n * The element a `Portal` renders into: the named element when `name` is given, otherwise the\n * context's element, falling back to the `default` named element in both cases.\n *\n * Components that reason about the portal element (the tooltip caps its width to it, the dialog\n * scopes its click-outside and focus handling to it) resolve it through this function as well, so\n * they cannot disagree with where the portal content ends up.\n */\nexport function resolvePortalElement(\n portal: PortalContextValue,\n name?: string,\n): HTMLElement | null {\n return (name ? portal.elements?.[name] : portal.element) || portal.elements?.default || null\n}\n","import {createGlobalScopedContext} from '../../lib/createGlobalScopedContext'\nimport {globalScope} from '../../lib/globalScope'\nimport {PortalContextValue} from './types'\n\nconst key = '@sanity/ui/context/portal'\nconst elementKey = Symbol.for(`${key}/element`)\n\nglobalScope[elementKey] = null\n\nconst defaultContextValue: PortalContextValue = {\n version: 0.0,\n boundaryElement: null,\n get element() {\n if (typeof document === 'undefined') {\n return null\n }\n\n if (globalScope[elementKey]) {\n return globalScope[elementKey]\n }\n\n globalScope[elementKey] = document.createElement('div')\n globalScope[elementKey].setAttribute('data-portal', '')\n\n document.body.appendChild(globalScope[elementKey])\n\n return globalScope[elementKey]\n },\n}\n\nexport const PortalContext = createGlobalScopedContext<PortalContextValue>(key, defaultContextValue)\n","import {useContext} from 'react'\n\nimport {isRecord} from '../../lib/isRecord'\nimport {PortalContext} from './portalContext'\nimport {PortalContextValue} from './types'\n\n/**\n * @public\n */\nexport function usePortal(): PortalContextValue {\n const value = useContext(PortalContext)\n\n if (!value) {\n throw new Error('usePortal(): missing context value')\n }\n\n // NOTE: This check is for future-compatiblity\n // - If the value is not an object, it’s not compatible with the current version\n // - If the value is an object, but doesn’t have `version: 0.0`, it’s not compatible with the current version\n if (!isRecord(value) || value.version !== 0.0) {\n throw new Error('usePortal(): the context value is not compatible')\n }\n\n return value\n}\n","import {createPortal} from 'react-dom'\n\nimport {resolvePortalElement} from './resolvePortalElement'\nimport {usePortal} from './usePortal'\n\n/**\n * @public\n */\nexport interface PortalProps {\n children: React.ReactNode\n /**\n * @beta This API might change. DO NOT USE IN PRODUCTION.\n */\n __unstable_name?: string\n}\n\n/**\n * @public\n */\nexport function Portal(props: PortalProps): React.ReactPortal | null {\n const {children, __unstable_name: name} = props\n const portal = usePortal()\n const portalElement = resolvePortalElement(portal, name)\n\n if (!portalElement) {\n return null\n }\n\n return createPortal(children, portalElement)\n}\n","interface PointCmd {\n type: 'point'\n x: number\n y: number\n radius?: number\n}\n\ninterface CurveCmd {\n type: 'curve'\n startControl: Point\n endControl: Point\n curveEnd: Point\n}\n\nexport type Cmd = PointCmd | CurveCmd\n\nexport interface Point {\n x: number\n y: number\n radius?: number\n}\n\nfunction moveTowardsLength(movingPoint: Point, targetPoint: Point, amount: number) {\n const width = targetPoint.x - movingPoint.x\n const height = targetPoint.y - movingPoint.y\n\n const distance = Math.sqrt(width * width + height * height)\n\n return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance))\n}\n\nfunction moveTowardsFractional(movingPoint: Point, targetPoint: Point, fraction: number): Point {\n return {\n x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,\n y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction,\n }\n}\n\nexport function getRoundedCommands(points: Point[]): Cmd[] {\n const len = points.length\n\n const cmds: Cmd[] = []\n\n for (let i = 0; i < len; i += 1) {\n const point = points[i]\n const prevPoint = points[i - 1]\n const nextPoint = points[i + 1]\n\n if (prevPoint && point.radius) {\n const curveStart = moveTowardsLength(point, prevPoint, point.radius)\n const curveEnd = moveTowardsLength(point, nextPoint, point.radius)\n const startControl = moveTowardsFractional(curveStart, point, 0.5)\n const endControl = moveTowardsFractional(point, curveEnd, 0.5)\n\n cmds.push({\n type: 'point',\n ...curveStart,\n })\n\n cmds.push({\n type: 'curve',\n curveEnd,\n startControl,\n endControl,\n })\n } else {\n cmds.push({\n type: 'point',\n ...point,\n })\n }\n }\n\n return cmds\n}\n\nexport function compileCommands(cmds: Cmd[]): string {\n return cmds\n .map((n, idx) => {\n if (n.type === 'point') {\n return `${idx === 0 ? 'M' : 'L'} ${n.x} ${n.y}`\n }\n\n if (n.type === 'curve') {\n return `C ${n.startControl.x} ${n.startControl.y} ${n.endControl.x} ${n.endControl.y} ${n.curveEnd.x} ${n.curveEnd.y}`\n }\n\n return ``\n })\n .join(' ')\n}\n","import {createVar, globalStyle, style} from '@vanilla-extract/css'\n\nexport const arrowSize = createVar()\n\nexport const arrow = style({\n position: 'absolute',\n width: arrowSize,\n height: arrowSize,\n selectors: {\n ':empty + &': {display: 'none'},\n \"[data-placement^='top'] > &\": {bottom: `calc(-1 * ${arrowSize})`},\n \"[data-placement^='right'] > &\": {left: `calc(-1 * ${arrowSize})`},\n \"[data-placement^='left'] > &\": {right: `calc(-1 * ${arrowSize})`},\n \"[data-placement^='bottom'] > &\": {top: `calc(-1 * ${arrowSize})`},\n },\n})\n\nglobalStyle(`${arrow} > svg`, {\n display: 'block',\n lineHeight: 0,\n transformOrigin: `calc(${arrowSize} / 2) calc(${arrowSize} / 2)`,\n})\n\nglobalStyle(`[data-placement^='top'] > ${arrow} > svg`, {transform: 'rotate(0)'})\nglobalStyle(`[data-placement^='right'] > ${arrow} > svg`, {transform: 'rotate(90deg)'})\nglobalStyle(`[data-placement^='left'] > ${arrow} > svg`, {transform: 'rotate(-90deg)'})\nglobalStyle(`[data-placement^='bottom'] > ${arrow} > svg`, {transform: 'rotate(180deg)'})\n\nexport const arrowStroke = style({\n stroke: 'var(--card-shadow-outline-color)',\n})\n\nexport const arrowShape = style({\n fill: 'var(--card-bg-color)',\n})\n","import {assignInlineVars} from '@vanilla-extract/dynamic'\nimport {clsx} from 'clsx/lite'\nimport {HTMLProps, useId} from 'react'\n\nimport {useTheme_v2} from '../../theme/useTheme'\nimport {compileCommands, getRoundedCommands, Point} from './cmds'\n\nimport {arrow, arrowShape, arrowSize, arrowStroke} from './arrow.css'\n\n/** @internal */\nexport function Arrow(\n props: {width: number; height: number; radius?: number} & Omit<\n HTMLProps<HTMLDivElement>,\n 'width' | 'height'\n >,\n): React.JSX.Element {\n const {className, width: w, height: h, radius = 0, ref, style, ...restProps} = props\n const {card} = useTheme_v2()\n const strokeMaskId = `stroke-mask-${useId()}`\n const strokeWidth = card.shadow.outline\n\n const center = w / 2\n\n const points: Point[] = [\n {\n x: 0,\n y: 0,\n },\n {\n x: radius,\n y: 0,\n radius,\n },\n {\n x: center,\n y: h - 1,\n radius,\n },\n {\n x: w - radius,\n y: 0,\n radius,\n },\n {\n x: w,\n y: 0,\n },\n ]\n\n const cmds = getRoundedCommands(points)\n const path = compileCommands(cmds)\n\n // oxlint-disable-next-line no-unnecessary-template-expression\n const strokePath = `${path}`\n const fillPath = `${path} M ${w} -1 M 0 -1 Z`\n\n return (\n <div\n data-ui=\"Arrow\"\n {...restProps}\n className={clsx(arrow, className)}\n ref={ref}\n style={{...style, ...assignInlineVars({[arrowSize]: `${w}px`})}}\n >\n <svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>\n <mask id={strokeMaskId}>\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>\n <path\n className={arrowStroke}\n d={strokePath}\n mask={`url(#${strokeMaskId})`}\n strokeWidth={strokeWidth * 2}\n />\n <path className={arrowShape} d={fillPath} />\n </svg>\n </div>\n )\n}\n"],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AAA,EAAA,QAKJF,OAAAA,EAAAA,QAJWV,MAAAA,EAAAA,QAEJG,MALT,MAAA,oBAAC,OAAD;EACE,WAAQ;EACR,GAAI;EACJ,WAAWH;EACN;EACL,OAAOG;EAEPO,UAAAA;CAYG,CAAA,GAfE,EAAA,MAAA,KAFD,EAAA,MAAA,WAKJA,EAAAA,MAAAA,KAJWV,EAAAA,MAAAA,IAEJG,EAAAA,MAAAA,gCALTS;AAqBJ"}
@@ -126,7 +126,11 @@ interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseAutocomp
126
126
  }, ref: Ref<HTMLDivElement>) => ReactNode;
127
127
  renderValue?: (value: string, option?: Option) => string;
128
128
  suffix?: ReactNode;
129
- /** The current value. */
129
+ /**
130
+ * The current value. A changed `value` replaces the value shown and drops a pending query,
131
+ * unless it equals the value shown (a parent echoing `onChange`). A selection or clear shows
132
+ * until `value` changes, and changing `value` to `undefined` keeps the value shown.
133
+ */
130
134
  value?: string;
131
135
  }
132
136
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.d.ts","names":[],"sources":["../src/core/components/autocomplete/types.ts","../src/core/components/autocomplete/autocomplete.tsx"],"mappings":";;;;;;;KAKY,8BAA8B,iBACxC,KAAK,MAAM,UAAU;;;;UAKN;EACf;;;;;UAMe;EACf;EACA;EACA;EACA;EACA;;;;;UAMe;EACf;;;;;UAMe;EACf;;;;;UAMe;EACf;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;EACA;EACA;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;;;;;UAMe;EACf;EACA;;;;;KAMU,kBACR,0BACA,2BACA,4BACA,0BACA,oCACA,oCACA,6BACA,6BACA;;;;UC1Da,kBAAkB,eAAe,yBAAyB;EACzE;EACA;EACA,gBAAgB,eAAe,QAAQ;EACvC;EAEA,OAAO,cAAc;EACrB;;EAEA,UAAU;EACV;EACA,YAAY;EACZ,iBAAiB;EACjB,YAAY;;EAEZ,uBAAuB;;EAEvB;;EAEA,UAAU;EACV;EACA,UAAU,KAAK,sEACb,KAAK,UAAU;EACjB,SAAS;EACT,SAAS,SAAS;;EAElB,kBAAkB;;EAElB,gBAAgB,QAAQ,WAAW,MAAM,IAAI;;EAE7C,iBACE;IACE,SAAS,MAAM,IAAI;IACnB;IACA,cAAc;IACd;IACA;KAEF,KAAK,IAAI,oBACN;EACL,eAAe,eAAe,SAAS;EACvC,SAAS;;EAET;;;;;;;;wBAec,aAAa,eAAe,wBAC1C,OAAO,kBAAkB,UACvB,KACE,UAAU,gSAmBX,IAAA"}
1
+ {"version":3,"file":"autocomplete.d.ts","names":[],"sources":["../src/core/components/autocomplete/types.ts","../src/core/components/autocomplete/autocomplete.tsx"],"mappings":";;;;;;;KAKY,8BAA8B,iBACxC,KAAK,MAAM,UAAU;;;;UAKN;EACf;;;;;UAMe;EACf;EACA;EACA;EACA;EACA;;;;;UAMe;EACf;;;;;UAMe;EACf;;;;;UAMe;EACf;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;EACA;EACA;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;;;;;UAMe;EACf;EACA;;;;;KAMU,kBACR,0BACA,2BACA,4BACA,0BACA,oCACA,oCACA,6BACA,6BACA;;;;UCtDa,kBAAkB,eAAe,yBAAyB;EACzE;EACA;EACA,gBAAgB,eAAe,QAAQ;EACvC;EAEA,OAAO,cAAc;EACrB;;EAEA,UAAU;EACV;EACA,YAAY;EACZ,iBAAiB;EACjB,YAAY;;EAEZ,uBAAuB;;EAEvB;;EAEA,UAAU;EACV;EACA,UAAU,KAAK,sEACb,KAAK,UAAU;EACjB,SAAS;EACT,SAAS,SAAS;;EAElB,kBAAkB;;EAElB,gBAAgB,QAAQ,WAAW,MAAM,IAAI;;EAE7C,iBACE;IACE,SAAS,MAAM,IAAI;IACnB;IACA,cAAc;IACd;IACA;KAEF,KAAK,IAAI,oBACN;EACL,eAAe,eAAe,SAAS;EACvC,SAAS;;;;;;EAMT;;;;;;;;wBAec,aAAa,eAAe,wBAC1C,OAAO,kBAAkB,UACvB,KACE,UAAU,gSAmBX,IAAA"}
@@ -5,12 +5,13 @@ import { t as _isEnterToClickElement } from "./element-BYgCE_iK.js";
5
5
  import { s as Card, y as Box } from "./useLayer-B0i19TTM.js";
6
6
  import { n as Text, t as Stack } from "./stack-Cv-WM-7p.js";
7
7
  import { t as Button } from "./button-dhq4ViVg.js";
8
- import { t as Popover } from "./popover-C72hePrK.js";
8
+ import { t as Popover } from "./popover-CEDyHcBi.js";
9
9
  import { c } from "react/compiler-runtime";
10
10
  import { ChevronDownIcon } from "@sanity/icons/ChevronDown";
11
11
  import { SpinnerIcon } from "@sanity/icons/Spinner";
12
12
  import { clsx } from "clsx/lite";
13
- import { cloneElement, useEffect, useImperativeHandle, useReducer, useRef, useState } from "react";
13
+ import { cloneElement, useDeferredValue, useEffect, useImperativeHandle, useReducer, useRef, useState } from "react";
14
+ import { useEffectEvent } from "use-effect-event";
14
15
  import { jsx, jsxs } from "react/jsx-runtime";
15
16
  function AutocompleteOption(props) {
16
17
  let $ = c(11), { children, id, onSelect, selected, value } = props, t0;
@@ -46,19 +47,17 @@ function autocompleteReducer(state, msg) {
46
47
  } : msg.type === "input/focus" ? {
47
48
  ...state,
48
49
  focused: !0
49
- } : msg.type === "root/blur" ? {
50
+ } : msg.type === "root/blur" || msg.type === "root/escape" ? {
50
51
  ...state,
52
+ activeValue: state.value || state.activeValue,
51
53
  focused: !1,
54
+ listFocused: !1,
52
55
  query: null
53
56
  } : msg.type === "root/clear" ? {
54
57
  ...state,
55
58
  activeValue: null,
56
59
  query: null,
57
60
  value: null
58
- } : msg.type === "root/escape" ? {
59
- ...state,
60
- focused: !1,
61
- query: null
62
61
  } : msg.type === "root/open" ? {
63
62
  ...state,
64
63
  query: state.query ?? msg.query
@@ -101,7 +100,7 @@ const DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, D
101
100
  * @public
102
101
  */
103
102
  function Autocomplete(props) {
104
- let $ = c(186), customValidity, disabled, filterOptionProp, forwardedRef, icon, id, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, optionsProp, prefix, readOnly, relatedElements, renderOptionProp, renderPopover, restProps, suffix, t0, t1, t2, t3, t4, t5, t6, valueProp;
103
+ let $ = c(187), customValidity, disabled, filterOptionProp, forwardedRef, icon, id, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, optionsProp, prefix, readOnly, relatedElements, renderOptionProp, renderPopover, restProps, suffix, t0, t1, t2, t3, t4, t5, t6, valueProp;
105
104
  $[0] === props ? (customValidity = $[1], disabled = $[2], filterOptionProp = $[3], forwardedRef = $[4], icon = $[5], id = $[6], loading = $[7], onBlur = $[8], onChange = $[9], onFocus = $[10], onQueryChange = $[11], onSelect = $[12], openButton = $[13], openOnFocus = $[14], optionsProp = $[15], prefix = $[16], readOnly = $[17], relatedElements = $[18], renderOptionProp = $[19], renderPopover = $[20], restProps = $[21], suffix = $[22], t0 = $[23], t1 = $[24], t2 = $[25], t3 = $[26], t4 = $[27], t5 = $[28], t6 = $[29], valueProp = $[30]) : ({border: t0, customValidity, disabled, filterOption: filterOptionProp, fontSize: t1, icon, id, listBox: t2, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, options: optionsProp, padding: t3, popover: t4, prefix, radius: t5, readOnly, ref: forwardedRef, relatedElements, renderOption: renderOptionProp, renderPopover, renderValue: t6, suffix, value: valueProp, ...restProps} = props, $[0] = props, $[1] = customValidity, $[2] = disabled, $[3] = filterOptionProp, $[4] = forwardedRef, $[5] = icon, $[6] = id, $[7] = loading, $[8] = onBlur, $[9] = onChange, $[10] = onFocus, $[11] = onQueryChange, $[12] = onSelect, $[13] = openButton, $[14] = openOnFocus, $[15] = optionsProp, $[16] = prefix, $[17] = readOnly, $[18] = relatedElements, $[19] = renderOptionProp, $[20] = renderPopover, $[21] = restProps, $[22] = suffix, $[23] = t0, $[24] = t1, $[25] = t2, $[26] = t3, $[27] = t4, $[28] = t5, $[29] = t6, $[30] = valueProp);
106
105
  let border = t0 === void 0 || t0, fontSize = t1 === void 0 ? 2 : t1, listBox = t2 === void 0 ? EMPTY_RECORD : t2, paddingProp = t3 === void 0 ? 3 : t3, popover = t4 === void 0 ? EMPTY_RECORD : t4, radius = t5 === void 0 ? 2 : t5, renderValue = t6 === void 0 ? DEFAULT_RENDER_VALUE : t6, t7 = valueProp || null, t8 = valueProp || null, t9;
107
106
  $[31] !== t7 || $[32] !== t8 ? (t9 = {
@@ -111,7 +110,12 @@ function Autocomplete(props) {
111
110
  query: null,
112
111
  value: t8
113
112
  }, $[31] = t7, $[32] = t8, $[33] = t9) : t9 = $[33];
114
- let [state, dispatch] = useReducer(autocompleteReducer, t9), { activeValue, focused, listFocused, query, value } = state, t10;
113
+ let [state, dispatch] = useReducer(autocompleteReducer, t9), { activeValue, focused, listFocused, query, value } = state, [prevValueProp, setPrevValueProp] = useState(valueProp);
114
+ valueProp !== prevValueProp && (setPrevValueProp(valueProp), valueProp !== void 0 && (valueProp || null) !== value && dispatch({
115
+ type: "value/change",
116
+ value: valueProp
117
+ }));
118
+ let t10;
115
119
  $[34] !== fontSize || $[35] !== paddingProp ? (t10 = (t11) => {
116
120
  let { value: value_0 } = t11;
117
121
  return /* @__PURE__ */ jsx(Card, {
@@ -126,7 +130,7 @@ function Autocomplete(props) {
126
130
  })
127
131
  });
128
132
  }, $[34] = fontSize, $[35] = paddingProp, $[36] = t10) : t10 = $[36];
129
- let renderOption = typeof renderOptionProp == "function" ? renderOptionProp : t10, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = useRef(null), resultsPopoverElementRef = useRef(null), inputElementRef = useRef(null), listBoxElementRef = useRef(null), [inputElement, setInputElement] = useState(null), listFocusedRef = useRef(!1), valueRef = useRef(value), valuePropRef = useRef(valueProp), popoverMouseWithinRef = useRef(!1), t11, t12;
133
+ let renderOption = typeof renderOptionProp == "function" ? renderOptionProp : t10, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = useRef(null), resultsPopoverElementRef = useRef(null), inputElementRef = useRef(null), listBoxElementRef = useRef(null), [inputElement, setInputElement] = useState(null), listFocusedRef = useRef(!1), popoverMouseWithinRef = useRef(!1), t11, t12;
130
134
  $[37] === inputElement ? (t11 = $[38], t12 = $[39]) : (t11 = () => inputElement, t12 = [inputElement], $[37] = inputElement, $[38] = t11, $[39] = t12), useImperativeHandle(inputElementRef, t11, t12);
131
135
  let t13, t14;
132
136
  $[40] === inputElement ? (t13 = $[41], t14 = $[42]) : (t13 = () => inputElement, t14 = [inputElement], $[40] = inputElement, $[41] = t13, $[42] = t14), useImperativeHandle(forwardedRef, t13, t14);
@@ -137,7 +141,7 @@ function Autocomplete(props) {
137
141
  let t17;
138
142
  $[50] !== filterOption || $[51] !== query ? (t17 = (option) => !query || filterOption(query, option), $[50] = filterOption, $[51] = query, $[52] = t17) : t17 = $[52], t16 = options.filter(t17), $[46] = filterOption, $[47] = options, $[48] = query, $[49] = t16;
139
143
  } else t16 = $[49];
140
- let filteredOptions = t16, filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, t17;
144
+ let filteredOptions = t16, filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, querying = query !== null && loading || focused && query !== null, deferredQuerying = useDeferredValue(querying), expanded = querying && deferredQuerying, t17;
141
145
  $[53] !== onBlur || $[54] !== onQueryChange || $[55] !== relatedElements ? (t17 = (event) => {
142
146
  setTimeout(() => {
143
147
  if (popoverMouseWithinRef.current) return;
@@ -164,7 +168,7 @@ function Autocomplete(props) {
164
168
  dispatch({
165
169
  type: "value/change",
166
170
  value: v
167
- }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
171
+ }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
168
172
  }, $[58] = onChange, $[59] = onQueryChange, $[60] = onSelect, $[61] = t19) : t19 = $[61];
169
173
  let handleOptionSelect = t19, t20;
170
174
  $[62] !== activeValue || $[63] !== filteredOptions || $[64] !== filteredOptionsLen || $[65] !== onQueryChange ? (t20 = (event_1) => {
@@ -193,10 +197,7 @@ function Autocomplete(props) {
193
197
  return;
194
198
  }
195
199
  let target = event_1.target, listEl = listBoxElementRef.current;
196
- if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event_1.key)) {
197
- inputElementRef.current?.focus();
198
- return;
199
- }
200
+ (listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event_1.key) && inputElementRef.current?.focus();
200
201
  }, $[62] = activeValue, $[63] = filteredOptions, $[64] = filteredOptionsLen, $[65] = onQueryChange, $[66] = t20) : t20 = $[66];
201
202
  let handleRootKeyDown = t20, t21;
202
203
  $[67] === onQueryChange ? t21 = $[68] : (t21 = (event_2) => {
@@ -227,37 +228,16 @@ function Autocomplete(props) {
227
228
  }, $[79] = t25) : t25 = $[79];
228
229
  let handlePopoverMouseLeave = t25, t26;
229
230
  $[80] !== onChange || $[81] !== onQueryChange ? (t26 = () => {
230
- dispatch({ type: "root/clear" }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
231
+ dispatch({ type: "root/clear" }), onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
231
232
  }, $[80] = onChange, $[81] = onQueryChange, $[82] = t26) : t26 = $[82];
232
233
  let handleClearButtonClick = t26, t27;
233
234
  $[83] === Symbol.for("react.memo_cache_sentinel") ? (t27 = () => {
234
235
  dispatch({ type: "input/focus" });
235
236
  }, $[83] = t27) : t27 = $[83];
236
- let handleClearButtonFocus = t27, t28, t29;
237
- $[84] === valueProp ? (t28 = $[85], t29 = $[86]) : (t28 = () => {
238
- if (valueProp !== valuePropRef.current) {
239
- valuePropRef.current = valueProp, valueProp !== void 0 && (dispatch({
240
- type: "value/change",
241
- value: valueProp
242
- }), valueRef.current = valueProp);
243
- return;
244
- }
245
- valueProp !== valueRef.current && (valueRef.current = valueProp || null, dispatch({
246
- type: "value/change",
247
- value: valueProp || null
248
- }));
249
- }, t29 = [valueProp], $[84] = valueProp, $[85] = t28, $[86] = t29), useEffect(t28, t29);
250
- let t30, t31;
251
- $[87] === focused ? (t30 = $[88], t31 = $[89]) : (t30 = () => {
252
- !focused && valueRef.current && dispatch({
253
- type: "root/setActiveValue",
254
- value: valueRef.current
255
- });
256
- }, t31 = [focused], $[87] = focused, $[88] = t30, $[89] = t31), useEffect(t30, t31);
257
- let t32, t33;
258
- $[90] !== activeValue || $[91] !== filteredOptions ? (t32 = () => {
237
+ let handleClearButtonFocus = t27, t28;
238
+ $[84] !== activeValue || $[85] !== filteredOptions || $[86] !== listFocused ? (t28 = () => {
259
239
  let listElement = listBoxElementRef.current;
260
- if (!listElement) return;
240
+ if (!listFocused || !listElement) return;
261
241
  let activeOption_1 = filteredOptions.find((o_2) => o_2.value === activeValue);
262
242
  if (activeOption_1) {
263
243
  let activeIndex_1 = filteredOptions.indexOf(activeOption_1), activeItemElement = listElement.childNodes[activeIndex_1];
@@ -266,30 +246,40 @@ function Autocomplete(props) {
266
246
  focusFirstDescendant(activeItemElement);
267
247
  }
268
248
  }
269
- }, t33 = [activeValue, filteredOptions], $[90] = activeValue, $[91] = filteredOptions, $[92] = t32, $[93] = t33) : (t32 = $[92], t33 = $[93]), useEffect(t32, t33);
270
- let t34;
249
+ }, $[84] = activeValue, $[85] = filteredOptions, $[86] = listFocused, $[87] = t28) : t28 = $[87];
250
+ let focusActiveOption = useEffectEvent(t28), t29;
251
+ $[88] !== expanded || $[89] !== focusActiveOption ? (t29 = () => {
252
+ expanded && focusActiveOption();
253
+ }, $[88] = expanded, $[89] = focusActiveOption, $[90] = t29) : t29 = $[90];
254
+ let t30;
255
+ $[91] !== activeValue || $[92] !== expanded || $[93] !== filteredOptions ? (t30 = [
256
+ activeValue,
257
+ expanded,
258
+ filteredOptions
259
+ ], $[91] = activeValue, $[92] = expanded, $[93] = filteredOptions, $[94] = t30) : t30 = $[94], useEffect(t29, t30);
260
+ let t31;
271
261
  bb0: {
272
262
  if (!loading && !disabled && value) {
273
- let t35;
274
- $[94] === Symbol.for("react.memo_cache_sentinel") ? (t35 = {
263
+ let t32;
264
+ $[95] === Symbol.for("react.memo_cache_sentinel") ? (t32 = {
275
265
  "aria-label": "Clear",
276
266
  onFocus: handleClearButtonFocus
277
- }, $[94] = t35) : t35 = $[94], t34 = t35;
267
+ }, $[95] = t32) : t32 = $[95], t31 = t32;
278
268
  break bb0;
279
269
  }
280
- t34 = void 0;
270
+ t31 = void 0;
281
271
  }
282
- let clearButton = t34, openButtonBoxPadding = padding.map(_temp), openButtonPadding = padding.map(_temp2), openButtonProps = typeof openButton == "object" ? openButton : EMPTY_RECORD, t35;
283
- $[95] !== dispatchOpen || $[96] !== openButtonProps ? (t35 = (event_4) => {
272
+ let clearButton = t31, openButtonBoxPadding = padding.map(_temp), openButtonPadding = padding.map(_temp2), openButtonProps = typeof openButton == "object" ? openButton : EMPTY_RECORD, t32;
273
+ $[96] !== dispatchOpen || $[97] !== openButtonProps ? (t32 = (event_4) => {
284
274
  dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus());
285
- }, $[95] = dispatchOpen, $[96] = openButtonProps, $[97] = t35) : t35 = $[97];
286
- let handleOpenClick = t35, t36;
287
- $[98] !== disabled || $[99] !== expanded || $[100] !== fontSize || $[101] !== handleOpenClick || $[102] !== openButton || $[103] !== openButtonBoxPadding || $[104] !== openButtonPadding || $[105] !== openButtonProps || $[106] !== readOnly ? (t36 = !disabled && !readOnly && openButton ? /* @__PURE__ */ jsx(Box, {
288
- "aria-hidden": expanded,
275
+ }, $[96] = dispatchOpen, $[97] = openButtonProps, $[98] = t32) : t32 = $[98];
276
+ let handleOpenClick = t32, t33;
277
+ $[99] !== disabled || $[100] !== fontSize || $[101] !== handleOpenClick || $[102] !== openButton || $[103] !== openButtonBoxPadding || $[104] !== openButtonPadding || $[105] !== openButtonProps || $[106] !== querying || $[107] !== readOnly ? (t33 = !disabled && !readOnly && openButton ? /* @__PURE__ */ jsx(Box, {
278
+ "aria-hidden": querying,
289
279
  padding: openButtonBoxPadding,
290
280
  children: /* @__PURE__ */ jsx(Button, {
291
281
  "aria-label": "Open",
292
- disabled: expanded,
282
+ disabled: querying,
293
283
  fontSize,
294
284
  icon: ChevronDownIcon,
295
285
  mode: "bleed",
@@ -297,36 +287,36 @@ function Autocomplete(props) {
297
287
  ...openButtonProps,
298
288
  onClick: handleOpenClick
299
289
  })
300
- }) : void 0, $[98] = disabled, $[99] = expanded, $[100] = fontSize, $[101] = handleOpenClick, $[102] = openButton, $[103] = openButtonBoxPadding, $[104] = openButtonPadding, $[105] = openButtonProps, $[106] = readOnly, $[107] = t36) : t36 = $[107];
301
- let openButtonNode = t36, t37;
290
+ }) : void 0, $[99] = disabled, $[100] = fontSize, $[101] = handleOpenClick, $[102] = openButton, $[103] = openButtonBoxPadding, $[104] = openButtonPadding, $[105] = openButtonProps, $[106] = querying, $[107] = readOnly, $[108] = t33) : t33 = $[108];
291
+ let openButtonNode = t33, t34;
302
292
  bb1: {
303
293
  if (query === null) {
304
294
  if (value !== null) {
305
- let t38;
306
- $[108] !== currentOption || $[109] !== renderValue || $[110] !== value ? (t38 = renderValue(value, currentOption), $[108] = currentOption, $[109] = renderValue, $[110] = value, $[111] = t38) : t38 = $[111], t37 = t38;
295
+ let t35;
296
+ $[109] !== currentOption || $[110] !== renderValue || $[111] !== value ? (t35 = renderValue(value, currentOption), $[109] = currentOption, $[110] = renderValue, $[111] = value, $[112] = t35) : t35 = $[112], t34 = t35;
307
297
  break bb1;
308
298
  }
309
- t37 = "";
299
+ t34 = "";
310
300
  break bb1;
311
301
  }
312
- t37 = query;
302
+ t34 = query;
313
303
  }
314
- let inputValue = t37, t38;
315
- $[112] === listFocused ? t38 = $[113] : (t38 = (event_5) => {
304
+ let inputValue = t34, t35;
305
+ $[113] === listFocused ? t35 = $[114] : (t35 = (event_5) => {
316
306
  event_5.key === "Tab" && listFocused && inputElementRef.current?.focus();
317
- }, $[112] = listFocused, $[113] = t38);
318
- let handleListBoxKeyDown = t38, t39;
307
+ }, $[113] = listFocused, $[114] = t35);
308
+ let handleListBoxKeyDown = t35, t36;
319
309
  bb2: {
320
310
  if (filteredOptions.length === 0) {
321
- t39 = null;
311
+ t36 = null;
322
312
  break bb2;
323
313
  }
324
- let t40 = listBox?.className, t41;
325
- $[114] === t40 ? t41 = $[115] : (t41 = clsx(autocompleteListBox, t40), $[114] = t40, $[115] = t41);
326
- let t42;
327
- if ($[116] !== activeValue || $[117] !== currentOption || $[118] !== filteredOptions || $[119] !== handleOptionSelect || $[120] !== id || $[121] !== listFocused || $[122] !== loading || $[123] !== renderOption) {
328
- let t43;
329
- $[125] !== activeValue || $[126] !== currentOption || $[127] !== handleOptionSelect || $[128] !== id || $[129] !== listFocused || $[130] !== loading || $[131] !== renderOption ? (t43 = (option_0) => {
314
+ let t37 = listBox?.className, t38;
315
+ $[115] === t37 ? t38 = $[116] : (t38 = clsx(autocompleteListBox, t37), $[115] = t37, $[116] = t38);
316
+ let t39;
317
+ if ($[117] !== activeValue || $[118] !== currentOption || $[119] !== filteredOptions || $[120] !== handleOptionSelect || $[121] !== id || $[122] !== listFocused || $[123] !== loading || $[124] !== renderOption) {
318
+ let t40;
319
+ $[126] !== activeValue || $[127] !== currentOption || $[128] !== handleOptionSelect || $[129] !== id || $[130] !== listFocused || $[131] !== loading || $[132] !== renderOption ? (t40 = (option_0) => {
330
320
  let active = activeValue === null ? currentOption === option_0 : option_0.value === activeValue;
331
321
  return /* @__PURE__ */ jsx(AutocompleteOption, {
332
322
  id: `${id}-option-${option_0.value}`,
@@ -339,10 +329,10 @@ function Autocomplete(props) {
339
329
  tabIndex: listFocused && active ? 0 : -1
340
330
  })
341
331
  }, option_0.value);
342
- }, $[125] = activeValue, $[126] = currentOption, $[127] = handleOptionSelect, $[128] = id, $[129] = listFocused, $[130] = loading, $[131] = renderOption, $[132] = t43) : t43 = $[132], t42 = filteredOptions.map(t43), $[116] = activeValue, $[117] = currentOption, $[118] = filteredOptions, $[119] = handleOptionSelect, $[120] = id, $[121] = listFocused, $[122] = loading, $[123] = renderOption, $[124] = t42;
343
- } else t42 = $[124];
344
- let t43;
345
- $[133] !== listBoxId || $[134] !== t42 ? (t43 = /* @__PURE__ */ jsx(Stack, {
332
+ }, $[126] = activeValue, $[127] = currentOption, $[128] = handleOptionSelect, $[129] = id, $[130] = listFocused, $[131] = loading, $[132] = renderOption, $[133] = t40) : t40 = $[133], t39 = filteredOptions.map(t40), $[117] = activeValue, $[118] = currentOption, $[119] = filteredOptions, $[120] = handleOptionSelect, $[121] = id, $[122] = listFocused, $[123] = loading, $[124] = renderOption, $[125] = t39;
333
+ } else t39 = $[125];
334
+ let t40;
335
+ $[134] !== listBoxId || $[135] !== t39 ? (t40 = /* @__PURE__ */ jsx(Stack, {
346
336
  as: "ul",
347
337
  "aria-multiselectable": !1,
348
338
  "data-ui": "AutoComplete__resultsList",
@@ -350,40 +340,40 @@ function Autocomplete(props) {
350
340
  ref: listBoxElementRef,
351
341
  role: "listbox",
352
342
  gap: 1,
353
- children: t42
354
- }), $[133] = listBoxId, $[134] = t42, $[135] = t43) : t43 = $[135];
355
- let t44;
356
- $[136] !== handleListBoxKeyDown || $[137] !== listBox || $[138] !== t41 || $[139] !== t43 ? (t44 = /* @__PURE__ */ jsx(Box, {
343
+ children: t39
344
+ }), $[134] = listBoxId, $[135] = t39, $[136] = t40) : t40 = $[136];
345
+ let t41;
346
+ $[137] !== handleListBoxKeyDown || $[138] !== listBox || $[139] !== t38 || $[140] !== t40 ? (t41 = /* @__PURE__ */ jsx(Box, {
357
347
  "data-ui": "AutoComplete__results",
358
348
  onKeyDown: handleListBoxKeyDown,
359
349
  padding: 1,
360
350
  ...listBox,
361
- className: t41,
351
+ className: t38,
362
352
  tabIndex: -1,
363
- children: t43
364
- }), $[136] = handleListBoxKeyDown, $[137] = listBox, $[138] = t41, $[139] = t43, $[140] = t44) : t44 = $[140], t39 = t44;
353
+ children: t40
354
+ }), $[137] = handleListBoxKeyDown, $[138] = listBox, $[139] = t38, $[140] = t40, $[141] = t41) : t41 = $[141], t36 = t41;
365
355
  }
366
- let content = t39, t40;
356
+ let content = t36, t37;
367
357
  bb3: {
368
358
  if (renderPopover) {
369
- let t41 = !expanded, t42;
370
- $[141] !== content || $[142] !== handlePopoverMouseEnter || $[143] !== handlePopoverMouseLeave || $[144] !== inputElement || $[145] !== renderPopover || $[146] !== t41 ? (t42 = /* @__PURE__ */ jsx(RenderPopover, {
359
+ let t38 = !expanded, t39;
360
+ $[142] !== content || $[143] !== handlePopoverMouseEnter || $[144] !== handlePopoverMouseLeave || $[145] !== inputElement || $[146] !== renderPopover || $[147] !== t38 ? (t39 = /* @__PURE__ */ jsx(RenderPopover, {
371
361
  content,
372
- hidden: t41,
362
+ hidden: t38,
373
363
  inputElement,
374
364
  onMouseEnter: handlePopoverMouseEnter,
375
365
  onMouseLeave: handlePopoverMouseLeave,
376
366
  resultsPopoverElementRef,
377
367
  renderPopover
378
- }), $[141] = content, $[142] = handlePopoverMouseEnter, $[143] = handlePopoverMouseLeave, $[144] = inputElement, $[145] = renderPopover, $[146] = t41, $[147] = t42) : t42 = $[147], t40 = t42;
368
+ }), $[142] = content, $[143] = handlePopoverMouseEnter, $[144] = handlePopoverMouseLeave, $[145] = inputElement, $[146] = renderPopover, $[147] = t38, $[148] = t39) : t39 = $[148], t37 = t39;
379
369
  break bb3;
380
370
  }
381
371
  if (filteredOptionsLen === 0) {
382
- t40 = null;
372
+ t37 = null;
383
373
  break bb3;
384
374
  }
385
- let t41;
386
- $[148] !== content || $[149] !== expanded || $[150] !== handlePopoverMouseEnter || $[151] !== handlePopoverMouseLeave || $[152] !== inputElement || $[153] !== popover || $[154] !== radius ? (t41 = /* @__PURE__ */ jsx(Popover, {
375
+ let t38;
376
+ $[149] !== content || $[150] !== expanded || $[151] !== handlePopoverMouseEnter || $[152] !== handlePopoverMouseLeave || $[153] !== inputElement || $[154] !== popover || $[155] !== radius ? (t38 = /* @__PURE__ */ jsx(Popover, {
387
377
  arrow: !1,
388
378
  constrainSize: !0,
389
379
  content,
@@ -399,14 +389,14 @@ function Autocomplete(props) {
399
389
  ref: resultsPopoverElementRef,
400
390
  referenceElement: inputElement,
401
391
  ...popover
402
- }), $[148] = content, $[149] = expanded, $[150] = handlePopoverMouseEnter, $[151] = handlePopoverMouseLeave, $[152] = inputElement, $[153] = popover, $[154] = radius, $[155] = t41) : t41 = $[155], t40 = t41;
392
+ }), $[149] = content, $[150] = expanded, $[151] = handlePopoverMouseEnter, $[152] = handlePopoverMouseLeave, $[153] = inputElement, $[154] = popover, $[155] = radius, $[156] = t38) : t38 = $[156], t37 = t38;
403
393
  }
404
- let results = t40, t41;
405
- $[156] === loading ? t41 = $[157] : (t41 = loading && /* @__PURE__ */ jsx(SpinnerIcon, { className: "_1b6o2se1" }), $[156] = loading, $[157] = t41);
406
- let t42 = suffix || openButtonNode, t43;
407
- $[158] !== activeItemId || $[159] !== border || $[160] !== clearButton || $[161] !== customValidity || $[162] !== disabled || $[163] !== expanded || $[164] !== fontSize || $[165] !== handleClearButtonClick || $[166] !== handleInputChange || $[167] !== handleInputFocus || $[168] !== icon || $[169] !== id || $[170] !== inputValue || $[171] !== listBoxId || $[172] !== padding || $[173] !== prefix || $[174] !== radius || $[175] !== readOnly || $[176] !== restProps || $[177] !== t41 || $[178] !== t42 ? (t43 = /* @__PURE__ */ jsx(TextInput, {
394
+ let results = t37, t38 = expanded ? activeItemId : void 0, t39;
395
+ $[157] === loading ? t39 = $[158] : (t39 = loading && /* @__PURE__ */ jsx(SpinnerIcon, { className: "_1b6o2se1" }), $[157] = loading, $[158] = t39);
396
+ let t40 = suffix || openButtonNode, t41;
397
+ $[159] !== border || $[160] !== clearButton || $[161] !== customValidity || $[162] !== disabled || $[163] !== expanded || $[164] !== fontSize || $[165] !== handleClearButtonClick || $[166] !== handleInputChange || $[167] !== handleInputFocus || $[168] !== icon || $[169] !== id || $[170] !== inputValue || $[171] !== listBoxId || $[172] !== padding || $[173] !== prefix || $[174] !== radius || $[175] !== readOnly || $[176] !== restProps || $[177] !== t38 || $[178] !== t39 || $[179] !== t40 ? (t41 = /* @__PURE__ */ jsx(TextInput, {
408
398
  ...restProps,
409
- "aria-activedescendant": activeItemId,
399
+ "aria-activedescendant": t38,
410
400
  "aria-autocomplete": "list",
411
401
  "aria-expanded": expanded,
412
402
  "aria-owns": listBoxId,
@@ -419,7 +409,7 @@ function Autocomplete(props) {
419
409
  disabled,
420
410
  fontSize,
421
411
  icon,
422
- iconRight: t41,
412
+ iconRight: t39,
423
413
  id,
424
414
  inputMode: "search",
425
415
  onChange: handleInputChange,
@@ -432,19 +422,19 @@ function Autocomplete(props) {
432
422
  ref: setInputElement,
433
423
  role: "combobox",
434
424
  spellCheck: !1,
435
- suffix: t42,
425
+ suffix: t40,
436
426
  value: inputValue
437
- }), $[158] = activeItemId, $[159] = border, $[160] = clearButton, $[161] = customValidity, $[162] = disabled, $[163] = expanded, $[164] = fontSize, $[165] = handleClearButtonClick, $[166] = handleInputChange, $[167] = handleInputFocus, $[168] = icon, $[169] = id, $[170] = inputValue, $[171] = listBoxId, $[172] = padding, $[173] = prefix, $[174] = radius, $[175] = readOnly, $[176] = restProps, $[177] = t41, $[178] = t42, $[179] = t43) : t43 = $[179];
438
- let t44;
439
- return $[180] !== handleRootBlur || $[181] !== handleRootFocus || $[182] !== handleRootKeyDown || $[183] !== results || $[184] !== t43 ? (t44 = /* @__PURE__ */ jsxs("div", {
427
+ }), $[159] = border, $[160] = clearButton, $[161] = customValidity, $[162] = disabled, $[163] = expanded, $[164] = fontSize, $[165] = handleClearButtonClick, $[166] = handleInputChange, $[167] = handleInputFocus, $[168] = icon, $[169] = id, $[170] = inputValue, $[171] = listBoxId, $[172] = padding, $[173] = prefix, $[174] = radius, $[175] = readOnly, $[176] = restProps, $[177] = t38, $[178] = t39, $[179] = t40, $[180] = t41) : t41 = $[180];
428
+ let t42;
429
+ return $[181] !== handleRootBlur || $[182] !== handleRootFocus || $[183] !== handleRootKeyDown || $[184] !== results || $[185] !== t41 ? (t42 = /* @__PURE__ */ jsxs("div", {
440
430
  className: autocomplete,
441
431
  "data-ui": "Autocomplete",
442
432
  onBlur: handleRootBlur,
443
433
  onFocus: handleRootFocus,
444
434
  onKeyDown: handleRootKeyDown,
445
435
  ref: rootElementRef,
446
- children: [t43, results]
447
- }), $[180] = handleRootBlur, $[181] = handleRootFocus, $[182] = handleRootKeyDown, $[183] = results, $[184] = t43, $[185] = t44) : t44 = $[185], t44;
436
+ children: [t41, results]
437
+ }), $[181] = handleRootBlur, $[182] = handleRootFocus, $[183] = handleRootKeyDown, $[184] = results, $[185] = t41, $[186] = t42) : t42 = $[186], t42;
448
438
  }
449
439
  function _temp2(v_1) {
450
440
  return Math.max(v_1 - 1, 0);