react-window 2.0.1 → 2.0.2-alpha.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 (127) hide show
  1. package/README.md +8 -9
  2. package/dist/react-window.cjs +1 -1
  3. package/dist/react-window.cjs.map +1 -1
  4. package/dist/react-window.d.ts +10 -1
  5. package/dist/react-window.js +408 -373
  6. package/dist/react-window.js.map +1 -1
  7. package/docs/assets/AriaRolesRoute-BQ4l2o71.js +2 -0
  8. package/docs/assets/AriaRolesRoute-BQ4l2o71.js.map +1 -0
  9. package/docs/assets/AriaRolesRoute-BXnUEUK2.js +2 -0
  10. package/docs/assets/AriaRolesRoute-BXnUEUK2.js.map +1 -0
  11. package/docs/assets/AriaRolesRoute-ahe1aw6k.js +2 -0
  12. package/docs/assets/AriaRolesRoute-ahe1aw6k.js.map +1 -0
  13. package/docs/assets/CellComponent.example-dKVH8ZYc.js +2 -0
  14. package/docs/assets/{CellComponent.example-e4JJmmZM.js.map → CellComponent.example-dKVH8ZYc.js.map} +1 -1
  15. package/docs/assets/ComponentProps-BA6jJCAT.js +2 -0
  16. package/docs/assets/ComponentProps-BA6jJCAT.js.map +1 -0
  17. package/docs/assets/ContinueLink-DN1_wnU9.js +2 -0
  18. package/docs/assets/ContinueLink-DN1_wnU9.js.map +1 -0
  19. package/docs/assets/FixedHeightList-HNBwl6P8.js +2 -0
  20. package/docs/assets/FixedHeightList-HNBwl6P8.js.map +1 -0
  21. package/docs/assets/FixedRowHeightsRoute-iwoWadtD.js +2 -0
  22. package/docs/assets/FixedRowHeightsRoute-iwoWadtD.js.map +1 -0
  23. package/docs/assets/FormattedCode-CDzGfhdX.js +2 -0
  24. package/docs/assets/FormattedCode-CDzGfhdX.js.map +1 -0
  25. package/docs/assets/{GettingStartedRoute-zN9jVy3e.js → GettingStartedRoute-6onVm0dP.js} +2 -2
  26. package/docs/assets/{GettingStartedRoute-zN9jVy3e.js.map → GettingStartedRoute-6onVm0dP.js.map} +1 -1
  27. package/docs/assets/Grid-BnGy9pmI.js +2 -0
  28. package/docs/assets/Grid-BnGy9pmI.js.map +1 -0
  29. package/docs/assets/{Header-BYp8JKXz.js → Header-DyQVANF3.js} +2 -2
  30. package/docs/assets/{Header-BYp8JKXz.js.map → Header-DyQVANF3.js.map} +1 -1
  31. package/docs/assets/HorizontalListsRoute-BQxNRT_F.js +2 -0
  32. package/docs/assets/HorizontalListsRoute-BQxNRT_F.js.map +1 -0
  33. package/docs/assets/ImperativeApiRoute-DN4crA5x.js +2 -0
  34. package/docs/assets/ImperativeApiRoute-DN4crA5x.js.map +1 -0
  35. package/docs/assets/ImperativeApiRoute-ZdLgDzyA.js +2 -0
  36. package/docs/assets/ImperativeApiRoute-ZdLgDzyA.js.map +1 -0
  37. package/docs/assets/List-CsalXuo6.js +2 -0
  38. package/docs/assets/List-CsalXuo6.js.map +1 -0
  39. package/docs/assets/LoadingSpinner-DXcA8wXA.js +2 -0
  40. package/docs/assets/LoadingSpinner-DXcA8wXA.js.map +1 -0
  41. package/docs/assets/{PageNotFound-B0nx-Cz_.js → PageNotFound-I9Ugq07H.js} +2 -2
  42. package/docs/assets/{PageNotFound-B0nx-Cz_.js.map → PageNotFound-I9Ugq07H.js.map} +1 -1
  43. package/docs/assets/{PlatformRequirementsRoute-C00ZSzCF.js → PlatformRequirementsRoute-Mn45V_j9.js} +2 -2
  44. package/docs/assets/{PlatformRequirementsRoute-C00ZSzCF.js.map → PlatformRequirementsRoute-Mn45V_j9.js.map} +1 -1
  45. package/docs/assets/PropsRoute-BzcsHp2c.js +2 -0
  46. package/docs/assets/PropsRoute-BzcsHp2c.js.map +1 -0
  47. package/docs/assets/PropsRoute-CHeNkGKQ.js +2 -0
  48. package/docs/assets/PropsRoute-CHeNkGKQ.js.map +1 -0
  49. package/docs/assets/RTLGridsRoute-RdjRBOG7.js +2 -0
  50. package/docs/assets/RTLGridsRoute-RdjRBOG7.js.map +1 -0
  51. package/docs/assets/RenderingGridRoute-bkYAfFEg.js +2 -0
  52. package/docs/assets/RenderingGridRoute-bkYAfFEg.js.map +1 -0
  53. package/docs/assets/{ScratchpadRoute-AXfI00Be.js → ScratchpadRoute-B8OO7yyx.js} +2 -2
  54. package/docs/assets/{ScratchpadRoute-AXfI00Be.js.map → ScratchpadRoute-B8OO7yyx.js.map} +1 -1
  55. package/docs/assets/Select-Dtoy3zH8.js +2 -0
  56. package/docs/assets/{Select-C5ovWBbK.js.map → Select-Dtoy3zH8.js.map} +1 -1
  57. package/docs/assets/{SupportRoute-C1V_AF9b.js → SupportRoute-Cy6JXaox.js} +2 -2
  58. package/docs/assets/{SupportRoute-C1V_AF9b.js.map → SupportRoute-Cy6JXaox.js.map} +1 -1
  59. package/docs/assets/TabularDataRoute-EbsuxYEq.js +2 -0
  60. package/docs/assets/TabularDataRoute-EbsuxYEq.js.map +1 -0
  61. package/docs/assets/VariableRowHeightsRoute-Bmh2fNYt.js +2 -0
  62. package/docs/assets/VariableRowHeightsRoute-Bmh2fNYt.js.map +1 -0
  63. package/docs/assets/addresses-CDQyd4n9.js +2 -0
  64. package/docs/assets/addresses-CDQyd4n9.js.map +1 -0
  65. package/docs/assets/{arePropsEqual-D3jAKwxp.js → arePropsEqual-Bhv0L31F.js} +2 -2
  66. package/docs/assets/arePropsEqual-Bhv0L31F.js.map +1 -0
  67. package/docs/assets/contacts-Bxrk2JS2.js +2 -0
  68. package/docs/assets/contacts-Bxrk2JS2.js.map +1 -0
  69. package/docs/assets/index-DEYagqsv.css +1 -0
  70. package/docs/assets/{index-B_YQ7rlN.js → index-Dfhz9Ad4.js} +3 -3
  71. package/docs/assets/index-Dfhz9Ad4.js.map +1 -0
  72. package/docs/assets/useCitiesByState-_PN38xmv.js +2 -0
  73. package/docs/assets/useCitiesByState-_PN38xmv.js.map +1 -0
  74. package/docs/assets/useContacts-CDDyJV-g.js +2 -0
  75. package/docs/assets/useContacts-CDDyJV-g.js.map +1 -0
  76. package/docs/generated/code-snippets/CellComponentAriaRoles.json +4 -0
  77. package/docs/generated/code-snippets/GridAriaRoles.json +3 -0
  78. package/docs/generated/code-snippets/ListAriaRoles.json +3 -0
  79. package/docs/generated/code-snippets/RowComponentAriaRoles.json +4 -0
  80. package/docs/generated/code-snippets/TableAriaAttributes.json +3 -0
  81. package/docs/generated/code-snippets/TableAriaOverrideProps.json +4 -0
  82. package/docs/generated/js-docs/Grid.json +1 -1
  83. package/docs/generated/js-docs/List.json +1 -1
  84. package/docs/index.html +2 -2
  85. package/docs/stats.html +1 -1
  86. package/package.json +1 -1
  87. package/docs/assets/CellComponent.example-e4JJmmZM.js +0 -2
  88. package/docs/assets/ComponentProps-DMkeake1.js +0 -2
  89. package/docs/assets/ComponentProps-DMkeake1.js.map +0 -1
  90. package/docs/assets/ContinueLink-CbPhCk1k.js +0 -2
  91. package/docs/assets/ContinueLink-CbPhCk1k.js.map +0 -1
  92. package/docs/assets/FixedRowHeightsRoute-D8GuxxOL.js +0 -2
  93. package/docs/assets/FixedRowHeightsRoute-D8GuxxOL.js.map +0 -1
  94. package/docs/assets/FormattedCode-CAmuOSRw.js +0 -2
  95. package/docs/assets/FormattedCode-CAmuOSRw.js.map +0 -1
  96. package/docs/assets/Grid-DH-j7ODh.js +0 -2
  97. package/docs/assets/Grid-DH-j7ODh.js.map +0 -1
  98. package/docs/assets/HorizontalListsRoute-rNcKbQ1k.js +0 -2
  99. package/docs/assets/HorizontalListsRoute-rNcKbQ1k.js.map +0 -1
  100. package/docs/assets/ImperativeApiRoute-DD9Z7HWg.js +0 -2
  101. package/docs/assets/ImperativeApiRoute-DD9Z7HWg.js.map +0 -1
  102. package/docs/assets/ImperativeApiRoute-DntU9ReR.js +0 -2
  103. package/docs/assets/ImperativeApiRoute-DntU9ReR.js.map +0 -1
  104. package/docs/assets/List-C4KHYcVU.js +0 -2
  105. package/docs/assets/List-C4KHYcVU.js.map +0 -1
  106. package/docs/assets/LoadingSpinner-Z5HQViRD.js +0 -2
  107. package/docs/assets/LoadingSpinner-Z5HQViRD.js.map +0 -1
  108. package/docs/assets/PropsRoute-D77WXdPD.js +0 -2
  109. package/docs/assets/PropsRoute-D77WXdPD.js.map +0 -1
  110. package/docs/assets/PropsRoute-D9jETWHk.js +0 -2
  111. package/docs/assets/PropsRoute-D9jETWHk.js.map +0 -1
  112. package/docs/assets/RTLGridsRoute-C49T7mLs.js +0 -2
  113. package/docs/assets/RTLGridsRoute-C49T7mLs.js.map +0 -1
  114. package/docs/assets/RenderingGridRoute-pTuxJ89O.js +0 -2
  115. package/docs/assets/RenderingGridRoute-pTuxJ89O.js.map +0 -1
  116. package/docs/assets/Select-C5ovWBbK.js +0 -2
  117. package/docs/assets/TabularDataRoute-B79B4UDS.js +0 -2
  118. package/docs/assets/TabularDataRoute-B79B4UDS.js.map +0 -1
  119. package/docs/assets/VariableRowHeightsRoute-Bf7uZQG0.js +0 -2
  120. package/docs/assets/VariableRowHeightsRoute-Bf7uZQG0.js.map +0 -1
  121. package/docs/assets/arePropsEqual-D3jAKwxp.js.map +0 -1
  122. package/docs/assets/index-B_YQ7rlN.js.map +0 -1
  123. package/docs/assets/index-CQLn-JKf.css +0 -1
  124. package/docs/assets/useCitiesByState-azL1M3ue.js +0 -2
  125. package/docs/assets/useCitiesByState-azL1M3ue.js.map +0 -1
  126. package/docs/assets/useContacts-BItVOkyi.js +0 -2
  127. package/docs/assets/useContacts-BItVOkyi.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-window",
3
- "version": "2.0.1",
3
+ "version": "2.0.2-alpha.0",
4
4
  "type": "module",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com> (https://github.com/bvaughn/)",
6
6
  "contributors": [
@@ -1,2 +0,0 @@
1
- import{j as s}from"./index-B_YQ7rlN.js";import{i as t}from"./useContacts-BItVOkyi.js";function n({contacts:n,columnIndex:e,rowIndex:o,style:r}){const c=n[o][t(e)];return s.jsx("div",{className:"truncate",style:r,children:c})}export{n as C};
2
- //# sourceMappingURL=CellComponent.example-e4JJmmZM.js.map
@@ -1,2 +0,0 @@
1
- import{r as e,j as r,b as t,B as s,E as n}from"./index-B_YQ7rlN.js";import{u as l,L as a}from"./LoadingSpinner-Z5HQViRD.js";import{H as o}from"./Header-BYp8JKXz.js";function i({title:r,titleId:t,...s},n){return e.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},s),r?e.createElement("title",{id:t},r):null,e.createElement("path",{fillRule:"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",clipRule:"evenodd"}),e.createElement("path",{fillRule:"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",clipRule:"evenodd"}))}const c=e.forwardRef(i),d={url:"https://github.com/bvaughn/react-window.git"};function p({json:t}){const{optionalProps:s,requiredProps:n}=e.useMemo(()=>function(e){const r=[],t=[];return Object.values(e.props).forEach(e=>{e.required?t.push(e):r.push(e)}),r.sort((e,r)=>e.name.localeCompare(r.name)),t.sort((e,r)=>e.name.localeCompare(r.name)),{optionalProps:r,requiredProps:t}}(t),[t]);return r.jsxs(r.Fragment,{children:[r.jsx(m,{header:"Required props",props:n}),r.jsx(m,{header:"Optional props",props:s})]})}function m({header:e,props:t}){return 0===t.length?null:r.jsxs("div",{children:[r.jsx("div",{className:"text-lg font-bold mt-2",children:e}),r.jsx("dl",{children:t.map(e=>r.jsxs("div",{children:[r.jsx("dt",{className:"mt-2 pl-4 indent-[-1rem]",children:r.jsxs("code",{className:"tok-operator",children:[r.jsx("span",{className:"tok-propertyName",children:e.name}),e.required||"?",":"," ","raw"in e.type?e.type.raw:e.type.name,e.defaultValue&&r.jsxs(r.Fragment,{children:[" = ",r.jsx("span",{className:"text-white",children:e.defaultValue.value})]})]})}),r.jsx("dd",{className:"ml-4 [&_code]:text-sky-300",dangerouslySetInnerHTML:{__html:e.description.replaceAll("\n- ","<br/>• ").replaceAll("\n\n","<br/><br/>").replaceAll(/`([^`]+)`/g,"<code>$1</code>")}})]},e.name))})]})}function u({section:e,url:s}){return r.jsx(t,{children:r.jsx(h,{section:e,url:s})})}function h({section:e,url:t}){const i=l(t);return i?r.jsxs(r.Fragment,{children:[r.jsxs(s,{align:"center",direction:"row",gap:2,wrap:!0,children:[r.jsx(o,{section:e,title:"Component props"}),r.jsx(n,{className:"text-sm text-emerald-300 hover:text-white",href:`${d.url.replace(".git","")}/blob/master/${i.filePath}`,children:r.jsx(c,{className:"inline-block size-4 fill-current"})})]}),r.jsx(p,{json:i})]}):r.jsxs(r.Fragment,{children:[r.jsx(o,{section:e,title:"Component props"}),r.jsx(a,{})]})}export{u as C};
2
- //# sourceMappingURL=ComponentProps-DMkeake1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComponentProps-DMkeake1.js","sources":["../../node_modules/.pnpm/@heroicons+react@2.2.0_react@19.1.0/node_modules/@heroicons/react/20/solid/esm/ArrowTopRightOnSquareIcon.js","../../src/components/props/PropsBlocks.tsx","../../src/utils/processPropsJSON.ts","../../src/components/props/ComponentProps.tsx"],"sourcesContent":["import * as React from \"react\";\nfunction ArrowTopRightOnSquareIcon({\n title,\n titleId,\n ...props\n}, svgRef) {\n return /*#__PURE__*/React.createElement(\"svg\", Object.assign({\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 20 20\",\n fill: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, /*#__PURE__*/React.createElement(\"path\", {\n fillRule: \"evenodd\",\n d: \"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z\",\n clipRule: \"evenodd\"\n }), /*#__PURE__*/React.createElement(\"path\", {\n fillRule: \"evenodd\",\n d: \"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z\",\n clipRule: \"evenodd\"\n }));\n}\nconst ForwardRef = /*#__PURE__*/ React.forwardRef(ArrowTopRightOnSquareIcon);\nexport default ForwardRef;","import { useMemo } from \"react\";\nimport type { ComponentDoc, PropItem } from \"react-docgen-typescript\";\nimport { processPropsJSON } from \"../../utils/processPropsJSON\";\n\nexport function PropsBlocks({ json }: { json: ComponentDoc }) {\n const { optionalProps, requiredProps } = useMemo(\n () => processPropsJSON(json),\n [json]\n );\n\n return (\n <>\n <PropsBlock header=\"Required props\" props={requiredProps} />\n <PropsBlock header=\"Optional props\" props={optionalProps} />\n </>\n );\n}\n\nexport function PropsBlock({\n header,\n props\n}: {\n header: string;\n props: PropItem[];\n}) {\n if (props.length === 0) {\n return null;\n }\n\n return (\n <div>\n <div className=\"text-lg font-bold mt-2\">{header}</div>\n <dl>\n {props.map((prop) => (\n <div key={prop.name}>\n <dt className=\"mt-2 pl-4 indent-[-1rem]\">\n <code className=\"tok-operator\">\n <span className=\"tok-propertyName\">{prop.name}</span>\n {prop.required || \"?\"}:{\" \"}\n {\"raw\" in prop.type ? prop.type.raw : prop.type.name}\n {prop.defaultValue && (\n <>\n {\" = \"}\n <span className=\"text-white\">\n {prop.defaultValue.value}\n </span>\n </>\n )}\n </code>\n </dt>\n <dd\n className=\"ml-4 [&_code]:text-sky-300\"\n dangerouslySetInnerHTML={{\n __html: prop.description\n .replaceAll(\"\\n- \", \"<br/>• \")\n .replaceAll(\"\\n\\n\", \"<br/><br/>\")\n .replaceAll(/`([^`]+)`/g, \"<code>$1</code>\")\n }}\n ></dd>\n </div>\n ))}\n </dl>\n </div>\n );\n}\n","import type { ComponentDoc, PropItem } from \"react-docgen-typescript\";\n\nexport function processPropsJSON(json: ComponentDoc) {\n const optionalProps: PropItem[] = [];\n const requiredProps: PropItem[] = [];\n\n Object.values(json.props).forEach((prop) => {\n if (prop.required) {\n requiredProps.push(prop);\n } else {\n optionalProps.push(prop);\n }\n });\n\n optionalProps.sort((a, b) => a.name.localeCompare(b.name));\n requiredProps.sort((a, b) => a.name.localeCompare(b.name));\n\n return { optionalProps, requiredProps };\n}\n","import { ArrowTopRightOnSquareIcon } from \"@heroicons/react/20/solid\";\nimport type { ComponentDoc } from \"react-docgen-typescript\";\nimport { repository } from \"../../../package.json\";\nimport { useJSONData } from \"../../hooks/useJSONData\";\nimport { Box } from \"../Box\";\nimport { ErrorBoundary } from \"../ErrorBoundary\";\nimport { ExternalLink } from \"../ExternalLink\";\nimport { Header } from \"../Header\";\nimport { LoadingSpinner } from \"../LoadingSpinner\";\nimport { PropsBlocks } from \"./PropsBlocks\";\n\nexport function ComponentProps({\n section,\n url\n}: {\n section: string;\n url: string;\n}) {\n return (\n <ErrorBoundary>\n <ComponentPropsLoader section={section} url={url} />\n </ErrorBoundary>\n );\n}\n\nfunction ComponentPropsLoader({\n section,\n url\n}: {\n section: string;\n url: string;\n}) {\n const json = useJSONData<ComponentDoc>(url);\n\n return json ? (\n <>\n <Box align=\"center\" direction=\"row\" gap={2} wrap>\n <Header section={section} title=\"Component props\" />\n <ExternalLink\n className=\"text-sm text-emerald-300 hover:text-white\"\n href={`${repository.url.replace(\".git\", \"\")}/blob/master/${json.filePath}`}\n >\n <ArrowTopRightOnSquareIcon className=\"inline-block size-4 fill-current\" />\n </ExternalLink>\n </Box>\n <PropsBlocks json={json} />\n </>\n ) : (\n <>\n <Header section={section} title=\"Component props\" />\n <LoadingSpinner />\n </>\n );\n}\n"],"names":["ArrowTopRightOnSquareIcon","title","titleId","props","svgRef","React.createElement","Object","assign","xmlns","viewBox","fill","ref","id","fillRule","d","clipRule","ForwardRef","React.forwardRef","PropsBlocks","json","optionalProps","requiredProps","useMemo","values","forEach","prop","required","push","sort","a","b","name","localeCompare","processPropsJSON","jsxs","Fragment","children","jsx","PropsBlock","header","length","className","map","type","raw","defaultValue","value","dangerouslySetInnerHTML","__html","description","replaceAll","ComponentProps","section","url","ErrorBoundary","ComponentPropsLoader","useJSONData","Box","align","direction","gap","wrap","Header","ExternalLink","href","repository","replace","filePath","LoadingSpinner"],"mappings":"qKACA,SAASA,GAA0BC,MACjCA,EAAAC,QACAA,KACGC,GACFC,GACD,OAAoBC,gBAAoB,MAAOC,OAAOC,OAAO,CAC3DC,MAAO,6BACPC,QAAS,YACTC,KAAM,eACN,cAAe,OACf,YAAa,OACbC,IAAKP,EACL,kBAAmBF,GAClBC,GAAQF,EAAqBI,EAAAA,cAAoB,QAAS,CAC3DO,GAAIV,GACHD,GAAS,KAAmBI,EAAAA,cAAoB,OAAQ,CACzDQ,SAAU,UACVC,EAAG,oNACHC,SAAU,YACKV,EAAAA,cAAoB,OAAQ,CAC3CQ,SAAU,UACVC,EAAG,qKACHC,SAAU,YAEd,CACA,MAAMC,EAA2BC,EAAAA,WAAiBjB,yDCtB3C,SAASkB,GAAYC,KAAEA,IAC5B,MAAMC,cAAEA,EAAAC,cAAeA,GAAkBC,EAAAA,QACvC,ICJG,SAA0BH,GAC/B,MAAMC,EAA4B,GAC5BC,EAA4B,GAalC,OAXAf,OAAOiB,OAAOJ,EAAKhB,OAAOq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AC7BA,EAAAC,IACAA,IAKA,aACGC,EAAA,CACClB,SAAAC,EAAAA,IAACkB,EAAA,CAAqBH,UAAkBC,SAG9C,CAEA,SAASE,GAAqBH,QAC5BA,EAAAC,IACAA,IAKA,MAAMlC,EAAOqC,EAA0BH,GAEvC,OAAOlC,EACLe,EAAAA,KAAAC,EAAAA,SAAA,CACEC,SAAA,CAAAF,EAAAA,KAACuB,EAAA,CAAIC,MAAM,SAASC,UAAU,MAAMC,IAAK,EAAGC,MAAI,EAC9CzB,SAAA,GAAAC,IAACyB,EAAA,CAAOV,UAAkBnD,MAAM,oBAChCoC,EAAAA,IAAC0B,EAAA,CACCtB,UAAU,4CACVuB,KAAM,GAAGC,EAAWZ,IAAIa,QAAQ,OAAQ,mBAAmB/C,EAAKgD,WAEhE/B,SAAAC,EAAAA,IAACrC,EAAA,CAA0ByC,UAAU,0CAGzCJ,MAACnB,GAAYC,YAGfe,EAAAA,KAAAC,EAAAA,SAAA,CACEC,SAAA,GAAAC,IAACyB,EAAA,CAAOV,UAAkBnD,MAAM,0BAC/BmE,EAAA,CAAA,KAGP","x_google_ignoreList":[0]}
@@ -1,2 +0,0 @@
1
- import{j as t,L as i}from"./index-B_YQ7rlN.js";function n({title:n,to:o}){return t.jsxs("div",{children:["Continue to ",t.jsx(i,{to:o,children:n}),"…"]})}export{n as C};
2
- //# sourceMappingURL=ContinueLink-CbPhCk1k.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContinueLink-CbPhCk1k.js","sources":["../../src/components/ContinueLink.tsx"],"sourcesContent":["import type { routeMap } from \"../routes\";\nimport { Link } from \"./Link\";\n\nexport function ContinueLink({\n title,\n to\n}: {\n title: string;\n to: keyof typeof routeMap;\n}) {\n return (\n <div>\n Continue to <Link to={to}>{title}</Link>…\n </div>\n );\n}\n"],"names":["ContinueLink","title","to","children","jsx","Link"],"mappings":"+CAGO,SAASA,GAAaC,MAC3BA,EAAAC,GACAA,IAKA,cACG,MAAA,CAAIC,SAAA,CAAA,iBACSC,IAACC,EAAA,CAAKH,KAASC,SAAAF,IAAa,MAG9C"}
@@ -1,2 +0,0 @@
1
- import{j as e,B as s,C as i,E as o}from"./index-B_YQ7rlN.js";import{B as t}from"./arePropsEqual-D3jAKwxp.js";import{F as r}from"./FormattedCode-CAmuOSRw.js";import{C as n}from"./ContinueLink-CbPhCk1k.js";import{H as d}from"./Header-BYp8JKXz.js";import{u as a,L as l}from"./LoadingSpinner-Z5HQViRD.js";import{L as h}from"./List-C4KHYcVU.js";function c({index:s,names:i,style:o}){return e.jsxs("div",{className:"flex items-center justify-between",style:o,children:[i[s],e.jsx("div",{className:"text-slate-500 text-xs",children:`${s+1} of ${i.length}`})]})}function p({names:s}){return e.jsx(h,{rowComponent:c,rowCount:s.length,rowHeight:25,rowProps:{names:s}})}const j=[];function m(){const h=a("/data/names.json")??j;return e.jsxs(s,{direction:"column",gap:4,children:[e.jsx(d,{section:"Lists",title:"Fixed row heights"}),e.jsx("div",{children:"The simplest type of list to render is one with fixed row heights."}),e.jsxs(t,{className:"h-50","data-focus-within":"bold",children:[!h.length&&e.jsx(l,{}),e.jsx(p,{names:h})]}),e.jsxs("div",{children:["To render this type of list, you need to specify how many rows it contains (",e.jsx("code",{children:"rowCount"}),"), which component should render rows (",e.jsx("code",{children:"rowComponent"}),"), and the height of each row (",e.jsx("code",{children:"rowHeight"}),"):"]}),e.jsx(r,{url:"/generated/code-snippets/FixedHeightList.json"}),e.jsxs("div",{children:["The ",e.jsx("code",{children:"rowProps"})," object can also be used to share between components. Values passed in ",e.jsx("code",{children:"rowProps"})," will also be passed as props to the row component:"]}),e.jsx(r,{url:"/generated/code-snippets/FixedHeightRowComponent.json"}),e.jsx(i,{intent:"warning",children:e.jsxs(s,{direction:"column",gap:4,children:[e.jsxs("div",{children:["Lists require vertical space to render rows. Typically the"," ",e.jsx(o,{href:"https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver",children:"ResizeObserver"})," ","API is used to determine how much space there is available within the parent DOM element."]}),e.jsxs("div",{children:["If an explicit height is specified (in pixels) using the"," ",e.jsx("code",{children:"style"})," prop, ",e.jsx("code",{children:"ResizeObserver"})," will not be used."]})]})}),e.jsx(n,{to:"/list/variable-row-height",title:"variable row heights"})]})}export{m as default};
2
- //# sourceMappingURL=FixedRowHeightsRoute-D8GuxxOL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FixedRowHeightsRoute-D8GuxxOL.js","sources":["../../src/routes/list/examples/FixedHeightRowComponent.example.tsx","../../src/routes/list/examples/FixedHeightList.example.tsx","../../src/constants.ts","../../src/routes/list/FixedRowHeightsRoute.tsx","../../src/routes/list/hooks/useNames.ts"],"sourcesContent":["import { type RowComponentProps } from \"react-window\";\n\nfunction RowComponent({\n index,\n names,\n style\n}: RowComponentProps<{\n names: string[];\n}>) {\n return (\n <div className=\"flex items-center justify-between\" style={style}>\n {names[index]}\n <div className=\"text-slate-500 text-xs\">{`${index + 1} of ${names.length}`}</div>\n </div>\n );\n}\n\n// <end>\n\nexport { RowComponent };\n","import { RowComponent } from \"./FixedHeightRowComponent.example\";\n\n// <begin>\n\nimport { List } from \"react-window\";\n\nfunction Example({ names }: { names: string[] }) {\n return (\n <List\n rowComponent={RowComponent}\n rowCount={names.length}\n rowHeight={25}\n rowProps={{ names }}\n />\n );\n}\n\n// <end>\n\nexport { Example };\n","export const EMPTY_ARRAY: unknown[] = [];\nexport const EMPTY_OBJECT = {};\nexport const NOOP_FUNCTION = () => {};\n","import { Block } from \"../../components/Block\";\nimport { Box } from \"../../components/Box\";\nimport { Callout } from \"../../components/Callout\";\nimport { FormattedCode } from \"../../components/code/FormattedCode\";\nimport { ContinueLink } from \"../../components/ContinueLink\";\nimport { ExternalLink } from \"../../components/ExternalLink\";\nimport { Header } from \"../../components/Header\";\nimport { LoadingSpinner } from \"../../components/LoadingSpinner\";\nimport { Example } from \"./examples/FixedHeightList.example\";\nimport { useNames } from \"./hooks/useNames\";\n\nexport default function FixedRowHeightsRoute() {\n const names = useNames();\n\n return (\n <Box direction=\"column\" gap={4}>\n <Header section=\"Lists\" title=\"Fixed row heights\" />\n <div>\n The simplest type of list to render is one with fixed row heights.\n </div>\n <Block className=\"h-50\" data-focus-within=\"bold\">\n {!names.length && <LoadingSpinner />}\n <Example names={names} />\n </Block>\n <div>\n To render this type of list, you need to specify how many rows it\n contains (<code>rowCount</code>), which component should render rows (\n <code>rowComponent</code>), and the height of each row (\n <code>rowHeight</code>):\n </div>\n <FormattedCode url=\"/generated/code-snippets/FixedHeightList.json\" />\n <div>\n The <code>rowProps</code> object can also be used to share between\n components. Values passed in <code>rowProps</code> will also be passed\n as props to the row component:\n </div>\n <FormattedCode url=\"/generated/code-snippets/FixedHeightRowComponent.json\" />\n <Callout intent=\"warning\">\n <Box direction=\"column\" gap={4}>\n <div>\n Lists require vertical space to render rows. Typically the{\" \"}\n <ExternalLink href=\"https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver\">\n ResizeObserver\n </ExternalLink>{\" \"}\n API is used to determine how much space there is available within\n the parent DOM element.\n </div>\n <div>\n If an explicit height is specified (in pixels) using the{\" \"}\n <code>style</code> prop, <code>ResizeObserver</code> will not be\n used.\n </div>\n </Box>\n </Callout>\n <ContinueLink\n to=\"/list/variable-row-height\"\n title=\"variable row heights\"\n />\n </Box>\n );\n}\n","import { useJSONData } from \"../../../hooks/useJSONData\";\nimport type json from \"../../../../public/data/names.json\";\nimport { EMPTY_ARRAY } from \"../../../constants\";\n\ntype Name = (typeof json)[0];\n\nexport function useNames(): Name[] {\n return useJSONData<Name[]>(\"/data/names.json\") ?? (EMPTY_ARRAY as Name[]);\n}\n"],"names":["RowComponent","index","names","style","jsxs","className","children","jsx","length","Example","List","rowComponent","rowCount","rowHeight","rowProps","EMPTY_ARRAY","FixedRowHeightsRoute","useJSONData","Box","direction","gap","Header","section","title","Block","LoadingSpinner","FormattedCode","url","Callout","intent","ExternalLink","href","ContinueLink","to"],"mappings":"oVAEA,SAASA,GAAaC,MACpBA,EAAAC,MACA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,MACzDC,IAAC,QAAKD,SAAA,UAAY,YAAOC,IAAC,QAAKD,SAAA,mBAAqB,6BAK1DC,EAAAA,IAACyB,EAAA,CACCC,GAAG,4BACHV,MAAM,2BAId"}
@@ -1,2 +0,0 @@
1
- import{r as e,j as t,c as r,b as s}from"./index-B_YQ7rlN.js";import{u as n,L as a}from"./LoadingSpinner-Z5HQViRD.js";function u({className:e="",html:s}){return t.jsx("code",{className:r("text-xs md:text-sm block text-left whitespace-pre-wrap text-white! rounded-md p-3 bg-black","flex flex-col",e),dangerouslySetInnerHTML:{__html:s}})}function o({url:e}){return t.jsx(s,{children:t.jsx(l,{url:e})})}function l({url:s}){const[o,l]=function(t,r){const[s,n]=e.useState(()=>{const e=localStorage.getItem(t);return null!=e?JSON.parse(e):r}),a=e.useRef({prevValue:null,value:JSON.stringify(s)});return e.useLayoutEffect(()=>{a.current.prevValue=a.current.value,a.current.value=JSON.stringify(s)}),e.useLayoutEffect(()=>{const e=e=>{t===e.key&&e.newValue&&e.newValue!==JSON.stringify(s)&&n(JSON.parse(e.newValue))};return window.addEventListener("storage",e),()=>{window.removeEventListener("storage",e)}},[t,s]),e.useLayoutEffect(()=>{window.dispatchEvent(new StorageEvent("storage",{key:t,newValue:a.current.value||"",oldValue:a.current.prevValue||""})),localStorage.setItem(t,a.current.value)},[t,s]),[s,n]}("CodeTabs::tab",!0),c=n(s);if(void 0===c)return t.jsx(a,{});const i=t.jsx(u,{html:o?c.typeScript??c.javaScript:c.javaScript});return c.typeScript?t.jsxs("div",{className:"relative",children:[i,t.jsxs("button",{className:r("absolute top-2 right-2 p-1 rounded-sm bg-white/10 cursor-pointer hover:text-sky-300 hover:bg-sky-950 text-xs flex flex-row items-center gap-1",{"text-white/50":!o,"text-sky-300 bg-sky-950/50":o}),onClick:()=>l(!o),children:[o?"TS":"JS",t.jsx("div",{className:r("w-2 h-2 rounded",{"bg-green-400":o,"bg-orange-400":!o})})]})]}):i}export{o as F};
2
- //# sourceMappingURL=FormattedCode-CAmuOSRw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormattedCode-CAmuOSRw.js","sources":["../../src/components/code/Code.tsx","../../src/components/code/FormattedCode.tsx","../../src/hooks/useLocalStorage.ts"],"sourcesContent":["import { cn } from \"../../utils/cn\";\nimport \"./code-mirror.css\";\n\nexport function Code({\n className = \"\",\n html\n}: {\n className?: string;\n html: string;\n}) {\n return (\n <code\n className={cn(\n \"text-xs md:text-sm block text-left whitespace-pre-wrap text-white! rounded-md p-3 bg-black\",\n \"flex flex-col\",\n className\n )}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n );\n}\n","import { useJSONData } from \"../../hooks/useJSONData\";\nimport useLocalStorage from \"../../hooks/useLocalStorage\";\nimport { cn } from \"../../utils/cn\";\nimport { ErrorBoundary } from \"../ErrorBoundary\";\nimport { LoadingSpinner } from \"../LoadingSpinner\";\nimport { Code } from \"./Code\";\n\ntype Markdown = {\n javaScript: string;\n typeScript?: string;\n};\n\nexport function FormattedCode({ url }: { url: string }) {\n return (\n <ErrorBoundary>\n <FormattedCodeLoader url={url} />\n </ErrorBoundary>\n );\n}\n\nexport function FormattedCodeLoader({ url }: { url: string }) {\n const [ts, setTS] = useLocalStorage(\"CodeTabs::tab\", true);\n\n const json = useJSONData<Markdown>(url);\n\n if (json === undefined) {\n return <LoadingSpinner />;\n }\n\n const code = (\n <Code html={ts ? (json.typeScript ?? json.javaScript) : json.javaScript} />\n );\n\n if (!json.typeScript) {\n return code;\n }\n\n return (\n <div className=\"relative\">\n {code}\n <button\n className={cn(\n \"absolute top-2 right-2 p-1 rounded-sm bg-white/10 cursor-pointer hover:text-sky-300 hover:bg-sky-950 text-xs flex flex-row items-center gap-1\",\n {\n \"text-white/50\": !ts,\n \"text-sky-300 bg-sky-950/50\": ts\n }\n )}\n onClick={() => setTS(!ts)}\n >\n {ts ? \"TS\" : \"JS\"}\n <div\n className={cn(\"w-2 h-2 rounded\", {\n \"bg-green-400\": ts,\n \"bg-orange-400\": !ts\n })}\n />\n </button>\n </div>\n );\n}\n","import { useLayoutEffect, useRef, useState } from \"react\";\n\nexport default function useLocalStorage<Type>(\n key: string,\n defaultValue: Type\n): [value: Type, setValue: (newValue: Type) => void] {\n const [value, setValue] = useState<Type>(() => {\n const storedValue = localStorage.getItem(key);\n if (storedValue != null) {\n return JSON.parse(storedValue) as Type;\n } else {\n return defaultValue;\n }\n });\n\n const committedValuesRef = useRef<{\n prevValue: string | null;\n value: string;\n }>({\n prevValue: null,\n value: JSON.stringify(value)\n });\n useLayoutEffect(() => {\n committedValuesRef.current.prevValue = committedValuesRef.current.value;\n committedValuesRef.current.value = JSON.stringify(value);\n });\n\n // Sync changes from local storage\n useLayoutEffect(() => {\n const onStorage = (event: StorageEvent) => {\n if (\n key === event.key &&\n event.newValue &&\n event.newValue !== JSON.stringify(value)\n ) {\n setValue(JSON.parse(event.newValue));\n }\n };\n\n window.addEventListener(\"storage\", onStorage);\n\n return () => {\n window.removeEventListener(\"storage\", onStorage);\n };\n }, [key, value]);\n\n // Sync changes to local storage\n useLayoutEffect(() => {\n window.dispatchEvent(\n new StorageEvent(\"storage\", {\n key,\n newValue: committedValuesRef.current.value || \"\",\n oldValue: committedValuesRef.current.prevValue || \"\"\n })\n );\n\n localStorage.setItem(key, committedValuesRef.current.value);\n }, [key, value]);\n\n return [value, setValue];\n}\n"],"names":["Code","className","html","jsx","cn","dangerouslySetInnerHTML","__html","FormattedCode","url","ErrorBoundary","children","FormattedCodeLoader","ts","setTS","key","defaultValue","value","setValue","useState","storedValue","localStorage","getItem","JSON","parse","committedValuesRef","useRef","prevValue","stringify","useLayoutEffect","current","onStorage","event","newValue","window","addEventListener","removeEventListener","dispatchEvent","StorageEvent","oldValue","setItem","useLocalStorage","json","useJSONData","LoadingSpinner","code","typeScript","javaScript","jsxs","onClick"],"mappings":"qHAGO,SAASA,GAAKC,UACnBA,EAAY,GAAAC,KACZA,IAKA,OACEC,EAAAA,IAAC,OAAA,CACCF,UAAWG,EACT,6FACA,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,aAKRE,KAAC,MAAA,CAAI9C,UAAU,WACZS,SAAA,CAAAkC,EACDG,EAAAA,KAAC,SAAA,CACC9C,UAAWG,EACT,gJACA,CACE,iBAAkBQ,EAClB,6BAA8BA,IAGlCoC,QAAS,IAAMnC,GAAOD,GAErBF,SAAA,CAAAE,EAAK,KAAO,KACbT,EAAAA,IAAC,MAAA,CACCF,UAAWG,EAAG,kBAAmB,CAC/B,eAAgBQ,EAChB,iBAAkBA,YApBnBgC,CA0BX"}
@@ -1,2 +0,0 @@
1
- import{r as e,j as t}from"./index-B_YQ7rlN.js";import{u as o,a as n,b as l}from"./arePropsEqual-D3jAKwxp.js";function r({cellComponent:r,cellProps:i,className:s,columnCount:a,columnWidth:c,defaultHeight:d=0,defaultWidth:u=0,dir:f,gridRef:m,onCellsRendered:x,onResize:h,overscanCount:g=3,rowCount:p,rowHeight:v,style:S,...C}){const I=o(i),w=e.useMemo(()=>e.memo(r,n),[r]),[z,b]=e.useState(null),E=function(t,o){const[n,l]=e.useState("rtl"===o);return e.useLayoutEffect(()=>{t&&(o||l(function(e){let t=e;for(;t;){if(t.dir)return"rtl"===t.dir;t=t.parentElement}return!1}(t)))},[o,t]),n}(z,f),{getCellBounds:O,getEstimatedSize:R,startIndex:T,scrollToIndex:y,stopIndex:j}=l({containerElement:z,defaultContainerSize:u,direction:"horizontal",isRtl:E,itemCount:a,itemProps:I,itemSize:c,onResize:h,overscanCount:g}),{getCellBounds:H,getEstimatedSize:P,startIndex:$,scrollToIndex:L,stopIndex:N}=l({containerElement:z,defaultContainerSize:d,direction:"vertical",itemCount:p,itemProps:I,itemSize:v,onResize:h,overscanCount:g});e.useImperativeHandle(m,()=>({get element(){return z},scrollToCell({behavior:e="auto",columnAlign:t="auto",columnIndex:o,rowAlign:n="auto",rowIndex:l}){L({align:n,behavior:e,containerScrollOffset:z?.scrollTop??0,index:l}),y({align:t,behavior:e,containerScrollOffset:z?.scrollLeft??0,index:o})},scrollToColumn({align:e="auto",behavior:t="auto",index:o}){y({align:e,behavior:t,containerScrollOffset:z?.scrollLeft??0,index:o})},scrollToRow({align:e="auto",behavior:t="auto",index:o}){L({align:e,behavior:t,containerScrollOffset:z?.scrollTop??0,index:o})}}),[z,y,L]),e.useEffect(()=>{T>=0&&j>=0&&$>=0&&N>=0&&x&&x({columnStartIndex:T,columnStopIndex:j,rowStartIndex:$,rowStopIndex:N})},[x,T,j,$,N]);const W=e.useMemo(()=>{const t=[];if(a>0&&p>0)for(let o=$;o<=N;o++){const n=H(o);for(let l=T;l<=j;l++){const r=O(l);t.push(e.createElement(w,{...I,columnIndex:l,key:`${o}-${l}`,rowIndex:o,style:{position:"absolute",left:E?void 0:0,right:E?0:void 0,transform:`translate(${E?-r.scrollOffset:r.scrollOffset}px, ${n.scrollOffset}px)`,height:p>1?n.size:"100%",width:r.size}}))}}return t},[w,I,a,T,j,O,H,E,p,$,N]);return t.jsx("div",{...C,className:s,dir:f,ref:b,style:{width:"100%",height:"100%",...S,maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto"},children:t.jsx("div",{className:s,style:{position:"relative",height:P(),width:R()},children:W})})}export{r as G};
2
- //# sourceMappingURL=Grid-DH-j7ODh.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Grid-DH-j7ODh.js","sources":["../../lib/components/grid/Grid.tsx","../../lib/core/useIsRtl.ts","../../lib/utils/isRtl.ts"],"sourcesContent":["import {\n memo,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n type ReactNode\n} from \"react\";\nimport { useIsRtl } from \"../../core/useIsRtl\";\nimport { useVirtualizer } from \"../../core/useVirtualizer\";\nimport { useMemoizedObject } from \"../../hooks/useMemoizedObject\";\nimport type { Align } from \"../../types\";\nimport { arePropsEqual } from \"../../utils/arePropsEqual\";\nimport type { GridProps } from \"./types\";\n\nexport function Grid<CellProps extends object>({\n cellComponent: CellComponentProp,\n cellProps: cellPropsUnstable,\n className,\n columnCount,\n columnWidth,\n defaultHeight = 0,\n defaultWidth = 0,\n dir,\n gridRef,\n onCellsRendered,\n onResize,\n overscanCount = 3,\n rowCount,\n rowHeight,\n style,\n ...rest\n}: GridProps<CellProps>) {\n const cellProps = useMemoizedObject(cellPropsUnstable);\n const CellComponent = useMemo(\n () => memo(CellComponentProp, arePropsEqual),\n [CellComponentProp]\n );\n\n const [element, setElement] = useState<HTMLDivElement | null>(null);\n\n const isRtl = useIsRtl(element, dir);\n\n const {\n getCellBounds: getColumnBounds,\n getEstimatedSize: getEstimatedWidth,\n startIndex: columnStartIndex,\n scrollToIndex: scrollToColumnIndex,\n stopIndex: columnStopIndex\n } = useVirtualizer({\n containerElement: element,\n defaultContainerSize: defaultWidth,\n direction: \"horizontal\",\n isRtl,\n itemCount: columnCount,\n itemProps: cellProps,\n itemSize: columnWidth,\n onResize,\n overscanCount\n });\n\n const {\n getCellBounds: getRowBounds,\n getEstimatedSize: getEstimatedHeight,\n startIndex: rowStartIndex,\n scrollToIndex: scrollToRowIndex,\n stopIndex: rowStopIndex\n } = useVirtualizer({\n containerElement: element,\n defaultContainerSize: defaultHeight,\n direction: \"vertical\",\n itemCount: rowCount,\n itemProps: cellProps,\n itemSize: rowHeight,\n onResize,\n overscanCount\n });\n\n useImperativeHandle(\n gridRef,\n () => ({\n get element() {\n return element;\n },\n\n scrollToCell({\n behavior = \"auto\",\n columnAlign = \"auto\",\n columnIndex,\n rowAlign = \"auto\",\n rowIndex\n }: {\n behavior?: ScrollBehavior;\n columnAlign?: Align;\n columnIndex: number;\n rowAlign?: Align;\n rowIndex: number;\n }) {\n scrollToRowIndex({\n align: rowAlign,\n behavior,\n containerScrollOffset: element?.scrollTop ?? 0,\n index: rowIndex\n });\n scrollToColumnIndex({\n align: columnAlign,\n behavior,\n containerScrollOffset: element?.scrollLeft ?? 0,\n index: columnIndex\n });\n },\n\n scrollToColumn({\n align = \"auto\",\n behavior = \"auto\",\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\n index: number;\n }) {\n scrollToColumnIndex({\n align,\n behavior,\n containerScrollOffset: element?.scrollLeft ?? 0,\n index\n });\n },\n\n scrollToRow({\n align = \"auto\",\n behavior = \"auto\",\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\n index: number;\n }) {\n scrollToRowIndex({\n align,\n behavior,\n containerScrollOffset: element?.scrollTop ?? 0,\n index\n });\n }\n }),\n [element, scrollToColumnIndex, scrollToRowIndex]\n );\n\n useEffect(() => {\n if (\n columnStartIndex >= 0 &&\n columnStopIndex >= 0 &&\n rowStartIndex >= 0 &&\n rowStopIndex >= 0 &&\n onCellsRendered\n ) {\n onCellsRendered({\n columnStartIndex,\n columnStopIndex,\n rowStartIndex,\n rowStopIndex\n });\n }\n }, [\n onCellsRendered,\n columnStartIndex,\n columnStopIndex,\n rowStartIndex,\n rowStopIndex\n ]);\n\n const cells = useMemo(() => {\n const children: ReactNode[] = [];\n if (columnCount > 0 && rowCount > 0) {\n for (let rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {\n const rowBounds = getRowBounds(rowIndex);\n for (\n let columnIndex = columnStartIndex;\n columnIndex <= columnStopIndex;\n columnIndex++\n ) {\n const columnBounds = getColumnBounds(columnIndex);\n\n children.push(\n <CellComponent\n {...(cellProps as CellProps)}\n columnIndex={columnIndex}\n key={`${rowIndex}-${columnIndex}`}\n rowIndex={rowIndex}\n style={{\n position: \"absolute\",\n left: isRtl ? undefined : 0,\n right: isRtl ? 0 : undefined,\n transform: `translate(${isRtl ? -columnBounds.scrollOffset : columnBounds.scrollOffset}px, ${rowBounds.scrollOffset}px)`,\n height: rowCount > 1 ? rowBounds.size : \"100%\",\n width: columnBounds.size\n }}\n />\n );\n }\n }\n }\n return children;\n }, [\n CellComponent,\n cellProps,\n columnCount,\n columnStartIndex,\n columnStopIndex,\n getColumnBounds,\n getRowBounds,\n isRtl,\n rowCount,\n rowStartIndex,\n rowStopIndex\n ]);\n\n return (\n <div\n {...rest}\n className={className}\n dir={dir}\n ref={setElement}\n style={{\n width: \"100%\",\n height: \"100%\",\n ...style,\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n flexGrow: 1,\n overflow: \"auto\"\n }}\n >\n <div\n className={className}\n style={{\n position: \"relative\",\n height: getEstimatedHeight(),\n width: getEstimatedWidth()\n }}\n >\n {cells}\n </div>\n </div>\n );\n}\n","import { useLayoutEffect, useState, type HTMLAttributes } from \"react\";\nimport { isRtl } from \"../utils/isRtl\";\n\nexport function useIsRtl(\n element: HTMLElement | null,\n dir: HTMLAttributes<HTMLElement>[\"dir\"]\n) {\n const [value, setValue] = useState(dir === \"rtl\");\n\n useLayoutEffect(() => {\n if (element) {\n if (!dir) {\n setValue(isRtl(element));\n }\n }\n }, [dir, element]);\n\n return value;\n}\n","export function isRtl(element: HTMLElement) {\n let currentElement: HTMLElement | null = element;\n while (currentElement) {\n if (currentElement.dir) {\n return currentElement.dir === \"rtl\";\n }\n\n currentElement = currentElement.parentElement;\n }\n\n return false;\n}\n"],"names":["Grid","cellComponent","CellComponentProp","cellProps","cellPropsUnstable","className","columnCount","columnWidth","defaultHeight","defaultWidth","dir","gridRef","onCellsRendered","onResize","overscanCount","rowCount","rowHeight","style","rest","useMemoizedObject","CellComponent","useMemo","memo","arePropsEqual","element","setElement","useState","isRtl","value","setValue","useLayoutEffect","currentElement","parentElement","useIsRtl","getCellBounds","getColumnBounds","getEstimatedSize","getEstimatedWidth","startIndex","columnStartIndex","scrollToIndex","scrollToColumnIndex","stopIndex","columnStopIndex","useVirtualizer","containerElement","defaultContainerSize","direction","itemCount","itemProps","itemSize","getRowBounds","getEstimatedHeight","rowStartIndex","scrollToRowIndex","rowStopIndex","useImperativeHandle","scrollToCell","behavior","columnAlign","columnIndex","rowAlign","rowIndex","align","containerScrollOffset","scrollTop","index","scrollLeft","scrollToColumn","scrollToRow","useEffect","cells","children","rowBounds","columnBounds","push","createElement","key","position","left","right","transform","scrollOffset","height","size","width","jsx","ref","maxHeight","maxWidth","flexGrow","overflow"],"mappings":"6GAeO,SAASA,GACdC,cAA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E,EAAW,EAAI0D,EAAUW,KAAO,OACxCC,MAAOX,EAAaU,QAI5B,CACF,CAEF,OAAOZ,GACN,CACDpD,EACAjB,EACAG,EACAiC,EACAI,EACAR,EACAgB,EACAxB,EACAZ,EACAsC,EACAE,IAGF,OACE+B,EAAAA,IAAC,MAAA,IACKpE,EACJb,YACAK,MACA6E,IAAK9D,EACLR,MAAO,CACLoE,MAAO,OACPF,OAAQ,UACLlE,EACHuE,UAAW,OACXC,SAAU,OACVC,SAAU,EACVC,SAAU,QAGZnB,SAAAc,EAAAA,IAAC,MAAA,CACCjF,YACAY,MAAO,CACL6D,SAAU,WACVK,OAAQ/B,IACRiC,MAAOhD,KAGRmC,SAAAD,KAIT"}
@@ -1,2 +0,0 @@
1
- import{j as e,c as s,r as o,B as r}from"./index-B_YQ7rlN.js";import{B as n}from"./arePropsEqual-D3jAKwxp.js";import{F as t}from"./FormattedCode-CAmuOSRw.js";import{u as i,L as l}from"./LoadingSpinner-Z5HQViRD.js";import{G as a}from"./Grid-DH-j7ODh.js";function d({columnIndex:o,emails:r,style:n}){return e.jsx("div",{className:s("px-2 truncate text-center leading-[2.5]",{"bg-white/10 rounded":o%2==0}),style:n,children:r[o]})}function c({emails:s}){return e.jsx(a,{cellComponent:d,cellProps:{emails:s},columnCount:s.length,columnWidth:150,rowCount:1,rowHeight:"100%"})}function m(){const s=function(){const e=i("/data/contacts.json");return o.useMemo(()=>e?e.map(e=>e.email).sort((e,s)=>e.localeCompare(s)):[],[e])}();return e.jsxs(r,{direction:"column",gap:4,children:[e.jsx("div",{children:"A horizontal list is just a grid with only one row."}),e.jsx("div",{children:"Here's an example horizontal list (grid) of emails:"}),e.jsxs(n,{className:"h-20","data-focus-within":"bold",children:[!s.length&&e.jsx(l,{}),e.jsx(c,{emails:s})]}),e.jsx("div",{children:"Here's what the configuration for the grid above looks like:"}),e.jsx(t,{url:"/generated/code-snippets/HorizontalList.json"}),e.jsx("div",{children:"And here's the cell renderer:"}),e.jsx(t,{url:"/generated/code-snippets/HorizontalListCellRenderer.json"})]})}export{m as default};
2
- //# sourceMappingURL=HorizontalListsRoute-rNcKbQ1k.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HorizontalListsRoute-rNcKbQ1k.js","sources":["../../src/routes/grid/examples/HorizontalListCellRenderer.example.tsx","../../src/routes/grid/examples/HorizontalList.example.tsx","../../src/routes/grid/HorizontalListsRoute.tsx","../../src/routes/grid/hooks/useEmails.ts"],"sourcesContent":["import { cn } from \"../../../utils/cn\";\n\n// <begin>\n\nimport { type CellComponentProps } from \"react-window\";\n\nfunction CellComponent({\n columnIndex,\n emails,\n style\n}: CellComponentProps<{ emails: string[] }>) {\n return (\n <div\n className={cn(\"px-2 truncate text-center leading-[2.5]\", {\n \"bg-white/10 rounded\": columnIndex % 2 === 0\n })}\n style={style}\n >\n {emails[columnIndex]}\n </div>\n );\n}\n\n// <end>\n\nexport { CellComponent };\n","import { CellComponent } from \"./HorizontalListCellRenderer.example\";\n\n// <begin>\n\nimport { Grid } from \"react-window\";\n\nfunction HorizontalList({ emails }: { emails: string[] }) {\n return (\n <Grid\n cellComponent={CellComponent}\n cellProps={{ emails }}\n columnCount={emails.length}\n columnWidth={150}\n rowCount={1}\n rowHeight=\"100%\"\n />\n );\n}\n\n// <end>\n\nexport { HorizontalList };\n","import { Block } from \"../../components/Block\";\nimport { Box } from \"../../components/Box\";\nimport { FormattedCode } from \"../../components/code/FormattedCode\";\nimport { LoadingSpinner } from \"../../components/LoadingSpinner\";\nimport { HorizontalList } from \"./examples/HorizontalList.example\";\nimport { useEmails } from \"./hooks/useEmails\";\n\nexport default function HorizontalListsRoute() {\n const emails = useEmails();\n\n return (\n <Box direction=\"column\" gap={4}>\n <div>A horizontal list is just a grid with only one row.</div>\n <div>Here's an example horizontal list (grid) of emails:</div>\n <Block className=\"h-20\" data-focus-within=\"bold\">\n {!emails.length && <LoadingSpinner />}\n <HorizontalList emails={emails} />\n </Block>\n <div>Here's what the configuration for the grid above looks like:</div>\n <FormattedCode url=\"/generated/code-snippets/HorizontalList.json\" />\n <div>And here's the cell renderer:</div>\n <FormattedCode url=\"/generated/code-snippets/HorizontalListCellRenderer.json\" />\n </Box>\n );\n}\n","import { useMemo } from \"react\";\nimport type json from \"../../../../public/data/contacts.json\";\nimport { useJSONData } from \"../../../hooks/useJSONData\";\n\ntype Contact = (typeof json)[0];\n\nexport function useEmails(): string[] {\n const json = useJSONData<Contact[]>(\"/data/contacts.json\");\n\n return useMemo(() => {\n if (json) {\n return json\n .map((contact) => contact.email)\n .sort((a, b) => a.localeCompare(b));\n }\n\n return [];\n }, [json]);\n}\n"],"names":["CellComponent","columnIndex","emails","style","jsx","className","cn","children","HorizontalList","Grid","cellComponent","cellProps","columnCount","length","columnWidth","rowCount","rowHeight","HorizontalListsRoute","json","useJSONData","useMemo","map","contact","email","sort","a","b","localeCompare","useEmails","jsxs","Box","direction","gap","Block","LoadingSpinner","FormattedCode","url"],"mappings":"4PAMA,SAASA,GAAcC,YACrBA,EAAAC,OACAA,EAAAC,MACAA,IAEA,OACEC,EAAAA,IAAC,MAAA,CACCC,UAAWC,EAAG,0CAA2C,CACvD,sBAAuBL,EAAc,GAAM,IAE7CE,QAECI,WAAON,IAGd,CCfA,SAASO,GAAeN,OAAEA,IACxB,OACEE,EAAAA,IAACK,EAAA,CACCC,cAAeV,EACfW,UAAW,CAAET,UACbU,YAAaV,EAAOW,OACpBC,YAAa,IACbC,SAAU,EACVC,UAAU,QAGhB,CCVA,SAAwBC,IACtB,MAAMf,ECFD,WACL,MAAMgB,EAAOC,EAAuB,uBAEpC,OAAOC,EAAAA,QAAQ,IACTF,EACKA,EACJG,IAAKC,GAAYA,EAAQC,OACzBC,KAAK,CAACC,EAAGC,IAAMD,EAAEE,cAAcD,IAG7B,GACN,CAACR,GACN,CDViBU,GAEf,OACEC,EAAAA,KAACC,EAAA,CAAIC,UAAU,SAASC,IAAK,EAC3BzB,SAAA,GAAAH,IAAC,OAAIG,SAAA,0DACLH,IAAC,OAAIG,SAAA,wDACLsB,EAAAA,KAACI,EAAA,CAAM5B,UAAU,OAAO,oBAAkB,OACvCE,SAAA,EAACL,EAAOW,cAAWqB,EAAA,CAAA,GACpB9B,MAACI,GAAeN,gBAElBE,IAAC,OAAIG,SAAA,mEACLH,IAAC+B,EAAA,CAAcC,IAAI,mDACnBhC,IAAC,OAAIG,SAAA,oCACLH,IAAC+B,EAAA,CAAcC,IAAI,+DAGzB"}
@@ -1,2 +0,0 @@
1
- import{r as e,j as o,B as s,a as l,C as a}from"./index-B_YQ7rlN.js";import{G as n}from"./Grid-DH-j7ODh.js";import{B as r}from"./arePropsEqual-D3jAKwxp.js";import{F as t}from"./FormattedCode-CAmuOSRw.js";import{H as i}from"./Header-BYp8JKXz.js";import{S as d}from"./Select-C5ovWBbK.js";import{C as c}from"./CellComponent.example-e4JJmmZM.js";import{u,C as h,c as m}from"./useContacts-BItVOkyi.js";import{L as p}from"./LoadingSpinner-Z5HQViRD.js";const v=e.useRef,x={label:"",value:""},j=["auto","center","end","smart","start"].map(e=>({label:`align: ${e}`,value:e}));j.unshift(x);const f=["auto","instant","smooth"].map(e=>({label:`behavior: ${e}`,value:e}));f.unshift(x);const g=h.map(e=>({label:e,value:e})).sort((e,o)=>e.label.localeCompare(o.label));function C(){const C=u(),b=e.useMemo(()=>{const e=[];return C&&(C.reduce((e,o)=>(e.includes(o.title)||e.push(o.title),e),new Array).sort().forEach(o=>{e.push({label:o,value:o})}),e.unshift(x)),e},[C]),[w,A]=e.useState(),[I,S]=e.useState(),[k,G]=e.useState(x),[N,P]=e.useState(x),R=v(null);return o.jsxs(s,{direction:"column",gap:4,children:[o.jsx(i,{section:"Grids",title:"Imperative API"}),o.jsx("div",{children:"Grid provides an imperative API for responding to events. The recommended way to access this API is to use the exported ref hook:"}),o.jsx(t,{url:"/generated/code-snippets/useGridRefImport.json"}),o.jsx("div",{children:"Attach the ref during render:"}),o.jsx(t,{url:"/generated/code-snippets/useGridRef.json"}),o.jsx("div",{children:"And call API methods in an event handler:"}),o.jsx(t,{url:"/generated/code-snippets/gridRefClickEventHandler.json"}),o.jsx("div",{children:"The form below uses the imperative API to scroll the list:"}),o.jsxs(s,{direction:"row",gap:4,children:[o.jsx(d,{className:"flex-1",onChange:A,options:j,placeholder:"Align",value:w}),o.jsx(d,{className:"flex-1",onChange:S,options:f,placeholder:"Scroll behavior",value:I})]}),o.jsxs(s,{direction:"row",gap:4,children:[o.jsx(d,{className:"flex-1",onChange:P,options:b,placeholder:"Job title",value:N}),o.jsx(d,{className:"flex-1",onChange:G,options:g,placeholder:"Column",value:k}),o.jsx(l,{className:"shrink-0",disabled:!k.value&&!N.value,onClick:()=>{const e=R.current;if(e){const o=k?.value?h.indexOf(k.value):void 0,s=N?.value?C.findIndex(e=>e.title===N.value):void 0;void 0!==o&&void 0!==s?e.scrollToCell({behavior:I?.value,columnAlign:w?.value,columnIndex:o,rowAlign:w?.value,rowIndex:s}):void 0!==o?e.scrollToColumn({align:w?.value,behavior:I?.value,index:o}):void 0!==s&&e.scrollToRow({align:w?.value,behavior:I?.value,index:s})}},children:"Scroll"})]}),o.jsxs(r,{className:"h-50","data-focus-within":"bold",children:[!C.length&&o.jsx(p,{}),o.jsx(n,{cellComponent:c,cellProps:{contacts:C},columnCount:g.length,columnWidth:m,gridRef:R,rowCount:C.length,rowHeight:25})]}),o.jsxs("div",{children:["The Grid API also provides ",o.jsx("code",{children:"scrollToColumn"})," and"," ",o.jsx("code",{children:"scrollToRow"})," methods for single-axis scrolling."]}),o.jsxs(a,{intent:"primary",children:[o.jsx("strong",{className:"text-sky-300",children:"Note"})," If you are passing the ref to another component or hook, use the ref callback function instead."]}),o.jsx(t,{url:"/generated/code-snippets/useGridCallbackRef.json"})]})}export{C as default};
2
- //# sourceMappingURL=ImperativeApiRoute-DD9Z7HWg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ImperativeApiRoute-DD9Z7HWg.js","sources":["../../lib/components/grid/useGridRef.ts","../../src/routes/grid/ImperativeApiRoute.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport type { GridImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref for the Grid component.\n */\nexport const useGridRef = useRef as typeof useRef<GridImperativeAPI>;\n","import { useMemo, useState } from \"react\";\nimport { Grid, useGridRef, type Align } from \"react-window\";\nimport { Block } from \"../../components/Block\";\nimport { Box } from \"../../components/Box\";\nimport { Button } from \"../../components/Button\";\nimport { Callout } from \"../../components/Callout\";\nimport { FormattedCode } from \"../../components/code/FormattedCode\";\nimport { Header } from \"../../components/Header\";\nimport { Select, type Option } from \"../../components/Select\";\nimport { CellComponent } from \"./examples/CellComponent.example\";\nimport { columnWidth } from \"./examples/columnWidth.example\";\nimport type { Contact } from \"./examples/Grid.example\";\nimport { COLUMN_KEYS } from \"./examples/shared\";\nimport { useContacts } from \"./hooks/useContacts\";\nimport { LoadingSpinner } from \"../../components/LoadingSpinner\";\n\nconst EMPTY_OPTION: Option<string> = {\n label: \"\",\n value: \"\"\n};\n\nconst ALIGNMENTS: Option<Align>[] = (\n [\"auto\", \"center\", \"end\", \"smart\", \"start\"] satisfies Align[]\n).map((value) => ({\n label: `align: ${value}`,\n value\n}));\nALIGNMENTS.unshift(EMPTY_OPTION as Option<Align>);\n\nconst BEHAVIORS: Option<ScrollBehavior>[] = (\n [\"auto\", \"instant\", \"smooth\"] satisfies ScrollBehavior[]\n).map((value) => ({\n label: `behavior: ${value}`,\n value\n}));\nBEHAVIORS.unshift(EMPTY_OPTION as Option<ScrollBehavior>);\n\nconst COLUMNS: Option<string>[] = COLUMN_KEYS.map((key) => ({\n label: key,\n value: key\n})).sort((a, b) => a.label.localeCompare(b.label));\n\nexport default function GridImperativeApiRoute() {\n const contacts = useContacts();\n\n const titleOptions = useMemo<Option<string>[]>(() => {\n const options: Option<string>[] = [];\n if (contacts) {\n contacts\n .reduce((array, contact) => {\n if (!array.includes(contact.title)) {\n array.push(contact.title);\n }\n return array;\n }, new Array<string>())\n .sort()\n .forEach((title) => {\n options.push({\n label: title,\n value: title\n });\n });\n\n options.unshift(EMPTY_OPTION);\n }\n\n return options;\n }, [contacts]);\n\n const [align, setAlign] = useState<Option<Align> | undefined>();\n const [behavior, setBehavior] = useState<\n Option<ScrollBehavior> | undefined\n >();\n const [column, setColumn] = useState<Option<string>>(EMPTY_OPTION);\n const [title, setTitle] = useState<Option<string>>(EMPTY_OPTION);\n\n const gridRef = useGridRef(null);\n\n const scrollToRow = () => {\n const grid = gridRef.current;\n if (grid) {\n const columnIndex = column?.value\n ? COLUMN_KEYS.indexOf(column.value as keyof Contact)\n : undefined;\n\n const rowIndex = title?.value\n ? contacts.findIndex((row) => row.title === title.value)\n : undefined;\n\n if (columnIndex !== undefined && rowIndex !== undefined) {\n grid.scrollToCell({\n behavior: behavior?.value,\n columnAlign: align?.value,\n columnIndex,\n rowAlign: align?.value,\n rowIndex\n });\n } else if (columnIndex !== undefined) {\n grid.scrollToColumn({\n align: align?.value,\n behavior: behavior?.value,\n index: columnIndex\n });\n } else if (rowIndex !== undefined) {\n grid.scrollToRow({\n align: align?.value,\n behavior: behavior?.value,\n index: rowIndex\n });\n }\n }\n };\n\n return (\n <Box direction=\"column\" gap={4}>\n <Header section=\"Grids\" title=\"Imperative API\" />\n <div>\n Grid provides an imperative API for responding to events. The\n recommended way to access this API is to use the exported ref hook:\n </div>\n <FormattedCode url=\"/generated/code-snippets/useGridRefImport.json\" />\n <div>Attach the ref during render:</div>\n <FormattedCode url=\"/generated/code-snippets/useGridRef.json\" />\n <div>And call API methods in an event handler:</div>\n <FormattedCode url=\"/generated/code-snippets/gridRefClickEventHandler.json\" />\n <div>The form below uses the imperative API to scroll the list:</div>\n <Box direction=\"row\" gap={4}>\n <Select\n className=\"flex-1\"\n onChange={setAlign}\n options={ALIGNMENTS}\n placeholder=\"Align\"\n value={align}\n />\n <Select\n className=\"flex-1\"\n onChange={setBehavior}\n options={BEHAVIORS}\n placeholder=\"Scroll behavior\"\n value={behavior}\n />\n </Box>\n <Box direction=\"row\" gap={4}>\n <Select\n className=\"flex-1\"\n onChange={setTitle}\n options={titleOptions}\n placeholder=\"Job title\"\n value={title}\n />\n <Select\n className=\"flex-1\"\n onChange={setColumn}\n options={COLUMNS}\n placeholder=\"Column\"\n value={column}\n />\n <Button\n className=\"shrink-0\"\n disabled={!column.value && !title.value}\n onClick={scrollToRow}\n >\n Scroll\n </Button>\n </Box>\n <Block className=\"h-50\" data-focus-within=\"bold\">\n {!contacts.length && <LoadingSpinner />}\n <Grid\n cellComponent={CellComponent}\n cellProps={{ contacts }}\n columnCount={COLUMNS.length}\n columnWidth={columnWidth}\n gridRef={gridRef}\n rowCount={contacts.length}\n rowHeight={25}\n />\n </Block>\n <div>\n The Grid API also provides <code>scrollToColumn</code> and{\" \"}\n <code>scrollToRow</code> methods for single-axis scrolling.\n </div>\n <Callout intent=\"primary\">\n <strong className=\"text-sky-300\">Note</strong> If you are passing the\n ref to another component or hook, use the ref callback function instead.\n </Callout>\n <FormattedCode url=\"/generated/code-snippets/useGridCallbackRef.json\" />\n </Box>\n );\n}\n"],"names":["useGridRef","useRef","EMPTY_OPTION","label","value","ALIGNMENTS","map","unshift","BEHAVIORS","COLUMNS","COLUMN_KEYS","key","sort","a","b","localeCompare","GridImperativeApiRoute","contacts","useContacts","titleOptions","useMemo","options","reduce","array","contact","includes","title","push","Array","forEach","align","setAlign","useState","behavior","setBehavior","column","setColumn","setTitle","gridRef","jsxs","Box","direction","gap","children","jsx","Header","section","FormattedCode","url","Select","className","onChange","placeholder","Button","disabled","onClick","grid","current","columnIndex","indexOf","rowIndex","findIndex","row","scrollToCell","columnAlign","rowAlign","scrollToColumn","index","scrollToRow","Block","length","LoadingSpinner","Grid","cellComponent","CellComponent","cellProps","columnCount","columnWidth","rowCount","rowHeight","Callout","intent"],"mappings":"6bAMO,MAAMA,EAAaC,EAAAA,OCUpBC,EAA+B,CACnCC,MAAO,GACPC,MAAO,IAGHC,EACJ,CAAC,OAAQ,SAAU,MAAO,QA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,YAAanE,EAAQ6D,OACrBO,cACAvC,UACAwC,SAAU7D,EAASqD,OACnBS,UAAW,eAGd,MAAA,CAAIpC,SAAA,CAAA,gCACwBC,IAAC,QAAKD,SAAA,mBAAqB,OAAK,MAC3DC,IAAC,QAAKD,SAAA,gBAAkB,2CAE1BJ,KAACyC,EAAA,CAAQC,OAAO,UACdtC,SAAA,CAAAC,EAAAA,IAAC,SAAA,CAAOM,UAAU,eAAeP,SAAA,SAAa,wGAGhDC,IAACG,EAAA,CAAcC,IAAI,uDAGzB"}
@@ -1,2 +0,0 @@
1
- import{r as e,j as s,B as t,a,C as o}from"./index-B_YQ7rlN.js";import{L as n}from"./List-C4KHYcVU.js";import{B as r}from"./arePropsEqual-D3jAKwxp.js";import{F as i}from"./FormattedCode-CAmuOSRw.js";import{H as l}from"./Header-BYp8JKXz.js";import{L as c}from"./LoadingSpinner-Z5HQViRD.js";import{S as d}from"./Select-C5ovWBbK.js";import{u,R as h}from"./useCitiesByState-azL1M3ue.js";const p=e.useRef;function m(e,{items:s}){return"state"===s[e].type?30:25}const j={label:"",value:""},f=["auto","center","end","smart","start"].map(e=>({label:`align: ${e}`,value:e}));f.unshift(j);const x=["auto","instant","smooth"].map(e=>({label:`behavior: ${e}`,value:e}));function v(){const[v,g]=e.useState(),[b,C]=e.useState(),[w,S]=e.useState(j),I=u(),L=e.useMemo(()=>{const e=I.filter(e=>"state"===e.type).map(e=>({label:e.state,value:e.state}));return e.unshift(j),e},[I]),k=p(null);return s.jsxs(t,{direction:"column",gap:4,children:[s.jsx(l,{section:"Lists",title:"Imperative API"}),s.jsx("div",{children:"List provides an imperative API for responding to events. The recommended way to access this API is to use the exported ref hook:"}),s.jsx(i,{url:"/generated/code-snippets/useListRefImport.json"}),s.jsx("div",{children:"Attach the ref during render:"}),s.jsx(i,{url:"/generated/code-snippets/useListRef.json"}),s.jsx("div",{children:"And call API methods in an event handler:"}),s.jsx(i,{url:"/generated/code-snippets/listRefClickEventHandler.json"}),s.jsx("div",{children:"The form below uses the imperative API to scroll the list:"}),s.jsxs(t,{direction:"row",gap:4,children:[s.jsx(d,{className:"flex-1",onChange:g,options:f,placeholder:"Align",value:v}),s.jsx(d,{className:"flex-1",onChange:C,options:x,placeholder:"Scroll behavior",value:b})]}),s.jsxs(t,{direction:"row",gap:4,children:[s.jsx(d,{className:"flex-1",onChange:S,options:L,placeholder:"State",value:w}),s.jsx(a,{className:"shrink-0",disabled:!w.value,onClick:()=>{const e=I.findIndex(e=>"state"===e.type&&e.state===w.value);k.current?.scrollToRow({align:v?.value,behavior:b?.value,index:e})},children:"Scroll"})]}),s.jsxs(r,{className:"h-50","data-focus-within":"bold",children:[!I.length&&s.jsx(c,{}),s.jsx(n,{listRef:k,rowComponent:h,rowCount:I.length,rowHeight:m,rowProps:{items:I}})]}),s.jsxs(o,{intent:"primary",children:[s.jsx("strong",{className:"text-sky-300",children:"Note"})," If you are passing the ref to another component or hook, use the ref callback function instead."]}),s.jsx(i,{url:"/generated/code-snippets/useListCallbackRef.json"})]})}x.unshift(j);export{v as default};
2
- //# sourceMappingURL=ImperativeApiRoute-DntU9ReR.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ImperativeApiRoute-DntU9ReR.js","sources":["../../lib/components/list/useListRef.ts","../../src/routes/list/examples/rowHeight.example.ts","../../src/routes/list/ImperativeApiRoute.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport type { ListImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref for the List component.\n */\nexport const useListRef = useRef as typeof useRef<ListImperativeAPI>;\n","import type { RowProps } from \"./ListVariableRowHeights.example\";\n\n// <begin>\n\nfunction rowHeight(index: number, { items }: RowProps) {\n return items[index].type === \"state\" ? 30 : 25;\n}\n\n// <end>\n\nexport { rowHeight };\n","import { useMemo, useState } from \"react\";\nimport { List, useListRef, type Align } from \"react-window\";\nimport { Block } from \"../../components/Block\";\nimport { Box } from \"../../components/Box\";\nimport { Button } from \"../../components/Button\";\nimport { Callout } from \"../../components/Callout\";\nimport { FormattedCode } from \"../../components/code/FormattedCode\";\nimport { Header } from \"../../components/Header\";\nimport { LoadingSpinner } from \"../../components/LoadingSpinner\";\nimport { Select, type Option } from \"../../components/Select\";\nimport { RowComponent } from \"./examples/ListVariableRowHeights.example\";\nimport { rowHeight } from \"./examples/rowHeight.example\";\nimport { useCitiesByState } from \"./hooks/useCitiesByState\";\n\nconst EMPTY_OPTION: Option<string> = {\n label: \"\",\n value: \"\"\n};\n\nconst ALIGNMENTS: Option<Align>[] = (\n [\"auto\", \"center\", \"end\", \"smart\", \"start\"] satisfies Align[]\n).map((value) => ({\n label: `align: ${value}`,\n value\n}));\nALIGNMENTS.unshift(EMPTY_OPTION as Option<Align>);\n\nconst BEHAVIORS: Option<ScrollBehavior>[] = (\n [\"auto\", \"instant\", \"smooth\"] satisfies ScrollBehavior[]\n).map((value) => ({\n label: `behavior: ${value}`,\n value\n}));\nBEHAVIORS.unshift(EMPTY_OPTION as Option<ScrollBehavior>);\n\nexport default function ListImperativeApiRoute() {\n const [align, setAlign] = useState<Option<Align> | undefined>();\n const [behavior, setBehavior] = useState<\n Option<ScrollBehavior> | undefined\n >();\n const [state, setState] = useState<Option<string>>(EMPTY_OPTION);\n\n const citiesByState = useCitiesByState();\n\n const stateOptions = useMemo<Option<string>[]>(() => {\n const options: Option<string>[] = citiesByState\n .filter((item) => item.type === \"state\")\n .map((item) => ({\n label: item.state,\n value: item.state\n }));\n options.unshift(EMPTY_OPTION);\n\n return options;\n }, [citiesByState]);\n\n const listRef = useListRef(null);\n\n const scrollToRow = () => {\n const index = citiesByState.findIndex(\n (item) => item.type === \"state\" && item.state === state.value\n );\n listRef.current?.scrollToRow({\n align: align?.value,\n behavior: behavior?.value,\n index\n });\n };\n\n return (\n <Box direction=\"column\" gap={4}>\n <Header section=\"Lists\" title=\"Imperative API\" />\n <div>\n List provides an imperative API for responding to events. The\n recommended way to access this API is to use the exported ref hook:\n </div>\n <FormattedCode url=\"/generated/code-snippets/useListRefImport.json\" />\n <div>Attach the ref during render:</div>\n <FormattedCode url=\"/generated/code-snippets/useListRef.json\" />\n <div>And call API methods in an event handler:</div>\n <FormattedCode url=\"/generated/code-snippets/listRefClickEventHandler.json\" />\n <div>The form below uses the imperative API to scroll the list:</div>\n <Box direction=\"row\" gap={4}>\n <Select\n className=\"flex-1\"\n onChange={setAlign}\n options={ALIGNMENTS}\n placeholder=\"Align\"\n value={align}\n />\n <Select\n className=\"flex-1\"\n onChange={setBehavior}\n options={BEHAVIORS}\n placeholder=\"Scroll behavior\"\n value={behavior}\n />\n </Box>\n <Box direction=\"row\" gap={4}>\n <Select\n className=\"flex-1\"\n onChange={setState}\n options={stateOptions}\n placeholder=\"State\"\n value={state}\n />\n <Button\n className=\"shrink-0\"\n disabled={!state.value}\n onClick={scrollToRow}\n >\n Scroll\n </Button>\n </Box>\n <Block className=\"h-50\" data-focus-within=\"bold\">\n {!citiesByState.length && <LoadingSpinner />}\n <List\n listRef={listRef}\n rowComponent={RowComponent}\n rowCount={citiesByState.length}\n rowHeight={rowHeight}\n rowProps={{ items: citiesByState }}\n />\n </Block>\n <Callout intent=\"primary\">\n <strong className=\"text-sky-300\">Note</strong> If you are passing the\n ref to another component or hook, use the ref callback function instead.\n </Callout>\n <FormattedCode url=\"/generated/code-snippets/useListCallbackRef.json\" />\n </Box>\n );\n}\n"],"names":["useListRef","useRef","rowHeight","index","items","type","EMPTY_OPTION","label","value","ALIGNMENTS","map","unshift","BEHAVIORS","ListImperativeApiRoute","align","setAlign","useState","behavior","setBehavior","state","setState","citiesByState","useCitiesByState","stateOptions","useMemo","options","filter","item","listRef","jsxs","Box","direction","gap","children","jsx","Header","section","title","FormattedCode","url","Select","className","onChange","placeholder","Button","disabled","onClick","findIndex","current","scrollToRow","Block","length","LoadingSpinner","List","rowComponent","RowComponent","rowCount","rowProps","Callout","intent"],"mappings":"8XAMO,MAAMA,EAAaC,EAAAA,OCF1B,SAASC,EAAUC,GAAeC,MAAEA,IAClC,M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OAGXY,EAAAA,KAACC,EAAA,CAAIC,UAAU,MAAMC,IAAK,EACxBC,SAAA,CAAAC,EAAAA,IAACM,EAAA,CACCC,UAAU,SACVC,SAAUtB,EACVK,QAASF,EACToB,YAAY,QACZnC,MAAOW,IAETe,EAAAA,IAACU,EAAA,CACCH,UAAU,WACVI,UAAW1B,EAAMX,MACjBsC,QAnDY,KAClB,MAAM3C,EAAQkB,EAAc0B,UACzBpB,GAAuB,UAAdA,EAAKtB,MAAoBsB,EAAKR,QAAUA,EAAMX,OAE1DoB,EAAQoB,SAASC,YAAY,CAC3BnC,MAAOA,GAAON,MACdS,SAAUA,GAAUT,MACpBL,WA6CG8B,SAAA,cAIHJ,EAAAA,KAACqB,EAAA,CAAMT,UAAU,OAAO,oBAAkB,OACvCR,SAAA,EAACZ,EAAc8B,cAAWC,EAAA,CAAA,GAC3BlB,EAAAA,IAACmB,EAAA,CACCzB,UACA0B,aAAcC,EACdC,SAAUnC,EAAc8B,OACxBjD,YACAuD,SAAU,CAAErD,MAAOiB,UAGvBQ,KAAC6B,EAAA,CAAQC,OAAO,UACd1B,SAAA,CAAAC,EAAAA,IAAC,SAAA,CAAOO,UAAU,eAAeR,SAAA,SAAa,wGAGhDC,IAACI,EAAA,CAAcC,IAAI,uDAGzB,CAlGA3B,EAAUD,QAAQL"}
@@ -1,2 +0,0 @@
1
- import{r as e,j as t}from"./index-B_YQ7rlN.js";import{u as o,a as s,b as n}from"./arePropsEqual-D3jAKwxp.js";function r({className:r,defaultHeight:i=0,listRef:a,onResize:l,onRowsRendered:u,overscanCount:c=3,rowComponent:d,rowCount:m,rowHeight:f,rowProps:p,style:x,...h}){const g=o(p),v=e.useMemo(()=>e.memo(d,s),[d]),[w,C]=e.useState(null),{getCellBounds:z,getEstimatedSize:I,scrollToIndex:R,startIndex:j,stopIndex:y}=n({containerElement:w,defaultContainerSize:i,direction:"vertical",itemCount:m,itemProps:g,itemSize:f,onResize:l,overscanCount:c});e.useImperativeHandle(a,()=>({get element(){return w},scrollToRow({align:e="auto",behavior:t="auto",index:o}){R({align:e,behavior:t,containerScrollOffset:w?.scrollTop??0,index:o})}}),[w,R]),e.useEffect(()=>{j>=0&&y>=0&&u&&u({startIndex:j,stopIndex:y})},[u,j,y]);const E=e.useMemo(()=>{const t=[];if(m>0)for(let o=j;o<=y;o++){const s=z(o);t.push(e.createElement(v,{...g,key:o,index:o,style:{position:"absolute",left:0,transform:`translateY(${s.scrollOffset}px)`,height:s.size,width:"100%"}}))}return t},[v,z,m,g,j,y]);return t.jsx("div",{...h,className:r,ref:C,style:{...x,maxHeight:"100%",flexGrow:1,overflowY:"auto"},children:t.jsx("div",{className:r,style:{height:I(),position:"relative",width:"100%"},children:E})})}export{r as L};
2
- //# sourceMappingURL=List-C4KHYcVU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"List-C4KHYcVU.js","sources":["../../lib/components/list/List.tsx"],"sourcesContent":["import {\n memo,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n type ReactNode\n} from \"react\";\nimport { useVirtualizer } from \"../../core/useVirtualizer\";\nimport { useMemoizedObject } from \"../../hooks/useMemoizedObject\";\nimport type { Align } from \"../../types\";\nimport { arePropsEqual } from \"../../utils/arePropsEqual\";\nimport type { ListProps } from \"./types\";\n\nexport function List<RowProps extends object>({\n className,\n defaultHeight = 0,\n listRef,\n onResize,\n onRowsRendered,\n overscanCount = 3,\n rowComponent: RowComponentProp,\n rowCount,\n rowHeight,\n rowProps: rowPropsUnstable,\n style,\n ...rest\n}: ListProps<RowProps>) {\n const rowProps = useMemoizedObject(rowPropsUnstable);\n const RowComponent = useMemo(\n () => memo(RowComponentProp, arePropsEqual),\n [RowComponentProp]\n );\n\n const [element, setElement] = useState<HTMLDivElement | null>(null);\n\n const {\n getCellBounds,\n getEstimatedSize,\n scrollToIndex,\n startIndex,\n stopIndex\n } = useVirtualizer({\n containerElement: element,\n defaultContainerSize: defaultHeight,\n direction: \"vertical\",\n itemCount: rowCount,\n itemProps: rowProps,\n itemSize: rowHeight,\n onResize,\n overscanCount\n });\n\n useImperativeHandle(\n listRef,\n () => ({\n get element() {\n return element;\n },\n\n scrollToRow({\n align = \"auto\",\n behavior = \"auto\",\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\n index: number;\n }) {\n scrollToIndex({\n align,\n behavior,\n containerScrollOffset: element?.scrollTop ?? 0,\n index\n });\n }\n }),\n [element, scrollToIndex]\n );\n\n useEffect(() => {\n if (startIndex >= 0 && stopIndex >= 0 && onRowsRendered) {\n onRowsRendered({\n startIndex,\n stopIndex\n });\n }\n }, [onRowsRendered, startIndex, stopIndex]);\n\n const rows = useMemo(() => {\n const children: ReactNode[] = [];\n if (rowCount > 0) {\n for (let index = startIndex; index <= stopIndex; index++) {\n const bounds = getCellBounds(index);\n\n children.push(\n <RowComponent\n {...(rowProps as RowProps)}\n key={index}\n index={index}\n style={{\n position: \"absolute\",\n left: 0,\n transform: `translateY(${bounds.scrollOffset}px)`,\n height: bounds.size,\n width: \"100%\"\n }}\n />\n );\n }\n }\n return children;\n }, [RowComponent, getCellBounds, rowCount, rowProps, startIndex, stopIndex]);\n\n return (\n <div\n {...rest}\n className={className}\n ref={setElement}\n style={{\n ...style,\n maxHeight: \"100%\",\n flexGrow: 1,\n overflowY: \"auto\"\n }}\n >\n <div\n className={className}\n style={{\n height: getEstimatedSize(),\n position: \"relative\",\n width: \"100%\"\n }}\n >\n {rows}\n </div>\n </div>\n );\n}\n"],"names":["List","className","defaultHeight","listRef","onResize","onRowsRendered","overscanCount","rowComponent","RowComponentProp","rowCount","rowHeight","rowProps","rowPropsUnstable","style","rest","useMemoizedObject","RowComponent","useMemo","memo","arePropsEqual","element","setElement","useState","getCellBounds","getEstimatedSize","scrollToIndex","startIndex","stopIndex","useVirtualizer","containerElement","defaultContainerSize","direction","itemCount","itemProps","itemSize","useImperativeHandle","scrollToRow","align","behavior","index","containerScrollOffset","scrollTop","useEffect","rows","children","bounds","push","createElement","key","position","left","transform","scrollOffset","height","size","width","jsx","ref","maxHeight","flexGrow","overflowY"],"mappings":"6GAcO,SAASA,GAA8BC,UAC5CA,EAAAC,cACAA,EAAgB,EAAAC,QAChBA,EAAAC,SACAA,EAAAC,eACAA,EAAAC,cACAA,EAAgB,EAChBC,aAAcC,EAAAC,SACdA,EAAAC,UACAA,EACAC,SAAUC,EAAAC,MACVA,KACGC,IAEH,MAAMH,EAAWI,EAAkBH,GAC7BI,EAAeC,EAAAA,QACnB,IAAMC,EAAAA,KAAKV,EAAkBW,GAC7B,CAACX,KAGIY,EAASC,GAAcC,EAAAA,SAAgC,OAExDC,cACJA,EAAAC,iBACAA,EAAAC,cACAA,EAAAC,WACAA,EAAAC,UACAA,GACEC,EAAe,CACjBC,iBAAkBT,EAClBU,qBAAsB5B,EACtB6B,UAAW,WACXC,UAAWvB,EACXwB,UAAWtB,EACXuB,SAAUxB,EACVN,WACAE,kBAGF6B,EAAAA,oBACEhC,EACA,KAAA,CACE,WAAIiB,GACF,OAAOA,CACT,EAEA,WAAAgB,EAAYC,MACVA,EAAQ,OAAAC,SACRA,EAAW,OAAAC,MACXA,IAMAd,EAAc,CACZY,QACAC,WACAE,sBAAuBpB,GAASqB,WAAa,EAC7CF,SAEJ,IAEF,CAACnB,EAASK,IAGZiB,EAAAA,UAAU,KACJhB,GAAc,GAAKC,GAAa,GAAKtB,GACvCA,EAAe,CACbqB,aACAC,eAGH,CAACtB,EAAgBqB,EAAYC,IAEhC,MAAMgB,EAAO1B,EAAAA,QAAQ,KACnB,MAAM2B,EAAwB,GAC9B,GAAInC,EAAW,EACb,IAAA,IAAS8B,EAAQb,EAAYa,GAASZ,EAAWY,IAAS,CACxD,MAAMM,EAAStB,EAAcgB,GAE7BK,EAASE,KACPC,EAAAA,cAAC/B,EAAA,IACML,EACLqC,IAAKT,EACLA,QACA1B,MAAO,CACLoC,SAAU,WACVC,KAAM,EACNC,UAAW,cAAcN,EAAOO,kBAChCC,OAAQR,EAAOS,KACfC,MAAO,UAIf,CAEF,OAAOX,GACN,CAAC5B,EAAcO,EAAed,EAAUE,EAAUe,EAAYC,IAEjE,OACE6B,EAAAA,IAAC,MAAA,IACK1C,EACJb,YACAwD,IAAKpC,EACLR,MAAO,IACFA,EACH6C,UAAW,OACXC,SAAU,EACVC,UAAW,QAGbhB,SAAAY,EAAAA,IAAC,MAAA,CACCvD,YACAY,MAAO,CACLwC,OAAQ7B,IACRyB,SAAU,WACVM,MAAO,QAGRX,SAAAD,KAIT"}
@@ -1,2 +0,0 @@
1
- import{r as e,j as t,B as r}from"./index-B_YQ7rlN.js";function a({title:t,titleId:r,...a},n){return e.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":r},a),t?e.createElement("title",{id:r},t):null,e.createElement("path",{fillRule:"evenodd",d:"M15.312 11.424a5.5 5.5 0 0 1-9.201 2.466l-.312-.311h2.433a.75.75 0 0 0 0-1.5H3.989a.75.75 0 0 0-.75.75v4.242a.75.75 0 0 0 1.5 0v-2.43l.31.31a7 7 0 0 0 11.712-3.138.75.75 0 0 0-1.449-.39Zm1.23-3.723a.75.75 0 0 0 .219-.53V2.929a.75.75 0 0 0-1.5 0V5.36l-.31-.31A7 7 0 0 0 3.239 8.188a.75.75 0 1 0 1.448.389A5.5 5.5 0 0 1 13.89 6.11l.311.31h-2.432a.75.75 0 0 0 0 1.5h4.243a.75.75 0 0 0 .53-.219Z",clipRule:"evenodd"}))}const n=e.forwardRef(a);function o(t){const[r,a]=e.useState(),[n,o]=e.useState(null);if(n)throw n;return e.useEffect(()=>{const e=new AbortController;return(async()=>{try{const r=await fetch(t,{signal:e.signal});if(!e.signal.aborted){const t=await r.json();e.signal.aborted||a(t)}}catch(r){if(r instanceof Error&&"AbortError"===r?.name)return;console.error("Error thrown for URL: %o\n\n%o",t,r),o(r)}})(),()=>{const t=new Error;t.name="AbortError",e.abort(t)}},[t]),r}function l(){return t.jsxs(r,{align:"center",className:"text-slate-300",direction:"row",gap:2,children:[t.jsx(n,{className:"size-4 animate-spin"}),"Loading..."]})}export{l as L,o as u};
2
- //# sourceMappingURL=LoadingSpinner-Z5HQViRD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoadingSpinner-Z5HQViRD.js","sources":["../../node_modules/.pnpm/@heroicons+react@2.2.0_react@19.1.0/node_modules/@heroicons/react/20/solid/esm/ArrowPathIcon.js","../../src/hooks/useJSONData.ts","../../src/components/LoadingSpinner.tsx"],"sourcesContent":["import * as React from \"react\";\nfunction ArrowPathIcon({\n title,\n titleId,\n ...props\n}, svgRef) {\n return /*#__PURE__*/React.createElement(\"svg\", Object.assign({\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 20 20\",\n fill: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\",\n ref: svgRef,\n \"aria-labelledby\": titleId\n }, props), title ? /*#__PURE__*/React.createElement(\"title\", {\n id: titleId\n }, title) : null, /*#__PURE__*/React.createElement(\"path\", {\n fillRule: \"evenodd\",\n d: \"M15.312 11.424a5.5 5.5 0 0 1-9.201 2.466l-.312-.311h2.433a.75.75 0 0 0 0-1.5H3.989a.75.75 0 0 0-.75.75v4.242a.75.75 0 0 0 1.5 0v-2.43l.31.31a7 7 0 0 0 11.712-3.138.75.75 0 0 0-1.449-.39Zm1.23-3.723a.75.75 0 0 0 .219-.53V2.929a.75.75 0 0 0-1.5 0V5.36l-.31-.31A7 7 0 0 0 3.239 8.188a.75.75 0 1 0 1.448.389A5.5 5.5 0 0 1 13.89 6.11l.311.31h-2.432a.75.75 0 0 0 0 1.5h4.243a.75.75 0 0 0 .53-.219Z\",\n clipRule: \"evenodd\"\n }));\n}\nconst ForwardRef = /*#__PURE__*/ React.forwardRef(ArrowPathIcon);\nexport default ForwardRef;","import { useEffect, useState } from \"react\";\n\nexport function useJSONData<Type extends object>(url: string) {\n const [json, setJSON] = useState<Type | undefined>();\n const [error, setError] = useState<unknown>(null);\n\n if (error) {\n throw error;\n }\n\n useEffect(() => {\n const abortController = new AbortController();\n\n (async () => {\n try {\n const data = await fetch(url, {\n signal: abortController.signal\n });\n if (!abortController.signal.aborted) {\n const json = await data.json();\n if (!abortController.signal.aborted) {\n setJSON(json as Type);\n }\n }\n } catch (error) {\n if (error instanceof Error && error?.name === \"AbortError\") {\n return;\n }\n\n console.error(\"Error thrown for URL: %o\\n\\n%o\", url, error);\n\n setError(error);\n }\n })();\n\n return () => {\n const error = new Error();\n error.name = \"AbortError\";\n\n abortController.abort(error);\n };\n }, [url]);\n\n return json;\n}\n","import { ArrowPathIcon } from \"@heroicons/react/20/solid\";\nimport { Box } from \"./Box\";\n\nexport function LoadingSpinner() {\n return (\n <Box align=\"center\" className=\"text-slate-300\" direction=\"row\" gap={2}>\n <ArrowPathIcon className=\"size-4 animate-spin\" />\n Loading...\n </Box>\n );\n}\n"],"names":["ArrowPathIcon","title","titleId","props","svgRef","React.createElement","Object","assign","xmlns","viewBox","fill","ref","id","fillRule","d","clipRule","ForwardRef","React.forwardRef","useJSONData","url","json","setJSON","useState","error","setError","useEffect","abortController","AbortController","data","fetch","signal","aborted","Error","name","console","abort","LoadingSpinner","jsxs","Box","align","className","direction","gap","children","jsx"],"mappings":"sDACA,SAASA,GAAcC,MACrBA,EAAAC,QACAA,KACGC,GACFC,GACD,OAAoBC,gBAAoB,MAAOC,OAAOC,OAAO,CAC3DC,MAAO,6BACPC,QAAS,YACTC,KAAM,eACN,cAAe,OACf,YAAa,OACbC,IAAKP,EACL,kBAAmBF,GAClBC,GAAQF,EAAqBI,EAAAA,cAAoB,QAAS,CAC3DO,GAAIV,GACHD,GAAS,KAAmBI,EAAAA,cAAoB,OAAQ,CACzDQ,SAAU,UACVC,EAAG,0YACHC,SAAU,YAEd,CACA,MAAMC,EAA2BC,EAAAA,WAAiBjB,GCpB3C,SAASkB,EAAiCC,GAC/C,MAAOC,EAAMC,GAAWC,cACjBC,EAAOC,GAAYF,EAAAA,SAAkB,MAE5C,GAAIC,EACF,MAAMA,EAoCR,OAjCAE,EAAAA,UAAU,KACR,MAAMC,EAAkB,IAAIC,gBAwB5B,MAtBA,WACE,IACE,MAAMC,QAAaC,MAAMV,EAAK,CAC5BW,OAAQJ,EAAgBI,SAE1B,IAAKJ,EAAgBI,OAAOC,QAAS,CACnC,MAAMX,QAAaQ,EAAKR,OACnBM,EAAgBI,OAAOC,SAC1BV,EAAQD,EAEZ,CACF,OAASG,GACP,GAAIA,aAAiBS,OAAyB,eAAhBT,GAAOU,KACnC,OAGFC,QAAQX,MAAM,iCAAkCJ,EAAKI,GAErDC,EAASD,EACX,CACF,EApBA,GAsBO,KACL,MAAMA,EAAQ,IAAIS,MAClBT,EAAMU,KAAO,aAEbP,EAAgBS,MAAMZ,KAEvB,CAACJ,IAEGC,CACT,CCzCO,SAASgB,IACd,OACEC,OAACC,GAAIC,MAAM,SAASC,UAAU,iBAAiBC,UAAU,MAAMC,IAAK,EAClEC,SAAA,GAAAC,IAAC5C,EAAA,CAAcwC,UAAU,wBAAwB,eAIvD","x_google_ignoreList":[0]}
@@ -1,2 +0,0 @@
1
- import{j as i,B as r}from"./index-B_YQ7rlN.js";import{C as o}from"./ContinueLink-CbPhCk1k.js";import{C as e}from"./ComponentProps-DMkeake1.js";import"./LoadingSpinner-Z5HQViRD.js";import"./Header-BYp8JKXz.js";function s(){return i.jsxs(r,{direction:"column",gap:4,children:[i.jsx(e,{section:"Grids",url:"/generated/js-docs/Grid.json"}),i.jsx(o,{to:"/grid/imperative-api",title:"imperative api"})]})}export{s as default};
2
- //# sourceMappingURL=PropsRoute-D77WXdPD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PropsRoute-D77WXdPD.js","sources":["../../src/routes/grid/PropsRoute.tsx"],"sourcesContent":["import { Box } from \"../../components/Box\";\nimport { ContinueLink } from \"../../components/ContinueLink\";\nimport { ComponentProps } from \"../../components/props/ComponentProps\";\n\nexport default function GridPropsRoute() {\n return (\n <Box direction=\"column\" gap={4}>\n <ComponentProps section=\"Grids\" url=\"/generated/js-docs/Grid.json\" />\n <ContinueLink to=\"/grid/imperative-api\" title=\"imperative api\" />\n </Box>\n );\n}\n"],"names":["GridPropsRoute","jsxs","Box","direction","gap","children","jsx","ComponentProps","section","url","ContinueLink","to","title"],"mappings":"iNAIA,SAAwBA,IACtB,OACEC,EAAAA,KAACC,EAAA,CAAIC,UAAU,SAASC,IAAK,EAC3BC,SAAA,CAAAC,EAAAA,IAACC,EAAA,CAAeC,QAAQ,QAAQC,IAAI,iCACpCH,EAAAA,IAACI,EAAA,CAAaC,GAAG,uBAAuBC,MAAM,qBAGpD"}
@@ -1,2 +0,0 @@
1
- import{j as i,B as s}from"./index-B_YQ7rlN.js";import{C as t}from"./ContinueLink-CbPhCk1k.js";import{C as o}from"./ComponentProps-DMkeake1.js";import"./LoadingSpinner-Z5HQViRD.js";import"./Header-BYp8JKXz.js";function e(){return i.jsxs(s,{direction:"column",gap:4,children:[i.jsx(o,{section:"Lists",url:"/generated/js-docs/List.json"}),i.jsx(t,{to:"/list/imperative-api",title:"imperative api"})]})}export{e as default};
2
- //# sourceMappingURL=PropsRoute-D9jETWHk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PropsRoute-D9jETWHk.js","sources":["../../src/routes/list/PropsRoute.tsx"],"sourcesContent":["import { Box } from \"../../components/Box\";\nimport { ContinueLink } from \"../../components/ContinueLink\";\nimport { ComponentProps } from \"../../components/props/ComponentProps\";\n\nexport default function ListPropsRoute() {\n return (\n <Box direction=\"column\" gap={4}>\n <ComponentProps section=\"Lists\" url=\"/generated/js-docs/List.json\" />\n <ContinueLink to=\"/list/imperative-api\" title=\"imperative api\" />\n </Box>\n );\n}\n"],"names":["ListPropsRoute","jsxs","Box","direction","gap","children","jsx","ComponentProps","section","url","ContinueLink","to","title"],"mappings":"iNAIA,SAAwBA,IACtB,OACEC,EAAAA,KAACC,EAAA,CAAIC,UAAU,SAASC,IAAK,EAC3BC,SAAA,CAAAC,EAAAA,IAACC,EAAA,CAAeC,QAAQ,QAAQC,IAAI,iCACpCH,EAAAA,IAACI,EAAA,CAAaC,GAAG,uBAAuBC,MAAM,qBAGpD"}
@@ -1,2 +0,0 @@
1
- import{j as e,B as t,E as s}from"./index-B_YQ7rlN.js";import{B as r}from"./arePropsEqual-D3jAKwxp.js";import{F as o}from"./FormattedCode-CAmuOSRw.js";import{L as n}from"./LoadingSpinner-Z5HQViRD.js";import{c as i,i as a,u as l}from"./useContacts-BItVOkyi.js";import{G as c}from"./Grid-DH-j7ODh.js";function d({contacts:t}){return e.jsx(c,{cellComponent:m,cellProps:{contacts:t},columnCount:10,columnWidth:i,dir:"rtl",rowCount:t.length,rowHeight:35})}function m({contacts:t,columnIndex:s,rowIndex:r,style:o}){const n=t[r][a(s)];return e.jsxs("div",{className:"truncate leading-none",style:o,children:[e.jsx("div",{children:n}),e.jsxs("small",{className:"text-slate-400",children:["row ",r,", col ",s]})]})}function h(){const i=l();return e.jsxs(t,{direction:"column",gap:4,children:[e.jsxs("div",{children:["Grids can also display right to left languages (like Arabic). The grid components check the"," ",e.jsxs(s,{href:"https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/dir",children:[e.jsx("code",{children:"dir"})," attribute"]})," ","to determine content directionality."]}),e.jsx("div",{children:"Using the same data as from the previous example, here is a grid rendered right to left."}),e.jsxs(r,{className:"h-50 overflow-auto","data-focus-within":"bold",children:[!i.length&&e.jsx(n,{}),e.jsx(d,{contacts:i})]}),e.jsx(o,{url:"/generated/code-snippets/RtlGrid.json"})]})}export{h as default};
2
- //# sourceMappingURL=RTLGridsRoute-C49T7mLs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RTLGridsRoute-C49T7mLs.js","sources":["../../src/routes/grid/examples/RtlGrid.example.tsx","../../src/routes/grid/RTLGridsRoute.tsx"],"sourcesContent":["import json from \"../../../../public/data/contacts.json\";\nimport { columnWidth } from \"./columnWidth.example\";\n\ntype Contact = (typeof json)[0];\n\n// <begin>\n\nimport { Grid } from \"react-window\";\n\nfunction RtlExample({ contacts }: { contacts: Contact[] }) {\n return (\n <Grid\n cellComponent={CellComponent}\n cellProps={{ contacts }}\n columnCount={10}\n columnWidth={columnWidth}\n dir=\"rtl\"\n rowCount={contacts.length}\n rowHeight={35}\n />\n );\n}\n\n// <end>\n\nimport { type CellComponentProps } from \"react-window\";\nimport { indexToColumn } from \"./shared\";\n\nfunction CellComponent({\n contacts,\n columnIndex,\n rowIndex,\n style\n}: CellComponentProps<{\n contacts: Contact[];\n}>) {\n const address = contacts[rowIndex];\n const content = address[indexToColumn(columnIndex)];\n\n return (\n <div className=\"truncate leading-none\" style={style}>\n <div>{content}</div>\n <small className=\"text-slate-400\">\n row {rowIndex}, col {columnIndex}\n </small>\n </div>\n );\n}\n\nexport { CellComponent, RtlExample };\nexport type { Contact };\n","import { Block } from \"../../components/Block\";\nimport { Box } from \"../../components/Box\";\nimport { FormattedCode } from \"../../components/code/FormattedCode\";\nimport { ExternalLink } from \"../../components/ExternalLink\";\nimport { LoadingSpinner } from \"../../components/LoadingSpinner\";\nimport { RtlExample } from \"./examples/RtlGrid.example\";\nimport { useContacts } from \"./hooks/useContacts\";\n\nexport default function RTLGridsRoute() {\n const contacts = useContacts();\n\n return (\n <Box direction=\"column\" gap={4}>\n <div>\n Grids can also display right to left languages (like Arabic). The grid\n components check the{\" \"}\n <ExternalLink href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/dir\">\n <code>dir</code> attribute\n </ExternalLink>{\" \"}\n to determine content directionality.\n </div>\n <div>\n Using the same data as from the previous example, here is a grid\n rendered right to left.\n </div>\n <Block className=\"h-50 overflow-auto\" data-focus-within=\"bold\">\n {!contacts.length && <LoadingSpinner />}\n <RtlExample contacts={contacts} />\n </Block>\n <FormattedCode url=\"/generated/code-snippets/RtlGrid.json\" />\n </Box>\n );\n}\n"],"names":["RtlExample","contacts","jsx","Grid","cellComponent","CellComponent","cellProps","columnCount","columnWidth","dir","rowCount","length","rowHeight","columnIndex","rowIndex","style","content","indexToColumn","jsxs","className","children","RTLGridsRoute","useContacts","Box","direction","gap","ExternalLink","href","Block","LoadingSpinner","FormattedCode","url"],"mappings":"0SASA,SAASA,GAAWC,SAAEA,IACpB,OACEC,EAAAA,IAACC,EAAA,CACCC,cAAeC,EACfC,UAAW,CAAEL,YACbM,YAAa,GACbC,cACAC,IAAI,MACJC,SAAUT,EAASU,OACnBC,UAAW,IAGjB,CAOA,SAASP,GAAcJ,SACrBA,EAAAY,YACAA,EAAAC,SACAA,EAAAC,MACAA,IAIA,MACMC,EADUf,EAASa,GACDG,EAAcJ,IAEtC,SACEK,KAAC,MAAA,CAAIC,UAAU,wBAAwBJ,QACrCK,SAAA,GAAAlB,IAAC,OAAKkB,SAAAJ,MACNE,KAAC,QAAA,CAAMC,UAAU,iBAAiBC,SAAA,CAAA,OAC3BN,EAAS,SAAOD,OAI7B,CCvCA,SAAwBQ,IACtB,MAAMpB,EAAWqB,IAEjB,OACEJ,EAAAA,KAACK,EAAA,CAAIC,UAAU,SAASC,IAAK,EAC3BL,SAAA,CAAAF,OAAC,MAAA,CAAIE,SAAA,CAAA,8FAEkB,MACrBF,KAACQ,EAAA,CAAaC,KAAK,oFACjBP,SAAA,GAAAlB,IAAC,QAAKkB,SAAA,QAAU,gBACF,IAAI,4CAGtBlB,IAAC,OAAIkB,SAAA,6FAILF,EAAAA,KAACU,EAAA,CAAMT,UAAU,qBAAqB,oBAAkB,OACrDC,SAAA,EAACnB,EAASU,cAAWkB,EAAA,CAAA,GACtB3B,MAACF,GAAWC,kBAEdC,IAAC4B,EAAA,CAAcC,IAAI,4CAGzB"}
@@ -1,2 +0,0 @@
1
- import{j as e,B as s,C as i,E as n}from"./index-B_YQ7rlN.js";import{B as r}from"./arePropsEqual-D3jAKwxp.js";import{F as o}from"./FormattedCode-CAmuOSRw.js";import{C as t}from"./ContinueLink-CbPhCk1k.js";import{H as d}from"./Header-BYp8JKXz.js";import{L as l}from"./LoadingSpinner-Z5HQViRD.js";import{C as a}from"./CellComponent.example-e4JJmmZM.js";import{c,u as h}from"./useContacts-BItVOkyi.js";import{G as p}from"./Grid-DH-j7ODh.js";function m({contacts:s}){return e.jsx(p,{cellComponent:a,cellProps:{contacts:s},columnCount:10,columnWidth:c,rowCount:s.length,rowHeight:25})}function j(){const a=h();return e.jsxs(s,{direction:"column",gap:4,children:[e.jsx(d,{section:"Grids",title:"Rendering a grid"}),e.jsxs("div",{children:["Use the ",e.jsx("code",{children:"Grid"})," component to render data with many rows and columns:"]}),e.jsxs(r,{className:"h-50 overflow-auto","data-focus-within":"bold",children:[!a.length&&e.jsx(l,{}),e.jsx(m,{contacts:a})]}),e.jsx("div",{children:"Grids require you to specify the number of rows and columns as well as the width and height of each:"}),e.jsx(o,{url:"/generated/code-snippets/Grid.json"}),e.jsx("div",{children:"Column widths and row heights can be either numbers or functions. In the example above, row height is fixed and column width is variable."}),e.jsx(o,{url:"/generated/code-snippets/columnWidth.json"}),e.jsxs("div",{children:["Lastly grids require a component to render cell, given a column and row index. As with lists, this component receives additional props specified as part of ",e.jsx("code",{children:"cellProps"}),":"]}),e.jsx(o,{url:"/generated/code-snippets/CellComponent.json"}),e.jsx(i,{intent:"warning",children:e.jsxs(s,{direction:"column",gap:4,children:[e.jsxs("div",{children:["Grids require space to render cells. Typically the"," ",e.jsx(n,{href:"https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver",children:"ResizeObserver"})," ","API is used to determine how much space there is available within the parent DOM element."]}),e.jsxs("div",{children:["If an explicit width and height are specified (in pixels) using the"," ",e.jsx("code",{children:"style"})," prop, ",e.jsx("code",{children:"ResizeObserver"})," will not be used."]})]})}),e.jsx(t,{to:"/grid/props",title:"component props"})]})}export{j as default};
2
- //# sourceMappingURL=RenderingGridRoute-pTuxJ89O.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RenderingGridRoute-pTuxJ89O.js","sources":["../../src/routes/grid/examples/Grid.example.tsx","../../src/routes/grid/RenderingGridRoute.tsx"],"sourcesContent":["import json from \"../../../../public/data/contacts.json\";\nimport { CellComponent } from \"./CellComponent.example\";\nimport { columnWidth } from \"./columnWidth.example\";\n\ntype Contact = (typeof json)[0];\n\n// <begin>\n\nimport { Grid } from \"react-window\";\n\nfunction Example({ contacts }: { contacts: Contact[] }) {\n return (\n <Grid\n cellComponent={CellComponent}\n cellProps={{ contacts }}\n columnCount={10}\n columnWidth={columnWidth}\n rowCount={contacts.length}\n rowHeight={25}\n />\n );\n}\n\n// <end>\n\nexport { CellComponent, Example };\nexport type { Contact };\n","import { Block } from \"../../components/Block\";\nimport { Box } from \"../../components/Box\";\nimport { Callout } from \"../../components/Callout\";\nimport { FormattedCode } from \"../../components/code/FormattedCode\";\nimport { ContinueLink } from \"../../components/ContinueLink\";\nimport { ExternalLink } from \"../../components/ExternalLink\";\nimport { Header } from \"../../components/Header\";\nimport { LoadingSpinner } from \"../../components/LoadingSpinner\";\nimport { Example } from \"./examples/Grid.example\";\nimport { useContacts } from \"./hooks/useContacts\";\n\nexport default function RenderingGridRoute() {\n const contacts = useContacts();\n\n return (\n <Box direction=\"column\" gap={4}>\n <Header section=\"Grids\" title=\"Rendering a grid\" />\n <div>\n Use the <code>Grid</code> component to render data with many rows and\n columns:\n </div>\n <Block className=\"h-50 overflow-auto\" data-focus-within=\"bold\">\n {!contacts.length && <LoadingSpinner />}\n <Example contacts={contacts} />\n </Block>\n <div>\n Grids require you to specify the number of rows and columns as well as\n the width and height of each:\n </div>\n <FormattedCode url=\"/generated/code-snippets/Grid.json\" />\n <div>\n Column widths and row heights can be either numbers or functions. In the\n example above, row height is fixed and column width is variable.\n </div>\n <FormattedCode url=\"/generated/code-snippets/columnWidth.json\" />\n <div>\n Lastly grids require a component to render cell, given a column and row\n index. As with lists, this component receives additional props specified\n as part of <code>cellProps</code>:\n </div>\n <FormattedCode url=\"/generated/code-snippets/CellComponent.json\" />\n <Callout intent=\"warning\">\n <Box direction=\"column\" gap={4}>\n <div>\n Grids require space to render cells. Typically the{\" \"}\n <ExternalLink href=\"https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver\">\n ResizeObserver\n </ExternalLink>{\" \"}\n API is used to determine how much space there is available within\n the parent DOM element.\n </div>\n <div>\n If an explicit width and height are specified (in pixels) using the{\" \"}\n <code>style</code> prop, <code>ResizeObserver</code> will not be\n used.\n </div>\n </Box>\n </Callout>\n <ContinueLink to=\"/grid/props\" title=\"component props\" />\n </Box>\n );\n}\n"],"names":["Example","contacts","jsx","Grid","cellComponent","CellComponent","cellProps","columnCount","columnWidth","rowCount","length","rowHeight","RenderingGridRoute","useContacts","jsxs","Box","direction","gap","children","Header","section","title","Block","className","LoadingSpinner","FormattedCode","url","Callout","intent","ExternalLink","href","ContinueLink","to"],"mappings":"qbAUA,SAASA,GAAQC,SAAEA,IACjB,OACEC,EAAAA,IAACC,EAAA,CACCC,cAAeC,EACfC,UAAW,CAAEL,YACbM,YAAa,GACbC,cACAC,SAAUR,EAASS,OACnBC,UAAW,IAGjB,CCVA,SAAwBC,IACtB,MAAMX,EAAWY,IAEjB,OACEC,EAAAA,KAACC,EAAA,CAAIC,UAAU,SAASC,IAAK,EAC3BC,SAAA,CAAAhB,EAAAA,IAACiB,EAAA,CAAOC,QAAQ,QAAQC,MAAM,4BAC7B,MAAA,CAAIH,SAAA,CAAA,aACKhB,IAAC,QAAKgB,SAAA,SAAW,2DAG3BJ,EAAAA,KAACQ,EAAA,CAAMC,UAAU,qBAAqB,oBAAkB,OACrDL,SAAA,EAACjB,EAASS,cAAWc,EAAA,CAAA,GACtBtB,MAACF,GAAQC,kBAEXC,IAAC,OAAIgB,SAAA,2GAILhB,IAACuB,EAAA,CAAcC,IAAI,yCACnBxB,IAAC,OAAIgB,SAAA,gJAILhB,IAACuB,EAAA,CAAcC,IAAI,qDAClB,MAAA,CAAIR,SAAA,CAAA,iKAGQhB,IAAC,QAAKgB,SAAA,cAAgB,SAEnChB,IAACuB,EAAA,CAAcC,IAAI,gDACnBxB,EAAAA,IAACyB,GAAQC,OAAO,UACdV,gBAACH,EAAA,CAAIC,UAAU,SAASC,IAAK,EAC3BC,SAAA,CAAAJ,OAAC,MAAA,CAAII,SAAA,CAAA,qDACgD,IACnDhB,EAAAA,IAAC2B,EAAA,CAAaC,KAAK,kEAAkEZ,SAAA,mBAErE,IAAI,sGAIrB,MAAA,CAAIA,SAAA,CAAA,sEACiE,MACpEhB,IAAC,QAAKgB,SAAA,UAAY,YAAOhB,IAAC,QAAKgB,SAAA,mBAAqB,6BAK1DhB,EAAAA,IAAC6B,EAAA,CAAaC,GAAG,cAAcX,MAAM,sBAG3C"}