@sanity/ui 4.0.7 → 4.1.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-CL8xmdbg.js → arrow-DKn5YKdy.js} +6 -5
- package/dist/arrow-DKn5YKdy.js.map +1 -0
- package/dist/autocomplete.d.ts +2 -2
- package/dist/autocomplete.d.ts.map +1 -1
- package/dist/autocomplete.js +37 -41
- package/dist/autocomplete.js.map +1 -1
- package/dist/breadcrumbs.d.ts +2 -2
- package/dist/breadcrumbs.d.ts.map +1 -1
- package/dist/breadcrumbs.js +30 -32
- package/dist/breadcrumbs.js.map +1 -1
- package/dist/{button-DQH2KIbq.js → button-Dh_M2fYx.js} +10 -10
- package/dist/button-Dh_M2fYx.js.map +1 -0
- package/dist/button-dnqMFkWg.d.ts.map +1 -1
- package/dist/code.d.ts +2 -2
- package/dist/code.d.ts.map +1 -1
- package/dist/{factory-BA3gEfyI.js → factory-BzXTX8_Q.js} +2 -2
- package/dist/{factory-BA3gEfyI.js.map → factory-BzXTX8_Q.js.map} +1 -1
- package/dist/{flex-CySCBzQm.js → flex-DmbDG2ks.js} +2 -2
- package/dist/{flex-CySCBzQm.js.map → flex-DmbDG2ks.js.map} +1 -1
- package/dist/{getElementRef-5HZQ-Owu.js → getElementRef-Jw7gY0eV.js} +13 -2
- package/dist/getElementRef-Jw7gY0eV.js.map +1 -0
- package/dist/{grid-I2TNptX-.js → grid-6JSgMj1O.js} +2 -2
- package/dist/{grid-I2TNptX-.js.map → grid-6JSgMj1O.js.map} +1 -1
- package/dist/{hotkeys-BPlacpG8.js → hotkeys-uSArGPzR.js} +28 -28
- package/dist/hotkeys-uSArGPzR.js.map +1 -0
- package/dist/index.d.ts +156 -156
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +317 -351
- package/dist/index.js.map +1 -1
- package/dist/layer-BfwisMR6.js +61 -0
- package/dist/layer-BfwisMR6.js.map +1 -0
- package/dist/layer-ChlP9Ik6.d.ts.map +1 -1
- package/dist/menu.d.ts +6 -6
- package/dist/menu.d.ts.map +1 -1
- package/dist/menu.js +50 -38
- package/dist/menu.js.map +1 -1
- package/dist/{popover-CEbjxiPx.js → popover-myCXZV_F.js} +34 -33
- package/dist/popover-myCXZV_F.js.map +1 -0
- package/dist/popover.js +1 -1
- package/dist/{stack-BGFEokua.js → stack-rsNFPq2-.js} +2 -2
- package/dist/{stack-BGFEokua.js.map → stack-rsNFPq2-.js.map} +1 -1
- package/dist/styles.css +408 -0
- package/dist/{textInput-B6ZZJSOj.js → textInput-DAaORuky.js} +38 -50
- package/dist/textInput-DAaORuky.js.map +1 -0
- package/dist/theme.d.ts +33 -33
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +1 -1
- package/dist/toast.d.ts +4 -4
- package/dist/toast.d.ts.map +1 -1
- package/dist/toast.js +80 -76
- package/dist/toast.js.map +1 -1
- package/dist/tooltip.d.ts +5 -5
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +97 -99
- package/dist/tooltip.js.map +1 -1
- package/dist/{useLayer-jUJIz8mh.js → useLayer-D1usxIE0.js} +2 -2
- package/dist/{useLayer-jUJIz8mh.js.map → useLayer-D1usxIE0.js.map} +1 -1
- package/package.json +10 -9
- package/dist/arrow-CL8xmdbg.js.map +0 -1
- package/dist/button-DQH2KIbq.js.map +0 -1
- package/dist/getElementRef-5HZQ-Owu.js.map +0 -1
- package/dist/hotkeys-BPlacpG8.js.map +0 -1
- package/dist/layer-DGn7KJIB.js +0 -61
- package/dist/layer-DGn7KJIB.js.map +0 -1
- package/dist/popover-CEbjxiPx.js.map +0 -1
- package/dist/textInput-B6ZZJSOj.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as useTheme_v2, d as createGlobalScopedContext, f as globalScope, r as isRecord } from "./useLayer-
|
|
1
|
+
import { _ as useTheme_v2, d as createGlobalScopedContext, f as globalScope, r as isRecord } from "./useLayer-D1usxIE0.js";
|
|
2
2
|
import { c } from "react/compiler-runtime";
|
|
3
3
|
import { useContext } from "react";
|
|
4
4
|
import { css, styled } from "styled-components";
|
|
@@ -80,13 +80,13 @@ function compileCommands(cmds) {
|
|
|
80
80
|
}
|
|
81
81
|
const StyledArrow = /* @__PURE__ */ styled.div.withConfig({
|
|
82
82
|
displayName: "StyledArrow",
|
|
83
|
-
componentId: "sc-
|
|
83
|
+
componentId: "sc-q06uyo-0"
|
|
84
84
|
})(({ $w: w }) => css`position:absolute;width:${w}px;height:${w}px;:empty + &{display:none;}& > svg{display:block;line-height:0;transform-origin:${w / 2}px ${w / 2}px;}[data-placement^='top'] > &{bottom:-${w}px;& > svg{transform:rotate(0);}}[data-placement^='right'] > &{left:-${w}px;& > svg{transform:rotate(90deg);}}[data-placement^='left'] > &{right:-${w}px;& > svg{transform:rotate(-90deg);}}[data-placement^='bottom'] > &{top:-${w}px;& > svg{transform:rotate(180deg);}}`), StrokePath = styled.path.withConfig({
|
|
85
85
|
displayName: "StrokePath",
|
|
86
|
-
componentId: "sc-
|
|
86
|
+
componentId: "sc-q06uyo-1"
|
|
87
87
|
})`stroke:var(--card-shadow-outline-color);`, ShapePath = styled.path.withConfig({
|
|
88
88
|
displayName: "ShapePath",
|
|
89
|
-
componentId: "sc-
|
|
89
|
+
componentId: "sc-q06uyo-2"
|
|
90
90
|
})`fill:var(--card-bg-color);`;
|
|
91
91
|
/** @internal */
|
|
92
92
|
function Arrow(props) {
|
|
@@ -150,6 +150,7 @@ function Arrow(props) {
|
|
|
150
150
|
}), $[19] = t2, $[20] = t3, $[21] = t5, $[22] = t6, $[23] = w, $[24] = t7) : t7 = $[24];
|
|
151
151
|
let t8;
|
|
152
152
|
return $[25] !== ref || $[26] !== restProps || $[27] !== t7 || $[28] !== w ? (t8 = /* @__PURE__ */ jsx(StyledArrow, {
|
|
153
|
+
"data-ui": "Arrow",
|
|
153
154
|
...restProps,
|
|
154
155
|
$w: w,
|
|
155
156
|
ref,
|
|
@@ -158,4 +159,4 @@ function Arrow(props) {
|
|
|
158
159
|
}
|
|
159
160
|
export { useBoundaryElement as a, PortalContext as i, Portal as n, BoundaryElementContext as o, usePortal as r, Arrow as t };
|
|
160
161
|
|
|
161
|
-
//# sourceMappingURL=arrow-
|
|
162
|
+
//# sourceMappingURL=arrow-DKn5YKdy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-DKn5YKdy.js","names":["createPortal(children, portalElement)","radius = 0","compileCommands(cmds)","<mask id=\"stroke-mask\">\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>","<StrokePath d={strokePath} mask=\"url(#stroke-mask)\" strokeWidth={strokeWidth * 2} />","strokeWidth * 2","<ShapePath d={fillPath} />","<svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>\n <mask id=\"stroke-mask\">\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>\n <StrokePath d={strokePath} mask=\"url(#stroke-mask)\" strokeWidth={strokeWidth * 2} />\n <ShapePath d={fillPath} />\n </svg>","`0 0 ${w} ${w}`","<StyledArrow data-ui=\"Arrow\" {...restProps} $w={w} ref={ref}>\n <svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>\n <mask id=\"stroke-mask\">\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>\n <StrokePath d={strokePath} mask=\"url(#stroke-mask)\" strokeWidth={strokeWidth * 2} />\n <ShapePath d={fillPath} />\n </svg>\n </StyledArrow>"],"sources":["../src/core/utils/boundaryElement/boundaryElementContext.ts","../src/core/utils/boundaryElement/useBoundaryElement.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.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 {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 {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 =\n (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default\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 {HTMLProps} from 'react'\nimport {css, styled} from 'styled-components'\n\nimport {useTheme_v2} from '../../theme/useTheme'\nimport {compileCommands, getRoundedCommands, Point} from './cmds'\n\nconst StyledArrow = styled.div<{$w: number}>(\n ({$w: w}) => css`\n position: absolute;\n width: ${w}px;\n height: ${w}px;\n\n :empty + & {\n display: none;\n }\n\n & > svg {\n display: block;\n line-height: 0;\n transform-origin: ${w / 2}px ${w / 2}px;\n }\n\n [data-placement^='top'] > & {\n bottom: -${w}px;\n\n & > svg {\n transform: rotate(0);\n }\n }\n\n [data-placement^='right'] > & {\n left: -${w}px;\n\n & > svg {\n transform: rotate(90deg);\n }\n }\n\n [data-placement^='left'] > & {\n right: -${w}px;\n\n & > svg {\n transform: rotate(-90deg);\n }\n }\n\n [data-placement^='bottom'] > & {\n top: -${w}px;\n\n & > svg {\n transform: rotate(180deg);\n }\n }\n `,\n)\n\nconst StrokePath = styled.path`\n stroke: var(--card-shadow-outline-color);\n`\n\nconst ShapePath = styled.path`\n fill: var(--card-bg-color);\n`\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 {width: w, height: h, radius = 0, ref, ...restProps} = props\n const {card} = useTheme_v2()\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 <StyledArrow data-ui=\"Arrow\" {...restProps} $w={w} ref={ref}>\n <svg width={w} height={w} viewBox={`0 0 ${w} ${w}`}>\n <mask id=\"stroke-mask\">\n <rect x={0} y={strokeWidth} width={w} height={w} fill=\"white\" />\n </mask>\n <StrokePath d={strokePath} mask=\"url(#stroke-mask)\" strokeWidth={strokeWidth * 2} />\n <ShapePath d={fillPath} />\n </svg>\n </StyledArrow>\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;ACrBA,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,OAGL,YAAY,cACP,YAAY,eAGrB,YAAY,cAAc,SAAS,cAAc,KAAK,GACtD,YAAY,WAAW,CAAC,aAAa,eAAe,EAAE,GAEtD,SAAS,KAAK,YAAY,YAAY,WAAW,GAE1C,YAAY;CACrB;AAG8E,CAAmB;;;;ACrBnG,SAAgB,YAAgC;CAC9C,IAAM,QAAQ,WAAW,aAAa;CAEtC,IAAI,CAAC,OACH,MAA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AAA,MAAAA,IALU,EAAA,MAAA;CADdG,IAAAA;CADF,OAC0D,EAAA,QAAA,OAAA,EAAA,QAAvB,aAAA,EAAA,QAC/BF,MAAAA,EAAAA,QAD8C,KAAhD,KAAA,oBAAC,aAAD;EAAa,WAAQ;EAAQ,GAAI;EAAW,IAAI;EAAQ;EACtDA,UAAAA;CAOW,CAAA,GAR2C,EAAA,MAAA,KAAvB,EAAA,MAAA,WAC/BA,EAAAA,MAAAA,IAD8C,EAAA,MAAA,6BAAhDE;AAUJ"}
|
package/dist/autocomplete.d.ts
CHANGED
|
@@ -135,6 +135,6 @@ interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseAutocomp
|
|
|
135
135
|
*
|
|
136
136
|
* @public
|
|
137
137
|
*/
|
|
138
|
-
declare function Autocomplete<Option extends BaseAutocompleteOption>(props: AutocompleteProps<Option> & Omit<HTMLProps<HTMLInputElement>, 'aria-activedescendant' | 'aria-autocomplete' | 'aria-expanded' | 'aria-owns' | 'as' | 'autoCapitalize' | 'autoComplete' | 'autoCorrect' | 'id' | 'inputMode' | 'onChange' | 'onSelect' | 'popover' | 'prefix' | 'role' | 'spellCheck' | 'type' | 'value'>): import("react").JSX.Element;
|
|
139
|
-
export {
|
|
138
|
+
export declare function Autocomplete<Option extends BaseAutocompleteOption>(props: AutocompleteProps<Option> & Omit<HTMLProps<HTMLInputElement>, 'aria-activedescendant' | 'aria-autocomplete' | 'aria-expanded' | 'aria-owns' | 'as' | 'autoCapitalize' | 'autoComplete' | 'autoCorrect' | 'id' | 'inputMode' | 'onChange' | 'onSelect' | 'popover' | 'prefix' | 'role' | 'spellCheck' | 'type' | 'value'>): import("react").JSX.Element;
|
|
139
|
+
export type { AutocompleteInputChangeMsg, AutocompleteInputFoocusMsg, AutocompleteMsg, AutocompleteOpenButtonProps, AutocompleteProps, AutocompleteRootBlurMsg, AutocompleteRootClearMsg, AutocompleteRootEscapeMsg, AutocompleteRootOpenMsg, AutocompleteRootSetActiveValueMsg, AutocompleteRootSetListFocusedMsg, AutocompleteState, AutocompleteValueChangeMsg, BaseAutocompleteOption };
|
|
140
140
|
//# sourceMappingURL=autocomplete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","names":[],"sources":["../src/core/components/autocomplete/types.ts","../src/core/components/autocomplete/autocomplete.tsx"],"mappings":";;;;;;;KAKY,8BAA8B,iBACxC,KAAK,MAAM,UAAU;;;;UAKN;EACf;;;;;UAMe;EACf;EACA;EACA;EACA;EACA;;;;;UAMe;EACf;;;;;UAMe;EACf;;;;;UAMe;EACf;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;EACA;EACA;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;;;;;UAMe;EACf;EACA;;;;;KAMU,kBACR,0BACA,2BACA,4BACA,0BACA,oCACA,oCACA,6BACA,6BACA;;;;
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","names":[],"sources":["../src/core/components/autocomplete/types.ts","../src/core/components/autocomplete/autocomplete.tsx"],"mappings":";;;;;;;KAKY,8BAA8B,iBACxC,KAAK,MAAM,UAAU;;;;UAKN;EACf;;;;;UAMe;EACf;EACA;EACA;EACA;EACA;;;;;UAMe;EACf;;;;;UAMe;EACf;;;;;UAMe;EACf;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;EACA;EACA;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;EACA;;;;;UAMe;EACf;;;;;UAMe;EACf;EACA;;;;;KAMU,kBACR,0BACA,2BACA,4BACA,0BACA,oCACA,oCACA,6BACA,6BACA;;;;UCzDa,kBAAkB,eAAe,yBAAyB;EACzE;EACA;EACA,gBAAgB,eAAe,QAAQ;EACvC;EAEA,OAAO,cAAc;EACrB;;EAEA,UAAU;EACV;EACA,YAAY;EACZ,iBAAiB;EACjB,YAAY;;EAEZ,uBAAuB;;EAEvB;;EAEA,UAAU;EACV;EACA,UAAU,KAAK,sEACb,KAAK,UAAU;EACjB,SAAS;EACT,SAAS,SAAS;;EAElB,kBAAkB;;EAElB,gBAAgB,QAAQ,WAAW,MAAM,IAAI;;EAE7C,iBACE;IACE,SAAS,MAAM,IAAI;IACnB;IACA,cAAc;IACd;IACA;KAEF,KAAK,IAAI,oBACN;EACL,eAAe,eAAe,SAAS;EACvC,SAAS;;EAET;;;;;;;;wBAec,aAAa,eAAe,wBAC1C,OAAO,kBAAkB,UACvB,KACE,UAAU,gSAmBX,IAAA"}
|
package/dist/autocomplete.js
CHANGED
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { n as _getArrayProp, o as EMPTY_ARRAY, s as EMPTY_RECORD } from "./helpers-C8xxXAQC.js";
|
|
3
|
-
import {
|
|
3
|
+
import { f as focusFirstDescendant, h as _raf, t as TextInput, u as _hasFocus } from "./textInput-DAaORuky.js";
|
|
4
4
|
import { t as _isEnterToClickElement } from "./element-BYgCE_iK.js";
|
|
5
|
-
import { s as Card, y as Box } from "./useLayer-
|
|
6
|
-
import { n as Text, t as Stack } from "./stack-
|
|
7
|
-
import { t as Button } from "./button-
|
|
8
|
-
import { t as Popover } from "./popover-
|
|
5
|
+
import { s as Card, y as Box } from "./useLayer-D1usxIE0.js";
|
|
6
|
+
import { n as Text, t as Stack } from "./stack-rsNFPq2-.js";
|
|
7
|
+
import { t as Button } from "./button-Dh_M2fYx.js";
|
|
8
|
+
import { t as Popover } from "./popover-myCXZV_F.js";
|
|
9
9
|
import { c } from "react/compiler-runtime";
|
|
10
10
|
import { ChevronDownIcon } from "@sanity/icons/ChevronDown";
|
|
11
11
|
import { SpinnerIcon } from "@sanity/icons/Spinner";
|
|
12
|
+
import { clsx } from "clsx/lite";
|
|
12
13
|
import { cloneElement, startTransition, useEffect, useImperativeHandle, useReducer, useRef, useState } from "react";
|
|
13
|
-
import { styled } from "styled-components";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
const StyledAutocomplete = styled.div.withConfig({
|
|
19
|
-
displayName: "StyledAutocomplete",
|
|
20
|
-
componentId: "sc-dc0p49-0"
|
|
21
|
-
})`line-height:0;`, ListBox = styled(Box).withConfig({
|
|
22
|
-
displayName: "ListBox",
|
|
23
|
-
componentId: "sc-dc0p49-1"
|
|
24
|
-
})`& > ul{list-style:none;padding:0;margin:0;}`;
|
|
25
15
|
function AutocompleteOption(props) {
|
|
26
16
|
let $ = c(11), { children, id, onSelect, selected, value } = props, t0;
|
|
27
17
|
$[0] !== onSelect || $[1] !== value ? (t0 = () => {
|
|
@@ -101,7 +91,9 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
101
91
|
"Meta",
|
|
102
92
|
"Tab",
|
|
103
93
|
"CapsLock"
|
|
104
|
-
], AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"]
|
|
94
|
+
], AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"];
|
|
95
|
+
var autocomplete = "_4c0fmk0", autocompleteListBox = "_4c0fmk1";
|
|
96
|
+
const DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1;
|
|
105
97
|
/**
|
|
106
98
|
* The Autocomplete component is typically used for search components.
|
|
107
99
|
* It consists of a text input for writing a query, and properties for rendering suggestions.
|
|
@@ -109,7 +101,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
109
101
|
* @public
|
|
110
102
|
*/
|
|
111
103
|
function Autocomplete(props) {
|
|
112
|
-
let $ = c(
|
|
104
|
+
let $ = c(187), customValidity, disabled, filterOptionProp, forwardedRef, icon, id, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, optionsProp, prefix, readOnly, relatedElements, renderOptionProp, renderPopover, restProps, suffix, t0, t1, t2, t3, t4, t5, t6, valueProp;
|
|
113
105
|
$[0] === props ? (customValidity = $[1], disabled = $[2], filterOptionProp = $[3], forwardedRef = $[4], icon = $[5], id = $[6], loading = $[7], onBlur = $[8], onChange = $[9], onFocus = $[10], onQueryChange = $[11], onSelect = $[12], openButton = $[13], openOnFocus = $[14], optionsProp = $[15], prefix = $[16], readOnly = $[17], relatedElements = $[18], renderOptionProp = $[19], renderPopover = $[20], restProps = $[21], suffix = $[22], t0 = $[23], t1 = $[24], t2 = $[25], t3 = $[26], t4 = $[27], t5 = $[28], t6 = $[29], valueProp = $[30]) : ({border: t0, customValidity, disabled, filterOption: filterOptionProp, fontSize: t1, icon, id, listBox: t2, loading, onBlur, onChange, onFocus, onQueryChange, onSelect, openButton, openOnFocus, options: optionsProp, padding: t3, popover: t4, prefix, radius: t5, readOnly, ref: forwardedRef, relatedElements, renderOption: renderOptionProp, renderPopover, renderValue: t6, suffix, value: valueProp, ...restProps} = props, $[0] = props, $[1] = customValidity, $[2] = disabled, $[3] = filterOptionProp, $[4] = forwardedRef, $[5] = icon, $[6] = id, $[7] = loading, $[8] = onBlur, $[9] = onChange, $[10] = onFocus, $[11] = onQueryChange, $[12] = onSelect, $[13] = openButton, $[14] = openOnFocus, $[15] = optionsProp, $[16] = prefix, $[17] = readOnly, $[18] = relatedElements, $[19] = renderOptionProp, $[20] = renderPopover, $[21] = restProps, $[22] = suffix, $[23] = t0, $[24] = t1, $[25] = t2, $[26] = t3, $[27] = t4, $[28] = t5, $[29] = t6, $[30] = valueProp);
|
|
114
106
|
let border = t0 === void 0 || t0, fontSize = t1 === void 0 ? 2 : t1, listBox = t2 === void 0 ? EMPTY_RECORD : t2, paddingProp = t3 === void 0 ? 3 : t3, popover = t4 === void 0 ? EMPTY_RECORD : t4, radius = t5 === void 0 ? 2 : t5, renderValue = t6 === void 0 ? DEFAULT_RENDER_VALUE : t6, t7 = valueProp || null, t8 = valueProp || null, t9;
|
|
115
107
|
$[31] !== t7 || $[32] !== t8 ? (t9 = {
|
|
@@ -333,10 +325,12 @@ function Autocomplete(props) {
|
|
|
333
325
|
t40 = null;
|
|
334
326
|
break bb2;
|
|
335
327
|
}
|
|
336
|
-
let t41;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
328
|
+
let t41 = listBox?.className, t42;
|
|
329
|
+
$[115] === t41 ? t42 = $[116] : (t42 = clsx(autocompleteListBox, t41), $[115] = t41, $[116] = t42);
|
|
330
|
+
let t43;
|
|
331
|
+
if ($[117] !== activeValue || $[118] !== currentOption || $[119] !== filteredOptions || $[120] !== handleOptionSelect || $[121] !== id || $[122] !== listFocused || $[123] !== loading || $[124] !== renderOption) {
|
|
332
|
+
let t44;
|
|
333
|
+
$[126] !== activeValue || $[127] !== currentOption || $[128] !== handleOptionSelect || $[129] !== id || $[130] !== listFocused || $[131] !== loading || $[132] !== renderOption ? (t44 = (option_0) => {
|
|
340
334
|
let active = activeValue === null ? currentOption === option_0 : option_0.value === activeValue;
|
|
341
335
|
return /* @__PURE__ */ jsx(AutocompleteOption, {
|
|
342
336
|
id: `${id}-option-${option_0.value}`,
|
|
@@ -349,10 +343,10 @@ function Autocomplete(props) {
|
|
|
349
343
|
tabIndex: listFocused && active ? 0 : -1
|
|
350
344
|
})
|
|
351
345
|
}, option_0.value);
|
|
352
|
-
}, $[
|
|
353
|
-
} else
|
|
354
|
-
let
|
|
355
|
-
$[
|
|
346
|
+
}, $[126] = activeValue, $[127] = currentOption, $[128] = handleOptionSelect, $[129] = id, $[130] = listFocused, $[131] = loading, $[132] = renderOption, $[133] = t44) : t44 = $[133], t43 = filteredOptions.map(t44), $[117] = activeValue, $[118] = currentOption, $[119] = filteredOptions, $[120] = handleOptionSelect, $[121] = id, $[122] = listFocused, $[123] = loading, $[124] = renderOption, $[125] = t43;
|
|
347
|
+
} else t43 = $[125];
|
|
348
|
+
let t44;
|
|
349
|
+
$[134] !== listBoxId || $[135] !== t43 ? (t44 = /* @__PURE__ */ jsx(Stack, {
|
|
356
350
|
as: "ul",
|
|
357
351
|
"aria-multiselectable": !1,
|
|
358
352
|
"data-ui": "AutoComplete__resultsList",
|
|
@@ -360,23 +354,24 @@ function Autocomplete(props) {
|
|
|
360
354
|
ref: listBoxElementRef,
|
|
361
355
|
role: "listbox",
|
|
362
356
|
gap: 1,
|
|
363
|
-
children:
|
|
364
|
-
}), $[
|
|
365
|
-
let
|
|
366
|
-
$[
|
|
357
|
+
children: t43
|
|
358
|
+
}), $[134] = listBoxId, $[135] = t43, $[136] = t44) : t44 = $[136];
|
|
359
|
+
let t45;
|
|
360
|
+
$[137] !== handleListBoxKeyDown || $[138] !== listBox || $[139] !== t42 || $[140] !== t44 ? (t45 = /* @__PURE__ */ jsx(Box, {
|
|
367
361
|
"data-ui": "AutoComplete__results",
|
|
368
362
|
onKeyDown: handleListBoxKeyDown,
|
|
369
363
|
padding: 1,
|
|
370
364
|
...listBox,
|
|
365
|
+
className: t42,
|
|
371
366
|
tabIndex: -1,
|
|
372
|
-
children:
|
|
373
|
-
}), $[
|
|
367
|
+
children: t44
|
|
368
|
+
}), $[137] = handleListBoxKeyDown, $[138] = listBox, $[139] = t42, $[140] = t44, $[141] = t45) : t45 = $[141], t40 = t45;
|
|
374
369
|
}
|
|
375
370
|
let content = t40, t41;
|
|
376
371
|
bb3: {
|
|
377
372
|
if (renderPopover) {
|
|
378
373
|
let t42 = !expanded, t43;
|
|
379
|
-
$[
|
|
374
|
+
$[142] !== content || $[143] !== handlePopoverMouseEnter || $[144] !== handlePopoverMouseLeave || $[145] !== inputElement || $[146] !== renderPopover || $[147] !== t42 ? (t43 = /* @__PURE__ */ jsx(RenderPopover, {
|
|
380
375
|
content,
|
|
381
376
|
hidden: t42,
|
|
382
377
|
inputElement,
|
|
@@ -384,7 +379,7 @@ function Autocomplete(props) {
|
|
|
384
379
|
onMouseLeave: handlePopoverMouseLeave,
|
|
385
380
|
resultsPopoverElementRef,
|
|
386
381
|
renderPopover
|
|
387
|
-
}), $[
|
|
382
|
+
}), $[142] = content, $[143] = handlePopoverMouseEnter, $[144] = handlePopoverMouseLeave, $[145] = inputElement, $[146] = renderPopover, $[147] = t42, $[148] = t43) : t43 = $[148], t41 = t43;
|
|
388
383
|
break bb3;
|
|
389
384
|
}
|
|
390
385
|
if (filteredOptionsLen === 0) {
|
|
@@ -392,7 +387,7 @@ function Autocomplete(props) {
|
|
|
392
387
|
break bb3;
|
|
393
388
|
}
|
|
394
389
|
let t42;
|
|
395
|
-
$[
|
|
390
|
+
$[149] !== content || $[150] !== expanded || $[151] !== handlePopoverMouseEnter || $[152] !== handlePopoverMouseLeave || $[153] !== inputElement || $[154] !== popover || $[155] !== radius ? (t42 = /* @__PURE__ */ jsx(Popover, {
|
|
396
391
|
arrow: !1,
|
|
397
392
|
constrainSize: !0,
|
|
398
393
|
content,
|
|
@@ -408,12 +403,12 @@ function Autocomplete(props) {
|
|
|
408
403
|
ref: resultsPopoverElementRef,
|
|
409
404
|
referenceElement: inputElement,
|
|
410
405
|
...popover
|
|
411
|
-
}), $[
|
|
406
|
+
}), $[149] = content, $[150] = expanded, $[151] = handlePopoverMouseEnter, $[152] = handlePopoverMouseLeave, $[153] = inputElement, $[154] = popover, $[155] = radius, $[156] = t42) : t42 = $[156], t41 = t42;
|
|
412
407
|
}
|
|
413
408
|
let results = t41, t42;
|
|
414
|
-
$[
|
|
409
|
+
$[157] === loading ? t42 = $[158] : (t42 = loading && /* @__PURE__ */ jsx(SpinnerIcon, { className: "_1b6o2se1" }), $[157] = loading, $[158] = t42);
|
|
415
410
|
let t43 = suffix || openButtonNode, t44;
|
|
416
|
-
$[
|
|
411
|
+
$[159] !== activeItemId || $[160] !== border || $[161] !== clearButton || $[162] !== customValidity || $[163] !== disabled || $[164] !== expanded || $[165] !== fontSize || $[166] !== handleClearButtonClick || $[167] !== handleInputChange || $[168] !== handleInputFocus || $[169] !== icon || $[170] !== id || $[171] !== inputValue || $[172] !== listBoxId || $[173] !== padding || $[174] !== prefix || $[175] !== radius || $[176] !== readOnly || $[177] !== restProps || $[178] !== t42 || $[179] !== t43 ? (t44 = /* @__PURE__ */ jsx(TextInput, {
|
|
417
412
|
...restProps,
|
|
418
413
|
"aria-activedescendant": activeItemId,
|
|
419
414
|
"aria-autocomplete": "list",
|
|
@@ -443,16 +438,17 @@ function Autocomplete(props) {
|
|
|
443
438
|
spellCheck: !1,
|
|
444
439
|
suffix: t43,
|
|
445
440
|
value: inputValue
|
|
446
|
-
}), $[
|
|
441
|
+
}), $[159] = activeItemId, $[160] = border, $[161] = clearButton, $[162] = customValidity, $[163] = disabled, $[164] = expanded, $[165] = fontSize, $[166] = handleClearButtonClick, $[167] = handleInputChange, $[168] = handleInputFocus, $[169] = icon, $[170] = id, $[171] = inputValue, $[172] = listBoxId, $[173] = padding, $[174] = prefix, $[175] = radius, $[176] = readOnly, $[177] = restProps, $[178] = t42, $[179] = t43, $[180] = t44) : t44 = $[180];
|
|
447
442
|
let t45;
|
|
448
|
-
return $[
|
|
443
|
+
return $[181] !== handleRootBlur || $[182] !== handleRootFocus || $[183] !== handleRootKeyDown || $[184] !== results || $[185] !== t44 ? (t45 = /* @__PURE__ */ jsxs("div", {
|
|
444
|
+
className: autocomplete,
|
|
449
445
|
"data-ui": "Autocomplete",
|
|
450
446
|
onBlur: handleRootBlur,
|
|
451
447
|
onFocus: handleRootFocus,
|
|
452
448
|
onKeyDown: handleRootKeyDown,
|
|
453
449
|
ref: rootElementRef,
|
|
454
450
|
children: [t44, results]
|
|
455
|
-
}), $[
|
|
451
|
+
}), $[181] = handleRootBlur, $[182] = handleRootFocus, $[183] = handleRootKeyDown, $[184] = results, $[185] = t44, $[186] = t45) : t45 = $[186], t45;
|
|
456
452
|
}
|
|
457
453
|
function _temp2(v_1) {
|
|
458
454
|
return Math.max(v_1 - 1, 0);
|