All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.lib.columnHelper.js.map Maven / Gradle / Ivy

The newest version!
{"version":3,"file":"columnHelper.js","sources":["../../src/columnHelper.ts"],"sourcesContent":["import {\n  AccessorFn,\n  ColumnDef,\n  DisplayColumnDef,\n  GroupColumnDef,\n  IdentifiedColumnDef,\n  RowData,\n} from './types'\nimport { DeepKeys, DeepValue, RequiredKeys } from './utils'\n\n// type Person = {\n//   firstName: string\n//   lastName: string\n//   age: number\n//   visits: number\n//   status: string\n//   progress: number\n//   createdAt: Date\n//   nested: {\n//     foo: [\n//       {\n//         bar: 'bar'\n//       }\n//     ]\n//     bar: { subBar: boolean }[]\n//     baz: {\n//       foo: 'foo'\n//       bar: {\n//         baz: 'baz'\n//       }\n//     }\n//   }\n// }\n\n// const test: DeepKeys = 'nested.foo.0.bar'\n// const test2: DeepKeys = 'nested.bar'\n\n// const helper = createColumnHelper()\n\n// helper.accessor('nested.foo', {\n//   cell: info => info.getValue(),\n// })\n\n// helper.accessor('nested.foo.0.bar', {\n//   cell: info => info.getValue(),\n// })\n\n// helper.accessor('nested.bar', {\n//   cell: info => info.getValue(),\n// })\n\nexport type ColumnHelper = {\n  accessor: <\n    TAccessor extends AccessorFn | DeepKeys,\n    TValue extends TAccessor extends AccessorFn\n      ? TReturn\n      : TAccessor extends DeepKeys\n      ? DeepValue\n      : never\n  >(\n    accessor: TAccessor,\n    column: TAccessor extends AccessorFn\n      ? DisplayColumnDef\n      : IdentifiedColumnDef\n  ) => ColumnDef\n  display: (column: DisplayColumnDef) => ColumnDef\n  group: (column: GroupColumnDef) => ColumnDef\n}\n\nexport function createColumnHelper<\n  TData extends RowData\n>(): ColumnHelper {\n  return {\n    accessor: (accessor, column) => {\n      return typeof accessor === 'function'\n        ? ({\n            ...column,\n            accessorFn: accessor,\n          } as any)\n        : {\n            ...column,\n            accessorKey: accessor,\n          }\n    },\n    display: column => column as ColumnDef,\n    group: column => column as ColumnDef,\n  }\n}\n"],"names":["createColumnHelper","accessor","column","accessorFn","accessorKey","display","group"],"mappings":";;;;;;;;;;;;;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AAoBO,SAASA,kBAAkBA,GAET;EACvB,OAAO;AACLC,IAAAA,QAAQ,EAAEA,CAACA,QAAQ,EAAEC,MAAM,KAAK;AAC9B,MAAA,OAAO,OAAOD,QAAQ,KAAK,UAAU,GAChC;AACC,QAAA,GAAGC,MAAM;AACTC,QAAAA,UAAU,EAAEF,QAAAA;AACd,OAAC,GACD;AACE,QAAA,GAAGC,MAAM;AACTE,QAAAA,WAAW,EAAEH,QAAAA;OACd,CAAA;KACN;IACDI,OAAO,EAAEH,MAAM,IAAIA,MAAmC;IACtDI,KAAK,EAAEJ,MAAM,IAAIA,MAAAA;GAClB,CAAA;AACH;;;;"}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy