@academix-admin/selection-viewer 0.5.4 → 0.5.6

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/index.cjs CHANGED
@@ -271,58 +271,6 @@ var useModalKeys = (isOpen, onClose, containerId) => {
271
271
  return () => document.removeEventListener("keydown", onKeyDown);
272
272
  }, [isOpen, onClose, containerId]);
273
273
  };
274
- function focusWithNativeScroll(input) {
275
- if (typeof document === "undefined") return;
276
- if (document.activeElement === input) {
277
- const bounce = document.createElement("input");
278
- bounce.setAttribute("aria-hidden", "true");
279
- bounce.tabIndex = -1;
280
- bounce.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;font-size:16px;border:0;padding:0;pointer-events:none;";
281
- document.body.appendChild(bounce);
282
- bounce.focus({ preventScroll: true });
283
- input.focus();
284
- bounce.remove();
285
- return;
286
- }
287
- input.focus();
288
- }
289
- function focusWhenMounted(getInput) {
290
- if (typeof document === "undefined") return () => {
291
- };
292
- const now = getInput();
293
- if (now) {
294
- now.focus({ preventScroll: true });
295
- return () => {
296
- };
297
- }
298
- const proxy = document.createElement("input");
299
- proxy.setAttribute("aria-hidden", "true");
300
- proxy.tabIndex = -1;
301
- proxy.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;font-size:16px;border:0;padding:0;pointer-events:none;";
302
- document.body.appendChild(proxy);
303
- proxy.focus({ preventScroll: true });
304
- let stopped = false;
305
- const started = Date.now();
306
- const hand = () => {
307
- if (stopped) return;
308
- const input = getInput();
309
- if (input) {
310
- input.focus();
311
- proxy.remove();
312
- return;
313
- }
314
- if (Date.now() - started > 1500) {
315
- proxy.remove();
316
- return;
317
- }
318
- requestAnimationFrame(hand);
319
- };
320
- requestAnimationFrame(hand);
321
- return () => {
322
- stopped = true;
323
- proxy.remove();
324
- };
325
- }
326
274
  var SelectionViewer = ({
327
275
  id: providedId,
328
276
  isOpen,
@@ -408,19 +356,24 @@ var SelectionViewer = ({
408
356
  return;
409
357
  }
410
358
  }, [isOpen, searchProp?.autoFocus]);
411
- React.useLayoutEffect(() => {
412
- if (!isOpen) return;
413
- leftSearch.current = false;
414
- if (!searchProp?.autoFocus) return;
415
- setShouldAutoFocus(true);
416
- return focusWhenMounted(() => searchInputRef.current);
417
- }, [isOpen]);
359
+ const focusedOnOpen = React.useRef(false);
418
360
  const handleOpenEnd = React.useCallback(() => {
419
- if (!searchProp?.autoFocus || !searchInputRef.current) return;
361
+ if (!searchProp?.autoFocus || !searchInputRef.current || focusedOnOpen.current) return;
362
+ focusedOnOpen.current = true;
420
363
  if (leftSearch.current) return;
421
364
  setShouldAutoFocus(true);
422
- focusWithNativeScroll(searchInputRef.current);
365
+ searchInputRef.current.focus();
423
366
  }, [searchProp?.autoFocus]);
367
+ React.useEffect(() => {
368
+ if (!isOpen) {
369
+ focusedOnOpen.current = false;
370
+ return;
371
+ }
372
+ leftSearch.current = false;
373
+ if (!searchProp?.autoFocus) return;
374
+ const late = setTimeout(handleOpenEnd, 1200);
375
+ return () => clearTimeout(late);
376
+ }, [isOpen]);
424
377
  const handleSearchChange = (e) => {
425
378
  const value = e.target.value;
426
379
  setSearchValue(value);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/SelectionViewer.tsx","../src/Row.tsx","../src/Column.tsx"],"names":["React","useEffect","useOverlayRoute","useState","useRef","useCallback","useMemo","useLayoutEffect","jsx","jsxs","Sheet","Fragment"],"mappings":";;;;;;;;;;;;;;AAcA,IAAM,mBAAA,GAAsBA,sBAAA,CAAM,aAAA,CAAwC,IAAI;AAI9E,IAAM,+BAAA,GAAkCA,sBAAA,CAAM,aAAA,CAAwC,IAAI;AAE1F,SAAS,sBAAsB,MAAA,EAA0C;AACvE,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,SAAA;AAChC,EAAA,IAAI,OAAO,IAAA,CAAK,CAAC,MAAM,CAAA,KAAM,MAAM,GAAG,OAAO,MAAA;AAC7C,EAAA,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AAA,GAAK,yBAAA;AAAA,MAChE,KAAA,EAAO,EAAE,OAAA,EAAS,MAAA,EAAQ,eAAe,QAAA,EAAU,GAAA,EAAK,KAAA,EAAO,GAAG,KAAA,EAAM;AAAA,MAEvE;AAAA;AAAA,GACH,EACF,CAAA;AAEJ;AAEA,MAAA,CAAO,WAAA,GAAc,QAAA","file":"index.cjs","sourcesContent":["import React, { useState, useEffect, useCallback, useRef, useMemo, useLayoutEffect } from \"react\";\nimport { Sheet } from \"@academix-admin/modal-sheet\";\nimport { useOverlayRoute } from '@academix-admin/overlay-route';\n\n// ==================== Aggregation (Row/Column) ====================\n// Independent from @academix-admin/search-viewer's equivalent (Library Charter: packages stay\n// mutually independent) — same shape, duplicated intentionally rather than shared.\n\ntype AggregateReporter = {\n report: (id: string, state: SelectionState) => void;\n unreport: (id: string) => void;\n};\n\n/** A `Row` reports its own `state` into the nearest `Column` through this. */\nconst RowAggregateContext = React.createContext<AggregateReporter | null>(null);\n\n/** `Column` reports its own aggregated state up through this — `SelectionViewer` provides it and\n * merges whatever's reported into its own selectionState resolution, with zero extra wiring. */\nconst SelectionViewerAggregateContext = React.createContext<AggregateReporter | null>(null);\n\nfunction computeAggregateState(states: SelectionState[]): SelectionState {\n if (states.length === 0) return \"initial\";\n if (states.some((s) => s === \"data\")) return \"data\";\n if (states.some((s) => s === \"loading\")) return \"loading\";\n if (states.every((s) => s === \"empty\")) return \"empty\";\n if (states.some((s) => s === \"error\")) return \"error\";\n return \"initial\";\n}\n\n// ==================== Types ====================\ntype Padding = {\n l: string;\n r: string;\n t: string;\n b: string;\n};\n\ntype SnapPoint = number;\n\ntype SelectionState = \"loading\" | \"empty\" | \"error\" | \"data\" | \"initial\";\n\n\ntype TitleProps = {\n text: string;\n textColor: string;\n className?: string;\n containerClass?: string;\n style?: React.CSSProperties;\n};\n\ntype SearchProps = {\n text: string;\n textColor: string;\n className?: string;\n background?: string;\n prefixIcon?: React.ReactNode;\n suffixIcon?: React.ReactNode;\n clearIcon?: React.ReactNode;\n backIcon?: React.ReactNode;\n prefixGap?: string;\n suffixGap?: string;\n padding?: Padding;\n autoFocus?: boolean;\n inputStyle?: React.CSSProperties;\n containerStyle?: React.CSSProperties;\n onChange?: (value: string) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n};\n\ntype LoadingProps = {\n view: React.ReactNode;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype NoResultProps = {\n view: React.ReactNode;\n text?: string;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype ErrorProps = {\n view: React.ReactNode;\n text?: string;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype CancelButtonProps = {\n text?: string;\n view: React.ReactNode;\n position?: \"left\" | \"right\";\n style?: React.CSSProperties;\n onClick?: () => void;\n /**\n * What a screen reader calls it. Defaults to \"Close\".\n *\n * A button whose only content is an icon has no accessible name at all, so it was announced as\n * just \"button\" — the one control that dismisses the sheet, and nothing said so.\n */\n ariaLabel?: string;\n};\n\ntype LayoutProps = {\n gapBetweenHandleAndTitle?: string;\n gapBetweenTitleAndSearch?: string;\n gapBetweenSearchAndContent?: string;\n /**\n * How far the rows are set in from the sides. Defaults to `16px`, matching the search box.\n *\n * The content had no inset while everything above it had 16px, so a list ran flush into the\n * sides of the screen under a search box that did not. Pass `0px` for rows that should reach\n * the edges.\n */\n contentPadding?: string;\n backgroundColor?: string;\n handleColor?: string;\n handleWidth?: string;\n fullScreenSearchBackground?: string;\n fullScreenSearchHeaderStyle?: React.CSSProperties;\n maxWidth?: string;\n};\n\ntype SelectionViewerProps = {\n id?: string;\n isOpen: boolean;\n backDrop?: boolean;\n onClose: () => void;\n /**\n * Give this overlay its own history entry under this name, so the platform's own Back (and the\n * iOS edge-swipe, and Android's gesture) closes the OVERLAY rather than the page under it.\n *\n * Off by default, because it changes what the back gesture does and no existing consumer asked\n * for that. Without it, Back with this open closes it AND leaves the page behind it: measured in\n * a real shop, the gesture walked straight out of a half-built sale.\n *\n * The name must be unique among overlays that can be open together, or they mistake each other's\n * entry. Make it STABLE across page loads and the overlay can also come back after a refresh —\n * see `useOverlayRoute` in `@academix-admin/overlay-route`, which this uses and which any\n * component can use directly.\n */\n historyRoute?: string;\n titleProp: TitleProps;\n searchProp?: SearchProps;\n loadingProp?: LoadingProps;\n noResultProp?: NoResultProps;\n errorProp?: ErrorProps;\n cancelButton?: CancelButtonProps;\n layoutProp?: LayoutProps;\n childrenDirection?: \"vertical\" | \"horizontal\";\n children?: React.ReactNode;\n onPaginate?: () => boolean | Promise<boolean>;\n snapPoints?: SnapPoint[];\n initialSnap?: number;\n unmountOnClose?: boolean;\n zIndex?: number;\n /**\n * Accessible name for the sheet, announced when it opens.\n *\n * A modal with no name is announced simply as \"dialog\", which tells a screen-reader user that\n * something has taken over the screen and nothing at all about what.\n */\n ariaLabel?: string;\n maxHeight?: string;\n minHeight?: string;\n selectionState?: SelectionState;\n closeThreshold?: number;\n};\n\n// ==================== Styles ====================\nconst getStyles = (id: string) => `\n#${id} .selection-viewer-header {\n padding: 0px;\n display: flex;\n flex-direction: column;\n align-items: center;\n position: relative;\n width: 100%;\n}\n\n/*\n * The close button, with a target a thumb can find.\n *\n * It sat at right: 0, top: 8 with no padding at all, so the icon was flush against the sheet's\n * edge and the only thing that could be tapped was the glyph itself — a target well under half\n * what a finger needs, in the corner of the screen where a thumb is least accurate. Inset by 4px\n * and padded out to 44px square, so the icon still reads as sitting in the corner while the\n * hittable area reaches the edges.\n *\n * The cancelButton.style prop is still spread last at the call site, so a consumer that was\n * overriding any of this keeps overriding it. (No backticks in here: this whole block lives\n * inside a template literal, and one would end the string.)\n */\n#${id} .selection-viewer-cancel {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 44px;\n min-height: 44px;\n padding: 10px;\n border: none;\n background-color: transparent;\n color: inherit;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n\n#${id} .selection-viewer-drag-handle {\n height: 5px;\n border-radius: 3px;\n margin-top: 16px;\n}\n\n#${id} .selection-viewer-container {\n display: flex;\n align-items: flex-start;\n width: 100%;\n}\n\n#${id} .selection-viewer-title {\n margin: 0px;\n font-size: 18px;\n font-weight: 600;\n padding: 0px 16px 0px 16px;\n word-break: break-word; /* break long words */\n white-space: normal; /* allow wrapping */\n}\n\n#${id} .selection-viewer-search {\n display: flex;\n align-items: center;\n margin: 16px 16px 4px 16px;\n border-radius: 12px;\n box-sizing: border-box;\n border: 1px solid rgba(0, 0, 0, 0.1);\n}\n\n#${id} .selection-viewer-search-input {\n flex: 1;\n border: none;\n background: transparent;\n padding: 12px 8px;\n outline: none;\n font-size: 16px !important;\n width: 100%;\n}\n\n/*\n * The rows, set in from the edges like everything else in the sheet.\n *\n * The title and the search box have carried a 16px margin from the start; the content had none, so\n * a list of cards ran flush into the sides of the screen while the search box above it did not.\n * The layoutProp.contentPadding option overrides it for a consumer that wants its rows edge to\n * edge. (No backticks: this block is inside a template literal.)\n */\n#${id} .selection-viewer-content {\n overflow-y: auto;\n -webkit-overflow-scrolling: touch;\n flex: 1;\n min-height: 0;\n box-sizing: border-box;\n}\n\n#${id} .selection-viewer-content.vertical {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n#${id} .selection-viewer-content.horizontal {\n display: flex;\n flex-direction: row;\n gap: 8px;\n overflow-x: auto;\n overflow-y: hidden;\n}\n\n#${id} .selection-viewer-no-results,\n#${id} .selection-viewer-error,\n#${id} .selection-viewer-loading {\n display: flex;\n justify-content: center;\n align-items: center;\n min-height: 120px;\n}\n\n#${id} .selection-viewer-default-no-results {\n color: #666;\n font-size: 14px;\n}\n\n#${id} .selection-viewer-default-error {\n color: red;\n font-size: 14px;\n}\n\n/* Full screen search mode */\n#${id} .selection-viewer-fullscreen-search {\n// position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 10;\n// padding-top: env(safe-area-inset-top);\n width: 100%;\n}\n\n#${id} .selection-viewer-search-back-button {\n background: none;\n border: none;\n padding: 8px;\n margin-right: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n#${id} .selection-viewer-search-back-button:hover {\n opacity: 0.7;\n}\n\n#${id} .selection-viewer-search-clear-button {\n background: none;\n border: none;\n padding: 8px;\n margin-left: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n#${id} .selection-viewer-search-clear-button:hover {\n opacity: 0.7;\n}\n\n/* React Modal Sheet overrides */\n#${id} .react-modal-sheet-container {\n max-width: 500px;\n margin: 0 auto;\n border-top-left-radius: 16px;\n border-top-right-radius: 16px;\n}\n\n#${id} .react-modal-sheet-backdrop {\n background-color: rgba(0, 0, 0, 0.5) !important;\n pointer-events: auto !important;\n}\n\n#${id} .react-modal-sheet-content {\n padding: 0 0px 0px 0px;\n height: 100%;\n}\n\n\n/* Mobile full-width behavior */\n@media (max-width: 500px) {\n #${id} .react-modal-sheet-container {\n max-width: 100%;\n border-radius: 0;\n }\n}\n\n/* Prevent iOS zooming */\n@media screen and (-webkit-min-device-pixel-ratio: 0) {\n #${id} .selection-viewer-search-input {\n font-size: 16px !important;\n }\n}\n`;\n\n// ==================== Hook to inject CSS per instance ====================\nconst useInjectStyles = (id: string) => {\n useEffect(() => {\n const styleId = `selection-viewer-styles-${id}`;\n let styleTag = document.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleTag) {\n styleTag = document.createElement(\"style\");\n styleTag.id = styleId;\n styleTag.innerHTML = getStyles(id);\n document.head.appendChild(styleTag);\n }\n\n // Cleanup on unmount\n return () => {\n if (styleTag && document.head.contains(styleTag)) {\n document.head.removeChild(styleTag);\n }\n };\n }, [id]);\n};\n\n// ==================== Component ====================\n/**\n * Escape closes the viewer, and Tab stays inside it.\n *\n * The viewer covers the screen, so what is behind it is not available — but nothing said so to the\n * keyboard. Tab walked out of the option list into the page underneath, where a person was\n * operating controls they could not see, and Escape did nothing at all, which is the one key\n * everybody reaches for to get out of a picker.\n *\n * Deliberately a private copy rather than an import from a sibling package: every library here\n * stands alone, and a shared helper between two of them is a dependency the consumer did not ask\n * for. Takes the container's `id` rather than a ref, because the sheet element belongs to the\n * underlying modal-sheet component; looking it up when a key is pressed finds it however that\n * component chooses to mount it. Focusables are re-queried on every Tab, since the option list\n * changes as the consumer filters it and a list captured on open is a list of dead elements.\n */\nconst useModalKeys = (isOpen: boolean, onClose: () => void, containerId: string) => {\n useEffect(() => {\n if (!isOpen || typeof document === \"undefined\") return;\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n onClose();\n return;\n }\n if (e.key !== \"Tab\") return;\n\n const focusable = document.getElementById(containerId)?.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]),' +\n ' textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n );\n if (!focusable || focusable.length === 0) return;\n\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [isOpen, onClose, containerId]);\n};\n\n/**\n * RAISE THE KEYBOARD INSIDE THE TAP, then hand it to the real box.\n *\n * iOS shows the keyboard only for a focus made while the user's own tap is still being handled.\n * The sheet mounts its search box a frame or more after it opens, so at the moment of the tap there\n * is no box to focus — and by the time there is, the tap is over and iOS will focus it silently,\n * with no keyboard. The standard way through: focus an invisible stand-in input synchronously (the\n * keyboard rises for it), then move focus to the real box the moment it exists — iOS keeps a raised\n * keyboard up when focus moves from one input to another in script. The stand-in is removed at once.\n *\n * `font-size: 16px` so iOS does not zoom the page to it.\n */\n/**\n * FOCUS THE BOX THE WAY A PLAIN focus() DID — native scroll included.\n *\n * Before 0.3.1 / 0.5.2 the box was focused once the sheet had opened, with a plain `focus()`, and\n * that is what made the sheet behave: iOS scrolls a newly focused box into view with the keyboard\n * accounted for, which pushed the header away and left the results showing above the keyboard. The\n * 0.3.1 / 0.5.2 fix (focus inside the tap, so the keyboard rises at all) focused with\n * `preventScroll: true`, and that scroll never happened again — the header stayed and the rows sat\n * under the keyboard.\n *\n * A box that ALREADY has focus is not scrolled by focusing it again, so focus is bounced through a\n * stand-in and back: moving focus from one input to another keeps the keyboard up on iOS, and the\n * real box, newly focused, gets the browser's own keyboard-aware scroll.\n */\nfunction focusWithNativeScroll(input: HTMLInputElement): void {\n if (typeof document === \"undefined\") return;\n if (document.activeElement === input) {\n const bounce = document.createElement(\"input\");\n bounce.setAttribute(\"aria-hidden\", \"true\");\n bounce.tabIndex = -1;\n bounce.style.cssText =\n \"position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;font-size:16px;border:0;padding:0;pointer-events:none;\";\n document.body.appendChild(bounce);\n bounce.focus({ preventScroll: true });\n input.focus();\n bounce.remove();\n return;\n }\n input.focus();\n}\n\nfunction focusWhenMounted(getInput: () => HTMLInputElement | null): () => void {\n if (typeof document === \"undefined\") return () => {};\n const now = getInput();\n if (now) {\n now.focus({ preventScroll: true });\n return () => {};\n }\n const proxy = document.createElement(\"input\");\n proxy.setAttribute(\"aria-hidden\", \"true\");\n proxy.tabIndex = -1;\n proxy.style.cssText =\n \"position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;font-size:16px;border:0;padding:0;pointer-events:none;\";\n document.body.appendChild(proxy);\n proxy.focus({ preventScroll: true });\n\n let stopped = false;\n const started = Date.now();\n const hand = () => {\n if (stopped) return;\n const input = getInput();\n if (input) {\n // A plain focus, so the browser scrolls the box into view as it always did (see above).\n input.focus();\n proxy.remove();\n return;\n }\n if (Date.now() - started > 1500) {\n proxy.remove();\n return;\n }\n requestAnimationFrame(hand);\n };\n requestAnimationFrame(hand);\n return () => {\n stopped = true;\n proxy.remove();\n };\n}\n\nconst SelectionViewer: React.FC<SelectionViewerProps> = ({\n id: providedId,\n isOpen,\n historyRoute,\n backDrop = true,\n onClose,\n titleProp,\n searchProp,\n loadingProp,\n noResultProp,\n errorProp,\n cancelButton,\n layoutProp,\n childrenDirection = \"vertical\",\n children,\n onPaginate,\n snapPoints = [0, 1],\n initialSnap = 1,\n unmountOnClose = true,\n zIndex = 1000,\n ariaLabel,\n maxHeight = \"90dvh\",\n minHeight = \"65dvh\",\n selectionState: selectionStateProp = \"initial\",\n closeThreshold = 0.2,\n}) => {\n\n /*\n * THE BACK GESTURE CLOSES THIS, NOT THE PAGE UNDER IT.\n *\n * Only when the consumer named a route: `useOverlayRoute` is a no-op with an empty name, and an\n * overlay that never asked for a history entry must not acquire one, or Back starts meaning\n * something different in an app that did not opt in.\n *\n * The capability lives in its own package rather than here, so that an app wanting a\n * back-closable sheet does not have to take a router with it — and so that a navigation library\n * can supply the history writing without either package importing the other.\n */\n useOverlayRoute(historyRoute ?? '', Boolean(historyRoute) && isOpen, onClose);\n const [id] = useState(() => providedId || `selection-${Math.random().toString(36).substring(2, 11)}`);\n const [searchValue, setSearchValue] = useState(\"\");\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n const [keyboardHeight, setKeyboardHeight] = useState(0);\n const [inputKey, setInputKey] = useState(0);\n const [shouldAutoFocus, setShouldAutoFocus] = useState(false);\n /*\n * The person left search with the arrow. `autoFocus` is for the OPENING only: after this, nothing\n * of ours may put the box back in focus — see `handleBackFromSearch`.\n */\n const leftSearch = useRef(false);\n const isPaginating = useRef(false);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const sheetRef = useRef<any>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n\n useInjectStyles(id);\n // Escape closes the viewer and Tab stays inside it — see useModalKeys.\n useModalKeys(isOpen, onClose, id);\n\n // Descendant sections (a Column, or anything else) can report a cumulative state up through this —\n // starts empty, so a plain SelectionViewer with no Row/Column children behaves exactly as before.\n const [reportedStates, setReportedStates] = useState<Map<string, SelectionState>>(new Map());\n const reportAggregate = useCallback((reporterId: string, state: SelectionState) => {\n setReportedStates((prev) => {\n const next = new Map(prev);\n next.set(reporterId, state);\n return next;\n });\n }, []);\n const unreportAggregate = useCallback((reporterId: string) => {\n setReportedStates((prev) => {\n if (!prev.has(reporterId)) return prev;\n const next = new Map(prev);\n next.delete(reporterId);\n return next;\n });\n }, []);\n const aggregateReporterValue = useMemo(\n () => ({ report: reportAggregate, unreport: unreportAggregate }),\n [reportAggregate, unreportAggregate]\n );\n const reportedAggregate =\n reportedStates.size > 0 ? computeAggregateState(Array.from(reportedStates.values())) : null;\n const isComposed = reportedAggregate !== null;\n\n // Precedence: an explicit `selectionState` prop always wins (matches today's exact behaviour for\n // any consumer not using Row/Column) -> then a reported Column aggregate, if one exists -> \"initial\".\n const selectionState =\n selectionStateProp !== \"initial\" ? selectionStateProp : reportedAggregate ?? \"initial\";\n\n // Track keyboard height\n useEffect(() => {\n if (typeof window === 'undefined' || !window.visualViewport) return;\n\n const handleResize = () => {\n const vp = window.visualViewport!;\n const kbHeight = window.innerHeight - vp.height;\n setKeyboardHeight(kbHeight > 0 ? kbHeight : 0);\n };\n\n window.visualViewport.addEventListener('resize', handleResize);\n window.visualViewport.addEventListener('scroll', handleResize);\n\n return () => {\n window.visualViewport?.removeEventListener('resize', handleResize);\n window.visualViewport?.removeEventListener('scroll', handleResize);\n };\n }, []);\n\n // Auto-focus on search\n useEffect(() => {\n if (!isOpen) {\n searchInputRef.current?.blur();\n setSearchValue(\"\");\n searchProp?.onChange?.(\"\");\n setShouldAutoFocus(false);\n return;\n }\n }, [isOpen, searchProp?.autoFocus]);\n\n /*\n * THE KEYBOARD COMES UP WITH THE SHEET — on iOS too. See search-viewer's `useSearchInput`: the\n * focus is made in a layout effect while the opening tap is still being handled, which is the only\n * focus iOS answers with a keyboard. It used to wait for the open animation and remount the input\n * first, so the focus landed on a discarded element, after the tap, and no keyboard rose.\n */\n useLayoutEffect(() => {\n if (!isOpen) return;\n leftSearch.current = false;\n if (!searchProp?.autoFocus) return;\n setShouldAutoFocus(true);\n return focusWhenMounted(() => searchInputRef.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n const handleOpenEnd = useCallback(() => {\n if (!searchProp?.autoFocus || !searchInputRef.current) return;\n // Left search before the sheet finished opening: that was the person's choice, not a lost focus.\n if (leftSearch.current) return;\n setShouldAutoFocus(true);\n // Now that the sheet is where it will stay: the scroll a plain focus gives (see above).\n focusWithNativeScroll(searchInputRef.current);\n }, [searchProp?.autoFocus]);\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value;\n setSearchValue(value);\n searchProp?.onChange?.(value);\n };\n\n const handleSearchFocus = () => {\n setIsSearchFocused(true);\n searchProp?.onFocus?.();\n requestAnimationFrame(() => {\n searchInputRef.current?.focus();\n });\n };\n\n const handleSearchBlur = () => {\n searchProp?.onBlur?.();\n };\n\n /*\n * THE ARROW LEAVES SEARCH, AND STAYS OUT.\n *\n * Leaving search swaps the full-screen search header for the normal one, and that mounts a NEW\n * search box. It carried `autoFocus` — still true from the opening — so the new box took focus\n * the moment it appeared, focusing it re-entered search mode, and the arrow looked dead: \"we\n * cannot press the back button in the viewer\". Opening is the only time the box focuses itself.\n */\n const handleBackFromSearch = () => {\n leftSearch.current = true;\n setShouldAutoFocus(false);\n setIsSearchFocused(false);\n if (searchInputRef.current) {\n searchInputRef.current.blur();\n }\n };\n\n const clearSearch = () => {\n setSearchValue(\"\");\n searchProp?.onChange?.(\"\");\n if (searchInputRef.current) {\n searchInputRef.current.focus();\n }\n };\n\n /*\n * PAGINATION LISTENS TO WHATEVER ACTUALLY SCROLLS.\n *\n * It listened to `.selection-viewer-content` alone. Inside the sheet that element is not the\n * scroller: react-modal-sheet wraps content in its own `.react-modal-sheet-content-scroller`, the\n * content grows to its full height (4,601px for a hundred rows, measured) and the WRAPPER scrolls.\n * The content box never fired a scroll event, so `onPaginate` was never called — every consumer's\n * list stopped at its first page with nothing to say it had.\n *\n * So the nearest scrolling ancestor is found and listened to, and the content itself as well (for\n * a layout where it is the scroller). And the check also runs when the content changes size: a\n * first page too short to scroll can never produce a scroll event, but it is plainly \"at the\n * bottom\", so it asks for the next one straight away.\n */\n const onPaginateRef = useRef(onPaginate);\n onPaginateRef.current = onPaginate;\n const [contentEl, setContentEl] = useState<HTMLDivElement | null>(null);\n\n const checkNearBottom = useCallback(async (el: HTMLElement) => {\n const paginate = onPaginateRef.current;\n if (isPaginating.current || !paginate) return;\n\n const { scrollTop, scrollHeight, clientHeight } = el;\n const isNearBottom = scrollHeight - scrollTop <= clientHeight * 1.2;\n if (!isNearBottom) return;\n\n isPaginating.current = true;\n const hasMore = await paginate();\n if (!hasMore) {\n isPaginating.current = false;\n } else {\n setTimeout(() => {\n isPaginating.current = false;\n }, 500);\n }\n }, []);\n\n const hasPaginate = Boolean(onPaginate);\n useEffect(() => {\n if (!contentEl || !hasPaginate) return;\n const scroller =\n (contentEl.closest(\".react-modal-sheet-content-scroller\") as HTMLElement | null) ?? contentEl;\n const onScroll = () => void checkNearBottom(scroller);\n const onInnerScroll = () => void checkNearBottom(contentEl);\n\n scroller.addEventListener(\"scroll\", onScroll, { passive: true });\n if (scroller !== contentEl) contentEl.addEventListener(\"scroll\", onInnerScroll, { passive: true });\n\n const resize =\n typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(() => onScroll()) : null;\n resize?.observe(contentEl);\n\n return () => {\n scroller.removeEventListener(\"scroll\", onScroll);\n contentEl.removeEventListener(\"scroll\", onInnerScroll);\n resize?.disconnect();\n };\n }, [contentEl, hasPaginate, checkNearBottom]);\n\n if (!isOpen && unmountOnClose) return null;\n\n return (\n <SelectionViewerAggregateContext.Provider value={aggregateReporterValue}>\n <Sheet\n ref={sheetRef}\n isOpen={isOpen}\n onClose={onClose}\n detent=\"content\"\n style={{ zIndex }}\n maxHeight={maxHeight}\n onOpenEnd={handleOpenEnd}\n >\n <Sheet.Container\n id={id}\n // Announced as a modal dialog. Without this a screen reader reads the sheet as one more\n // region of the page and gives no indication that what is behind it is unavailable — and\n // an automated check for an open dialog finds nothing at all.\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n style={{\n maxHeight: maxHeight,\n minHeight: isSearchFocused ? \"100dvh\" : minHeight,\n maxWidth: layoutProp?.maxWidth ?? '800px',\n margin: \"0 auto\",\n width: \"100%\",\n left: 0,\n right: 0,\n paddingBottom: \"calc(0px + env(safe-area-inset-bottom))\",\n background: isSearchFocused\n ? layoutProp?.fullScreenSearchBackground || layoutProp?.backgroundColor\n : layoutProp?.backgroundColor,\n borderTopLeftRadius: isSearchFocused ? \"0px\" : \"16px\",\n borderTopRightRadius: isSearchFocused ? \"0px\" : \"16px\",\n }}\n >\n {isSearchFocused ? (\n <Sheet.Header>\n <div\n className=\"selection-viewer-fullscreen-search\"\n style={layoutProp?.fullScreenSearchHeaderStyle}\n >\n <div className=\"selection-viewer-search\" style={{\n ...searchProp?.containerStyle,\n background: searchProp?.background,\n padding: searchProp?.padding\n ? `${searchProp.padding.t} ${searchProp.padding.r} ${searchProp.padding.b} ${searchProp.padding.l}`\n : \"16px\"\n }}>\n <button\n className=\"selection-viewer-search-back-button\"\n onClick={handleBackFromSearch}\n aria-label=\"Exit search mode\"\n >\n {searchProp?.backIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M15 18L9 12L15 6\" stroke={searchProp?.textColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n\n <input\n key={inputKey}\n ref={searchInputRef}\n type=\"text\"\n placeholder={searchProp?.text}\n value={searchValue}\n onChange={handleSearchChange}\n className={searchProp?.className || \"selection-viewer-search-input\"}\n style={{\n color: searchProp?.textColor,\n ...searchProp?.inputStyle\n }}\n onFocus={handleSearchFocus}\n onBlur={handleSearchBlur}\n autoFocus={shouldAutoFocus}\n />\n\n {searchValue && (\n <button\n className=\"selection-viewer-search-clear-button\"\n onClick={clearSearch}\n aria-label=\"Clear search\"\n >\n {searchProp?.clearIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 6L6 18M6 6L18 18\" stroke={searchProp?.textColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n )}\n </div>\n </div>\n </Sheet.Header>\n ) : (\n <Sheet.Header>\n <div className=\"selection-viewer-header\">\n {/* Cancel button left */}\n {cancelButton?.position === \"left\" && (\n <button\n aria-label={cancelButton.ariaLabel || \"Close\"}\n className=\"selection-viewer-cancel\"\n style={{\n position: \"absolute\",\n left: \"4px\",\n top: \"4px\",\n ...cancelButton.style\n }}\n onClick={cancelButton.onClick || onClose}\n >\n {cancelButton.view || cancelButton.text || \"Cancel\"}\n </button>\n )}\n\n {/* Drag handle */}\n {!isSearchFocused && (\n <div\n className=\"selection-viewer-drag-handle\"\n style={{\n background: layoutProp?.handleColor || \"#ccc\",\n width: layoutProp?.handleWidth || \"40px\",\n marginBottom: layoutProp?.gapBetweenHandleAndTitle || \"12px\",\n }}\n />\n )}\n\n {/* Cancel button right */}\n {cancelButton?.position === \"right\" && (\n <button\n aria-label={cancelButton.ariaLabel || \"Close\"}\n className=\"selection-viewer-cancel\"\n style={{\n position: \"absolute\",\n right: \"4px\",\n top: \"4px\",\n ...cancelButton.style\n }}\n onClick={cancelButton.onClick || onClose}\n >\n {cancelButton.view || cancelButton.text || \"Cancel\"}\n </button>\n )}\n\n {/* Title */}\n <div className={titleProp.containerClass || \"selection-viewer-container\"}>\n <h2\n id={`${id}-title`}\n className={titleProp.className || \"selection-viewer-title\"}\n style={{\n marginBottom: layoutProp?.gapBetweenTitleAndSearch || \"8px\",\n color: titleProp?.textColor || 'black',\n ...titleProp.style\n }}\n >\n {titleProp.text}\n </h2>\n </div>\n </div>\n\n {/* Search */}\n {searchProp && (\n <div\n className=\"selection-viewer-search\"\n style={{\n background: searchProp.background,\n padding: searchProp.padding\n ? `${searchProp.padding.t} ${searchProp.padding.r} ${searchProp.padding.b} ${searchProp.padding.l}`\n : \"8px 16px\",\n marginBottom: layoutProp?.gapBetweenSearchAndContent,\n ...searchProp.containerStyle\n }}\n >\n {searchProp.prefixIcon && (\n <span style={{ marginRight: searchProp.prefixGap || \"8px\" }}>\n {searchProp.prefixIcon}\n </span>\n )}\n <input\n key={inputKey}\n ref={searchInputRef}\n type=\"text\"\n placeholder={searchProp.text}\n value={searchValue}\n onChange={handleSearchChange}\n className={searchProp.className || \"selection-viewer-search-input\"}\n style={{\n color: searchProp?.textColor,\n ...searchProp.inputStyle\n }}\n onFocus={handleSearchFocus}\n onBlur={handleSearchBlur}\n autoFocus={shouldAutoFocus}\n />\n {searchValue && (\n <button\n className=\"selection-viewer-search-clear-button\"\n onClick={clearSearch}\n aria-label=\"Clear search\"\n style={{ marginLeft: searchProp.suffixGap || \"8px\" }}\n >\n {searchProp.clearIcon || searchProp.suffixIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 6L6 18M6 6L18 18\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n )}\n {!searchValue && searchProp.suffixIcon && (\n <span style={{ marginLeft: searchProp.suffixGap || \"8px\" }}>\n {searchProp.suffixIcon}\n </span>\n )}\n </div>\n )}\n </Sheet.Header>\n )}\n\n <Sheet.Content>\n <div\n ref={setContentEl}\n className={`selection-viewer-content ${childrenDirection}`}\n style={{\n paddingTop: isSearchFocused ? layoutProp?.gapBetweenSearchAndContent : '0',\n paddingBottom: keyboardHeight > 0\n ? `${keyboardHeight + 16}px`\n : '16px',\n /*\n * Set in from the edges, like everything else in the sheet.\n *\n * The title and the search box have carried 16px from the start and the content had\n * none, so a list of rows ran flush into the sides of the screen under a search box\n * that did not. Overridable for rows that genuinely want the full width.\n */\n paddingLeft: layoutProp?.contentPadding ?? '16px',\n paddingRight: layoutProp?.contentPadding ?? '16px',\n }}\n >\n {/* Show children first, then loading at bottom */}\n {React.Children.count(children) > 0 ? (\n <>\n {children}\n {selectionState === \"loading\" && (\n <div\n className=\"selection-viewer-loading\"\n style={{\n padding: loadingProp?.padding\n ? `${loadingProp.padding.t} ${loadingProp.padding.r} ${loadingProp.padding.b} ${loadingProp.padding.l}`\n : \"16px\",\n ...loadingProp?.style\n }}\n >\n {loadingProp?.view}\n </div>\n )}\n {/*\n Shown ALONGSIDE the children, not instead of them.\n\n This was guarded on composed mode — a Column/Row descendant reporting its own\n state — on the reasoning that only a composed sheet can have children and be\n empty at the same time. That is not true of the commonest arrangement there is:\n a consumer that wraps its rows in a single container. `React.Children.count` is\n then 1 whether the container holds fifty rows or none, so the empty branch below\n never ran and the sheet showed a blank white screen — at the exact moment\n somebody had searched for something that is not there, which is when the empty\n state is the only useful thing on screen.\n\n Layered rather than substituted, for the reason the composed case already had:\n a child that reports its own state must stay mounted to go on reporting. A\n consumer whose `selectionState` says \"empty\" is asserting there is nothing to\n show, so drawing its own view beside visually-empty children is what it asked\n for.\n */}\n {selectionState === \"empty\" && (\n <div\n className=\"selection-viewer-no-results\"\n style={{\n padding: noResultProp?.padding\n ? `${noResultProp.padding.t} ${noResultProp.padding.r} ${noResultProp.padding.b} ${noResultProp.padding.l}`\n : \"16px\",\n ...noResultProp?.style\n }}\n >\n {noResultProp?.view || (\n <div className=\"selection-viewer-default-no-results\">\n {noResultProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n )}\n {selectionState === \"error\" && (\n <div\n className=\"selection-viewer-error\"\n style={{\n padding: errorProp?.padding\n ? `${errorProp.padding.t} ${errorProp.padding.r} ${errorProp.padding.b} ${errorProp.padding.l}`\n : \"16px\",\n ...errorProp?.style\n }}\n >\n {errorProp?.view || (\n <div className=\"selection-viewer-default-error\">\n {errorProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n )}\n </>\n ) : (selectionState === \"empty\" || (React.Children.count(children) <= 0 && (selectionState != \"loading\" && selectionState != \"error\"))) ? (\n <div\n className=\"selection-viewer-no-results\"\n style={{\n padding: noResultProp?.padding\n ? `${noResultProp.padding.t} ${noResultProp.padding.r} ${noResultProp.padding.b} ${noResultProp.padding.l}`\n : \"16px\",\n ...noResultProp?.style\n }}\n >\n {noResultProp?.view || (\n <div className=\"selection-viewer-default-no-results\">\n {noResultProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n ) : selectionState === \"loading\" ? (\n <div\n className=\"selection-viewer-loading\"\n style={{\n padding: loadingProp?.padding\n ? `${loadingProp.padding.t} ${loadingProp.padding.r} ${loadingProp.padding.b} ${loadingProp.padding.l}`\n : \"16px\",\n ...loadingProp?.style\n }}\n >\n {loadingProp?.view}\n </div>\n ) : (selectionState === \"error\") ? (\n <div\n className=\"selection-viewer-error\"\n style={{\n padding: errorProp?.padding\n ? `${errorProp.padding.t} ${errorProp.padding.r} ${errorProp.padding.b} ${errorProp.padding.l}`\n : \"16px\",\n ...errorProp?.style\n }}\n >\n {errorProp?.view || (\n <div className=\"selection-viewer-default-error\">\n {errorProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n ) : null}\n </div>\n </Sheet.Content>\n </Sheet.Container>\n <Sheet.Backdrop onTap={backDrop ? onClose : undefined} />\n </Sheet>\n </SelectionViewerAggregateContext.Provider>\n );\n};\n\n// ==================== Controller Hook ====================\ntype Operation = {\n open: () => void;\n close: () => void;\n toggle: () => void;\n setSelectionState: (val: SelectionState) => void;\n};\n\nconst useSelectionController = (initialSelectionState?: SelectionState): [\n string,\n Operation,\n boolean,\n SelectionState\n] => {\n const [isOpen, setIsOpen] = useState(false);\n const [selectionState, setSelectionState] = useState(initialSelectionState || 'initial');\n const [selectionId] = useState(() => `selection-${Math.random().toString(36).substring(2, 11)}`);\n\n const operations = useMemo<Operation>(() => ({\n open: () => setIsOpen(true),\n close: () => setIsOpen(false),\n toggle: () => setIsOpen((prev) => !prev),\n setSelectionState\n }), [setSelectionState]);\n\n return [selectionId, operations, isOpen, selectionState];\n};\n\nexport { SelectionViewer, useSelectionController, RowAggregateContext, SelectionViewerAggregateContext, computeAggregateState };\nexport type {\n SelectionViewerProps,\n SelectionState,\n TitleProps,\n SearchProps,\n LoadingProps,\n NoResultProps,\n ErrorProps,\n CancelButtonProps,\n LayoutProps,\n Padding,\n SnapPoint,\n AggregateReporter,\n};\nexport default SelectionViewer;\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { RowAggregateContext } from \"./SelectionViewer\";\nimport type { SelectionState } from \"./SelectionViewer\";\n\nexport type RowProps = {\n id?: string;\n /** Consumer-owned — SelectionViewer has never owned fetch/filter state, so unlike\n * search-viewer's Row this isn't internally computed. Mirrors how `selectionState`\n * is already a prop on SelectionViewer itself today. Defaults to \"data\": if you\n * render children without wiring this, we assume what you rendered IS the data. */\n state?: SelectionState;\n /** Called when this Row is scrolled horizontally near its end. Return (or resolve to)\n * `true` if more data may follow (keeps the pagination trigger armed), `false` once\n * there's nothing left to fetch — mirrors SelectionViewer's own `onPaginate` contract. */\n onPaginate?: () => boolean | Promise<boolean>;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n/** A horizontally-scrolling, independently-paginating section — the Row/Column\n * equivalent for `SelectionViewer`. No shared code with `@academix-admin/search-viewer`'s\n * Row (Library Charter: packages stay mutually independent) — this one has no\n * query/debounce/cache engine of its own since `SelectionViewer` never had one either;\n * the consumer owns fetching/filtering and just tells this Row what `state` it's in. */\nfunction Row({ id: providedId, state = \"data\", onPaginate, className, style, children }: RowProps) {\n const aggregateReporter = React.useContext(RowAggregateContext);\n const [rowId] = useState(() => providedId || `row-${Math.random().toString(36).substring(2, 11)}`);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const isPaginating = useRef(false);\n\n const handleScroll = useCallback(async () => {\n const el = containerRef.current;\n if (!el || isPaginating.current || !onPaginate) return;\n\n // Same \"near the end\" threshold as SelectionViewer's own vertical pagination trigger, adapted\n // to horizontal scroll metrics since a Row scrolls sideways.\n const { scrollLeft, scrollWidth, clientWidth } = el;\n if (scrollWidth - scrollLeft > clientWidth * 1.2) return;\n\n isPaginating.current = true;\n const hasMore = await onPaginate();\n if (!hasMore) {\n isPaginating.current = false;\n } else {\n setTimeout(() => {\n isPaginating.current = false;\n }, 500);\n }\n }, [onPaginate]);\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el || !onPaginate) return;\n el.addEventListener(\"scroll\", handleScroll);\n return () => el.removeEventListener(\"scroll\", handleScroll);\n }, [handleScroll, onPaginate]);\n\n useEffect(() => {\n aggregateReporter?.report(rowId, state);\n return () => aggregateReporter?.unreport(rowId);\n }, [aggregateReporter, rowId, state]);\n\n return (\n <div\n ref={containerRef}\n className={className ? `selection-viewer-row ${className}` : \"selection-viewer-row\"}\n style={{\n display: \"flex\",\n flexDirection: \"row\",\n gap: \"8px\",\n overflowX: \"auto\",\n overflowY: \"hidden\",\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n\nRow.displayName = \"Row\";\n\nexport { Row };\n","import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { RowAggregateContext, SelectionViewerAggregateContext, computeAggregateState } from \"./SelectionViewer\";\nimport type { SelectionState } from \"./SelectionViewer\";\n\nexport type ColumnProps = {\n id?: string;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n/** A vertical arrangement of `Row`s (or other content) — the explicit, composable\n * equivalent of today's flat `children` list. Its default layout is deliberately\n * identical to the existing `.selection-viewer-content.vertical` rendering\n * (`flex-direction: column, gap: 8px`), so today's flat usage is, unchanged, \"an\n * implicit Column with no Rows.\"\n *\n * Provides the `RowAggregateContext` its `Row` children report into, computes ONE\n * cumulative state from everything reported, and is itself a reporter one level up:\n * nested inside another `Column` it reports through that Column's `RowAggregateContext`\n * (behaving like a Row); at the top level it reports through `SelectionViewerAggregateContext`,\n * which `SelectionViewer` provides — this drives the outer sheet's loading/empty/error\n * views automatically with zero manual wiring, and lets Columns nest arbitrarily deep. */\nfunction Column({ id: providedId, className, style, children }: ColumnProps) {\n const [columnId] = useState(\n () => providedId || `column-${Math.random().toString(36).substring(2, 11)}`\n );\n\n const [reportedStates, setReportedStates] = useState<Map<string, SelectionState>>(new Map());\n const report = useCallback((id: string, state: SelectionState) => {\n setReportedStates((prev) => {\n const next = new Map(prev);\n next.set(id, state);\n return next;\n });\n }, []);\n const unreport = useCallback((id: string) => {\n setReportedStates((prev) => {\n if (!prev.has(id)) return prev;\n const next = new Map(prev);\n next.delete(id);\n return next;\n });\n }, []);\n const rowAggregateValue = useMemo(() => ({ report, unreport }), [report, unreport]);\n\n const aggregateState =\n reportedStates.size > 0 ? computeAggregateState(Array.from(reportedStates.values())) : \"initial\";\n\n const parentRowAggregate = React.useContext(RowAggregateContext);\n const selectionViewerAggregate = React.useContext(SelectionViewerAggregateContext);\n const upstreamReporter = parentRowAggregate ?? selectionViewerAggregate;\n\n useEffect(() => {\n if (!upstreamReporter) return;\n upstreamReporter.report(columnId, aggregateState);\n return () => upstreamReporter.unreport(columnId);\n }, [upstreamReporter, columnId, aggregateState]);\n\n return (\n <RowAggregateContext.Provider value={rowAggregateValue}>\n <div\n className={className ? `selection-viewer-column ${className}` : \"selection-viewer-column\"}\n style={{ display: \"flex\", flexDirection: \"column\", gap: \"8px\", ...style }}\n >\n {children}\n </div>\n </RowAggregateContext.Provider>\n );\n}\n\nColumn.displayName = \"Column\";\n\nexport { Column };\n"]}
1
+ {"version":3,"sources":["../src/SelectionViewer.tsx","../src/Row.tsx","../src/Column.tsx"],"names":["React","useEffect","useOverlayRoute","useState","useRef","useCallback","useMemo","jsx","jsxs","Sheet","Fragment"],"mappings":";;;;;;;;;;;;;;AAcA,IAAM,mBAAA,GAAsBA,sBAAA,CAAM,aAAA,CAAwC,IAAI;AAI9E,IAAM,+BAAA,GAAkCA,sBAAA,CAAM,aAAA,CAAwC,IAAI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useMemo } from \"react\";\nimport { Sheet } from \"@academix-admin/modal-sheet\";\nimport { useOverlayRoute } from '@academix-admin/overlay-route';\n\n// ==================== Aggregation (Row/Column) ====================\n// Independent from @academix-admin/search-viewer's equivalent (Library Charter: packages stay\n// mutually independent) — same shape, duplicated intentionally rather than shared.\n\ntype AggregateReporter = {\n report: (id: string, state: SelectionState) => void;\n unreport: (id: string) => void;\n};\n\n/** A `Row` reports its own `state` into the nearest `Column` through this. */\nconst RowAggregateContext = React.createContext<AggregateReporter | null>(null);\n\n/** `Column` reports its own aggregated state up through this — `SelectionViewer` provides it and\n * merges whatever's reported into its own selectionState resolution, with zero extra wiring. */\nconst SelectionViewerAggregateContext = React.createContext<AggregateReporter | null>(null);\n\nfunction computeAggregateState(states: SelectionState[]): SelectionState {\n if (states.length === 0) return \"initial\";\n if (states.some((s) => s === \"data\")) return \"data\";\n if (states.some((s) => s === \"loading\")) return \"loading\";\n if (states.every((s) => s === \"empty\")) return \"empty\";\n if (states.some((s) => s === \"error\")) return \"error\";\n return \"initial\";\n}\n\n// ==================== Types ====================\ntype Padding = {\n l: string;\n r: string;\n t: string;\n b: string;\n};\n\ntype SnapPoint = number;\n\ntype SelectionState = \"loading\" | \"empty\" | \"error\" | \"data\" | \"initial\";\n\n\ntype TitleProps = {\n text: string;\n textColor: string;\n className?: string;\n containerClass?: string;\n style?: React.CSSProperties;\n};\n\ntype SearchProps = {\n text: string;\n textColor: string;\n className?: string;\n background?: string;\n prefixIcon?: React.ReactNode;\n suffixIcon?: React.ReactNode;\n clearIcon?: React.ReactNode;\n backIcon?: React.ReactNode;\n prefixGap?: string;\n suffixGap?: string;\n padding?: Padding;\n autoFocus?: boolean;\n inputStyle?: React.CSSProperties;\n containerStyle?: React.CSSProperties;\n onChange?: (value: string) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n};\n\ntype LoadingProps = {\n view: React.ReactNode;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype NoResultProps = {\n view: React.ReactNode;\n text?: string;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype ErrorProps = {\n view: React.ReactNode;\n text?: string;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype CancelButtonProps = {\n text?: string;\n view: React.ReactNode;\n position?: \"left\" | \"right\";\n style?: React.CSSProperties;\n onClick?: () => void;\n /**\n * What a screen reader calls it. Defaults to \"Close\".\n *\n * A button whose only content is an icon has no accessible name at all, so it was announced as\n * just \"button\" — the one control that dismisses the sheet, and nothing said so.\n */\n ariaLabel?: string;\n};\n\ntype LayoutProps = {\n gapBetweenHandleAndTitle?: string;\n gapBetweenTitleAndSearch?: string;\n gapBetweenSearchAndContent?: string;\n /**\n * How far the rows are set in from the sides. Defaults to `16px`, matching the search box.\n *\n * The content had no inset while everything above it had 16px, so a list ran flush into the\n * sides of the screen under a search box that did not. Pass `0px` for rows that should reach\n * the edges.\n */\n contentPadding?: string;\n backgroundColor?: string;\n handleColor?: string;\n handleWidth?: string;\n fullScreenSearchBackground?: string;\n fullScreenSearchHeaderStyle?: React.CSSProperties;\n maxWidth?: string;\n};\n\ntype SelectionViewerProps = {\n id?: string;\n isOpen: boolean;\n backDrop?: boolean;\n onClose: () => void;\n /**\n * Give this overlay its own history entry under this name, so the platform's own Back (and the\n * iOS edge-swipe, and Android's gesture) closes the OVERLAY rather than the page under it.\n *\n * Off by default, because it changes what the back gesture does and no existing consumer asked\n * for that. Without it, Back with this open closes it AND leaves the page behind it: measured in\n * a real shop, the gesture walked straight out of a half-built sale.\n *\n * The name must be unique among overlays that can be open together, or they mistake each other's\n * entry. Make it STABLE across page loads and the overlay can also come back after a refresh —\n * see `useOverlayRoute` in `@academix-admin/overlay-route`, which this uses and which any\n * component can use directly.\n */\n historyRoute?: string;\n titleProp: TitleProps;\n searchProp?: SearchProps;\n loadingProp?: LoadingProps;\n noResultProp?: NoResultProps;\n errorProp?: ErrorProps;\n cancelButton?: CancelButtonProps;\n layoutProp?: LayoutProps;\n childrenDirection?: \"vertical\" | \"horizontal\";\n children?: React.ReactNode;\n onPaginate?: () => boolean | Promise<boolean>;\n snapPoints?: SnapPoint[];\n initialSnap?: number;\n unmountOnClose?: boolean;\n zIndex?: number;\n /**\n * Accessible name for the sheet, announced when it opens.\n *\n * A modal with no name is announced simply as \"dialog\", which tells a screen-reader user that\n * something has taken over the screen and nothing at all about what.\n */\n ariaLabel?: string;\n maxHeight?: string;\n minHeight?: string;\n selectionState?: SelectionState;\n closeThreshold?: number;\n};\n\n// ==================== Styles ====================\nconst getStyles = (id: string) => `\n#${id} .selection-viewer-header {\n padding: 0px;\n display: flex;\n flex-direction: column;\n align-items: center;\n position: relative;\n width: 100%;\n}\n\n/*\n * The close button, with a target a thumb can find.\n *\n * It sat at right: 0, top: 8 with no padding at all, so the icon was flush against the sheet's\n * edge and the only thing that could be tapped was the glyph itself — a target well under half\n * what a finger needs, in the corner of the screen where a thumb is least accurate. Inset by 4px\n * and padded out to 44px square, so the icon still reads as sitting in the corner while the\n * hittable area reaches the edges.\n *\n * The cancelButton.style prop is still spread last at the call site, so a consumer that was\n * overriding any of this keeps overriding it. (No backticks in here: this whole block lives\n * inside a template literal, and one would end the string.)\n */\n#${id} .selection-viewer-cancel {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 44px;\n min-height: 44px;\n padding: 10px;\n border: none;\n background-color: transparent;\n color: inherit;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n\n#${id} .selection-viewer-drag-handle {\n height: 5px;\n border-radius: 3px;\n margin-top: 16px;\n}\n\n#${id} .selection-viewer-container {\n display: flex;\n align-items: flex-start;\n width: 100%;\n}\n\n#${id} .selection-viewer-title {\n margin: 0px;\n font-size: 18px;\n font-weight: 600;\n padding: 0px 16px 0px 16px;\n word-break: break-word; /* break long words */\n white-space: normal; /* allow wrapping */\n}\n\n#${id} .selection-viewer-search {\n display: flex;\n align-items: center;\n margin: 16px 16px 4px 16px;\n border-radius: 12px;\n box-sizing: border-box;\n border: 1px solid rgba(0, 0, 0, 0.1);\n}\n\n#${id} .selection-viewer-search-input {\n flex: 1;\n border: none;\n background: transparent;\n padding: 12px 8px;\n outline: none;\n font-size: 16px !important;\n width: 100%;\n}\n\n/*\n * The rows, set in from the edges like everything else in the sheet.\n *\n * The title and the search box have carried a 16px margin from the start; the content had none, so\n * a list of cards ran flush into the sides of the screen while the search box above it did not.\n * The layoutProp.contentPadding option overrides it for a consumer that wants its rows edge to\n * edge. (No backticks: this block is inside a template literal.)\n */\n#${id} .selection-viewer-content {\n overflow-y: auto;\n -webkit-overflow-scrolling: touch;\n flex: 1;\n min-height: 0;\n box-sizing: border-box;\n}\n\n#${id} .selection-viewer-content.vertical {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n#${id} .selection-viewer-content.horizontal {\n display: flex;\n flex-direction: row;\n gap: 8px;\n overflow-x: auto;\n overflow-y: hidden;\n}\n\n#${id} .selection-viewer-no-results,\n#${id} .selection-viewer-error,\n#${id} .selection-viewer-loading {\n display: flex;\n justify-content: center;\n align-items: center;\n min-height: 120px;\n}\n\n#${id} .selection-viewer-default-no-results {\n color: #666;\n font-size: 14px;\n}\n\n#${id} .selection-viewer-default-error {\n color: red;\n font-size: 14px;\n}\n\n/* Full screen search mode */\n#${id} .selection-viewer-fullscreen-search {\n// position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 10;\n// padding-top: env(safe-area-inset-top);\n width: 100%;\n}\n\n#${id} .selection-viewer-search-back-button {\n background: none;\n border: none;\n padding: 8px;\n margin-right: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n#${id} .selection-viewer-search-back-button:hover {\n opacity: 0.7;\n}\n\n#${id} .selection-viewer-search-clear-button {\n background: none;\n border: none;\n padding: 8px;\n margin-left: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n#${id} .selection-viewer-search-clear-button:hover {\n opacity: 0.7;\n}\n\n/* React Modal Sheet overrides */\n#${id} .react-modal-sheet-container {\n max-width: 500px;\n margin: 0 auto;\n border-top-left-radius: 16px;\n border-top-right-radius: 16px;\n}\n\n#${id} .react-modal-sheet-backdrop {\n background-color: rgba(0, 0, 0, 0.5) !important;\n pointer-events: auto !important;\n}\n\n#${id} .react-modal-sheet-content {\n padding: 0 0px 0px 0px;\n height: 100%;\n}\n\n\n/* Mobile full-width behavior */\n@media (max-width: 500px) {\n #${id} .react-modal-sheet-container {\n max-width: 100%;\n border-radius: 0;\n }\n}\n\n/* Prevent iOS zooming */\n@media screen and (-webkit-min-device-pixel-ratio: 0) {\n #${id} .selection-viewer-search-input {\n font-size: 16px !important;\n }\n}\n`;\n\n// ==================== Hook to inject CSS per instance ====================\nconst useInjectStyles = (id: string) => {\n useEffect(() => {\n const styleId = `selection-viewer-styles-${id}`;\n let styleTag = document.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleTag) {\n styleTag = document.createElement(\"style\");\n styleTag.id = styleId;\n styleTag.innerHTML = getStyles(id);\n document.head.appendChild(styleTag);\n }\n\n // Cleanup on unmount\n return () => {\n if (styleTag && document.head.contains(styleTag)) {\n document.head.removeChild(styleTag);\n }\n };\n }, [id]);\n};\n\n// ==================== Component ====================\n/**\n * Escape closes the viewer, and Tab stays inside it.\n *\n * The viewer covers the screen, so what is behind it is not available — but nothing said so to the\n * keyboard. Tab walked out of the option list into the page underneath, where a person was\n * operating controls they could not see, and Escape did nothing at all, which is the one key\n * everybody reaches for to get out of a picker.\n *\n * Deliberately a private copy rather than an import from a sibling package: every library here\n * stands alone, and a shared helper between two of them is a dependency the consumer did not ask\n * for. Takes the container's `id` rather than a ref, because the sheet element belongs to the\n * underlying modal-sheet component; looking it up when a key is pressed finds it however that\n * component chooses to mount it. Focusables are re-queried on every Tab, since the option list\n * changes as the consumer filters it and a list captured on open is a list of dead elements.\n */\nconst useModalKeys = (isOpen: boolean, onClose: () => void, containerId: string) => {\n useEffect(() => {\n if (!isOpen || typeof document === \"undefined\") return;\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n onClose();\n return;\n }\n if (e.key !== \"Tab\") return;\n\n const focusable = document.getElementById(containerId)?.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]),' +\n ' textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n );\n if (!focusable || focusable.length === 0) return;\n\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [isOpen, onClose, containerId]);\n};\n\nconst SelectionViewer: React.FC<SelectionViewerProps> = ({\n id: providedId,\n isOpen,\n historyRoute,\n backDrop = true,\n onClose,\n titleProp,\n searchProp,\n loadingProp,\n noResultProp,\n errorProp,\n cancelButton,\n layoutProp,\n childrenDirection = \"vertical\",\n children,\n onPaginate,\n snapPoints = [0, 1],\n initialSnap = 1,\n unmountOnClose = true,\n zIndex = 1000,\n ariaLabel,\n maxHeight = \"90dvh\",\n minHeight = \"65dvh\",\n selectionState: selectionStateProp = \"initial\",\n closeThreshold = 0.2,\n}) => {\n\n /*\n * THE BACK GESTURE CLOSES THIS, NOT THE PAGE UNDER IT.\n *\n * Only when the consumer named a route: `useOverlayRoute` is a no-op with an empty name, and an\n * overlay that never asked for a history entry must not acquire one, or Back starts meaning\n * something different in an app that did not opt in.\n *\n * The capability lives in its own package rather than here, so that an app wanting a\n * back-closable sheet does not have to take a router with it — and so that a navigation library\n * can supply the history writing without either package importing the other.\n */\n useOverlayRoute(historyRoute ?? '', Boolean(historyRoute) && isOpen, onClose);\n const [id] = useState(() => providedId || `selection-${Math.random().toString(36).substring(2, 11)}`);\n const [searchValue, setSearchValue] = useState(\"\");\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n const [keyboardHeight, setKeyboardHeight] = useState(0);\n const [inputKey, setInputKey] = useState(0);\n const [shouldAutoFocus, setShouldAutoFocus] = useState(false);\n /*\n * The person left search with the arrow. `autoFocus` is for the OPENING only: after this, nothing\n * of ours may put the box back in focus — see `handleBackFromSearch`.\n */\n const leftSearch = useRef(false);\n const isPaginating = useRef(false);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const sheetRef = useRef<any>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n\n useInjectStyles(id);\n // Escape closes the viewer and Tab stays inside it — see useModalKeys.\n useModalKeys(isOpen, onClose, id);\n\n // Descendant sections (a Column, or anything else) can report a cumulative state up through this —\n // starts empty, so a plain SelectionViewer with no Row/Column children behaves exactly as before.\n const [reportedStates, setReportedStates] = useState<Map<string, SelectionState>>(new Map());\n const reportAggregate = useCallback((reporterId: string, state: SelectionState) => {\n setReportedStates((prev) => {\n const next = new Map(prev);\n next.set(reporterId, state);\n return next;\n });\n }, []);\n const unreportAggregate = useCallback((reporterId: string) => {\n setReportedStates((prev) => {\n if (!prev.has(reporterId)) return prev;\n const next = new Map(prev);\n next.delete(reporterId);\n return next;\n });\n }, []);\n const aggregateReporterValue = useMemo(\n () => ({ report: reportAggregate, unreport: unreportAggregate }),\n [reportAggregate, unreportAggregate]\n );\n const reportedAggregate =\n reportedStates.size > 0 ? computeAggregateState(Array.from(reportedStates.values())) : null;\n const isComposed = reportedAggregate !== null;\n\n // Precedence: an explicit `selectionState` prop always wins (matches today's exact behaviour for\n // any consumer not using Row/Column) -> then a reported Column aggregate, if one exists -> \"initial\".\n const selectionState =\n selectionStateProp !== \"initial\" ? selectionStateProp : reportedAggregate ?? \"initial\";\n\n // Track keyboard height\n useEffect(() => {\n if (typeof window === 'undefined' || !window.visualViewport) return;\n\n const handleResize = () => {\n const vp = window.visualViewport!;\n const kbHeight = window.innerHeight - vp.height;\n setKeyboardHeight(kbHeight > 0 ? kbHeight : 0);\n };\n\n window.visualViewport.addEventListener('resize', handleResize);\n window.visualViewport.addEventListener('scroll', handleResize);\n\n return () => {\n window.visualViewport?.removeEventListener('resize', handleResize);\n window.visualViewport?.removeEventListener('scroll', handleResize);\n };\n }, []);\n\n // Auto-focus on search\n useEffect(() => {\n if (!isOpen) {\n searchInputRef.current?.blur();\n setSearchValue(\"\");\n searchProp?.onChange?.(\"\");\n setShouldAutoFocus(false);\n return;\n }\n }, [isOpen, searchProp?.autoFocus]);\n\n/*\n * THE KEYBOARD COMES UP ONCE THE SHEET HAS OPENED — the way a person's own tap on the box does.\n *\n * Nothing is focused while the sheet slides up. When it has opened (`onOpenEnd`) the box, now at\n * the top of the screen, gets a plain focus(): iOS raises the keyboard, the header stays, and the\n * rows sit above the keyboard. This is 0.3.0 / 0.5.0's timing, which academix-web runs.\n *\n * 0.3.1–0.3.3 / 0.5.2–0.5.5 tried to raise the keyboard inside the opening tap instead (the box\n * itself, then an invisible stand-in at the top of the screen). With the keyboard rising while\n * the sheet was still moving, iOS moved the page: the header went off the top and the rows sat\n * under the keyboard, until the person dropped the keyboard and tapped the box again.\n *\n * `autoFocus` is set only here, so a box remounted later (leaving search) does not grab focus.\n * If the sheet never reports that it opened, the box is focused after 1.2s all the same.\n */\n const focusedOnOpen = useRef(false);\n const handleOpenEnd = useCallback(() => {\n if (!searchProp?.autoFocus || !searchInputRef.current || focusedOnOpen.current) return;\n focusedOnOpen.current = true;\n // Left search before the sheet finished opening: that was the person's choice.\n if (leftSearch.current) return;\n setShouldAutoFocus(true);\n searchInputRef.current.focus();\n }, [searchProp?.autoFocus]);\n\n useEffect(() => {\n if (!isOpen) {\n focusedOnOpen.current = false;\n return;\n }\n leftSearch.current = false;\n if (!searchProp?.autoFocus) return;\n const late = setTimeout(handleOpenEnd, 1200);\n return () => clearTimeout(late);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value;\n setSearchValue(value);\n searchProp?.onChange?.(value);\n };\n\n const handleSearchFocus = () => {\n setIsSearchFocused(true);\n searchProp?.onFocus?.();\n requestAnimationFrame(() => {\n searchInputRef.current?.focus();\n });\n };\n\n const handleSearchBlur = () => {\n searchProp?.onBlur?.();\n };\n\n /*\n * THE ARROW LEAVES SEARCH, AND STAYS OUT.\n *\n * Leaving search swaps the full-screen search header for the normal one, and that mounts a NEW\n * search box. It carried `autoFocus` — still true from the opening — so the new box took focus\n * the moment it appeared, focusing it re-entered search mode, and the arrow looked dead: \"we\n * cannot press the back button in the viewer\". Opening is the only time the box focuses itself.\n */\n const handleBackFromSearch = () => {\n leftSearch.current = true;\n setShouldAutoFocus(false);\n setIsSearchFocused(false);\n if (searchInputRef.current) {\n searchInputRef.current.blur();\n }\n };\n\n const clearSearch = () => {\n setSearchValue(\"\");\n searchProp?.onChange?.(\"\");\n if (searchInputRef.current) {\n searchInputRef.current.focus();\n }\n };\n\n /*\n * PAGINATION LISTENS TO WHATEVER ACTUALLY SCROLLS.\n *\n * It listened to `.selection-viewer-content` alone. Inside the sheet that element is not the\n * scroller: react-modal-sheet wraps content in its own `.react-modal-sheet-content-scroller`, the\n * content grows to its full height (4,601px for a hundred rows, measured) and the WRAPPER scrolls.\n * The content box never fired a scroll event, so `onPaginate` was never called — every consumer's\n * list stopped at its first page with nothing to say it had.\n *\n * So the nearest scrolling ancestor is found and listened to, and the content itself as well (for\n * a layout where it is the scroller). And the check also runs when the content changes size: a\n * first page too short to scroll can never produce a scroll event, but it is plainly \"at the\n * bottom\", so it asks for the next one straight away.\n */\n const onPaginateRef = useRef(onPaginate);\n onPaginateRef.current = onPaginate;\n const [contentEl, setContentEl] = useState<HTMLDivElement | null>(null);\n\n const checkNearBottom = useCallback(async (el: HTMLElement) => {\n const paginate = onPaginateRef.current;\n if (isPaginating.current || !paginate) return;\n\n const { scrollTop, scrollHeight, clientHeight } = el;\n const isNearBottom = scrollHeight - scrollTop <= clientHeight * 1.2;\n if (!isNearBottom) return;\n\n isPaginating.current = true;\n const hasMore = await paginate();\n if (!hasMore) {\n isPaginating.current = false;\n } else {\n setTimeout(() => {\n isPaginating.current = false;\n }, 500);\n }\n }, []);\n\n const hasPaginate = Boolean(onPaginate);\n useEffect(() => {\n if (!contentEl || !hasPaginate) return;\n const scroller =\n (contentEl.closest(\".react-modal-sheet-content-scroller\") as HTMLElement | null) ?? contentEl;\n const onScroll = () => void checkNearBottom(scroller);\n const onInnerScroll = () => void checkNearBottom(contentEl);\n\n scroller.addEventListener(\"scroll\", onScroll, { passive: true });\n if (scroller !== contentEl) contentEl.addEventListener(\"scroll\", onInnerScroll, { passive: true });\n\n const resize =\n typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(() => onScroll()) : null;\n resize?.observe(contentEl);\n\n return () => {\n scroller.removeEventListener(\"scroll\", onScroll);\n contentEl.removeEventListener(\"scroll\", onInnerScroll);\n resize?.disconnect();\n };\n }, [contentEl, hasPaginate, checkNearBottom]);\n\n if (!isOpen && unmountOnClose) return null;\n\n return (\n <SelectionViewerAggregateContext.Provider value={aggregateReporterValue}>\n <Sheet\n ref={sheetRef}\n isOpen={isOpen}\n onClose={onClose}\n detent=\"content\"\n style={{ zIndex }}\n maxHeight={maxHeight}\n onOpenEnd={handleOpenEnd}\n >\n <Sheet.Container\n id={id}\n // Announced as a modal dialog. Without this a screen reader reads the sheet as one more\n // region of the page and gives no indication that what is behind it is unavailable — and\n // an automated check for an open dialog finds nothing at all.\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n style={{\n maxHeight: maxHeight,\n minHeight: isSearchFocused ? \"100dvh\" : minHeight,\n maxWidth: layoutProp?.maxWidth ?? '800px',\n margin: \"0 auto\",\n width: \"100%\",\n left: 0,\n right: 0,\n paddingBottom: \"calc(0px + env(safe-area-inset-bottom))\",\n background: isSearchFocused\n ? layoutProp?.fullScreenSearchBackground || layoutProp?.backgroundColor\n : layoutProp?.backgroundColor,\n borderTopLeftRadius: isSearchFocused ? \"0px\" : \"16px\",\n borderTopRightRadius: isSearchFocused ? \"0px\" : \"16px\",\n }}\n >\n {isSearchFocused ? (\n <Sheet.Header>\n <div\n className=\"selection-viewer-fullscreen-search\"\n style={layoutProp?.fullScreenSearchHeaderStyle}\n >\n <div className=\"selection-viewer-search\" style={{\n ...searchProp?.containerStyle,\n background: searchProp?.background,\n padding: searchProp?.padding\n ? `${searchProp.padding.t} ${searchProp.padding.r} ${searchProp.padding.b} ${searchProp.padding.l}`\n : \"16px\"\n }}>\n <button\n className=\"selection-viewer-search-back-button\"\n onClick={handleBackFromSearch}\n aria-label=\"Exit search mode\"\n >\n {searchProp?.backIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M15 18L9 12L15 6\" stroke={searchProp?.textColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n\n <input\n key={inputKey}\n ref={searchInputRef}\n type=\"text\"\n placeholder={searchProp?.text}\n value={searchValue}\n onChange={handleSearchChange}\n className={searchProp?.className || \"selection-viewer-search-input\"}\n style={{\n color: searchProp?.textColor,\n ...searchProp?.inputStyle\n }}\n onFocus={handleSearchFocus}\n onBlur={handleSearchBlur}\n autoFocus={shouldAutoFocus}\n />\n\n {searchValue && (\n <button\n className=\"selection-viewer-search-clear-button\"\n onClick={clearSearch}\n aria-label=\"Clear search\"\n >\n {searchProp?.clearIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 6L6 18M6 6L18 18\" stroke={searchProp?.textColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n )}\n </div>\n </div>\n </Sheet.Header>\n ) : (\n <Sheet.Header>\n <div className=\"selection-viewer-header\">\n {/* Cancel button left */}\n {cancelButton?.position === \"left\" && (\n <button\n aria-label={cancelButton.ariaLabel || \"Close\"}\n className=\"selection-viewer-cancel\"\n style={{\n position: \"absolute\",\n left: \"4px\",\n top: \"4px\",\n ...cancelButton.style\n }}\n onClick={cancelButton.onClick || onClose}\n >\n {cancelButton.view || cancelButton.text || \"Cancel\"}\n </button>\n )}\n\n {/* Drag handle */}\n {!isSearchFocused && (\n <div\n className=\"selection-viewer-drag-handle\"\n style={{\n background: layoutProp?.handleColor || \"#ccc\",\n width: layoutProp?.handleWidth || \"40px\",\n marginBottom: layoutProp?.gapBetweenHandleAndTitle || \"12px\",\n }}\n />\n )}\n\n {/* Cancel button right */}\n {cancelButton?.position === \"right\" && (\n <button\n aria-label={cancelButton.ariaLabel || \"Close\"}\n className=\"selection-viewer-cancel\"\n style={{\n position: \"absolute\",\n right: \"4px\",\n top: \"4px\",\n ...cancelButton.style\n }}\n onClick={cancelButton.onClick || onClose}\n >\n {cancelButton.view || cancelButton.text || \"Cancel\"}\n </button>\n )}\n\n {/* Title */}\n <div className={titleProp.containerClass || \"selection-viewer-container\"}>\n <h2\n id={`${id}-title`}\n className={titleProp.className || \"selection-viewer-title\"}\n style={{\n marginBottom: layoutProp?.gapBetweenTitleAndSearch || \"8px\",\n color: titleProp?.textColor || 'black',\n ...titleProp.style\n }}\n >\n {titleProp.text}\n </h2>\n </div>\n </div>\n\n {/* Search */}\n {searchProp && (\n <div\n className=\"selection-viewer-search\"\n style={{\n background: searchProp.background,\n padding: searchProp.padding\n ? `${searchProp.padding.t} ${searchProp.padding.r} ${searchProp.padding.b} ${searchProp.padding.l}`\n : \"8px 16px\",\n marginBottom: layoutProp?.gapBetweenSearchAndContent,\n ...searchProp.containerStyle\n }}\n >\n {searchProp.prefixIcon && (\n <span style={{ marginRight: searchProp.prefixGap || \"8px\" }}>\n {searchProp.prefixIcon}\n </span>\n )}\n <input\n key={inputKey}\n ref={searchInputRef}\n type=\"text\"\n placeholder={searchProp.text}\n value={searchValue}\n onChange={handleSearchChange}\n className={searchProp.className || \"selection-viewer-search-input\"}\n style={{\n color: searchProp?.textColor,\n ...searchProp.inputStyle\n }}\n onFocus={handleSearchFocus}\n onBlur={handleSearchBlur}\n autoFocus={shouldAutoFocus}\n />\n {searchValue && (\n <button\n className=\"selection-viewer-search-clear-button\"\n onClick={clearSearch}\n aria-label=\"Clear search\"\n style={{ marginLeft: searchProp.suffixGap || \"8px\" }}\n >\n {searchProp.clearIcon || searchProp.suffixIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 6L6 18M6 6L18 18\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n )}\n {!searchValue && searchProp.suffixIcon && (\n <span style={{ marginLeft: searchProp.suffixGap || \"8px\" }}>\n {searchProp.suffixIcon}\n </span>\n )}\n </div>\n )}\n </Sheet.Header>\n )}\n\n <Sheet.Content>\n <div\n ref={setContentEl}\n className={`selection-viewer-content ${childrenDirection}`}\n style={{\n paddingTop: isSearchFocused ? layoutProp?.gapBetweenSearchAndContent : '0',\n paddingBottom: keyboardHeight > 0\n ? `${keyboardHeight + 16}px`\n : '16px',\n /*\n * Set in from the edges, like everything else in the sheet.\n *\n * The title and the search box have carried 16px from the start and the content had\n * none, so a list of rows ran flush into the sides of the screen under a search box\n * that did not. Overridable for rows that genuinely want the full width.\n */\n paddingLeft: layoutProp?.contentPadding ?? '16px',\n paddingRight: layoutProp?.contentPadding ?? '16px',\n }}\n >\n {/* Show children first, then loading at bottom */}\n {React.Children.count(children) > 0 ? (\n <>\n {children}\n {selectionState === \"loading\" && (\n <div\n className=\"selection-viewer-loading\"\n style={{\n padding: loadingProp?.padding\n ? `${loadingProp.padding.t} ${loadingProp.padding.r} ${loadingProp.padding.b} ${loadingProp.padding.l}`\n : \"16px\",\n ...loadingProp?.style\n }}\n >\n {loadingProp?.view}\n </div>\n )}\n {/*\n Shown ALONGSIDE the children, not instead of them.\n\n This was guarded on composed mode — a Column/Row descendant reporting its own\n state — on the reasoning that only a composed sheet can have children and be\n empty at the same time. That is not true of the commonest arrangement there is:\n a consumer that wraps its rows in a single container. `React.Children.count` is\n then 1 whether the container holds fifty rows or none, so the empty branch below\n never ran and the sheet showed a blank white screen — at the exact moment\n somebody had searched for something that is not there, which is when the empty\n state is the only useful thing on screen.\n\n Layered rather than substituted, for the reason the composed case already had:\n a child that reports its own state must stay mounted to go on reporting. A\n consumer whose `selectionState` says \"empty\" is asserting there is nothing to\n show, so drawing its own view beside visually-empty children is what it asked\n for.\n */}\n {selectionState === \"empty\" && (\n <div\n className=\"selection-viewer-no-results\"\n style={{\n padding: noResultProp?.padding\n ? `${noResultProp.padding.t} ${noResultProp.padding.r} ${noResultProp.padding.b} ${noResultProp.padding.l}`\n : \"16px\",\n ...noResultProp?.style\n }}\n >\n {noResultProp?.view || (\n <div className=\"selection-viewer-default-no-results\">\n {noResultProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n )}\n {selectionState === \"error\" && (\n <div\n className=\"selection-viewer-error\"\n style={{\n padding: errorProp?.padding\n ? `${errorProp.padding.t} ${errorProp.padding.r} ${errorProp.padding.b} ${errorProp.padding.l}`\n : \"16px\",\n ...errorProp?.style\n }}\n >\n {errorProp?.view || (\n <div className=\"selection-viewer-default-error\">\n {errorProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n )}\n </>\n ) : (selectionState === \"empty\" || (React.Children.count(children) <= 0 && (selectionState != \"loading\" && selectionState != \"error\"))) ? (\n <div\n className=\"selection-viewer-no-results\"\n style={{\n padding: noResultProp?.padding\n ? `${noResultProp.padding.t} ${noResultProp.padding.r} ${noResultProp.padding.b} ${noResultProp.padding.l}`\n : \"16px\",\n ...noResultProp?.style\n }}\n >\n {noResultProp?.view || (\n <div className=\"selection-viewer-default-no-results\">\n {noResultProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n ) : selectionState === \"loading\" ? (\n <div\n className=\"selection-viewer-loading\"\n style={{\n padding: loadingProp?.padding\n ? `${loadingProp.padding.t} ${loadingProp.padding.r} ${loadingProp.padding.b} ${loadingProp.padding.l}`\n : \"16px\",\n ...loadingProp?.style\n }}\n >\n {loadingProp?.view}\n </div>\n ) : (selectionState === \"error\") ? (\n <div\n className=\"selection-viewer-error\"\n style={{\n padding: errorProp?.padding\n ? `${errorProp.padding.t} ${errorProp.padding.r} ${errorProp.padding.b} ${errorProp.padding.l}`\n : \"16px\",\n ...errorProp?.style\n }}\n >\n {errorProp?.view || (\n <div className=\"selection-viewer-default-error\">\n {errorProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n ) : null}\n </div>\n </Sheet.Content>\n </Sheet.Container>\n <Sheet.Backdrop onTap={backDrop ? onClose : undefined} />\n </Sheet>\n </SelectionViewerAggregateContext.Provider>\n );\n};\n\n// ==================== Controller Hook ====================\ntype Operation = {\n open: () => void;\n close: () => void;\n toggle: () => void;\n setSelectionState: (val: SelectionState) => void;\n};\n\nconst useSelectionController = (initialSelectionState?: SelectionState): [\n string,\n Operation,\n boolean,\n SelectionState\n] => {\n const [isOpen, setIsOpen] = useState(false);\n const [selectionState, setSelectionState] = useState(initialSelectionState || 'initial');\n const [selectionId] = useState(() => `selection-${Math.random().toString(36).substring(2, 11)}`);\n\n const operations = useMemo<Operation>(() => ({\n open: () => setIsOpen(true),\n close: () => setIsOpen(false),\n toggle: () => setIsOpen((prev) => !prev),\n setSelectionState\n }), [setSelectionState]);\n\n return [selectionId, operations, isOpen, selectionState];\n};\n\nexport { SelectionViewer, useSelectionController, RowAggregateContext, SelectionViewerAggregateContext, computeAggregateState };\nexport type {\n SelectionViewerProps,\n SelectionState,\n TitleProps,\n SearchProps,\n LoadingProps,\n NoResultProps,\n ErrorProps,\n CancelButtonProps,\n LayoutProps,\n Padding,\n SnapPoint,\n AggregateReporter,\n};\nexport default SelectionViewer;\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { RowAggregateContext } from \"./SelectionViewer\";\nimport type { SelectionState } from \"./SelectionViewer\";\n\nexport type RowProps = {\n id?: string;\n /** Consumer-owned — SelectionViewer has never owned fetch/filter state, so unlike\n * search-viewer's Row this isn't internally computed. Mirrors how `selectionState`\n * is already a prop on SelectionViewer itself today. Defaults to \"data\": if you\n * render children without wiring this, we assume what you rendered IS the data. */\n state?: SelectionState;\n /** Called when this Row is scrolled horizontally near its end. Return (or resolve to)\n * `true` if more data may follow (keeps the pagination trigger armed), `false` once\n * there's nothing left to fetch — mirrors SelectionViewer's own `onPaginate` contract. */\n onPaginate?: () => boolean | Promise<boolean>;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n/** A horizontally-scrolling, independently-paginating section — the Row/Column\n * equivalent for `SelectionViewer`. No shared code with `@academix-admin/search-viewer`'s\n * Row (Library Charter: packages stay mutually independent) — this one has no\n * query/debounce/cache engine of its own since `SelectionViewer` never had one either;\n * the consumer owns fetching/filtering and just tells this Row what `state` it's in. */\nfunction Row({ id: providedId, state = \"data\", onPaginate, className, style, children }: RowProps) {\n const aggregateReporter = React.useContext(RowAggregateContext);\n const [rowId] = useState(() => providedId || `row-${Math.random().toString(36).substring(2, 11)}`);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const isPaginating = useRef(false);\n\n const handleScroll = useCallback(async () => {\n const el = containerRef.current;\n if (!el || isPaginating.current || !onPaginate) return;\n\n // Same \"near the end\" threshold as SelectionViewer's own vertical pagination trigger, adapted\n // to horizontal scroll metrics since a Row scrolls sideways.\n const { scrollLeft, scrollWidth, clientWidth } = el;\n if (scrollWidth - scrollLeft > clientWidth * 1.2) return;\n\n isPaginating.current = true;\n const hasMore = await onPaginate();\n if (!hasMore) {\n isPaginating.current = false;\n } else {\n setTimeout(() => {\n isPaginating.current = false;\n }, 500);\n }\n }, [onPaginate]);\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el || !onPaginate) return;\n el.addEventListener(\"scroll\", handleScroll);\n return () => el.removeEventListener(\"scroll\", handleScroll);\n }, [handleScroll, onPaginate]);\n\n useEffect(() => {\n aggregateReporter?.report(rowId, state);\n return () => aggregateReporter?.unreport(rowId);\n }, [aggregateReporter, rowId, state]);\n\n return (\n <div\n ref={containerRef}\n className={className ? `selection-viewer-row ${className}` : \"selection-viewer-row\"}\n style={{\n display: \"flex\",\n flexDirection: \"row\",\n gap: \"8px\",\n overflowX: \"auto\",\n overflowY: \"hidden\",\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n\nRow.displayName = \"Row\";\n\nexport { Row };\n","import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { RowAggregateContext, SelectionViewerAggregateContext, computeAggregateState } from \"./SelectionViewer\";\nimport type { SelectionState } from \"./SelectionViewer\";\n\nexport type ColumnProps = {\n id?: string;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n/** A vertical arrangement of `Row`s (or other content) — the explicit, composable\n * equivalent of today's flat `children` list. Its default layout is deliberately\n * identical to the existing `.selection-viewer-content.vertical` rendering\n * (`flex-direction: column, gap: 8px`), so today's flat usage is, unchanged, \"an\n * implicit Column with no Rows.\"\n *\n * Provides the `RowAggregateContext` its `Row` children report into, computes ONE\n * cumulative state from everything reported, and is itself a reporter one level up:\n * nested inside another `Column` it reports through that Column's `RowAggregateContext`\n * (behaving like a Row); at the top level it reports through `SelectionViewerAggregateContext`,\n * which `SelectionViewer` provides — this drives the outer sheet's loading/empty/error\n * views automatically with zero manual wiring, and lets Columns nest arbitrarily deep. */\nfunction Column({ id: providedId, className, style, children }: ColumnProps) {\n const [columnId] = useState(\n () => providedId || `column-${Math.random().toString(36).substring(2, 11)}`\n );\n\n const [reportedStates, setReportedStates] = useState<Map<string, SelectionState>>(new Map());\n const report = useCallback((id: string, state: SelectionState) => {\n setReportedStates((prev) => {\n const next = new Map(prev);\n next.set(id, state);\n return next;\n });\n }, []);\n const unreport = useCallback((id: string) => {\n setReportedStates((prev) => {\n if (!prev.has(id)) return prev;\n const next = new Map(prev);\n next.delete(id);\n return next;\n });\n }, []);\n const rowAggregateValue = useMemo(() => ({ report, unreport }), [report, unreport]);\n\n const aggregateState =\n reportedStates.size > 0 ? computeAggregateState(Array.from(reportedStates.values())) : \"initial\";\n\n const parentRowAggregate = React.useContext(RowAggregateContext);\n const selectionViewerAggregate = React.useContext(SelectionViewerAggregateContext);\n const upstreamReporter = parentRowAggregate ?? selectionViewerAggregate;\n\n useEffect(() => {\n if (!upstreamReporter) return;\n upstreamReporter.report(columnId, aggregateState);\n return () => upstreamReporter.unreport(columnId);\n }, [upstreamReporter, columnId, aggregateState]);\n\n return (\n <RowAggregateContext.Provider value={rowAggregateValue}>\n <div\n className={className ? `selection-viewer-column ${className}` : \"selection-viewer-column\"}\n style={{ display: \"flex\", flexDirection: \"column\", gap: \"8px\", ...style }}\n >\n {children}\n </div>\n </RowAggregateContext.Provider>\n );\n}\n\nColumn.displayName = \"Column\";\n\nexport { Column };\n"]}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import React, { useState, useRef, useCallback, useMemo, useEffect, useLayoutEffect } from 'react';
2
+ import React, { useState, useRef, useCallback, useMemo, useEffect } from 'react';
3
3
  import { Sheet } from '@academix-admin/modal-sheet';
4
4
  import { useOverlayRoute } from '@academix-admin/overlay-route';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -263,58 +263,6 @@ var useModalKeys = (isOpen, onClose, containerId) => {
263
263
  return () => document.removeEventListener("keydown", onKeyDown);
264
264
  }, [isOpen, onClose, containerId]);
265
265
  };
266
- function focusWithNativeScroll(input) {
267
- if (typeof document === "undefined") return;
268
- if (document.activeElement === input) {
269
- const bounce = document.createElement("input");
270
- bounce.setAttribute("aria-hidden", "true");
271
- bounce.tabIndex = -1;
272
- bounce.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;font-size:16px;border:0;padding:0;pointer-events:none;";
273
- document.body.appendChild(bounce);
274
- bounce.focus({ preventScroll: true });
275
- input.focus();
276
- bounce.remove();
277
- return;
278
- }
279
- input.focus();
280
- }
281
- function focusWhenMounted(getInput) {
282
- if (typeof document === "undefined") return () => {
283
- };
284
- const now = getInput();
285
- if (now) {
286
- now.focus({ preventScroll: true });
287
- return () => {
288
- };
289
- }
290
- const proxy = document.createElement("input");
291
- proxy.setAttribute("aria-hidden", "true");
292
- proxy.tabIndex = -1;
293
- proxy.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;font-size:16px;border:0;padding:0;pointer-events:none;";
294
- document.body.appendChild(proxy);
295
- proxy.focus({ preventScroll: true });
296
- let stopped = false;
297
- const started = Date.now();
298
- const hand = () => {
299
- if (stopped) return;
300
- const input = getInput();
301
- if (input) {
302
- input.focus();
303
- proxy.remove();
304
- return;
305
- }
306
- if (Date.now() - started > 1500) {
307
- proxy.remove();
308
- return;
309
- }
310
- requestAnimationFrame(hand);
311
- };
312
- requestAnimationFrame(hand);
313
- return () => {
314
- stopped = true;
315
- proxy.remove();
316
- };
317
- }
318
266
  var SelectionViewer = ({
319
267
  id: providedId,
320
268
  isOpen,
@@ -400,19 +348,24 @@ var SelectionViewer = ({
400
348
  return;
401
349
  }
402
350
  }, [isOpen, searchProp?.autoFocus]);
403
- useLayoutEffect(() => {
404
- if (!isOpen) return;
405
- leftSearch.current = false;
406
- if (!searchProp?.autoFocus) return;
407
- setShouldAutoFocus(true);
408
- return focusWhenMounted(() => searchInputRef.current);
409
- }, [isOpen]);
351
+ const focusedOnOpen = useRef(false);
410
352
  const handleOpenEnd = useCallback(() => {
411
- if (!searchProp?.autoFocus || !searchInputRef.current) return;
353
+ if (!searchProp?.autoFocus || !searchInputRef.current || focusedOnOpen.current) return;
354
+ focusedOnOpen.current = true;
412
355
  if (leftSearch.current) return;
413
356
  setShouldAutoFocus(true);
414
- focusWithNativeScroll(searchInputRef.current);
357
+ searchInputRef.current.focus();
415
358
  }, [searchProp?.autoFocus]);
359
+ useEffect(() => {
360
+ if (!isOpen) {
361
+ focusedOnOpen.current = false;
362
+ return;
363
+ }
364
+ leftSearch.current = false;
365
+ if (!searchProp?.autoFocus) return;
366
+ const late = setTimeout(handleOpenEnd, 1200);
367
+ return () => clearTimeout(late);
368
+ }, [isOpen]);
416
369
  const handleSearchChange = (e) => {
417
370
  const value = e.target.value;
418
371
  setSearchValue(value);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/SelectionViewer.tsx","../src/Row.tsx","../src/Column.tsx"],"names":["React","useState","useRef","useCallback","useEffect","jsx","useMemo"],"mappings":";;;;;;AAcA,IAAM,mBAAA,GAAsB,KAAA,CAAM,aAAA,CAAwC,IAAI;AAI9E,IAAM,+BAAA,GAAkC,KAAA,CAAM,aAAA,CAAwC,IAAI;AAE1F,SAAS,sBAAsB,MAAA,EAA0C;AACvE,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,SAAA;AAChC,EAAA,IAAI,OAAO,IAAA,CAAK,CAAC,MAAM,CAAA,KAAM,MAAM,GAAG,OAAO,MAAA;AAC7C,EAAA,IAAI,OAAO,IAAA,CAAK,CAAC,MAAM,CAAA,KAAM,SAAS,GAAG,OAAO,SAAA;AAChD,EAAA,IAAI,OAAO,KAAA,CAAM,CAAC,MAAM,CAAA,KAAM,OAAO,GAAG,OAAO,OAAA;AAC/C,EAAA,IAAI,OAAO,IAAA,CAAK,CAAC,MAAM,CAAA,KAAM,OAAO,GAAG,OAAO,OAAA;AAC9C,EAAA,OAAO,SAAA;AACT;AAiJA,IAAM,SAAA,GAAY,CAAC,EAAA,KAAe;AAAA,CAAA,EAC/B,EAAE,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,EAsBF,EAAE,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,MAAM,wBAAA,GAA2BA,KAAAA,CAAM,UAAA,CAAW,+BAA+B,CAAA;AACjF,EAAA,MAAM,mBAAmB,kBAAA,IAAsB,wBAAA;AAE/C,EAAAI,UAAU,MAAM;AACd,IAAA,IAAI,CAAC,gBAAA,EAAkB;AACvB,IAAA,gBAAA,CAAiB,MAAA,CAAO,UAAU,cAAc,CAAA;AAChD,IAAA,OAAO,MAAM,gBAAA,CAAiB,QAAA,CAAS,QAAQ,CAAA;AAAA,EACjD,CAAA,EAAG,CAAC,gBAAA,EAAkB,QAAA,EAAU,cAAc,CAAC,CAAA;AAE/C,EAAA,uBACEC,GAAAA,CAAC,mBAAA,CAAoB,UAApB,EAA6B,KAAA,EAAO,mBACnC,QAAA,kBAAAA,GAAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,SAAA,GAAY,CAAA,wBAAA,EAA2B,SAAS,CAAA,CAAA,GAAK,yBAAA;AAAA,MAChE,KAAA,EAAO,EAAE,OAAA,EAAS,MAAA,EAAQ,eAAe,QAAA,EAAU,GAAA,EAAK,KAAA,EAAO,GAAG,KAAA,EAAM;AAAA,MAEvE;AAAA;AAAA,GACH,EACF,CAAA;AAEJ;AAEA,MAAA,CAAO,WAAA,GAAc,QAAA","file":"index.js","sourcesContent":["import React, { useState, useEffect, useCallback, useRef, useMemo, useLayoutEffect } from \"react\";\nimport { Sheet } from \"@academix-admin/modal-sheet\";\nimport { useOverlayRoute } from '@academix-admin/overlay-route';\n\n// ==================== Aggregation (Row/Column) ====================\n// Independent from @academix-admin/search-viewer's equivalent (Library Charter: packages stay\n// mutually independent) — same shape, duplicated intentionally rather than shared.\n\ntype AggregateReporter = {\n report: (id: string, state: SelectionState) => void;\n unreport: (id: string) => void;\n};\n\n/** A `Row` reports its own `state` into the nearest `Column` through this. */\nconst RowAggregateContext = React.createContext<AggregateReporter | null>(null);\n\n/** `Column` reports its own aggregated state up through this — `SelectionViewer` provides it and\n * merges whatever's reported into its own selectionState resolution, with zero extra wiring. */\nconst SelectionViewerAggregateContext = React.createContext<AggregateReporter | null>(null);\n\nfunction computeAggregateState(states: SelectionState[]): SelectionState {\n if (states.length === 0) return \"initial\";\n if (states.some((s) => s === \"data\")) return \"data\";\n if (states.some((s) => s === \"loading\")) return \"loading\";\n if (states.every((s) => s === \"empty\")) return \"empty\";\n if (states.some((s) => s === \"error\")) return \"error\";\n return \"initial\";\n}\n\n// ==================== Types ====================\ntype Padding = {\n l: string;\n r: string;\n t: string;\n b: string;\n};\n\ntype SnapPoint = number;\n\ntype SelectionState = \"loading\" | \"empty\" | \"error\" | \"data\" | \"initial\";\n\n\ntype TitleProps = {\n text: string;\n textColor: string;\n className?: string;\n containerClass?: string;\n style?: React.CSSProperties;\n};\n\ntype SearchProps = {\n text: string;\n textColor: string;\n className?: string;\n background?: string;\n prefixIcon?: React.ReactNode;\n suffixIcon?: React.ReactNode;\n clearIcon?: React.ReactNode;\n backIcon?: React.ReactNode;\n prefixGap?: string;\n suffixGap?: string;\n padding?: Padding;\n autoFocus?: boolean;\n inputStyle?: React.CSSProperties;\n containerStyle?: React.CSSProperties;\n onChange?: (value: string) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n};\n\ntype LoadingProps = {\n view: React.ReactNode;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype NoResultProps = {\n view: React.ReactNode;\n text?: string;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype ErrorProps = {\n view: React.ReactNode;\n text?: string;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype CancelButtonProps = {\n text?: string;\n view: React.ReactNode;\n position?: \"left\" | \"right\";\n style?: React.CSSProperties;\n onClick?: () => void;\n /**\n * What a screen reader calls it. Defaults to \"Close\".\n *\n * A button whose only content is an icon has no accessible name at all, so it was announced as\n * just \"button\" — the one control that dismisses the sheet, and nothing said so.\n */\n ariaLabel?: string;\n};\n\ntype LayoutProps = {\n gapBetweenHandleAndTitle?: string;\n gapBetweenTitleAndSearch?: string;\n gapBetweenSearchAndContent?: string;\n /**\n * How far the rows are set in from the sides. Defaults to `16px`, matching the search box.\n *\n * The content had no inset while everything above it had 16px, so a list ran flush into the\n * sides of the screen under a search box that did not. Pass `0px` for rows that should reach\n * the edges.\n */\n contentPadding?: string;\n backgroundColor?: string;\n handleColor?: string;\n handleWidth?: string;\n fullScreenSearchBackground?: string;\n fullScreenSearchHeaderStyle?: React.CSSProperties;\n maxWidth?: string;\n};\n\ntype SelectionViewerProps = {\n id?: string;\n isOpen: boolean;\n backDrop?: boolean;\n onClose: () => void;\n /**\n * Give this overlay its own history entry under this name, so the platform's own Back (and the\n * iOS edge-swipe, and Android's gesture) closes the OVERLAY rather than the page under it.\n *\n * Off by default, because it changes what the back gesture does and no existing consumer asked\n * for that. Without it, Back with this open closes it AND leaves the page behind it: measured in\n * a real shop, the gesture walked straight out of a half-built sale.\n *\n * The name must be unique among overlays that can be open together, or they mistake each other's\n * entry. Make it STABLE across page loads and the overlay can also come back after a refresh —\n * see `useOverlayRoute` in `@academix-admin/overlay-route`, which this uses and which any\n * component can use directly.\n */\n historyRoute?: string;\n titleProp: TitleProps;\n searchProp?: SearchProps;\n loadingProp?: LoadingProps;\n noResultProp?: NoResultProps;\n errorProp?: ErrorProps;\n cancelButton?: CancelButtonProps;\n layoutProp?: LayoutProps;\n childrenDirection?: \"vertical\" | \"horizontal\";\n children?: React.ReactNode;\n onPaginate?: () => boolean | Promise<boolean>;\n snapPoints?: SnapPoint[];\n initialSnap?: number;\n unmountOnClose?: boolean;\n zIndex?: number;\n /**\n * Accessible name for the sheet, announced when it opens.\n *\n * A modal with no name is announced simply as \"dialog\", which tells a screen-reader user that\n * something has taken over the screen and nothing at all about what.\n */\n ariaLabel?: string;\n maxHeight?: string;\n minHeight?: string;\n selectionState?: SelectionState;\n closeThreshold?: number;\n};\n\n// ==================== Styles ====================\nconst getStyles = (id: string) => `\n#${id} .selection-viewer-header {\n padding: 0px;\n display: flex;\n flex-direction: column;\n align-items: center;\n position: relative;\n width: 100%;\n}\n\n/*\n * The close button, with a target a thumb can find.\n *\n * It sat at right: 0, top: 8 with no padding at all, so the icon was flush against the sheet's\n * edge and the only thing that could be tapped was the glyph itself — a target well under half\n * what a finger needs, in the corner of the screen where a thumb is least accurate. Inset by 4px\n * and padded out to 44px square, so the icon still reads as sitting in the corner while the\n * hittable area reaches the edges.\n *\n * The cancelButton.style prop is still spread last at the call site, so a consumer that was\n * overriding any of this keeps overriding it. (No backticks in here: this whole block lives\n * inside a template literal, and one would end the string.)\n */\n#${id} .selection-viewer-cancel {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 44px;\n min-height: 44px;\n padding: 10px;\n border: none;\n background-color: transparent;\n color: inherit;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n\n#${id} .selection-viewer-drag-handle {\n height: 5px;\n border-radius: 3px;\n margin-top: 16px;\n}\n\n#${id} .selection-viewer-container {\n display: flex;\n align-items: flex-start;\n width: 100%;\n}\n\n#${id} .selection-viewer-title {\n margin: 0px;\n font-size: 18px;\n font-weight: 600;\n padding: 0px 16px 0px 16px;\n word-break: break-word; /* break long words */\n white-space: normal; /* allow wrapping */\n}\n\n#${id} .selection-viewer-search {\n display: flex;\n align-items: center;\n margin: 16px 16px 4px 16px;\n border-radius: 12px;\n box-sizing: border-box;\n border: 1px solid rgba(0, 0, 0, 0.1);\n}\n\n#${id} .selection-viewer-search-input {\n flex: 1;\n border: none;\n background: transparent;\n padding: 12px 8px;\n outline: none;\n font-size: 16px !important;\n width: 100%;\n}\n\n/*\n * The rows, set in from the edges like everything else in the sheet.\n *\n * The title and the search box have carried a 16px margin from the start; the content had none, so\n * a list of cards ran flush into the sides of the screen while the search box above it did not.\n * The layoutProp.contentPadding option overrides it for a consumer that wants its rows edge to\n * edge. (No backticks: this block is inside a template literal.)\n */\n#${id} .selection-viewer-content {\n overflow-y: auto;\n -webkit-overflow-scrolling: touch;\n flex: 1;\n min-height: 0;\n box-sizing: border-box;\n}\n\n#${id} .selection-viewer-content.vertical {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n#${id} .selection-viewer-content.horizontal {\n display: flex;\n flex-direction: row;\n gap: 8px;\n overflow-x: auto;\n overflow-y: hidden;\n}\n\n#${id} .selection-viewer-no-results,\n#${id} .selection-viewer-error,\n#${id} .selection-viewer-loading {\n display: flex;\n justify-content: center;\n align-items: center;\n min-height: 120px;\n}\n\n#${id} .selection-viewer-default-no-results {\n color: #666;\n font-size: 14px;\n}\n\n#${id} .selection-viewer-default-error {\n color: red;\n font-size: 14px;\n}\n\n/* Full screen search mode */\n#${id} .selection-viewer-fullscreen-search {\n// position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 10;\n// padding-top: env(safe-area-inset-top);\n width: 100%;\n}\n\n#${id} .selection-viewer-search-back-button {\n background: none;\n border: none;\n padding: 8px;\n margin-right: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n#${id} .selection-viewer-search-back-button:hover {\n opacity: 0.7;\n}\n\n#${id} .selection-viewer-search-clear-button {\n background: none;\n border: none;\n padding: 8px;\n margin-left: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n#${id} .selection-viewer-search-clear-button:hover {\n opacity: 0.7;\n}\n\n/* React Modal Sheet overrides */\n#${id} .react-modal-sheet-container {\n max-width: 500px;\n margin: 0 auto;\n border-top-left-radius: 16px;\n border-top-right-radius: 16px;\n}\n\n#${id} .react-modal-sheet-backdrop {\n background-color: rgba(0, 0, 0, 0.5) !important;\n pointer-events: auto !important;\n}\n\n#${id} .react-modal-sheet-content {\n padding: 0 0px 0px 0px;\n height: 100%;\n}\n\n\n/* Mobile full-width behavior */\n@media (max-width: 500px) {\n #${id} .react-modal-sheet-container {\n max-width: 100%;\n border-radius: 0;\n }\n}\n\n/* Prevent iOS zooming */\n@media screen and (-webkit-min-device-pixel-ratio: 0) {\n #${id} .selection-viewer-search-input {\n font-size: 16px !important;\n }\n}\n`;\n\n// ==================== Hook to inject CSS per instance ====================\nconst useInjectStyles = (id: string) => {\n useEffect(() => {\n const styleId = `selection-viewer-styles-${id}`;\n let styleTag = document.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleTag) {\n styleTag = document.createElement(\"style\");\n styleTag.id = styleId;\n styleTag.innerHTML = getStyles(id);\n document.head.appendChild(styleTag);\n }\n\n // Cleanup on unmount\n return () => {\n if (styleTag && document.head.contains(styleTag)) {\n document.head.removeChild(styleTag);\n }\n };\n }, [id]);\n};\n\n// ==================== Component ====================\n/**\n * Escape closes the viewer, and Tab stays inside it.\n *\n * The viewer covers the screen, so what is behind it is not available — but nothing said so to the\n * keyboard. Tab walked out of the option list into the page underneath, where a person was\n * operating controls they could not see, and Escape did nothing at all, which is the one key\n * everybody reaches for to get out of a picker.\n *\n * Deliberately a private copy rather than an import from a sibling package: every library here\n * stands alone, and a shared helper between two of them is a dependency the consumer did not ask\n * for. Takes the container's `id` rather than a ref, because the sheet element belongs to the\n * underlying modal-sheet component; looking it up when a key is pressed finds it however that\n * component chooses to mount it. Focusables are re-queried on every Tab, since the option list\n * changes as the consumer filters it and a list captured on open is a list of dead elements.\n */\nconst useModalKeys = (isOpen: boolean, onClose: () => void, containerId: string) => {\n useEffect(() => {\n if (!isOpen || typeof document === \"undefined\") return;\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n onClose();\n return;\n }\n if (e.key !== \"Tab\") return;\n\n const focusable = document.getElementById(containerId)?.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]),' +\n ' textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n );\n if (!focusable || focusable.length === 0) return;\n\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [isOpen, onClose, containerId]);\n};\n\n/**\n * RAISE THE KEYBOARD INSIDE THE TAP, then hand it to the real box.\n *\n * iOS shows the keyboard only for a focus made while the user's own tap is still being handled.\n * The sheet mounts its search box a frame or more after it opens, so at the moment of the tap there\n * is no box to focus — and by the time there is, the tap is over and iOS will focus it silently,\n * with no keyboard. The standard way through: focus an invisible stand-in input synchronously (the\n * keyboard rises for it), then move focus to the real box the moment it exists — iOS keeps a raised\n * keyboard up when focus moves from one input to another in script. The stand-in is removed at once.\n *\n * `font-size: 16px` so iOS does not zoom the page to it.\n */\n/**\n * FOCUS THE BOX THE WAY A PLAIN focus() DID — native scroll included.\n *\n * Before 0.3.1 / 0.5.2 the box was focused once the sheet had opened, with a plain `focus()`, and\n * that is what made the sheet behave: iOS scrolls a newly focused box into view with the keyboard\n * accounted for, which pushed the header away and left the results showing above the keyboard. The\n * 0.3.1 / 0.5.2 fix (focus inside the tap, so the keyboard rises at all) focused with\n * `preventScroll: true`, and that scroll never happened again — the header stayed and the rows sat\n * under the keyboard.\n *\n * A box that ALREADY has focus is not scrolled by focusing it again, so focus is bounced through a\n * stand-in and back: moving focus from one input to another keeps the keyboard up on iOS, and the\n * real box, newly focused, gets the browser's own keyboard-aware scroll.\n */\nfunction focusWithNativeScroll(input: HTMLInputElement): void {\n if (typeof document === \"undefined\") return;\n if (document.activeElement === input) {\n const bounce = document.createElement(\"input\");\n bounce.setAttribute(\"aria-hidden\", \"true\");\n bounce.tabIndex = -1;\n bounce.style.cssText =\n \"position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;font-size:16px;border:0;padding:0;pointer-events:none;\";\n document.body.appendChild(bounce);\n bounce.focus({ preventScroll: true });\n input.focus();\n bounce.remove();\n return;\n }\n input.focus();\n}\n\nfunction focusWhenMounted(getInput: () => HTMLInputElement | null): () => void {\n if (typeof document === \"undefined\") return () => {};\n const now = getInput();\n if (now) {\n now.focus({ preventScroll: true });\n return () => {};\n }\n const proxy = document.createElement(\"input\");\n proxy.setAttribute(\"aria-hidden\", \"true\");\n proxy.tabIndex = -1;\n proxy.style.cssText =\n \"position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;font-size:16px;border:0;padding:0;pointer-events:none;\";\n document.body.appendChild(proxy);\n proxy.focus({ preventScroll: true });\n\n let stopped = false;\n const started = Date.now();\n const hand = () => {\n if (stopped) return;\n const input = getInput();\n if (input) {\n // A plain focus, so the browser scrolls the box into view as it always did (see above).\n input.focus();\n proxy.remove();\n return;\n }\n if (Date.now() - started > 1500) {\n proxy.remove();\n return;\n }\n requestAnimationFrame(hand);\n };\n requestAnimationFrame(hand);\n return () => {\n stopped = true;\n proxy.remove();\n };\n}\n\nconst SelectionViewer: React.FC<SelectionViewerProps> = ({\n id: providedId,\n isOpen,\n historyRoute,\n backDrop = true,\n onClose,\n titleProp,\n searchProp,\n loadingProp,\n noResultProp,\n errorProp,\n cancelButton,\n layoutProp,\n childrenDirection = \"vertical\",\n children,\n onPaginate,\n snapPoints = [0, 1],\n initialSnap = 1,\n unmountOnClose = true,\n zIndex = 1000,\n ariaLabel,\n maxHeight = \"90dvh\",\n minHeight = \"65dvh\",\n selectionState: selectionStateProp = \"initial\",\n closeThreshold = 0.2,\n}) => {\n\n /*\n * THE BACK GESTURE CLOSES THIS, NOT THE PAGE UNDER IT.\n *\n * Only when the consumer named a route: `useOverlayRoute` is a no-op with an empty name, and an\n * overlay that never asked for a history entry must not acquire one, or Back starts meaning\n * something different in an app that did not opt in.\n *\n * The capability lives in its own package rather than here, so that an app wanting a\n * back-closable sheet does not have to take a router with it — and so that a navigation library\n * can supply the history writing without either package importing the other.\n */\n useOverlayRoute(historyRoute ?? '', Boolean(historyRoute) && isOpen, onClose);\n const [id] = useState(() => providedId || `selection-${Math.random().toString(36).substring(2, 11)}`);\n const [searchValue, setSearchValue] = useState(\"\");\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n const [keyboardHeight, setKeyboardHeight] = useState(0);\n const [inputKey, setInputKey] = useState(0);\n const [shouldAutoFocus, setShouldAutoFocus] = useState(false);\n /*\n * The person left search with the arrow. `autoFocus` is for the OPENING only: after this, nothing\n * of ours may put the box back in focus — see `handleBackFromSearch`.\n */\n const leftSearch = useRef(false);\n const isPaginating = useRef(false);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const sheetRef = useRef<any>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n\n useInjectStyles(id);\n // Escape closes the viewer and Tab stays inside it — see useModalKeys.\n useModalKeys(isOpen, onClose, id);\n\n // Descendant sections (a Column, or anything else) can report a cumulative state up through this —\n // starts empty, so a plain SelectionViewer with no Row/Column children behaves exactly as before.\n const [reportedStates, setReportedStates] = useState<Map<string, SelectionState>>(new Map());\n const reportAggregate = useCallback((reporterId: string, state: SelectionState) => {\n setReportedStates((prev) => {\n const next = new Map(prev);\n next.set(reporterId, state);\n return next;\n });\n }, []);\n const unreportAggregate = useCallback((reporterId: string) => {\n setReportedStates((prev) => {\n if (!prev.has(reporterId)) return prev;\n const next = new Map(prev);\n next.delete(reporterId);\n return next;\n });\n }, []);\n const aggregateReporterValue = useMemo(\n () => ({ report: reportAggregate, unreport: unreportAggregate }),\n [reportAggregate, unreportAggregate]\n );\n const reportedAggregate =\n reportedStates.size > 0 ? computeAggregateState(Array.from(reportedStates.values())) : null;\n const isComposed = reportedAggregate !== null;\n\n // Precedence: an explicit `selectionState` prop always wins (matches today's exact behaviour for\n // any consumer not using Row/Column) -> then a reported Column aggregate, if one exists -> \"initial\".\n const selectionState =\n selectionStateProp !== \"initial\" ? selectionStateProp : reportedAggregate ?? \"initial\";\n\n // Track keyboard height\n useEffect(() => {\n if (typeof window === 'undefined' || !window.visualViewport) return;\n\n const handleResize = () => {\n const vp = window.visualViewport!;\n const kbHeight = window.innerHeight - vp.height;\n setKeyboardHeight(kbHeight > 0 ? kbHeight : 0);\n };\n\n window.visualViewport.addEventListener('resize', handleResize);\n window.visualViewport.addEventListener('scroll', handleResize);\n\n return () => {\n window.visualViewport?.removeEventListener('resize', handleResize);\n window.visualViewport?.removeEventListener('scroll', handleResize);\n };\n }, []);\n\n // Auto-focus on search\n useEffect(() => {\n if (!isOpen) {\n searchInputRef.current?.blur();\n setSearchValue(\"\");\n searchProp?.onChange?.(\"\");\n setShouldAutoFocus(false);\n return;\n }\n }, [isOpen, searchProp?.autoFocus]);\n\n /*\n * THE KEYBOARD COMES UP WITH THE SHEET — on iOS too. See search-viewer's `useSearchInput`: the\n * focus is made in a layout effect while the opening tap is still being handled, which is the only\n * focus iOS answers with a keyboard. It used to wait for the open animation and remount the input\n * first, so the focus landed on a discarded element, after the tap, and no keyboard rose.\n */\n useLayoutEffect(() => {\n if (!isOpen) return;\n leftSearch.current = false;\n if (!searchProp?.autoFocus) return;\n setShouldAutoFocus(true);\n return focusWhenMounted(() => searchInputRef.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n const handleOpenEnd = useCallback(() => {\n if (!searchProp?.autoFocus || !searchInputRef.current) return;\n // Left search before the sheet finished opening: that was the person's choice, not a lost focus.\n if (leftSearch.current) return;\n setShouldAutoFocus(true);\n // Now that the sheet is where it will stay: the scroll a plain focus gives (see above).\n focusWithNativeScroll(searchInputRef.current);\n }, [searchProp?.autoFocus]);\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value;\n setSearchValue(value);\n searchProp?.onChange?.(value);\n };\n\n const handleSearchFocus = () => {\n setIsSearchFocused(true);\n searchProp?.onFocus?.();\n requestAnimationFrame(() => {\n searchInputRef.current?.focus();\n });\n };\n\n const handleSearchBlur = () => {\n searchProp?.onBlur?.();\n };\n\n /*\n * THE ARROW LEAVES SEARCH, AND STAYS OUT.\n *\n * Leaving search swaps the full-screen search header for the normal one, and that mounts a NEW\n * search box. It carried `autoFocus` — still true from the opening — so the new box took focus\n * the moment it appeared, focusing it re-entered search mode, and the arrow looked dead: \"we\n * cannot press the back button in the viewer\". Opening is the only time the box focuses itself.\n */\n const handleBackFromSearch = () => {\n leftSearch.current = true;\n setShouldAutoFocus(false);\n setIsSearchFocused(false);\n if (searchInputRef.current) {\n searchInputRef.current.blur();\n }\n };\n\n const clearSearch = () => {\n setSearchValue(\"\");\n searchProp?.onChange?.(\"\");\n if (searchInputRef.current) {\n searchInputRef.current.focus();\n }\n };\n\n /*\n * PAGINATION LISTENS TO WHATEVER ACTUALLY SCROLLS.\n *\n * It listened to `.selection-viewer-content` alone. Inside the sheet that element is not the\n * scroller: react-modal-sheet wraps content in its own `.react-modal-sheet-content-scroller`, the\n * content grows to its full height (4,601px for a hundred rows, measured) and the WRAPPER scrolls.\n * The content box never fired a scroll event, so `onPaginate` was never called — every consumer's\n * list stopped at its first page with nothing to say it had.\n *\n * So the nearest scrolling ancestor is found and listened to, and the content itself as well (for\n * a layout where it is the scroller). And the check also runs when the content changes size: a\n * first page too short to scroll can never produce a scroll event, but it is plainly \"at the\n * bottom\", so it asks for the next one straight away.\n */\n const onPaginateRef = useRef(onPaginate);\n onPaginateRef.current = onPaginate;\n const [contentEl, setContentEl] = useState<HTMLDivElement | null>(null);\n\n const checkNearBottom = useCallback(async (el: HTMLElement) => {\n const paginate = onPaginateRef.current;\n if (isPaginating.current || !paginate) return;\n\n const { scrollTop, scrollHeight, clientHeight } = el;\n const isNearBottom = scrollHeight - scrollTop <= clientHeight * 1.2;\n if (!isNearBottom) return;\n\n isPaginating.current = true;\n const hasMore = await paginate();\n if (!hasMore) {\n isPaginating.current = false;\n } else {\n setTimeout(() => {\n isPaginating.current = false;\n }, 500);\n }\n }, []);\n\n const hasPaginate = Boolean(onPaginate);\n useEffect(() => {\n if (!contentEl || !hasPaginate) return;\n const scroller =\n (contentEl.closest(\".react-modal-sheet-content-scroller\") as HTMLElement | null) ?? contentEl;\n const onScroll = () => void checkNearBottom(scroller);\n const onInnerScroll = () => void checkNearBottom(contentEl);\n\n scroller.addEventListener(\"scroll\", onScroll, { passive: true });\n if (scroller !== contentEl) contentEl.addEventListener(\"scroll\", onInnerScroll, { passive: true });\n\n const resize =\n typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(() => onScroll()) : null;\n resize?.observe(contentEl);\n\n return () => {\n scroller.removeEventListener(\"scroll\", onScroll);\n contentEl.removeEventListener(\"scroll\", onInnerScroll);\n resize?.disconnect();\n };\n }, [contentEl, hasPaginate, checkNearBottom]);\n\n if (!isOpen && unmountOnClose) return null;\n\n return (\n <SelectionViewerAggregateContext.Provider value={aggregateReporterValue}>\n <Sheet\n ref={sheetRef}\n isOpen={isOpen}\n onClose={onClose}\n detent=\"content\"\n style={{ zIndex }}\n maxHeight={maxHeight}\n onOpenEnd={handleOpenEnd}\n >\n <Sheet.Container\n id={id}\n // Announced as a modal dialog. Without this a screen reader reads the sheet as one more\n // region of the page and gives no indication that what is behind it is unavailable — and\n // an automated check for an open dialog finds nothing at all.\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n style={{\n maxHeight: maxHeight,\n minHeight: isSearchFocused ? \"100dvh\" : minHeight,\n maxWidth: layoutProp?.maxWidth ?? '800px',\n margin: \"0 auto\",\n width: \"100%\",\n left: 0,\n right: 0,\n paddingBottom: \"calc(0px + env(safe-area-inset-bottom))\",\n background: isSearchFocused\n ? layoutProp?.fullScreenSearchBackground || layoutProp?.backgroundColor\n : layoutProp?.backgroundColor,\n borderTopLeftRadius: isSearchFocused ? \"0px\" : \"16px\",\n borderTopRightRadius: isSearchFocused ? \"0px\" : \"16px\",\n }}\n >\n {isSearchFocused ? (\n <Sheet.Header>\n <div\n className=\"selection-viewer-fullscreen-search\"\n style={layoutProp?.fullScreenSearchHeaderStyle}\n >\n <div className=\"selection-viewer-search\" style={{\n ...searchProp?.containerStyle,\n background: searchProp?.background,\n padding: searchProp?.padding\n ? `${searchProp.padding.t} ${searchProp.padding.r} ${searchProp.padding.b} ${searchProp.padding.l}`\n : \"16px\"\n }}>\n <button\n className=\"selection-viewer-search-back-button\"\n onClick={handleBackFromSearch}\n aria-label=\"Exit search mode\"\n >\n {searchProp?.backIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M15 18L9 12L15 6\" stroke={searchProp?.textColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n\n <input\n key={inputKey}\n ref={searchInputRef}\n type=\"text\"\n placeholder={searchProp?.text}\n value={searchValue}\n onChange={handleSearchChange}\n className={searchProp?.className || \"selection-viewer-search-input\"}\n style={{\n color: searchProp?.textColor,\n ...searchProp?.inputStyle\n }}\n onFocus={handleSearchFocus}\n onBlur={handleSearchBlur}\n autoFocus={shouldAutoFocus}\n />\n\n {searchValue && (\n <button\n className=\"selection-viewer-search-clear-button\"\n onClick={clearSearch}\n aria-label=\"Clear search\"\n >\n {searchProp?.clearIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 6L6 18M6 6L18 18\" stroke={searchProp?.textColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n )}\n </div>\n </div>\n </Sheet.Header>\n ) : (\n <Sheet.Header>\n <div className=\"selection-viewer-header\">\n {/* Cancel button left */}\n {cancelButton?.position === \"left\" && (\n <button\n aria-label={cancelButton.ariaLabel || \"Close\"}\n className=\"selection-viewer-cancel\"\n style={{\n position: \"absolute\",\n left: \"4px\",\n top: \"4px\",\n ...cancelButton.style\n }}\n onClick={cancelButton.onClick || onClose}\n >\n {cancelButton.view || cancelButton.text || \"Cancel\"}\n </button>\n )}\n\n {/* Drag handle */}\n {!isSearchFocused && (\n <div\n className=\"selection-viewer-drag-handle\"\n style={{\n background: layoutProp?.handleColor || \"#ccc\",\n width: layoutProp?.handleWidth || \"40px\",\n marginBottom: layoutProp?.gapBetweenHandleAndTitle || \"12px\",\n }}\n />\n )}\n\n {/* Cancel button right */}\n {cancelButton?.position === \"right\" && (\n <button\n aria-label={cancelButton.ariaLabel || \"Close\"}\n className=\"selection-viewer-cancel\"\n style={{\n position: \"absolute\",\n right: \"4px\",\n top: \"4px\",\n ...cancelButton.style\n }}\n onClick={cancelButton.onClick || onClose}\n >\n {cancelButton.view || cancelButton.text || \"Cancel\"}\n </button>\n )}\n\n {/* Title */}\n <div className={titleProp.containerClass || \"selection-viewer-container\"}>\n <h2\n id={`${id}-title`}\n className={titleProp.className || \"selection-viewer-title\"}\n style={{\n marginBottom: layoutProp?.gapBetweenTitleAndSearch || \"8px\",\n color: titleProp?.textColor || 'black',\n ...titleProp.style\n }}\n >\n {titleProp.text}\n </h2>\n </div>\n </div>\n\n {/* Search */}\n {searchProp && (\n <div\n className=\"selection-viewer-search\"\n style={{\n background: searchProp.background,\n padding: searchProp.padding\n ? `${searchProp.padding.t} ${searchProp.padding.r} ${searchProp.padding.b} ${searchProp.padding.l}`\n : \"8px 16px\",\n marginBottom: layoutProp?.gapBetweenSearchAndContent,\n ...searchProp.containerStyle\n }}\n >\n {searchProp.prefixIcon && (\n <span style={{ marginRight: searchProp.prefixGap || \"8px\" }}>\n {searchProp.prefixIcon}\n </span>\n )}\n <input\n key={inputKey}\n ref={searchInputRef}\n type=\"text\"\n placeholder={searchProp.text}\n value={searchValue}\n onChange={handleSearchChange}\n className={searchProp.className || \"selection-viewer-search-input\"}\n style={{\n color: searchProp?.textColor,\n ...searchProp.inputStyle\n }}\n onFocus={handleSearchFocus}\n onBlur={handleSearchBlur}\n autoFocus={shouldAutoFocus}\n />\n {searchValue && (\n <button\n className=\"selection-viewer-search-clear-button\"\n onClick={clearSearch}\n aria-label=\"Clear search\"\n style={{ marginLeft: searchProp.suffixGap || \"8px\" }}\n >\n {searchProp.clearIcon || searchProp.suffixIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 6L6 18M6 6L18 18\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n )}\n {!searchValue && searchProp.suffixIcon && (\n <span style={{ marginLeft: searchProp.suffixGap || \"8px\" }}>\n {searchProp.suffixIcon}\n </span>\n )}\n </div>\n )}\n </Sheet.Header>\n )}\n\n <Sheet.Content>\n <div\n ref={setContentEl}\n className={`selection-viewer-content ${childrenDirection}`}\n style={{\n paddingTop: isSearchFocused ? layoutProp?.gapBetweenSearchAndContent : '0',\n paddingBottom: keyboardHeight > 0\n ? `${keyboardHeight + 16}px`\n : '16px',\n /*\n * Set in from the edges, like everything else in the sheet.\n *\n * The title and the search box have carried 16px from the start and the content had\n * none, so a list of rows ran flush into the sides of the screen under a search box\n * that did not. Overridable for rows that genuinely want the full width.\n */\n paddingLeft: layoutProp?.contentPadding ?? '16px',\n paddingRight: layoutProp?.contentPadding ?? '16px',\n }}\n >\n {/* Show children first, then loading at bottom */}\n {React.Children.count(children) > 0 ? (\n <>\n {children}\n {selectionState === \"loading\" && (\n <div\n className=\"selection-viewer-loading\"\n style={{\n padding: loadingProp?.padding\n ? `${loadingProp.padding.t} ${loadingProp.padding.r} ${loadingProp.padding.b} ${loadingProp.padding.l}`\n : \"16px\",\n ...loadingProp?.style\n }}\n >\n {loadingProp?.view}\n </div>\n )}\n {/*\n Shown ALONGSIDE the children, not instead of them.\n\n This was guarded on composed mode — a Column/Row descendant reporting its own\n state — on the reasoning that only a composed sheet can have children and be\n empty at the same time. That is not true of the commonest arrangement there is:\n a consumer that wraps its rows in a single container. `React.Children.count` is\n then 1 whether the container holds fifty rows or none, so the empty branch below\n never ran and the sheet showed a blank white screen — at the exact moment\n somebody had searched for something that is not there, which is when the empty\n state is the only useful thing on screen.\n\n Layered rather than substituted, for the reason the composed case already had:\n a child that reports its own state must stay mounted to go on reporting. A\n consumer whose `selectionState` says \"empty\" is asserting there is nothing to\n show, so drawing its own view beside visually-empty children is what it asked\n for.\n */}\n {selectionState === \"empty\" && (\n <div\n className=\"selection-viewer-no-results\"\n style={{\n padding: noResultProp?.padding\n ? `${noResultProp.padding.t} ${noResultProp.padding.r} ${noResultProp.padding.b} ${noResultProp.padding.l}`\n : \"16px\",\n ...noResultProp?.style\n }}\n >\n {noResultProp?.view || (\n <div className=\"selection-viewer-default-no-results\">\n {noResultProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n )}\n {selectionState === \"error\" && (\n <div\n className=\"selection-viewer-error\"\n style={{\n padding: errorProp?.padding\n ? `${errorProp.padding.t} ${errorProp.padding.r} ${errorProp.padding.b} ${errorProp.padding.l}`\n : \"16px\",\n ...errorProp?.style\n }}\n >\n {errorProp?.view || (\n <div className=\"selection-viewer-default-error\">\n {errorProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n )}\n </>\n ) : (selectionState === \"empty\" || (React.Children.count(children) <= 0 && (selectionState != \"loading\" && selectionState != \"error\"))) ? (\n <div\n className=\"selection-viewer-no-results\"\n style={{\n padding: noResultProp?.padding\n ? `${noResultProp.padding.t} ${noResultProp.padding.r} ${noResultProp.padding.b} ${noResultProp.padding.l}`\n : \"16px\",\n ...noResultProp?.style\n }}\n >\n {noResultProp?.view || (\n <div className=\"selection-viewer-default-no-results\">\n {noResultProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n ) : selectionState === \"loading\" ? (\n <div\n className=\"selection-viewer-loading\"\n style={{\n padding: loadingProp?.padding\n ? `${loadingProp.padding.t} ${loadingProp.padding.r} ${loadingProp.padding.b} ${loadingProp.padding.l}`\n : \"16px\",\n ...loadingProp?.style\n }}\n >\n {loadingProp?.view}\n </div>\n ) : (selectionState === \"error\") ? (\n <div\n className=\"selection-viewer-error\"\n style={{\n padding: errorProp?.padding\n ? `${errorProp.padding.t} ${errorProp.padding.r} ${errorProp.padding.b} ${errorProp.padding.l}`\n : \"16px\",\n ...errorProp?.style\n }}\n >\n {errorProp?.view || (\n <div className=\"selection-viewer-default-error\">\n {errorProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n ) : null}\n </div>\n </Sheet.Content>\n </Sheet.Container>\n <Sheet.Backdrop onTap={backDrop ? onClose : undefined} />\n </Sheet>\n </SelectionViewerAggregateContext.Provider>\n );\n};\n\n// ==================== Controller Hook ====================\ntype Operation = {\n open: () => void;\n close: () => void;\n toggle: () => void;\n setSelectionState: (val: SelectionState) => void;\n};\n\nconst useSelectionController = (initialSelectionState?: SelectionState): [\n string,\n Operation,\n boolean,\n SelectionState\n] => {\n const [isOpen, setIsOpen] = useState(false);\n const [selectionState, setSelectionState] = useState(initialSelectionState || 'initial');\n const [selectionId] = useState(() => `selection-${Math.random().toString(36).substring(2, 11)}`);\n\n const operations = useMemo<Operation>(() => ({\n open: () => setIsOpen(true),\n close: () => setIsOpen(false),\n toggle: () => setIsOpen((prev) => !prev),\n setSelectionState\n }), [setSelectionState]);\n\n return [selectionId, operations, isOpen, selectionState];\n};\n\nexport { SelectionViewer, useSelectionController, RowAggregateContext, SelectionViewerAggregateContext, computeAggregateState };\nexport type {\n SelectionViewerProps,\n SelectionState,\n TitleProps,\n SearchProps,\n LoadingProps,\n NoResultProps,\n ErrorProps,\n CancelButtonProps,\n LayoutProps,\n Padding,\n SnapPoint,\n AggregateReporter,\n};\nexport default SelectionViewer;\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { RowAggregateContext } from \"./SelectionViewer\";\nimport type { SelectionState } from \"./SelectionViewer\";\n\nexport type RowProps = {\n id?: string;\n /** Consumer-owned — SelectionViewer has never owned fetch/filter state, so unlike\n * search-viewer's Row this isn't internally computed. Mirrors how `selectionState`\n * is already a prop on SelectionViewer itself today. Defaults to \"data\": if you\n * render children without wiring this, we assume what you rendered IS the data. */\n state?: SelectionState;\n /** Called when this Row is scrolled horizontally near its end. Return (or resolve to)\n * `true` if more data may follow (keeps the pagination trigger armed), `false` once\n * there's nothing left to fetch — mirrors SelectionViewer's own `onPaginate` contract. */\n onPaginate?: () => boolean | Promise<boolean>;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n/** A horizontally-scrolling, independently-paginating section — the Row/Column\n * equivalent for `SelectionViewer`. No shared code with `@academix-admin/search-viewer`'s\n * Row (Library Charter: packages stay mutually independent) — this one has no\n * query/debounce/cache engine of its own since `SelectionViewer` never had one either;\n * the consumer owns fetching/filtering and just tells this Row what `state` it's in. */\nfunction Row({ id: providedId, state = \"data\", onPaginate, className, style, children }: RowProps) {\n const aggregateReporter = React.useContext(RowAggregateContext);\n const [rowId] = useState(() => providedId || `row-${Math.random().toString(36).substring(2, 11)}`);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const isPaginating = useRef(false);\n\n const handleScroll = useCallback(async () => {\n const el = containerRef.current;\n if (!el || isPaginating.current || !onPaginate) return;\n\n // Same \"near the end\" threshold as SelectionViewer's own vertical pagination trigger, adapted\n // to horizontal scroll metrics since a Row scrolls sideways.\n const { scrollLeft, scrollWidth, clientWidth } = el;\n if (scrollWidth - scrollLeft > clientWidth * 1.2) return;\n\n isPaginating.current = true;\n const hasMore = await onPaginate();\n if (!hasMore) {\n isPaginating.current = false;\n } else {\n setTimeout(() => {\n isPaginating.current = false;\n }, 500);\n }\n }, [onPaginate]);\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el || !onPaginate) return;\n el.addEventListener(\"scroll\", handleScroll);\n return () => el.removeEventListener(\"scroll\", handleScroll);\n }, [handleScroll, onPaginate]);\n\n useEffect(() => {\n aggregateReporter?.report(rowId, state);\n return () => aggregateReporter?.unreport(rowId);\n }, [aggregateReporter, rowId, state]);\n\n return (\n <div\n ref={containerRef}\n className={className ? `selection-viewer-row ${className}` : \"selection-viewer-row\"}\n style={{\n display: \"flex\",\n flexDirection: \"row\",\n gap: \"8px\",\n overflowX: \"auto\",\n overflowY: \"hidden\",\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n\nRow.displayName = \"Row\";\n\nexport { Row };\n","import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { RowAggregateContext, SelectionViewerAggregateContext, computeAggregateState } from \"./SelectionViewer\";\nimport type { SelectionState } from \"./SelectionViewer\";\n\nexport type ColumnProps = {\n id?: string;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n/** A vertical arrangement of `Row`s (or other content) — the explicit, composable\n * equivalent of today's flat `children` list. Its default layout is deliberately\n * identical to the existing `.selection-viewer-content.vertical` rendering\n * (`flex-direction: column, gap: 8px`), so today's flat usage is, unchanged, \"an\n * implicit Column with no Rows.\"\n *\n * Provides the `RowAggregateContext` its `Row` children report into, computes ONE\n * cumulative state from everything reported, and is itself a reporter one level up:\n * nested inside another `Column` it reports through that Column's `RowAggregateContext`\n * (behaving like a Row); at the top level it reports through `SelectionViewerAggregateContext`,\n * which `SelectionViewer` provides — this drives the outer sheet's loading/empty/error\n * views automatically with zero manual wiring, and lets Columns nest arbitrarily deep. */\nfunction Column({ id: providedId, className, style, children }: ColumnProps) {\n const [columnId] = useState(\n () => providedId || `column-${Math.random().toString(36).substring(2, 11)}`\n );\n\n const [reportedStates, setReportedStates] = useState<Map<string, SelectionState>>(new Map());\n const report = useCallback((id: string, state: SelectionState) => {\n setReportedStates((prev) => {\n const next = new Map(prev);\n next.set(id, state);\n return next;\n });\n }, []);\n const unreport = useCallback((id: string) => {\n setReportedStates((prev) => {\n if (!prev.has(id)) return prev;\n const next = new Map(prev);\n next.delete(id);\n return next;\n });\n }, []);\n const rowAggregateValue = useMemo(() => ({ report, unreport }), [report, unreport]);\n\n const aggregateState =\n reportedStates.size > 0 ? computeAggregateState(Array.from(reportedStates.values())) : \"initial\";\n\n const parentRowAggregate = React.useContext(RowAggregateContext);\n const selectionViewerAggregate = React.useContext(SelectionViewerAggregateContext);\n const upstreamReporter = parentRowAggregate ?? selectionViewerAggregate;\n\n useEffect(() => {\n if (!upstreamReporter) return;\n upstreamReporter.report(columnId, aggregateState);\n return () => upstreamReporter.unreport(columnId);\n }, [upstreamReporter, columnId, aggregateState]);\n\n return (\n <RowAggregateContext.Provider value={rowAggregateValue}>\n <div\n className={className ? `selection-viewer-column ${className}` : \"selection-viewer-column\"}\n style={{ display: \"flex\", flexDirection: \"column\", gap: \"8px\", ...style }}\n >\n {children}\n </div>\n </RowAggregateContext.Provider>\n );\n}\n\nColumn.displayName = \"Column\";\n\nexport { Column };\n"]}
1
+ {"version":3,"sources":["../src/SelectionViewer.tsx","../src/Row.tsx","../src/Column.tsx"],"names":["React","useState","useRef","useCallback","useEffect","jsx","useMemo"],"mappings":";;;;;;AAcA,IAAM,mBAAA,GAAsB,KAAA,CAAM,aAAA,CAAwC,IAAI;AAI9E,IAAM,+BAAA,GAAkC,KAAA,CAAM,aAAA,CAAwC,IAAI;AAE1F,SAAS,sBAAsB,MAAA,EAA0C;AACvE,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,SAAA;AAChC,EAAA,IAAI,OAAO,IAAA,CAAK,CAAC,MAAM,CAAA,KAAM,MAAM,GAAG,OAAO,MAAA;AAC7C,EAAA,IAAI,OAAO,IAAA,CAAK,CAAC,MAAM,CAAA,KAAM,SAAS,GAAG,OAAO,SAAA;AAChD,EAAA,IAAI,OAAO,KAAA,CAAM,CAAC,MAAM,CAAA,KAAM,OAAO,GAAG,OAAO,OAAA;AAC/C,EAAA,IAAI,OAAO,IAAA,CAAK,CAAC,MAAM,CAAA,KAAM,OAAO,GAAG,OAAO,OAAA;AAC9C,EAAA,OAAO,SAAA;AACT;AAiJA,IAAM,SAAA,GAAY,CAAC,EAAA,KAAe;AAAA,CAAA,EAC/B,EAAE,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,EAsBF,EAAE,CAAA;AAAA;AA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AA6B,KAAA,EAAO,mBACnC,QAAA,kBAAAA,GAAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,SAAA,GAAY,CAAA,wBAAA,EAA2B,SAAS,CAAA,CAAA,GAAK,yBAAA;AAAA,MAChE,KAAA,EAAO,EAAE,OAAA,EAAS,MAAA,EAAQ,eAAe,QAAA,EAAU,GAAA,EAAK,KAAA,EAAO,GAAG,KAAA,EAAM;AAAA,MAEvE;AAAA;AAAA,GACH,EACF,CAAA;AAEJ;AAEA,MAAA,CAAO,WAAA,GAAc,QAAA","file":"index.js","sourcesContent":["import React, { useState, useEffect, useCallback, useRef, useMemo } from \"react\";\nimport { Sheet } from \"@academix-admin/modal-sheet\";\nimport { useOverlayRoute } from '@academix-admin/overlay-route';\n\n// ==================== Aggregation (Row/Column) ====================\n// Independent from @academix-admin/search-viewer's equivalent (Library Charter: packages stay\n// mutually independent) — same shape, duplicated intentionally rather than shared.\n\ntype AggregateReporter = {\n report: (id: string, state: SelectionState) => void;\n unreport: (id: string) => void;\n};\n\n/** A `Row` reports its own `state` into the nearest `Column` through this. */\nconst RowAggregateContext = React.createContext<AggregateReporter | null>(null);\n\n/** `Column` reports its own aggregated state up through this — `SelectionViewer` provides it and\n * merges whatever's reported into its own selectionState resolution, with zero extra wiring. */\nconst SelectionViewerAggregateContext = React.createContext<AggregateReporter | null>(null);\n\nfunction computeAggregateState(states: SelectionState[]): SelectionState {\n if (states.length === 0) return \"initial\";\n if (states.some((s) => s === \"data\")) return \"data\";\n if (states.some((s) => s === \"loading\")) return \"loading\";\n if (states.every((s) => s === \"empty\")) return \"empty\";\n if (states.some((s) => s === \"error\")) return \"error\";\n return \"initial\";\n}\n\n// ==================== Types ====================\ntype Padding = {\n l: string;\n r: string;\n t: string;\n b: string;\n};\n\ntype SnapPoint = number;\n\ntype SelectionState = \"loading\" | \"empty\" | \"error\" | \"data\" | \"initial\";\n\n\ntype TitleProps = {\n text: string;\n textColor: string;\n className?: string;\n containerClass?: string;\n style?: React.CSSProperties;\n};\n\ntype SearchProps = {\n text: string;\n textColor: string;\n className?: string;\n background?: string;\n prefixIcon?: React.ReactNode;\n suffixIcon?: React.ReactNode;\n clearIcon?: React.ReactNode;\n backIcon?: React.ReactNode;\n prefixGap?: string;\n suffixGap?: string;\n padding?: Padding;\n autoFocus?: boolean;\n inputStyle?: React.CSSProperties;\n containerStyle?: React.CSSProperties;\n onChange?: (value: string) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n};\n\ntype LoadingProps = {\n view: React.ReactNode;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype NoResultProps = {\n view: React.ReactNode;\n text?: string;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype ErrorProps = {\n view: React.ReactNode;\n text?: string;\n padding?: Padding;\n style?: React.CSSProperties;\n};\n\ntype CancelButtonProps = {\n text?: string;\n view: React.ReactNode;\n position?: \"left\" | \"right\";\n style?: React.CSSProperties;\n onClick?: () => void;\n /**\n * What a screen reader calls it. Defaults to \"Close\".\n *\n * A button whose only content is an icon has no accessible name at all, so it was announced as\n * just \"button\" — the one control that dismisses the sheet, and nothing said so.\n */\n ariaLabel?: string;\n};\n\ntype LayoutProps = {\n gapBetweenHandleAndTitle?: string;\n gapBetweenTitleAndSearch?: string;\n gapBetweenSearchAndContent?: string;\n /**\n * How far the rows are set in from the sides. Defaults to `16px`, matching the search box.\n *\n * The content had no inset while everything above it had 16px, so a list ran flush into the\n * sides of the screen under a search box that did not. Pass `0px` for rows that should reach\n * the edges.\n */\n contentPadding?: string;\n backgroundColor?: string;\n handleColor?: string;\n handleWidth?: string;\n fullScreenSearchBackground?: string;\n fullScreenSearchHeaderStyle?: React.CSSProperties;\n maxWidth?: string;\n};\n\ntype SelectionViewerProps = {\n id?: string;\n isOpen: boolean;\n backDrop?: boolean;\n onClose: () => void;\n /**\n * Give this overlay its own history entry under this name, so the platform's own Back (and the\n * iOS edge-swipe, and Android's gesture) closes the OVERLAY rather than the page under it.\n *\n * Off by default, because it changes what the back gesture does and no existing consumer asked\n * for that. Without it, Back with this open closes it AND leaves the page behind it: measured in\n * a real shop, the gesture walked straight out of a half-built sale.\n *\n * The name must be unique among overlays that can be open together, or they mistake each other's\n * entry. Make it STABLE across page loads and the overlay can also come back after a refresh —\n * see `useOverlayRoute` in `@academix-admin/overlay-route`, which this uses and which any\n * component can use directly.\n */\n historyRoute?: string;\n titleProp: TitleProps;\n searchProp?: SearchProps;\n loadingProp?: LoadingProps;\n noResultProp?: NoResultProps;\n errorProp?: ErrorProps;\n cancelButton?: CancelButtonProps;\n layoutProp?: LayoutProps;\n childrenDirection?: \"vertical\" | \"horizontal\";\n children?: React.ReactNode;\n onPaginate?: () => boolean | Promise<boolean>;\n snapPoints?: SnapPoint[];\n initialSnap?: number;\n unmountOnClose?: boolean;\n zIndex?: number;\n /**\n * Accessible name for the sheet, announced when it opens.\n *\n * A modal with no name is announced simply as \"dialog\", which tells a screen-reader user that\n * something has taken over the screen and nothing at all about what.\n */\n ariaLabel?: string;\n maxHeight?: string;\n minHeight?: string;\n selectionState?: SelectionState;\n closeThreshold?: number;\n};\n\n// ==================== Styles ====================\nconst getStyles = (id: string) => `\n#${id} .selection-viewer-header {\n padding: 0px;\n display: flex;\n flex-direction: column;\n align-items: center;\n position: relative;\n width: 100%;\n}\n\n/*\n * The close button, with a target a thumb can find.\n *\n * It sat at right: 0, top: 8 with no padding at all, so the icon was flush against the sheet's\n * edge and the only thing that could be tapped was the glyph itself — a target well under half\n * what a finger needs, in the corner of the screen where a thumb is least accurate. Inset by 4px\n * and padded out to 44px square, so the icon still reads as sitting in the corner while the\n * hittable area reaches the edges.\n *\n * The cancelButton.style prop is still spread last at the call site, so a consumer that was\n * overriding any of this keeps overriding it. (No backticks in here: this whole block lives\n * inside a template literal, and one would end the string.)\n */\n#${id} .selection-viewer-cancel {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 44px;\n min-height: 44px;\n padding: 10px;\n border: none;\n background-color: transparent;\n color: inherit;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n\n#${id} .selection-viewer-drag-handle {\n height: 5px;\n border-radius: 3px;\n margin-top: 16px;\n}\n\n#${id} .selection-viewer-container {\n display: flex;\n align-items: flex-start;\n width: 100%;\n}\n\n#${id} .selection-viewer-title {\n margin: 0px;\n font-size: 18px;\n font-weight: 600;\n padding: 0px 16px 0px 16px;\n word-break: break-word; /* break long words */\n white-space: normal; /* allow wrapping */\n}\n\n#${id} .selection-viewer-search {\n display: flex;\n align-items: center;\n margin: 16px 16px 4px 16px;\n border-radius: 12px;\n box-sizing: border-box;\n border: 1px solid rgba(0, 0, 0, 0.1);\n}\n\n#${id} .selection-viewer-search-input {\n flex: 1;\n border: none;\n background: transparent;\n padding: 12px 8px;\n outline: none;\n font-size: 16px !important;\n width: 100%;\n}\n\n/*\n * The rows, set in from the edges like everything else in the sheet.\n *\n * The title and the search box have carried a 16px margin from the start; the content had none, so\n * a list of cards ran flush into the sides of the screen while the search box above it did not.\n * The layoutProp.contentPadding option overrides it for a consumer that wants its rows edge to\n * edge. (No backticks: this block is inside a template literal.)\n */\n#${id} .selection-viewer-content {\n overflow-y: auto;\n -webkit-overflow-scrolling: touch;\n flex: 1;\n min-height: 0;\n box-sizing: border-box;\n}\n\n#${id} .selection-viewer-content.vertical {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n#${id} .selection-viewer-content.horizontal {\n display: flex;\n flex-direction: row;\n gap: 8px;\n overflow-x: auto;\n overflow-y: hidden;\n}\n\n#${id} .selection-viewer-no-results,\n#${id} .selection-viewer-error,\n#${id} .selection-viewer-loading {\n display: flex;\n justify-content: center;\n align-items: center;\n min-height: 120px;\n}\n\n#${id} .selection-viewer-default-no-results {\n color: #666;\n font-size: 14px;\n}\n\n#${id} .selection-viewer-default-error {\n color: red;\n font-size: 14px;\n}\n\n/* Full screen search mode */\n#${id} .selection-viewer-fullscreen-search {\n// position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 10;\n// padding-top: env(safe-area-inset-top);\n width: 100%;\n}\n\n#${id} .selection-viewer-search-back-button {\n background: none;\n border: none;\n padding: 8px;\n margin-right: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n#${id} .selection-viewer-search-back-button:hover {\n opacity: 0.7;\n}\n\n#${id} .selection-viewer-search-clear-button {\n background: none;\n border: none;\n padding: 8px;\n margin-left: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: opacity 0.2s;\n}\n\n#${id} .selection-viewer-search-clear-button:hover {\n opacity: 0.7;\n}\n\n/* React Modal Sheet overrides */\n#${id} .react-modal-sheet-container {\n max-width: 500px;\n margin: 0 auto;\n border-top-left-radius: 16px;\n border-top-right-radius: 16px;\n}\n\n#${id} .react-modal-sheet-backdrop {\n background-color: rgba(0, 0, 0, 0.5) !important;\n pointer-events: auto !important;\n}\n\n#${id} .react-modal-sheet-content {\n padding: 0 0px 0px 0px;\n height: 100%;\n}\n\n\n/* Mobile full-width behavior */\n@media (max-width: 500px) {\n #${id} .react-modal-sheet-container {\n max-width: 100%;\n border-radius: 0;\n }\n}\n\n/* Prevent iOS zooming */\n@media screen and (-webkit-min-device-pixel-ratio: 0) {\n #${id} .selection-viewer-search-input {\n font-size: 16px !important;\n }\n}\n`;\n\n// ==================== Hook to inject CSS per instance ====================\nconst useInjectStyles = (id: string) => {\n useEffect(() => {\n const styleId = `selection-viewer-styles-${id}`;\n let styleTag = document.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleTag) {\n styleTag = document.createElement(\"style\");\n styleTag.id = styleId;\n styleTag.innerHTML = getStyles(id);\n document.head.appendChild(styleTag);\n }\n\n // Cleanup on unmount\n return () => {\n if (styleTag && document.head.contains(styleTag)) {\n document.head.removeChild(styleTag);\n }\n };\n }, [id]);\n};\n\n// ==================== Component ====================\n/**\n * Escape closes the viewer, and Tab stays inside it.\n *\n * The viewer covers the screen, so what is behind it is not available — but nothing said so to the\n * keyboard. Tab walked out of the option list into the page underneath, where a person was\n * operating controls they could not see, and Escape did nothing at all, which is the one key\n * everybody reaches for to get out of a picker.\n *\n * Deliberately a private copy rather than an import from a sibling package: every library here\n * stands alone, and a shared helper between two of them is a dependency the consumer did not ask\n * for. Takes the container's `id` rather than a ref, because the sheet element belongs to the\n * underlying modal-sheet component; looking it up when a key is pressed finds it however that\n * component chooses to mount it. Focusables are re-queried on every Tab, since the option list\n * changes as the consumer filters it and a list captured on open is a list of dead elements.\n */\nconst useModalKeys = (isOpen: boolean, onClose: () => void, containerId: string) => {\n useEffect(() => {\n if (!isOpen || typeof document === \"undefined\") return;\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n onClose();\n return;\n }\n if (e.key !== \"Tab\") return;\n\n const focusable = document.getElementById(containerId)?.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]),' +\n ' textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n );\n if (!focusable || focusable.length === 0) return;\n\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [isOpen, onClose, containerId]);\n};\n\nconst SelectionViewer: React.FC<SelectionViewerProps> = ({\n id: providedId,\n isOpen,\n historyRoute,\n backDrop = true,\n onClose,\n titleProp,\n searchProp,\n loadingProp,\n noResultProp,\n errorProp,\n cancelButton,\n layoutProp,\n childrenDirection = \"vertical\",\n children,\n onPaginate,\n snapPoints = [0, 1],\n initialSnap = 1,\n unmountOnClose = true,\n zIndex = 1000,\n ariaLabel,\n maxHeight = \"90dvh\",\n minHeight = \"65dvh\",\n selectionState: selectionStateProp = \"initial\",\n closeThreshold = 0.2,\n}) => {\n\n /*\n * THE BACK GESTURE CLOSES THIS, NOT THE PAGE UNDER IT.\n *\n * Only when the consumer named a route: `useOverlayRoute` is a no-op with an empty name, and an\n * overlay that never asked for a history entry must not acquire one, or Back starts meaning\n * something different in an app that did not opt in.\n *\n * The capability lives in its own package rather than here, so that an app wanting a\n * back-closable sheet does not have to take a router with it — and so that a navigation library\n * can supply the history writing without either package importing the other.\n */\n useOverlayRoute(historyRoute ?? '', Boolean(historyRoute) && isOpen, onClose);\n const [id] = useState(() => providedId || `selection-${Math.random().toString(36).substring(2, 11)}`);\n const [searchValue, setSearchValue] = useState(\"\");\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n const [keyboardHeight, setKeyboardHeight] = useState(0);\n const [inputKey, setInputKey] = useState(0);\n const [shouldAutoFocus, setShouldAutoFocus] = useState(false);\n /*\n * The person left search with the arrow. `autoFocus` is for the OPENING only: after this, nothing\n * of ours may put the box back in focus — see `handleBackFromSearch`.\n */\n const leftSearch = useRef(false);\n const isPaginating = useRef(false);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const sheetRef = useRef<any>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n\n useInjectStyles(id);\n // Escape closes the viewer and Tab stays inside it — see useModalKeys.\n useModalKeys(isOpen, onClose, id);\n\n // Descendant sections (a Column, or anything else) can report a cumulative state up through this —\n // starts empty, so a plain SelectionViewer with no Row/Column children behaves exactly as before.\n const [reportedStates, setReportedStates] = useState<Map<string, SelectionState>>(new Map());\n const reportAggregate = useCallback((reporterId: string, state: SelectionState) => {\n setReportedStates((prev) => {\n const next = new Map(prev);\n next.set(reporterId, state);\n return next;\n });\n }, []);\n const unreportAggregate = useCallback((reporterId: string) => {\n setReportedStates((prev) => {\n if (!prev.has(reporterId)) return prev;\n const next = new Map(prev);\n next.delete(reporterId);\n return next;\n });\n }, []);\n const aggregateReporterValue = useMemo(\n () => ({ report: reportAggregate, unreport: unreportAggregate }),\n [reportAggregate, unreportAggregate]\n );\n const reportedAggregate =\n reportedStates.size > 0 ? computeAggregateState(Array.from(reportedStates.values())) : null;\n const isComposed = reportedAggregate !== null;\n\n // Precedence: an explicit `selectionState` prop always wins (matches today's exact behaviour for\n // any consumer not using Row/Column) -> then a reported Column aggregate, if one exists -> \"initial\".\n const selectionState =\n selectionStateProp !== \"initial\" ? selectionStateProp : reportedAggregate ?? \"initial\";\n\n // Track keyboard height\n useEffect(() => {\n if (typeof window === 'undefined' || !window.visualViewport) return;\n\n const handleResize = () => {\n const vp = window.visualViewport!;\n const kbHeight = window.innerHeight - vp.height;\n setKeyboardHeight(kbHeight > 0 ? kbHeight : 0);\n };\n\n window.visualViewport.addEventListener('resize', handleResize);\n window.visualViewport.addEventListener('scroll', handleResize);\n\n return () => {\n window.visualViewport?.removeEventListener('resize', handleResize);\n window.visualViewport?.removeEventListener('scroll', handleResize);\n };\n }, []);\n\n // Auto-focus on search\n useEffect(() => {\n if (!isOpen) {\n searchInputRef.current?.blur();\n setSearchValue(\"\");\n searchProp?.onChange?.(\"\");\n setShouldAutoFocus(false);\n return;\n }\n }, [isOpen, searchProp?.autoFocus]);\n\n/*\n * THE KEYBOARD COMES UP ONCE THE SHEET HAS OPENED — the way a person's own tap on the box does.\n *\n * Nothing is focused while the sheet slides up. When it has opened (`onOpenEnd`) the box, now at\n * the top of the screen, gets a plain focus(): iOS raises the keyboard, the header stays, and the\n * rows sit above the keyboard. This is 0.3.0 / 0.5.0's timing, which academix-web runs.\n *\n * 0.3.1–0.3.3 / 0.5.2–0.5.5 tried to raise the keyboard inside the opening tap instead (the box\n * itself, then an invisible stand-in at the top of the screen). With the keyboard rising while\n * the sheet was still moving, iOS moved the page: the header went off the top and the rows sat\n * under the keyboard, until the person dropped the keyboard and tapped the box again.\n *\n * `autoFocus` is set only here, so a box remounted later (leaving search) does not grab focus.\n * If the sheet never reports that it opened, the box is focused after 1.2s all the same.\n */\n const focusedOnOpen = useRef(false);\n const handleOpenEnd = useCallback(() => {\n if (!searchProp?.autoFocus || !searchInputRef.current || focusedOnOpen.current) return;\n focusedOnOpen.current = true;\n // Left search before the sheet finished opening: that was the person's choice.\n if (leftSearch.current) return;\n setShouldAutoFocus(true);\n searchInputRef.current.focus();\n }, [searchProp?.autoFocus]);\n\n useEffect(() => {\n if (!isOpen) {\n focusedOnOpen.current = false;\n return;\n }\n leftSearch.current = false;\n if (!searchProp?.autoFocus) return;\n const late = setTimeout(handleOpenEnd, 1200);\n return () => clearTimeout(late);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value;\n setSearchValue(value);\n searchProp?.onChange?.(value);\n };\n\n const handleSearchFocus = () => {\n setIsSearchFocused(true);\n searchProp?.onFocus?.();\n requestAnimationFrame(() => {\n searchInputRef.current?.focus();\n });\n };\n\n const handleSearchBlur = () => {\n searchProp?.onBlur?.();\n };\n\n /*\n * THE ARROW LEAVES SEARCH, AND STAYS OUT.\n *\n * Leaving search swaps the full-screen search header for the normal one, and that mounts a NEW\n * search box. It carried `autoFocus` — still true from the opening — so the new box took focus\n * the moment it appeared, focusing it re-entered search mode, and the arrow looked dead: \"we\n * cannot press the back button in the viewer\". Opening is the only time the box focuses itself.\n */\n const handleBackFromSearch = () => {\n leftSearch.current = true;\n setShouldAutoFocus(false);\n setIsSearchFocused(false);\n if (searchInputRef.current) {\n searchInputRef.current.blur();\n }\n };\n\n const clearSearch = () => {\n setSearchValue(\"\");\n searchProp?.onChange?.(\"\");\n if (searchInputRef.current) {\n searchInputRef.current.focus();\n }\n };\n\n /*\n * PAGINATION LISTENS TO WHATEVER ACTUALLY SCROLLS.\n *\n * It listened to `.selection-viewer-content` alone. Inside the sheet that element is not the\n * scroller: react-modal-sheet wraps content in its own `.react-modal-sheet-content-scroller`, the\n * content grows to its full height (4,601px for a hundred rows, measured) and the WRAPPER scrolls.\n * The content box never fired a scroll event, so `onPaginate` was never called — every consumer's\n * list stopped at its first page with nothing to say it had.\n *\n * So the nearest scrolling ancestor is found and listened to, and the content itself as well (for\n * a layout where it is the scroller). And the check also runs when the content changes size: a\n * first page too short to scroll can never produce a scroll event, but it is plainly \"at the\n * bottom\", so it asks for the next one straight away.\n */\n const onPaginateRef = useRef(onPaginate);\n onPaginateRef.current = onPaginate;\n const [contentEl, setContentEl] = useState<HTMLDivElement | null>(null);\n\n const checkNearBottom = useCallback(async (el: HTMLElement) => {\n const paginate = onPaginateRef.current;\n if (isPaginating.current || !paginate) return;\n\n const { scrollTop, scrollHeight, clientHeight } = el;\n const isNearBottom = scrollHeight - scrollTop <= clientHeight * 1.2;\n if (!isNearBottom) return;\n\n isPaginating.current = true;\n const hasMore = await paginate();\n if (!hasMore) {\n isPaginating.current = false;\n } else {\n setTimeout(() => {\n isPaginating.current = false;\n }, 500);\n }\n }, []);\n\n const hasPaginate = Boolean(onPaginate);\n useEffect(() => {\n if (!contentEl || !hasPaginate) return;\n const scroller =\n (contentEl.closest(\".react-modal-sheet-content-scroller\") as HTMLElement | null) ?? contentEl;\n const onScroll = () => void checkNearBottom(scroller);\n const onInnerScroll = () => void checkNearBottom(contentEl);\n\n scroller.addEventListener(\"scroll\", onScroll, { passive: true });\n if (scroller !== contentEl) contentEl.addEventListener(\"scroll\", onInnerScroll, { passive: true });\n\n const resize =\n typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(() => onScroll()) : null;\n resize?.observe(contentEl);\n\n return () => {\n scroller.removeEventListener(\"scroll\", onScroll);\n contentEl.removeEventListener(\"scroll\", onInnerScroll);\n resize?.disconnect();\n };\n }, [contentEl, hasPaginate, checkNearBottom]);\n\n if (!isOpen && unmountOnClose) return null;\n\n return (\n <SelectionViewerAggregateContext.Provider value={aggregateReporterValue}>\n <Sheet\n ref={sheetRef}\n isOpen={isOpen}\n onClose={onClose}\n detent=\"content\"\n style={{ zIndex }}\n maxHeight={maxHeight}\n onOpenEnd={handleOpenEnd}\n >\n <Sheet.Container\n id={id}\n // Announced as a modal dialog. Without this a screen reader reads the sheet as one more\n // region of the page and gives no indication that what is behind it is unavailable — and\n // an automated check for an open dialog finds nothing at all.\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n style={{\n maxHeight: maxHeight,\n minHeight: isSearchFocused ? \"100dvh\" : minHeight,\n maxWidth: layoutProp?.maxWidth ?? '800px',\n margin: \"0 auto\",\n width: \"100%\",\n left: 0,\n right: 0,\n paddingBottom: \"calc(0px + env(safe-area-inset-bottom))\",\n background: isSearchFocused\n ? layoutProp?.fullScreenSearchBackground || layoutProp?.backgroundColor\n : layoutProp?.backgroundColor,\n borderTopLeftRadius: isSearchFocused ? \"0px\" : \"16px\",\n borderTopRightRadius: isSearchFocused ? \"0px\" : \"16px\",\n }}\n >\n {isSearchFocused ? (\n <Sheet.Header>\n <div\n className=\"selection-viewer-fullscreen-search\"\n style={layoutProp?.fullScreenSearchHeaderStyle}\n >\n <div className=\"selection-viewer-search\" style={{\n ...searchProp?.containerStyle,\n background: searchProp?.background,\n padding: searchProp?.padding\n ? `${searchProp.padding.t} ${searchProp.padding.r} ${searchProp.padding.b} ${searchProp.padding.l}`\n : \"16px\"\n }}>\n <button\n className=\"selection-viewer-search-back-button\"\n onClick={handleBackFromSearch}\n aria-label=\"Exit search mode\"\n >\n {searchProp?.backIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M15 18L9 12L15 6\" stroke={searchProp?.textColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n\n <input\n key={inputKey}\n ref={searchInputRef}\n type=\"text\"\n placeholder={searchProp?.text}\n value={searchValue}\n onChange={handleSearchChange}\n className={searchProp?.className || \"selection-viewer-search-input\"}\n style={{\n color: searchProp?.textColor,\n ...searchProp?.inputStyle\n }}\n onFocus={handleSearchFocus}\n onBlur={handleSearchBlur}\n autoFocus={shouldAutoFocus}\n />\n\n {searchValue && (\n <button\n className=\"selection-viewer-search-clear-button\"\n onClick={clearSearch}\n aria-label=\"Clear search\"\n >\n {searchProp?.clearIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 6L6 18M6 6L18 18\" stroke={searchProp?.textColor || 'currentColor'} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n )}\n </div>\n </div>\n </Sheet.Header>\n ) : (\n <Sheet.Header>\n <div className=\"selection-viewer-header\">\n {/* Cancel button left */}\n {cancelButton?.position === \"left\" && (\n <button\n aria-label={cancelButton.ariaLabel || \"Close\"}\n className=\"selection-viewer-cancel\"\n style={{\n position: \"absolute\",\n left: \"4px\",\n top: \"4px\",\n ...cancelButton.style\n }}\n onClick={cancelButton.onClick || onClose}\n >\n {cancelButton.view || cancelButton.text || \"Cancel\"}\n </button>\n )}\n\n {/* Drag handle */}\n {!isSearchFocused && (\n <div\n className=\"selection-viewer-drag-handle\"\n style={{\n background: layoutProp?.handleColor || \"#ccc\",\n width: layoutProp?.handleWidth || \"40px\",\n marginBottom: layoutProp?.gapBetweenHandleAndTitle || \"12px\",\n }}\n />\n )}\n\n {/* Cancel button right */}\n {cancelButton?.position === \"right\" && (\n <button\n aria-label={cancelButton.ariaLabel || \"Close\"}\n className=\"selection-viewer-cancel\"\n style={{\n position: \"absolute\",\n right: \"4px\",\n top: \"4px\",\n ...cancelButton.style\n }}\n onClick={cancelButton.onClick || onClose}\n >\n {cancelButton.view || cancelButton.text || \"Cancel\"}\n </button>\n )}\n\n {/* Title */}\n <div className={titleProp.containerClass || \"selection-viewer-container\"}>\n <h2\n id={`${id}-title`}\n className={titleProp.className || \"selection-viewer-title\"}\n style={{\n marginBottom: layoutProp?.gapBetweenTitleAndSearch || \"8px\",\n color: titleProp?.textColor || 'black',\n ...titleProp.style\n }}\n >\n {titleProp.text}\n </h2>\n </div>\n </div>\n\n {/* Search */}\n {searchProp && (\n <div\n className=\"selection-viewer-search\"\n style={{\n background: searchProp.background,\n padding: searchProp.padding\n ? `${searchProp.padding.t} ${searchProp.padding.r} ${searchProp.padding.b} ${searchProp.padding.l}`\n : \"8px 16px\",\n marginBottom: layoutProp?.gapBetweenSearchAndContent,\n ...searchProp.containerStyle\n }}\n >\n {searchProp.prefixIcon && (\n <span style={{ marginRight: searchProp.prefixGap || \"8px\" }}>\n {searchProp.prefixIcon}\n </span>\n )}\n <input\n key={inputKey}\n ref={searchInputRef}\n type=\"text\"\n placeholder={searchProp.text}\n value={searchValue}\n onChange={handleSearchChange}\n className={searchProp.className || \"selection-viewer-search-input\"}\n style={{\n color: searchProp?.textColor,\n ...searchProp.inputStyle\n }}\n onFocus={handleSearchFocus}\n onBlur={handleSearchBlur}\n autoFocus={shouldAutoFocus}\n />\n {searchValue && (\n <button\n className=\"selection-viewer-search-clear-button\"\n onClick={clearSearch}\n aria-label=\"Clear search\"\n style={{ marginLeft: searchProp.suffixGap || \"8px\" }}\n >\n {searchProp.clearIcon || searchProp.suffixIcon || (\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 6L6 18M6 6L18 18\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )}\n </button>\n )}\n {!searchValue && searchProp.suffixIcon && (\n <span style={{ marginLeft: searchProp.suffixGap || \"8px\" }}>\n {searchProp.suffixIcon}\n </span>\n )}\n </div>\n )}\n </Sheet.Header>\n )}\n\n <Sheet.Content>\n <div\n ref={setContentEl}\n className={`selection-viewer-content ${childrenDirection}`}\n style={{\n paddingTop: isSearchFocused ? layoutProp?.gapBetweenSearchAndContent : '0',\n paddingBottom: keyboardHeight > 0\n ? `${keyboardHeight + 16}px`\n : '16px',\n /*\n * Set in from the edges, like everything else in the sheet.\n *\n * The title and the search box have carried 16px from the start and the content had\n * none, so a list of rows ran flush into the sides of the screen under a search box\n * that did not. Overridable for rows that genuinely want the full width.\n */\n paddingLeft: layoutProp?.contentPadding ?? '16px',\n paddingRight: layoutProp?.contentPadding ?? '16px',\n }}\n >\n {/* Show children first, then loading at bottom */}\n {React.Children.count(children) > 0 ? (\n <>\n {children}\n {selectionState === \"loading\" && (\n <div\n className=\"selection-viewer-loading\"\n style={{\n padding: loadingProp?.padding\n ? `${loadingProp.padding.t} ${loadingProp.padding.r} ${loadingProp.padding.b} ${loadingProp.padding.l}`\n : \"16px\",\n ...loadingProp?.style\n }}\n >\n {loadingProp?.view}\n </div>\n )}\n {/*\n Shown ALONGSIDE the children, not instead of them.\n\n This was guarded on composed mode — a Column/Row descendant reporting its own\n state — on the reasoning that only a composed sheet can have children and be\n empty at the same time. That is not true of the commonest arrangement there is:\n a consumer that wraps its rows in a single container. `React.Children.count` is\n then 1 whether the container holds fifty rows or none, so the empty branch below\n never ran and the sheet showed a blank white screen — at the exact moment\n somebody had searched for something that is not there, which is when the empty\n state is the only useful thing on screen.\n\n Layered rather than substituted, for the reason the composed case already had:\n a child that reports its own state must stay mounted to go on reporting. A\n consumer whose `selectionState` says \"empty\" is asserting there is nothing to\n show, so drawing its own view beside visually-empty children is what it asked\n for.\n */}\n {selectionState === \"empty\" && (\n <div\n className=\"selection-viewer-no-results\"\n style={{\n padding: noResultProp?.padding\n ? `${noResultProp.padding.t} ${noResultProp.padding.r} ${noResultProp.padding.b} ${noResultProp.padding.l}`\n : \"16px\",\n ...noResultProp?.style\n }}\n >\n {noResultProp?.view || (\n <div className=\"selection-viewer-default-no-results\">\n {noResultProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n )}\n {selectionState === \"error\" && (\n <div\n className=\"selection-viewer-error\"\n style={{\n padding: errorProp?.padding\n ? `${errorProp.padding.t} ${errorProp.padding.r} ${errorProp.padding.b} ${errorProp.padding.l}`\n : \"16px\",\n ...errorProp?.style\n }}\n >\n {errorProp?.view || (\n <div className=\"selection-viewer-default-error\">\n {errorProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n )}\n </>\n ) : (selectionState === \"empty\" || (React.Children.count(children) <= 0 && (selectionState != \"loading\" && selectionState != \"error\"))) ? (\n <div\n className=\"selection-viewer-no-results\"\n style={{\n padding: noResultProp?.padding\n ? `${noResultProp.padding.t} ${noResultProp.padding.r} ${noResultProp.padding.b} ${noResultProp.padding.l}`\n : \"16px\",\n ...noResultProp?.style\n }}\n >\n {noResultProp?.view || (\n <div className=\"selection-viewer-default-no-results\">\n {noResultProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n ) : selectionState === \"loading\" ? (\n <div\n className=\"selection-viewer-loading\"\n style={{\n padding: loadingProp?.padding\n ? `${loadingProp.padding.t} ${loadingProp.padding.r} ${loadingProp.padding.b} ${loadingProp.padding.l}`\n : \"16px\",\n ...loadingProp?.style\n }}\n >\n {loadingProp?.view}\n </div>\n ) : (selectionState === \"error\") ? (\n <div\n className=\"selection-viewer-error\"\n style={{\n padding: errorProp?.padding\n ? `${errorProp.padding.t} ${errorProp.padding.r} ${errorProp.padding.b} ${errorProp.padding.l}`\n : \"16px\",\n ...errorProp?.style\n }}\n >\n {errorProp?.view || (\n <div className=\"selection-viewer-default-error\">\n {errorProp?.text || \"No results found\"}\n </div>\n )}\n </div>\n ) : null}\n </div>\n </Sheet.Content>\n </Sheet.Container>\n <Sheet.Backdrop onTap={backDrop ? onClose : undefined} />\n </Sheet>\n </SelectionViewerAggregateContext.Provider>\n );\n};\n\n// ==================== Controller Hook ====================\ntype Operation = {\n open: () => void;\n close: () => void;\n toggle: () => void;\n setSelectionState: (val: SelectionState) => void;\n};\n\nconst useSelectionController = (initialSelectionState?: SelectionState): [\n string,\n Operation,\n boolean,\n SelectionState\n] => {\n const [isOpen, setIsOpen] = useState(false);\n const [selectionState, setSelectionState] = useState(initialSelectionState || 'initial');\n const [selectionId] = useState(() => `selection-${Math.random().toString(36).substring(2, 11)}`);\n\n const operations = useMemo<Operation>(() => ({\n open: () => setIsOpen(true),\n close: () => setIsOpen(false),\n toggle: () => setIsOpen((prev) => !prev),\n setSelectionState\n }), [setSelectionState]);\n\n return [selectionId, operations, isOpen, selectionState];\n};\n\nexport { SelectionViewer, useSelectionController, RowAggregateContext, SelectionViewerAggregateContext, computeAggregateState };\nexport type {\n SelectionViewerProps,\n SelectionState,\n TitleProps,\n SearchProps,\n LoadingProps,\n NoResultProps,\n ErrorProps,\n CancelButtonProps,\n LayoutProps,\n Padding,\n SnapPoint,\n AggregateReporter,\n};\nexport default SelectionViewer;\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { RowAggregateContext } from \"./SelectionViewer\";\nimport type { SelectionState } from \"./SelectionViewer\";\n\nexport type RowProps = {\n id?: string;\n /** Consumer-owned — SelectionViewer has never owned fetch/filter state, so unlike\n * search-viewer's Row this isn't internally computed. Mirrors how `selectionState`\n * is already a prop on SelectionViewer itself today. Defaults to \"data\": if you\n * render children without wiring this, we assume what you rendered IS the data. */\n state?: SelectionState;\n /** Called when this Row is scrolled horizontally near its end. Return (or resolve to)\n * `true` if more data may follow (keeps the pagination trigger armed), `false` once\n * there's nothing left to fetch — mirrors SelectionViewer's own `onPaginate` contract. */\n onPaginate?: () => boolean | Promise<boolean>;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n/** A horizontally-scrolling, independently-paginating section — the Row/Column\n * equivalent for `SelectionViewer`. No shared code with `@academix-admin/search-viewer`'s\n * Row (Library Charter: packages stay mutually independent) — this one has no\n * query/debounce/cache engine of its own since `SelectionViewer` never had one either;\n * the consumer owns fetching/filtering and just tells this Row what `state` it's in. */\nfunction Row({ id: providedId, state = \"data\", onPaginate, className, style, children }: RowProps) {\n const aggregateReporter = React.useContext(RowAggregateContext);\n const [rowId] = useState(() => providedId || `row-${Math.random().toString(36).substring(2, 11)}`);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const isPaginating = useRef(false);\n\n const handleScroll = useCallback(async () => {\n const el = containerRef.current;\n if (!el || isPaginating.current || !onPaginate) return;\n\n // Same \"near the end\" threshold as SelectionViewer's own vertical pagination trigger, adapted\n // to horizontal scroll metrics since a Row scrolls sideways.\n const { scrollLeft, scrollWidth, clientWidth } = el;\n if (scrollWidth - scrollLeft > clientWidth * 1.2) return;\n\n isPaginating.current = true;\n const hasMore = await onPaginate();\n if (!hasMore) {\n isPaginating.current = false;\n } else {\n setTimeout(() => {\n isPaginating.current = false;\n }, 500);\n }\n }, [onPaginate]);\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el || !onPaginate) return;\n el.addEventListener(\"scroll\", handleScroll);\n return () => el.removeEventListener(\"scroll\", handleScroll);\n }, [handleScroll, onPaginate]);\n\n useEffect(() => {\n aggregateReporter?.report(rowId, state);\n return () => aggregateReporter?.unreport(rowId);\n }, [aggregateReporter, rowId, state]);\n\n return (\n <div\n ref={containerRef}\n className={className ? `selection-viewer-row ${className}` : \"selection-viewer-row\"}\n style={{\n display: \"flex\",\n flexDirection: \"row\",\n gap: \"8px\",\n overflowX: \"auto\",\n overflowY: \"hidden\",\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n\nRow.displayName = \"Row\";\n\nexport { Row };\n","import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { RowAggregateContext, SelectionViewerAggregateContext, computeAggregateState } from \"./SelectionViewer\";\nimport type { SelectionState } from \"./SelectionViewer\";\n\nexport type ColumnProps = {\n id?: string;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\n/** A vertical arrangement of `Row`s (or other content) — the explicit, composable\n * equivalent of today's flat `children` list. Its default layout is deliberately\n * identical to the existing `.selection-viewer-content.vertical` rendering\n * (`flex-direction: column, gap: 8px`), so today's flat usage is, unchanged, \"an\n * implicit Column with no Rows.\"\n *\n * Provides the `RowAggregateContext` its `Row` children report into, computes ONE\n * cumulative state from everything reported, and is itself a reporter one level up:\n * nested inside another `Column` it reports through that Column's `RowAggregateContext`\n * (behaving like a Row); at the top level it reports through `SelectionViewerAggregateContext`,\n * which `SelectionViewer` provides — this drives the outer sheet's loading/empty/error\n * views automatically with zero manual wiring, and lets Columns nest arbitrarily deep. */\nfunction Column({ id: providedId, className, style, children }: ColumnProps) {\n const [columnId] = useState(\n () => providedId || `column-${Math.random().toString(36).substring(2, 11)}`\n );\n\n const [reportedStates, setReportedStates] = useState<Map<string, SelectionState>>(new Map());\n const report = useCallback((id: string, state: SelectionState) => {\n setReportedStates((prev) => {\n const next = new Map(prev);\n next.set(id, state);\n return next;\n });\n }, []);\n const unreport = useCallback((id: string) => {\n setReportedStates((prev) => {\n if (!prev.has(id)) return prev;\n const next = new Map(prev);\n next.delete(id);\n return next;\n });\n }, []);\n const rowAggregateValue = useMemo(() => ({ report, unreport }), [report, unreport]);\n\n const aggregateState =\n reportedStates.size > 0 ? computeAggregateState(Array.from(reportedStates.values())) : \"initial\";\n\n const parentRowAggregate = React.useContext(RowAggregateContext);\n const selectionViewerAggregate = React.useContext(SelectionViewerAggregateContext);\n const upstreamReporter = parentRowAggregate ?? selectionViewerAggregate;\n\n useEffect(() => {\n if (!upstreamReporter) return;\n upstreamReporter.report(columnId, aggregateState);\n return () => upstreamReporter.unreport(columnId);\n }, [upstreamReporter, columnId, aggregateState]);\n\n return (\n <RowAggregateContext.Provider value={rowAggregateValue}>\n <div\n className={className ? `selection-viewer-column ${className}` : \"selection-viewer-column\"}\n style={{ display: \"flex\", flexDirection: \"column\", gap: \"8px\", ...style }}\n >\n {children}\n </div>\n </RowAggregateContext.Provider>\n );\n}\n\nColumn.displayName = \"Column\";\n\nexport { Column };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@academix-admin/selection-viewer",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Imperative React selection sheet — search + pick from a list — with a controller hook, built on @academix-admin/modal-sheet.",
5
5
  "keywords": [
6
6
  "react",