@sanity/ui 4.4.5 → 4.5.0-panda.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{arrow-72xi7WAV.js → arrow-BVbVEhyN.js} +21 -25
- package/dist/arrow-BVbVEhyN.js.map +1 -0
- package/dist/autocomplete.js +8 -10
- package/dist/autocomplete.js.map +1 -1
- package/dist/breadcrumbs.js +5 -6
- package/dist/breadcrumbs.js.map +1 -1
- package/dist/{button-D34_7IeR.js → button-DLiQy0Qz.js} +6 -7
- package/dist/button-DLiQy0Qz.js.map +1 -0
- package/dist/{hotkeys-DInKzmc_.js → hotkeys-D-yvp5RU.js} +4 -6
- package/dist/{hotkeys-DInKzmc_.js.map → hotkeys-D-yvp5RU.js.map} +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -53
- package/dist/index.js.map +1 -1
- package/dist/{layer-Bg3aVJDJ.js → layer-CA793bFP.js} +2 -3
- package/dist/layer-CA793bFP.js.map +1 -0
- package/dist/menu.js +5 -7
- package/dist/menu.js.map +1 -1
- package/dist/{popover-DiKiJ-Cd.js → popover-bcCbXwoP.js} +2 -2
- package/dist/{popover-DiKiJ-Cd.js.map → popover-bcCbXwoP.js.map} +1 -1
- package/dist/popover.js +1 -1
- package/dist/{stack-DpKdobwf.js → stack-TOlBMvbq.js} +2 -3
- package/dist/stack-TOlBMvbq.js.map +1 -0
- package/dist/styles.css +694 -560
- package/dist/{textInput-BMXkOQzX.js → textInput-ByCyqiAh.js} +8 -9
- package/dist/{textInput-BMXkOQzX.js.map → textInput-ByCyqiAh.js.map} +1 -1
- package/dist/toast.js +10 -13
- package/dist/toast.js.map +1 -1
- package/dist/tooltip.js +5 -7
- package/dist/tooltip.js.map +1 -1
- package/package.json +7 -5
- package/dist/arrow-72xi7WAV.js.map +0 -1
- package/dist/button-D34_7IeR.js.map +0 -1
- package/dist/layer-Bg3aVJDJ.js.map +0 -1
- package/dist/stack-DpKdobwf.js.map +0 -1
|
@@ -4,7 +4,6 @@ import { clsx } from "clsx/lite";
|
|
|
4
4
|
import { useContext, useId } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
|
-
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
8
7
|
const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
|
|
9
8
|
version: 0,
|
|
10
9
|
element: null
|
|
@@ -100,10 +99,9 @@ function getRoundedCommands(points) {
|
|
|
100
99
|
function compileCommands(cmds) {
|
|
101
100
|
return cmds.map((n, idx) => n.type === "point" ? `${idx === 0 ? "M" : "L"} ${n.x} ${n.y}` : n.type === "curve" ? `C ${n.startControl.x} ${n.startControl.y} ${n.endControl.x} ${n.endControl.y} ${n.curveEnd.x} ${n.curveEnd.y}` : "").join(" ");
|
|
102
101
|
}
|
|
103
|
-
var arrow = "_1up8bk1", arrowShape = "_1up8bk3", arrowSize = "var(--_1up8bk0)", arrowStroke = "_1up8bk2";
|
|
104
102
|
/** @internal */
|
|
105
103
|
function Arrow(props) {
|
|
106
|
-
let $ = c(
|
|
104
|
+
let $ = c(42), className, h, ref, restProps, style, t0, w;
|
|
107
105
|
$[0] === props ? (className = $[1], h = $[2], ref = $[3], restProps = $[4], style = $[5], t0 = $[6], w = $[7]) : ({className, width: w, height: h, radius: t0, ref, style, ...restProps} = props, $[0] = props, $[1] = className, $[2] = h, $[3] = ref, $[4] = restProps, $[5] = style, $[6] = t0, $[7] = w);
|
|
108
106
|
let radius = t0 === void 0 ? 0 : t0, { card } = useTheme_v2(), strokeMaskId = `stroke-mask-${useId()}`, strokeWidth = card.shadow.outline, center = w / 2, t1;
|
|
109
107
|
$[8] !== center || $[9] !== h || $[10] !== radius || $[11] !== w ? (t1 = compileCommands(getRoundedCommands([
|
|
@@ -132,41 +130,39 @@ function Arrow(props) {
|
|
|
132
130
|
}
|
|
133
131
|
])), $[8] = center, $[9] = h, $[10] = radius, $[11] = w, $[12] = t1) : t1 = $[12];
|
|
134
132
|
let path = t1, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`, t2;
|
|
135
|
-
$[13] === className ? t2 = $[14] : (t2 = clsx(
|
|
133
|
+
$[13] === className ? t2 = $[14] : (t2 = clsx("cXkSBu lhPceK dxAhXf jNWDtd fDskaq czwhQE kWaIza ejXzrG ePAzun iDWtIJ gQimFy dhENJV cwZwVg elNbcS hIhfXc", className), $[13] = className, $[14] = t2);
|
|
136
134
|
let t3 = `${w}px`, t4;
|
|
137
|
-
$[15]
|
|
138
|
-
let t5;
|
|
139
|
-
$[17] !== style || $[18] !== t4 ? (t5 = {
|
|
135
|
+
$[15] !== style || $[16] !== t3 ? (t4 = {
|
|
140
136
|
...style,
|
|
141
|
-
|
|
142
|
-
}, $[
|
|
143
|
-
let t6 = `0 0 ${w} ${w}`, t7;
|
|
144
|
-
$[
|
|
137
|
+
"--arrow-size": t3
|
|
138
|
+
}, $[15] = style, $[16] = t3, $[17] = t4) : t4 = $[17];
|
|
139
|
+
let t5 = t4, t6 = `0 0 ${w} ${w}`, t7;
|
|
140
|
+
$[18] !== strokeWidth || $[19] !== w ? (t7 = /* @__PURE__ */ jsx("rect", {
|
|
145
141
|
x: 0,
|
|
146
142
|
y: strokeWidth,
|
|
147
143
|
width: w,
|
|
148
144
|
height: w,
|
|
149
145
|
fill: "white"
|
|
150
|
-
}), $[
|
|
146
|
+
}), $[18] = strokeWidth, $[19] = w, $[20] = t7) : t7 = $[20];
|
|
151
147
|
let t8;
|
|
152
|
-
$[
|
|
148
|
+
$[21] !== strokeMaskId || $[22] !== t7 ? (t8 = /* @__PURE__ */ jsx("mask", {
|
|
153
149
|
id: strokeMaskId,
|
|
154
150
|
children: t7
|
|
155
|
-
}), $[
|
|
151
|
+
}), $[21] = strokeMaskId, $[22] = t7, $[23] = t8) : t8 = $[23];
|
|
156
152
|
let t9 = `url(#${strokeMaskId})`, t10 = strokeWidth * 2, t11;
|
|
157
|
-
$[
|
|
158
|
-
className:
|
|
153
|
+
$[24] !== strokePath || $[25] !== t10 || $[26] !== t9 ? (t11 = /* @__PURE__ */ jsx("path", {
|
|
154
|
+
className: "duAXIW",
|
|
159
155
|
d: strokePath,
|
|
160
156
|
mask: t9,
|
|
161
157
|
strokeWidth: t10
|
|
162
|
-
}), $[
|
|
158
|
+
}), $[24] = strokePath, $[25] = t10, $[26] = t9, $[27] = t11) : t11 = $[27];
|
|
163
159
|
let t12;
|
|
164
|
-
$[
|
|
165
|
-
className:
|
|
160
|
+
$[28] === fillPath ? t12 = $[29] : (t12 = /* @__PURE__ */ jsx("path", {
|
|
161
|
+
className: "iPpIdb",
|
|
166
162
|
d: fillPath
|
|
167
|
-
}), $[
|
|
163
|
+
}), $[28] = fillPath, $[29] = t12);
|
|
168
164
|
let t13;
|
|
169
|
-
$[
|
|
165
|
+
$[30] !== t11 || $[31] !== t12 || $[32] !== t6 || $[33] !== t8 || $[34] !== w ? (t13 = /* @__PURE__ */ jsxs("svg", {
|
|
170
166
|
width: w,
|
|
171
167
|
height: w,
|
|
172
168
|
viewBox: t6,
|
|
@@ -175,17 +171,17 @@ function Arrow(props) {
|
|
|
175
171
|
t11,
|
|
176
172
|
t12
|
|
177
173
|
]
|
|
178
|
-
}), $[
|
|
174
|
+
}), $[30] = t11, $[31] = t12, $[32] = t6, $[33] = t8, $[34] = w, $[35] = t13) : t13 = $[35];
|
|
179
175
|
let t14;
|
|
180
|
-
return $[
|
|
176
|
+
return $[36] !== ref || $[37] !== restProps || $[38] !== t13 || $[39] !== t2 || $[40] !== t5 ? (t14 = /* @__PURE__ */ jsx("div", {
|
|
181
177
|
"data-ui": "Arrow",
|
|
182
178
|
...restProps,
|
|
183
179
|
className: t2,
|
|
184
180
|
ref,
|
|
185
181
|
style: t5,
|
|
186
182
|
children: t13
|
|
187
|
-
}), $[
|
|
183
|
+
}), $[36] = ref, $[37] = restProps, $[38] = t13, $[39] = t2, $[40] = t5, $[41] = t14) : t14 = $[41], t14;
|
|
188
184
|
}
|
|
189
185
|
export { resolvePortalElement as a, PortalContext as i, Portal as n, useBoundaryElement as o, usePortal as r, BoundaryElementContext as s, Arrow as t };
|
|
190
186
|
|
|
191
|
-
//# sourceMappingURL=arrow-
|
|
187
|
+
//# sourceMappingURL=arrow-BVbVEhyN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-BVbVEhyN.js","names":["createPortal(children, portalElement)","_c","radius = 0","compileCommands(cmds)","clsx(arrow, className)","{...style, '--arrow-size': `${w}px`}","`${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, '--arrow-size': `${w}px`} as CSSProperties}\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>","{...style, '--arrow-size': `${w}px`} as CSSProperties","_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 {css} from '#styled-system/css'\n\nconst arrowSize = 'var(--arrow-size)'\n\nexport const arrow = css({\n 'position': 'absolute',\n 'width': arrowSize,\n 'height': arrowSize,\n ':empty + &': {display: 'none'},\n \"[data-placement^='top'] > &\": {\n 'bottom': `calc(-1 * ${arrowSize})`,\n '& > svg': {transform: 'rotate(0)'},\n },\n \"[data-placement^='right'] > &\": {\n 'left': `calc(-1 * ${arrowSize})`,\n '& > svg': {transform: 'rotate(90deg)'},\n },\n \"[data-placement^='left'] > &\": {\n 'right': `calc(-1 * ${arrowSize})`,\n '& > svg': {transform: 'rotate(-90deg)'},\n },\n \"[data-placement^='bottom'] > &\": {\n 'top': `calc(-1 * ${arrowSize})`,\n '& > svg': {transform: 'rotate(180deg)'},\n },\n '& > svg': {\n display: 'block',\n lineHeight: 0,\n transformOrigin: `calc(${arrowSize} / 2) calc(${arrowSize} / 2)`,\n },\n})\n\nexport const arrowStroke = css({\n stroke: 'var(--card-shadow-outline-color)',\n})\n\nexport const arrowShape = css({\n fill: 'var(--card-bg-color)',\n})\n","import {clsx} from 'clsx/lite'\nimport {CSSProperties, HTMLProps, useId} from 'react'\n\nimport {useTheme_v2} from '../../theme/useTheme'\nimport {compileCommands, getRoundedCommands, Point} from './cmds'\n\nimport {arrow, arrowShape, 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, '--arrow-size': `${w}px`} as CSSProperties}\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,OAAO,IAAI,GAAG,IAAI,SAAS;AAE9C,YAAY,cAAc;AAuB1B,MAAa,gBAAgB,0BAA8C,KAAK;CApB9E,SAAS;CACT,iBAAiB;CACjB,IAAI,UAAU;EAcZ,OAbI,OAAO,WAAa,MACf,QAGL,YAAY,gBAIhB,YAAY,cAAc,SAAS,cAAc,KAAK,GACtD,YAAY,WAAW,CAAC,aAAa,eAAe,EAAE,GAEtD,SAAS,KAAK,YAAY,YAAY,WAAW,IAE1C,YAAY;CACrB;AAG8E,CAAmB;;;;ACrBnG,SAAgB,YAAgC;CAC9C,IAAM,QAAQ,WAAW,aAAa;CAEtC,IAAI,CAAC,OACH,MAAU,MAAM,oCAAoC;CAMtD,IAAI,CAAC,SAAS,KAAK,KAAK,MAAM,YAAY,GACxC,MAAU,MAAM,kDAAkD;CAGpE,OAAO;AACT;;;;ACLA,SAAgB,OAAO,OAA8C;eAC7D,EAAC,UAAU,iBAAiB,SAAQ,OACpC,SAAS,UAAU,GAOlBA;CAAa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E,EAAAA,MAAAA,IACjCN,EAAAA,MAAAA,IADU,EAAA,MAAA;CAPdO,IAAAA;CADF,OAKS,EAAA,QAAA,OAAA,EAAA,QAFD,aAAA,EAAA,QAKJF,OAAAA,EAAAA,QAJWT,MAAAA,EAAAA,QAEJY,MALT,MAAA,oBAAC,OAAD;EACE,WAAQ;EACR,GAAI;EACJ,WAAWZ;EACN;EACL,OAAOY;EAEPH,UAAAA;CAYG,CAAA,GAfE,EAAA,MAAA,KAFD,EAAA,MAAA,WAKJA,EAAAA,MAAAA,KAJWT,EAAAA,MAAAA,IAEJY,EAAAA,MAAAA,gCALTD;AAqBJ"}
|
package/dist/autocomplete.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { c as EMPTY_RECORD, n as _getArrayProp, s as EMPTY_ARRAY } from "./helpers-XThPpWje.js";
|
|
3
|
-
import { h as focusFirstDescendant, p as _hasFocus, t as TextInput, v as _raf } from "./textInput-
|
|
3
|
+
import { h as focusFirstDescendant, p as _hasFocus, t as TextInput, v as _raf } from "./textInput-ByCyqiAh.js";
|
|
4
4
|
import { t as _isEnterToClickElement } from "./element-BYgCE_iK.js";
|
|
5
5
|
import { s as Card, y as Box } from "./useLayer-D_TnC6On.js";
|
|
6
|
-
import { n as Text, t as Stack } from "./stack-
|
|
7
|
-
import { t as Button } from "./button-
|
|
8
|
-
import { t as Popover } from "./popover-
|
|
6
|
+
import { n as Text, t as Stack } from "./stack-TOlBMvbq.js";
|
|
7
|
+
import { t as Button } from "./button-DLiQy0Qz.js";
|
|
8
|
+
import { t as Popover } from "./popover-bcCbXwoP.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";
|
|
@@ -90,9 +90,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
90
90
|
"Meta",
|
|
91
91
|
"Tab",
|
|
92
92
|
"CapsLock"
|
|
93
|
-
], AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"];
|
|
94
|
-
var autocomplete = "gmvfr80", autocompleteListBox = "gmvfr81";
|
|
95
|
-
const DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1;
|
|
93
|
+
], AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1;
|
|
96
94
|
/**
|
|
97
95
|
* The Autocomplete component is typically used for search components.
|
|
98
96
|
* It consists of a text input for writing a query, and properties for rendering suggestions.
|
|
@@ -312,7 +310,7 @@ function Autocomplete(props) {
|
|
|
312
310
|
break bb2;
|
|
313
311
|
}
|
|
314
312
|
let t37 = listBox?.className, t38;
|
|
315
|
-
$[115] === t37 ? t38 = $[116] : (t38 = clsx(
|
|
313
|
+
$[115] === t37 ? t38 = $[116] : (t38 = clsx("hDvsDr cRpRRD juqQPY", t37), $[115] = t37, $[116] = t38);
|
|
316
314
|
let t39;
|
|
317
315
|
if ($[117] !== activeValue || $[118] !== currentOption || $[119] !== filteredOptions || $[120] !== handleOptionSelect || $[121] !== id || $[122] !== listFocused || $[123] !== loading || $[124] !== renderOption) {
|
|
318
316
|
let t40;
|
|
@@ -392,7 +390,7 @@ function Autocomplete(props) {
|
|
|
392
390
|
}), $[149] = content, $[150] = expanded, $[151] = handlePopoverMouseEnter, $[152] = handlePopoverMouseLeave, $[153] = inputElement, $[154] = popover, $[155] = radius, $[156] = t38) : t38 = $[156], t37 = t38;
|
|
393
391
|
}
|
|
394
392
|
let results = t37, t38 = expanded ? activeItemId : void 0, t39;
|
|
395
|
-
$[157] === loading ? t39 = $[158] : (t39 = loading && /* @__PURE__ */ jsx(SpinnerIcon, { className: "
|
|
393
|
+
$[157] === loading ? t39 = $[158] : (t39 = loading && /* @__PURE__ */ jsx(SpinnerIcon, { className: "ljhKOt jmIqco iNjdVt" }), $[157] = loading, $[158] = t39);
|
|
396
394
|
let t40 = suffix || openButtonNode, t41;
|
|
397
395
|
$[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, {
|
|
398
396
|
...restProps,
|
|
@@ -427,7 +425,7 @@ function Autocomplete(props) {
|
|
|
427
425
|
}), $[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
426
|
let t42;
|
|
429
427
|
return $[181] !== handleRootBlur || $[182] !== handleRootFocus || $[183] !== handleRootKeyDown || $[184] !== results || $[185] !== t41 ? (t42 = /* @__PURE__ */ jsxs("div", {
|
|
430
|
-
className:
|
|
428
|
+
className: "eGjDnc",
|
|
431
429
|
"data-ui": "Autocomplete",
|
|
432
430
|
onBlur: handleRootBlur,
|
|
433
431
|
onFocus: handleRootFocus,
|
package/dist/autocomplete.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.js","names":["() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }","useCallback(() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }, [onSelect, value])","(event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n }","useCallback(\n (event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n },\n [handleClick],\n )","<li\n aria-selected={selected}\n data-ui=\"AutocompleteOption\"\n id={id}\n // oxlint-disable-next-line no-noninteractive-element-to-interactive-role, prefer-tag-over-role\n role=\"option\"\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {children}\n </li>","_c","border = true","fontSize = 2","listBox = EMPTY_RECORD","paddingProp = 3","popover = EMPTY_RECORD","radius = 2","renderValue = DEFAULT_RENDER_VALUE","{\n activeValue: valueProp || null,\n focused: false,\n listFocused: false,\n query: null,\n value: valueProp || null,\n }","valueProp || null","({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n )","{value}: BaseAutocompleteOption","value","useCallback(\n ({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n ),\n [fontSize, paddingProp],\n )","() => inputElement","[inputElement]","value !== null ? options.find((o) => o.value === value) : undefined","useMemo(\n () => (value !== null ? options.find((o) => o.value === value) : undefined),\n [options, value],\n )","options.filter((option) => (query ? filterOption(query, option) : true))","(option) => (query ? filterOption(query, option) : true)","useMemo(\n () => options.filter((option) => (query ? filterOption(query, option) : true)),\n [filterOption, options, query],\n )","(event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n }","useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n },\n [onBlur, onQueryChange, relatedElements],\n )","(event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }","event","listFocused","useCallback((event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }, [])","(v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n }","useCallback(\n (v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n },\n [onChange, onSelect, onQueryChange],\n )","(event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n }","o","activeOption","activeIndex","nextActiveOption","useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n },\n [activeValue, filteredOptions, filteredOptionsLen, onQueryChange],\n )","(event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n }","useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n },\n [onQueryChange],\n )","() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }","useCallback(() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }, [currentOption, renderValue, value])","(event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n }","useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n },\n [focused, onFocus, openOnFocus, dispatchOpen],\n )","() => {\n popoverMouseWithinRef.current = true\n }","useCallback(() => {\n popoverMouseWithinRef.current = true\n }, [])","() => {\n popoverMouseWithinRef.current = false\n }","useCallback(() => {\n popoverMouseWithinRef.current = false\n }, [])","() => {\n dispatch({type: 'root/clear'})\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }","useCallback(() => {\n dispatch({type: 'root/clear'})\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }, [onChange, onQueryChange])","() => {\n dispatch({type: 'input/focus'})\n }","useCallback(() => {\n dispatch({type: 'input/focus'})\n }, [])","() => {\n const listElement = listBoxElementRef.current\n\n if (!listFocused || !listElement) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n\n if (activeOption) {\n const activeIndex = filteredOptions.indexOf(activeOption)\n // oxlint-disable-next-line no-unsafe-type-assertion\n const activeItemElement = listElement.childNodes[activeIndex] as HTMLLIElement | undefined\n\n if (activeItemElement) {\n if (_hasFocus(activeItemElement)) {\n // already focused\n return\n }\n\n focusFirstDescendant(activeItemElement)\n }\n }\n }","() => {\n if (expanded) focusActiveOption()\n }","[activeValue, expanded, filteredOptions]","useMemo(() => {\n if (!loading && !disabled && value) {\n return {\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }\n }\n\n return undefined\n }, [disabled, handleClearButtonFocus, loading, value])","{\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }","(v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n }","(v) => Math.max(v - 1, 0)","(event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n }","openButtonProps.onClick","useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n },\n [openButtonProps, dispatchOpen],\n )","!disabled && !readOnly && openButton ? (\n <Box aria-hidden={querying} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={querying}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined","useMemo(\n () =>\n !disabled && !readOnly && openButton ? (\n <Box aria-hidden={querying} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={querying}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined,\n [\n disabled,\n fontSize,\n handleOpenClick,\n openButton,\n openButtonBoxPadding,\n openButtonPadding,\n openButtonProps,\n querying,\n readOnly,\n ],\n )","useMemo(() => {\n if (query === null) {\n if (value !== null) {\n return renderValue(value, currentOption)\n }\n\n return ''\n }\n\n return query\n }, [currentOption, query, renderValue, value])","renderValue(value, currentOption)","(event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n }","useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n },\n [listFocused],\n )","useMemo(() => {\n if (filteredOptions.length === 0) return null\n\n return (\n <Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>\n )\n }, [\n activeValue,\n currentOption,\n filteredOptions,\n handleOptionSelect,\n handleListBoxKeyDown,\n id,\n listBox,\n listBoxId,\n listFocused,\n loading,\n renderOption,\n ])","clsx(autocompleteListBox, listBox?.className)","listBox?.className","filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })","(option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n }","option","<Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>","<Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>","useMemo(() => {\n if (renderPopover) {\n return (\n <RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />\n )\n }\n\n if (filteredOptionsLen === 0) {\n return null\n }\n\n return (\n <Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />\n )\n }, [\n content,\n expanded,\n filteredOptionsLen,\n handlePopoverMouseEnter,\n handlePopoverMouseLeave,\n inputElement,\n popover,\n radius,\n renderPopover,\n ])","<RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />","!expanded","<Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />","loading && <SpinnerIcon className={spinnerIcon} />","<TextInput\n {...restProps}\n aria-activedescendant={expanded ? activeItemId : undefined}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />","expanded ? activeItemId : undefined","suffix || openButtonNode","<div\n className={autocomplete}\n data-ui=\"Autocomplete\"\n onBlur={handleRootBlur}\n onFocus={handleRootFocus}\n onKeyDown={handleRootKeyDown}\n ref={rootElementRef}\n >\n <TextInput\n {...restProps}\n aria-activedescendant={expanded ? activeItemId : undefined}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />\n {results}\n </div>","v","_c","defaultRenderOption","\"onFocus\""],"sources":["../src/core/components/autocomplete/autocompleteOption.tsx","../src/core/components/autocomplete/autocompleteReducer.ts","../src/core/components/autocomplete/constants.ts","../src/core/components/autocomplete/autocomplete.css.ts","../src/core/components/autocomplete/autocomplete.tsx"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {_isEnterToClickElement} from '../../helpers/element'\n\nexport interface AutocompleteOptionProps {\n children: React.ReactNode\n id: string\n onSelect: (v: string) => void\n selected: boolean\n value: string\n}\n\nexport function AutocompleteOption(props: AutocompleteOptionProps): React.JSX.Element {\n const {children, id, onSelect, selected, value} = props\n\n const handleClick = useCallback(() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }, [onSelect, value])\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n },\n [handleClick],\n )\n\n return (\n <li\n aria-selected={selected}\n data-ui=\"AutocompleteOption\"\n id={id}\n // oxlint-disable-next-line no-noninteractive-element-to-interactive-role, prefer-tag-over-role\n role=\"option\"\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {children}\n </li>\n )\n}\n","import {AutocompleteMsg, AutocompleteState} from './types'\n\n/**\n * @internal\n */\nexport function autocompleteReducer(\n state: AutocompleteState,\n msg: AutocompleteMsg,\n): AutocompleteState {\n if (msg.type === 'input/change') {\n return {...state, activeValue: null, focused: true, query: msg.query}\n }\n\n if (msg.type === 'input/focus') {\n return {...state, focused: true}\n }\n\n // Closing puts the active option back on the value. It also ends keyboard navigation in the list,\n // which an arrow key can start before the list shows, with no focus event to end it.\n if (msg.type === 'root/blur' || msg.type === 'root/escape') {\n return {\n ...state,\n activeValue: state.value || state.activeValue,\n focused: false,\n listFocused: false,\n query: null,\n }\n }\n\n if (msg.type === 'root/clear') {\n return {...state, activeValue: null, query: null, value: null}\n }\n\n if (msg.type === 'root/open') {\n return {...state, query: state.query ?? msg.query}\n }\n\n if (msg.type === 'root/setActiveValue') {\n return {...state, activeValue: msg.value, listFocused: msg.listFocused || state.listFocused}\n }\n\n if (msg.type === 'root/setListFocused') {\n return {...state, listFocused: msg.listFocused}\n }\n\n if (msg.type === 'value/change') {\n return {...state, activeValue: msg.value, query: null, value: msg.value}\n }\n\n return state\n}\n","import {Placement} from '../../types/placement'\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [\n 'Control',\n 'Shift',\n 'Alt',\n 'Enter',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n 'Meta',\n 'Tab',\n 'CapsLock',\n]\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_POPOVER_PLACEMENT: Placement = 'bottom-start'\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS: Placement[] = ['bottom-start', 'top-start']\n","import {globalStyle, style} from '@vanilla-extract/css'\n\nexport const autocomplete = style({\n lineHeight: 0,\n})\n\nexport const autocompleteListBox = style({})\n\nglobalStyle(`${autocompleteListBox} > ul`, {\n listStyle: 'none',\n padding: 0,\n margin: 0,\n})\n","import {ChevronDownIcon} from '@sanity/icons/ChevronDown'\nimport {SpinnerIcon} from '@sanity/icons/Spinner'\nimport {clsx} from 'clsx/lite'\nimport {\n ChangeEvent,\n cloneElement,\n ElementType,\n FocusEvent,\n HTMLProps,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n Ref,\n useCallback,\n useDeferredValue,\n useEffect,\n useImperativeHandle,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from 'react'\n// TODO: switch to `useEffectEvent` from `react` once https://github.com/facebook/react/issues/34818\n// is fixed in the lowest React version we support (consumers may wrap `Autocomplete` in `memo`)\nimport {useEffectEvent} from 'use-effect-event'\n\nimport {EMPTY_ARRAY, EMPTY_RECORD} from '../../constants'\nimport {_raf} from '../../helpers/animation'\nimport {_hasFocus, focusFirstDescendant} from '../../helpers/focus'\nimport {Box, BoxProps} from '../../primitives/box/box'\nimport {Button} from '../../primitives/button/button'\nimport {Card} from '../../primitives/card/card'\nimport {Popover, PopoverProps} from '../../primitives/popover/popover'\nimport {Stack} from '../../primitives/stack/stack'\nimport {Text} from '../../primitives/text/text'\nimport {TextInput} from '../../primitives/textInput/textInput'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {Radius} from '../../types/radius'\nimport {AutocompleteOption} from './autocompleteOption'\nimport {autocompleteReducer} from './autocompleteReducer'\nimport {\n AUTOCOMPLETE_LISTBOX_IGNORE_KEYS,\n AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS,\n AUTOCOMPLETE_POPOVER_PLACEMENT,\n} from './constants'\nimport {AutocompleteOpenButtonProps, BaseAutocompleteOption} from './types'\n\nimport {spinnerIcon} from '../../primitives/spinner/spinner.css'\nimport {autocomplete, autocompleteListBox} from './autocomplete.css'\n\n/**\n * @public\n */\nexport interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseAutocompleteOption> {\n border?: boolean\n customValidity?: string\n filterOption?: (query: string, option: Option) => boolean\n fontSize?: number | number[]\n // oxlint-disable-next-line no-redundant-type-constituents\n icon?: ElementType | ReactNode\n id: string\n /** @beta */\n listBox?: BoxProps\n loading?: boolean\n onChange?: (value: string) => void\n onQueryChange?: (query: string | null) => void\n onSelect?: (value: string) => void\n /** @beta */\n openButton?: boolean | AutocompleteOpenButtonProps\n /** @beta */\n openOnFocus?: boolean\n /** The options to render. */\n options?: Option[]\n padding?: number | number[]\n popover?: Omit<PopoverProps, 'content' | 'onMouseEnter' | 'onMouseLeave' | 'open'> &\n Omit<HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'ref' | 'width'>\n prefix?: ReactNode\n radius?: Radius | Radius[]\n /** @beta */\n relatedElements?: HTMLElement[]\n /** The callback function for rendering each option. */\n renderOption?: (option: Option) => React.JSX.Element\n /** @beta */\n renderPopover?: (\n props: {\n content: React.JSX.Element | null\n hidden: boolean\n inputElement: HTMLInputElement | null\n onMouseEnter: () => void\n onMouseLeave: () => void\n },\n ref: Ref<HTMLDivElement>,\n ) => ReactNode\n renderValue?: (value: string, option?: Option) => string\n suffix?: ReactNode\n /**\n * The current value. A changed `value` replaces the value shown and drops a pending query,\n * unless it equals the value shown (a parent echoing `onChange`). A selection or clear shows\n * until `value` changes, and changing `value` to `undefined` keeps the value shown.\n */\n value?: string\n}\n\nconst DEFAULT_RENDER_VALUE = (value: string, option?: BaseAutocompleteOption) =>\n option ? option.value : value\n\nconst DEFAULT_FILTER_OPTION = (query: string, option: BaseAutocompleteOption) =>\n option.value.toLowerCase().indexOf(query.toLowerCase()) > -1\n\n/**\n * The Autocomplete component is typically used for search components.\n * It consists of a text input for writing a query, and properties for rendering suggestions.\n *\n * @public\n */\nexport function Autocomplete<Option extends BaseAutocompleteOption>(\n props: AutocompleteProps<Option> &\n Omit<\n HTMLProps<HTMLInputElement>,\n | 'aria-activedescendant'\n | 'aria-autocomplete'\n | 'aria-expanded'\n | 'aria-owns'\n | 'as'\n | 'autoCapitalize'\n | 'autoComplete'\n | 'autoCorrect'\n | 'id'\n | 'inputMode'\n | 'onChange'\n | 'onSelect'\n | 'popover'\n | 'prefix'\n | 'role'\n | 'spellCheck'\n | 'type'\n | 'value'\n >,\n) {\n const {\n border = true,\n customValidity,\n disabled,\n filterOption: filterOptionProp,\n fontSize = 2,\n icon,\n id,\n listBox = EMPTY_RECORD,\n loading,\n onBlur,\n onChange,\n onFocus,\n onQueryChange,\n onSelect,\n openButton,\n openOnFocus,\n options: optionsProp,\n padding: paddingProp = 3,\n popover = EMPTY_RECORD,\n prefix,\n radius = 2,\n readOnly,\n ref: forwardedRef,\n relatedElements,\n renderOption: renderOptionProp,\n renderPopover,\n renderValue = DEFAULT_RENDER_VALUE,\n suffix,\n value: valueProp,\n ...restProps\n } = props\n\n const [state, dispatch] = useReducer(autocompleteReducer, {\n activeValue: valueProp || null,\n focused: false,\n listFocused: false,\n query: null,\n value: valueProp || null,\n })\n\n const {activeValue, focused, listFocused, query, value} = state\n\n // https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes\n const [prevValueProp, setPrevValueProp] = useState(valueProp)\n\n if (valueProp !== prevValueProp) {\n setPrevValueProp(valueProp)\n // A clear stores `null` and reports `''`\n if (valueProp !== undefined && (valueProp || null) !== value) {\n dispatch({type: 'value/change', value: valueProp})\n }\n }\n\n const defaultRenderOption = useCallback(\n ({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n ),\n [fontSize, paddingProp],\n )\n\n const renderOption =\n typeof renderOptionProp === 'function' ? renderOptionProp : defaultRenderOption\n\n const filterOption =\n typeof filterOptionProp === 'function' ? filterOptionProp : DEFAULT_FILTER_OPTION\n\n // Element refs\n const rootElementRef = useRef<HTMLDivElement | null>(null)\n const resultsPopoverElementRef = useRef<HTMLDivElement | null>(null)\n const inputElementRef = useRef<HTMLInputElement | null>(null)\n const listBoxElementRef = useRef<HTMLUListElement | null>(null)\n // Element refs that need to be accessed during render\n const [inputElement, setInputElement] = useState<HTMLInputElement | null>(null)\n\n // Value refs\n const listFocusedRef = useRef(false)\n const popoverMouseWithinRef = useRef(false)\n\n // Forward inputElement state to inputElementRef\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n inputElementRef,\n () => inputElement,\n [inputElement],\n )\n // Forward inputElement to parent\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n forwardedRef,\n () => inputElement,\n [inputElement],\n )\n\n const listBoxId = `${id}-listbox`\n const options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY\n const padding = _getArrayProp(paddingProp)\n const currentOption = useMemo(\n () => (value !== null ? options.find((o) => o.value === value) : undefined),\n [options, value],\n )\n const filteredOptions = useMemo(\n () => options.filter((option) => (query ? filterOption(query, option) : true)),\n [filterOption, options, query],\n )\n const filteredOptionsLen = filteredOptions.length\n const activeItemId = activeValue ? `${id}-option-${activeValue}` : undefined\n const querying = (query !== null && loading) || (focused && query !== null)\n // The list opens in a deferred render, so the keystroke, focus or click that opens it paints\n // first, and closes in the same render as the state that closes it. Dispatching the open in a\n // transition instead would drop a render-phase `value` sync while the transition is pending.\n const deferredQuerying = useDeferredValue(querying)\n const expanded = querying && deferredQuerying\n\n const handleRootBlur = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n },\n [onBlur, onQueryChange, relatedElements],\n )\n\n const handleRootFocus = useCallback((event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }, [])\n\n const handleOptionSelect = useCallback(\n (v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n },\n [onChange, onSelect, onQueryChange],\n )\n\n const handleRootKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n },\n [activeValue, filteredOptions, filteredOptionsLen, onQueryChange],\n )\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n },\n [onQueryChange],\n )\n\n const dispatchOpen = useCallback(() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }, [currentOption, renderValue, value])\n\n const handleInputFocus = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n },\n [focused, onFocus, openOnFocus, dispatchOpen],\n )\n\n const handlePopoverMouseEnter = useCallback(() => {\n popoverMouseWithinRef.current = true\n }, [])\n\n const handlePopoverMouseLeave = useCallback(() => {\n popoverMouseWithinRef.current = false\n }, [])\n\n const handleClearButtonClick = useCallback(() => {\n dispatch({type: 'root/clear'})\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }, [onChange, onQueryChange])\n\n const handleClearButtonFocus = useCallback(() => {\n dispatch({type: 'input/focus'})\n }, [])\n\n // Focus the active option, but only while the keyboard is in the list: opening the list leaves\n // focus in the input even when the option is focusable (a link or button). An effect event, so\n // focus entering the list on a click does not re-run it and scroll the clicked option away.\n const focusActiveOption = useEffectEvent(() => {\n const listElement = listBoxElementRef.current\n\n if (!listFocused || !listElement) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n\n if (activeOption) {\n const activeIndex = filteredOptions.indexOf(activeOption)\n // oxlint-disable-next-line no-unsafe-type-assertion\n const activeItemElement = listElement.childNodes[activeIndex] as HTMLLIElement | undefined\n\n if (activeItemElement) {\n if (_hasFocus(activeItemElement)) {\n // already focused\n return\n }\n\n focusFirstDescendant(activeItemElement)\n }\n }\n })\n\n // Also runs when the deferred render shows the list, for an arrow key pressed before it did\n useEffect(() => {\n if (expanded) focusActiveOption()\n }, [activeValue, expanded, filteredOptions])\n\n const clearButton = useMemo(() => {\n if (!loading && !disabled && value) {\n return {\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }\n }\n\n return undefined\n }, [disabled, handleClearButtonFocus, loading, value])\n\n const openButtonBoxPadding = padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n })\n const openButtonPadding = padding.map((v) => Math.max(v - 1, 0))\n const openButtonProps: AutocompleteOpenButtonProps =\n typeof openButton === 'object' ? openButton : EMPTY_RECORD\n\n const handleOpenClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n },\n [openButtonProps, dispatchOpen],\n )\n\n const openButtonNode = useMemo(\n () =>\n !disabled && !readOnly && openButton ? (\n <Box aria-hidden={querying} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={querying}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined,\n [\n disabled,\n fontSize,\n handleOpenClick,\n openButton,\n openButtonBoxPadding,\n openButtonPadding,\n openButtonProps,\n querying,\n readOnly,\n ],\n )\n\n const inputValue = useMemo(() => {\n if (query === null) {\n if (value !== null) {\n return renderValue(value, currentOption)\n }\n\n return ''\n }\n\n return query\n }, [currentOption, query, renderValue, value])\n\n const handleListBoxKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n },\n [listFocused],\n )\n\n const content = useMemo(() => {\n if (filteredOptions.length === 0) return null\n\n return (\n <Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>\n )\n }, [\n activeValue,\n currentOption,\n filteredOptions,\n handleOptionSelect,\n handleListBoxKeyDown,\n id,\n listBox,\n listBoxId,\n listFocused,\n loading,\n renderOption,\n ])\n\n const results = useMemo(() => {\n if (renderPopover) {\n return (\n <RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />\n )\n }\n\n if (filteredOptionsLen === 0) {\n return null\n }\n\n return (\n <Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />\n )\n }, [\n content,\n expanded,\n filteredOptionsLen,\n handlePopoverMouseEnter,\n handlePopoverMouseLeave,\n inputElement,\n popover,\n radius,\n renderPopover,\n ])\n\n return (\n // The handlers only observe focus and key events bubbling from the input and\n // list box, which carry the roles; the wrapper itself is not interactive.\n // oxlint-disable-next-line no-static-element-interactions\n <div\n className={autocomplete}\n data-ui=\"Autocomplete\"\n onBlur={handleRootBlur}\n onFocus={handleRootFocus}\n onKeyDown={handleRootKeyDown}\n ref={rootElementRef}\n >\n <TextInput\n {...restProps}\n aria-activedescendant={expanded ? activeItemId : undefined}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />\n {results}\n </div>\n )\n}\n\nfunction RenderPopover({\n renderPopover,\n content,\n hidden,\n inputElement,\n onMouseEnter,\n onMouseLeave,\n resultsPopoverElementRef,\n}: {\n renderPopover: Exclude<AutocompleteProps['renderPopover'], undefined>\n resultsPopoverElementRef: Parameters<Exclude<AutocompleteProps['renderPopover'], undefined>>[1]\n} & Parameters<Exclude<AutocompleteProps['renderPopover'], undefined>>[0]) {\n return renderPopover(\n {\n content,\n hidden,\n inputElement,\n onMouseEnter,\n onMouseLeave,\n },\n resultsPopoverElementRef,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAgB,mBAAmB,OAAmD;gBAC9E,EAAC,UAAU,IAAI,UAAU,UAAU,UAAS,OAElBA;CAI5B,AAAA,EAAA,OAAA,YAAA,EAAA,OAAS,SAJmB,WAAM;EAGpC,iBAAiB;GACf,SAAS,KAAK;EAChB,GAAG,CAAC;CACN,GAFI,EAAA,KAAA,UAAS,EAAA,KAAA;CAJb,IAAM,cAAcC,IASlBC;CAEI,AAAA,EAAA,OAAA,2BAFJ,MAAC,UAA8C;EAC7C,AAAI,MAAM,QAAQ,WAAW,CAAC,uBAAuB,MAAM,aAAa,KACtE,YAAY;CAEhB,GAFI,EAAA,KAAA;CAHN,IAAM,gBAAgBC,IAUpBC;CADF,OAUK,EAAA,OAAA,YAAA,EAAA,OAHQ,eAAA,EAAA,OACE,iBAAA,EAAA,OAJP,MAAA,EAAA,OAFW,YADjB,KAAA,oBAAC,MAAD;EACE,iBAAe;EACf,WAAQ;EACJ;EAEJ,MAAK;EACL,SAAS;EACT,WAAW;EAEV;CACC,CAAA,GADD,EAAA,KAAA,UAHQ,EAAA,KAAA,aACE,EAAA,KAAA,eAJP,EAAA,KAAA,IAFW,EAAA,KAAA,o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AA,OAAA,UARK,EAAA,OAAA,UASL,EAAA,OAAA,UAMD,EAAA,OAAA,wBADC,EAAA,OAAA,mBAED,EAAA,OAAA,kBANH,EAAA,OAAA,MAEF,EAAA,OAAA,IAcG,EAAA,OAAA,YAzBI,EAAA,OAAA,WAgBF,EAAA,OAAA,SACD,EAAA,OAAA,QACA,EAAA,OAAA,QACE,EAAA,OAAA,UAvBN,EAAA,OAAA,WACmBD,EAAAA,OAAAA,KAaZF,EAAAA,OAAAA,KAcHG,EAAAA,OAAAA;CArCZC,IAAAA;CAJF,OAOY,EAAA,SAAA,kBAAA,EAAA,SACC,mBAAA,EAAA,SACE,qBAAA,EAAA,SAmCV,WAAA,EAAA,SAhCDH,OARF,MAAA,qBAAC,OAAD;EACE,WAAW;EACX,WAAQ;EACR,QAAQ;EACR,SAAS;EACT,WAAW;EACX,KAAK;EANP,UAAA,CAQEA,KAgCC,OACE;KAtCK,EAAA,OAAA,gBACC,EAAA,OAAA,iBACE,EAAA,OAAA,mBAmCV,EAAA,OAAA,SAhCDA,EAAAA,OAAAA,mCARFG;AA2CJ;AA9NwC,SAAA,OAAC,KAAA;CAAM,OAAA,KAAK,IAAIC,MAAI,GAAG,CAAC;;AAPrB,SAAA,MAAC,KAAM;CAK9C,OAJIA,QAAM,IAAU,IAChBA,QAAM,KACNA,QAAM,IAAU,IAEbA,MAAI;AACb;AAiOF,SAAS,cAAc,EACrB,eACA,SACA,QACA,cACA,cACA,cACA,4BAIyE;CACzE,OAAO,cACL;EACE;EACA;EACA;EACA;EACA;CACF,GACA,wBACF;AACF"}
|
|
1
|
+
{"version":3,"file":"autocomplete.js","names":["() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }","useCallback(() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }, [onSelect, value])","(event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n }","useCallback(\n (event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n },\n [handleClick],\n )","<li\n aria-selected={selected}\n data-ui=\"AutocompleteOption\"\n id={id}\n // oxlint-disable-next-line no-noninteractive-element-to-interactive-role, prefer-tag-over-role\n role=\"option\"\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {children}\n </li>","_c","border = true","fontSize = 2","listBox = EMPTY_RECORD","paddingProp = 3","popover = EMPTY_RECORD","radius = 2","renderValue = DEFAULT_RENDER_VALUE","{\n activeValue: valueProp || null,\n focused: false,\n listFocused: false,\n query: null,\n value: valueProp || null,\n }","valueProp || null","({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n )","{value}: BaseAutocompleteOption","value","useCallback(\n ({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n ),\n [fontSize, paddingProp],\n )","() => inputElement","[inputElement]","value !== null ? options.find((o) => o.value === value) : undefined","useMemo(\n () => (value !== null ? options.find((o) => o.value === value) : undefined),\n [options, value],\n )","options.filter((option) => (query ? filterOption(query, option) : true))","(option) => (query ? filterOption(query, option) : true)","useMemo(\n () => options.filter((option) => (query ? filterOption(query, option) : true)),\n [filterOption, options, query],\n )","(event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n }","useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n },\n [onBlur, onQueryChange, relatedElements],\n )","(event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }","event","listFocused","useCallback((event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }, [])","(v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n }","useCallback(\n (v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n },\n [onChange, onSelect, onQueryChange],\n )","(event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n }","o","activeOption","activeIndex","nextActiveOption","useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n },\n [activeValue, filteredOptions, filteredOptionsLen, onQueryChange],\n )","(event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n }","useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n },\n [onQueryChange],\n )","() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }","useCallback(() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }, [currentOption, renderValue, value])","(event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n }","useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n },\n [focused, onFocus, openOnFocus, dispatchOpen],\n )","() => {\n popoverMouseWithinRef.current = true\n }","useCallback(() => {\n popoverMouseWithinRef.current = true\n }, [])","() => {\n popoverMouseWithinRef.current = false\n }","useCallback(() => {\n popoverMouseWithinRef.current = false\n }, [])","() => {\n dispatch({type: 'root/clear'})\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }","useCallback(() => {\n dispatch({type: 'root/clear'})\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }, [onChange, onQueryChange])","() => {\n dispatch({type: 'input/focus'})\n }","useCallback(() => {\n dispatch({type: 'input/focus'})\n }, [])","() => {\n const listElement = listBoxElementRef.current\n\n if (!listFocused || !listElement) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n\n if (activeOption) {\n const activeIndex = filteredOptions.indexOf(activeOption)\n // oxlint-disable-next-line no-unsafe-type-assertion\n const activeItemElement = listElement.childNodes[activeIndex] as HTMLLIElement | undefined\n\n if (activeItemElement) {\n if (_hasFocus(activeItemElement)) {\n // already focused\n return\n }\n\n focusFirstDescendant(activeItemElement)\n }\n }\n }","() => {\n if (expanded) focusActiveOption()\n }","[activeValue, expanded, filteredOptions]","useMemo(() => {\n if (!loading && !disabled && value) {\n return {\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }\n }\n\n return undefined\n }, [disabled, handleClearButtonFocus, loading, value])","{\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }","(v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n }","(v) => Math.max(v - 1, 0)","(event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n }","openButtonProps.onClick","useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n },\n [openButtonProps, dispatchOpen],\n )","!disabled && !readOnly && openButton ? (\n <Box aria-hidden={querying} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={querying}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined","useMemo(\n () =>\n !disabled && !readOnly && openButton ? (\n <Box aria-hidden={querying} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={querying}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined,\n [\n disabled,\n fontSize,\n handleOpenClick,\n openButton,\n openButtonBoxPadding,\n openButtonPadding,\n openButtonProps,\n querying,\n readOnly,\n ],\n )","useMemo(() => {\n if (query === null) {\n if (value !== null) {\n return renderValue(value, currentOption)\n }\n\n return ''\n }\n\n return query\n }, [currentOption, query, renderValue, value])","renderValue(value, currentOption)","(event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n }","useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n },\n [listFocused],\n )","useMemo(() => {\n if (filteredOptions.length === 0) return null\n\n return (\n <Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>\n )\n }, [\n activeValue,\n currentOption,\n filteredOptions,\n handleOptionSelect,\n handleListBoxKeyDown,\n id,\n listBox,\n listBoxId,\n listFocused,\n loading,\n renderOption,\n ])","clsx(autocompleteListBox, listBox?.className)","listBox?.className","filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })","(option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n }","option","<Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>","<Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>","useMemo(() => {\n if (renderPopover) {\n return (\n <RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />\n )\n }\n\n if (filteredOptionsLen === 0) {\n return null\n }\n\n return (\n <Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />\n )\n }, [\n content,\n expanded,\n filteredOptionsLen,\n handlePopoverMouseEnter,\n handlePopoverMouseLeave,\n inputElement,\n popover,\n radius,\n renderPopover,\n ])","<RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />","!expanded","<Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />","loading && <SpinnerIcon className={spinnerIcon} />","<TextInput\n {...restProps}\n aria-activedescendant={expanded ? activeItemId : undefined}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />","expanded ? activeItemId : undefined","suffix || openButtonNode","<div\n className={autocomplete}\n data-ui=\"Autocomplete\"\n onBlur={handleRootBlur}\n onFocus={handleRootFocus}\n onKeyDown={handleRootKeyDown}\n ref={rootElementRef}\n >\n <TextInput\n {...restProps}\n aria-activedescendant={expanded ? activeItemId : undefined}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />\n {results}\n </div>","v","_c","defaultRenderOption","\"onFocus\""],"sources":["../src/core/components/autocomplete/autocompleteOption.tsx","../src/core/components/autocomplete/autocompleteReducer.ts","../src/core/components/autocomplete/constants.ts","../src/core/components/autocomplete/autocomplete.css.ts","../src/core/components/autocomplete/autocomplete.tsx"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {_isEnterToClickElement} from '../../helpers/element'\n\nexport interface AutocompleteOptionProps {\n children: React.ReactNode\n id: string\n onSelect: (v: string) => void\n selected: boolean\n value: string\n}\n\nexport function AutocompleteOption(props: AutocompleteOptionProps): React.JSX.Element {\n const {children, id, onSelect, selected, value} = props\n\n const handleClick = useCallback(() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }, [onSelect, value])\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n },\n [handleClick],\n )\n\n return (\n <li\n aria-selected={selected}\n data-ui=\"AutocompleteOption\"\n id={id}\n // oxlint-disable-next-line no-noninteractive-element-to-interactive-role, prefer-tag-over-role\n role=\"option\"\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {children}\n </li>\n )\n}\n","import {AutocompleteMsg, AutocompleteState} from './types'\n\n/**\n * @internal\n */\nexport function autocompleteReducer(\n state: AutocompleteState,\n msg: AutocompleteMsg,\n): AutocompleteState {\n if (msg.type === 'input/change') {\n return {...state, activeValue: null, focused: true, query: msg.query}\n }\n\n if (msg.type === 'input/focus') {\n return {...state, focused: true}\n }\n\n // Closing puts the active option back on the value. It also ends keyboard navigation in the list,\n // which an arrow key can start before the list shows, with no focus event to end it.\n if (msg.type === 'root/blur' || msg.type === 'root/escape') {\n return {\n ...state,\n activeValue: state.value || state.activeValue,\n focused: false,\n listFocused: false,\n query: null,\n }\n }\n\n if (msg.type === 'root/clear') {\n return {...state, activeValue: null, query: null, value: null}\n }\n\n if (msg.type === 'root/open') {\n return {...state, query: state.query ?? msg.query}\n }\n\n if (msg.type === 'root/setActiveValue') {\n return {...state, activeValue: msg.value, listFocused: msg.listFocused || state.listFocused}\n }\n\n if (msg.type === 'root/setListFocused') {\n return {...state, listFocused: msg.listFocused}\n }\n\n if (msg.type === 'value/change') {\n return {...state, activeValue: msg.value, query: null, value: msg.value}\n }\n\n return state\n}\n","import {Placement} from '../../types/placement'\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [\n 'Control',\n 'Shift',\n 'Alt',\n 'Enter',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n 'Meta',\n 'Tab',\n 'CapsLock',\n]\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_POPOVER_PLACEMENT: Placement = 'bottom-start'\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS: Placement[] = ['bottom-start', 'top-start']\n","import {css} from '#styled-system/css'\n\nexport const autocomplete = css({\n lineHeight: 0,\n})\n\nexport const autocompleteListBox = css({\n '& > ul': {\n listStyle: 'none',\n padding: 0,\n margin: 0,\n },\n})\n","import {ChevronDownIcon} from '@sanity/icons/ChevronDown'\nimport {SpinnerIcon} from '@sanity/icons/Spinner'\nimport {clsx} from 'clsx/lite'\nimport {\n ChangeEvent,\n cloneElement,\n ElementType,\n FocusEvent,\n HTMLProps,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n Ref,\n useCallback,\n useDeferredValue,\n useEffect,\n useImperativeHandle,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from 'react'\n// TODO: switch to `useEffectEvent` from `react` once https://github.com/facebook/react/issues/34818\n// is fixed in the lowest React version we support (consumers may wrap `Autocomplete` in `memo`)\nimport {useEffectEvent} from 'use-effect-event'\n\nimport {EMPTY_ARRAY, EMPTY_RECORD} from '../../constants'\nimport {_raf} from '../../helpers/animation'\nimport {_hasFocus, focusFirstDescendant} from '../../helpers/focus'\nimport {Box, BoxProps} from '../../primitives/box/box'\nimport {Button} from '../../primitives/button/button'\nimport {Card} from '../../primitives/card/card'\nimport {Popover, PopoverProps} from '../../primitives/popover/popover'\nimport {Stack} from '../../primitives/stack/stack'\nimport {Text} from '../../primitives/text/text'\nimport {TextInput} from '../../primitives/textInput/textInput'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {Radius} from '../../types/radius'\nimport {AutocompleteOption} from './autocompleteOption'\nimport {autocompleteReducer} from './autocompleteReducer'\nimport {\n AUTOCOMPLETE_LISTBOX_IGNORE_KEYS,\n AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS,\n AUTOCOMPLETE_POPOVER_PLACEMENT,\n} from './constants'\nimport {AutocompleteOpenButtonProps, BaseAutocompleteOption} from './types'\n\nimport {spinnerIcon} from '../../primitives/spinner/spinner.css'\nimport {autocomplete, autocompleteListBox} from './autocomplete.css'\n\n/**\n * @public\n */\nexport interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseAutocompleteOption> {\n border?: boolean\n customValidity?: string\n filterOption?: (query: string, option: Option) => boolean\n fontSize?: number | number[]\n // oxlint-disable-next-line no-redundant-type-constituents\n icon?: ElementType | ReactNode\n id: string\n /** @beta */\n listBox?: BoxProps\n loading?: boolean\n onChange?: (value: string) => void\n onQueryChange?: (query: string | null) => void\n onSelect?: (value: string) => void\n /** @beta */\n openButton?: boolean | AutocompleteOpenButtonProps\n /** @beta */\n openOnFocus?: boolean\n /** The options to render. */\n options?: Option[]\n padding?: number | number[]\n popover?: Omit<PopoverProps, 'content' | 'onMouseEnter' | 'onMouseLeave' | 'open'> &\n Omit<HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'ref' | 'width'>\n prefix?: ReactNode\n radius?: Radius | Radius[]\n /** @beta */\n relatedElements?: HTMLElement[]\n /** The callback function for rendering each option. */\n renderOption?: (option: Option) => React.JSX.Element\n /** @beta */\n renderPopover?: (\n props: {\n content: React.JSX.Element | null\n hidden: boolean\n inputElement: HTMLInputElement | null\n onMouseEnter: () => void\n onMouseLeave: () => void\n },\n ref: Ref<HTMLDivElement>,\n ) => ReactNode\n renderValue?: (value: string, option?: Option) => string\n suffix?: ReactNode\n /**\n * The current value. A changed `value` replaces the value shown and drops a pending query,\n * unless it equals the value shown (a parent echoing `onChange`). A selection or clear shows\n * until `value` changes, and changing `value` to `undefined` keeps the value shown.\n */\n value?: string\n}\n\nconst DEFAULT_RENDER_VALUE = (value: string, option?: BaseAutocompleteOption) =>\n option ? option.value : value\n\nconst DEFAULT_FILTER_OPTION = (query: string, option: BaseAutocompleteOption) =>\n option.value.toLowerCase().indexOf(query.toLowerCase()) > -1\n\n/**\n * The Autocomplete component is typically used for search components.\n * It consists of a text input for writing a query, and properties for rendering suggestions.\n *\n * @public\n */\nexport function Autocomplete<Option extends BaseAutocompleteOption>(\n props: AutocompleteProps<Option> &\n Omit<\n HTMLProps<HTMLInputElement>,\n | 'aria-activedescendant'\n | 'aria-autocomplete'\n | 'aria-expanded'\n | 'aria-owns'\n | 'as'\n | 'autoCapitalize'\n | 'autoComplete'\n | 'autoCorrect'\n | 'id'\n | 'inputMode'\n | 'onChange'\n | 'onSelect'\n | 'popover'\n | 'prefix'\n | 'role'\n | 'spellCheck'\n | 'type'\n | 'value'\n >,\n) {\n const {\n border = true,\n customValidity,\n disabled,\n filterOption: filterOptionProp,\n fontSize = 2,\n icon,\n id,\n listBox = EMPTY_RECORD,\n loading,\n onBlur,\n onChange,\n onFocus,\n onQueryChange,\n onSelect,\n openButton,\n openOnFocus,\n options: optionsProp,\n padding: paddingProp = 3,\n popover = EMPTY_RECORD,\n prefix,\n radius = 2,\n readOnly,\n ref: forwardedRef,\n relatedElements,\n renderOption: renderOptionProp,\n renderPopover,\n renderValue = DEFAULT_RENDER_VALUE,\n suffix,\n value: valueProp,\n ...restProps\n } = props\n\n const [state, dispatch] = useReducer(autocompleteReducer, {\n activeValue: valueProp || null,\n focused: false,\n listFocused: false,\n query: null,\n value: valueProp || null,\n })\n\n const {activeValue, focused, listFocused, query, value} = state\n\n // https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes\n const [prevValueProp, setPrevValueProp] = useState(valueProp)\n\n if (valueProp !== prevValueProp) {\n setPrevValueProp(valueProp)\n // A clear stores `null` and reports `''`\n if (valueProp !== undefined && (valueProp || null) !== value) {\n dispatch({type: 'value/change', value: valueProp})\n }\n }\n\n const defaultRenderOption = useCallback(\n ({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n ),\n [fontSize, paddingProp],\n )\n\n const renderOption =\n typeof renderOptionProp === 'function' ? renderOptionProp : defaultRenderOption\n\n const filterOption =\n typeof filterOptionProp === 'function' ? filterOptionProp : DEFAULT_FILTER_OPTION\n\n // Element refs\n const rootElementRef = useRef<HTMLDivElement | null>(null)\n const resultsPopoverElementRef = useRef<HTMLDivElement | null>(null)\n const inputElementRef = useRef<HTMLInputElement | null>(null)\n const listBoxElementRef = useRef<HTMLUListElement | null>(null)\n // Element refs that need to be accessed during render\n const [inputElement, setInputElement] = useState<HTMLInputElement | null>(null)\n\n // Value refs\n const listFocusedRef = useRef(false)\n const popoverMouseWithinRef = useRef(false)\n\n // Forward inputElement state to inputElementRef\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n inputElementRef,\n () => inputElement,\n [inputElement],\n )\n // Forward inputElement to parent\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n forwardedRef,\n () => inputElement,\n [inputElement],\n )\n\n const listBoxId = `${id}-listbox`\n const options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY\n const padding = _getArrayProp(paddingProp)\n const currentOption = useMemo(\n () => (value !== null ? options.find((o) => o.value === value) : undefined),\n [options, value],\n )\n const filteredOptions = useMemo(\n () => options.filter((option) => (query ? filterOption(query, option) : true)),\n [filterOption, options, query],\n )\n const filteredOptionsLen = filteredOptions.length\n const activeItemId = activeValue ? `${id}-option-${activeValue}` : undefined\n const querying = (query !== null && loading) || (focused && query !== null)\n // The list opens in a deferred render, so the keystroke, focus or click that opens it paints\n // first, and closes in the same render as the state that closes it. Dispatching the open in a\n // transition instead would drop a render-phase `value` sync while the transition is pending.\n const deferredQuerying = useDeferredValue(querying)\n const expanded = querying && deferredQuerying\n\n const handleRootBlur = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n },\n [onBlur, onQueryChange, relatedElements],\n )\n\n const handleRootFocus = useCallback((event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }, [])\n\n const handleOptionSelect = useCallback(\n (v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n },\n [onChange, onSelect, onQueryChange],\n )\n\n const handleRootKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n },\n [activeValue, filteredOptions, filteredOptionsLen, onQueryChange],\n )\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n },\n [onQueryChange],\n )\n\n const dispatchOpen = useCallback(() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }, [currentOption, renderValue, value])\n\n const handleInputFocus = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n },\n [focused, onFocus, openOnFocus, dispatchOpen],\n )\n\n const handlePopoverMouseEnter = useCallback(() => {\n popoverMouseWithinRef.current = true\n }, [])\n\n const handlePopoverMouseLeave = useCallback(() => {\n popoverMouseWithinRef.current = false\n }, [])\n\n const handleClearButtonClick = useCallback(() => {\n dispatch({type: 'root/clear'})\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }, [onChange, onQueryChange])\n\n const handleClearButtonFocus = useCallback(() => {\n dispatch({type: 'input/focus'})\n }, [])\n\n // Focus the active option, but only while the keyboard is in the list: opening the list leaves\n // focus in the input even when the option is focusable (a link or button). An effect event, so\n // focus entering the list on a click does not re-run it and scroll the clicked option away.\n const focusActiveOption = useEffectEvent(() => {\n const listElement = listBoxElementRef.current\n\n if (!listFocused || !listElement) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n\n if (activeOption) {\n const activeIndex = filteredOptions.indexOf(activeOption)\n // oxlint-disable-next-line no-unsafe-type-assertion\n const activeItemElement = listElement.childNodes[activeIndex] as HTMLLIElement | undefined\n\n if (activeItemElement) {\n if (_hasFocus(activeItemElement)) {\n // already focused\n return\n }\n\n focusFirstDescendant(activeItemElement)\n }\n }\n })\n\n // Also runs when the deferred render shows the list, for an arrow key pressed before it did\n useEffect(() => {\n if (expanded) focusActiveOption()\n }, [activeValue, expanded, filteredOptions])\n\n const clearButton = useMemo(() => {\n if (!loading && !disabled && value) {\n return {\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }\n }\n\n return undefined\n }, [disabled, handleClearButtonFocus, loading, value])\n\n const openButtonBoxPadding = padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n })\n const openButtonPadding = padding.map((v) => Math.max(v - 1, 0))\n const openButtonProps: AutocompleteOpenButtonProps =\n typeof openButton === 'object' ? openButton : EMPTY_RECORD\n\n const handleOpenClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n },\n [openButtonProps, dispatchOpen],\n )\n\n const openButtonNode = useMemo(\n () =>\n !disabled && !readOnly && openButton ? (\n <Box aria-hidden={querying} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={querying}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined,\n [\n disabled,\n fontSize,\n handleOpenClick,\n openButton,\n openButtonBoxPadding,\n openButtonPadding,\n openButtonProps,\n querying,\n readOnly,\n ],\n )\n\n const inputValue = useMemo(() => {\n if (query === null) {\n if (value !== null) {\n return renderValue(value, currentOption)\n }\n\n return ''\n }\n\n return query\n }, [currentOption, query, renderValue, value])\n\n const handleListBoxKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n },\n [listFocused],\n )\n\n const content = useMemo(() => {\n if (filteredOptions.length === 0) return null\n\n return (\n <Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>\n )\n }, [\n activeValue,\n currentOption,\n filteredOptions,\n handleOptionSelect,\n handleListBoxKeyDown,\n id,\n listBox,\n listBoxId,\n listFocused,\n loading,\n renderOption,\n ])\n\n const results = useMemo(() => {\n if (renderPopover) {\n return (\n <RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />\n )\n }\n\n if (filteredOptionsLen === 0) {\n return null\n }\n\n return (\n <Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />\n )\n }, [\n content,\n expanded,\n filteredOptionsLen,\n handlePopoverMouseEnter,\n handlePopoverMouseLeave,\n inputElement,\n popover,\n radius,\n renderPopover,\n ])\n\n return (\n // The handlers only observe focus and key events bubbling from the input and\n // list box, which carry the roles; the wrapper itself is not interactive.\n // oxlint-disable-next-line no-static-element-interactions\n <div\n className={autocomplete}\n data-ui=\"Autocomplete\"\n onBlur={handleRootBlur}\n onFocus={handleRootFocus}\n onKeyDown={handleRootKeyDown}\n ref={rootElementRef}\n >\n <TextInput\n {...restProps}\n aria-activedescendant={expanded ? activeItemId : undefined}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />\n {results}\n </div>\n )\n}\n\nfunction RenderPopover({\n renderPopover,\n content,\n hidden,\n inputElement,\n onMouseEnter,\n onMouseLeave,\n resultsPopoverElementRef,\n}: {\n renderPopover: Exclude<AutocompleteProps['renderPopover'], undefined>\n resultsPopoverElementRef: Parameters<Exclude<AutocompleteProps['renderPopover'], undefined>>[1]\n} & Parameters<Exclude<AutocompleteProps['renderPopover'], undefined>>[0]) {\n return renderPopover(\n {\n content,\n hidden,\n inputElement,\n onMouseEnter,\n onMouseLeave,\n },\n resultsPopoverElementRef,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAgB,mBAAmB,OAAmD;gBAC9E,EAAC,UAAU,IAAI,UAAU,UAAU,UAAS,OAElBA;CAI5B,AAAA,EAAA,OAAA,YAAA,EAAA,OAAS,SAJmB,WAAM;EAGpC,iBAAiB;GACf,SAAS,KAAK;EAChB,GAAG,CAAC;CACN,GAFI,EAAA,KAAA,UAAS,EAAA,KAAA;CAJb,IAAM,cAAcC,IASlBC;CAEI,AAAA,EAAA,OAAA,2BAFJ,MAAC,UAA8C;EAC7C,AAAI,MAAM,QAAQ,WAAW,CAAC,uBAAuB,MAAM,aAAa,KACtE,YAAY;CAEhB,GAFI,EAAA,KAAA;CAHN,IAAM,gBAAgBC,IAUpBC;CADF,OAUK,EAAA,OAAA,YAAA,EAAA,OAHQ,eAAA,EAAA,OACE,iBAAA,EAAA,OAJP,MAAA,EAAA,OAFW,YADjB,KAAA,oBAAC,MAAD;EACE,iBAAe;EACf,WAAQ;EACJ;EAEJ,MAAK;EACL,SAAS;EACT,WAAW;EAEV;CACC,CAAA,GADD,EAAA,KAAA,UAHQ,EAAA,KAAA,aACE,EAAA,KAAA,eAJP,EAAA,KAAA,IAFW,EAAA,KAAA,oCADjBA;AAYJ;;;;ACxCA,SAAgB,oBACd,OACA,KACmB;CAyCnB,OAxCI,IAAI,SAAS,iBACR;EAAC,GAAG;EAAO,aAAa;EAAM,SAAS;EAAM,OAAO,IAAI;CAAK,IAGlE,IAAI,SAAS,gBACR;EAAC,GAAG;EAAO,SAAS;CAAI,IAK7B,IAAI,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OAAA,QACE,EAAA,OAAA,UAvBN,EAAA,OAAA,WACmBD,EAAAA,OAAAA,KAaZF,EAAAA,OAAAA,KAcHG,EAAAA,OAAAA;CArCZC,IAAAA;CAJF,OAOY,EAAA,SAAA,kBAAA,EAAA,SACC,mBAAA,EAAA,SACE,qBAAA,EAAA,SAmCV,WAAA,EAAA,SAhCDH,OARF,MAAA,qBAAC,OAAD;EACE,WAAW;EACX,WAAQ;EACR,QAAQ;EACR,SAAS;EACT,WAAW;EACX,KAAK;EANP,UAAA,CAQEA,KAgCC,OACE;KAtCK,EAAA,OAAA,gBACC,EAAA,OAAA,iBACE,EAAA,OAAA,mBAmCV,EAAA,OAAA,SAhCDA,EAAAA,OAAAA,mCARFG;AA2CJ;AA9NwC,SAAA,OAAC,KAAA;CAAM,OAAA,KAAK,IAAIC,MAAI,GAAG,CAAC;;AAPrB,SAAA,MAAC,KAAM;CAK9C,OAJIA,QAAM,IAAU,IAChBA,QAAM,KACNA,QAAM,IAAU,IAEbA,MAAI;AACb;AAiOF,SAAS,cAAc,EACrB,eACA,SACA,QACA,cACA,cACA,cACA,4BAIyE;CACzE,OAAO,cACL;EACE;EACA;EACA;EACA;EACA;CACF,GACA,wBACF;AACF"}
|
package/dist/breadcrumbs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { n as _getArrayProp } from "./helpers-XThPpWje.js";
|
|
3
3
|
import { y as Box } from "./useLayer-D_TnC6On.js";
|
|
4
|
-
import { n as Text, t as Stack } from "./stack-
|
|
5
|
-
import { t as Button } from "./button-
|
|
6
|
-
import { t as Popover } from "./popover-
|
|
4
|
+
import { n as Text, t as Stack } from "./stack-TOlBMvbq.js";
|
|
5
|
+
import { t as Button } from "./button-DLiQy0Qz.js";
|
|
6
|
+
import { t as Popover } from "./popover-bcCbXwoP.js";
|
|
7
7
|
import { t as useClickOutsideEvent } from "./useClickOutsideEvent-CC1zgOmv.js";
|
|
8
8
|
import { c } from "react/compiler-runtime";
|
|
9
9
|
import { clsx } from "clsx/lite";
|
|
@@ -14,7 +14,6 @@ const ExpandButton = styled(Button).withConfig({
|
|
|
14
14
|
displayName: "ExpandButton",
|
|
15
15
|
componentId: "sc-6vrn4n-0"
|
|
16
16
|
})`margin:-4px;`;
|
|
17
|
-
var breadcrumbs = "_1il6d3z0", expandButton = "_1il6d3z1";
|
|
18
17
|
/**
|
|
19
18
|
* @beta
|
|
20
19
|
*/
|
|
@@ -43,7 +42,7 @@ function Breadcrumbs(props) {
|
|
|
43
42
|
space
|
|
44
43
|
}, $[15] = maxLength, $[16] = open, $[17] = rawItems, $[18] = space, $[19] = t6) : t6 = $[19];
|
|
45
44
|
let items = useItems(t6), t7;
|
|
46
|
-
$[20] === className ? t7 = $[21] : (t7 = clsx(
|
|
45
|
+
$[20] === className ? t7 = $[21] : (t7 = clsx("fAtomh HgOzd eGjDnc hEzNkW jZsjHW bnBrYd cbkwRf", className), $[20] = className, $[21] = t7);
|
|
47
46
|
let t8;
|
|
48
47
|
if ($[22] !== items || $[23] !== separator || $[24] !== space) {
|
|
49
48
|
let t9;
|
|
@@ -86,7 +85,7 @@ function useItems(t0) {
|
|
|
86
85
|
}), $[16] = space, $[17] = t3, $[18] = t4) : t4 = $[18];
|
|
87
86
|
let t5 = open ? collapse : expand, t6;
|
|
88
87
|
$[19] !== expandElementRef || $[20] !== open || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsx(ExpandButton, {
|
|
89
|
-
className:
|
|
88
|
+
className: "bGTgkg",
|
|
90
89
|
fontSize: 1,
|
|
91
90
|
mode: "bleed",
|
|
92
91
|
onClick: t5,
|