@fuf-stack/megapixels 0.13.4 → 0.14.0

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.
Files changed (50) hide show
  1. package/dist/DataTable/index.cjs +8 -0
  2. package/dist/DataTable/index.d.cts +2 -0
  3. package/dist/DataTable/index.d.ts +2 -0
  4. package/dist/DataTable/index.js +2 -0
  5. package/dist/DataTable-CF0oifeL.cjs +1166 -0
  6. package/dist/DataTable-CF0oifeL.cjs.map +1 -0
  7. package/dist/DataTable-Da6WZFKm.js +1145 -0
  8. package/dist/DataTable-Da6WZFKm.js.map +1 -0
  9. package/dist/Filter/index.cjs +1 -1
  10. package/dist/Filter/index.d.cts +1 -1
  11. package/dist/Filter/index.d.ts +1 -1
  12. package/dist/Filter/index.js +1 -1
  13. package/dist/{Filter-faDLPGFC.cjs → Filter-CbApjj6y.cjs} +41 -50
  14. package/dist/Filter-CbApjj6y.cjs.map +1 -0
  15. package/dist/{Filter-BKfVjFPo.js → Filter-DNj4lzj5.js} +35 -23
  16. package/dist/Filter-DNj4lzj5.js.map +1 -0
  17. package/dist/VirtualList/index.cjs +8 -0
  18. package/dist/VirtualList/index.d.cts +2 -0
  19. package/dist/VirtualList/index.d.ts +2 -0
  20. package/dist/VirtualList/index.js +2 -0
  21. package/dist/VirtualList-BALnlyjy.cjs +172 -0
  22. package/dist/VirtualList-BALnlyjy.cjs.map +1 -0
  23. package/dist/VirtualList-DQ4uR-wR.js +153 -0
  24. package/dist/VirtualList-DQ4uR-wR.js.map +1 -0
  25. package/dist/index-BGYzDspd.d.cts +5192 -0
  26. package/dist/index-BGYzDspd.d.cts.map +1 -0
  27. package/dist/index-Crb5hCFD.d.ts +5192 -0
  28. package/dist/index-Crb5hCFD.d.ts.map +1 -0
  29. package/dist/index-D7ZLM0zx.d.cts +1141 -0
  30. package/dist/index-D7ZLM0zx.d.cts.map +1 -0
  31. package/dist/{index-CgoXcO8f.d.cts → index-DCiYTnRL.d.ts} +22 -12
  32. package/dist/{index-E2k5kJ14.d.ts.map → index-DCiYTnRL.d.ts.map} +1 -1
  33. package/dist/{index-E2k5kJ14.d.ts → index-FDKfDW98.d.cts} +21 -11
  34. package/dist/{index-CgoXcO8f.d.cts.map → index-FDKfDW98.d.cts.map} +1 -1
  35. package/dist/index-jFySXsl9.d.ts +1141 -0
  36. package/dist/index-jFySXsl9.d.ts.map +1 -0
  37. package/dist/index.cjs +7 -1
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +4 -2
  40. package/dist/index.d.ts +4 -2
  41. package/dist/index.js +4 -2
  42. package/dist/index.js.map +1 -1
  43. package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
  44. package/dist/useInfiniteVirtualizer-BK0VroW4.cjs +175 -0
  45. package/dist/useInfiniteVirtualizer-BK0VroW4.cjs.map +1 -0
  46. package/dist/useInfiniteVirtualizer-BSCDrdRi.js +170 -0
  47. package/dist/useInfiniteVirtualizer-BSCDrdRi.js.map +1 -0
  48. package/package.json +16 -5
  49. package/dist/Filter-BKfVjFPo.js.map +0 -1
  50. package/dist/Filter-faDLPGFC.cjs.map +0 -1
@@ -1,15 +1,15 @@
1
- import createDebug from "debug";
1
+ import { Suspense, createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
2
2
  import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
3
+ import Button from "@fuf-stack/pixels/Button";
4
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
+ import Menu from "@fuf-stack/pixels/Menu";
6
+ import createDebug from "debug";
3
7
  import Form from "@fuf-stack/uniform/Form";
4
- import { Suspense, createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
5
8
  import { any, array, boolean, object, refineArray, string, stringToJSON, veto } from "@fuf-stack/veto";
6
9
  import Label from "@fuf-stack/pixels/Label";
7
10
  import { useFormContext } from "@fuf-stack/uniform/hooks/useFormContext";
8
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
11
  import { FaSliders } from "react-icons/fa6";
10
- import Menu from "@fuf-stack/pixels/Menu";
11
12
  import { PiSlidersHorizontalBold } from "react-icons/pi";
12
- import Button from "@fuf-stack/pixels/Button";
13
13
  import Modal from "@fuf-stack/pixels/Modal";
14
14
  import SubmitButton from "@fuf-stack/uniform/SubmitButton";
15
15
  import { FaSearch } from "react-icons/fa";
@@ -273,7 +273,7 @@ const useFilters = () => {
273
273
  //#region src/Filter/Subcomponents/ActiveFilters.tsx
274
274
  const ActiveFilters = ({ className = void 0 }) => {
275
275
  const { activeFilters, getFilterValueByName, getFilterInstanceByName, hasError, removeFilter, showFilterModal } = useFilters();
276
- return /* @__PURE__ */ jsx(Fragment, { children: activeFilters.map((name) => {
276
+ return /* @__PURE__ */ jsx(Fragment$1, { children: activeFilters.map((name) => {
277
277
  const instance = getFilterInstanceByName(name);
278
278
  const value = getFilterValueByName(name);
279
279
  const DisplayComponent = instance.components.Display;
@@ -306,7 +306,7 @@ const ActiveFilters = ({ className = void 0 }) => {
306
306
  * Renders a menu trigger that opens a list of addable filters. Selecting an
307
307
  * item triggers the parent to seed a default value and open the modal.
308
308
  */
309
- const AddFilterMenu = ({ classNames = {} }) => {
309
+ const AddFilterMenu = ({ classNames = {}, disableAnimation = false, portalContainer = void 0 }) => {
310
310
  const { unusedFilters, addFilter, getFilterInstanceByName } = useFilters();
311
311
  const menuItems = unusedFilters.map((name) => {
312
312
  const instance = getFilterInstanceByName(name);
@@ -325,9 +325,11 @@ const AddFilterMenu = ({ classNames = {} }) => {
325
325
  item: classNames.addFilterMenuItem,
326
326
  trigger: classNames.addFilterMenuButton
327
327
  },
328
+ disableAnimation,
328
329
  isDisabled: !menuItems.length,
329
330
  items: menuItems,
330
331
  placement: "bottom-start",
332
+ portalContainer,
331
333
  triggerButtonProps: {
332
334
  "aria-label": "Add Filter",
333
335
  "data-testid": "add_filter_button",
@@ -340,7 +342,7 @@ const AddFilterMenu = ({ classNames = {} }) => {
340
342
  };
341
343
  //#endregion
342
344
  //#region src/Filter/Subcomponents/FilterModal.tsx
343
- const FilterModal = ({ classNames = {} }) => {
345
+ const FilterModal = ({ classNames = {}, disableAnimation = false, portalContainer = void 0 }) => {
344
346
  const { closeFilterModal, getFilterFormFieldName, getFilterInstanceByName, modalFilterName, removeFilter } = useFilters();
345
347
  if (!modalFilterName) return null;
346
348
  const instance = getFilterInstanceByName(modalFilterName);
@@ -352,7 +354,8 @@ const FilterModal = ({ classNames = {} }) => {
352
354
  footer: classNames.footer,
353
355
  header: classNames.header
354
356
  },
355
- footer: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
357
+ disableAnimation,
358
+ footer: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
356
359
  ariaLabel: "Remove filter",
357
360
  color: "danger",
358
361
  onClick: () => {
@@ -366,9 +369,10 @@ const FilterModal = ({ classNames = {} }) => {
366
369
  testId: "apply_filter_button",
367
370
  children: "Apply Filter"
368
371
  })] }),
369
- header: /* @__PURE__ */ jsxs(Fragment, { children: [instance.icon ?? /* @__PURE__ */ jsx(PiSlidersHorizontalBold, {}), /* @__PURE__ */ jsx("div", { children: `${config?.text ?? modalFilterName} Filter` })] }),
372
+ header: /* @__PURE__ */ jsxs(Fragment$1, { children: [instance.icon ?? /* @__PURE__ */ jsx(PiSlidersHorizontalBold, {}), /* @__PURE__ */ jsx("div", { children: `${config?.text ?? modalFilterName} Filter` })] }),
370
373
  isOpen: true,
371
374
  onClose: closeFilterModal,
375
+ portalContainer,
372
376
  children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(FormComponent, {
373
377
  config,
374
378
  fieldName: getFilterFormFieldName(modalFilterName)
@@ -460,7 +464,7 @@ const filterVariants = tv({ slots: {
460
464
  * The form is the source of truth during user interaction; the committed
461
465
  * state is controlled by the parent via `values`/`onChange`.
462
466
  */
463
- const Filter = ({ children = void 0, className = void 0, config, formName = "filterComponentForm", onChange, values }) => {
467
+ const Filter = ({ children = void 0, className = void 0, config, disableAnimation = false, formName = "filterComponentForm", onChange, portalContainer = void 0, values }) => {
464
468
  const handleSubmit = (nextValues) => {
465
469
  debug("handleSubmit", { nextValues });
466
470
  onChange(nextValues);
@@ -502,15 +506,23 @@ const Filter = ({ children = void 0, className = void 0, config, formName = "fil
502
506
  config: config.filters,
503
507
  children: [
504
508
  /* @__PURE__ */ jsx(ActiveFilters, { className: classNames.activeFilterLabel }),
505
- /* @__PURE__ */ jsx(AddFilterMenu, { classNames: {
506
- addFilterMenuButton: classNames.addFilterMenuButton,
507
- addFilterMenuItem: classNames.addFilterMenuItem
508
- } }),
509
- /* @__PURE__ */ jsx(FilterModal, { classNames: {
510
- body: classNames.filterModalBody,
511
- footer: classNames.filterModalFooter,
512
- header: classNames.filterModalHeader
513
- } })
509
+ /* @__PURE__ */ jsx(AddFilterMenu, {
510
+ classNames: {
511
+ addFilterMenuButton: classNames.addFilterMenuButton,
512
+ addFilterMenuItem: classNames.addFilterMenuItem
513
+ },
514
+ disableAnimation,
515
+ portalContainer
516
+ }),
517
+ /* @__PURE__ */ jsx(FilterModal, {
518
+ classNames: {
519
+ body: classNames.filterModalBody,
520
+ footer: classNames.filterModalFooter,
521
+ header: classNames.filterModalHeader
522
+ },
523
+ disableAnimation,
524
+ portalContainer
525
+ })
514
526
  ]
515
527
  })]
516
528
  }), children?.(valuesValidated ?? {})]
@@ -558,8 +570,8 @@ const createFilter = (definition) => {
558
570
  * and the provided `config` strings.
559
571
  */
560
572
  const Display$1 = ({ value, config: { text, textPrefix, textNoWord } }) => {
561
- if (typeof value === "boolean") return /* @__PURE__ */ jsx(Fragment, { children: `${value ? textPrefix : `${textPrefix} ${textNoWord ?? "no"}`} ${text}` });
562
- return /* @__PURE__ */ jsx(Fragment, { children: `${text}...` });
573
+ if (typeof value === "boolean") return /* @__PURE__ */ jsx(Fragment$1, { children: `${value ? textPrefix : `${textPrefix} ${textNoWord ?? "no"}`} ${text}` });
574
+ return /* @__PURE__ */ jsx(Fragment$1, { children: `${text}...` });
563
575
  };
564
576
  //#endregion
565
577
  //#region src/Filter/filters/boolean/Form.tsx
@@ -722,4 +734,4 @@ var Filter_default = Filter;
722
734
  //#endregion
723
735
  export { filterVariants as i, filters as n, createFilter as r, Filter_default as t };
724
736
 
725
- //# sourceMappingURL=Filter-BKfVjFPo.js.map
737
+ //# sourceMappingURL=Filter-DNj4lzj5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Filter-DNj4lzj5.js","names":["Display","Form","config","validate","boolean","validate","Form"],"sources":["../src/Filter/hooks/useFilterValidation.ts","../src/Filter/Subcomponents/FiltersContext.tsx","../src/Filter/Subcomponents/ActiveFilters.tsx","../src/Filter/Subcomponents/AddFilterMenu.tsx","../src/Filter/Subcomponents/FilterModal.tsx","../src/Filter/Subcomponents/SearchInput.tsx","../src/Filter/Filter.tsx","../src/Filter/filters/createFilter.ts","../src/Filter/filters/boolean/Display.tsx","../src/Filter/filters/boolean/Form.tsx","../src/Filter/filters/boolean/schema.ts","../src/Filter/filters/boolean/boolean.ts","../src/Filter/filters/checkboxes/Display.tsx","../src/Filter/filters/checkboxes/Form.tsx","../src/Filter/filters/checkboxes/schema.ts","../src/Filter/filters/checkboxes/checkboxes.ts","../src/Filter/index.ts"],"sourcesContent":["import type { VetoInstance, VetoRawShape, VetoTypeAny } from '@fuf-stack/veto';\nimport type { FilterInstance } from '../filters/types';\n\nimport { useMemo } from 'react';\n\nimport { object, string, stringToJSON, veto } from '@fuf-stack/veto';\n\n/**\n * useFilterValidation\n *\n * Builds a composite validation schema from all provided filter definitions\n * under \"filter\" and optionally includes a \"search\" string field.\n * Memoized by inputs.\n */\nexport const useFilterValidation = (\n filters: FilterInstance<unknown, unknown>[],\n withSearch?: boolean,\n) => {\n return useMemo<VetoInstance>(() => {\n // build filter validation\n let filterSchema: Record<string, VetoTypeAny> = {};\n filters.forEach((f) => {\n filterSchema = {\n ...filterSchema,\n [f.name]: f.validation(f.config) as VetoTypeAny,\n };\n });\n\n const validationSchema: VetoRawShape = {\n // filter validation\n filter: stringToJSON()\n .pipe(object(filterSchema))\n .or(object(filterSchema))\n .optional()\n .nullable()\n // transform null to undefined\n .transform((val) => {\n return val ?? undefined;\n }),\n // optional search validation\n ...(withSearch\n ? { search: string({ min: 0 }).nullable().optional() }\n : {}),\n };\n\n return veto(validationSchema);\n }, [filters, withSearch]);\n};\n\nexport default useFilterValidation;\n","import type { ReactNode } from 'react';\nimport type { FilterInstance, FiltersConfiguration } from '../filters/types';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useFormContext } from '@fuf-stack/uniform/hooks/useFormContext';\n\ninterface FiltersContextValue {\n /** Active filters (names only) */\n activeFilters: string[];\n /** Seed default value and open modal for a filter usage. */\n addFilter: (name: string) => void;\n /** Close the modal. */\n closeFilterModal: () => void;\n /** Build fully-qualified form field path for a filter name */\n getFilterFormFieldName: (name: string) => string;\n /** Get current form value for a given filter name */\n getFilterValueByName: (name: string) => unknown;\n /** Get filter instance by name */\n getFilterInstanceByName: (name: string) => FilterInstance<unknown, unknown>;\n /** Validation helper for a specific filter field. */\n hasError: (name: string) => boolean;\n /** Name of the current filter that has its modal open */\n modalFilterName: string | undefined;\n /** Remove a filter from the form. */\n removeFilter: (name: string) => void;\n /** Open the modal for a given filter name. */\n showFilterModal: (name: string) => void;\n /** Filters that are not active (names only) */\n unusedFilters: string[];\n}\n\n/**\n * FiltersContext\n *\n * Central state for the filter UI with a clear boundary:\n * - The parent component controls committed filter values (via value/onChange)\n * - The form acts as an edit buffer (used by the modal)\n *\n * Design:\n * - activeFilters/unusedFilters are names-only and derived from the controlled\n * form state\n * - getFilterInstanceByName gives access to the concrete registry entry to\n * retrieve the correct Form/Display components\n * - add seeds defaults in the form and opens the modal\n * - remove un-registers the form field; if the removed filter is currently\n * open in the modal, the modal is closed without rollback\n * - on a new successful form submit (Apply), the modal closes without rollback\n * by subscribing to ex-forms submit state\n */\nconst FiltersContext = createContext<FiltersContextValue | undefined>(\n undefined,\n);\n\nexport const FiltersContextProvider = ({\n children,\n config,\n}: {\n children: ReactNode;\n config: FiltersConfiguration;\n}) => {\n // ex-forms integration:\n // - setValue/unregister/getFieldState: core helpers to manipulate and validate fields\n // - formState: we subscribe to submit-success to auto-close the modal after Apply\n const {\n formState,\n getFieldState,\n setValue,\n triggerSubmit,\n unregister,\n watch,\n } = useFormContext();\n\n /**\n * currentModalFilter\n *\n * Single source of truth for the filter edit modal and its rollback snapshot.\n * - name: which filter's modal is currently open (null when closed)\n * - hadValue/previousValue: snapshot of the controlled value taken when the\n * modal is opened; used to restore state if the user cancels/closes without\n * applying.\n *\n * Lifecycle semantics:\n * - showFilterModal(name): capture snapshot (current controlled value) and open\n * the modal for that filter.\n * - closeFilterModal(): if a snapshot exists, roll back un-applied edits by\n * restoring the previous value (setValue) or removing the field (unregister)\n * when it did not exist before; then clear currentModalFilter.\n * - On successful submit (Apply): close and clear currentModalFilter WITHOUT rollback\n * so edits remain committed.\n * - removeFilter(name): unregisters the field; when removing the filter that is\n * currently open, close the modal WITHOUT rollback (since removal is explicit).\n */\n const [currentModalFilter, setCurrentModalFilter] = useState<{\n name: string;\n hadValue: boolean;\n previousValue: unknown;\n } | null>(null);\n\n // Read current filter values from the form as the live edit buffer\n const filterValue = watch('filter', {});\n\n /**\n * getFilterFormFieldName\n *\n * Returns the fully-qualified field path for a given filter name,\n * e.g., `${filterUrlParam}.status`.\n */\n const getFilterFormFieldName = useCallback((name: string) => {\n return `filter.${name}`;\n }, []);\n\n /**\n * getFilterValueByName\n *\n * Returns the committed value for a filter from the controlled state.\n */\n const getFilterValueByName = useCallback(\n (name: string) => {\n return (filterValue as Record<string, unknown>)[name];\n },\n [filterValue],\n );\n\n /** Open the filter edit modal for the given filter name. */\n const showFilterModal = useCallback(\n (name: string) => {\n const prev = getFilterValueByName(name);\n setCurrentModalFilter({\n name,\n hadValue: typeof prev !== 'undefined',\n previousValue: prev,\n });\n },\n [getFilterValueByName],\n );\n\n /** Close the filter edit modal. Rollback un-applied edits to controlled state. */\n const closeFilterModal = useCallback(() => {\n if (currentModalFilter?.name) {\n const fieldName = getFilterFormFieldName(currentModalFilter.name);\n // if the filter had a value, set it back to the previous value,\n // otherwise unregister the field\n if (currentModalFilter.hadValue) {\n setValue(fieldName, currentModalFilter.previousValue);\n } else {\n unregister(fieldName);\n }\n }\n setCurrentModalFilter(null);\n }, [getFilterFormFieldName, currentModalFilter, setValue, unregister]);\n\n /**\n * Auto-close on submit success\n *\n * Close the modal only on new successful submissions. We track the last\n * submitCount and only react when it changes AND the form reports a\n * successful submit. This prevents closing when `isSubmitSuccessful` remains\n * true without a new submit event.\n */\n const lastSubmitCountRef = useRef<number>(0);\n useEffect(() => {\n if (\n formState.submitCount !== lastSubmitCountRef.current &&\n formState.isSubmitSuccessful\n ) {\n // On successful submit, close without rollback\n setCurrentModalFilter(null);\n }\n lastSubmitCountRef.current = formState.submitCount;\n }, [\n formState.submitCount,\n formState.isSubmitSuccessful,\n setCurrentModalFilter,\n ]);\n\n /**\n * activeFilters\n *\n * Filter names derived from the controlled form state. A filter is considered\n * active when a field exists at `filter.<name>`. Newly added filters become\n * active immediately (seeded default), and will be rolled back on cancel.\n */\n const activeFilters = useMemo(() => {\n return config\n .filter((f) => {\n return Object.hasOwn(filterValue ?? {}, f.name);\n })\n .map((f) => {\n return f.name;\n });\n }, [config, filterValue]);\n\n /**\n * unusedFilters\n *\n * Complement of activeFilters (names without a corresponding `filter.<name>`\n * field in the controlled form state).\n */\n const unusedFilters = useMemo(() => {\n return config\n .filter((f) => {\n return !Object.hasOwn(filterValue ?? {}, f.name);\n })\n .map((f) => {\n return f.name;\n });\n }, [config, filterValue]);\n\n /**\n * getRegistryFilterByName\n *\n * Looks up the concrete registry entry for a filter by name, enabling access\n * to typed Form/Display components and other registry-level metadata.\n */\n const getFilterInstanceByName = useCallback(\n (name: string) => {\n return config.find((f) => {\n return f.name === name;\n }) as FilterInstance<unknown, unknown>;\n },\n [config],\n );\n\n /**\n * addFilter\n *\n * Seeds the filter with its registry default value inside the form and opens\n * the modal for immediate editing. No URL writes happen here.\n */\n const addFilter = useCallback(\n (name: string) => {\n const inst = getFilterInstanceByName(name);\n showFilterModal(name);\n setValue(getFilterFormFieldName(name), inst.defaultValue);\n },\n [\n getFilterFormFieldName,\n getFilterInstanceByName,\n setValue,\n showFilterModal,\n ],\n );\n\n /**\n * removeFilter\n *\n * Unregisters the filter field from the form. This immediately removes the\n * filter from the active list since derived state watches the form. It\n * closes the modal without rollback if the removed filter is currently open.\n */\n const removeFilter = useCallback(\n (name: string) => {\n // unregister form field\n unregister(getFilterFormFieldName(name));\n // close filter modal if open\n if (currentModalFilter?.name === name) {\n // Explicit removal: close without rollback\n setCurrentModalFilter(null);\n }\n // trigger form submit (to update filter state)\n triggerSubmit();\n },\n [\n getFilterFormFieldName,\n currentModalFilter,\n setCurrentModalFilter,\n triggerSubmit,\n unregister,\n ],\n );\n\n /**\n * hasError\n *\n * Helper that checks the ex-forms field state for a specific filter and\n * reports whether the field is currently invalid.\n */\n const hasError = useCallback(\n (name: string) => {\n return getFieldState(getFilterFormFieldName(name)).invalid;\n },\n [getFieldState, getFilterFormFieldName],\n );\n\n const contextValue: FiltersContextValue = useMemo(() => {\n return {\n activeFilters,\n addFilter,\n closeFilterModal,\n getFilterFormFieldName,\n getFilterValueByName,\n getFilterInstanceByName,\n hasError,\n modalFilterName: currentModalFilter?.name,\n removeFilter,\n showFilterModal,\n unusedFilters,\n };\n }, [\n activeFilters,\n addFilter,\n closeFilterModal,\n getFilterFormFieldName,\n getFilterValueByName,\n getFilterInstanceByName,\n hasError,\n currentModalFilter,\n removeFilter,\n showFilterModal,\n unusedFilters,\n ]);\n\n return (\n <FiltersContext.Provider value={contextValue}>\n {children}\n </FiltersContext.Provider>\n );\n};\n\n/**\n * useFilters\n *\n * Convenience hook to consume the FiltersContext. Throws a descriptive error\n * when used outside of a FiltersContextProvider to make integration mistakes\n * obvious during development.\n */\nexport const useFilters = (): FiltersContextValue => {\n const ctx = useContext(FiltersContext);\n if (!ctx) {\n throw new Error('useFilters must be used within FiltersContextProvider');\n }\n return ctx;\n};\n\nexport default FiltersContext;\n","import Label from '@fuf-stack/pixels/Label';\n\nimport { useFilters } from './FiltersContext';\n\n/**\n * ActiveFilters\n *\n * Shows the list of currently applied filters as clickable chips that open\n * the edit modal. Each chip can be removed via its close action.\n */\ninterface ActiveFiltersProps {\n /** CSS class name to apply to each label */\n className?: string;\n}\n\nconst ActiveFilters = ({ className = undefined }: ActiveFiltersProps) => {\n const {\n activeFilters,\n getFilterValueByName,\n getFilterInstanceByName,\n hasError,\n removeFilter,\n showFilterModal,\n } = useFilters();\n return (\n <>\n {activeFilters.map((name) => {\n const instance = getFilterInstanceByName(name);\n const value = getFilterValueByName(name);\n\n // get the display component from the instance\n const DisplayComponent = instance.components.Display;\n\n return (\n <button\n key={name}\n aria-label={`Open ${name} filter`}\n onClick={() => {\n showFilterModal(name);\n }}\n type=\"button\"\n >\n <Label\n className={className}\n color={hasError(name) ? 'danger' : 'primary'}\n onClose={() => {\n removeFilter(name);\n }}\n variant=\"flat\"\n >\n {instance.icon}\n <DisplayComponent config={instance.config} value={value} />\n </Label>\n </button>\n );\n })}\n </>\n );\n};\n\nexport default ActiveFilters;\n","import { FaSliders } from 'react-icons/fa6';\n\nimport Menu from '@fuf-stack/pixels/Menu';\n\nimport { useFilters } from './FiltersContext';\n\ninterface AddFilterMenuProps {\n /** CSS class name map for slots */\n classNames?: Partial<{\n addFilterMenuItem: string;\n addFilterMenuButton: string;\n }>;\n /** disables the menu open/close animation */\n disableAnimation?: boolean;\n /** container the menu popover portal is rendered into (defaults to document.body) */\n portalContainer?: HTMLElement;\n}\n\n/**\n * AddFilterMenu\n *\n * Renders a menu trigger that opens a list of addable filters. Selecting an\n * item triggers the parent to seed a default value and open the modal.\n */\nconst AddFilterMenu = ({\n classNames = {},\n disableAnimation = false,\n portalContainer = undefined,\n}: AddFilterMenuProps) => {\n const { unusedFilters, addFilter, getFilterInstanceByName } = useFilters();\n\n const menuItems = unusedFilters.map((name) => {\n const instance = getFilterInstanceByName(name);\n const config = instance.config as { text?: string };\n const label = config?.text ?? name;\n return {\n key: name,\n icon: instance.icon,\n label,\n onClick: () => {\n addFilter(name);\n },\n };\n });\n\n return (\n <Menu\n className={{\n item: classNames.addFilterMenuItem,\n trigger: classNames.addFilterMenuButton,\n }}\n disableAnimation={disableAnimation}\n isDisabled={!menuItems.length}\n items={menuItems}\n placement=\"bottom-start\"\n portalContainer={portalContainer}\n triggerButtonProps={{\n 'aria-label': 'Add Filter',\n 'data-testid': 'add_filter_button',\n disableRipple: true,\n size: 'sm',\n variant: 'bordered',\n }}\n >\n <FaSliders />\n Filter\n </Menu>\n );\n};\n\nexport default AddFilterMenu;\n","import { Suspense } from 'react';\nimport { PiSlidersHorizontalBold } from 'react-icons/pi';\n\nimport Button from '@fuf-stack/pixels/Button';\nimport Modal from '@fuf-stack/pixels/Modal';\nimport SubmitButton from '@fuf-stack/uniform/SubmitButton';\n\nimport { useFilters } from './FiltersContext';\n\ninterface FilterModalProps {\n classNames?: Partial<{\n header: string;\n footer: string;\n body: string;\n }>;\n /** disables the modal open/close animation */\n disableAnimation?: boolean;\n /** container the modal portal is rendered into (defaults to document.body) */\n portalContainer?: HTMLElement;\n}\n\nconst FilterModal = ({\n classNames = {},\n disableAnimation = false,\n portalContainer = undefined,\n}: FilterModalProps) => {\n const {\n closeFilterModal,\n getFilterFormFieldName,\n getFilterInstanceByName,\n modalFilterName,\n removeFilter,\n } = useFilters();\n\n // don't render if no filter is open\n if (!modalFilterName) {\n return null;\n }\n\n const instance = getFilterInstanceByName(modalFilterName);\n const config = instance.config as { text?: string };\n\n // get the form component from the instance\n const FormComponent = instance.components.Form;\n\n return (\n <Modal\n className={{\n body: classNames.body,\n footer: classNames.footer,\n header: classNames.header,\n }}\n disableAnimation={disableAnimation}\n footer={\n <>\n <Button\n ariaLabel=\"Remove filter\"\n color=\"danger\"\n onClick={() => {\n removeFilter(modalFilterName);\n }}\n testId=\"remove_filter_button\"\n variant=\"flat\"\n >\n Remove\n </Button>\n <SubmitButton ariaLabel=\"Apply filter\" testId=\"apply_filter_button\">\n Apply Filter\n </SubmitButton>\n </>\n }\n header={\n <>\n {instance.icon ?? <PiSlidersHorizontalBold />}\n <div>{`${config?.text ?? modalFilterName} Filter`}</div>\n </>\n }\n isOpen\n onClose={closeFilterModal}\n portalContainer={portalContainer}\n >\n <Suspense>\n <FormComponent\n config={config}\n fieldName={getFilterFormFieldName(modalFilterName)}\n />\n </Suspense>\n </Modal>\n );\n};\n\nexport default FilterModal;\n","import { useState } from 'react';\nimport { FaSearch } from 'react-icons/fa';\n\nimport { motion } from '@fuf-stack/pixel-motion';\nimport Button from '@fuf-stack/pixels/Button';\nimport { useFormContext } from '@fuf-stack/uniform/hooks/useFormContext';\nimport Input from '@fuf-stack/uniform/Input';\nimport SubmitButton from '@fuf-stack/uniform/SubmitButton';\n\nexport type SearchConfiguration =\n | boolean\n | {\n /** Placeholder shown in the search input */\n placeholder?: string;\n };\n\ninterface SearchInputProps {\n /** Slots class names passed from parent variants */\n classNames?: Partial<{\n searchWrapper: string;\n searchShowButton: string;\n searchMotionDiv: string;\n searchInput: string;\n searchInputWrapper: string;\n searchSubmitButton: string;\n }>;\n /** Search configuration */\n config: SearchConfiguration;\n}\n\n/**\n * SearchInput\n *\n * By default renders only a search button. When clicked, the text input animates in\n * and a trailing submit button is shown.\n */\nconst SearchInput = ({ classNames = {}, config }: SearchInputProps) => {\n const { formState, setFocus, triggerSubmit } = useFormContext();\n\n // Auto-open if there is an initial or externally set search value\n const isInitiallyVisible = !!formState?.defaultValues?.search;\n const [isVisible, setIsVisible] = useState(isInitiallyVisible);\n\n const placeholder =\n typeof config === 'object' ? config.placeholder : undefined;\n\n return (\n <div className={classNames.searchWrapper}>\n {!isVisible && (\n <Button\n ariaLabel=\"Show search input\"\n className={classNames.searchShowButton}\n icon={<FaSearch />}\n onClick={() => {\n setIsVisible(true);\n }}\n size=\"sm\"\n testId=\"show_search_input_button\"\n variant=\"bordered\"\n />\n )}\n {isVisible ? (\n <motion.div\n key=\"search-input\"\n animate={{ opacity: 1 }}\n className={classNames.searchMotionDiv}\n // if the input was not initially visible, animate in\n initial={!isInitiallyVisible ? { opacity: 0.5 } : false}\n onAnimationComplete={() => {\n // if the input was not initially visible, focus it\n if (!isInitiallyVisible) {\n setFocus('search');\n }\n }}\n transition={{\n duration: 0.3,\n ease: 'circOut',\n }}\n >\n <Input\n className={{\n input: classNames.searchInput,\n inputWrapper: classNames.searchInputWrapper,\n }}\n clearable\n debounceDelay={0}\n placeholder={placeholder}\n size=\"sm\"\n name=\"search\"\n // submit on clear\n onClear={() => {\n triggerSubmit();\n }}\n />\n <SubmitButton\n className={classNames.searchSubmitButton}\n color=\"primary\"\n icon={<FaSearch />}\n size=\"sm\"\n testId=\"submit_search_button\"\n ariaLabel=\"Submit search\"\n // eslint-disable-next-line react/no-children-prop\n children={null}\n />\n </motion.div>\n ) : null}\n </div>\n );\n};\n\nexport default SearchInput;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { VetoInput } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FiltersConfiguration } from './filters/types';\nimport type { SearchConfiguration } from './Subcomponents/SearchInput';\n\nimport createDebug from 'debug';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport Form from '@fuf-stack/uniform/Form';\n\nimport { useFilterValidation } from './hooks/useFilterValidation';\nimport ActiveFilters from './Subcomponents/ActiveFilters';\nimport AddFilterMenu from './Subcomponents/AddFilterMenu';\nimport FilterModal from './Subcomponents/FilterModal';\nimport { FiltersContextProvider } from './Subcomponents/FiltersContext';\nimport SearchInput from './Subcomponents/SearchInput';\n\nconst debug = createDebug('megapixels:Filter');\n\n// filter styling variants\nexport const filterVariants = tv({\n slots: {\n // outer wrapper\n base: 'flex flex-auto flex-col',\n // add filter menu trigger button\n addFilterMenuButton: '',\n // add filter menu item\n addFilterMenuItem: '',\n // active filter label\n activeFilterLabel: 'h-8 cursor-pointer rounded-md dark:text-foreground',\n // filter modal body\n filterModalBody: '',\n // filter modal header\n filterModalHeader: 'flex items-center gap-3 text-default-700',\n // filter modal footer\n filterModalFooter: 'justify-between',\n // form element\n form: 'mb-3 flex flex-wrap gap-3',\n // search input field\n searchInput: '',\n // search input wrapper (inner control)\n searchInputWrapper: '',\n // search motion container\n searchMotionDiv: 'flex w-72 gap-2',\n // search show button\n searchShowButton: '',\n // search submit button\n searchSubmitButton: '',\n // search wrapper\n searchWrapper: 'flex items-center',\n },\n});\n\ntype ClassName = TVClassName<typeof filterVariants>;\n\nexport interface FilterValues {\n search?: string;\n filter?: string | Record<string, unknown> | null;\n}\n\nexport type FilterChildRenderFn = (values: {\n search?: string;\n filter?: Record<string, unknown>;\n}) => ReactNode;\n\n/**\n * Filter\n *\n * Controlled, form-driven filter UI.\n *\n * Responsibilities\n * - Derives initial form values from the controlled `values` prop\n * - Builds a composite validation schema from the filter registry (and optional search)\n * - Exposes ergonomic UI: active filters list, add/remove actions, and per-filter modal\n * - Commits changes by invoking the controlled `onChange` callback on submit\n *\n * Structure\n * - Owns an ex-forms `Form` that wraps the entire filter experience\n * - Optionally renders a search input bound to the `search` field\n * - Renders ActiveFilters, AddFilterMenu, and FilterModal inside a shared context\n * - Optionally renders children as a render-prop with the resolved `values`\n */\nexport interface FilterProps {\n /** Optional render-prop that receives the resolved, controlled values */\n children?: FilterChildRenderFn;\n /** CSS class name */\n className?: ClassName;\n /** Disables the add-filter menu and modal open/close animations */\n disableAnimation?: boolean;\n /** Configuration of the filter */\n config: {\n /**\n * Declarative filter configuration. Each entry ties a logical name to a\n * registry filter type and (optionally) per-usage config overrides.\n */\n filters: FiltersConfiguration;\n /** Optional configuration for search field */\n search?: SearchConfiguration;\n };\n /** ex-forms form instance name. Defaults to \"filterComponentForm\". */\n formName?: string;\n /** Controlled setter invoked on submit with the next canonical values */\n onChange: (nextValues: FilterValues) => void;\n /**\n * Container the add-filter menu and filter modal portals render into.\n * Defaults to document.body; set this to keep portals scoped to a parent\n * (e.g. for embedding or deterministic snapshot tests).\n */\n portalContainer?: HTMLElement;\n /** Controlled committed state: the canonical `search` and `filter` values */\n values: FilterValues;\n}\n\n/**\n * Renders the filter UI bound to a single ex-forms `Form`.\n * The form is the source of truth during user interaction; the committed\n * state is controlled by the parent via `values`/`onChange`.\n */\nconst Filter = ({\n children = undefined,\n className = undefined,\n config,\n disableAnimation = false,\n formName = 'filterComponentForm',\n onChange,\n portalContainer = undefined,\n values,\n}: FilterProps) => {\n // Submit handler: map form state back into the controlled `values` shape\n const handleSubmit = (nextValues: Record<string, unknown>) => {\n debug('handleSubmit', { nextValues });\n onChange(nextValues);\n };\n\n // Build validation schema for all configured filters (and optional search)\n const validation = useFilterValidation(\n config.filters,\n Boolean(config.search),\n );\n\n // validate controlled values are valid\n const {\n data: valuesValidated,\n errors,\n success,\n } = validation.validate(values as VetoInput);\n\n // classNames from slots\n const variants = filterVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n debug('render', {\n props: { config, values },\n validation: { errors, success, valuesValidated },\n });\n\n return (\n <div className={classNames.base}>\n {/*\n Uniform Form wrapper\n - initialValues derive from controlled props (with optional defaults)\n - validation is built from the registry for all configured filters\n - onSubmit maps form values back into values/onChange\n */}\n <Form\n className={classNames.form}\n // disable debug mode for now\n debug={{ disable: true }}\n initialValues={valuesValidated ?? {}}\n name={formName}\n onSubmit={handleSubmit}\n validation={validation}\n >\n {/* Render search if search config is provided */}\n {config.search ? (\n <SearchInput\n classNames={{\n searchInput: classNames.searchInput,\n searchInputWrapper: classNames.searchInputWrapper,\n searchMotionDiv: classNames.searchMotionDiv,\n searchShowButton: classNames.searchShowButton,\n searchSubmitButton: classNames.searchSubmitButton,\n searchWrapper: classNames.searchWrapper,\n }}\n config={config.search}\n />\n ) : null}\n {/*\n FiltersContextProvider exposes a minimal API for the UI layer:\n - activeFilters/unusedFilters by name\n - helpers to get merged config, value, components, and field names\n - methods to add/remove filters and show/close the modal\n */}\n <FiltersContextProvider config={config.filters}>\n <ActiveFilters className={classNames.activeFilterLabel} />\n <AddFilterMenu\n classNames={{\n addFilterMenuButton: classNames.addFilterMenuButton,\n addFilterMenuItem: classNames.addFilterMenuItem,\n }}\n disableAnimation={disableAnimation}\n portalContainer={portalContainer}\n />\n <FilterModal\n classNames={{\n body: classNames.filterModalBody,\n footer: classNames.filterModalFooter,\n header: classNames.filterModalHeader,\n }}\n disableAnimation={disableAnimation}\n portalContainer={portalContainer}\n />\n </FiltersContextProvider>\n </Form>\n {/* Children can consume derived search string and parsed filter object */}\n {children?.(valuesValidated ?? {})}\n </div>\n );\n};\n\nexport default Filter;\n","import type { FilterDefinition, FilterFactory } from './types';\n\n/**\n * createFilter\n *\n * Builds a filter factory from a static FilterDefinition. The returned factory\n * accepts a usage descriptor (name/icon and optional partial config) and\n * produces a concrete FilterInstance with:\n * - merged config (shallow: definition.defaults.config overlaid by overrides)\n * - Form/Display components\n * - validate function (forwarded from the definition)\n * - defaultValue (forwarded from the definition)\n * - name and icon for UI integration\n *\n * @typeParam Config - Configuration object shape for the filter\n * @typeParam Value - Runtime value type for the filter\n * @param definition - Static description of the filter (components, defaults, validate)\n * @returns FilterFactory that creates FilterInstance<Config, Value>\n */\nconst createFilter = <Config, Value>(\n definition: FilterDefinition<Config, Value>,\n): FilterFactory<Config, Value> => {\n return ({ name, icon, config }) => {\n return {\n components: definition.components,\n config: { ...definition.defaults.config, ...(config ?? {}) },\n defaultValue: definition.defaults.value,\n icon,\n name,\n validation: definition.validation,\n };\n };\n};\n\nexport default createFilter;\n","import type { FilterDisplayProps } from '../types';\nimport type { Config, Value } from './schema';\n\n/**\n * Read-only presentation for the boolean filter.\n * Displays human-readable text based on the current boolean `value`\n * and the provided `config` strings.\n */\nconst Display = ({\n value,\n config: { text, textPrefix, textNoWord },\n}: FilterDisplayProps<Config, Value>) => {\n if (typeof value === 'boolean') {\n return (\n <>\n {`${value ? textPrefix : `${textPrefix} ${textNoWord ?? 'no'}`} ${text}`}\n </>\n );\n }\n return <>{`${text}...`}</>;\n};\n\nexport default Display;\n","import type { FilterFormProps } from '../types';\nimport type { Config } from './schema';\n\nimport Switch from '@fuf-stack/uniform/Switch';\n\n/**\n * Renders the form control for the boolean filter.\n * Uses a `Switch` to toggle the boolean value and composes\n * the label from the provided `config` and `fieldName`.\n */\nconst Form = ({\n fieldName,\n config: { text, textPrefix },\n}: FilterFormProps<Config>) => {\n return <Switch label={`${textPrefix} ${text}`} name={fieldName} />;\n};\n\nexport default Form;\n","import type { vInfer } from '@fuf-stack/veto';\n\nimport { boolean, object, string } from '@fuf-stack/veto';\n\n/** configuration of the filter */\nexport const config = object({\n /**\n * Human‑readable label used in the UI (e.g. in the chip and modal header).\n * Examples: \"Magical\", \"Haunted\"\n */\n text: string(),\n /**\n * Optional word shown before the label when building sentence‑like chips.\n * Examples: \"is\" → \"is Magical\"\n */\n textPrefix: string().optional(),\n /**\n * Optional negation word used when a boolean value is false.\n * Examples: \"not\" → \"is not Magical\"\n */\n textNoWord: string().optional(),\n});\n\n/** validate the filter value */\nexport const validate = (_config?: Config) => {\n return boolean().optional();\n};\n\nexport type Config = vInfer<typeof config>;\nexport type Value = vInfer<ReturnType<typeof validate>>;\n","/* eslint-disable import-x/prefer-default-export */\n\nimport type { Config, Value } from './schema';\n\nimport createFilter from '../createFilter';\nimport Display from './Display';\nimport Form from './Form';\nimport { validate } from './schema';\n\n/**\n * Boolean filter definition for the Filter system.\n * Provides Display and Form components, default value/config, and validation.\n *\n * Defaults:\n * - value: true\n * - config: { text: 'Active', textPrefix: 'is', textNoWord: 'no' }\n *\n * @see Display\n * @see Form\n * @see validate\n */\nexport const boolean = createFilter<Config, Value>({\n components: { Display, Form },\n defaults: {\n value: true,\n config: { text: 'Active', textPrefix: 'is', textNoWord: 'no' },\n },\n validation: validate,\n});\n","import type { FilterDisplayProps } from '../types';\nimport type { Config, Value } from './schema';\n\n/**\n * Read-only presentation for the checkboxes filter.\n * Resolves and displays selected option labels based on `value` and `config`.\n * Supports string, ReactNode, and function labels (mode: 'display').\n */\nconst Display = ({\n value,\n config: { text, options },\n}: FilterDisplayProps<Config, Value>) => {\n if (value && value.length > 0) {\n return (\n <span className=\"flex items-center gap-1\">\n {text} is\n {value.map((val) => {\n const option = options.find((op) => {\n return op.value === val;\n });\n const label = option?.label ?? val;\n const resolvedLabel =\n typeof label === 'function' ? label('display') : label;\n return <span key={val}>{resolvedLabel}</span>;\n })}\n </span>\n );\n }\n return `${text} is ...`;\n};\n\nexport default Display;\n","import type { FilterFormProps } from '../types';\nimport type { Config } from './schema';\n\nimport Checkboxes from '@fuf-stack/uniform/Checkboxes';\n\n/**\n * Renders the form control for the checkboxes filter.\n * Uses a `Checkboxes` to select multiple options.\n * Resolves function labels with 'form' mode.\n */\nconst Form = ({ fieldName, config }: FilterFormProps<Config>) => {\n const resolvedOptions = config.options.map((option) => {\n return {\n ...option,\n label:\n typeof option.label === 'function'\n ? option.label('form')\n : option.label,\n };\n });\n\n return <Checkboxes name={fieldName} options={resolvedOptions} />;\n};\n\nexport default Form;\n","import type { vInfer } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\n\nimport { any, array, object, refineArray, string } from '@fuf-stack/veto';\n\n/** configuration of the filter */\nexport const config = object({\n /**\n * Human‑readable label used in the UI (e.g. label and modal header).\n * Example: \"Snacks\", \"Mood\"\n */\n text: string(),\n /**\n * Options rendered as multiple checkboxes. Each option needs a `label`\n * (what the user sees) and a `value` (what is written into the form state).\n * Label can be a string, React node, or a function that receives mode\n * ('form' or 'display') and returns a React node.\n */\n options: array(object({ label: any(), value: string() })),\n});\n\n/** Type-safe Config that overrides label to support ReactNode or function */\nexport type Config = Omit<vInfer<typeof config>, 'options'> & {\n options: {\n label: ReactNode | ((mode: 'form' | 'display') => ReactNode);\n value: string;\n }[];\n};\n\n/** validate the filter value */\nexport const validate = (cfg?: Config) => {\n return refineArray(array(string()).optional())({\n unique: true,\n custom: (values, ctx) => {\n if (!cfg) {\n return;\n }\n values.forEach((value) => {\n if (\n !cfg.options.find((option) => {\n return option?.value === value;\n })\n ) {\n ctx.addIssue({\n code: 'custom',\n message: `Invalid value: ${value}`,\n });\n }\n });\n },\n });\n};\n\nexport type Value = vInfer<ReturnType<typeof validate>>;\n","/* eslint-disable import-x/prefer-default-export */\n\nimport type { Config, Value } from './schema';\n\nimport createFilter from '../createFilter';\nimport Display from './Display';\nimport Form from './Form';\nimport { validate } from './schema';\n\n/**\n * Checkboxes filter definition for the Filter system.\n * Provides Display and Form components, default value/config, and validation.\n *\n * Defaults:\n * - value: []\n * - config: { text: 'Options', options: [] }\n *\n * @see Display\n * @see Form\n * @see validate\n */\nexport const checkboxes = createFilter<Config, Value>({\n components: { Display, Form },\n defaults: { value: [], config: { text: 'Options', options: [] } },\n validation: validate,\n});\n","import Filter from './Filter';\nimport { boolean } from './filters/boolean/boolean';\nimport { checkboxes } from './filters/checkboxes/checkboxes';\n\n// export types\nexport type * from './filters/types';\n\n// export helpers\nexport { default as createFilter } from './filters/createFilter';\n\n// export all filters\nexport const filters = {\n boolean,\n checkboxes,\n};\n\n// export everything from the Filter component (types and filterVariants)\nexport * from './Filter';\n\n// export the Filter component as default\nexport default Filter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,uBACX,SACA,eACG;CACH,OAAO,cAA4B;EAEjC,IAAI,eAA4C,CAAC;EACjD,QAAQ,SAAS,MAAM;GACrB,eAAe;IACb,GAAG;KACF,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM;GACjC;EACF,CAAC;EAmBD,OAAO,KAAK;GAfV,QAAQ,aAAa,CAAC,CACnB,KAAK,OAAO,YAAY,CAAC,CAAC,CAC1B,GAAG,OAAO,YAAY,CAAC,CAAC,CACxB,SAAS,CAAC,CACV,SAAS,CAAC,CAEV,WAAW,QAAQ;IAClB,OAA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perties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_VirtualList = require("../VirtualList-BALnlyjy.cjs");
6
+ exports.VirtualList = require_VirtualList.VirtualList;
7
+ exports.default = require_VirtualList.VirtualList_default;
8
+ exports.virtualListVariants = require_VirtualList.virtualListVariants;
@@ -0,0 +1,2 @@
1
+ import { n as VirtualListProps, r as virtualListVariants, t as VirtualList } from "../index-D7ZLM0zx.cjs";
2
+ export { VirtualList, VirtualList as default, type VirtualListProps, virtualListVariants };
@@ -0,0 +1,2 @@
1
+ import { n as VirtualListProps, r as virtualListVariants, t as VirtualList } from "../index-jFySXsl9.js";
2
+ export { VirtualList, VirtualList as default, type VirtualListProps, virtualListVariants };
@@ -0,0 +1,2 @@
1
+ import { n as VirtualList, r as virtualListVariants, t as VirtualList_default } from "../VirtualList-DQ4uR-wR.js";
2
+ export { VirtualList, VirtualList_default as default, virtualListVariants };
@@ -0,0 +1,172 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
2
+ const require_useInfiniteVirtualizer = require("./useInfiniteVirtualizer-BK0VroW4.cjs");
3
+ let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
4
+ let _fuf_stack_pixels_ScrollShadow = require("@fuf-stack/pixels/ScrollShadow");
5
+ _fuf_stack_pixels_ScrollShadow = require_rolldown_runtime.__toESM(_fuf_stack_pixels_ScrollShadow, 1);
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ //#region src/VirtualList/VirtualList.tsx
8
+ const virtualListVariants = (0, _fuf_stack_pixel_utils.tv)({ slots: {
9
+ base: "w-full max-w-2xl",
10
+ item: "box-border border-b border-divider bg-content1 p-3 text-foreground",
11
+ list: "relative m-0 list-none p-0",
12
+ loadingMoreCell: "py-3 text-center text-default-500",
13
+ placeholderItem: "box-border border-b border-divider bg-content1 px-3",
14
+ scrollContainer: "w-full min-w-80 overflow-y-auto overflow-x-hidden",
15
+ scrollFrame: "rounded-md border border-divider bg-content1",
16
+ scrollShadow: ""
17
+ } });
18
+ /**
19
+ * Generic virtualized list with optional cursor-based infinite scrolling.
20
+ *
21
+ * Behavior:
22
+ * - renders only virtualized rows for performance
23
+ * - supports dynamic heights via shared `useInfiniteVirtualizer`
24
+ * - supports two scrollbar strategies in infinite mode (`loaded-count` and
25
+ * `total-count`) by appending placeholders and a load-more sentinel
26
+ */
27
+ const VirtualList = ({ className = void 0, data, infiniteScroll = void 0, loadingMoreContent = "Loading more...", renderItem, retryContent = "Load next page", testId = void 0, virtualization }) => {
28
+ const classNames = (0, _fuf_stack_pixel_utils.variantsToClassNames)(virtualListVariants(), className, "base");
29
+ const baseItems = data.map((item, index) => {
30
+ return {
31
+ index,
32
+ key: `item-${index}`,
33
+ kind: "item",
34
+ value: item
35
+ };
36
+ });
37
+ if (infiniteScroll?.scrollbarMode === "total-count") {
38
+ const placeholderCount = Math.max(infiniteScroll.pageInfo.totalCount - data.length, 0);
39
+ for (let placeholderOffset = 0; placeholderOffset < placeholderCount; placeholderOffset += 1) baseItems.push({
40
+ index: data.length + placeholderOffset,
41
+ key: `placeholder-${data.length + placeholderOffset}`,
42
+ kind: "placeholder"
43
+ });
44
+ }
45
+ if (infiniteScroll && (infiniteScroll.pageInfo.hasNextPage || infiniteScroll.isFetchingNextPage || infiniteScroll.loadMoreError)) baseItems.push({
46
+ index: -1,
47
+ key: "load-more",
48
+ kind: "load-more"
49
+ });
50
+ const loadedItemCount = data.length;
51
+ const { measureElement, retry, scrollElementRef, totalSize, virtualItems } = require_useInfiniteVirtualizer.useInfiniteVirtualizer({
52
+ count: baseItems.length,
53
+ dynamicRowHeight: virtualization.dynamicRowHeight ?? Boolean(infiniteScroll),
54
+ estimateSize: () => {
55
+ return virtualization.estimateRowHeight ?? 45;
56
+ },
57
+ hasNextPage: infiniteScroll?.pageInfo.hasNextPage,
58
+ isFetchingNextPage: infiniteScroll?.isFetchingNextPage,
59
+ loadedCount: loadedItemCount,
60
+ loadMoreError: infiniteScroll?.loadMoreError,
61
+ loadMoreThreshold: infiniteScroll?.loadMoreThreshold,
62
+ onLoadMore: infiniteScroll ? () => {
63
+ infiniteScroll.onLoadMore({
64
+ cursor: infiniteScroll.pageInfo.endCursor,
65
+ direction: "forward"
66
+ });
67
+ } : void 0,
68
+ overscan: virtualization.overscan,
69
+ shouldLoadMore: ({ loadMoreThreshold, virtualItems: activeItems }) => {
70
+ if (!infiniteScroll) return false;
71
+ const kindsInRange = new Set(activeItems.map((item) => {
72
+ return baseItems[item.index]?.kind;
73
+ }));
74
+ if (kindsInRange.has("placeholder") || kindsInRange.has("load-more")) return true;
75
+ return (activeItems[activeItems.length - 1]?.index ?? 0) >= Math.max(loadedItemCount - loadMoreThreshold - 1, 0);
76
+ }
77
+ });
78
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
79
+ className: classNames.base,
80
+ "data-slot": "base",
81
+ "data-testid": testId,
82
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
83
+ className: classNames.scrollFrame,
84
+ "data-slot": "scroll-frame",
85
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixels_ScrollShadow.default, {
86
+ ref: scrollElementRef,
87
+ className: classNames.scrollShadow ? `${classNames.scrollContainer} ${classNames.scrollShadow}` : classNames.scrollContainer,
88
+ visibility: infiniteScroll?.loadMoreError ? "none" : "auto",
89
+ dataSlot: "scroll-container",
90
+ style: { maxHeight: virtualization.maxHeight },
91
+ size: virtualization.scrollShadowSize ?? 40,
92
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
93
+ className: classNames.list,
94
+ "data-slot": "list",
95
+ style: { height: `${totalSize}px` },
96
+ children: virtualItems.map((virtualItem) => {
97
+ const item = baseItems[virtualItem.index];
98
+ if (!item) return null;
99
+ if (item.kind === "placeholder") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
100
+ ref: measureElement,
101
+ className: classNames.placeholderItem,
102
+ "data-index": virtualItem.index,
103
+ "data-slot": "placeholder-item",
104
+ style: {
105
+ alignItems: "center",
106
+ display: "flex",
107
+ height: `${virtualItem.size}px`,
108
+ position: "absolute",
109
+ transform: `translateY(${virtualItem.start}px)`,
110
+ width: "100%"
111
+ },
112
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "block h-3 w-2/3 animate-pulse rounded bg-default-300/50 dark:bg-default-300/20" })
113
+ }, item.key);
114
+ if (item.kind === "load-more") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
115
+ ref: measureElement,
116
+ className: classNames.loadingMoreCell,
117
+ "data-index": virtualItem.index,
118
+ "data-slot": "loading-more-cell",
119
+ style: {
120
+ position: "absolute",
121
+ transform: `translateY(${virtualItem.start}px)`,
122
+ width: "100%"
123
+ },
124
+ children: infiniteScroll?.loadMoreError ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
125
+ onClick: retry,
126
+ type: "button",
127
+ children: infiniteScroll.retryContent ?? retryContent
128
+ }) : loadingMoreContent
129
+ }, item.key);
130
+ if (item.kind === "item") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
131
+ ref: measureElement,
132
+ className: classNames.item,
133
+ "data-index": virtualItem.index,
134
+ "data-slot": "item",
135
+ style: {
136
+ position: "absolute",
137
+ transform: `translateY(${virtualItem.start}px)`,
138
+ width: "100%"
139
+ },
140
+ children: renderItem(item.value, item.index)
141
+ }, item.key);
142
+ return null;
143
+ })
144
+ })
145
+ })
146
+ })
147
+ });
148
+ };
149
+ //#endregion
150
+ //#region src/VirtualList/index.ts
151
+ var VirtualList_default = VirtualList;
152
+ //#endregion
153
+ Object.defineProperty(exports, "VirtualList", {
154
+ enumerable: true,
155
+ get: function() {
156
+ return VirtualList;
157
+ }
158
+ });
159
+ Object.defineProperty(exports, "VirtualList_default", {
160
+ enumerable: true,
161
+ get: function() {
162
+ return VirtualList_default;
163
+ }
164
+ });
165
+ Object.defineProperty(exports, "virtualListVariants", {
166
+ enumerable: true,
167
+ get: function() {
168
+ return virtualListVariants;
169
+ }
170
+ });
171
+
172
+ //# sourceMappingURL=VirtualList-BALnlyjy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VirtualList-BALnlyjy.cjs","names":["useInfiniteVirtualizer","ScrollShadow"],"sources":["../src/VirtualList/VirtualList.tsx","../src/VirtualList/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\nimport type {\n DataTableInfiniteScrollFeature,\n DataTableVirtualizationFeature,\n} from '../DataTable';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport ScrollShadow from '@fuf-stack/pixels/ScrollShadow';\n\nimport { useInfiniteVirtualizer } from '../hooks/useInfiniteVirtualizer';\n\nexport const virtualListVariants = tv({\n slots: {\n // Root wrapper for the entire component.\n base: 'w-full max-w-2xl',\n // Rendered item row for loaded data.\n item: 'box-border border-b border-divider bg-content1 p-3 text-foreground',\n // Positioned list container that owns virtual row placement.\n list: 'relative m-0 list-none p-0',\n // Footer row for loading/retry actions in infinite mode.\n loadingMoreCell: 'py-3 text-center text-default-500',\n // Skeleton-like placeholder for unloaded rows in total-count mode.\n placeholderItem: 'box-border border-b border-divider bg-content1 px-3',\n // Scrollable viewport used as the virtualizer scroll element.\n scrollContainer: 'w-full min-w-80 overflow-y-auto overflow-x-hidden',\n // Visual frame around the masked scroll area (stays fully opaque).\n scrollFrame: 'rounded-md border border-divider bg-content1',\n // Optional styling slot for ScrollShadow wrapper behavior.\n scrollShadow: '',\n },\n});\n\ntype VirtualListClassName = TVClassName<typeof virtualListVariants>;\n\nexport interface VirtualListProps<TData> {\n /** Slot-based class overrides generated from `virtualListVariants`. */\n className?: VirtualListClassName;\n /** Currently loaded items to render. */\n data: TData[];\n /** Optional cursor-based infinite-scroll configuration. */\n infiniteScroll?: DataTableInfiniteScrollFeature;\n /** Content rendered in the load-more row while fetching. */\n loadingMoreContent?: ReactNode;\n /** Fallback retry label when load-more has failed. */\n retryContent?: ReactNode;\n /** Renderer for each loaded item. */\n renderItem: (item: TData, index: number) => ReactNode;\n /** Optional `data-testid` prefix. */\n testId?: string;\n /** Virtualizer viewport and measurement options. */\n virtualization: DataTableVirtualizationFeature;\n}\n\n/**\n * Generic virtualized list with optional cursor-based infinite scrolling.\n *\n * Behavior:\n * - renders only virtualized rows for performance\n * - supports dynamic heights via shared `useInfiniteVirtualizer`\n * - supports two scrollbar strategies in infinite mode (`loaded-count` and\n * `total-count`) by appending placeholders and a load-more sentinel\n */\nconst VirtualList = <TData,>({\n className = undefined,\n data,\n infiniteScroll = undefined,\n loadingMoreContent = 'Loading more...',\n renderItem,\n retryContent = 'Load next page',\n testId = undefined,\n virtualization,\n}: VirtualListProps<TData>) => {\n const variants = virtualListVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n /** Internal flattened item model consumed by the virtualizer render loop. */\n type VirtualListItem =\n | { index: number; key: string; kind: 'item'; value: TData }\n | { index: number; key: string; kind: 'load-more' | 'placeholder' };\n\n // Start with currently loaded data items.\n const baseItems: VirtualListItem[] = data.map((item, index) => {\n return {\n index,\n key: `item-${index}`,\n kind: 'item',\n value: item,\n };\n });\n\n if (infiniteScroll?.scrollbarMode === 'total-count') {\n // Reserve full scrollbar height by adding placeholders for unloaded rows.\n const placeholderCount = Math.max(\n infiniteScroll.pageInfo.totalCount - data.length,\n 0,\n );\n for (\n let placeholderOffset = 0;\n placeholderOffset < placeholderCount;\n placeholderOffset += 1\n ) {\n baseItems.push({\n index: data.length + placeholderOffset,\n key: `placeholder-${data.length + placeholderOffset}`,\n kind: 'placeholder',\n });\n }\n }\n\n if (\n infiniteScroll &&\n (infiniteScroll.pageInfo.hasNextPage ||\n infiniteScroll.isFetchingNextPage ||\n infiniteScroll.loadMoreError)\n ) {\n // Add a trailing sentinel row for loading/retry behavior.\n baseItems.push({\n index: -1,\n key: 'load-more',\n kind: 'load-more',\n });\n }\n\n const loadedItemCount = data.length;\n\n // Shared virtualizer handles windowing + load-more triggering; this component\n // only maps its virtual items to list markup.\n const { measureElement, retry, scrollElementRef, totalSize, virtualItems } =\n useInfiniteVirtualizer({\n count: baseItems.length,\n dynamicRowHeight:\n virtualization.dynamicRowHeight ?? Boolean(infiniteScroll),\n estimateSize: () => {\n return virtualization.estimateRowHeight ?? 45;\n },\n hasNextPage: infiniteScroll?.pageInfo.hasNextPage,\n isFetchingNextPage: infiniteScroll?.isFetchingNextPage,\n loadedCount: loadedItemCount,\n loadMoreError: infiniteScroll?.loadMoreError,\n loadMoreThreshold: infiniteScroll?.loadMoreThreshold,\n onLoadMore: infiniteScroll\n ? () => {\n infiniteScroll.onLoadMore({\n cursor: infiniteScroll.pageInfo.endCursor,\n direction: 'forward',\n });\n }\n : undefined,\n overscan: virtualization.overscan,\n // Decide when to request the next page from the parent.\n shouldLoadMore: ({ loadMoreThreshold, virtualItems: activeItems }) => {\n if (!infiniteScroll) {\n return false;\n }\n\n // If placeholders or the load-more row are visible, fetch immediately.\n const kindsInRange = new Set(\n activeItems.map((item) => {\n return baseItems[item.index]?.kind;\n }),\n );\n if (kindsInRange.has('placeholder') || kindsInRange.has('load-more')) {\n return true;\n }\n\n // Otherwise prefetch shortly before the loaded tail enters viewport.\n const lastVirtualIndex =\n activeItems[activeItems.length - 1]?.index ?? 0;\n const boundary = Math.max(loadedItemCount - loadMoreThreshold - 1, 0);\n return lastVirtualIndex >= boundary;\n },\n });\n\n return (\n <div className={classNames.base} data-slot=\"base\" data-testid={testId}>\n <div className={classNames.scrollFrame} data-slot=\"scroll-frame\">\n <ScrollShadow\n ref={scrollElementRef}\n className={\n classNames.scrollShadow\n ? `${classNames.scrollContainer} ${classNames.scrollShadow}`\n : classNames.scrollContainer\n }\n // show scroll shadow when there is no page load more error\n visibility={infiniteScroll?.loadMoreError ? 'none' : 'auto'}\n dataSlot=\"scroll-container\"\n style={{ maxHeight: virtualization.maxHeight }}\n size={virtualization.scrollShadowSize ?? 40}\n >\n <ul\n className={classNames.list}\n data-slot=\"list\"\n // Total virtual height (loaded rows + optional placeholders/sentinel).\n style={{ height: `${totalSize}px` }}\n >\n {virtualItems.map((virtualItem) => {\n const item = baseItems[virtualItem.index];\n if (!item) {\n return null;\n }\n\n if (item.kind === 'placeholder') {\n // Reserved space for rows we have not loaded yet (total-count mode).\n return (\n <li\n key={item.key}\n ref={measureElement}\n className={classNames.placeholderItem}\n data-index={virtualItem.index}\n data-slot=\"placeholder-item\"\n style={{\n alignItems: 'center',\n display: 'flex',\n height: `${virtualItem.size}px`,\n position: 'absolute',\n transform: `translateY(${virtualItem.start}px)`,\n width: '100%',\n }}\n >\n <span className=\"block h-3 w-2/3 animate-pulse rounded bg-default-300/50 dark:bg-default-300/20\" />\n </li>\n );\n }\n\n if (item.kind === 'load-more') {\n // Infinite-scroll sentinel row: loading indicator or retry action.\n return (\n <li\n key={item.key}\n ref={measureElement}\n className={classNames.loadingMoreCell}\n data-index={virtualItem.index}\n data-slot=\"loading-more-cell\"\n style={{\n position: 'absolute',\n transform: `translateY(${virtualItem.start}px)`,\n width: '100%',\n }}\n >\n {infiniteScroll?.loadMoreError ? (\n <button onClick={retry} type=\"button\">\n {infiniteScroll.retryContent ?? retryContent}\n </button>\n ) : (\n loadingMoreContent\n )}\n </li>\n );\n }\n\n if (item.kind === 'item') {\n return (\n // Standard loaded item row.\n <li\n key={item.key}\n ref={measureElement}\n className={classNames.item}\n data-index={virtualItem.index}\n data-slot=\"item\"\n style={{\n position: 'absolute',\n transform: `translateY(${virtualItem.start}px)`,\n width: '100%',\n }}\n >\n {renderItem(item.value, item.index)}\n </li>\n );\n }\n\n return null;\n })}\n </ul>\n </ScrollShadow>\n </div>\n </div>\n );\n};\n\nexport default VirtualList;\n","import VirtualList from './VirtualList';\n\nexport { virtualListVariants } from './VirtualList';\nexport type { VirtualListProps } from './VirtualList';\n\nexport { VirtualList };\nexport default VirtualList;\n"],"mappings":";;;;;;;AAYA,MAAa,uBAAA,GAAA,uBAAA,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,WAAW,cAAc,YAAY,MAAM;QAC3C,OAAO;OACT;iBAEA,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD,EAAM,WAAU,iFAAkF,CAAA;MAChG,GAfG,KAAK,GAeR;MAIR,IAAI,KAAK,SAAS,aAEhB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;OAEE,KAAK;OACL,WAAW,WAAW;OACtB,cAAY,YAAY;OACxB,aAAU;OACV,OAAO;QACL,UAAU;QACV,WAAW,cAAc,YAAY,MAAM;QAC3C,OAAO;OACT;iBAEC,gBAAgB,gBACf,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;QAAQ,SAAS;QAAO,MAAK;kBAC1B,eAAe,gBAAgB;OAC1B,CAAA,IAER;MAEA,GAlBG,KAAK,GAkBR;MAIR,IAAI,KAAK,SAAS,QAChB,OAEE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;OAEE,KAAK;OACL,WAAW,WAAW;OACtB,cAAY,YAAY;OACxB,aAAU;OACV,OAAO;QACL,UAAU;QACV,WAAW,cAAc,YAAY,MAAM;QAC3C,OAAO;OACT;iBAEC,WAAW,KAAK,OAAO,KAAK,KAAK;MAChC,GAZG,KAAK,GAYR;MAIR,OAAO;KACT,CAAC;IACC,CAAA;GACQ,CAAA;EACX,CAAA;CACF,CAAA;AAET;;;AChRA,IAAA,sBAAe"}
@@ -0,0 +1,153 @@
1
+ import { t as useInfiniteVirtualizer } from "./useInfiniteVirtualizer-BSCDrdRi.js";
2
+ import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
3
+ import ScrollShadow from "@fuf-stack/pixels/ScrollShadow";
4
+ import { jsx } from "react/jsx-runtime";
5
+ //#region src/VirtualList/VirtualList.tsx
6
+ const virtualListVariants = tv({ slots: {
7
+ base: "w-full max-w-2xl",
8
+ item: "box-border border-b border-divider bg-content1 p-3 text-foreground",
9
+ list: "relative m-0 list-none p-0",
10
+ loadingMoreCell: "py-3 text-center text-default-500",
11
+ placeholderItem: "box-border border-b border-divider bg-content1 px-3",
12
+ scrollContainer: "w-full min-w-80 overflow-y-auto overflow-x-hidden",
13
+ scrollFrame: "rounded-md border border-divider bg-content1",
14
+ scrollShadow: ""
15
+ } });
16
+ /**
17
+ * Generic virtualized list with optional cursor-based infinite scrolling.
18
+ *
19
+ * Behavior:
20
+ * - renders only virtualized rows for performance
21
+ * - supports dynamic heights via shared `useInfiniteVirtualizer`
22
+ * - supports two scrollbar strategies in infinite mode (`loaded-count` and
23
+ * `total-count`) by appending placeholders and a load-more sentinel
24
+ */
25
+ const VirtualList = ({ className = void 0, data, infiniteScroll = void 0, loadingMoreContent = "Loading more...", renderItem, retryContent = "Load next page", testId = void 0, virtualization }) => {
26
+ const classNames = variantsToClassNames(virtualListVariants(), className, "base");
27
+ const baseItems = data.map((item, index) => {
28
+ return {
29
+ index,
30
+ key: `item-${index}`,
31
+ kind: "item",
32
+ value: item
33
+ };
34
+ });
35
+ if (infiniteScroll?.scrollbarMode === "total-count") {
36
+ const placeholderCount = Math.max(infiniteScroll.pageInfo.totalCount - data.length, 0);
37
+ for (let placeholderOffset = 0; placeholderOffset < placeholderCount; placeholderOffset += 1) baseItems.push({
38
+ index: data.length + placeholderOffset,
39
+ key: `placeholder-${data.length + placeholderOffset}`,
40
+ kind: "placeholder"
41
+ });
42
+ }
43
+ if (infiniteScroll && (infiniteScroll.pageInfo.hasNextPage || infiniteScroll.isFetchingNextPage || infiniteScroll.loadMoreError)) baseItems.push({
44
+ index: -1,
45
+ key: "load-more",
46
+ kind: "load-more"
47
+ });
48
+ const loadedItemCount = data.length;
49
+ const { measureElement, retry, scrollElementRef, totalSize, virtualItems } = useInfiniteVirtualizer({
50
+ count: baseItems.length,
51
+ dynamicRowHeight: virtualization.dynamicRowHeight ?? Boolean(infiniteScroll),
52
+ estimateSize: () => {
53
+ return virtualization.estimateRowHeight ?? 45;
54
+ },
55
+ hasNextPage: infiniteScroll?.pageInfo.hasNextPage,
56
+ isFetchingNextPage: infiniteScroll?.isFetchingNextPage,
57
+ loadedCount: loadedItemCount,
58
+ loadMoreError: infiniteScroll?.loadMoreError,
59
+ loadMoreThreshold: infiniteScroll?.loadMoreThreshold,
60
+ onLoadMore: infiniteScroll ? () => {
61
+ infiniteScroll.onLoadMore({
62
+ cursor: infiniteScroll.pageInfo.endCursor,
63
+ direction: "forward"
64
+ });
65
+ } : void 0,
66
+ overscan: virtualization.overscan,
67
+ shouldLoadMore: ({ loadMoreThreshold, virtualItems: activeItems }) => {
68
+ if (!infiniteScroll) return false;
69
+ const kindsInRange = new Set(activeItems.map((item) => {
70
+ return baseItems[item.index]?.kind;
71
+ }));
72
+ if (kindsInRange.has("placeholder") || kindsInRange.has("load-more")) return true;
73
+ return (activeItems[activeItems.length - 1]?.index ?? 0) >= Math.max(loadedItemCount - loadMoreThreshold - 1, 0);
74
+ }
75
+ });
76
+ return /* @__PURE__ */ jsx("div", {
77
+ className: classNames.base,
78
+ "data-slot": "base",
79
+ "data-testid": testId,
80
+ children: /* @__PURE__ */ jsx("div", {
81
+ className: classNames.scrollFrame,
82
+ "data-slot": "scroll-frame",
83
+ children: /* @__PURE__ */ jsx(ScrollShadow, {
84
+ ref: scrollElementRef,
85
+ className: classNames.scrollShadow ? `${classNames.scrollContainer} ${classNames.scrollShadow}` : classNames.scrollContainer,
86
+ visibility: infiniteScroll?.loadMoreError ? "none" : "auto",
87
+ dataSlot: "scroll-container",
88
+ style: { maxHeight: virtualization.maxHeight },
89
+ size: virtualization.scrollShadowSize ?? 40,
90
+ children: /* @__PURE__ */ jsx("ul", {
91
+ className: classNames.list,
92
+ "data-slot": "list",
93
+ style: { height: `${totalSize}px` },
94
+ children: virtualItems.map((virtualItem) => {
95
+ const item = baseItems[virtualItem.index];
96
+ if (!item) return null;
97
+ if (item.kind === "placeholder") return /* @__PURE__ */ jsx("li", {
98
+ ref: measureElement,
99
+ className: classNames.placeholderItem,
100
+ "data-index": virtualItem.index,
101
+ "data-slot": "placeholder-item",
102
+ style: {
103
+ alignItems: "center",
104
+ display: "flex",
105
+ height: `${virtualItem.size}px`,
106
+ position: "absolute",
107
+ transform: `translateY(${virtualItem.start}px)`,
108
+ width: "100%"
109
+ },
110
+ children: /* @__PURE__ */ jsx("span", { className: "block h-3 w-2/3 animate-pulse rounded bg-default-300/50 dark:bg-default-300/20" })
111
+ }, item.key);
112
+ if (item.kind === "load-more") return /* @__PURE__ */ jsx("li", {
113
+ ref: measureElement,
114
+ className: classNames.loadingMoreCell,
115
+ "data-index": virtualItem.index,
116
+ "data-slot": "loading-more-cell",
117
+ style: {
118
+ position: "absolute",
119
+ transform: `translateY(${virtualItem.start}px)`,
120
+ width: "100%"
121
+ },
122
+ children: infiniteScroll?.loadMoreError ? /* @__PURE__ */ jsx("button", {
123
+ onClick: retry,
124
+ type: "button",
125
+ children: infiniteScroll.retryContent ?? retryContent
126
+ }) : loadingMoreContent
127
+ }, item.key);
128
+ if (item.kind === "item") return /* @__PURE__ */ jsx("li", {
129
+ ref: measureElement,
130
+ className: classNames.item,
131
+ "data-index": virtualItem.index,
132
+ "data-slot": "item",
133
+ style: {
134
+ position: "absolute",
135
+ transform: `translateY(${virtualItem.start}px)`,
136
+ width: "100%"
137
+ },
138
+ children: renderItem(item.value, item.index)
139
+ }, item.key);
140
+ return null;
141
+ })
142
+ })
143
+ })
144
+ })
145
+ });
146
+ };
147
+ //#endregion
148
+ //#region src/VirtualList/index.ts
149
+ var VirtualList_default = VirtualList;
150
+ //#endregion
151
+ export { VirtualList as n, virtualListVariants as r, VirtualList_default as t };
152
+
153
+ //# sourceMappingURL=VirtualList-DQ4uR-wR.js.map