@tanstack/vue-table 8.7.8 → 8.8.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.
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/merge-proxy.js.map +1 -1
- package/build/umd/index.development.js +16 -15
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/merge-proxy.ts","../../src/index.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nexport const $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...new Set(keys)]\n },\n },\n propTraps\n )\n}\n","import {\n TableOptions,\n createTable,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, defineComponent } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nexport const FlexRender = defineComponent({\n props: ['render', 'props'],\n setup: (props: { render: any; props: any }) => {\n return () => {\n if (\n typeof props.render === 'function' ||\n typeof props.render === 'object'\n ) {\n return h(props.render, props.props)\n }\n\n return props.render\n }\n },\n})\n\nexport function useVueTable<TData extends RowData>(\n options: TableOptions<TData>\n) {\n const resolvedOptions: TableOptionsResolved<TData> = mergeProxy(\n {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n mergeOptions(\n defaultOptions: TableOptions<TData>,\n options: TableOptions<TData>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const table = createTable<TData>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(table.initialState)\n\n watchEffect(() => {\n table.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)\n },\n })\n })\n })\n\n return table\n}\n"],"names":["trueFn","$PROXY","Symbol","propTraps","get","_","property","receiver","has","set","deleteProperty","getOwnPropertyDescriptor","configurable","enumerable","ownKeys","keys","resolveSource","s","value","mergeProxy","sources","
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/merge-proxy.ts","../../src/index.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nexport const $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...new Set(keys)]\n },\n },\n propTraps\n )\n}\n","import {\n TableOptions,\n createTable,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, defineComponent } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nexport const FlexRender = defineComponent({\n props: ['render', 'props'],\n setup: (props: { render: any; props: any }) => {\n return () => {\n if (\n typeof props.render === 'function' ||\n typeof props.render === 'object'\n ) {\n return h(props.render, props.props)\n }\n\n return props.render\n }\n },\n})\n\nexport function useVueTable<TData extends RowData>(\n options: TableOptions<TData>\n) {\n const resolvedOptions: TableOptionsResolved<TData> = mergeProxy(\n {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n mergeOptions(\n defaultOptions: TableOptions<TData>,\n options: TableOptions<TData>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const table = createTable<TData>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(table.initialState)\n\n watchEffect(() => {\n table.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)\n },\n })\n })\n })\n\n return table\n}\n"],"names":["trueFn","$PROXY","Symbol","propTraps","get","_","property","receiver","has","set","deleteProperty","getOwnPropertyDescriptor","configurable","enumerable","ownKeys","keys","resolveSource","s","value","mergeProxy","_len","arguments","length","sources","Array","_key","Proxy","i","v","undefined","push","Object","Set","FlexRender","defineComponent","props","setup","render","h","useVueTable","options","resolvedOptions","state","onStateChange","renderFallbackValue","mergeOptions","defaultOptions","table","createTable","ref","initialState","watchEffect","setOptions","prev","_options$state","stateProxy","prop","updater","Function"],"mappings":";;;;;;;;;;;;;;AAAA,SAASA,MAAMA,GAAG;AAChB,EAAA,OAAO,IAAI,CAAA;AACb,CAAA;AAEO,MAAMC,MAAM,GAAGC,MAAM,CAAC,aAAa,CAAC,CAAA;;AAE3C;AACA,MAAMC,SAIJ,GAAG;AACHC,EAAAA,GAAGA,CAACC,CAAC,EAAEC,QAAQ,EAAEC,QAAQ,EAAE;AACzB,IAAA,IAAID,QAAQ,KAAKL,MAAM,EAAE,OAAOM,QAAQ,CAAA;AACxC,IAAA,OAAOF,CAAC,CAACD,GAAG,CAACE,QAAQ,CAAC,CAAA;GACvB;AACDE,EAAAA,GAAGA,CAACH,CAAC,EAAEC,QAAQ,EAAE;AACf,IAAA,OAAOD,CAAC,CAACG,GAAG,CAACF,QAAQ,CAAC,CAAA;GACvB;AACDG,EAAAA,GAAG,EAAET,MAAM;AACXU,EAAAA,cAAc,EAAEV,MAAM;AACtBW,EAAAA,wBAAwBA,CAACN,CAAC,EAAEC,QAAQ,EAAE;IACpC,OAAO;AACLM,MAAAA,YAAY,EAAE,IAAI;AAClBC,MAAAA,UAAU,EAAE,IAAI;AAChBT,MAAAA,GAAGA,GAAG;AACJ,QAAA,OAAOC,CAAC,CAACD,GAAG,CAACE,QAAQ,CAAC,CAAA;OACvB;AACDG,MAAAA,GAAG,EAAET,MAAM;AACXU,MAAAA,cAAc,EAAEV,MAAAA;KACjB,CAAA;GACF;EACDc,OAAOA,CAACT,CAAC,EAAE;IACT,OAAOA,CAAC,CAACU,IAAI,EAAE,CAAA;AACjB,GAAA;AACF,CAAC,CAAA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MAAM;AAChBJ,IAAAA,KAAK,CAACK,UAAU,CAACC,IAAI,IAAI;AAAA,MAAA,IAAAC,cAAA,CAAA;AACvB,MAAA,MAAMC,UAAU,GAAG,IAAI7B,KAAK,CAAC,EAAE,EAAwB;QACrDtB,GAAG,EAAEA,CAACC,CAAC,EAAEmD,IAAI,KAAKd,KAAK,CAACxB,KAAK,CAACsC,IAAI,CAAA;AACpC,OAAC,CAAC,CAAA;AAEF,MAAA,OAAOrC,UAAU,CAACkC,IAAI,EAAEb,OAAO,EAAE;AAC/B;AACA;AACA;AACAE,QAAAA,KAAK,EAAEvB,UAAU,CAACoC,UAAU,GAAAD,cAAA,GAAEd,OAAO,CAACE,KAAK,KAAAY,IAAAA,GAAAA,cAAA,GAAI,EAAE,CAAC;AAClD;AACA;QACAX,aAAa,EAAGc,OAAY,IAAK;UAC/B,IAAIA,OAAO,YAAYC,QAAQ,EAAE;YAC/BhB,KAAK,CAACxB,KAAK,GAAGuC,OAAO,CAACf,KAAK,CAACxB,KAAK,CAAC,CAAA;AACpC,WAAC,MAAM;YACLwB,KAAK,CAACxB,KAAK,GAAGuC,OAAO,CAAA;AACvB,WAAA;UAEAjB,OAAO,CAACG,aAAa,IAArBH,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACG,aAAa,CAAGc,OAAO,CAAC,CAAA;AAClC,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOV,KAAK,CAAA;AACd;;;;"}
|
package/build/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n TableOptions,\n createTable,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, defineComponent } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nexport const FlexRender = defineComponent({\n props: ['render', 'props'],\n setup: (props: { render: any; props: any }) => {\n return () => {\n if (\n typeof props.render === 'function' ||\n typeof props.render === 'object'\n ) {\n return h(props.render, props.props)\n }\n\n return props.render\n }\n },\n})\n\nexport function useVueTable<TData extends RowData>(\n options: TableOptions<TData>\n) {\n const resolvedOptions: TableOptionsResolved<TData> = mergeProxy(\n {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n mergeOptions(\n defaultOptions: TableOptions<TData>,\n options: TableOptions<TData>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const table = createTable<TData>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(table.initialState)\n\n watchEffect(() => {\n table.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)\n },\n })\n })\n })\n\n return table\n}\n"],"names":["FlexRender","defineComponent","props","setup","render","h","useVueTable","options","resolvedOptions","mergeProxy","state","onStateChange","renderFallbackValue","mergeOptions","defaultOptions","table","createTable","ref","initialState","watchEffect","setOptions","prev","stateProxy","Proxy","get","_","prop","value","updater","Function"],"mappings":";;;;;;;;;;;;;;;;;;AAWaA,MAAAA,UAAU,GAAGC,mBAAe,CAAC;AACxCC,EAAAA,KAAK,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC1BC,KAAK,EAAGD,KAAkC,IAAK;AAC7C,IAAA,OAAO,MAAM;AACX,MAAA,IACE,OAAOA,KAAK,CAACE,MAAM,KAAK,UAAU,IAClC,OAAOF,KAAK,CAACE,MAAM,KAAK,QAAQ,EAChC;QACA,OAAOC,KAAC,CAACH,KAAK,CAACE,MAAM,EAAEF,KAAK,CAACA,KAAK,CAAC,CAAA;AACrC,OAAA;MAEA,OAAOA,KAAK,CAACE,MAAM,CAAA;KACpB,CAAA;AACH,GAAA;AACF,CAAC,EAAC;AAEK,SAASE,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n TableOptions,\n createTable,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, defineComponent } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nexport const FlexRender = defineComponent({\n props: ['render', 'props'],\n setup: (props: { render: any; props: any }) => {\n return () => {\n if (\n typeof props.render === 'function' ||\n typeof props.render === 'object'\n ) {\n return h(props.render, props.props)\n }\n\n return props.render\n }\n },\n})\n\nexport function useVueTable<TData extends RowData>(\n options: TableOptions<TData>\n) {\n const resolvedOptions: TableOptionsResolved<TData> = mergeProxy(\n {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n mergeOptions(\n defaultOptions: TableOptions<TData>,\n options: TableOptions<TData>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const table = createTable<TData>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(table.initialState)\n\n watchEffect(() => {\n table.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)\n },\n })\n })\n })\n\n return table\n}\n"],"names":["FlexRender","defineComponent","props","setup","render","h","useVueTable","options","resolvedOptions","mergeProxy","state","onStateChange","renderFallbackValue","mergeOptions","defaultOptions","table","createTable","ref","initialState","watchEffect","setOptions","prev","_options$state","stateProxy","Proxy","get","_","prop","value","updater","Function"],"mappings":";;;;;;;;;;;;;;;;;;AAWaA,MAAAA,UAAU,GAAGC,mBAAe,CAAC;AACxCC,EAAAA,KAAK,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC1BC,KAAK,EAAGD,KAAkC,IAAK;AAC7C,IAAA,OAAO,MAAM;AACX,MAAA,IACE,OAAOA,KAAK,CAACE,MAAM,KAAK,UAAU,IAClC,OAAOF,KAAK,CAACE,MAAM,KAAK,QAAQ,EAChC;QACA,OAAOC,KAAC,CAACH,KAAK,CAACE,MAAM,EAAEF,KAAK,CAACA,KAAK,CAAC,CAAA;AACrC,OAAA;MAEA,OAAOA,KAAK,CAACE,MAAM,CAAA;KACpB,CAAA;AACH,GAAA;AACF,CAAC,EAAC;AAEK,SAASE,WAAWA,CACzBC,OAA4B,EAC5B;EACA,MAAMC,eAA4C,GAAGC,qBAAU,CAC7D;IACEC,KAAK,EAAE,EAAE;AAAE;AACXC,IAAAA,aAAa,EAAEA,MAAM,EAAE;AAAE;AACzBC,IAAAA,mBAAmB,EAAE,IAAI;AACzBC,IAAAA,YAAYA,CACVC,cAAmC,EACnCP,OAA4B,EAC5B;AACA,MAAA,OAAOE,qBAAU,CAACK,cAAc,EAAEP,OAAO,CAAC,CAAA;AAC5C,KAAA;GACD,EACDA,OAAO,CACR,CAAA;AAED,EAAA,MAAMQ,KAAK,GAAGC,qBAAW,CAAQR,eAAe,CAAC,CAAA;AACjD;AACA,EAAA,MAAME,KAAK,GAAGO,OAAG,CAACF,KAAK,CAACG,YAAY,CAAC,CAAA;AAErCC,EAAAA,eAAW,CAAC,MAAM;AAChBJ,IAAAA,KAAK,CAACK,UAAU,CAACC,IAAI,IAAI;AAAA,MAAA,IAAAC,cAAA,CAAA;AACvB,MAAA,MAAMC,UAAU,GAAG,IAAIC,KAAK,CAAC,EAAE,EAAwB;QACrDC,GAAG,EAAEA,CAACC,CAAC,EAAEC,IAAI,KAAKjB,KAAK,CAACkB,KAAK,CAACD,IAAI,CAAA;AACpC,OAAC,CAAC,CAAA;AAEF,MAAA,OAAOlB,qBAAU,CAACY,IAAI,EAAEd,OAAO,EAAE;AAC/B;AACA;AACA;AACAG,QAAAA,KAAK,EAAED,qBAAU,CAACc,UAAU,GAAAD,cAAA,GAAEf,OAAO,CAACG,KAAK,KAAAY,IAAAA,GAAAA,cAAA,GAAI,EAAE,CAAC;AAClD;AACA;QACAX,aAAa,EAAGkB,OAAY,IAAK;UAC/B,IAAIA,OAAO,YAAYC,QAAQ,EAAE;YAC/BpB,KAAK,CAACkB,KAAK,GAAGC,OAAO,CAACnB,KAAK,CAACkB,KAAK,CAAC,CAAA;AACpC,WAAC,MAAM;YACLlB,KAAK,CAACkB,KAAK,GAAGC,OAAO,CAAA;AACvB,WAAA;UAEAtB,OAAO,CAACI,aAAa,IAArBJ,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACI,aAAa,CAAGkB,OAAO,CAAC,CAAA;AAClC,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOd,KAAK,CAAA;AACd;;;;;;;;;;;"}
|
package/build/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/merge-proxy.ts","../../src/index.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nexport const $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...new Set(keys)]\n },\n },\n propTraps\n )\n}\n","import {\n TableOptions,\n createTable,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, defineComponent } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nexport const FlexRender = defineComponent({\n props: ['render', 'props'],\n setup: (props: { render: any; props: any }) => {\n return () => {\n if (\n typeof props.render === 'function' ||\n typeof props.render === 'object'\n ) {\n return h(props.render, props.props)\n }\n\n return props.render\n }\n },\n})\n\nexport function useVueTable<TData extends RowData>(\n options: TableOptions<TData>\n) {\n const resolvedOptions: TableOptionsResolved<TData> = mergeProxy(\n {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n mergeOptions(\n defaultOptions: TableOptions<TData>,\n options: TableOptions<TData>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const table = createTable<TData>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(table.initialState)\n\n watchEffect(() => {\n table.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)\n },\n })\n })\n })\n\n return table\n}\n"],"names":["trueFn","$PROXY","Symbol","propTraps","get","_","property","receiver","has","set","deleteProperty","getOwnPropertyDescriptor","configurable","enumerable","ownKeys","keys","resolveSource","s","value","mergeProxy","sources","
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/merge-proxy.ts","../../src/index.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nexport const $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...new Set(keys)]\n },\n },\n propTraps\n )\n}\n","import {\n TableOptions,\n createTable,\n TableOptionsResolved,\n RowData,\n} from '@tanstack/table-core'\nimport { h, watchEffect, ref, defineComponent } from 'vue'\nimport { mergeProxy } from './merge-proxy'\n\nexport * from '@tanstack/table-core'\n\nexport const FlexRender = defineComponent({\n props: ['render', 'props'],\n setup: (props: { render: any; props: any }) => {\n return () => {\n if (\n typeof props.render === 'function' ||\n typeof props.render === 'object'\n ) {\n return h(props.render, props.props)\n }\n\n return props.render\n }\n },\n})\n\nexport function useVueTable<TData extends RowData>(\n options: TableOptions<TData>\n) {\n const resolvedOptions: TableOptionsResolved<TData> = mergeProxy(\n {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n mergeOptions(\n defaultOptions: TableOptions<TData>,\n options: TableOptions<TData>\n ) {\n return mergeProxy(defaultOptions, options)\n },\n },\n options\n )\n\n const table = createTable<TData>(resolvedOptions)\n // can't use `reactive` because update needs to be immutable\n const state = ref(table.initialState)\n\n watchEffect(() => {\n table.setOptions(prev => {\n const stateProxy = new Proxy({} as typeof state.value, {\n get: (_, prop) => state.value[prop as keyof typeof state.value],\n })\n\n return mergeProxy(prev, options, {\n // merge the initialState and `options.state`\n // create a new proxy on each `setOptions` call\n // and get the value from state on each property access\n state: mergeProxy(stateProxy, options.state ?? {}),\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: (updater: any) => {\n if (updater instanceof Function) {\n state.value = updater(state.value)\n } else {\n state.value = updater\n }\n\n options.onStateChange?.(updater)\n },\n })\n })\n })\n\n return table\n}\n"],"names":["trueFn","$PROXY","Symbol","propTraps","get","_","property","receiver","has","set","deleteProperty","getOwnPropertyDescriptor","configurable","enumerable","ownKeys","keys","resolveSource","s","value","mergeProxy","_len","arguments","length","sources","Array","_key","Proxy","i","v","undefined","push","Object","Set","FlexRender","defineComponent","props","setup","render","h","useVueTable","options","resolvedOptions","state","onStateChange","renderFallbackValue","mergeOptions","defaultOptions","table","createTable","ref","initialState","watchEffect","setOptions","prev","_options$state","stateProxy","prop","updater","Function"],"mappings":";;;;;;;;;;;;;;AAAA,SAASA,MAAMA,GAAG;AAChB,EAAA,OAAO,IAAI,CAAA;AACb,CAAA;AAEO,MAAMC,MAAM,GAAGC,MAAM,CAAC,aAAa,CAAC,CAAA;;AAE3C;AACA,MAAMC,SAIJ,GAAG;AACHC,EAAAA,GAAGA,CAACC,CAAC,EAAEC,QAAQ,EAAEC,QAAQ,EAAE;AACzB,IAAA,IAAID,QAAQ,KAAKL,MAAM,EAAE,OAAOM,QAAQ,CAAA;AACxC,IAAA,OAAOF,CAAC,CAACD,GAAG,CAACE,QAAQ,CAAC,CAAA;GACvB;AACDE,EAAAA,GAAGA,CAACH,CAAC,EAAEC,QAAQ,E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K,GAAGuC,OAAO,CAAA;AACvB,WAAA;UAEAjB,OAAO,CAACG,aAAa,IAArBH,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACG,aAAa,CAAGc,OAAO,CAAC,CAAA;AAClC,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOV,KAAK,CAAA;AACd;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-proxy.js","sources":["../../src/merge-proxy.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nexport const $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...new Set(keys)]\n },\n },\n propTraps\n )\n}\n"],"names":["trueFn","$PROXY","Symbol","propTraps","get","_","property","receiver","has","set","deleteProperty","getOwnPropertyDescriptor","configurable","enumerable","ownKeys","keys","resolveSource","s","value","mergeProxy","sources","
|
|
1
|
+
{"version":3,"file":"merge-proxy.js","sources":["../../src/merge-proxy.ts"],"sourcesContent":["function trueFn() {\n return true\n}\n\nexport const $PROXY = Symbol('merge-proxy')\n\n// https://github.com/solidjs/solid/blob/c20ca4fd8c36bc0522fedb2c7f38a110b7ee2663/packages/solid/src/render/component.ts#L51-L118\nconst propTraps: ProxyHandler<{\n get: (k: string | number | symbol) => any\n has: (k: string | number | symbol) => boolean\n keys: () => string[]\n}> = {\n get(_, property, receiver) {\n if (property === $PROXY) return receiver\n return _.get(property)\n },\n has(_, property) {\n return _.has(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n getOwnPropertyDescriptor(_, property) {\n return {\n configurable: true,\n enumerable: true,\n get() {\n return _.get(property)\n },\n set: trueFn,\n deleteProperty: trueFn,\n }\n },\n ownKeys(_) {\n return _.keys()\n },\n}\n\ntype UnboxLazy<T> = T extends () => infer U ? U : T\ntype BoxedTupleTypes<T extends any[]> = {\n [P in keyof T]: [UnboxLazy<T[P]>]\n}[Exclude<keyof T, keyof any[]>]\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I\n) => void\n ? I\n : never\ntype UnboxIntersection<T> = T extends { 0: infer U } ? U : never\ntype MergeProxy<T extends any[]> = UnboxIntersection<\n UnionToIntersection<BoxedTupleTypes<T>>\n>\n\nfunction resolveSource(s: any) {\n return 'value' in s ? s.value : s\n}\n\nexport function mergeProxy<T extends any[]>(...sources: T): MergeProxy<T>\nexport function mergeProxy(...sources: any): any {\n return new Proxy(\n {\n get(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n const v = resolveSource(sources[i])[property]\n if (v !== undefined) return v\n }\n },\n has(property: string | number | symbol) {\n for (let i = sources.length - 1; i >= 0; i--) {\n if (property in resolveSource(sources[i])) return true\n }\n return false\n },\n keys() {\n const keys = []\n for (let i = 0; i < sources.length; i++)\n keys.push(...Object.keys(resolveSource(sources[i])))\n return [...new Set(keys)]\n },\n },\n propTraps\n )\n}\n"],"names":["trueFn","$PROXY","Symbol","propTraps","get","_","property","receiver","has","set","deleteProperty","getOwnPropertyDescriptor","configurable","enumerable","ownKeys","keys","resolveSource","s","value","mergeProxy","_len","arguments","length","sources","Array","_key","Proxy","i","v","undefined","push","Object","Set"],"mappings":";;;;;;;;;;;;;;AAAA,SAASA,MAAMA,GAAG;AAChB,EAAA,OAAO,IAAI,CAAA;AACb,CAAA;MAEaC,MAAM,GAAGC,MAAM,CAAC,aAAa,EAAC;;AAE3C;AACA,MAAMC,SAIJ,GAAG;AACHC,EAAAA,GAAGA,CAACC,CAAC,EAAEC,QAAQ,EAAEC,QAAQ,EAAE;AACzB,IAAA,IAAID,QAAQ,KAAKL,MAAM,EAAE,OAAOM,QAAQ,CAAA;AACxC,IAAA,OAAOF,CAAC,CAACD,GAAG,CAACE,QAAQ,CAAC,CAAA;GACvB;AACDE,EAAAA,GAAGA,CAACH,CAAC,EAAEC,QAAQ,EAAE;AACf,IAAA,OAAOD,CAAC,CAACG,GAAG,CAACF,QAAQ,CAAC,CAAA;GACvB;AACDG,EAAAA,GAAG,EAAET,MAAM;AACXU,EAAAA,cAAc,EAAEV,MAAM;AACtBW,EAAAA,wBAAwBA,CAACN,CAAC,EAAEC,QAAQ,EAAE;IACpC,OAAO;AACLM,MAAAA,Y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EAAEK,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;QAC5C,IAAIrB,QAAQ,IAAIU,aAAa,CAACO,OAAO,CAACI,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,CAAA;AACxD,OAAA;AACA,MAAA,OAAO,KAAK,CAAA;KACb;AACDZ,IAAAA,IAAIA,GAAG;MACL,MAAMA,IAAI,GAAG,EAAE,CAAA;AACf,MAAA,KAAK,IAAIY,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,OAAO,CAACD,MAAM,EAAEK,CAAC,EAAE,EACrCZ,IAAI,CAACe,IAAI,CAAC,GAAGC,MAAM,CAAChB,IAAI,CAACC,aAAa,CAACO,OAAO,CAACI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACtD,MAAA,OAAO,CAAC,GAAG,IAAIK,GAAG,CAACjB,IAAI,CAAC,CAAC,CAAA;AAC3B,KAAA;GACD,EACDZ,SAAS,CACV,CAAA;AACH;;;;;"}
|
|
@@ -2015,7 +2015,7 @@
|
|
|
2015
2015
|
rowSelection
|
|
2016
2016
|
} = table.getState();
|
|
2017
2017
|
let isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
2018
|
-
if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
|
|
2018
|
+
if (isAllPageRowsSelected && paginationFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
|
|
2019
2019
|
isAllPageRowsSelected = false;
|
|
2020
2020
|
}
|
|
2021
2021
|
return isAllPageRowsSelected;
|
|
@@ -2833,12 +2833,13 @@
|
|
|
2833
2833
|
return cell;
|
|
2834
2834
|
}
|
|
2835
2835
|
|
|
2836
|
-
const createRow = (table, id, original, rowIndex, depth, subRows) => {
|
|
2836
|
+
const createRow = (table, id, original, rowIndex, depth, subRows, parentRow) => {
|
|
2837
2837
|
let row = {
|
|
2838
2838
|
id,
|
|
2839
2839
|
index: rowIndex,
|
|
2840
2840
|
original,
|
|
2841
2841
|
depth,
|
|
2842
|
+
parentRow,
|
|
2842
2843
|
_valuesCache: {},
|
|
2843
2844
|
_uniqueValuesCache: {},
|
|
2844
2845
|
getValue: columnId => {
|
|
@@ -2968,7 +2969,7 @@
|
|
|
2968
2969
|
flatRows: [],
|
|
2969
2970
|
rowsById: {}
|
|
2970
2971
|
};
|
|
2971
|
-
const accessRows = function (originalRows, depth,
|
|
2972
|
+
const accessRows = function (originalRows, depth, parentRow) {
|
|
2972
2973
|
if (depth === void 0) {
|
|
2973
2974
|
depth = 0;
|
|
2974
2975
|
}
|
|
@@ -2982,7 +2983,7 @@
|
|
|
2982
2983
|
// }
|
|
2983
2984
|
|
|
2984
2985
|
// Make the row
|
|
2985
|
-
const row = createRow(table, table._getRowId(originalRows[i], i,
|
|
2986
|
+
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow);
|
|
2986
2987
|
|
|
2987
2988
|
// Keep track of every row in a flat array
|
|
2988
2989
|
rowModel.flatRows.push(row);
|
|
@@ -3029,7 +3030,7 @@
|
|
|
3029
3030
|
const newFilteredFlatRows = [];
|
|
3030
3031
|
const newFilteredRowsById = {};
|
|
3031
3032
|
const maxDepth = (_table$options$maxLea = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea : 100;
|
|
3032
|
-
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3033
|
+
const recurseFilterRows = function (rowsToFilter, depth, parentRow) {
|
|
3033
3034
|
if (depth === void 0) {
|
|
3034
3035
|
depth = 0;
|
|
3035
3036
|
}
|
|
@@ -3039,10 +3040,10 @@
|
|
|
3039
3040
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3040
3041
|
var _row$subRows;
|
|
3041
3042
|
let row = rowsToFilter[i];
|
|
3042
|
-
const newRow = createRow(table, row.id, row.original, row.index, row.depth);
|
|
3043
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined, parentRow);
|
|
3043
3044
|
newRow.columnFilters = row.columnFilters;
|
|
3044
3045
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length && depth < maxDepth) {
|
|
3045
|
-
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3046
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1, newRow);
|
|
3046
3047
|
row = newRow;
|
|
3047
3048
|
if (filterRow(row) && !newRow.subRows.length) {
|
|
3048
3049
|
rows.push(row);
|
|
@@ -3080,7 +3081,7 @@
|
|
|
3080
3081
|
const maxDepth = (_table$options$maxLea2 = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea2 : 100;
|
|
3081
3082
|
|
|
3082
3083
|
// Filters top level and nested rows
|
|
3083
|
-
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3084
|
+
const recurseFilterRows = function (rowsToFilter, depth, parentRow) {
|
|
3084
3085
|
if (depth === void 0) {
|
|
3085
3086
|
depth = 0;
|
|
3086
3087
|
}
|
|
@@ -3095,8 +3096,8 @@
|
|
|
3095
3096
|
if (pass) {
|
|
3096
3097
|
var _row$subRows2;
|
|
3097
3098
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length && depth < maxDepth) {
|
|
3098
|
-
const newRow = createRow(table, row.id, row.original, row.index, row.depth);
|
|
3099
|
-
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3099
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined, parentRow);
|
|
3100
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1, newRow);
|
|
3100
3101
|
row = newRow;
|
|
3101
3102
|
}
|
|
3102
3103
|
rows.push(row);
|
|
@@ -3407,7 +3408,7 @@
|
|
|
3407
3408
|
// const nonGroupedRowsById: Record<RowId, Row> = {};
|
|
3408
3409
|
|
|
3409
3410
|
// Recursively group the data
|
|
3410
|
-
const groupUpRecursively = function (rows, depth, parentId) {
|
|
3411
|
+
const groupUpRecursively = function (rows, depth, parentRow, parentId) {
|
|
3411
3412
|
if (depth === void 0) {
|
|
3412
3413
|
depth = 0;
|
|
3413
3414
|
}
|
|
@@ -3419,7 +3420,7 @@
|
|
|
3419
3420
|
groupedFlatRows.push(row);
|
|
3420
3421
|
groupedRowsById[row.id] = row;
|
|
3421
3422
|
if (row.subRows) {
|
|
3422
|
-
row.subRows = groupUpRecursively(row.subRows, depth + 1);
|
|
3423
|
+
row.subRows = groupUpRecursively(row.subRows, depth + 1, row);
|
|
3423
3424
|
}
|
|
3424
3425
|
return row;
|
|
3425
3426
|
});
|
|
@@ -3436,11 +3437,11 @@
|
|
|
3436
3437
|
id = parentId ? `${parentId}>${id}` : id;
|
|
3437
3438
|
|
|
3438
3439
|
// First, Recurse to group sub rows before aggregation
|
|
3439
|
-
const subRows = groupUpRecursively(groupedRows, depth + 1, id);
|
|
3440
|
+
const subRows = groupUpRecursively(groupedRows, depth + 1, parentRow, id);
|
|
3440
3441
|
|
|
3441
3442
|
// Flatten the leaf rows of the rows in this group
|
|
3442
3443
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3443
|
-
const row = createRow(table, id, leafRows[0].original, index, depth);
|
|
3444
|
+
const row = createRow(table, id, leafRows[0].original, index, depth, undefined, parentRow);
|
|
3444
3445
|
Object.assign(row, {
|
|
3445
3446
|
groupingColumnId: columnId,
|
|
3446
3447
|
groupingValue,
|
|
@@ -3487,7 +3488,7 @@
|
|
|
3487
3488
|
});
|
|
3488
3489
|
return aggregatedGroupedRows;
|
|
3489
3490
|
};
|
|
3490
|
-
const groupedRows = groupUpRecursively(rowModel.rows, 0, '');
|
|
3491
|
+
const groupedRows = groupUpRecursively(rowModel.rows, 0, undefined, '');
|
|
3491
3492
|
groupedRows.forEach(subRow => {
|
|
3492
3493
|
groupedFlatRows.push(subRow);
|
|
3493
3494
|
groupedRowsById[subRow.id] = subRow;
|