MCPcopy
hub / github.com/TanStack/table / createAngularTable

Function createAngularTable

packages/angular-table/src/index.ts:28–79  ·  view source on GitHub ↗
(
  options: () => TableOptions<TData>
)

Source from the content-addressed store, hash-verified

26} from './flex-render/flex-render-component'
27
28export function createAngularTable<TData extends RowData>(
29 options: () => TableOptions<TData>
30): Table<TData> & Signal<Table<TData>> {
31 return lazyInit(() => {
32 const resolvedOptions = {
33 state: {},
34 onStateChange: () => {},
35 renderFallbackValue: null,
36 ...options(),
37 }
38
39 const table = createTable(resolvedOptions)
40
41 // By default, manage table state here using the table's initial state
42 const state = signal<TableState>(table.initialState)
43
44 // Compose table options using computed.
45 // This is to allow `tableSignal` to listen and set table option
46 const updatedOptions = computed<TableOptionsResolved<TData>>(() => {
47 // listen to table state changed
48 const tableState = state()
49 // listen to input options changed
50 const tableOptions = options()
51 return {
52 ...table.options,
53 ...resolvedOptions,
54 ...tableOptions,
55 state: { ...tableState, ...tableOptions.state },
56 onStateChange: updater => {
57 const value =
58 updater instanceof Function ? updater(tableState) : updater
59 state.set(value)
60 resolvedOptions.onStateChange?.(updater)
61 },
62 }
63 })
64
65 // convert table instance to signal for proxify to listen to any table state and options changes
66 const tableSignal = computed(
67 () => {
68 table.setOptions(updatedOptions())
69 return table
70 },
71 {
72 equal: () => false,
73 }
74 )
75
76 // proxify Table instance to provide ability for consumer to listen to any table state changes
77 return proxifyTable(tableSignal)
78 })
79}

Callers 15

TestComponentClass · 0.90
FakeComponentClass · 0.90
AppComponentClass · 0.90
AppComponentClass · 0.90
AppComponentClass · 0.90
AppComponentClass · 0.90
AppComponentClass · 0.90
AppComponentClass · 0.90
AppComponentClass · 0.90
AppComponentClass · 0.90

Calls 3

lazyInitFunction · 0.90
createTableFunction · 0.90
proxifyTableFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…