{"version":3,"file":"ListModelContext.mjs","names":[],"sources":["../../../../../../../components-base/src/list/ListModelContext.ts"],"sourcesContent":["import type { ListSettingsDefaults, ListSettingsPort } from \"./settings/types\";\nimport type { PropertyName } from \"./types\";\nimport type { Column, Table } from \"@tanstack/table-core\";\n\n/**\n * What a shared list model may reach for.\n *\n * The narrow replacement for the `List` back-reference the model classes used\n * to carry: a `List` is a React object — its constructor calls hooks — while\n * what sorting and searching actually need is the TanStack table and the\n * persistence. A binding's own list satisfies this shape and keeps passing\n * itself.\n *\n * `dataTable`, not `table`: Flow's `List` already calls its own view model\n * `table`, and the TanStack instance is a different thing — the rows, the\n * sorting state and the global filter. It is a getter on purpose, because the\n * model is built before the table is and reading it eagerly reads `undefined`.\n */\nexport interface ListModelContext<T> {\n  readonly dataTable: Table<T>;\n  readonly settings?: ListSettingsPort;\n  readonly settingsDefaults?: ListSettingsDefaults;\n}\n\n/**\n * The table's column for a property.\n *\n * Throws rather than returning `undefined`: a sorting or a filter names a\n * column the list declared, so a miss is a wiring mistake, and the alternative\n * is a control that silently does nothing.\n */\nexport const getListColumn = <T>(\n  table: Table<T>,\n  property: PropertyName<T>,\n): Column<T> => {\n  const column = table.getColumn(property as string);\n\n  if (!column) {\n    throw new Error(`Column #${String(property)} is not defined`);\n  }\n\n  return column;\n};\n"],"mappings":";;;;;;;;;;AA+BA,IAAa,iBACX,OACA,aACc;CACd,MAAM,SAAS,MAAM,UAAU,QAAkB;CAEjD,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,WAAW,OAAO,QAAQ,EAAE,gBAAgB;CAG9D,OAAO;AACT"}