@bazza-ui/react 0.1.0-canary.15 → 0.1.0-canary.17
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/combobox/index.cjs +1 -1
- package/dist/combobox/index.cjs.map +1 -1
- package/dist/combobox/index.d.ts +842 -834
- package/dist/combobox/index.js +1 -1
- package/dist/combobox/index.js.map +1 -1
- package/dist/command-menu/index.cjs +1 -1
- package/dist/command-menu/index.cjs.map +1 -1
- package/dist/command-menu/index.d.ts +123 -96
- package/dist/command-menu/index.js +1 -1
- package/dist/command-menu/index.js.map +1 -1
- package/dist/context-menu/index.cjs +1 -1
- package/dist/context-menu/index.cjs.map +1 -1
- package/dist/context-menu/index.d.ts +701 -658
- package/dist/context-menu/index.js +1 -1
- package/dist/context-menu/index.js.map +1 -1
- package/dist/dropdown-menu/index.cjs +1 -1
- package/dist/dropdown-menu/index.cjs.map +1 -1
- package/dist/dropdown-menu/index.d.ts +723 -680
- package/dist/dropdown-menu/index.js +1 -1
- package/dist/dropdown-menu/index.js.map +1 -1
- package/dist/events-DDOsDu4X.d.ts +2091 -0
- package/dist/index-Cabqj7qI.d.ts +2003 -0
- package/dist/index-D8OrKThQ.d.ts +977 -0
- package/dist/internal/listbox/index.cjs +1 -2
- package/dist/internal/listbox/index.d.ts +2 -272
- package/dist/internal/listbox/index.js +1 -2
- package/dist/internal/popup-menu/index.cjs +1 -2
- package/dist/internal/popup-menu/index.d.ts +4 -238
- package/dist/internal/popup-menu/index.js +1 -2
- package/dist/items-CD2hw6-3.js +2 -0
- package/dist/items-CD2hw6-3.js.map +1 -0
- package/dist/items-DYDljwnt.cjs +2 -0
- package/dist/items-DYDljwnt.cjs.map +1 -0
- package/dist/{items-B6HeFO_8.d.cts → items-ceX--VIv.d.ts} +21 -19
- package/dist/kbd/index.cjs +1 -1
- package/dist/kbd/index.cjs.map +1 -1
- package/dist/kbd/index.d.ts +35 -35
- package/dist/kbd/index.js +1 -1
- package/dist/kbd/index.js.map +1 -1
- package/dist/listbox-CnwUlLZA.js +2 -0
- package/dist/listbox-CnwUlLZA.js.map +1 -0
- package/dist/listbox-DYvJTiF6.cjs +2 -0
- package/dist/listbox-DYvJTiF6.cjs.map +1 -0
- package/dist/loaders/index.cjs +1 -1
- package/dist/loaders/index.cjs.map +1 -1
- package/dist/loaders/index.d.ts +218 -188
- package/dist/loaders/index.js +1 -1
- package/dist/loaders/index.js.map +1 -1
- package/dist/merge-element-props-0mpNO7ZH.cjs +2 -0
- package/dist/merge-element-props-0mpNO7ZH.cjs.map +1 -0
- package/dist/merge-element-props-PxUvRHax.js +2 -0
- package/dist/merge-element-props-PxUvRHax.js.map +1 -0
- package/dist/platform-C-sxBTRa.cjs +2 -0
- package/dist/platform-C-sxBTRa.cjs.map +1 -0
- package/dist/platform-C4_cGUkS.js +2 -0
- package/dist/platform-C4_cGUkS.js.map +1 -0
- package/dist/popup-menu-BBAzAXIe.cjs +2 -0
- package/dist/popup-menu-BBAzAXIe.cjs.map +1 -0
- package/dist/popup-menu-HmBMJEZc.js +2 -0
- package/dist/popup-menu-HmBMJEZc.js.map +1 -0
- package/dist/resolve-state-props-C-zbhdXd.cjs +2 -0
- package/dist/resolve-state-props-C-zbhdXd.cjs.map +1 -0
- package/dist/resolve-state-props-D31kizRZ.js +2 -0
- package/dist/resolve-state-props-D31kizRZ.js.map +1 -0
- package/dist/rolldown-runtime-5lHFv1cW.cjs +1 -0
- package/dist/rolldown-runtime-DK3Fl9T5.js +1 -0
- package/dist/select/index.cjs +1 -1
- package/dist/select/index.cjs.map +1 -1
- package/dist/select/index.d.ts +835 -828
- package/dist/select/index.js +1 -1
- package/dist/select/index.js.map +1 -1
- package/dist/suggestion-menu/index.cjs +4 -0
- package/dist/suggestion-menu/index.cjs.map +1 -0
- package/dist/suggestion-menu/index.d.ts +359 -0
- package/dist/suggestion-menu/index.js +4 -0
- package/dist/suggestion-menu/index.js.map +1 -0
- package/dist/types-BbN28E3_.d.ts +50 -0
- package/dist/video-player/index.cjs +2 -2
- package/dist/video-player/index.cjs.map +1 -1
- package/dist/video-player/index.d.ts +964 -1000
- package/dist/video-player/index.js +2 -2
- package/dist/video-player/index.js.map +1 -1
- package/package.json +14 -5
- package/dist/ListboxStore-B8oTpM57.d.cts +0 -453
- package/dist/ListboxStore-CV5vPUUc.d.ts +0 -453
- package/dist/chunk-4C666HHU.js +0 -2
- package/dist/chunk-4C666HHU.js.map +0 -1
- package/dist/chunk-5T5B5SPR.cjs +0 -2
- package/dist/chunk-5T5B5SPR.cjs.map +0 -1
- package/dist/chunk-A4Z5BY7H.js +0 -2
- package/dist/chunk-A4Z5BY7H.js.map +0 -1
- package/dist/chunk-BEWVWSAW.cjs +0 -2
- package/dist/chunk-BEWVWSAW.cjs.map +0 -1
- package/dist/chunk-EDZTZHQ4.js +0 -2
- package/dist/chunk-EDZTZHQ4.js.map +0 -1
- package/dist/chunk-IT372NHF.js +0 -2
- package/dist/chunk-IT372NHF.js.map +0 -1
- package/dist/chunk-JFEVUUPC.cjs +0 -2
- package/dist/chunk-JFEVUUPC.cjs.map +0 -1
- package/dist/chunk-KO3DXT3Y.js +0 -2
- package/dist/chunk-KO3DXT3Y.js.map +0 -1
- package/dist/chunk-LXXK4S4Q.js +0 -2
- package/dist/chunk-LXXK4S4Q.js.map +0 -1
- package/dist/chunk-M4G6J7DP.cjs +0 -2
- package/dist/chunk-M4G6J7DP.cjs.map +0 -1
- package/dist/chunk-SCDHQZFI.cjs +0 -2
- package/dist/chunk-SCDHQZFI.cjs.map +0 -1
- package/dist/chunk-XMZZ62VJ.cjs +0 -2
- package/dist/chunk-XMZZ62VJ.cjs.map +0 -1
- package/dist/combobox/index.d.cts +0 -1066
- package/dist/command-menu/index.d.cts +0 -154
- package/dist/command-score-CTJ9NV6n.d.cts +0 -23
- package/dist/command-score-CTJ9NV6n.d.ts +0 -23
- package/dist/context-menu/index.d.cts +0 -696
- package/dist/dropdown-menu/index.d.cts +0 -723
- package/dist/events-BTHQ2OoH.d.ts +0 -1860
- package/dist/events-DVcrtGe3.d.cts +0 -1860
- package/dist/input-C95v6jB0.d.cts +0 -46
- package/dist/input-CYweYB_i.d.ts +0 -46
- package/dist/internal/listbox/index.cjs.map +0 -1
- package/dist/internal/listbox/index.d.cts +0 -272
- package/dist/internal/listbox/index.js.map +0 -1
- package/dist/internal/popup-menu/index.cjs.map +0 -1
- package/dist/internal/popup-menu/index.d.cts +0 -238
- package/dist/internal/popup-menu/index.js.map +0 -1
- package/dist/items-B6HeFO_8.d.ts +0 -37
- package/dist/kbd/index.d.cts +0 -61
- package/dist/loaders/index.d.cts +0 -363
- package/dist/loading-C6WZGUc3.d.cts +0 -29
- package/dist/loading-CC4n55sR.d.ts +0 -29
- package/dist/resolve-B-j0eW24.d.cts +0 -406
- package/dist/resolve-B1F-a3P1.d.ts +0 -406
- package/dist/scroll-arrow-BBoKckL_.d.cts +0 -544
- package/dist/scroll-arrow-fl3B5sVO.d.ts +0 -544
- package/dist/select/index.d.cts +0 -1005
- package/dist/separator-Dn15rte3.d.ts +0 -275
- package/dist/separator-NjsBVzek.d.cts +0 -275
- package/dist/surface-context-CGLDpMej.d.ts +0 -14
- package/dist/surface-context-CN4Lb_6F.d.cts +0 -14
- package/dist/type-guards-BHHzjRvZ.d.cts +0 -351
- package/dist/type-guards-C0e_GpeY.d.ts +0 -351
- package/dist/types-DT4FOOa2.d.cts +0 -51
- package/dist/types-DT4FOOa2.d.ts +0 -51
- package/dist/use-listbox-item-NzZuY34-.d.cts +0 -212
- package/dist/use-listbox-item-NzZuY34-.d.ts +0 -212
- package/dist/video-player/index.d.cts +0 -1391
package/dist/chunk-IT372NHF.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{makeEventPreventable as s,mergeProps as p}from"@base-ui/react/merge-props";function E(e,n){return p(e,l(n))}function l(e){let n={...e};for(let t in n){let r=n[t];m(t,r)&&(n[t]=(o,...a)=>(s(o),r(o,...a)))}return n}function m(e,n){return e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>=65&&e.charCodeAt(2)<=90&&typeof n=="function"}export{E as a};
|
|
2
|
-
//# sourceMappingURL=chunk-IT372NHF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/merge-element-props.ts"],"sourcesContent":["import { makeEventPreventable, mergeProps } from '@base-ui/react/merge-props'\nimport type * as React from 'react'\n\ntype ElementType = React.ElementType\ntype ElementProps<T extends ElementType> = React.ComponentPropsWithRef<T>\n\nexport function mergeElementProps<\n T extends ElementType,\n InternalProps extends Record<string, unknown> = ElementProps<T>,\n ExternalProps extends Partial<ElementProps<T>> = Partial<ElementProps<T>>,\n>(internalProps: InternalProps, externalProps: ExternalProps) {\n return mergeProps<T>(\n internalProps as ElementProps<T>,\n wrapEventHandlers<T>(externalProps) as ElementProps<T>,\n ) as InternalProps & ExternalProps\n}\n\nfunction wrapEventHandlers<T extends ElementType>(\n props: Partial<ElementProps<T>>,\n) {\n const wrappedProps = { ...props } as Record<string, unknown>\n\n for (const propName in wrappedProps) {\n const propValue = wrappedProps[propName]\n if (isEventHandler(propName, propValue)) {\n wrappedProps[propName] = (\n event: React.SyntheticEvent,\n ...args: unknown[]\n ) => {\n makeEventPreventable(\n event as Parameters<typeof makeEventPreventable>[0],\n )\n return propValue(event, ...args)\n }\n }\n }\n\n return wrappedProps as Partial<ElementProps<T>>\n}\n\nfunction isEventHandler(\n key: string,\n value: unknown,\n): value is (event: React.SyntheticEvent, ...args: unknown[]) => unknown {\n return (\n key.charCodeAt(0) === 111 &&\n key.charCodeAt(1) === 110 &&\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90 &&\n typeof value === 'function'\n )\n}\n"],"mappings":"AAAA,OAAS,wBAAAA,EAAsB,cAAAC,MAAkB,6BAM1C,SAASC,EAIdC,EAA8BC,EAA8B,CAC5D,OAAOH,EACLE,EACAE,EAAqBD,CAAa,CACpC,CACF,CAEA,SAASC,EACPC,EACA,CACA,IAAMC,EAAe,CAAE,GAAGD,CAAM,EAEhC,QAAWE,KAAYD,EAAc,CACnC,IAAME,EAAYF,EAAaC,CAAQ,EACnCE,EAAeF,EAAUC,CAAS,IACpCF,EAAaC,CAAQ,EAAI,CACvBG,KACGC,KAEHZ,EACEW,CACF,EACOF,EAAUE,EAAO,GAAGC,CAAI,GAGrC,CAEA,OAAOL,CACT,CAEA,SAASG,EACPG,EACAC,EACuE,CACvE,OACED,EAAI,WAAW,CAAC,IAAM,KACtBA,EAAI,WAAW,CAAC,IAAM,KACtBA,EAAI,WAAW,CAAC,GAAK,IACrBA,EAAI,WAAW,CAAC,GAAK,IACrB,OAAOC,GAAU,UAErB","names":["makeEventPreventable","mergeProps","mergeElementProps","internalProps","externalProps","wrapEventHandlers","props","wrappedProps","propName","propValue","isEventHandler","event","args","key","value"]}
|
package/dist/chunk-JFEVUUPC.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var i={esc:"escape",return:"enter",del:"delete",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",space:"space",spacebar:"space",plus:"+"};function l(e){return _nullishCoalesce(i[e], () => (e))}function p(){return{meta:!1,ctrl:!1,alt:!1,shift:!1,mod:!1,key:null}}function f(e){let t=e.trim();return t.length===0?{chords:[]}:{chords:t.split(/\s+/).map(a=>{let n=p();for(let s of a.split("+")){let r=s.trim().toLowerCase();if(r!=="")if(r==="mod")n.mod=!0;else if(r==="meta"||r==="cmd"||r==="command"||r==="win"||r==="super")n.meta=!0;else if(r==="ctrl"||r==="control")n.ctrl=!0;else if(r==="alt"||r==="option"||r==="opt")n.alt=!0;else if(r==="shift")n.shift=!0;else{if(n.key!==null)throw new Error(`Keybinding chord "${a}" contains multiple keys: "${n.key}" and "${r}"`);n.key=l(r)}}return n})}}function c(e,t){let a=e.toLowerCase();switch(a){case"enter":return t==="apple"?"\u21B5":"Enter";case"escape":return"Esc";case"backspace":return t==="apple"?"\u232B":"Backspace";case"delete":return t==="apple"?"\u2326":"Del";case"tab":return t==="apple"?"\u21E5":"Tab";case"space":return"Space";case"arrowup":return"\u2191";case"arrowdown":return"\u2193";case"arrowleft":return"\u2190";case"arrowright":return"\u2192";default:return a.length===1?a.toUpperCase():a.charAt(0).toUpperCase()+a.slice(1)}}function g(e,t){let a=e.ctrl||t==="other"&&e.mod,n=e.meta||t==="apple"&&e.mod,s=[];return a&&s.push(t==="apple"?"\u2303":"Ctrl"),e.alt&&s.push(t==="apple"?"\u2325":"Alt"),e.shift&&s.push(t==="apple"?"\u21E7":"Shift"),n&&s.push(t==="apple"?"\u2318":"Win"),e.key!==null&&s.push(c(e.key,t)),s}var _react = require('react'); var o = _interopRequireWildcard(_react);function u(){if(typeof navigator>"u")return!1;let e=navigator,t=_optionalChain([e, 'access', _ => _.userAgentData, 'optionalAccess', _2 => _2.platform])||e.platform||e.userAgent;return/mac|iphone|ipad|ipod/i.test(t)}function m(e){let[t,a]=o.useState("other");return o.useEffect(()=>{e===void 0&&u()&&a("apple")},[e]),_nullishCoalesce(e, () => (t))}exports.a = f; exports.b = c; exports.c = g; exports.d = u; exports.e = m;
|
|
2
|
-
//# sourceMappingURL=chunk-JFEVUUPC.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/kbd/utils/parse-keybinding.ts","../src/kbd/utils/platform.ts"],"names":["keyAliases","normalizeKey","key","createChord","parseKeybinding","keys","trimmed","chordValue","chord","tokenValue","token","getKeyLabel","platform","normalizedKey","getChordLabels","isCtrl","isMeta","labels","isApplePlatform","nav","usePlatform","override","setPlatform"],"mappings":"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","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-JFEVUUPC.cjs","sourcesContent":["export interface KeyChord {\n meta: boolean\n ctrl: boolean\n alt: boolean\n shift: boolean\n mod: boolean\n key: string | null\n}\n\nexport interface Keybinding {\n chords: KeyChord[]\n}\n\ntype Platform = 'apple' | 'other'\n\nconst keyAliases: Record<string, string> = {\n esc: 'escape',\n return: 'enter',\n del: 'delete',\n up: 'arrowup',\n down: 'arrowdown',\n left: 'arrowleft',\n right: 'arrowright',\n space: 'space',\n spacebar: 'space',\n plus: '+',\n}\n\nfunction normalizeKey(key: string): string {\n return keyAliases[key] ?? key\n}\n\nfunction createChord(): KeyChord {\n return {\n meta: false,\n ctrl: false,\n alt: false,\n shift: false,\n mod: false,\n key: null,\n }\n}\n\nexport function parseKeybinding(keys: string): Keybinding {\n const trimmed = keys.trim()\n\n if (trimmed.length === 0) {\n return { chords: [] }\n }\n\n return {\n chords: trimmed.split(/\\s+/).map((chordValue) => {\n const chord = createChord()\n\n for (const tokenValue of chordValue.split('+')) {\n const token = tokenValue.trim().toLowerCase()\n\n if (token === '') {\n // Skip empty tokens from trailing/leading/double \"+\" (e.g. \"mod+\").\n // A literal \"+\" key is expressed with the \"plus\" alias.\n continue\n }\n\n if (token === 'mod') {\n chord.mod = true\n } else if (\n token === 'meta' ||\n token === 'cmd' ||\n token === 'command' ||\n token === 'win' ||\n token === 'super'\n ) {\n chord.meta = true\n } else if (token === 'ctrl' || token === 'control') {\n chord.ctrl = true\n } else if (token === 'alt' || token === 'option' || token === 'opt') {\n chord.alt = true\n } else if (token === 'shift') {\n chord.shift = true\n } else {\n if (chord.key !== null) {\n throw new Error(\n `Keybinding chord \"${chordValue}\" contains multiple keys: \"${chord.key}\" and \"${token}\"`,\n )\n }\n\n chord.key = normalizeKey(token)\n }\n }\n\n return chord\n }),\n }\n}\n\nexport function getKeyLabel(key: string, platform: Platform): string {\n const normalizedKey = key.toLowerCase()\n\n switch (normalizedKey) {\n case 'enter':\n return platform === 'apple' ? '↵' : 'Enter'\n case 'escape':\n return 'Esc'\n case 'backspace':\n return platform === 'apple' ? '⌫' : 'Backspace'\n case 'delete':\n return platform === 'apple' ? '⌦' : 'Del'\n case 'tab':\n return platform === 'apple' ? '⇥' : 'Tab'\n case 'space':\n return 'Space'\n case 'arrowup':\n return '↑'\n case 'arrowdown':\n return '↓'\n case 'arrowleft':\n return '←'\n case 'arrowright':\n return '→'\n default:\n if (normalizedKey.length === 1) {\n return normalizedKey.toUpperCase()\n }\n\n return normalizedKey.charAt(0).toUpperCase() + normalizedKey.slice(1)\n }\n}\n\nexport function getChordLabels(chord: KeyChord, platform: Platform): string[] {\n const isCtrl = chord.ctrl || (platform === 'other' && chord.mod)\n const isMeta = chord.meta || (platform === 'apple' && chord.mod)\n const labels: string[] = []\n\n if (isCtrl) {\n labels.push(platform === 'apple' ? '⌃' : 'Ctrl')\n }\n\n if (chord.alt) {\n labels.push(platform === 'apple' ? '⌥' : 'Alt')\n }\n\n if (chord.shift) {\n labels.push(platform === 'apple' ? '⇧' : 'Shift')\n }\n\n if (isMeta) {\n labels.push(platform === 'apple' ? '⌘' : 'Win')\n }\n\n if (chord.key !== null) {\n labels.push(getKeyLabel(chord.key, platform))\n }\n\n return labels\n}\n","'use client'\n\nimport * as React from 'react'\n\ntype Platform = 'apple' | 'other'\n\ninterface NavigatorWithUserAgentData extends Navigator {\n userAgentData?: {\n platform?: string\n }\n}\n\nexport function isApplePlatform(): boolean {\n if (typeof navigator === 'undefined') {\n return false\n }\n\n const nav = navigator as NavigatorWithUserAgentData\n const platform = nav.userAgentData?.platform || nav.platform || nav.userAgent\n\n return /mac|iphone|ipad|ipod/i.test(platform)\n}\n\n/**\n * Returns the current platform while keeping the first client render aligned with\n * SSR. Without an override, this starts as \"other\" and corrects to \"apple\" after\n * mount when appropriate, avoiding hydration mismatches.\n */\nexport function usePlatform(override?: Platform): Platform {\n const [platform, setPlatform] = React.useState<Platform>('other')\n\n React.useEffect(() => {\n if (override === undefined && isApplePlatform()) {\n setPlatform('apple')\n }\n }, [override])\n\n return override ?? platform\n}\n"]}
|
package/dist/chunk-KO3DXT3Y.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var d=(e,n)=>Object.is(e,n);function l(e,n,t){return e==null||n==null?Object.is(e,n):t(e,n)}function o(e,n,t){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:l(r,n,t))}function f(e,n,t){return e.filter(r=>!l(r,n,t))}function a(e){return e??""}function i(e,n){if(!e)return;if(Array.isArray(e)){let r=e.find(u=>a(u.value)===n);return r?{label:r.label,keywords:r.keywords}:void 0}let t=e[n];if(t!==void 0)return{label:t}}function m(e,n){return i(e,n)?.label}function y(e,n){let t=n.filter(u=>!!u);if(t.length===0)return e;let r=e?[...e]:[];for(let u of t)r.includes(u)||r.push(u);return r}export{d as a,l as b,o as c,f as d,i as e,m as f,y as g};
|
|
2
|
-
//# sourceMappingURL=chunk-KO3DXT3Y.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/item-equality.ts","../src/utils/items.ts"],"sourcesContent":["/**\n * Type for custom item equality comparison functions.\n * Used to compare object values in Select and Combobox components.\n */\nexport type ItemEqualityComparer<Value = unknown> = (\n itemValue: Value,\n value: Value,\n) => boolean\n\n/**\n * Default equality comparer using Object.is.\n * Handles primitives and object reference equality.\n */\nexport const defaultItemEquality: ItemEqualityComparer = (item, value) =>\n Object.is(item, value)\n\n/**\n * Compare two items for equality using a custom comparer.\n * Handles null/undefined values separately using Object.is.\n */\nexport function compareItemEquality<Value>(\n item: Value | null | undefined,\n value: Value | null | undefined,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n // Handle null/undefined with Object.is for consistent behavior\n if (item == null || value == null) {\n return Object.is(item, value)\n }\n return comparer(item, value)\n}\n\n/**\n * Check if a collection includes a specific value using custom equality.\n */\nexport function itemIncludes<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value | null | undefined,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n if (!collection || collection.length === 0) {\n return false\n }\n return collection.some((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Find the index of a value in a collection using custom equality.\n * Returns -1 if not found.\n */\nexport function findItemIndex<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): number {\n if (!collection || collection.length === 0) {\n return -1\n }\n return collection.findIndex((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Remove a value from a collection using custom equality.\n * Returns a new array without the matching item.\n */\nexport function removeItem<Value>(\n collection: readonly Value[],\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): Value[] {\n return collection.filter(\n (item) => !compareItemEquality(item, value, comparer),\n )\n}\n","import type * as React from 'react'\n\n/**\n * A single entry in the array form of the `items` prop passed to\n * `Select.Root` / `Combobox.Root`.\n */\nexport interface ItemsEntry {\n /**\n * The item's value.\n *\n * Use `null` to describe a clearable/placeholder item (its label is used as\n * the trigger placeholder and selecting it clears the value).\n */\n value: string | null\n /** The label to display for this item. */\n label: React.ReactNode\n /**\n * Additional keywords to match against when filtering, on top of the label.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n}\n\n/**\n * Data structure describing the items rendered in a Select/Combobox popup.\n *\n * Either a record mapping a value to its label, or an array of entries. Only\n * the array form can express `keywords` or a `null` (clearable) value.\n */\nexport type Items = Record<string, React.ReactNode> | Array<ItemsEntry>\n\n/**\n * The resolved metadata for a single item looked up from the `items` prop.\n */\nexport interface ResolvedItem {\n label: React.ReactNode\n keywords?: string[]\n}\n\n/** Serialize an entry value to the string key used for registry lookups. */\nfunction entryKey(value: string | null): string {\n return value == null ? '' : value\n}\n\n/**\n * Resolve the full entry (label + keywords) from the `items` prop for a given\n * serialized value key. Returns `undefined` when there is no match.\n */\nexport function resolveItemFromItems(\n items: Items | undefined,\n valueKey: string,\n): ResolvedItem | undefined {\n if (!items) return undefined\n\n if (Array.isArray(items)) {\n const entry = items.find((i) => entryKey(i.value) === valueKey)\n if (!entry) return undefined\n return { label: entry.label, keywords: entry.keywords }\n }\n\n const label = items[valueKey]\n if (label === undefined) return undefined\n return { label }\n}\n\n/**\n * Resolve just the label from the `items` prop for a given serialized value\n * key. Returns `undefined` when there is no match.\n */\nexport function resolveLabelFromItems(\n items: Items | undefined,\n valueKey: string,\n): React.ReactNode | undefined {\n return resolveItemFromItems(items, valueKey)?.label\n}\n\n/**\n * Merge a set of extra keyword strings into an existing keywords array,\n * preserving order and removing duplicates. Returns the original `keywords`\n * reference untouched when there is nothing to add.\n */\nexport function mergeKeywords(\n keywords: string[] | undefined,\n extra: Array<string | undefined>,\n): string[] | undefined {\n const additions = extra.filter((k): k is string => Boolean(k))\n if (additions.length === 0) return keywords\n\n const merged = keywords ? [...keywords] : []\n for (const keyword of additions) {\n if (!merged.includes(keyword)) merged.push(keyword)\n }\n return merged\n}\n"],"mappings":"AAaO,IAAMA,EAA4C,CAACC,EAAMC,IAC9D,OAAO,GAAGD,EAAMC,CAAK,EAMhB,SAASC,EACdF,EACAC,EACAE,EACS,CAET,OAAIH,GAAQ,MAAQC,GAAS,KACpB,OAAO,GAAGD,EAAMC,CAAK,EAEvBE,EAASH,EAAMC,CAAK,CAC7B,CAKO,SAASG,EACdC,EACAJ,EACAE,EACS,CACT,MAAI,CAACE,GAAcA,EAAW,SAAW,EAChC,GAEFA,EAAW,KAAML,GAClBA,IAAS,OACJ,GAEFE,EAAoBF,EAAMC,EAAOE,CAAQ,CACjD,CACH,CA0BO,SAASG,EACdC,EACAC,EACAC,EACS,CACT,OAAOF,EAAW,OACfG,GAAS,CAACC,EAAoBD,EAAMF,EAAOC,CAAQ,CACtD,CACF,CC3CA,SAASG,EAASC,EAA8B,CAC9C,OAAOA,GAAgB,EACzB,CAMO,SAASC,EACdC,EACAC,EAC0B,CAC1B,GAAI,CAACD,EAAO,OAEZ,GAAI,MAAM,QAAQA,CAAK,EAAG,CACxB,IAAME,EAAQF,EAAM,KAAMG,GAAMN,EAASM,EAAE,KAAK,IAAMF,CAAQ,EAC9D,OAAKC,EACE,CAAE,MAAOA,EAAM,MAAO,SAAUA,EAAM,QAAS,EAD1C,MAEd,CAEA,IAAME,EAAQJ,EAAMC,CAAQ,EAC5B,GAAIG,IAAU,OACd,MAAO,CAAE,MAAAA,CAAM,CACjB,CAMO,SAASC,EACdL,EACAC,EAC6B,CAC7B,OAAOF,EAAqBC,EAAOC,CAAQ,GAAG,KAChD,CAOO,SAASK,EACdC,EACAC,EACsB,CACtB,IAAMC,EAAYD,EAAM,OAAQE,GAAmB,EAAQA,CAAE,EAC7D,GAAID,EAAU,SAAW,EAAG,OAAOF,EAEnC,IAAMI,EAASJ,EAAW,CAAC,GAAGA,CAAQ,EAAI,CAAC,EAC3C,QAAWK,KAAWH,EACfE,EAAO,SAASC,CAAO,GAAGD,EAAO,KAAKC,CAAO,EAEpD,OAAOD,CACT","names":["defaultItemEquality","item","value","compareItemEquality","comparer","itemIncludes","collection","removeItem","collection","value","comparer","item","compareItemEquality","entryKey","value","resolveItemFromItems","items","valueKey","entry","i","label","resolveLabelFromItems","mergeKeywords","keywords","extra","additions","k","merged","keyword"]}
|
package/dist/chunk-LXXK4S4Q.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var i={esc:"escape",return:"enter",del:"delete",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",space:"space",spacebar:"space",plus:"+"};function l(e){return i[e]??e}function p(){return{meta:!1,ctrl:!1,alt:!1,shift:!1,mod:!1,key:null}}function f(e){let t=e.trim();return t.length===0?{chords:[]}:{chords:t.split(/\s+/).map(a=>{let n=p();for(let s of a.split("+")){let r=s.trim().toLowerCase();if(r!=="")if(r==="mod")n.mod=!0;else if(r==="meta"||r==="cmd"||r==="command"||r==="win"||r==="super")n.meta=!0;else if(r==="ctrl"||r==="control")n.ctrl=!0;else if(r==="alt"||r==="option"||r==="opt")n.alt=!0;else if(r==="shift")n.shift=!0;else{if(n.key!==null)throw new Error(`Keybinding chord "${a}" contains multiple keys: "${n.key}" and "${r}"`);n.key=l(r)}}return n})}}function c(e,t){let a=e.toLowerCase();switch(a){case"enter":return t==="apple"?"\u21B5":"Enter";case"escape":return"Esc";case"backspace":return t==="apple"?"\u232B":"Backspace";case"delete":return t==="apple"?"\u2326":"Del";case"tab":return t==="apple"?"\u21E5":"Tab";case"space":return"Space";case"arrowup":return"\u2191";case"arrowdown":return"\u2193";case"arrowleft":return"\u2190";case"arrowright":return"\u2192";default:return a.length===1?a.toUpperCase():a.charAt(0).toUpperCase()+a.slice(1)}}function g(e,t){let a=e.ctrl||t==="other"&&e.mod,n=e.meta||t==="apple"&&e.mod,s=[];return a&&s.push(t==="apple"?"\u2303":"Ctrl"),e.alt&&s.push(t==="apple"?"\u2325":"Alt"),e.shift&&s.push(t==="apple"?"\u21E7":"Shift"),n&&s.push(t==="apple"?"\u2318":"Win"),e.key!==null&&s.push(c(e.key,t)),s}import*as o from"react";function u(){if(typeof navigator>"u")return!1;let e=navigator,t=e.userAgentData?.platform||e.platform||e.userAgent;return/mac|iphone|ipad|ipod/i.test(t)}function m(e){let[t,a]=o.useState("other");return o.useEffect(()=>{e===void 0&&u()&&a("apple")},[e]),e??t}export{f as a,c as b,g as c,u as d,m as e};
|
|
2
|
-
//# sourceMappingURL=chunk-LXXK4S4Q.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/kbd/utils/parse-keybinding.ts","../src/kbd/utils/platform.ts"],"sourcesContent":["export interface KeyChord {\n meta: boolean\n ctrl: boolean\n alt: boolean\n shift: boolean\n mod: boolean\n key: string | null\n}\n\nexport interface Keybinding {\n chords: KeyChord[]\n}\n\ntype Platform = 'apple' | 'other'\n\nconst keyAliases: Record<string, string> = {\n esc: 'escape',\n return: 'enter',\n del: 'delete',\n up: 'arrowup',\n down: 'arrowdown',\n left: 'arrowleft',\n right: 'arrowright',\n space: 'space',\n spacebar: 'space',\n plus: '+',\n}\n\nfunction normalizeKey(key: string): string {\n return keyAliases[key] ?? key\n}\n\nfunction createChord(): KeyChord {\n return {\n meta: false,\n ctrl: false,\n alt: false,\n shift: false,\n mod: false,\n key: null,\n }\n}\n\nexport function parseKeybinding(keys: string): Keybinding {\n const trimmed = keys.trim()\n\n if (trimmed.length === 0) {\n return { chords: [] }\n }\n\n return {\n chords: trimmed.split(/\\s+/).map((chordValue) => {\n const chord = createChord()\n\n for (const tokenValue of chordValue.split('+')) {\n const token = tokenValue.trim().toLowerCase()\n\n if (token === '') {\n // Skip empty tokens from trailing/leading/double \"+\" (e.g. \"mod+\").\n // A literal \"+\" key is expressed with the \"plus\" alias.\n continue\n }\n\n if (token === 'mod') {\n chord.mod = true\n } else if (\n token === 'meta' ||\n token === 'cmd' ||\n token === 'command' ||\n token === 'win' ||\n token === 'super'\n ) {\n chord.meta = true\n } else if (token === 'ctrl' || token === 'control') {\n chord.ctrl = true\n } else if (token === 'alt' || token === 'option' || token === 'opt') {\n chord.alt = true\n } else if (token === 'shift') {\n chord.shift = true\n } else {\n if (chord.key !== null) {\n throw new Error(\n `Keybinding chord \"${chordValue}\" contains multiple keys: \"${chord.key}\" and \"${token}\"`,\n )\n }\n\n chord.key = normalizeKey(token)\n }\n }\n\n return chord\n }),\n }\n}\n\nexport function getKeyLabel(key: string, platform: Platform): string {\n const normalizedKey = key.toLowerCase()\n\n switch (normalizedKey) {\n case 'enter':\n return platform === 'apple' ? '↵' : 'Enter'\n case 'escape':\n return 'Esc'\n case 'backspace':\n return platform === 'apple' ? '⌫' : 'Backspace'\n case 'delete':\n return platform === 'apple' ? '⌦' : 'Del'\n case 'tab':\n return platform === 'apple' ? '⇥' : 'Tab'\n case 'space':\n return 'Space'\n case 'arrowup':\n return '↑'\n case 'arrowdown':\n return '↓'\n case 'arrowleft':\n return '←'\n case 'arrowright':\n return '→'\n default:\n if (normalizedKey.length === 1) {\n return normalizedKey.toUpperCase()\n }\n\n return normalizedKey.charAt(0).toUpperCase() + normalizedKey.slice(1)\n }\n}\n\nexport function getChordLabels(chord: KeyChord, platform: Platform): string[] {\n const isCtrl = chord.ctrl || (platform === 'other' && chord.mod)\n const isMeta = chord.meta || (platform === 'apple' && chord.mod)\n const labels: string[] = []\n\n if (isCtrl) {\n labels.push(platform === 'apple' ? '⌃' : 'Ctrl')\n }\n\n if (chord.alt) {\n labels.push(platform === 'apple' ? '⌥' : 'Alt')\n }\n\n if (chord.shift) {\n labels.push(platform === 'apple' ? '⇧' : 'Shift')\n }\n\n if (isMeta) {\n labels.push(platform === 'apple' ? '⌘' : 'Win')\n }\n\n if (chord.key !== null) {\n labels.push(getKeyLabel(chord.key, platform))\n }\n\n return labels\n}\n","'use client'\n\nimport * as React from 'react'\n\ntype Platform = 'apple' | 'other'\n\ninterface NavigatorWithUserAgentData extends Navigator {\n userAgentData?: {\n platform?: string\n }\n}\n\nexport function isApplePlatform(): boolean {\n if (typeof navigator === 'undefined') {\n return false\n }\n\n const nav = navigator as NavigatorWithUserAgentData\n const platform = nav.userAgentData?.platform || nav.platform || nav.userAgent\n\n return /mac|iphone|ipad|ipod/i.test(platform)\n}\n\n/**\n * Returns the current platform while keeping the first client render aligned with\n * SSR. Without an override, this starts as \"other\" and corrects to \"apple\" after\n * mount when appropriate, avoiding hydration mismatches.\n */\nexport function usePlatform(override?: Platform): Platform {\n const [platform, setPlatform] = React.useState<Platform>('other')\n\n React.useEffect(() => {\n if (override === undefined && isApplePlatform()) {\n setPlatform('apple')\n }\n }, [override])\n\n return override ?? platform\n}\n"],"mappings":"AAeA,IAAMA,EAAqC,CACzC,IAAK,SACL,OAAQ,QACR,IAAK,SACL,GAAI,UACJ,KAAM,YACN,KAAM,YACN,MAAO,aACP,MAAO,QACP,SAAU,QACV,KAAM,GACR,EAEA,SAASC,EAAaC,EAAqB,CACzC,OAAOF,EAAWE,CAAG,GAAKA,CAC5B,CAEA,SAASC,GAAwB,CAC/B,MAAO,CACL,KAAM,GACN,KAAM,GACN,IAAK,GACL,MAAO,GACP,IAAK,GACL,IAAK,IACP,CACF,CAEO,SAASC,EAAgBC,EAA0B,CACxD,IAAMC,EAAUD,EAAK,KAAK,EAE1B,OAAIC,EAAQ,SAAW,EACd,CAAE,OAAQ,CAAC,CAAE,EAGf,CACL,OAAQA,EAAQ,MAAM,KAAK,EAAE,IAAKC,GAAe,CAC/C,IAAMC,EAAQL,EAAY,EAE1B,QAAWM,KAAcF,EAAW,MAAM,GAAG,EAAG,CAC9C,IAAMG,EAAQD,EAAW,KAAK,EAAE,YAAY,EAE5C,GAAIC,IAAU,GAMd,GAAIA,IAAU,MACZF,EAAM,IAAM,WAEZE,IAAU,QACVA,IAAU,OACVA,IAAU,WACVA,IAAU,OACVA,IAAU,QAEVF,EAAM,KAAO,WACJE,IAAU,QAAUA,IAAU,UACvCF,EAAM,KAAO,WACJE,IAAU,OAASA,IAAU,UAAYA,IAAU,MAC5DF,EAAM,IAAM,WACHE,IAAU,QACnBF,EAAM,MAAQ,OACT,CACL,GAAIA,EAAM,MAAQ,KAChB,MAAM,IAAI,MACR,qBAAqBD,CAAU,8BAA8BC,EAAM,GAAG,UAAUE,CAAK,GACvF,EAGFF,EAAM,IAAMP,EAAaS,CAAK,CAChC,CACF,CAEA,OAAOF,CACT,CAAC,CACH,CACF,CAEO,SAASG,EAAYT,EAAaU,EAA4B,CACnE,IAAMC,EAAgBX,EAAI,YAAY,EAEtC,OAAQW,EAAe,CACrB,IAAK,QACH,OAAOD,IAAa,QAAU,SAAM,QACtC,IAAK,SACH,MAAO,MACT,IAAK,YACH,OAAOA,IAAa,QAAU,SAAM,YACtC,IAAK,SACH,OAAOA,IAAa,QAAU,SAAM,MACtC,IAAK,MACH,OAAOA,IAAa,QAAU,SAAM,MACtC,IAAK,QACH,MAAO,QACT,IAAK,UACH,MAAO,SACT,IAAK,YACH,MAAO,SACT,IAAK,YACH,MAAO,SACT,IAAK,aACH,MAAO,SACT,QACE,OAAIC,EAAc,SAAW,EACpBA,EAAc,YAAY,EAG5BA,EAAc,OAAO,CAAC,EAAE,YAAY,EAAIA,EAAc,MAAM,CAAC,CACxE,CACF,CAEO,SAASC,EAAeN,EAAiBI,EAA8B,CAC5E,IAAMG,EAASP,EAAM,MAASI,IAAa,SAAWJ,EAAM,IACtDQ,EAASR,EAAM,MAASI,IAAa,SAAWJ,EAAM,IACtDS,EAAmB,CAAC,EAE1B,OAAIF,GACFE,EAAO,KAAKL,IAAa,QAAU,SAAM,MAAM,EAG7CJ,EAAM,KACRS,EAAO,KAAKL,IAAa,QAAU,SAAM,KAAK,EAG5CJ,EAAM,OACRS,EAAO,KAAKL,IAAa,QAAU,SAAM,OAAO,EAG9CI,GACFC,EAAO,KAAKL,IAAa,QAAU,SAAM,KAAK,EAG5CJ,EAAM,MAAQ,MAChBS,EAAO,KAAKN,EAAYH,EAAM,IAAKI,CAAQ,CAAC,EAGvCK,CACT,CCxJA,UAAYC,MAAW,QAUhB,SAASC,GAA2B,CACzC,GAAI,OAAO,UAAc,IACvB,MAAO,GAGT,IAAMC,EAAM,UACNC,EAAWD,EAAI,eAAe,UAAYA,EAAI,UAAYA,EAAI,UAEpE,MAAO,wBAAwB,KAAKC,CAAQ,CAC9C,CAOO,SAASC,EAAYC,EAA+B,CACzD,GAAM,CAACF,EAAUG,CAAW,EAAU,WAAmB,OAAO,EAEhE,OAAM,YAAU,IAAM,CAChBD,IAAa,QAAaJ,EAAgB,GAC5CK,EAAY,OAAO,CAEvB,EAAG,CAACD,CAAQ,CAAC,EAENA,GAAYF,CACrB","names":["keyAliases","normalizeKey","key","createChord","parseKeybinding","keys","trimmed","chordValue","chord","tokenValue","token","getKeyLabel","platform","normalizedKey","getChordLabels","isCtrl","isMeta","labels","React","isApplePlatform","nav","platform","usePlatform","override","setPlatform"]}
|
package/dist/chunk-M4G6J7DP.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/chunk-M4G6J7DP.cjs"],"names":[],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-M4G6J7DP.cjs"}
|
package/dist/chunk-SCDHQZFI.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _mergeprops = require('@base-ui/react/merge-props');function E(e,n){return _mergeprops.mergeProps.call(void 0, e,l(n))}function l(e){let n={...e};for(let t in n){let r=n[t];m(t,r)&&(n[t]=(o,...a)=>(_mergeprops.makeEventPreventable.call(void 0, o),r(o,...a)))}return n}function m(e,n){return e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>=65&&e.charCodeAt(2)<=90&&typeof n=="function"}exports.a = E;
|
|
2
|
-
//# sourceMappingURL=chunk-SCDHQZFI.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/merge-element-props.ts"],"names":["mergeElementProps","internalProps","externalProps","mergeProps","wrapEventHandlers","props","wrappedProps","propName","propValue","isEventHandler","event","args","makeEventPreventable","key","value"],"mappings":"AAAA,iIAAiD,SAMjCA,CAAAA,CAIdC,CAAAA,CAA8BC,CAAAA,CAA8B,CAC5D,OAAOC,oCAAAA,CACLF,CACAG,CAAAA,CAAqBF,CAAa,CACpC,CACF,CAEA,SAASE,CAAAA,CACPC,CAAAA,CACA,CACA,IAAMC,CAAAA,CAAe,CAAE,GAAGD,CAAM,CAAA,CAEhC,GAAA,CAAA,IAAWE,EAAAA,GAAYD,CAAAA,CAAc,CACnC,IAAME,CAAAA,CAAYF,CAAAA,CAAaC,CAAQ,CAAA,CACnCE,CAAAA,CAAeF,CAAAA,CAAUC,CAAS,CAAA,EAAA,CACpCF,CAAAA,CAAaC,CAAQ,CAAA,CAAI,CACvBG,CAAAA,CAAAA,GACGC,CAAAA,CAAAA,EAAAA,CAEHC,8CAAAA,CAEA,CAAA,CACOJ,CAAAA,CAAUE,CAAAA,CAAO,GAAGC,CAAI,CAAA,CAAA,CAGrC,CAEA,OAAOL,CACT,CAEA,SAASG,CAAAA,CACPI,CAAAA,CACAC,CAAAA,CACuE,CACvE,OACED,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,GAAM,GAAA,EACtBA,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,GAAM,GAAA,EACtBA,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,EAAK,EAAA,EACrBA,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,EAAK,EAAA,EACrB,OAAOC,CAAAA,EAAU,UAErB,CAAA,cAAA","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-SCDHQZFI.cjs","sourcesContent":["import { makeEventPreventable, mergeProps } from '@base-ui/react/merge-props'\nimport type * as React from 'react'\n\ntype ElementType = React.ElementType\ntype ElementProps<T extends ElementType> = React.ComponentPropsWithRef<T>\n\nexport function mergeElementProps<\n T extends ElementType,\n InternalProps extends Record<string, unknown> = ElementProps<T>,\n ExternalProps extends Partial<ElementProps<T>> = Partial<ElementProps<T>>,\n>(internalProps: InternalProps, externalProps: ExternalProps) {\n return mergeProps<T>(\n internalProps as ElementProps<T>,\n wrapEventHandlers<T>(externalProps) as ElementProps<T>,\n ) as InternalProps & ExternalProps\n}\n\nfunction wrapEventHandlers<T extends ElementType>(\n props: Partial<ElementProps<T>>,\n) {\n const wrappedProps = { ...props } as Record<string, unknown>\n\n for (const propName in wrappedProps) {\n const propValue = wrappedProps[propName]\n if (isEventHandler(propName, propValue)) {\n wrappedProps[propName] = (\n event: React.SyntheticEvent,\n ...args: unknown[]\n ) => {\n makeEventPreventable(\n event as Parameters<typeof makeEventPreventable>[0],\n )\n return propValue(event, ...args)\n }\n }\n }\n\n return wrappedProps as Partial<ElementProps<T>>\n}\n\nfunction isEventHandler(\n key: string,\n value: unknown,\n): value is (event: React.SyntheticEvent, ...args: unknown[]) => unknown {\n return (\n key.charCodeAt(0) === 111 &&\n key.charCodeAt(1) === 110 &&\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90 &&\n typeof value === 'function'\n )\n}\n"]}
|
package/dist/chunk-XMZZ62VJ.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var _chunkM4G6J7DPcjs = require('./chunk-M4G6J7DP.cjs');var _react = require('react'); var G = _interopRequireWildcard(_react); var H = _interopRequireWildcard(_react); var T = _interopRequireWildcard(_react); var A = _interopRequireWildcard(_react); var D = _interopRequireWildcard(_react); var b = _interopRequireWildcard(_react); var ge = _interopRequireWildcard(_react); var C = _interopRequireWildcard(_react);var he=G.createContext(null);function B(){return G.useContext(he)}var q=H.createContext(null);function ze(){let n=H.useContext(q);if(!n)throw new Error("Item child components must be used within an Item");return n}function Ne(){return H.useContext(q)}var $=T.createContext(null);function Y(){let n=T.useContext($);if(!n)throw new Error("Listbox components must be used within a Listbox provider");return n}function Fe(){return T.useContext($)}var W=A.createContext(null);process.env.NODE_ENV!=="production"&&(W.displayName="RowWidthContext");function Ge(){let n=A.useContext(W);if(!n)throw new Error("useRowWidthContext must be used within a List with measureRowWidth enabled");return n}function X(){return A.useContext(W)}var J=D.createContext(null);function Q(){let n=D.useContext(J);if(!n)throw new Error("Listbox components must be used within a Surface provider");return n}function We(){return D.useContext(J)}function P(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]), () => (""))}function fe(n){return n.normalize("NFD").replace(/\p{Diacritic}/gu,"")}function Ke(n){return n?n.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""):""}function _e(n){let{id:e,value:t,keywords:r,disabled:s=!1,activatable:o=!0,forceMount:a=!1,shortcut:l,forceOrder:d,forceScore:c,isSubmenuTrigger:h=!1,onSelect:g,closeOnClick:v=!0,onAfterSelect:R,children:m,aimGuard:E}=n,{store:i}=Q(),u=B(),{depth:x}=Y(),f=b.useRef(null),I=b.useId(),[O,z]=b.useState(null);b.useLayoutEffect(()=>{if(O)return i.registerRow(I,O,{kind:"item",groupId:_optionalChain([u, 'optionalAccess', _4 => _4.groupId])})},[O,I,_optionalChain([u, 'optionalAccess', _5 => _5.groupId]),i]);let[M,N]=b.useState("");b.useLayoutEffect(()=>{if(e===void 0&&t===void 0&&f.current){let y=_nullishCoalesce(_optionalChain([f, 'access', _6 => _6.current, 'access', _7 => _7.textContent, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()]), () => (""));N(y)}},[e,t,m]);let p=_nullishCoalesce(e, () => ((P(t)||M))),F=b.useId(),K=_nullishCoalesce(e, () => (`item-${F}`)),_=_optionalChain([r, 'optionalAccess', _10 => _10.map, 'call', _11 => _11(y=>P(y)), 'access', _12 => _12.filter, 'call', _13 => _13(Boolean)]),ye=_?JSON.stringify(_):void 0;b.useEffect(()=>!p&&!a?void 0:i.registerItem(p,{value:p,keywords:_,groupId:_optionalChain([u, 'optionalAccess', _14 => _14.groupId]),disabled:s,activatable:o,isSubmenuTrigger:h,shortcut:l,forceOrder:d,forceScore:c,closeOnClick:v}),[p,ye,_optionalChain([u, 'optionalAccess', _15 => _15.groupId]),s,o,h,l,d,c,v,i,a]),b.useEffect(()=>{if(p)return i.registerItemRef(p,f)},[p,i]);let U=X();b.useLayoutEffect(()=>{U&&f.current&&p&&U.queueMeasurement(f.current,p)},[U,p]),b.useEffect(()=>{if(!(!g||!p))return i.registerItemSelect(p,g)},[p,g,i]);let we=i.useState("normalizedSearch"),j=i.useState("isHighlighted",p),ie=i.useState("isFirstRow",I),se=i.useState("isLastRow",I),oe=i.useState("isFirstInGroup",I),ae=i.useState("isLastInGroup",I),Oe=i.useState("getItemScore",p),Me=i.isFilterDisabled(),Le=we.length>0,Pe=a||Me||!Le||Oe>0,le=b.useCallback(y=>{if(y.defaultPrevented||s||o===!1||!p)return;y.preventDefault(),_optionalChain([i, 'access', _16 => _16.context, 'access', _17 => _17.itemSelects, 'access', _18 => _18.get, 'call', _19 => _19(p), 'optionalCall', _20 => _20()]),_optionalChain([R, 'optionalCall', _21 => _21(p)])},[s,o,i,p,R]),ce=b.useCallback(y=>{y.preventDefault()},[]),ue=b.useCallback(y=>{if(!y.defaultPrevented&&!s&&p){if(E){let{aimGuardActiveRef:de,guardedDepthRef:De}=E;if(de.current&&De.current===x)return}i.shouldAllowPointerHighlight(y.clientX,y.clientY)&&i.setHighlightedId(p)}},[s,E,x,i,p]),ke=b.useMemo(()=>({id:K,highlighted:j,disabled:s,shortcut:l}),[K,j,s,l]),He=b.useCallback(y=>p?i.registerItemSelect(p,y):()=>{},[i,p]),Te=b.useMemo(()=>({onClick:le,onPointerMove:ue,onPointerDown:ce}),[le,ue,ce]),k=_optionalChain([u, 'optionalAccess', _22 => _22.positional]),Ae=b.useMemo(()=>({first:_nullishCoalesce(_optionalChain([k, 'optionalAccess', _23 => _23.first]), () => (ie)),last:_nullishCoalesce(_optionalChain([k, 'optionalAccess', _24 => _24.last]), () => (se)),firstInGroup:_nullishCoalesce(_optionalChain([k, 'optionalAccess', _25 => _25.firstInGroup]), () => (oe)),lastInGroup:_nullishCoalesce(_optionalChain([k, 'optionalAccess', _26 => _26.lastInGroup]), () => (ae))}),[k,ie,se,oe,ae]);return{id:K,storeId:p,ref:f,rowRef:z,positional:Ae,isHighlighted:j,isVisible:Pe,contextValue:ke,handlers:Te,registerSelect:He}}function Ue(n){let{store:e,surfaceId:t,enabled:r,onKeyDown:s,onSelect:o,closeAll:a,focusOwner:l,depth:d=0,submenuContext:c,subpageContext:h,enableTypeToSearch:g=!1,skipFocusOwnerCheck:v=!1}=n,R=_nullishCoalesce(_optionalChain([l, 'optionalAccess', _27 => _27.useState, 'call', _28 => _28("isOwner",t)]), () => (!0)),m=v?!0:R;return{handleKeyDown:ge.useCallback(i=>{if(_optionalChain([s, 'optionalCall', _29 => _29(i)]),!i.defaultPrevented&&r&&m&&!(i.nativeEvent.isComposing||i.keyCode===229)){if(g){let u=e.context.hideUntilActive,x=e.state.inputActive;if(u&&!x&&i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey){let I=e.context.shortcuts.get(i.key.toLowerCase());if(I&&e.selectByShortcut(i.key)){i.preventDefault();let O=e.context.items.get(I);_optionalChain([o, 'optionalCall', _30 => _30({itemId:I,closeOnClick:_nullishCoalesce(_optionalChain([O, 'optionalAccess', _31 => _31.closeOnClick]), () => (!0))})]);return}i.preventDefault(),e.setPendingSearch(i.key),e.setInputActive(!0);return}}switch(i.key){case"ArrowDown":{i.preventDefault(),e.highlightNext();break}case"ArrowUp":{i.preventDefault(),e.highlightPrev();break}case"n":{i.ctrlKey&&(i.preventDefault(),e.highlightNext());break}case"p":{i.ctrlKey&&(i.preventDefault(),e.highlightPrev());break}case"ArrowRight":{e.isHighlightedSubmenuTrigger()&&(i.preventDefault(),e.openSubmenuForHighlighted());break}case"l":{i.ctrlKey&&e.isHighlightedSubmenuTrigger()&&(i.preventDefault(),e.openSubmenuForHighlighted());break}case"ArrowLeft":{if(_optionalChain([h, 'optionalAccess', _32 => _32.goBack, 'call', _33 => _33()])){i.preventDefault(),l&&h.parentSurfaceId&&l.setOwnerId(h.parentSurfaceId);break}d>0&&c&&l&&(i.preventDefault(),c.setOpen(!1),l.setOwnerId(c.parentSurfaceId));break}case"h":{if(i.ctrlKey&&_optionalChain([h, 'optionalAccess', _34 => _34.goBack, 'call', _35 => _35()])){i.preventDefault(),l&&h.parentSurfaceId&&l.setOwnerId(h.parentSurfaceId);break}i.ctrlKey&&d>0&&c&&l&&(i.preventDefault(),c.setOpen(!1),l.setOwnerId(c.parentSurfaceId));break}case"Enter":{i.preventDefault();let u=e.state.highlightedId,x=e.getHighlightedItem();if(_optionalChain([x, 'optionalAccess', _36 => _36.activatable])===!1)break;e.selectHighlighted(),_optionalChain([o, 'optionalCall', _37 => _37({itemId:u,closeOnClick:_nullishCoalesce(_optionalChain([x, 'optionalAccess', _38 => _38.closeOnClick]), () => (!0))})]);break}case"Home":{i.preventDefault(),e.setHighlightedId(null),e.highlightNext();break}case"End":{i.preventDefault(),e.setHighlightedId(null),e.highlightPrev();break}case"Escape":{if(h){i.preventDefault(),i.stopPropagation(),h.closeRootOnEsc?a():h.goBack()&&l&&h.parentSurfaceId?l.setOwnerId(h.parentSurfaceId):d>0&&c&&(c.setOpen(!1),l&&l.setOwnerId(c.parentSurfaceId));break}if(d===0)break;i.preventDefault(),i.stopPropagation(),_optionalChain([c, 'optionalAccess', _39 => _39.closeRootOnEsc])!==!1?a():(c.setOpen(!1),l&&l.setOwnerId(c.parentSurfaceId));break}default:{let u=e.state.normalizedSearch.length>0;if(i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey&&!u){let f=e.context.shortcuts.get(i.key.toLowerCase());if(f&&e.selectByShortcut(i.key)){i.preventDefault();let I=e.context.items.get(f);_optionalChain([o, 'optionalCall', _40 => _40({itemId:f,closeOnClick:_nullishCoalesce(_optionalChain([I, 'optionalAccess', _41 => _41.closeOnClick]), () => (!0))})])}}break}}}},[s,r,m,g,e,d,c,h,l,o,a])}}var je=!1,Be=!1;function w(...n){je&&console.log("[useStickyRowWidth]",...n)}function pe(n){return`${Math.ceil(n)}px`}function qe(n){let e=Number.parseFloat(n);return Number.isFinite(e)?e:null}function $e(n){let{listRef:e,targetRef:t,maxWidth:r,enabled:s=!0}=n,o=C.useCallback(()=>_nullishCoalesce(_optionalChain([t, 'optionalAccess', _42 => _42.current]), () => (e.current)),[t,e]),a=C.useRef(0);C.useLayoutEffect(()=>{if(!s)return;let i=o();if(!i)return;let u=qe(i.style.getPropertyValue("--row-width").trim());!u||u<=a.current||(a.current=u,w("Hydrated max width from existing --row-width:",{hydratedWidth:u}))},[s,o]);let l=C.useRef([]),d=C.useRef([]),c=C.useRef(!1),h=C.useRef(new Set),g=C.useCallback(i=>{let u=o();if(!u)return;let x=r!==void 0?Math.min(i,r):i;w("--row-width updated:",{rawWidth:i,cappedWidth:x,cssValue:pe(x),maxWidthCap:r,targetElement:u.tagName+(u.className?`.${u.className.split(" ").join(".")}`:"")}),u.style.setProperty("--row-width",pe(x))},[o,r]),v=C.useCallback(()=>{c.current||(c.current=!0,requestAnimationFrame(()=>{let i=l.current,u=a.current,x=!1;if(i.length>0){w("Measuring batch of",i.length,"rows");for(let{element:f,id:I}of i){if(h.current.has(I))continue;if(!f.isConnected){w("Row skipped (unmounted):",{id:I});continue}let O=f.style.width,z=f.style.maxWidth;f.setAttribute("data-measuring",""),f.style.maxWidth="none",f.style.width="max-content";let M=Math.max(f.scrollWidth,f.offsetWidth)+1,N=getComputedStyle(f);if(w("Row measurement details:",{id:I,measuredWidth:M,scrollWidth:f.scrollWidth,offsetWidth:f.offsetWidth,computedWidth:N.width,computedMaxWidth:N.maxWidth,inlineMaxWidth:z,textContent:_optionalChain([f, 'access', _43 => _43.textContent, 'optionalAccess', _44 => _44.slice, 'call', _45 => _45(0,50)])}),Be||(f.style.width=O,f.style.maxWidth=z,f.removeAttribute("data-measuring")),M<=1){let p=f.getBoundingClientRect(),F=getComputedStyle(f);w("Row skipped (0-width, will retry):",{id:I,width:M,scrollWidth:f.scrollWidth,offsetWidth:f.offsetWidth,boundingRect:{width:p.width,height:p.height},display:F.display,visibility:F.visibility,innerHTML:f.innerHTML.slice(0,100),isConnected:f.isConnected,parentElement:_optionalChain([f, 'access', _46 => _46.parentElement, 'optionalAccess', _47 => _47.tagName])});continue}w("Row measured:",{id:I,width:M,currentMax:u,isNewMax:M>u}),M>u&&(u=M,x=!0),h.current.add(I)}l.current=[]}x&&(w("New max width found:",{previousMax:a.current,newMax:u,totalMeasured:h.current.size}),a.current=u,d.current.push(()=>g(u)));for(let f of d.current)f();d.current=[],c.current=!1}))},[g]),R=C.useCallback((i,u)=>{if(!s){w("queueMeasurement skipped (disabled):",u);return}if(h.current.has(u)){w("queueMeasurement skipped (already measured):",u);return}w("queueMeasurement:",{id:u,queueSize:l.current.length+1,element:i.tagName}),l.current.push({element:i,id:u}),v()},[s,v]),m=C.useCallback(()=>{let i=a.current,u=h.current.size;h.current.clear(),a.current=0;let x=o();x&&x.style.removeProperty("--row-width"),w("Measurements reset:",{previousMaxWidth:i,previousMeasuredCount:u,targetElement:_optionalChain([x, 'optionalAccess', _48 => _48.tagName])})},[o]),E=C.useCallback(()=>{let i=h.current.size;h.current.clear(),w("Measured IDs cleared (sticky width kept):",{previousMeasuredCount:i,currentMaxWidth:a.current})},[]);return C.useEffect(()=>{if(!s)return;let i=o();if(!i||typeof ResizeObserver>"u")return;let u=null,x=new ResizeObserver(f=>{u!==null&&cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=null,a.current>0&&(w("ResizeObserver triggered re-apply:",{currentMax:a.current,containerSize:_optionalChain([f, 'access', _49 => _49[0], 'optionalAccess', _50 => _50.contentRect])}),g(a.current))})});return x.observe(i),()=>{u!==null&&cancelAnimationFrame(u),x.disconnect()}},[o,s,g]),{queueMeasurement:R,resetMeasurements:m,clearMeasuredIds:E}}var _store = require('@base-ui/utils/store');var _useRefWithInit = require('@base-ui/utils/useRefWithInit');var L={};_chunkM4G6J7DPcjs.a.call(void 0, L,{auto:()=>ft,clearPress:()=>at,closePress:()=>it,escapeKey:()=>Ze,focusOut:()=>tt,imperativeAction:()=>gt,inputChange:()=>st,inputClear:()=>ot,itemKeyboardSelect:()=>rt,itemPress:()=>nt,keyboard:()=>ht,listNavigation:()=>lt,none:()=>pt,outsidePress:()=>et,pointer:()=>dt,siblingOpen:()=>ut,submenuTrigger:()=>ct,triggerContextMenu:()=>Qe,triggerFocus:()=>Je,triggerHover:()=>Xe,triggerPress:()=>Ye});var Ye="trigger-press",Xe="trigger-hover",Je="trigger-focus",Qe="trigger-context-menu",Ze="escape-key",et="outside-press",tt="focus-out",nt="item-press",rt="item-keyboard-select",it="close-press",st="input-change",ot="input-clear",at="clear-press",lt="list-navigation",ct="submenu-trigger",ut="sibling-open",dt="pointer",ht="keyboard",ft="auto",gt="imperative-action",pt="none";function me(n,e,t,r){let s=!1,o=!1;return{reason:n,event:_nullishCoalesce(e, () => (new Event("ui-event"))),cancel(){s=!0},allowPropagation(){o=!0},get isCanceled(){return s},get isPropagationAllowed(){return o},trigger:t,...r}}function xe(n,e,t){return{reason:n,event:_nullishCoalesce(e, () => (new Event("ui-event"))),...t}}var Z=null,be=!1;function mt(n){Z=n.pointerType||"mouse"}function xt(){Z=null}function Zt(){be||typeof document>"u"||(be=!0,document.addEventListener("pointerdown",mt,{capture:!0,passive:!0}),document.addEventListener("keydown",xt,{capture:!0,passive:!0}))}function Se(n){switch(n){case"touch":return"touch";case"pen":return"pen";case"mouse":return"mouse";default:return null}}function Ie(n){let e=Se(_optionalChain([n, 'optionalAccess', _51 => _51.pointerType]));return e||(n&&typeof KeyboardEvent<"u"&&n instanceof KeyboardEvent?"keyboard":_nullishCoalesce(Se(Z), () => ("keyboard")))}var Re=1,bt=.9,St=.8,It=.17,ee=.1,te=.999,Rt=.9999;var vt=.99,Ct=/[\\/_+.#"@[({&]/,Et=/[\\/_+.#"@[({&]/g,yt=/[\s-]/,Ce=/[\s-]/g;function ne(n,e,t,r,s,o,a){if(o===e.length)return s===n.length?Re:vt;let l=`${s},${o}`;if(a[l]!==void 0)return a[l];let d=r.charAt(o),c=t.indexOf(d,s),h=0,g,v,R,m;for(;c>=0;)g=ne(n,e,t,r,c+1,o+1,a),g>h&&(c===s?g*=Re:Ct.test(n.charAt(c-1))?(g*=St,R=n.slice(s,c-1).match(Et),R&&s>0&&(g*=te**R.length)):yt.test(n.charAt(c-1))?(g*=bt,m=n.slice(s,c-1).match(Ce),m&&s>0&&(g*=te**m.length)):(g*=It,s>0&&(g*=te**(c-s))),n.charAt(c)!==e.charAt(o)&&(g*=Rt)),(g<ee&&t.charAt(c-1)===r.charAt(o+1)||r.charAt(o+1)===r.charAt(o)&&t.charAt(c-1)!==r.charAt(o))&&(v=ne(n,e,t,r,c+1,o+2,a),v*ee>g&&(g=v*ee)),g>h&&(h=g),c=t.indexOf(d,c+1);return a[l]=h,h}function ve(n){return fe(n.toLowerCase()).replace(Ce," ")}function V(n,e,t){if(!e)return 1;if(!n)return 0;let r=t&&t.length>0?`${n} ${t.join(" ")}`:n;return ne(r,e,ve(r),ve(e),0,0,{})}var wt=V;var Lt={open:_store.createSelector.call(void 0, n=>_nullishCoalesce(n.openProp, () => (n.open))),openMethod:_store.createSelector.call(void 0, n=>n.openMethod),search:_store.createSelector.call(void 0, n=>_nullishCoalesce(n.searchProp, () => (n.search))),normalizedSearch:_store.createSelector.call(void 0, n=>n.normalizedSearch),highlightedId:_store.createSelector.call(void 0, n=>n.highlightedId),highlightSource:_store.createSelector.call(void 0, n=>n.highlightSource),hasInput:_store.createSelector.call(void 0, n=>n.hasInput),inputActive:_store.createSelector.call(void 0, n=>n.inputActive),pendingSearch:_store.createSelector.call(void 0, n=>n.pendingSearch),filteredCount:_store.createSelector.call(void 0, n=>n.filteredCount),filteredItems:_store.createSelector.call(void 0, n=>n.filteredItems),visibleGroups:_store.createSelector.call(void 0, n=>n.visibleGroups),virtualized:_store.createSelector.call(void 0, n=>n.virtualized),isHighlighted:_store.createSelector.call(void 0, (n,e)=>n.highlightedId===e),isGroupVisible:_store.createSelector.call(void 0, (n,e)=>n.normalizedSearch.length===0||n.visibleGroups.has(e)),isFirstRow:_store.createSelector.call(void 0, (n,e)=>n.virtualized?!1:_optionalChain([n, 'access', _52 => _52.orderedRows, 'access', _53 => _53.filter, 'call', _54 => _54(r=>r.groupId===void 0), 'access', _55 => _55[0], 'optionalAccess', _56 => _56.id])===e),isLastRow:_store.createSelector.call(void 0, (n,e)=>n.virtualized?!1:_optionalChain([n, 'access', _57 => _57.orderedRows, 'access', _58 => _58.filter, 'call', _59 => _59(r=>r.groupId===void 0), 'access', _60 => _60.at, 'call', _61 => _61(-1), 'optionalAccess', _62 => _62.id])===e),isFirstGroup:_store.createSelector.call(void 0, (n,e)=>n.virtualized?!1:_optionalChain([n, 'access', _63 => _63.orderedRows, 'access', _64 => _64.filter, 'call', _65 => _65(r=>r.kind==="group"), 'access', _66 => _66[0], 'optionalAccess', _67 => _67.id])===e),isLastGroup:_store.createSelector.call(void 0, (n,e)=>n.virtualized?!1:_optionalChain([n, 'access', _68 => _68.orderedRows, 'access', _69 => _69.filter, 'call', _70 => _70(r=>r.kind==="group"), 'access', _71 => _71.at, 'call', _72 => _72(-1), 'optionalAccess', _73 => _73.id])===e),isFirstInGroup:_store.createSelector.call(void 0, (n,e)=>{if(n.virtualized)return!1;let t=n.orderedRows.find(s=>s.id===e);return _optionalChain([t, 'optionalAccess', _74 => _74.groupId])?_optionalChain([n, 'access', _75 => _75.orderedRows, 'access', _76 => _76.filter, 'call', _77 => _77(s=>s.groupId===t.groupId), 'access', _78 => _78[0], 'optionalAccess', _79 => _79.id])===e:!1}),isLastInGroup:_store.createSelector.call(void 0, (n,e)=>{if(n.virtualized)return!1;let t=n.orderedRows.find(s=>s.id===e);return _optionalChain([t, 'optionalAccess', _80 => _80.groupId])?_optionalChain([n, 'access', _81 => _81.orderedRows, 'access', _82 => _82.filter, 'call', _83 => _83(s=>s.groupId===t.groupId), 'access', _84 => _84.at, 'call', _85 => _85(-1), 'optionalAccess', _86 => _86.id])===e:!1}),getItemScore:_store.createSelector.call(void 0, (n,e)=>n.normalizedSearch.length===0?1:_nullishCoalesce(n.filteredItems.get(e), () => (0))),hasSearchWithNoResults:_store.createSelector.call(void 0, n=>n.normalizedSearch.length===0?!1:n.virtualized&&n.virtualItemsCount>=0?n.virtualItemsCount===0:n.filteredCount===0)};function Ee(n,e){return n.element===null||e.element===null||!n.element.isConnected||!e.element.isConnected?n.index-e.index:n.element.compareDocumentPosition(e.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var Pt=n=>P(n),re= exports.y = (_class =class n extends _store.ReactStore{constructor(e,t){let s={...{filter:V,normalizeSearch:Pt,loop:!0,autoHighlightFirst:!0,clearSearchOnClose:!0,resetScrollOnSearch:!0,hideUntilActive:!1,listId:"",inputId:"",items:new Map,groups:new Map,itemSelects:new Map,submenuOpens:new Map,submenuCloses:new Map,shortcuts:new Map,rowElements:new Map,onOpenChange:()=>{},onSearchChange:void 0,virtualItems:[],orderedItems:[],onHighlightChange:void 0,refs:{listRef:{current:null},listScrollContainerRef:{current:null},popupRef:{current:null},itemRefs:new Map,groupRefs:new Map},onCloseComplete:void 0,onPopupCloseComplete:void 0,lastPointerPosition:null},...t},o={...kt(),...e};o.normalizedSearch=s.normalizeSearch(o.search),super(o,s,Lt);_class.prototype.__init.call(this);,this.observe("open",(a,l)=>{if(a!==l)if(a)this.resetPointerPosition(),this.context.autoHighlightFirst===!0&&this.highlightFirstItem();else{this.context.clearSearchOnClose===!0&&this.setSearch("");let d=this.context.clearSearchOnClose==="after-exit";this.update({inputActive:d?this.state.inputActive:!1,pendingSearch:""})}}),this.observe("search",(a,l)=>{a!==l&&this.syncNormalizedSearch()}),this.observe(a=>a.searchProp,(a,l)=>{a!==l&&this.syncNormalizedSearch()}),this.observe("normalizedSearch",(a,l)=>{a!==l&&(this.resetPointerPosition(),this.recomputeFilteredItems(l),this.context.resetScrollOnSearch&&!this.state.virtualized&&this.scrollListToTop())})}setOpen(e,t=L.none,r){let s=me(t,r);this.context.onOpenChange(e,s),!s.isCanceled&&(e&&this.set("openMethod",Ie(r)),this.set("open",e))}setSearch(e){let t=_nullishCoalesce(this.state.searchProp, () => (e));this.update({search:e,normalizedSearch:this.context.normalizeSearch(t)}),_optionalChain([this, 'access', _87 => _87.context, 'access', _88 => _88.onSearchChange, 'optionalCall', _89 => _89(e)])}setSearchNormalizer(e){this.context.normalizeSearch=e;let t=_nullishCoalesce(this.state.searchProp, () => (this.state.search)),r=e(t);r!==this.state.normalizedSearch&&this.set("normalizedSearch",r)}syncNormalizedSearch(){let e=_nullishCoalesce(this.state.searchProp, () => (this.state.search)),t=this.context.normalizeSearch(e);t!==this.state.normalizedSearch&&this.set("normalizedSearch",t)}__init() {this.defaultSearchInitialized=!1}initializeDefaultSearch(e){this.defaultSearchInitialized||(this.defaultSearchInitialized=!0,this.state.searchProp===void 0&&e!==this.state.search&&this.setSearch(e))}setHighlightedId(e,t="pointer"){this.state.highlightedId!==e&&(this.closeSiblingSubmenus(e),this.update({highlightedId:e,highlightSource:t}),this.notifyHighlightChange(e,t),t==="keyboard"&&e!==null&&this.scrollItemIntoView(e))}notifyHighlightChange(e,t){let{onHighlightChange:r}=this.context;if(!r)return;let s=t==="keyboard"?L.keyboard:t==="pointer"?L.pointer:L.auto,o=e===null?-1:this.state.virtualized?this.getVirtualItemIndex(e):this.getVisibleItemIndex(e),a=xe(s,void 0,{index:o});r(e,o,a)}scrollItemIntoView(e){let{refs:t}=this.context,r=t.listRef.current,o=_optionalChain([t, 'access', _90 => _90.itemRefs, 'access', _91 => _91.get, 'call', _92 => _92(e), 'optionalAccess', _93 => _93.current]);if(o&&r)try{r.contains(o)&&(o.scrollIntoView({block:"nearest"}),this.maybeRevealGroupTop(e,r))}catch (e2){}}maybeRevealGroupTop(e,t){let r=_optionalChain([this, 'access', _94 => _94.context, 'access', _95 => _95.items, 'access', _96 => _96.get, 'call', _97 => _97(e), 'optionalAccess', _98 => _98.groupId]);if(!r||this.getVisibleItemIds().find(c=>_optionalChain([this, 'access', _99 => _99.context, 'access', _100 => _100.items, 'access', _101 => _101.get, 'call', _102 => _102(c), 'optionalAccess', _103 => _103.groupId])===r)!==e)return;let a=_optionalChain([this, 'access', _104 => _104.context, 'access', _105 => _105.refs, 'access', _106 => _106.groupRefs, 'access', _107 => _107.get, 'call', _108 => _108(r), 'optionalAccess', _109 => _109.current]);if(!a||!t.contains(a))return;let l=_nullishCoalesce(this.context.refs.listScrollContainerRef.current, () => (this.getScrollResetElement(t))),d=l.getBoundingClientRect().top-a.getBoundingClientRect().top;d>0&&(l.scrollTop-=d)}scrollListToTop(){let e=this.context.refs.listRef.current,t=_nullishCoalesce(this.context.refs.listScrollContainerRef.current, () => ((e?this.getScrollResetElement(e):null)));if(t){if(typeof t.scrollTo=="function"){t.scrollTo({top:0});return}t.scrollTop=0}}getScrollResetElement(e){let t=e;for(;t;){if(this.isScrollableElement(t))return t;t=t.parentElement}return e}isScrollableElement(e){let r=_optionalChain([e, 'access', _110 => _110.ownerDocument, 'optionalAccess', _111 => _111.defaultView, 'optionalAccess', _112 => _112.getComputedStyle, 'call', _113 => _113(e), 'access', _114 => _114.overflowY]),s=r==="auto"||r==="scroll"||r==="overlay";return e.scrollTop>0||s&&e.scrollHeight>e.clientHeight}setHasInput(e){this.set("hasInput",e)}setInputActive(e){this.set("inputActive",e)}setPendingSearch(e){this.set("pendingSearch",e)}setHideUntilActive(e){this.context.hideUntilActive=e,e&&this.state.normalizedSearch.length>0&&this.setInputActive(!0)}setVirtualized(e){this.set("virtualized",e)}setVirtualItems(e){let t=this.context.virtualItems;if(this.context.virtualItems=e,this.set("virtualItemsCount",e.length),this.preRegisterVirtualItems(),e===t)return;if(t.length===e.length){let a=!0;for(let l=0;l<t.length;l++){let d=t[l],c=e[l];if(!d||!c||d.value!==c.value||d.disabled!==c.disabled){a=!1;break}}if(a)return}if(!this.state.virtualized||!this.state.open||e.length===0)return;let r=t.find(a=>!a.disabled),s=e.find(a=>!a.disabled),o=r!==void 0&&_optionalChain([s, 'optionalAccess', _115 => _115.value])!==r.value;this.validateHighlight({forceFirst:o})}setOrderedItems(e,t){let r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _116 => _116.reason]), () => ("replace")),s=this.context.orderedItems;if(this.context.orderedItems=e,e!==s&&this.state.open){if(r==="append"&&this.state.highlightedId!==null){let o=this.state.highlightedId,a=this.context.items.get(o),l=e.includes(o),d=a?!a.disabled:!1;if(l&&d)return}if(e.length>0){let o=e.find(a=>this.context.items.has(a));o!==void 0?this.setHighlightedId(o,"auto"):this.setHighlightedId(null)}else this.setHighlightedId(null)}}maybeAutoHighlightOnRegister(e){if(this.context.filter!==!1||!this.state.open||this.state.highlightedId!==null||!this.context.autoHighlightFirst)return;let t=this.context.orderedItems;if(t.length===0)return;t.find(s=>this.context.items.has(s))===e&&this.setHighlightedId(e,"auto")}setOnHighlightChange(e){this.context.onHighlightChange=e}setListRef(e){this.context.refs.listRef=e}setListScrollContainerRef(e){this.context.refs.listScrollContainerRef=e}setPopupRef(e){this.context.refs.popupRef=e}registerItemRef(e,t){return this.context.refs.itemRefs.set(e,t),()=>{this.context.refs.itemRefs.delete(e)}}shouldAllowPointerHighlight(e,t){let r=this.context.lastPointerPosition;if(r===null)return this.context.lastPointerPosition={x:e,y:t},!0;let s=Math.abs(e-r.x),o=Math.abs(t-r.y);return s>1||o>1?(this.context.lastPointerPosition={x:e,y:t},!0):!1}resetPointerPosition(){this.context.lastPointerPosition=null}preRegisterVirtualItems(){let e=this.context.virtualItems;if(e.length!==0){for(let t of e)this.context.items.has(t.value)||this.context.items.set(t.value,{value:t.value,keywords:t.keywords,disabled:t.disabled});this.recomputeFilteredItems()}}registerItem(e,t){let r=this.context.items.get(e);if(r&&r.value===t.value&&r.disabled===t.disabled&&r.forceOrder===t.forceOrder&&r.forceScore===t.forceScore&&r.groupId===t.groupId&&r.shortcut===t.shortcut&&r.activatable===t.activatable)return()=>{this.context.items.get(e)===r&&(this.context.items.delete(e),this.context.itemSelects.delete(e),t.groupId&&_optionalChain([this, 'access', _117 => _117.context, 'access', _118 => _118.groups, 'access', _119 => _119.get, 'call', _120 => _120(t.groupId), 'optionalAccess', _121 => _121.delete, 'call', _122 => _122(e)]),t.shortcut&&this.context.shortcuts.delete(t.shortcut.toLowerCase()),this.recomputeFilteredItems())};if(this.context.items.set(e,t),t.groupId){let o=this.context.groups.get(t.groupId);o&&o.add(e)}if(t.shortcut){let o=t.shortcut.toLowerCase();this.context.shortcuts.set(o,e)}return this.recomputeFilteredItems(),this.maybeAutoHighlightOnRegister(e),()=>{if(this.context.items.delete(e),this.context.itemSelects.delete(e),t.groupId){let o=this.context.groups.get(t.groupId);o&&o.delete(e)}if(t.shortcut){let o=t.shortcut.toLowerCase();this.context.shortcuts.delete(o)}this.recomputeFilteredItems()}}registerGroup(e,t){return this.context.groups.set(e,new Set),t&&this.context.refs.groupRefs.set(e,t),()=>{this.context.groups.delete(e),this.context.refs.groupRefs.delete(e)}}registerRow(e,t,r){this.context.rowElements.set(e,t);let o=[...this.state.orderedRows.filter(a=>a.id!==e),{id:e,kind:r.kind,groupId:r.groupId}];return o.sort((a,l)=>this.compareRowOrder(a,l)),this.set("orderedRows",o),()=>{this.context.rowElements.get(e)===t&&(this.context.rowElements.delete(e),this.set("orderedRows",this.state.orderedRows.filter(a=>a.id!==e)))}}compareRowOrder(e,t){let r=this.context.rowElements.get(e.id),s=this.context.rowElements.get(t.id);if(!r||!s||!r.isConnected||!s.isConnected)return 0;let o=r.compareDocumentPosition(s);return o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0}registerItemSelect(e,t){return t&&this.context.itemSelects.set(e,t),()=>{this.context.itemSelects.delete(e)}}registerSubmenuOpen(e,t){return t&&this.context.submenuOpens.set(e,t),()=>{this.context.submenuOpens.delete(e)}}registerSubmenuClose(e,t){return t&&this.context.submenuCloses.set(e,t),()=>{this.context.submenuCloses.delete(e)}}closeSiblingSubmenus(e){for(let[t,r]of this.context.submenuCloses)if(t!==e)try{r()}catch (e3){}}highlightNext(){let e=this.getVisibleItemIds();if(e.length===0)return;let r=(this.state.highlightedId?e.indexOf(this.state.highlightedId):-1)+1;r>=e.length&&(r=this.context.loop?0:e.length-1);let s=e[r];s&&this.setHighlightedId(s,"keyboard")}highlightPrev(){let e=this.getVisibleItemIds();if(e.length===0)return;let r=(this.state.highlightedId?e.indexOf(this.state.highlightedId):e.length)-1;r<0&&(r=this.context.loop?e.length-1:0);let s=e[r];s&&this.setHighlightedId(s,"keyboard")}selectHighlighted(){if(this.state.highlightedId){if(_optionalChain([this, 'access', _123 => _123.context, 'access', _124 => _124.items, 'access', _125 => _125.get, 'call', _126 => _126(this.state.highlightedId), 'optionalAccess', _127 => _127.activatable])===!1)return;_optionalChain([this, 'access', _128 => _128.context, 'access', _129 => _129.itemSelects, 'access', _130 => _130.get, 'call', _131 => _131(this.state.highlightedId), 'optionalCall', _132 => _132()])}}selectByShortcut(e){let t=this.context.shortcuts.get(e.toLowerCase());if(!t)return!1;let r=this.context.items.get(t);if(!r||r.disabled)return!1;let s=_nullishCoalesce(this.state.filteredItems.get(t), () => (0));return this.state.normalizedSearch.length===0||s>0?(_optionalChain([this, 'access', _133 => _133.context, 'access', _134 => _134.itemSelects, 'access', _135 => _135.get, 'call', _136 => _136(t), 'optionalCall', _137 => _137()]),!0):!1}openSubmenuForHighlighted(){this.state.highlightedId&&_optionalChain([this, 'access', _138 => _138.context, 'access', _139 => _139.submenuOpens, 'access', _140 => _140.get, 'call', _141 => _141(this.state.highlightedId), 'optionalCall', _142 => _142()])}isHighlightedSubmenuTrigger(){return this.state.highlightedId?_nullishCoalesce(_optionalChain([this, 'access', _143 => _143.context, 'access', _144 => _144.items, 'access', _145 => _145.get, 'call', _146 => _146(this.state.highlightedId), 'optionalAccess', _147 => _147.isSubmenuTrigger]), () => (!1)):!1}getHighlightedItem(){if(this.state.highlightedId)return this.context.items.get(this.state.highlightedId)}clearSearch(){this.setSearch("")}clearHighlight(){this.update({highlightedId:null,highlightSource:null})}highlightFirstItem(){let e=this.getVisibleItemIds();e.length>0&&e[0]?this.update({highlightedId:e[0],highlightSource:null}):this.update({highlightedId:null,highlightSource:null})}applyAutoHighlight(){if(!this.state.open)return;let e=this.context.autoHighlightFirst;e===!0?this.highlightFirstItem():typeof e=="string"&&this.highlightItemByValue(e)}highlightItemByValue(e){let t=this.getVisibleItemIds(),r=null;t.includes(e)?r=e:t.length>0&&t[0]&&(r=t[0]),this.update({highlightedId:r,highlightSource:null}),r&&requestAnimationFrame(()=>{this.scrollItemIntoView(r)})}isFilterDisabled(){return this.context.filter===!1}getVisibleItemIds(){let e=[],t=this.state.normalizedSearch,r=this.state.filteredItems,s=this.context.virtualItems,o=this.context.orderedItems;if(this.state.virtualized&&s.length>0){for(let d of s){let c=_nullishCoalesce(r.get(d.value), () => (0));(t.length===0||c>0)&&!d.disabled&&e.push(d.value)}return e}if(this.context.filter===!1&&o.length>0){let d=[];for(let c of o){let h=this.context.items.get(c);h&&!h.disabled?e.push(c):h||d.push(c)}if(process.env.NODE_ENV!=="production"&&d.length>0&&e.length>0)for(let c of d)console.warn(`[ListboxStore] Item "${c}" is in orderedItems but not registered. This may cause keyboard navigation to skip this item. Make sure the render function passes the \`id\` prop: <Item {...props}>...</Item>`);return e}let a=[],l=0;this.context.items.forEach((d,c)=>{let h=l++,g=_nullishCoalesce(r.get(c), () => (0));(t.length===0||g>0)&&!d.disabled&&a.push({id:c,element:_nullishCoalesce(_optionalChain([this, 'access', _148 => _148.context, 'access', _149 => _149.refs, 'access', _150 => _150.itemRefs, 'access', _151 => _151.get, 'call', _152 => _152(c), 'optionalAccess', _153 => _153.current]), () => (null)),index:h})}),a.sort(Ee);for(let{id:d}of a)e.push(d);return e}getVisibleItemIndex(e){return this.getVisibleItemIds().indexOf(e)}getVirtualItemIndex(e){return this.state.virtualized?this.context.virtualItems.findIndex(t=>t.value===e):-1}validateHighlight(e={}){let{forceFirst:t=!1,filteredItems:r=this.state.filteredItems,newSearch:s,prevSearch:o}=e,a=o!==void 0?o:this.state.normalizedSearch,l=s!==void 0?s:a,d=s!==void 0&&s!==a;if(!this.state.open||!this.context.autoHighlightFirst)return this.state.highlightedId;let c=this.state.highlightedId,{filter:h}=this.context,g=t||d,v=!1;if(c&&!g){let m=_nullishCoalesce(r.get(c), () => (0)),E=l.length===0||h===!1||m>0,i=this.context.items.get(c),u=this.context.virtualItems.find(O=>O.value===c),x=_nullishCoalesce(_nullishCoalesce(_optionalChain([i, 'optionalAccess', _154 => _154.disabled]), () => (_optionalChain([u, 'optionalAccess', _155 => _155.disabled]))), () => (!1)),f=this.state.virtualized||i!==void 0,I=!this.state.virtualized||this.context.virtualItems.length===0||u!==void 0;v=E&&!x&&f&&I}if(v)return c;let R=null;if(this.state.virtualized&&this.context.virtualItems.length>0)for(let m of this.context.virtualItems){let E=_nullishCoalesce(r.get(m.value), () => (0));if((l.length===0||h===!1||E>0)&&!m.disabled){R=m.value;break}}else if(h===!1&&this.context.orderedItems.length>0)for(let m of this.context.orderedItems){let E=this.context.items.get(m);if(E&&!E.disabled){R=m;break}}else{let m=null,E=0;for(let[i,u]of this.context.items){let x=E++,f=_nullishCoalesce(r.get(i), () => (0));if((l.length===0||f>0)&&!u.disabled){let O={id:i,element:_nullishCoalesce(_optionalChain([this, 'access', _156 => _156.context, 'access', _157 => _157.refs, 'access', _158 => _158.itemRefs, 'access', _159 => _159.get, 'call', _160 => _160(i), 'optionalAccess', _161 => _161.current]), () => (null)),index:x};(m===null||Ee(O,m)<0)&&(m=O)}}R=_nullishCoalesce(_optionalChain([m, 'optionalAccess', _162 => _162.id]), () => (null))}return R!==c&&this.update({highlightedId:R,highlightSource:null}),R}recomputeFilteredItems(e){let{filter:t}=this.context,r=this.state.normalizedSearch,s=this.context.items,o=this.context.groups,a=new Map,l=new Set,d=0;if(!r||t===!1){if(this.state.virtualized&&this.context.virtualItems.length>0)for(let h of this.context.virtualItems)a.set(h.value,1),d++;else s.forEach((h,g)=>{a.set(g,1),d++});o.forEach((h,g)=>{l.add(g)})}else{let h=t||V;s.forEach((g,v)=>{let R=h(g.value,r,g.keywords),m=_nullishCoalesce(g.forceScore, () => (R));a.set(v,m),m>0&&(d++,g.groupId&&l.add(g.groupId))})}if(t===!1){this.update({filteredItems:a,visibleGroups:l,filteredCount:d,filterTrigger:this.state.filterTrigger+1});return}let c=this.validateHighlight({filteredItems:a,newSearch:r,prevSearch:e});this.update({filteredItems:a,visibleGroups:l,filteredCount:d,filterTrigger:this.state.filterTrigger+1,highlightedId:c,highlightSource:null})}static useStore(e,t,r){return _useRefWithInit.useRefWithInit.call(void 0, ()=>_nullishCoalesce(e, () => (new n(t,r)))).current}}, _class);function kt(){return{open:!1,openProp:void 0,openMethod:null,search:"",searchProp:void 0,normalizedSearch:"",highlightedId:null,highlightSource:null,hasInput:!1,inputActive:!1,pendingSearch:"",filteredItems:new Map,visibleGroups:new Set,filteredCount:0,filterTrigger:0,virtualized:!1,virtualItemsCount:0,orderedRows:[]}}exports.a = L; exports.b = me; exports.c = Zt; exports.d = he; exports.e = B; exports.f = q; exports.g = ze; exports.h = Ne; exports.i = $; exports.j = Y; exports.k = Fe; exports.l = W; exports.m = Ge; exports.n = X; exports.o = J; exports.p = Q; exports.q = We; exports.r = P; exports.s = Ke; exports.t = _e; exports.u = Ue; exports.v = $e; exports.w = V; exports.x = wt; exports.y = re;
|
|
2
|
-
//# sourceMappingURL=chunk-XMZZ62VJ.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/chunk-XMZZ62VJ.cjs","../src/internal/listbox/contexts/group-context.ts","../src/internal/listbox/contexts/item-context.ts","../src/internal/listbox/contexts/listbox-context.ts","../src/internal/listbox/contexts/row-width-context.ts","../src/internal/listbox/contexts/surface-context.ts","../src/internal/listbox/hooks/use-listbox-item.ts","../src/internal/listbox/utils/normalize.ts"],"names":["GroupContext","useGroupContext","ItemContext","useItemContext","context","useMaybeItemContext","ListboxContext","useListboxContext","useMaybeListboxContext","RowWidthContext","useRowWidthContext","useMaybeRowWidthContext","SurfaceContext","useSurfaceContext","useMaybeSurfaceContext","normalizeValue","value","deburr","slugify","useListboxItem","params","idProp","valueProp","keywords","disabled","activatable","forceMount","shortcut","forceOrder","forceScore","isSubmenuTrigger","onSelect","closeOnClick","onAfterSelect","children","aimGuard","store","groupContext","depth","ref","rowId","rowElement","setRowElement","inferredValue","setInferredValue","textContent","registrationId","generatedDomId","domId"],"mappings":"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","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-XMZZ62VJ.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Group Context (for items to know their parent group)\n// ============================================================================\n\nexport interface GroupPositional {\n first?: boolean\n last?: boolean\n firstInGroup?: boolean\n lastInGroup?: boolean\n firstGroup?: boolean\n lastGroup?: boolean\n}\n\nexport interface GroupContextValue {\n groupId?: string\n positional?: GroupPositional\n}\n\nconst GroupContext = React.createContext<GroupContextValue | null>(null)\n\nexport function useGroupContext(): GroupContextValue | null {\n return React.useContext(GroupContext)\n}\n\nexport { GroupContext }\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Item Context (for child components like indicators to access item state)\n// ============================================================================\n\nexport interface ItemContextValue {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Keyboard shortcut for this item */\n shortcut?: string\n}\n\nconst ItemContext = React.createContext<ItemContextValue | null>(null)\n\nexport function useItemContext(): ItemContextValue {\n const context = React.useContext(ItemContext)\n if (!context) {\n throw new Error('Item child components must be used within an Item')\n }\n return context\n}\n\nexport function useMaybeItemContext(): ItemContextValue | null {\n return React.useContext(ItemContext)\n}\n\nexport { ItemContext }\n","'use client'\n\nimport * as React from 'react'\nimport type { HighlightChangeEventDetails } from '../../popup-menu/events.js'\nimport type { ListboxStore, VirtualItem } from '../store/ListboxStore.js'\n\n/**\n * Virtualization configuration passed from Root/Submenu to Surface.\n */\nexport interface VirtualizationConfig {\n /** Whether virtualization mode is enabled */\n virtualized: boolean\n /** Pre-registered items for virtualization */\n items: VirtualItem[]\n /**\n * Callback when highlighted item changes (for scroll sync).\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => void\n}\n\nexport interface ListboxContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Nesting depth: 0 = root menu, 1+ = submenu */\n depth: number\n /** Close the entire menu tree (deepest submenu to root, sequentially) */\n closeAll: () => void\n /** Register a surface (submenu) for closeAll tracking. Returns unregister function. */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Virtualization configuration (if enabled) */\n virtualization?: VirtualizationConfig\n}\n\nconst ListboxContext = React.createContext<ListboxContextValue | null>(null)\n\nexport function useListboxContext(): ListboxContextValue {\n const context = React.useContext(ListboxContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Listbox provider')\n }\n return context\n}\n\nexport function useMaybeListboxContext(): ListboxContextValue | null {\n return React.useContext(ListboxContext)\n}\n\nexport { ListboxContext }\n","'use client'\n\nimport * as React from 'react'\n\n/**\n * Context value for row width measurement.\n * Provided by List when `measureRowWidth` is enabled.\n */\nexport interface RowWidthContextValue {\n /**\n * Queue a row element for width measurement.\n * Call this when a row mounts or becomes visible.\n *\n * @param element - The DOM element to measure\n * @param id - Unique identifier for this row (used to avoid re-measuring)\n */\n queueMeasurement: (element: HTMLElement, id: string) => void\n}\n\n/**\n * Context for row width measurement.\n * Items use this to self-register for measurement.\n */\nexport const RowWidthContext = React.createContext<RowWidthContextValue | null>(\n null,\n)\n\nif (process.env.NODE_ENV !== 'production') {\n RowWidthContext.displayName = 'RowWidthContext'\n}\n\n/**\n * Hook to get the row width context.\n * Throws an error if used outside of a List with `measureRowWidth` enabled.\n */\nexport function useRowWidthContext(): RowWidthContextValue {\n const context = React.useContext(RowWidthContext)\n if (!context) {\n throw new Error(\n 'useRowWidthContext must be used within a List with measureRowWidth enabled',\n )\n }\n return context\n}\n\n/**\n * Hook to optionally get the row width context.\n * Returns null if not within a List with `measureRowWidth` enabled.\n * This is the preferred hook for items that should work both with and without measurement.\n */\nexport function useMaybeRowWidthContext(): RowWidthContextValue | null {\n return React.useContext(RowWidthContext)\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ListboxStore } from '../store/ListboxStore.js'\n\n// Re-export types from the store for convenience\nexport type {\n FilterFn,\n ItemRegistration,\n} from '../store/ListboxStore.js'\n\n// ============================================================================\n// Surface Context\n// ============================================================================\n\nexport interface SurfaceContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Unique identifier for this surface */\n surfaceId: string\n}\n\nconst SurfaceContext = React.createContext<SurfaceContextValue | null>(null)\n\nexport function useSurfaceContext(): SurfaceContextValue {\n const context = React.useContext(SurfaceContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Surface provider')\n }\n return context\n}\n\nexport function useMaybeSurfaceContext(): SurfaceContextValue | null {\n return React.useContext(SurfaceContext)\n}\n\nexport { SurfaceContext }\n","'use client'\n\nimport * as React from 'react'\nimport { useGroupContext } from '../contexts/group-context.js'\nimport type { ItemContextValue } from '../contexts/item-context.js'\nimport { useListboxContext } from '../contexts/listbox-context.js'\nimport { useMaybeRowWidthContext } from '../contexts/row-width-context.js'\nimport { useSurfaceContext } from '../contexts/surface-context.js'\nimport { normalizeValue } from '../utils/normalize.js'\n\n/**\n * Aim guard refs for submenu navigation.\n * Optional - only needed for popup menus with submenus.\n */\nexport interface AimGuardRefs {\n /** Whether aim guard is currently active */\n aimGuardActiveRef: React.RefObject<boolean>\n /** The depth at which aim guard is active (null when not guarding) */\n guardedDepthRef: React.RefObject<number | null>\n}\n\n/**\n * Parameters for the useListboxItem hook.\n */\nexport interface UseListboxItemParams {\n /**\n * Explicit unique identifier for this item in the store.\n * Takes highest priority for item registration.\n * Used by data-first APIs to ensure consistent IDs.\n */\n id?: string\n\n /**\n * Unique value for this item used as identifier and for filtering.\n * If not provided, will be inferred from textContent.\n * Used for registration when `id` is not provided.\n */\n value?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Whether this item can be activated via Enter or click.\n * Non-activatable items remain highlightable.\n * @default true\n */\n activatable?: boolean\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n\n /**\n * Keyboard shortcut to trigger this item.\n * When the menu is focused and the user presses this key, the item will be selected.\n * Should be a single character (e.g., \"1\", \"a\", etc.).\n */\n shortcut?: string\n\n /**\n * Forces this row's relative order during score-based sorting.\n * Lower values appear earlier.\n * @default 0\n */\n forceOrder?: number\n\n /**\n * Overrides this row's computed fuzzy-match score.\n * Useful for pinning or manually ranking rows in score-based views.\n */\n forceScore?: number\n\n /**\n * Whether this item is a submenu trigger (for store registration).\n * @default false\n */\n isSubmenuTrigger?: boolean\n\n /**\n * Callback when this item is selected (via click or Enter key).\n * For simple items, pass this directly. For checkbox/radio items,\n * use registerSelect() to register a dynamic handler.\n */\n onSelect?: () => void\n\n /**\n * Whether selecting this item should close the menu.\n * @default true\n */\n closeOnClick?: boolean\n\n /**\n * Callback invoked after selection occurs (via click).\n * Called with the item's ID. The consumer handles any\n * post-selection behavior like closing menus.\n */\n onAfterSelect?: (itemId: string) => void\n\n /**\n * Children (used for text content inference when value is not provided).\n */\n children?: React.ReactNode\n\n /**\n * Optional aim guard refs for popup menu navigation.\n * When provided, pointer move events will respect the aim guard.\n */\n aimGuard?: AimGuardRefs\n}\n\n/**\n * Return value from the useListboxItem hook.\n */\nexport interface UseListboxItemReturn {\n /** Unique ID for this item (DOM ID for aria-activedescendant) */\n id: string\n\n /**\n * Store identifier for this item.\n * Use this when calling store methods like setHighlightedId, registerSubmenuOpen, etc.\n * This is the `value` prop (or inferred from textContent).\n */\n storeId: string\n\n /** Ref to attach to the item element */\n ref: React.RefObject<HTMLDivElement | null>\n\n /** Callback ref that tracks the mounted row element for positional attributes. Merge into the rendered element's ref. */\n rowRef: (element: HTMLElement | null) => void\n\n /** Positional state among visible rows (all false in virtualized mode). */\n positional: {\n first: boolean\n last: boolean\n firstInGroup: boolean\n lastInGroup: boolean\n }\n\n /** Whether item is currently highlighted */\n isHighlighted: boolean\n\n /** Whether item should be rendered (passes filter) */\n isVisible: boolean\n\n /** Context value to provide to children via ItemContext.Provider */\n contextValue: ItemContextValue\n\n /**\n * Event handlers to spread on the element.\n * These handle click, pointer move, and pointer down events.\n */\n handlers: {\n onClick: React.MouseEventHandler<HTMLDivElement>\n onPointerMove: React.PointerEventHandler<HTMLDivElement>\n onPointerDown: React.PointerEventHandler<HTMLDivElement>\n }\n\n /**\n * Register a custom onSelect handler.\n * This is useful for checkbox/radio items where the select behavior\n * needs to be customized (e.g., toggle checked state).\n * Returns an unregister function.\n */\n registerSelect: (handler: (() => void) | undefined) => () => void\n}\n\n/**\n * Hook that provides all shared logic for navigatable/highlightable listbox items.\n *\n * This hook handles:\n * - Item registration with the listbox store\n * - Highlight state management (keyboard and pointer)\n * - Filter/search visibility\n * - Scroll into view on keyboard navigation\n * - Click, pointer move, and pointer down event handlers\n * - Optional aim guard integration (for submenu navigation)\n *\n * @example\n * ```tsx\n * function CustomItem(props) {\n * const item = useListboxItem({\n * value: props.value,\n * disabled: props.disabled,\n * onSelect: props.onSelect,\n * })\n *\n * if (!item.isVisible) return null\n *\n * return (\n * <ItemContext.Provider value={item.contextValue}>\n * <div\n * ref={item.ref}\n * {...item.handlers}\n * data-highlighted={item.isHighlighted || undefined}\n * >\n * {props.children}\n * </div>\n * </ItemContext.Provider>\n * )\n * }\n * ```\n */\nexport function useListboxItem(\n params: UseListboxItemParams,\n): UseListboxItemReturn {\n const {\n id: idProp,\n value: valueProp,\n keywords,\n disabled = false,\n activatable = true,\n forceMount = false,\n shortcut,\n forceOrder,\n forceScore,\n isSubmenuTrigger = false,\n onSelect,\n closeOnClick = true,\n onAfterSelect,\n children,\n aimGuard,\n } = params\n\n const { store } = useSurfaceContext()\n const groupContext = useGroupContext()\n const { depth } = useListboxContext()\n\n const ref = React.useRef<HTMLDivElement>(null)\n\n // Positional row registry: stable per-instance row id + mounted element\n const rowId = React.useId()\n const [rowElement, setRowElement] = React.useState<HTMLElement | null>(null)\n\n React.useLayoutEffect(() => {\n if (!rowElement) return undefined\n return store.registerRow(rowId, rowElement, {\n kind: 'item',\n groupId: groupContext?.groupId,\n })\n }, [rowElement, rowId, groupContext?.groupId, store])\n\n // Infer value from textContent if not provided\n const [inferredValue, setInferredValue] = React.useState<string>('')\n\n // biome-ignore lint/correctness/useExhaustiveDependencies(children): children is an intentional trigger dep — re-infer the value from textContent when content changes\n React.useLayoutEffect(() => {\n if (idProp === undefined && valueProp === undefined && ref.current) {\n const textContent = ref.current.textContent?.trim() ?? ''\n setInferredValue(textContent)\n }\n }, [idProp, valueProp, children])\n\n // Registration ID priority: id prop > value prop > textContent inference\n // This ensures data-first APIs can provide explicit IDs that match their internal tracking\n // Note: valueProp is normalized (trimmed) to match cmdk's behavior\n const registrationId = idProp ?? (normalizeValue(valueProp) || inferredValue)\n\n // Generate a stable ID for DOM id attribute (aria-activedescendant, etc.)\n // When id prop is provided (data-first APIs), use it directly for DOM ID\n // This ensures aria-activedescendant works correctly with composite IDs\n const generatedDomId = React.useId()\n const domId = idProp ?? `item-${generatedDomId}`\n\n // Stabilize keywords to prevent infinite loops when passed as inline arrays\n // We use JSON.stringify to compare by value rather than reference\n // Keywords are also normalized (trimmed) to match cmdk's behavior\n const normalizedKeywords = keywords\n ?.map((k) => normalizeValue(k))\n .filter(Boolean)\n const keywordsKey = normalizedKeywords\n ? JSON.stringify(normalizedKeywords)\n : undefined\n\n // Register item with store (using registrationId as the unique identifier)\n // biome-ignore lint/correctness/useExhaustiveDependencies: keywordsKey is a stable by-value stand-in for normalizedKeywords — depending on the array itself (new identity every render) causes an infinite register/recompute loop\n React.useEffect(() => {\n if (!registrationId && !forceMount) return\n\n const unregister = store.registerItem(registrationId, {\n value: registrationId,\n keywords: normalizedKeywords,\n groupId: groupContext?.groupId,\n disabled,\n activatable,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n })\n\n return unregister\n }, [\n registrationId,\n keywordsKey,\n groupContext?.groupId,\n disabled,\n activatable,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n store,\n forceMount,\n ])\n\n // Register DOM ref with store for scroll behavior\n React.useEffect(() => {\n if (!registrationId) return\n return store.registerItemRef(registrationId, ref)\n }, [registrationId, store])\n\n // Register for row width measurement if enabled\n const rowWidthContext = useMaybeRowWidthContext()\n\n React.useLayoutEffect(() => {\n if (rowWidthContext && ref.current && registrationId) {\n rowWidthContext.queueMeasurement(ref.current, registrationId)\n }\n }, [rowWidthContext, registrationId])\n\n // Register onSelect handler if provided directly\n React.useEffect(() => {\n if (!onSelect || !registrationId) return\n return store.registerItemSelect(registrationId, onSelect)\n }, [registrationId, onSelect, store])\n\n // Use selectors to get derived state (using registrationId as identifier)\n const normalizedSearch = store.useState('normalizedSearch')\n const isHighlighted = store.useState('isHighlighted', registrationId)\n const isFirstRow = store.useState('isFirstRow', rowId)\n const isLastRow = store.useState('isLastRow', rowId)\n const isFirstInGroup = store.useState('isFirstInGroup', rowId)\n const isLastInGroup = store.useState('isLastInGroup', rowId)\n const score = store.useState('getItemScore', registrationId)\n\n // Check if filtering is disabled (consumer handles filtering externally)\n const filterDisabled = store.isFilterDisabled()\n\n // Determine visibility based on filter score\n // When filterDisabled, consumer handles filtering so all items are visible\n const hasSearch = normalizedSearch.length > 0\n const isVisible = forceMount || filterDisabled || !hasSearch || score > 0\n\n // Note: Scroll behavior is now handled by the store's setHighlightedId method.\n // It uses the registered DOM refs to call scrollIntoView when the element exists,\n // or falls back to onHighlightChange for virtualizer sync.\n\n // Event handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (activatable === false) return\n if (!registrationId) return\n\n event.preventDefault()\n\n // Call the registered onSelect handler via store\n const registeredHandler = store.context.itemSelects.get(registrationId)\n registeredHandler?.()\n\n // Notify consumer that selection occurred (for closing menus, etc.)\n onAfterSelect?.(registrationId)\n },\n [disabled, activatable, store, registrationId, onAfterSelect],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n },\n [],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (!registrationId) return\n\n // Don't highlight if aim guard is active at this depth (user is moving toward submenu)\n // Only block highlighting in the same menu where the trigger is located\n if (aimGuard) {\n const { aimGuardActiveRef, guardedDepthRef } = aimGuard\n if (aimGuardActiveRef.current && guardedDepthRef.current === depth)\n return\n }\n\n // Check if pointer has actually moved - prevents phantom highlights when\n // content shifts under a stationary pointer (e.g., search results changing)\n if (!store.shouldAllowPointerHighlight(event.clientX, event.clientY)) {\n return\n }\n\n // Highlight on hover (using registrationId as identifier)\n store.setHighlightedId(registrationId)\n },\n [disabled, aimGuard, depth, store, registrationId],\n )\n\n // Context value for child components\n const contextValue: ItemContextValue = React.useMemo(\n () => ({\n id: domId,\n highlighted: isHighlighted,\n disabled,\n shortcut,\n }),\n [domId, isHighlighted, disabled, shortcut],\n )\n\n // Register a custom select handler (for checkbox/radio items)\n const registerSelect = React.useCallback(\n (handler: (() => void) | undefined) => {\n if (!registrationId) return () => {}\n return store.registerItemSelect(registrationId, handler)\n },\n [store, registrationId],\n )\n\n const handlers = React.useMemo(\n () => ({\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n }),\n [handleClick, handlePointerMove, handlePointerDown],\n )\n\n const contextPositional = groupContext?.positional\n const positional = React.useMemo(\n () => ({\n first: contextPositional?.first ?? isFirstRow,\n last: contextPositional?.last ?? isLastRow,\n firstInGroup: contextPositional?.firstInGroup ?? isFirstInGroup,\n lastInGroup: contextPositional?.lastInGroup ?? isLastInGroup,\n }),\n [contextPositional, isFirstRow, isLastRow, isFirstInGroup, isLastInGroup],\n )\n\n return {\n id: domId,\n storeId: registrationId,\n ref,\n rowRef: setRowElement,\n positional,\n isHighlighted,\n isVisible,\n contextValue,\n handlers,\n registerSelect,\n }\n}\n","/**\n * Normalizes a value string for use in filtering and identification.\n * Trims leading/trailing whitespace to match cmdk's behavior.\n *\n * @param value - The value to normalize\n * @returns The trimmed value, or empty string if value is nullish\n */\nexport function normalizeValue(value: string | undefined | null): string {\n return value?.trim() ?? ''\n}\n\n/**\n * Remove diacritics/accents from a string so unaccented queries match accented\n * content (e.g. \"cafe\" matches \"café\", \"municao\" matches \"munição\").\n *\n * Uses Unicode NFD decomposition and strips combining marks. Characters that\n * do not decompose into a base letter plus a combining mark (e.g. \"ø\", \"ł\")\n * are intentionally left unchanged.\n *\n * @param value - The value to fold\n * @returns The value with combining diacritical marks removed\n */\nexport function deburr(value: string): string {\n return value.normalize('NFD').replace(/\\p{Diacritic}/gu, '')\n}\n\n/**\n * Converts a value string to a URL-safe slug for use in IDs.\n * - Trims whitespace\n * - Converts to lowercase\n * - Replaces spaces with hyphens\n * - Removes non-alphanumeric characters (except hyphens)\n * - Collapses multiple hyphens into one\n * - Removes leading/trailing hyphens\n *\n * @example\n * slugify(\"User Settings\") // \"user-settings\"\n * slugify(\" Hello World! \") // \"hello-world\"\n * slugify(\"Café & Co.\") // \"caf-co\"\n *\n * @param value - The value to slugify\n * @returns The slugified value, or empty string if value is nullish\n */\nexport function slugify(value: string | undefined | null): string {\n if (!value) return ''\n\n return (\n value\n .trim()\n .toLowerCase()\n // Replace spaces with hyphens\n .replace(/\\s+/g, '-')\n // Remove non-alphanumeric characters (except hyphens)\n .replace(/[^a-z0-9-]/g, '')\n // Collapse multiple hyphens into one\n .replace(/-+/g, '-')\n // Remove leading/trailing hyphens\n .replace(/^-|-$/g, '')\n )\n}\n"]}
|