{"version":3,"file":"index.mjs","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nexport * from '@tanstack/table-core'\n\nimport {\n TableOptions,\n TableOptionsResolved,\n RowData,\n createTable,\n} from '@tanstack/table-core'\n\nexport type Renderable = React.ReactNode | React.ComponentType\n\n//\n\n/**\n * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.\n */\nexport function flexRender(\n Comp: Renderable,\n props: TProps\n): React.ReactNode | JSX.Element {\n return !Comp ? null : isReactComponent(Comp) ? (\n \n ) : (\n Comp\n )\n}\n\nfunction isReactComponent(\n component: unknown\n): component is React.ComponentType {\n return (\n isClassComponent(component) ||\n typeof component === 'function' ||\n isExoticComponent(component)\n )\n}\n\nfunction isClassComponent(component: any) {\n return (\n typeof component === 'function' &&\n (() => {\n const proto = Object.getPrototypeOf(component)\n return proto.prototype && proto.prototype.isReactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)\n )\n}\n\nexport function useReactTable(\n options: TableOptions\n) {\n // Compose in the generic options to the user options\n const resolvedOptions: TableOptionsResolved = {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n ...options,\n }\n\n // Create a new table and store it in state\n const [tableRef] = React.useState(() => ({\n current: createTable(resolvedOptions),\n }))\n\n // By default, manage table state here using the table's initial state\n const [state, setState] = React.useState(() => tableRef.current.initialState)\n\n // Compose the default state above with any user state. This will allow the user\n // to only control a subset of the state if desired.\n tableRef.current.setOptions(prev => ({\n ...prev,\n ...options,\n state: {\n ...state,\n ...options.state,\n },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n setState(updater)\n options.onStateChange?.(updater)\n },\n }))\n\n return tableRef.current\n}\n"],"names":["flexRender","Comp","props","isReactComponent","React","createElement","component","isClassComponent","isExoticComponent","proto","Object","getPrototypeOf","prototype","$$typeof","includes","description","useReactTable","options","resolvedOptions","state","onStateChange","renderFallbackValue","tableRef","useState","current","createTable","setState","initialState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;AAYA;AAEA;AACA;AACA;AACO,SAASA,UAAUA,CACxBC,IAAwB,EACxBC,KAAa,EACkB;AAC/B,EAAA,OAAO,CAACD,IAAI,GAAG,IAAI,GAAGE,gBAAgB,CAASF,IAAI,CAAC,gBAClDG,KAAA,CAAAC,aAAA,CAACJ,IAAI,EAAKC,KAAQ,CAAC,GAEnBD,IACD,CAAA;AACH,CAAA;AAEA,SAASE,gBAAgBA,CACvBG,SAAkB,EACwB;AAC1C,EAAA,OACEC,gBAAgB,CAACD,SAAS,CAAC,IAC3B,OAAOA,SAAS,KAAK,UAAU,IAC/BE,iBAAiB,CAACF,SAAS,CAAC,CAAA;AAEhC,CAAA;AAEA,SAASC,gBAAgBA,CAACD,SAAc,EAAE;AACxC,EAAA,OACE,OAAOA,SAAS,KAAK,UAAU,IAC/B,CAAC,MAAM;AACL,IAAA,MAAMG,KAAK,GAAGC,MAAM,CAACC,cAAc,CAACL,SAAS,CAAC,CAAA;IAC9C,OAAOG,KAAK,CAACG,SAAS,IAAIH,KAAK,CAACG,SAAS,CAACT,gBAAgB,CAAA;AAC5D,GAAC,GAAG,CAAA;AAER,CAAA;AAEA,SAASK,iBAAiBA,CAACF,SAAc,EAAE;EACzC,OACE,OAAOA,SAAS,KAAK,QAAQ,IAC7B,OAAOA,SAAS,CAACO,QAAQ,KAAK,QAAQ,IACtC,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAACC,QAAQ,CAACR,SAAS,CAACO,QAAQ,CAACE,WAAW,CAAC,CAAA;AAEhF,CAAA;AAEO,SAASC,aAAaA,CAC3BC,OAA4B,EAC5B;AACA;AACA,EAAA,MAAMC,eAA4C,GAAG;IACnDC,KAAK,EAAE,EAAE;AAAE;AACXC,IAAAA,aAAa,EAAEA,MAAM,EAAE;AAAE;A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