n8n-editor-ui 1.105.3 → 1.106.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.
Files changed (115) hide show
  1. package/dist/assets/{AnimatedSpinner-DN2jXYlg.js → AnimatedSpinner-BT-tHTIr.js} +1 -1
  2. package/dist/assets/{AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-CI8fSX5_.js → AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-BeYYXOqm.js} +1 -1
  3. package/dist/assets/{AuthView-CDj6SylT.js → AuthView-qxCpg9Vt.js} +2 -2
  4. package/dist/assets/{ChangePasswordView-B5GRVadN.js → ChangePasswordView-YpoX0OgW.js} +3 -3
  5. package/dist/assets/CollectionParameter-B7ioj7nV.js +4 -0
  6. package/dist/assets/{ConsumedTokensDetails.vue_vue_type_script_setup_true_lang-BqZCYQqJ.js → ConsumedTokensDetails.vue_vue_type_script_setup_true_lang-CYlb_OaL.js} +1 -1
  7. package/dist/assets/{CredentialsView-LniKS1gL.js → CredentialsView-XfBa-FgD.js} +8 -8
  8. package/dist/assets/DataStoreView-D5shCvXR.js +344 -0
  9. package/dist/assets/DataStoreView-bZrewhaR.css +159 -0
  10. package/dist/assets/{DemoFooter-BlcOl9Ia.js → DemoFooter-GL7a3c8m.js} +6 -6
  11. package/dist/assets/{EmptySharedSectionActionBox.vue_vue_type_script_setup_true_lang-CkI0vaWb.js → EmptySharedSectionActionBox.vue_vue_type_script_setup_true_lang-B5QhpE-B.js} +1 -1
  12. package/dist/assets/{EntityNotFound-D-i0iOEh.js → EntityNotFound-BSClXGSU.js} +1 -1
  13. package/dist/assets/{EntityUnAuthorised-CtvzhcxM.js → EntityUnAuthorised-rdODRu8_.js} +1 -1
  14. package/dist/assets/{ErrorView-DqayUzyN.js → ErrorView-DDtX9a9K.js} +1 -1
  15. package/dist/assets/{EvaluationsRootView-u-tzY3TN.js → EvaluationsRootView-NcI-bjuh.js} +1 -1
  16. package/dist/assets/{EvaluationsView-Cv6F74cp.js → EvaluationsView-P9DGMaUt.js} +3 -3
  17. package/dist/assets/{ExecutionsTime.vue_vue_type_script_setup_true_lang-Ar7NipI9.js → ExecutionsTime.vue_vue_type_script_setup_true_lang-CIpd91fZ.js} +2 -2
  18. package/dist/assets/{ExecutionsView-BDCP9XVW.js → ExecutionsView-NkCHKd3U.js} +8 -8
  19. package/dist/assets/{FixedCollectionParameter-dYhz2Ism.js → FixedCollectionParameter-0-xS_bRE.js} +1 -1
  20. package/dist/assets/{ForgotMyPasswordView-C69Wn008.js → ForgotMyPasswordView-DqADZ9FM.js} +3 -3
  21. package/dist/assets/{InfoAccordion-CH0m5p8-.js → InfoAccordion-CR3AoL8Q.js} +1 -1
  22. package/dist/assets/{InsightsChartAverageRuntime-DAN-ukDS.js → InsightsChartAverageRuntime-C9xMoV66.js} +4 -4
  23. package/dist/assets/{InsightsChartFailed-DQmPYaEe.js → InsightsChartFailed-BXTLYxeQ.js} +4 -4
  24. package/dist/assets/{InsightsChartFailureRate-DO7uhap1.js → InsightsChartFailureRate-B0i0ej03.js} +4 -4
  25. package/dist/assets/{InsightsChartTimeSaved-CQA_4401.js → InsightsChartTimeSaved-DvotshIJ.js} +4 -4
  26. package/dist/assets/{InsightsChartTotal--CVbOXo5.js → InsightsChartTotal-BA2XNYoP.js} +4 -4
  27. package/dist/assets/{InsightsDashboard-CrBkWNMD.js → InsightsDashboard-CD18Zlv9.js} +10 -10
  28. package/dist/assets/{InsightsPaywall-C0dTxHKs.js → InsightsPaywall-DkCpVq9K.js} +1 -1
  29. package/dist/assets/{InsightsSummary-C6Y-SKzK.js → InsightsSummary-te2NcZ9J.js} +1 -1
  30. package/dist/assets/{InsightsTableWorkflows-BbVGyCBO.js → InsightsTableWorkflows-BWxBUXJC.js} +4 -5
  31. package/dist/assets/{Logo-CsvXL0P7.js → Logo-BxRx1Sn7.js} +1 -1
  32. package/dist/assets/{LogsPanel-CN42eNUt.js → LogsPanel-BMolfuZj.js} +6 -5
  33. package/dist/assets/{MainHeader-CoJhLOFm.js → MainHeader-04Z61-C3.js} +8 -8
  34. package/dist/assets/{MainSidebar-R8rwZ_Pn.js → MainSidebar-w66HTCDw.js} +3 -5
  35. package/dist/assets/NodeCreation-Q_eKy6g5.js +172 -0
  36. package/dist/assets/{NodeCreator-B4qIG19F.js → NodeCreator-CrAhvxUw.js} +1 -2
  37. package/dist/assets/{NodeDetailsView-DAAY8u0j.js → NodeDetailsView-B8VNYLDG.js} +16 -30
  38. package/dist/assets/{NodeDetailsView-CaTI-1QQ.css → NodeDetailsView-Cam4nPwL.css} +0 -3
  39. package/dist/assets/{NodeDetailsViewV2-rO5xAOLt.js → NodeDetailsViewV2-DnGtw1tW.js} +18 -31
  40. package/dist/assets/{NodeDetailsViewV2-LLVofUjw.css → NodeDetailsViewV2-LzYZcnv5.css} +0 -124
  41. package/dist/assets/{NodeView-B2097MY0.css → NodeView-BMiOpmk4.css} +184 -10
  42. package/dist/assets/{NodeView-COL17PiI.js → NodeView-C4gvxUVX.js} +137 -69
  43. package/dist/assets/{ProjectHeader-eW3SFgfy.js → ProjectHeader-Dj1zlff0.js} +46 -6
  44. package/dist/assets/{ProjectSettings-C2AHG6jb.js → ProjectSettings-DGLVLIdf.js} +3 -3
  45. package/dist/assets/{PushConnectionTracker.vue_vue_type_script_setup_true_lang-qgsXLVHp.js → PushConnectionTracker.vue_vue_type_script_setup_true_lang-BMifVbDm.js} +1 -1
  46. package/dist/assets/{ResourcesListLayout-uBbUHbxU.css → ResourcesListLayout-6eIqe4Ld.css} +8 -8
  47. package/dist/assets/{ResourcesListLayout-CRbZPcXi.js → ResourcesListLayout-BBjWNm-W.js} +56 -30
  48. package/dist/assets/{RunDataJson-BsgYpb7j.js → RunDataJson-B9KyYBpg.js} +3 -3
  49. package/dist/assets/{RunDataJsonActions-BwVIOF0o.js → RunDataJsonActions-Duqt5QgE.js} +1 -1
  50. package/dist/assets/{RunDataParsedAiContent-uldVOLgS.js → RunDataParsedAiContent-CyGJ7cWY.js} +2 -2
  51. package/dist/assets/{RunDataSearch-B_OkRO9N.js → RunDataSearch-CnT_s2fI.js} +3 -2
  52. package/dist/assets/{RunDataTable-BKnUlzVX.js → RunDataTable-DS--mKOx.js} +1 -1
  53. package/dist/assets/{SamlOnboarding-uGmw-L7G.js → SamlOnboarding-CXobvVPO.js} +3 -3
  54. package/dist/assets/{SettingsApiView-DIRnZSMH.js → SettingsApiView-d2EPD0v0.js} +1 -1
  55. package/dist/assets/{SettingsCommunityNodesView-BF3-gFEu.js → SettingsCommunityNodesView-D8Hu1ibZ.js} +4 -4
  56. package/dist/assets/{SettingsExternalSecrets-BceN7BZL.js → SettingsExternalSecrets-CaEiVMrT.js} +1 -1
  57. package/dist/assets/{SettingsLdapView-ErdD4koz.js → SettingsLdapView-BG-JZnoc.js} +1 -1
  58. package/dist/assets/{SettingsLogStreamingView-BAEs0SFs.js → SettingsLogStreamingView-CSVfO_Zn.js} +1 -1
  59. package/dist/assets/{SettingsPersonalView-C-Jmfurq.js → SettingsPersonalView-CtYxuOr8.js} +1 -1
  60. package/dist/assets/{SettingsSourceControl-D0b0Y8tK.js → SettingsSourceControl-CMY9og8f.js} +1 -1
  61. package/dist/assets/{SettingsSso-DHUWvjXP.js → SettingsSso-Cb9eLBFc.js} +1 -1
  62. package/dist/assets/{SettingsUsageAndPlan-CD14-RrC.js → SettingsUsageAndPlan-Ctu7EqQt.js} +1 -1
  63. package/dist/assets/{SettingsUsersView-DjO-Sh89.js → SettingsUsersView-CZ1NXmdI.js} +1 -2
  64. package/dist/assets/{SettingsView-CHxTZS8i.js → SettingsView--K0sRU6u.js} +1 -1
  65. package/dist/assets/{SetupView-C1Ln2UdV.js → SetupView-B2miL_Xi.js} +3 -3
  66. package/dist/assets/{SetupWorkflowCredentialsButton-BPymVgJe.js → SetupWorkflowCredentialsButton-BNtMeQ7B.js} +1 -1
  67. package/dist/assets/{SetupWorkflowFromTemplateView-wFX8bZAJ.js → SetupWorkflowFromTemplateView-CTKyYiT2.js} +3 -3
  68. package/dist/assets/{SigninView-C0kbXdPM.js → SigninView-Cwal9uDr.js} +3 -3
  69. package/dist/assets/{SignoutView-DAFKgMcr.js → SignoutView-HYdgGBTv.js} +1 -1
  70. package/dist/assets/{SignupView-PPupzKGC.js → SignupView-C-cruKwR.js} +3 -3
  71. package/dist/assets/{TableBase-gdXXFVAP.js → TableBase-BrU7ycgG.js} +1 -1
  72. package/dist/assets/{Tags-F2rWzlFg.js → Tags-B52OEMR8.js} +1 -1
  73. package/dist/assets/{TemplateDetails-Cv5PGkmu.js → TemplateDetails-CJHZRvKM.js} +2 -2
  74. package/dist/assets/{TemplateList-18ftmcJJ.js → TemplateList-BNPtBAlT.js} +1 -1
  75. package/dist/assets/{TemplatesCollectionView-DMVhS77J.js → TemplatesCollectionView-B3x_Q5aa.js} +6 -6
  76. package/dist/assets/{TemplatesSearchView-CA5t-yFo.js → TemplatesSearchView-Bu485VBl.js} +3 -3
  77. package/dist/assets/{TemplatesView-C0Eg9WLM.js → TemplatesView-D6dJhGNK.js} +1 -1
  78. package/dist/assets/{TemplatesWorkflowView-CGBohTkh.js → TemplatesWorkflowView-Bpnh-uFe.js} +6 -6
  79. package/dist/assets/{TriggerPanel-e3n6XSn6.js → TriggerPanel-Bh-GmBcj.js} +5 -5
  80. package/dist/assets/{VariablesView-xpXMqeMR.js → VariablesView-DHHlaB3P.js} +5 -5
  81. package/dist/assets/{VueMarkdown-DB88HNOs.js → VueMarkdown-CPLXg7f3.js} +1 -1
  82. package/dist/assets/{WorkerView-CkGaZ7n4.js → WorkerView-BUNXsftd.js} +6 -6
  83. package/dist/assets/{WorkflowActivator-D5g0kUNF.js → WorkflowActivator-CxzTs9kB.js} +3 -3
  84. package/dist/assets/{WorkflowExecutionsInfoAccordion-Cgs62HlG.js → WorkflowExecutionsInfoAccordion-DX3IfR5Z.js} +2 -2
  85. package/dist/assets/{WorkflowExecutionsLandingPage-Dg7W4mV0.js → WorkflowExecutionsLandingPage-DOdAJCQJ.js} +3 -3
  86. package/dist/assets/{WorkflowExecutionsPreview-C4vsWZbx.js → WorkflowExecutionsPreview-BgTqxHb-.js} +4 -4
  87. package/dist/assets/{WorkflowExecutionsView-lcK1FkoU.js → WorkflowExecutionsView-EYRMn-We.js} +6 -6
  88. package/dist/assets/{WorkflowHistory-xHaZRT-3.js → WorkflowHistory-hyAEcU5h.js} +2 -2
  89. package/dist/assets/{WorkflowOnboardingView-DBkTMmpE.js → WorkflowOnboardingView-SyPwYcj1.js} +1 -1
  90. package/dist/assets/{WorkflowPreview-BwzoCwMQ.js → WorkflowPreview-DtiGZ8jt.js} +1 -1
  91. package/dist/assets/{WorkflowsView-uWjceF97.js → WorkflowsView-B_kHCXhq.js} +125 -16
  92. package/dist/assets/{canvas-DJZKQR0M.js → canvas-CXoLZ47B.js} +1 -1
  93. package/dist/assets/{chartjs.utils-B_AakY6C.js → chartjs.utils-DvLXBjgm.js} +2 -2
  94. package/dist/assets/{en-D7cJPQEa.js → en-ORjqW56z.js} +41 -7
  95. package/dist/assets/{global-link-actions-CkD1SfM8.js → global-link-actions-DJzO0XY8.js} +1 -1
  96. package/dist/assets/{index-0vi2zwei.js → index-CgvvLCqI.js} +13217 -8401
  97. package/dist/assets/{index-wfdzkZ5N.js → index-Ci6ERb78.js} +1 -1
  98. package/dist/assets/{index-BnmK7yJz.css → index-DegUPemN.css} +1058 -482
  99. package/dist/assets/{pickBy-BVWE53bB.js → pickBy-C3y4kDIS.js} +1 -1
  100. package/dist/assets/readyToRunWorkflows.store-BcJDo6QO.js +2436 -0
  101. package/dist/assets/{templateActions-DzOhSXT7.js → templateActions-UuwYO8mn.js} +1 -1
  102. package/dist/assets/{useBeforeUnload-D8cfIuzK.js → useBeforeUnload-DtWRHUnb.js} +1 -1
  103. package/dist/assets/{useExecutionDebugging-DSzk_VRK.js → useExecutionDebugging-lNwnzl0B.js} +1 -1
  104. package/dist/assets/{useImportCurlCommand-C1X3Ke_i.js → useImportCurlCommand-Y4wyh6JG.js} +1 -1
  105. package/dist/assets/useProjectPages-xsj6GD9u.js +17 -0
  106. package/dist/assets/{usePushConnection-DoC4OSDa.js → usePushConnection-Odqh2Hhm.js} +10 -3
  107. package/dist/assets/{useWorkflowActivate-BwfqoMi7.js → useWorkflowActivate-DFgPcDUt.js} +1 -1
  108. package/dist/index.html +2 -2
  109. package/package.json +1 -1
  110. package/vite.config.mts +2 -0
  111. package/dist/assets/CollectionParameter-BPA801P5.js +0 -4
  112. package/dist/assets/N8nDataTableServer-BHILYG__.js +0 -3203
  113. package/dist/assets/NodeCreation-gPsMJZWq.js +0 -440
  114. package/dist/assets/aiTemplatesStarterCollection.store-BsCe0bSk.js +0 -795
  115. package/dist/assets/useProjectPages-DYrfMJmY.js +0 -21
@@ -1,3203 +0,0 @@
1
- import { d as defineComponent, bv as isRef, ch as shallowRef, ab as watch, r as ref, fl as watchEffect, aN as h, l as unref, e5 as mergeModels, fm as useSlots, x as computed, e6 as useModel, fn as ElCheckbox, cf as useThrottleFn, h as createElementBlock, g as openBlock, j as createBaseVNode, f as createCommentVNode, P as normalizeStyle, n as normalizeClass, F as Fragment, y as renderList, e as createBlock, k as createTextVNode, t as toDisplayString, bS as withModifiers, J as renderSlot, i as createVNode, fo as ElSkeletonItem, D as mergeProps, fp as _sfc_main$1, fq as ElSelect, w as withCtx, fr as ElOption, bu as get, _ as _export_sfc } from "./index-0vi2zwei.js";
2
- /**
3
- * table-core
4
- *
5
- * Copyright (c) TanStack
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE.md file in the root directory of this source tree.
9
- *
10
- * @license MIT
11
- */
12
- function createColumnHelper() {
13
- return {
14
- accessor: (accessor, column) => {
15
- return typeof accessor === "function" ? {
16
- ...column,
17
- accessorFn: accessor
18
- } : {
19
- ...column,
20
- accessorKey: accessor
21
- };
22
- },
23
- display: (column) => column,
24
- group: (column) => column
25
- };
26
- }
27
- function functionalUpdate(updater, input) {
28
- return typeof updater === "function" ? updater(input) : updater;
29
- }
30
- function makeStateUpdater(key, instance) {
31
- return (updater) => {
32
- instance.setState((old) => {
33
- return {
34
- ...old,
35
- [key]: functionalUpdate(updater, old[key])
36
- };
37
- });
38
- };
39
- }
40
- function isFunction(d) {
41
- return d instanceof Function;
42
- }
43
- function isNumberArray(d) {
44
- return Array.isArray(d) && d.every((val) => typeof val === "number");
45
- }
46
- function flattenBy(arr, getChildren) {
47
- const flat = [];
48
- const recurse = (subArr) => {
49
- subArr.forEach((item) => {
50
- flat.push(item);
51
- const children = getChildren(item);
52
- if (children != null && children.length) {
53
- recurse(children);
54
- }
55
- });
56
- };
57
- recurse(arr);
58
- return flat;
59
- }
60
- function memo(getDeps, fn, opts) {
61
- let deps = [];
62
- let result;
63
- return (depArgs) => {
64
- let depTime;
65
- if (opts.key && opts.debug) depTime = Date.now();
66
- const newDeps = getDeps(depArgs);
67
- const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
68
- if (!depsChanged) {
69
- return result;
70
- }
71
- deps = newDeps;
72
- let resultTime;
73
- if (opts.key && opts.debug) resultTime = Date.now();
74
- result = fn(...newDeps);
75
- opts == null || opts.onChange == null || opts.onChange(result);
76
- if (opts.key && opts.debug) {
77
- if (opts != null && opts.debug()) {
78
- const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
79
- const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
80
- const resultFpsPercentage = resultEndTime / 16;
81
- const pad = (str, num) => {
82
- str = String(str);
83
- while (str.length < num) {
84
- str = " " + str;
85
- }
86
- return str;
87
- };
88
- console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
89
- font-size: .6rem;
90
- font-weight: bold;
91
- color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
92
- }
93
- }
94
- return result;
95
- };
96
- }
97
- function getMemoOptions(tableOptions, debugLevel, key, onChange) {
98
- return {
99
- debug: () => {
100
- var _tableOptions$debugAl;
101
- return (_tableOptions$debugAl = tableOptions == null ? void 0 : tableOptions.debugAll) != null ? _tableOptions$debugAl : tableOptions[debugLevel];
102
- },
103
- key: false,
104
- onChange
105
- };
106
- }
107
- function createCell(table, row, column, columnId) {
108
- const getRenderValue = () => {
109
- var _cell$getValue;
110
- return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
111
- };
112
- const cell = {
113
- id: `${row.id}_${column.id}`,
114
- row,
115
- column,
116
- getValue: () => row.getValue(columnId),
117
- renderValue: getRenderValue,
118
- getContext: memo(() => [table, column, row, cell], (table2, column2, row2, cell2) => ({
119
- table: table2,
120
- column: column2,
121
- row: row2,
122
- cell: cell2,
123
- getValue: cell2.getValue,
124
- renderValue: cell2.renderValue
125
- }), getMemoOptions(table.options, "debugCells"))
126
- };
127
- table._features.forEach((feature) => {
128
- feature.createCell == null || feature.createCell(cell, column, row, table);
129
- }, {});
130
- return cell;
131
- }
132
- function createColumn(table, columnDef, depth, parent) {
133
- var _ref, _resolvedColumnDef$id;
134
- const defaultColumn = table._getDefaultColumnDef();
135
- const resolvedColumnDef = {
136
- ...defaultColumn,
137
- ...columnDef
138
- };
139
- const accessorKey = resolvedColumnDef.accessorKey;
140
- let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? typeof String.prototype.replaceAll === "function" ? accessorKey.replaceAll(".", "_") : accessorKey.replace(/\./g, "_") : void 0) != null ? _ref : typeof resolvedColumnDef.header === "string" ? resolvedColumnDef.header : void 0;
141
- let accessorFn;
142
- if (resolvedColumnDef.accessorFn) {
143
- accessorFn = resolvedColumnDef.accessorFn;
144
- } else if (accessorKey) {
145
- if (accessorKey.includes(".")) {
146
- accessorFn = (originalRow) => {
147
- let result = originalRow;
148
- for (const key of accessorKey.split(".")) {
149
- var _result;
150
- result = (_result = result) == null ? void 0 : _result[key];
151
- }
152
- return result;
153
- };
154
- } else {
155
- accessorFn = (originalRow) => originalRow[resolvedColumnDef.accessorKey];
156
- }
157
- }
158
- if (!id) {
159
- throw new Error();
160
- }
161
- let column = {
162
- id: `${String(id)}`,
163
- accessorFn,
164
- parent,
165
- depth,
166
- columnDef: resolvedColumnDef,
167
- columns: [],
168
- getFlatColumns: memo(() => [true], () => {
169
- var _column$columns;
170
- return [column, ...(_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap((d) => d.getFlatColumns())];
171
- }, getMemoOptions(table.options, "debugColumns")),
172
- getLeafColumns: memo(() => [table._getOrderColumnsFn()], (orderColumns2) => {
173
- var _column$columns2;
174
- if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
175
- let leafColumns = column.columns.flatMap((column2) => column2.getLeafColumns());
176
- return orderColumns2(leafColumns);
177
- }
178
- return [column];
179
- }, getMemoOptions(table.options, "debugColumns"))
180
- };
181
- for (const feature of table._features) {
182
- feature.createColumn == null || feature.createColumn(column, table);
183
- }
184
- return column;
185
- }
186
- const debug = "debugHeaders";
187
- function createHeader(table, column, options) {
188
- var _options$id;
189
- const id = (_options$id = options.id) != null ? _options$id : column.id;
190
- let header = {
191
- id,
192
- column,
193
- index: options.index,
194
- isPlaceholder: !!options.isPlaceholder,
195
- placeholderId: options.placeholderId,
196
- depth: options.depth,
197
- subHeaders: [],
198
- colSpan: 0,
199
- rowSpan: 0,
200
- headerGroup: null,
201
- getLeafHeaders: () => {
202
- const leafHeaders = [];
203
- const recurseHeader = (h2) => {
204
- if (h2.subHeaders && h2.subHeaders.length) {
205
- h2.subHeaders.map(recurseHeader);
206
- }
207
- leafHeaders.push(h2);
208
- };
209
- recurseHeader(header);
210
- return leafHeaders;
211
- },
212
- getContext: () => ({
213
- table,
214
- header,
215
- column
216
- })
217
- };
218
- table._features.forEach((feature) => {
219
- feature.createHeader == null || feature.createHeader(header, table);
220
- });
221
- return header;
222
- }
223
- const Headers = {
224
- createTable: (table) => {
225
- table.getHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
226
- var _left$map$filter, _right$map$filter;
227
- const leftColumns = (_left$map$filter = left == null ? void 0 : left.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
228
- const rightColumns = (_right$map$filter = right == null ? void 0 : right.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
229
- const centerColumns = leafColumns.filter((column) => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
230
- const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], table);
231
- return headerGroups;
232
- }, getMemoOptions(table.options, debug));
233
- table.getCenterHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
234
- leafColumns = leafColumns.filter((column) => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
235
- return buildHeaderGroups(allColumns, leafColumns, table, "center");
236
- }, getMemoOptions(table.options, debug));
237
- table.getLeftHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
238
- var _left$map$filter2;
239
- const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
240
- return buildHeaderGroups(allColumns, orderedLeafColumns, table, "left");
241
- }, getMemoOptions(table.options, debug));
242
- table.getRightHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
243
- var _right$map$filter2;
244
- const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
245
- return buildHeaderGroups(allColumns, orderedLeafColumns, table, "right");
246
- }, getMemoOptions(table.options, debug));
247
- table.getFooterGroups = memo(() => [table.getHeaderGroups()], (headerGroups) => {
248
- return [...headerGroups].reverse();
249
- }, getMemoOptions(table.options, debug));
250
- table.getLeftFooterGroups = memo(() => [table.getLeftHeaderGroups()], (headerGroups) => {
251
- return [...headerGroups].reverse();
252
- }, getMemoOptions(table.options, debug));
253
- table.getCenterFooterGroups = memo(() => [table.getCenterHeaderGroups()], (headerGroups) => {
254
- return [...headerGroups].reverse();
255
- }, getMemoOptions(table.options, debug));
256
- table.getRightFooterGroups = memo(() => [table.getRightHeaderGroups()], (headerGroups) => {
257
- return [...headerGroups].reverse();
258
- }, getMemoOptions(table.options, debug));
259
- table.getFlatHeaders = memo(() => [table.getHeaderGroups()], (headerGroups) => {
260
- return headerGroups.map((headerGroup) => {
261
- return headerGroup.headers;
262
- }).flat();
263
- }, getMemoOptions(table.options, debug));
264
- table.getLeftFlatHeaders = memo(() => [table.getLeftHeaderGroups()], (left) => {
265
- return left.map((headerGroup) => {
266
- return headerGroup.headers;
267
- }).flat();
268
- }, getMemoOptions(table.options, debug));
269
- table.getCenterFlatHeaders = memo(() => [table.getCenterHeaderGroups()], (left) => {
270
- return left.map((headerGroup) => {
271
- return headerGroup.headers;
272
- }).flat();
273
- }, getMemoOptions(table.options, debug));
274
- table.getRightFlatHeaders = memo(() => [table.getRightHeaderGroups()], (left) => {
275
- return left.map((headerGroup) => {
276
- return headerGroup.headers;
277
- }).flat();
278
- }, getMemoOptions(table.options, debug));
279
- table.getCenterLeafHeaders = memo(() => [table.getCenterFlatHeaders()], (flatHeaders) => {
280
- return flatHeaders.filter((header) => {
281
- var _header$subHeaders;
282
- return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
283
- });
284
- }, getMemoOptions(table.options, debug));
285
- table.getLeftLeafHeaders = memo(() => [table.getLeftFlatHeaders()], (flatHeaders) => {
286
- return flatHeaders.filter((header) => {
287
- var _header$subHeaders2;
288
- return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
289
- });
290
- }, getMemoOptions(table.options, debug));
291
- table.getRightLeafHeaders = memo(() => [table.getRightFlatHeaders()], (flatHeaders) => {
292
- return flatHeaders.filter((header) => {
293
- var _header$subHeaders3;
294
- return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
295
- });
296
- }, getMemoOptions(table.options, debug));
297
- table.getLeafHeaders = memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
298
- var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
299
- return [...(_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : [], ...(_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : [], ...(_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : []].map((header) => {
300
- return header.getLeafHeaders();
301
- }).flat();
302
- }, getMemoOptions(table.options, debug));
303
- }
304
- };
305
- function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
306
- var _headerGroups$0$heade, _headerGroups$;
307
- let maxDepth = 0;
308
- const findMaxDepth = function(columns, depth) {
309
- if (depth === void 0) {
310
- depth = 1;
311
- }
312
- maxDepth = Math.max(maxDepth, depth);
313
- columns.filter((column) => column.getIsVisible()).forEach((column) => {
314
- var _column$columns;
315
- if ((_column$columns = column.columns) != null && _column$columns.length) {
316
- findMaxDepth(column.columns, depth + 1);
317
- }
318
- }, 0);
319
- };
320
- findMaxDepth(allColumns);
321
- let headerGroups = [];
322
- const createHeaderGroup = (headersToGroup, depth) => {
323
- const headerGroup = {
324
- depth,
325
- id: [headerFamily, `${depth}`].filter(Boolean).join("_"),
326
- headers: []
327
- };
328
- const pendingParentHeaders = [];
329
- headersToGroup.forEach((headerToGroup) => {
330
- const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
331
- const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
332
- let column;
333
- let isPlaceholder = false;
334
- if (isLeafHeader && headerToGroup.column.parent) {
335
- column = headerToGroup.column.parent;
336
- } else {
337
- column = headerToGroup.column;
338
- isPlaceholder = true;
339
- }
340
- if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
341
- latestPendingParentHeader.subHeaders.push(headerToGroup);
342
- } else {
343
- const header = createHeader(table, column, {
344
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join("_"),
345
- isPlaceholder,
346
- placeholderId: isPlaceholder ? `${pendingParentHeaders.filter((d) => d.column === column).length}` : void 0,
347
- depth,
348
- index: pendingParentHeaders.length
349
- });
350
- header.subHeaders.push(headerToGroup);
351
- pendingParentHeaders.push(header);
352
- }
353
- headerGroup.headers.push(headerToGroup);
354
- headerToGroup.headerGroup = headerGroup;
355
- });
356
- headerGroups.push(headerGroup);
357
- if (depth > 0) {
358
- createHeaderGroup(pendingParentHeaders, depth - 1);
359
- }
360
- };
361
- const bottomHeaders = columnsToGroup.map((column, index) => createHeader(table, column, {
362
- depth: maxDepth,
363
- index
364
- }));
365
- createHeaderGroup(bottomHeaders, maxDepth - 1);
366
- headerGroups.reverse();
367
- const recurseHeadersForSpans = (headers) => {
368
- const filteredHeaders = headers.filter((header) => header.column.getIsVisible());
369
- return filteredHeaders.map((header) => {
370
- let colSpan = 0;
371
- let rowSpan = 0;
372
- let childRowSpans = [0];
373
- if (header.subHeaders && header.subHeaders.length) {
374
- childRowSpans = [];
375
- recurseHeadersForSpans(header.subHeaders).forEach((_ref) => {
376
- let {
377
- colSpan: childColSpan,
378
- rowSpan: childRowSpan
379
- } = _ref;
380
- colSpan += childColSpan;
381
- childRowSpans.push(childRowSpan);
382
- });
383
- } else {
384
- colSpan = 1;
385
- }
386
- const minChildRowSpan = Math.min(...childRowSpans);
387
- rowSpan = rowSpan + minChildRowSpan;
388
- header.colSpan = colSpan;
389
- header.rowSpan = rowSpan;
390
- return {
391
- colSpan,
392
- rowSpan
393
- };
394
- });
395
- };
396
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
397
- return headerGroups;
398
- }
399
- const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
400
- let row = {
401
- id,
402
- index: rowIndex,
403
- original,
404
- depth,
405
- parentId,
406
- _valuesCache: {},
407
- _uniqueValuesCache: {},
408
- getValue: (columnId) => {
409
- if (row._valuesCache.hasOwnProperty(columnId)) {
410
- return row._valuesCache[columnId];
411
- }
412
- const column = table.getColumn(columnId);
413
- if (!(column != null && column.accessorFn)) {
414
- return void 0;
415
- }
416
- row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
417
- return row._valuesCache[columnId];
418
- },
419
- getUniqueValues: (columnId) => {
420
- if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
421
- return row._uniqueValuesCache[columnId];
422
- }
423
- const column = table.getColumn(columnId);
424
- if (!(column != null && column.accessorFn)) {
425
- return void 0;
426
- }
427
- if (!column.columnDef.getUniqueValues) {
428
- row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
429
- return row._uniqueValuesCache[columnId];
430
- }
431
- row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
432
- return row._uniqueValuesCache[columnId];
433
- },
434
- renderValue: (columnId) => {
435
- var _row$getValue;
436
- return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
437
- },
438
- subRows: [],
439
- getLeafRows: () => flattenBy(row.subRows, (d) => d.subRows),
440
- getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : void 0,
441
- getParentRows: () => {
442
- let parentRows = [];
443
- let currentRow = row;
444
- while (true) {
445
- const parentRow = currentRow.getParentRow();
446
- if (!parentRow) break;
447
- parentRows.push(parentRow);
448
- currentRow = parentRow;
449
- }
450
- return parentRows.reverse();
451
- },
452
- getAllCells: memo(() => [table.getAllLeafColumns()], (leafColumns) => {
453
- return leafColumns.map((column) => {
454
- return createCell(table, row, column, column.id);
455
- });
456
- }, getMemoOptions(table.options, "debugRows")),
457
- _getAllCellsByColumnId: memo(() => [row.getAllCells()], (allCells) => {
458
- return allCells.reduce((acc, cell) => {
459
- acc[cell.column.id] = cell;
460
- return acc;
461
- }, {});
462
- }, getMemoOptions(table.options, "debugRows"))
463
- };
464
- for (let i = 0; i < table._features.length; i++) {
465
- const feature = table._features[i];
466
- feature == null || feature.createRow == null || feature.createRow(row, table);
467
- }
468
- return row;
469
- };
470
- const ColumnFaceting = {
471
- createColumn: (column, table) => {
472
- column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
473
- column.getFacetedRowModel = () => {
474
- if (!column._getFacetedRowModel) {
475
- return table.getPreFilteredRowModel();
476
- }
477
- return column._getFacetedRowModel();
478
- };
479
- column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
480
- column.getFacetedUniqueValues = () => {
481
- if (!column._getFacetedUniqueValues) {
482
- return /* @__PURE__ */ new Map();
483
- }
484
- return column._getFacetedUniqueValues();
485
- };
486
- column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
487
- column.getFacetedMinMaxValues = () => {
488
- if (!column._getFacetedMinMaxValues) {
489
- return void 0;
490
- }
491
- return column._getFacetedMinMaxValues();
492
- };
493
- }
494
- };
495
- const includesString = (row, columnId, filterValue) => {
496
- var _filterValue$toString, _row$getValue;
497
- const search = filterValue == null || (_filterValue$toString = filterValue.toString()) == null ? void 0 : _filterValue$toString.toLowerCase();
498
- return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
499
- };
500
- includesString.autoRemove = (val) => testFalsey(val);
501
- const includesStringSensitive = (row, columnId, filterValue) => {
502
- var _row$getValue2;
503
- return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
504
- };
505
- includesStringSensitive.autoRemove = (val) => testFalsey(val);
506
- const equalsString = (row, columnId, filterValue) => {
507
- var _row$getValue3;
508
- return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
509
- };
510
- equalsString.autoRemove = (val) => testFalsey(val);
511
- const arrIncludes = (row, columnId, filterValue) => {
512
- var _row$getValue4;
513
- return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
514
- };
515
- arrIncludes.autoRemove = (val) => testFalsey(val);
516
- const arrIncludesAll = (row, columnId, filterValue) => {
517
- return !filterValue.some((val) => {
518
- var _row$getValue5;
519
- return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
520
- });
521
- };
522
- arrIncludesAll.autoRemove = (val) => testFalsey(val) || !(val != null && val.length);
523
- const arrIncludesSome = (row, columnId, filterValue) => {
524
- return filterValue.some((val) => {
525
- var _row$getValue6;
526
- return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
527
- });
528
- };
529
- arrIncludesSome.autoRemove = (val) => testFalsey(val) || !(val != null && val.length);
530
- const equals = (row, columnId, filterValue) => {
531
- return row.getValue(columnId) === filterValue;
532
- };
533
- equals.autoRemove = (val) => testFalsey(val);
534
- const weakEquals = (row, columnId, filterValue) => {
535
- return row.getValue(columnId) == filterValue;
536
- };
537
- weakEquals.autoRemove = (val) => testFalsey(val);
538
- const inNumberRange = (row, columnId, filterValue) => {
539
- let [min2, max2] = filterValue;
540
- const rowValue = row.getValue(columnId);
541
- return rowValue >= min2 && rowValue <= max2;
542
- };
543
- inNumberRange.resolveFilterValue = (val) => {
544
- let [unsafeMin, unsafeMax] = val;
545
- let parsedMin = typeof unsafeMin !== "number" ? parseFloat(unsafeMin) : unsafeMin;
546
- let parsedMax = typeof unsafeMax !== "number" ? parseFloat(unsafeMax) : unsafeMax;
547
- let min2 = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
548
- let max2 = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
549
- if (min2 > max2) {
550
- const temp = min2;
551
- min2 = max2;
552
- max2 = temp;
553
- }
554
- return [min2, max2];
555
- };
556
- inNumberRange.autoRemove = (val) => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
557
- const filterFns = {
558
- includesString,
559
- includesStringSensitive,
560
- equalsString,
561
- arrIncludes,
562
- arrIncludesAll,
563
- arrIncludesSome,
564
- equals,
565
- weakEquals,
566
- inNumberRange
567
- };
568
- function testFalsey(val) {
569
- return val === void 0 || val === null || val === "";
570
- }
571
- const ColumnFiltering = {
572
- getDefaultColumnDef: () => {
573
- return {
574
- filterFn: "auto"
575
- };
576
- },
577
- getInitialState: (state) => {
578
- return {
579
- columnFilters: [],
580
- ...state
581
- };
582
- },
583
- getDefaultOptions: (table) => {
584
- return {
585
- onColumnFiltersChange: makeStateUpdater("columnFilters", table),
586
- filterFromLeafRows: false,
587
- maxLeafRowFilterDepth: 100
588
- };
589
- },
590
- createColumn: (column, table) => {
591
- column.getAutoFilterFn = () => {
592
- const firstRow = table.getCoreRowModel().flatRows[0];
593
- const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
594
- if (typeof value === "string") {
595
- return filterFns.includesString;
596
- }
597
- if (typeof value === "number") {
598
- return filterFns.inNumberRange;
599
- }
600
- if (typeof value === "boolean") {
601
- return filterFns.equals;
602
- }
603
- if (value !== null && typeof value === "object") {
604
- return filterFns.equals;
605
- }
606
- if (Array.isArray(value)) {
607
- return filterFns.arrIncludes;
608
- }
609
- return filterFns.weakEquals;
610
- };
611
- column.getFilterFn = () => {
612
- var _table$options$filter, _table$options$filter2;
613
- return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === "auto" ? column.getAutoFilterFn() : (
614
- // @ts-ignore
615
- (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn]
616
- );
617
- };
618
- column.getCanFilter = () => {
619
- var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
620
- return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
621
- };
622
- column.getIsFiltered = () => column.getFilterIndex() > -1;
623
- column.getFilterValue = () => {
624
- var _table$getState$colum;
625
- return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find((d) => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
626
- };
627
- column.getFilterIndex = () => {
628
- var _table$getState$colum2, _table$getState$colum3;
629
- return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex((d) => d.id === column.id)) != null ? _table$getState$colum2 : -1;
630
- };
631
- column.setFilterValue = (value) => {
632
- table.setColumnFilters((old) => {
633
- const filterFn = column.getFilterFn();
634
- const previousFilter = old == null ? void 0 : old.find((d) => d.id === column.id);
635
- const newFilter = functionalUpdate(value, previousFilter ? previousFilter.value : void 0);
636
- if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
637
- var _old$filter;
638
- return (_old$filter = old == null ? void 0 : old.filter((d) => d.id !== column.id)) != null ? _old$filter : [];
639
- }
640
- const newFilterObj = {
641
- id: column.id,
642
- value: newFilter
643
- };
644
- if (previousFilter) {
645
- var _old$map;
646
- return (_old$map = old == null ? void 0 : old.map((d) => {
647
- if (d.id === column.id) {
648
- return newFilterObj;
649
- }
650
- return d;
651
- })) != null ? _old$map : [];
652
- }
653
- if (old != null && old.length) {
654
- return [...old, newFilterObj];
655
- }
656
- return [newFilterObj];
657
- });
658
- };
659
- },
660
- createRow: (row, _table) => {
661
- row.columnFilters = {};
662
- row.columnFiltersMeta = {};
663
- },
664
- createTable: (table) => {
665
- table.setColumnFilters = (updater) => {
666
- const leafColumns = table.getAllLeafColumns();
667
- const updateFn = (old) => {
668
- var _functionalUpdate;
669
- return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter((filter) => {
670
- const column = leafColumns.find((d) => d.id === filter.id);
671
- if (column) {
672
- const filterFn = column.getFilterFn();
673
- if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
674
- return false;
675
- }
676
- }
677
- return true;
678
- });
679
- };
680
- table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
681
- };
682
- table.resetColumnFilters = (defaultState) => {
683
- var _table$initialState$c, _table$initialState;
684
- table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
685
- };
686
- table.getPreFilteredRowModel = () => table.getCoreRowModel();
687
- table.getFilteredRowModel = () => {
688
- if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
689
- table._getFilteredRowModel = table.options.getFilteredRowModel(table);
690
- }
691
- if (table.options.manualFiltering || !table._getFilteredRowModel) {
692
- return table.getPreFilteredRowModel();
693
- }
694
- return table._getFilteredRowModel();
695
- };
696
- }
697
- };
698
- function shouldAutoRemoveFilter(filterFn, value, column) {
699
- return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === "undefined" || typeof value === "string" && !value;
700
- }
701
- const sum = (columnId, _leafRows, childRows) => {
702
- return childRows.reduce((sum2, next) => {
703
- const nextValue = next.getValue(columnId);
704
- return sum2 + (typeof nextValue === "number" ? nextValue : 0);
705
- }, 0);
706
- };
707
- const min = (columnId, _leafRows, childRows) => {
708
- let min2;
709
- childRows.forEach((row) => {
710
- const value = row.getValue(columnId);
711
- if (value != null && (min2 > value || min2 === void 0 && value >= value)) {
712
- min2 = value;
713
- }
714
- });
715
- return min2;
716
- };
717
- const max = (columnId, _leafRows, childRows) => {
718
- let max2;
719
- childRows.forEach((row) => {
720
- const value = row.getValue(columnId);
721
- if (value != null && (max2 < value || max2 === void 0 && value >= value)) {
722
- max2 = value;
723
- }
724
- });
725
- return max2;
726
- };
727
- const extent = (columnId, _leafRows, childRows) => {
728
- let min2;
729
- let max2;
730
- childRows.forEach((row) => {
731
- const value = row.getValue(columnId);
732
- if (value != null) {
733
- if (min2 === void 0) {
734
- if (value >= value) min2 = max2 = value;
735
- } else {
736
- if (min2 > value) min2 = value;
737
- if (max2 < value) max2 = value;
738
- }
739
- }
740
- });
741
- return [min2, max2];
742
- };
743
- const mean = (columnId, leafRows) => {
744
- let count2 = 0;
745
- let sum2 = 0;
746
- leafRows.forEach((row) => {
747
- let value = row.getValue(columnId);
748
- if (value != null && (value = +value) >= value) {
749
- ++count2, sum2 += value;
750
- }
751
- });
752
- if (count2) return sum2 / count2;
753
- return;
754
- };
755
- const median = (columnId, leafRows) => {
756
- if (!leafRows.length) {
757
- return;
758
- }
759
- const values = leafRows.map((row) => row.getValue(columnId));
760
- if (!isNumberArray(values)) {
761
- return;
762
- }
763
- if (values.length === 1) {
764
- return values[0];
765
- }
766
- const mid = Math.floor(values.length / 2);
767
- const nums = values.sort((a, b) => a - b);
768
- return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
769
- };
770
- const unique = (columnId, leafRows) => {
771
- return Array.from(new Set(leafRows.map((d) => d.getValue(columnId))).values());
772
- };
773
- const uniqueCount = (columnId, leafRows) => {
774
- return new Set(leafRows.map((d) => d.getValue(columnId))).size;
775
- };
776
- const count = (_columnId, leafRows) => {
777
- return leafRows.length;
778
- };
779
- const aggregationFns = {
780
- sum,
781
- min,
782
- max,
783
- extent,
784
- mean,
785
- median,
786
- unique,
787
- uniqueCount,
788
- count
789
- };
790
- const ColumnGrouping = {
791
- getDefaultColumnDef: () => {
792
- return {
793
- aggregatedCell: (props) => {
794
- var _toString, _props$getValue;
795
- return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
796
- },
797
- aggregationFn: "auto"
798
- };
799
- },
800
- getInitialState: (state) => {
801
- return {
802
- grouping: [],
803
- ...state
804
- };
805
- },
806
- getDefaultOptions: (table) => {
807
- return {
808
- onGroupingChange: makeStateUpdater("grouping", table),
809
- groupedColumnMode: "reorder"
810
- };
811
- },
812
- createColumn: (column, table) => {
813
- column.toggleGrouping = () => {
814
- table.setGrouping((old) => {
815
- if (old != null && old.includes(column.id)) {
816
- return old.filter((d) => d !== column.id);
817
- }
818
- return [...old != null ? old : [], column.id];
819
- });
820
- };
821
- column.getCanGroup = () => {
822
- var _column$columnDef$ena, _table$options$enable;
823
- return ((_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGrouping) != null ? _table$options$enable : true) && (!!column.accessorFn || !!column.columnDef.getGroupingValue);
824
- };
825
- column.getIsGrouped = () => {
826
- var _table$getState$group;
827
- return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
828
- };
829
- column.getGroupedIndex = () => {
830
- var _table$getState$group2;
831
- return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
832
- };
833
- column.getToggleGroupingHandler = () => {
834
- const canGroup = column.getCanGroup();
835
- return () => {
836
- if (!canGroup) return;
837
- column.toggleGrouping();
838
- };
839
- };
840
- column.getAutoAggregationFn = () => {
841
- const firstRow = table.getCoreRowModel().flatRows[0];
842
- const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
843
- if (typeof value === "number") {
844
- return aggregationFns.sum;
845
- }
846
- if (Object.prototype.toString.call(value) === "[object Date]") {
847
- return aggregationFns.extent;
848
- }
849
- };
850
- column.getAggregationFn = () => {
851
- var _table$options$aggreg, _table$options$aggreg2;
852
- if (!column) {
853
- throw new Error();
854
- }
855
- return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === "auto" ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
856
- };
857
- },
858
- createTable: (table) => {
859
- table.setGrouping = (updater) => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
860
- table.resetGrouping = (defaultState) => {
861
- var _table$initialState$g, _table$initialState;
862
- table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
863
- };
864
- table.getPreGroupedRowModel = () => table.getFilteredRowModel();
865
- table.getGroupedRowModel = () => {
866
- if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
867
- table._getGroupedRowModel = table.options.getGroupedRowModel(table);
868
- }
869
- if (table.options.manualGrouping || !table._getGroupedRowModel) {
870
- return table.getPreGroupedRowModel();
871
- }
872
- return table._getGroupedRowModel();
873
- };
874
- },
875
- createRow: (row, table) => {
876
- row.getIsGrouped = () => !!row.groupingColumnId;
877
- row.getGroupingValue = (columnId) => {
878
- if (row._groupingValuesCache.hasOwnProperty(columnId)) {
879
- return row._groupingValuesCache[columnId];
880
- }
881
- const column = table.getColumn(columnId);
882
- if (!(column != null && column.columnDef.getGroupingValue)) {
883
- return row.getValue(columnId);
884
- }
885
- row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
886
- return row._groupingValuesCache[columnId];
887
- };
888
- row._groupingValuesCache = {};
889
- },
890
- createCell: (cell, column, row, table) => {
891
- cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
892
- cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
893
- cell.getIsAggregated = () => {
894
- var _row$subRows;
895
- return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
896
- };
897
- }
898
- };
899
- function orderColumns(leafColumns, grouping, groupedColumnMode) {
900
- if (!(grouping != null && grouping.length) || !groupedColumnMode) {
901
- return leafColumns;
902
- }
903
- const nonGroupingColumns = leafColumns.filter((col) => !grouping.includes(col.id));
904
- if (groupedColumnMode === "remove") {
905
- return nonGroupingColumns;
906
- }
907
- const groupingColumns = grouping.map((g) => leafColumns.find((col) => col.id === g)).filter(Boolean);
908
- return [...groupingColumns, ...nonGroupingColumns];
909
- }
910
- const ColumnOrdering = {
911
- getInitialState: (state) => {
912
- return {
913
- columnOrder: [],
914
- ...state
915
- };
916
- },
917
- getDefaultOptions: (table) => {
918
- return {
919
- onColumnOrderChange: makeStateUpdater("columnOrder", table)
920
- };
921
- },
922
- createColumn: (column, table) => {
923
- column.getIndex = memo((position) => [_getVisibleLeafColumns(table, position)], (columns) => columns.findIndex((d) => d.id === column.id), getMemoOptions(table.options, "debugColumns"));
924
- column.getIsFirstColumn = (position) => {
925
- var _columns$;
926
- const columns = _getVisibleLeafColumns(table, position);
927
- return ((_columns$ = columns[0]) == null ? void 0 : _columns$.id) === column.id;
928
- };
929
- column.getIsLastColumn = (position) => {
930
- var _columns;
931
- const columns = _getVisibleLeafColumns(table, position);
932
- return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
933
- };
934
- },
935
- createTable: (table) => {
936
- table.setColumnOrder = (updater) => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
937
- table.resetColumnOrder = (defaultState) => {
938
- var _table$initialState$c;
939
- table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
940
- };
941
- table._getOrderColumnsFn = memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => (columns) => {
942
- let orderedColumns = [];
943
- if (!(columnOrder != null && columnOrder.length)) {
944
- orderedColumns = columns;
945
- } else {
946
- const columnOrderCopy = [...columnOrder];
947
- const columnsCopy = [...columns];
948
- while (columnsCopy.length && columnOrderCopy.length) {
949
- const targetColumnId = columnOrderCopy.shift();
950
- const foundIndex = columnsCopy.findIndex((d) => d.id === targetColumnId);
951
- if (foundIndex > -1) {
952
- orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
953
- }
954
- }
955
- orderedColumns = [...orderedColumns, ...columnsCopy];
956
- }
957
- return orderColumns(orderedColumns, grouping, groupedColumnMode);
958
- }, getMemoOptions(table.options, "debugTable"));
959
- }
960
- };
961
- const getDefaultColumnPinningState = () => ({
962
- left: [],
963
- right: []
964
- });
965
- const ColumnPinning = {
966
- getInitialState: (state) => {
967
- return {
968
- columnPinning: getDefaultColumnPinningState(),
969
- ...state
970
- };
971
- },
972
- getDefaultOptions: (table) => {
973
- return {
974
- onColumnPinningChange: makeStateUpdater("columnPinning", table)
975
- };
976
- },
977
- createColumn: (column, table) => {
978
- column.pin = (position) => {
979
- const columnIds = column.getLeafColumns().map((d) => d.id).filter(Boolean);
980
- table.setColumnPinning((old) => {
981
- var _old$left3, _old$right3;
982
- if (position === "right") {
983
- var _old$left, _old$right;
984
- return {
985
- left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter((d) => !(columnIds != null && columnIds.includes(d))),
986
- right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter((d) => !(columnIds != null && columnIds.includes(d))), ...columnIds]
987
- };
988
- }
989
- if (position === "left") {
990
- var _old$left2, _old$right2;
991
- return {
992
- left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter((d) => !(columnIds != null && columnIds.includes(d))), ...columnIds],
993
- right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter((d) => !(columnIds != null && columnIds.includes(d)))
994
- };
995
- }
996
- return {
997
- left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter((d) => !(columnIds != null && columnIds.includes(d))),
998
- right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter((d) => !(columnIds != null && columnIds.includes(d)))
999
- };
1000
- });
1001
- };
1002
- column.getCanPin = () => {
1003
- const leafColumns = column.getLeafColumns();
1004
- return leafColumns.some((d) => {
1005
- var _d$columnDef$enablePi, _ref, _table$options$enable;
1006
- return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_ref = (_table$options$enable = table.options.enableColumnPinning) != null ? _table$options$enable : table.options.enablePinning) != null ? _ref : true);
1007
- });
1008
- };
1009
- column.getIsPinned = () => {
1010
- const leafColumnIds = column.getLeafColumns().map((d) => d.id);
1011
- const {
1012
- left,
1013
- right
1014
- } = table.getState().columnPinning;
1015
- const isLeft = leafColumnIds.some((d) => left == null ? void 0 : left.includes(d));
1016
- const isRight = leafColumnIds.some((d) => right == null ? void 0 : right.includes(d));
1017
- return isLeft ? "left" : isRight ? "right" : false;
1018
- };
1019
- column.getPinnedIndex = () => {
1020
- var _table$getState$colum, _table$getState$colum2;
1021
- const position = column.getIsPinned();
1022
- return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
1023
- };
1024
- },
1025
- createRow: (row, table) => {
1026
- row.getCenterVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
1027
- const leftAndRight = [...left != null ? left : [], ...right != null ? right : []];
1028
- return allCells.filter((d) => !leftAndRight.includes(d.column.id));
1029
- }, getMemoOptions(table.options, "debugRows"));
1030
- row.getLeftVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
1031
- const cells = (left != null ? left : []).map((columnId) => allCells.find((cell) => cell.column.id === columnId)).filter(Boolean).map((d) => ({
1032
- ...d,
1033
- position: "left"
1034
- }));
1035
- return cells;
1036
- }, getMemoOptions(table.options, "debugRows"));
1037
- row.getRightVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
1038
- const cells = (right != null ? right : []).map((columnId) => allCells.find((cell) => cell.column.id === columnId)).filter(Boolean).map((d) => ({
1039
- ...d,
1040
- position: "right"
1041
- }));
1042
- return cells;
1043
- }, getMemoOptions(table.options, "debugRows"));
1044
- },
1045
- createTable: (table) => {
1046
- table.setColumnPinning = (updater) => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
1047
- table.resetColumnPinning = (defaultState) => {
1048
- var _table$initialState$c, _table$initialState;
1049
- return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
1050
- };
1051
- table.getIsSomeColumnsPinned = (position) => {
1052
- var _pinningState$positio;
1053
- const pinningState = table.getState().columnPinning;
1054
- if (!position) {
1055
- var _pinningState$left, _pinningState$right;
1056
- return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1057
- }
1058
- return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1059
- };
1060
- table.getLeftLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
1061
- return (left != null ? left : []).map((columnId) => allColumns.find((column) => column.id === columnId)).filter(Boolean);
1062
- }, getMemoOptions(table.options, "debugColumns"));
1063
- table.getRightLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
1064
- return (right != null ? right : []).map((columnId) => allColumns.find((column) => column.id === columnId)).filter(Boolean);
1065
- }, getMemoOptions(table.options, "debugColumns"));
1066
- table.getCenterLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
1067
- const leftAndRight = [...left != null ? left : [], ...right != null ? right : []];
1068
- return allColumns.filter((d) => !leftAndRight.includes(d.id));
1069
- }, getMemoOptions(table.options, "debugColumns"));
1070
- }
1071
- };
1072
- const defaultColumnSizing = {
1073
- size: 150,
1074
- minSize: 20,
1075
- maxSize: Number.MAX_SAFE_INTEGER
1076
- };
1077
- const getDefaultColumnSizingInfoState = () => ({
1078
- startOffset: null,
1079
- startSize: null,
1080
- deltaOffset: null,
1081
- deltaPercentage: null,
1082
- isResizingColumn: false,
1083
- columnSizingStart: []
1084
- });
1085
- const ColumnSizing = {
1086
- getDefaultColumnDef: () => {
1087
- return defaultColumnSizing;
1088
- },
1089
- getInitialState: (state) => {
1090
- return {
1091
- columnSizing: {},
1092
- columnSizingInfo: getDefaultColumnSizingInfoState(),
1093
- ...state
1094
- };
1095
- },
1096
- getDefaultOptions: (table) => {
1097
- return {
1098
- columnResizeMode: "onEnd",
1099
- columnResizeDirection: "ltr",
1100
- onColumnSizingChange: makeStateUpdater("columnSizing", table),
1101
- onColumnSizingInfoChange: makeStateUpdater("columnSizingInfo", table)
1102
- };
1103
- },
1104
- createColumn: (column, table) => {
1105
- column.getSize = () => {
1106
- var _column$columnDef$min, _ref, _column$columnDef$max;
1107
- const columnSize = table.getState().columnSizing[column.id];
1108
- return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
1109
- };
1110
- column.getStart = memo((position) => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(0, column.getIndex(position)).reduce((sum2, column2) => sum2 + column2.getSize(), 0), getMemoOptions(table.options, "debugColumns"));
1111
- column.getAfter = memo((position) => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum2, column2) => sum2 + column2.getSize(), 0), getMemoOptions(table.options, "debugColumns"));
1112
- column.resetSize = () => {
1113
- table.setColumnSizing((_ref2) => {
1114
- let {
1115
- [column.id]: _,
1116
- ...rest
1117
- } = _ref2;
1118
- return rest;
1119
- });
1120
- };
1121
- column.getCanResize = () => {
1122
- var _column$columnDef$ena, _table$options$enable;
1123
- return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
1124
- };
1125
- column.getIsResizing = () => {
1126
- return table.getState().columnSizingInfo.isResizingColumn === column.id;
1127
- };
1128
- },
1129
- createHeader: (header, table) => {
1130
- header.getSize = () => {
1131
- let sum2 = 0;
1132
- const recurse = (header2) => {
1133
- if (header2.subHeaders.length) {
1134
- header2.subHeaders.forEach(recurse);
1135
- } else {
1136
- var _header$column$getSiz;
1137
- sum2 += (_header$column$getSiz = header2.column.getSize()) != null ? _header$column$getSiz : 0;
1138
- }
1139
- };
1140
- recurse(header);
1141
- return sum2;
1142
- };
1143
- header.getStart = () => {
1144
- if (header.index > 0) {
1145
- const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
1146
- return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
1147
- }
1148
- return 0;
1149
- };
1150
- header.getResizeHandler = (_contextDocument) => {
1151
- const column = table.getColumn(header.column.id);
1152
- const canResize = column == null ? void 0 : column.getCanResize();
1153
- return (e) => {
1154
- if (!column || !canResize) {
1155
- return;
1156
- }
1157
- e.persist == null || e.persist();
1158
- if (isTouchStartEvent(e)) {
1159
- if (e.touches && e.touches.length > 1) {
1160
- return;
1161
- }
1162
- }
1163
- const startSize = header.getSize();
1164
- const columnSizingStart = header ? header.getLeafHeaders().map((d) => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
1165
- const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
1166
- const newColumnSizing = {};
1167
- const updateOffset = (eventType, clientXPos) => {
1168
- if (typeof clientXPos !== "number") {
1169
- return;
1170
- }
1171
- table.setColumnSizingInfo((old) => {
1172
- var _old$startOffset, _old$startSize;
1173
- const deltaDirection = table.options.columnResizeDirection === "rtl" ? -1 : 1;
1174
- const deltaOffset = (clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0)) * deltaDirection;
1175
- const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
1176
- old.columnSizingStart.forEach((_ref3) => {
1177
- let [columnId, headerSize] = _ref3;
1178
- newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
1179
- });
1180
- return {
1181
- ...old,
1182
- deltaOffset,
1183
- deltaPercentage
1184
- };
1185
- });
1186
- if (table.options.columnResizeMode === "onChange" || eventType === "end") {
1187
- table.setColumnSizing((old) => ({
1188
- ...old,
1189
- ...newColumnSizing
1190
- }));
1191
- }
1192
- };
1193
- const onMove = (clientXPos) => updateOffset("move", clientXPos);
1194
- const onEnd = (clientXPos) => {
1195
- updateOffset("end", clientXPos);
1196
- table.setColumnSizingInfo((old) => ({
1197
- ...old,
1198
- isResizingColumn: false,
1199
- startOffset: null,
1200
- startSize: null,
1201
- deltaOffset: null,
1202
- deltaPercentage: null,
1203
- columnSizingStart: []
1204
- }));
1205
- };
1206
- const contextDocument = _contextDocument || typeof document !== "undefined" ? document : null;
1207
- const mouseEvents = {
1208
- moveHandler: (e2) => onMove(e2.clientX),
1209
- upHandler: (e2) => {
1210
- contextDocument == null || contextDocument.removeEventListener("mousemove", mouseEvents.moveHandler);
1211
- contextDocument == null || contextDocument.removeEventListener("mouseup", mouseEvents.upHandler);
1212
- onEnd(e2.clientX);
1213
- }
1214
- };
1215
- const touchEvents = {
1216
- moveHandler: (e2) => {
1217
- if (e2.cancelable) {
1218
- e2.preventDefault();
1219
- e2.stopPropagation();
1220
- }
1221
- onMove(e2.touches[0].clientX);
1222
- return false;
1223
- },
1224
- upHandler: (e2) => {
1225
- var _e$touches$;
1226
- contextDocument == null || contextDocument.removeEventListener("touchmove", touchEvents.moveHandler);
1227
- contextDocument == null || contextDocument.removeEventListener("touchend", touchEvents.upHandler);
1228
- if (e2.cancelable) {
1229
- e2.preventDefault();
1230
- e2.stopPropagation();
1231
- }
1232
- onEnd((_e$touches$ = e2.touches[0]) == null ? void 0 : _e$touches$.clientX);
1233
- }
1234
- };
1235
- const passiveIfSupported = passiveEventSupported() ? {
1236
- passive: false
1237
- } : false;
1238
- if (isTouchStartEvent(e)) {
1239
- contextDocument == null || contextDocument.addEventListener("touchmove", touchEvents.moveHandler, passiveIfSupported);
1240
- contextDocument == null || contextDocument.addEventListener("touchend", touchEvents.upHandler, passiveIfSupported);
1241
- } else {
1242
- contextDocument == null || contextDocument.addEventListener("mousemove", mouseEvents.moveHandler, passiveIfSupported);
1243
- contextDocument == null || contextDocument.addEventListener("mouseup", mouseEvents.upHandler, passiveIfSupported);
1244
- }
1245
- table.setColumnSizingInfo((old) => ({
1246
- ...old,
1247
- startOffset: clientX,
1248
- startSize,
1249
- deltaOffset: 0,
1250
- deltaPercentage: 0,
1251
- columnSizingStart,
1252
- isResizingColumn: column.id
1253
- }));
1254
- };
1255
- };
1256
- },
1257
- createTable: (table) => {
1258
- table.setColumnSizing = (updater) => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater);
1259
- table.setColumnSizingInfo = (updater) => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater);
1260
- table.resetColumnSizing = (defaultState) => {
1261
- var _table$initialState$c;
1262
- table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
1263
- };
1264
- table.resetHeaderSizeInfo = (defaultState) => {
1265
- var _table$initialState$c2;
1266
- table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
1267
- };
1268
- table.getTotalSize = () => {
1269
- var _table$getHeaderGroup, _table$getHeaderGroup2;
1270
- return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum2, header) => {
1271
- return sum2 + header.getSize();
1272
- }, 0)) != null ? _table$getHeaderGroup : 0;
1273
- };
1274
- table.getLeftTotalSize = () => {
1275
- var _table$getLeftHeaderG, _table$getLeftHeaderG2;
1276
- return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum2, header) => {
1277
- return sum2 + header.getSize();
1278
- }, 0)) != null ? _table$getLeftHeaderG : 0;
1279
- };
1280
- table.getCenterTotalSize = () => {
1281
- var _table$getCenterHeade, _table$getCenterHeade2;
1282
- return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum2, header) => {
1283
- return sum2 + header.getSize();
1284
- }, 0)) != null ? _table$getCenterHeade : 0;
1285
- };
1286
- table.getRightTotalSize = () => {
1287
- var _table$getRightHeader, _table$getRightHeader2;
1288
- return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum2, header) => {
1289
- return sum2 + header.getSize();
1290
- }, 0)) != null ? _table$getRightHeader : 0;
1291
- };
1292
- }
1293
- };
1294
- let passiveSupported = null;
1295
- function passiveEventSupported() {
1296
- if (typeof passiveSupported === "boolean") return passiveSupported;
1297
- let supported = false;
1298
- try {
1299
- const options = {
1300
- get passive() {
1301
- supported = true;
1302
- return false;
1303
- }
1304
- };
1305
- const noop2 = () => {
1306
- };
1307
- window.addEventListener("test", noop2, options);
1308
- window.removeEventListener("test", noop2);
1309
- } catch (err) {
1310
- supported = false;
1311
- }
1312
- passiveSupported = supported;
1313
- return passiveSupported;
1314
- }
1315
- function isTouchStartEvent(e) {
1316
- return e.type === "touchstart";
1317
- }
1318
- const ColumnVisibility = {
1319
- getInitialState: (state) => {
1320
- return {
1321
- columnVisibility: {},
1322
- ...state
1323
- };
1324
- },
1325
- getDefaultOptions: (table) => {
1326
- return {
1327
- onColumnVisibilityChange: makeStateUpdater("columnVisibility", table)
1328
- };
1329
- },
1330
- createColumn: (column, table) => {
1331
- column.toggleVisibility = (value) => {
1332
- if (column.getCanHide()) {
1333
- table.setColumnVisibility((old) => ({
1334
- ...old,
1335
- [column.id]: value != null ? value : !column.getIsVisible()
1336
- }));
1337
- }
1338
- };
1339
- column.getIsVisible = () => {
1340
- var _ref, _table$getState$colum;
1341
- const childColumns = column.columns;
1342
- return (_ref = childColumns.length ? childColumns.some((c) => c.getIsVisible()) : (_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) != null ? _ref : true;
1343
- };
1344
- column.getCanHide = () => {
1345
- var _column$columnDef$ena, _table$options$enable;
1346
- return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
1347
- };
1348
- column.getToggleVisibilityHandler = () => {
1349
- return (e) => {
1350
- column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
1351
- };
1352
- };
1353
- },
1354
- createRow: (row, table) => {
1355
- row._getAllVisibleCells = memo(() => [row.getAllCells(), table.getState().columnVisibility], (cells) => {
1356
- return cells.filter((cell) => cell.column.getIsVisible());
1357
- }, getMemoOptions(table.options, "debugRows"));
1358
- row.getVisibleCells = memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, "debugRows"));
1359
- },
1360
- createTable: (table) => {
1361
- const makeVisibleColumnsMethod = (key, getColumns) => {
1362
- return memo(() => [getColumns(), getColumns().filter((d) => d.getIsVisible()).map((d) => d.id).join("_")], (columns) => {
1363
- return columns.filter((d) => d.getIsVisible == null ? void 0 : d.getIsVisible());
1364
- }, getMemoOptions(table.options, "debugColumns"));
1365
- };
1366
- table.getVisibleFlatColumns = makeVisibleColumnsMethod("getVisibleFlatColumns", () => table.getAllFlatColumns());
1367
- table.getVisibleLeafColumns = makeVisibleColumnsMethod("getVisibleLeafColumns", () => table.getAllLeafColumns());
1368
- table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod("getLeftVisibleLeafColumns", () => table.getLeftLeafColumns());
1369
- table.getRightVisibleLeafColumns = makeVisibleColumnsMethod("getRightVisibleLeafColumns", () => table.getRightLeafColumns());
1370
- table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod("getCenterVisibleLeafColumns", () => table.getCenterLeafColumns());
1371
- table.setColumnVisibility = (updater) => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
1372
- table.resetColumnVisibility = (defaultState) => {
1373
- var _table$initialState$c;
1374
- table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
1375
- };
1376
- table.toggleAllColumnsVisible = (value) => {
1377
- var _value;
1378
- value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
1379
- table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
1380
- ...obj,
1381
- [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
1382
- }), {}));
1383
- };
1384
- table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some((column) => !(column.getIsVisible != null && column.getIsVisible()));
1385
- table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some((column) => column.getIsVisible == null ? void 0 : column.getIsVisible());
1386
- table.getToggleAllColumnsVisibilityHandler = () => {
1387
- return (e) => {
1388
- var _target;
1389
- table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
1390
- };
1391
- };
1392
- }
1393
- };
1394
- function _getVisibleLeafColumns(table, position) {
1395
- return !position ? table.getVisibleLeafColumns() : position === "center" ? table.getCenterVisibleLeafColumns() : position === "left" ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
1396
- }
1397
- const GlobalFaceting = {
1398
- createTable: (table) => {
1399
- table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, "__global__");
1400
- table.getGlobalFacetedRowModel = () => {
1401
- if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
1402
- return table.getPreFilteredRowModel();
1403
- }
1404
- return table._getGlobalFacetedRowModel();
1405
- };
1406
- table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, "__global__");
1407
- table.getGlobalFacetedUniqueValues = () => {
1408
- if (!table._getGlobalFacetedUniqueValues) {
1409
- return /* @__PURE__ */ new Map();
1410
- }
1411
- return table._getGlobalFacetedUniqueValues();
1412
- };
1413
- table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, "__global__");
1414
- table.getGlobalFacetedMinMaxValues = () => {
1415
- if (!table._getGlobalFacetedMinMaxValues) {
1416
- return;
1417
- }
1418
- return table._getGlobalFacetedMinMaxValues();
1419
- };
1420
- }
1421
- };
1422
- const GlobalFiltering = {
1423
- getInitialState: (state) => {
1424
- return {
1425
- globalFilter: void 0,
1426
- ...state
1427
- };
1428
- },
1429
- getDefaultOptions: (table) => {
1430
- return {
1431
- onGlobalFilterChange: makeStateUpdater("globalFilter", table),
1432
- globalFilterFn: "auto",
1433
- getColumnCanGlobalFilter: (column) => {
1434
- var _table$getCoreRowMode;
1435
- const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
1436
- return typeof value === "string" || typeof value === "number";
1437
- }
1438
- };
1439
- },
1440
- createColumn: (column, table) => {
1441
- column.getCanGlobalFilter = () => {
1442
- var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol;
1443
- return ((_column$columnDef$ena = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGlobalFilter) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
1444
- };
1445
- },
1446
- createTable: (table) => {
1447
- table.getGlobalAutoFilterFn = () => {
1448
- return filterFns.includesString;
1449
- };
1450
- table.getGlobalFilterFn = () => {
1451
- var _table$options$filter, _table$options$filter2;
1452
- const {
1453
- globalFilterFn
1454
- } = table.options;
1455
- return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === "auto" ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns[globalFilterFn];
1456
- };
1457
- table.setGlobalFilter = (updater) => {
1458
- table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
1459
- };
1460
- table.resetGlobalFilter = (defaultState) => {
1461
- table.setGlobalFilter(defaultState ? void 0 : table.initialState.globalFilter);
1462
- };
1463
- }
1464
- };
1465
- const RowExpanding = {
1466
- getInitialState: (state) => {
1467
- return {
1468
- expanded: {},
1469
- ...state
1470
- };
1471
- },
1472
- getDefaultOptions: (table) => {
1473
- return {
1474
- onExpandedChange: makeStateUpdater("expanded", table),
1475
- paginateExpandedRows: true
1476
- };
1477
- },
1478
- createTable: (table) => {
1479
- let registered = false;
1480
- let queued = false;
1481
- table._autoResetExpanded = () => {
1482
- var _ref, _table$options$autoRe;
1483
- if (!registered) {
1484
- table._queue(() => {
1485
- registered = true;
1486
- });
1487
- return;
1488
- }
1489
- if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
1490
- if (queued) return;
1491
- queued = true;
1492
- table._queue(() => {
1493
- table.resetExpanded();
1494
- queued = false;
1495
- });
1496
- }
1497
- };
1498
- table.setExpanded = (updater) => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
1499
- table.toggleAllRowsExpanded = (expanded) => {
1500
- if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
1501
- table.setExpanded(true);
1502
- } else {
1503
- table.setExpanded({});
1504
- }
1505
- };
1506
- table.resetExpanded = (defaultState) => {
1507
- var _table$initialState$e, _table$initialState;
1508
- table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
1509
- };
1510
- table.getCanSomeRowsExpand = () => {
1511
- return table.getPrePaginationRowModel().flatRows.some((row) => row.getCanExpand());
1512
- };
1513
- table.getToggleAllRowsExpandedHandler = () => {
1514
- return (e) => {
1515
- e.persist == null || e.persist();
1516
- table.toggleAllRowsExpanded();
1517
- };
1518
- };
1519
- table.getIsSomeRowsExpanded = () => {
1520
- const expanded = table.getState().expanded;
1521
- return expanded === true || Object.values(expanded).some(Boolean);
1522
- };
1523
- table.getIsAllRowsExpanded = () => {
1524
- const expanded = table.getState().expanded;
1525
- if (typeof expanded === "boolean") {
1526
- return expanded === true;
1527
- }
1528
- if (!Object.keys(expanded).length) {
1529
- return false;
1530
- }
1531
- if (table.getRowModel().flatRows.some((row) => !row.getIsExpanded())) {
1532
- return false;
1533
- }
1534
- return true;
1535
- };
1536
- table.getExpandedDepth = () => {
1537
- let maxDepth = 0;
1538
- const rowIds = table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded);
1539
- rowIds.forEach((id) => {
1540
- const splitId = id.split(".");
1541
- maxDepth = Math.max(maxDepth, splitId.length);
1542
- });
1543
- return maxDepth;
1544
- };
1545
- table.getPreExpandedRowModel = () => table.getSortedRowModel();
1546
- table.getExpandedRowModel = () => {
1547
- if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
1548
- table._getExpandedRowModel = table.options.getExpandedRowModel(table);
1549
- }
1550
- if (table.options.manualExpanding || !table._getExpandedRowModel) {
1551
- return table.getPreExpandedRowModel();
1552
- }
1553
- return table._getExpandedRowModel();
1554
- };
1555
- },
1556
- createRow: (row, table) => {
1557
- row.toggleExpanded = (expanded) => {
1558
- table.setExpanded((old) => {
1559
- var _expanded;
1560
- const exists = old === true ? true : !!(old != null && old[row.id]);
1561
- let oldExpanded = {};
1562
- if (old === true) {
1563
- Object.keys(table.getRowModel().rowsById).forEach((rowId) => {
1564
- oldExpanded[rowId] = true;
1565
- });
1566
- } else {
1567
- oldExpanded = old;
1568
- }
1569
- expanded = (_expanded = expanded) != null ? _expanded : !exists;
1570
- if (!exists && expanded) {
1571
- return {
1572
- ...oldExpanded,
1573
- [row.id]: true
1574
- };
1575
- }
1576
- if (exists && !expanded) {
1577
- const {
1578
- [row.id]: _,
1579
- ...rest
1580
- } = oldExpanded;
1581
- return rest;
1582
- }
1583
- return old;
1584
- });
1585
- };
1586
- row.getIsExpanded = () => {
1587
- var _table$options$getIsR;
1588
- const expanded = table.getState().expanded;
1589
- return !!((_table$options$getIsR = table.options.getIsRowExpanded == null ? void 0 : table.options.getIsRowExpanded(row)) != null ? _table$options$getIsR : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
1590
- };
1591
- row.getCanExpand = () => {
1592
- var _table$options$getRow, _table$options$enable, _row$subRows;
1593
- return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
1594
- };
1595
- row.getIsAllParentsExpanded = () => {
1596
- let isFullyExpanded = true;
1597
- let currentRow = row;
1598
- while (isFullyExpanded && currentRow.parentId) {
1599
- currentRow = table.getRow(currentRow.parentId, true);
1600
- isFullyExpanded = currentRow.getIsExpanded();
1601
- }
1602
- return isFullyExpanded;
1603
- };
1604
- row.getToggleExpandedHandler = () => {
1605
- const canExpand = row.getCanExpand();
1606
- return () => {
1607
- if (!canExpand) return;
1608
- row.toggleExpanded();
1609
- };
1610
- };
1611
- }
1612
- };
1613
- const defaultPageIndex = 0;
1614
- const defaultPageSize = 10;
1615
- const getDefaultPaginationState = () => ({
1616
- pageIndex: defaultPageIndex,
1617
- pageSize: defaultPageSize
1618
- });
1619
- const RowPagination = {
1620
- getInitialState: (state) => {
1621
- return {
1622
- ...state,
1623
- pagination: {
1624
- ...getDefaultPaginationState(),
1625
- ...state == null ? void 0 : state.pagination
1626
- }
1627
- };
1628
- },
1629
- getDefaultOptions: (table) => {
1630
- return {
1631
- onPaginationChange: makeStateUpdater("pagination", table)
1632
- };
1633
- },
1634
- createTable: (table) => {
1635
- let registered = false;
1636
- let queued = false;
1637
- table._autoResetPageIndex = () => {
1638
- var _ref, _table$options$autoRe;
1639
- if (!registered) {
1640
- table._queue(() => {
1641
- registered = true;
1642
- });
1643
- return;
1644
- }
1645
- if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetPageIndex) != null ? _ref : !table.options.manualPagination) {
1646
- if (queued) return;
1647
- queued = true;
1648
- table._queue(() => {
1649
- table.resetPageIndex();
1650
- queued = false;
1651
- });
1652
- }
1653
- };
1654
- table.setPagination = (updater) => {
1655
- const safeUpdater = (old) => {
1656
- let newState = functionalUpdate(updater, old);
1657
- return newState;
1658
- };
1659
- return table.options.onPaginationChange == null ? void 0 : table.options.onPaginationChange(safeUpdater);
1660
- };
1661
- table.resetPagination = (defaultState) => {
1662
- var _table$initialState$p;
1663
- table.setPagination(defaultState ? getDefaultPaginationState() : (_table$initialState$p = table.initialState.pagination) != null ? _table$initialState$p : getDefaultPaginationState());
1664
- };
1665
- table.setPageIndex = (updater) => {
1666
- table.setPagination((old) => {
1667
- let pageIndex = functionalUpdate(updater, old.pageIndex);
1668
- const maxPageIndex = typeof table.options.pageCount === "undefined" || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
1669
- pageIndex = Math.max(0, Math.min(pageIndex, maxPageIndex));
1670
- return {
1671
- ...old,
1672
- pageIndex
1673
- };
1674
- });
1675
- };
1676
- table.resetPageIndex = (defaultState) => {
1677
- var _table$initialState$p2, _table$initialState;
1678
- table.setPageIndex(defaultState ? defaultPageIndex : (_table$initialState$p2 = (_table$initialState = table.initialState) == null || (_table$initialState = _table$initialState.pagination) == null ? void 0 : _table$initialState.pageIndex) != null ? _table$initialState$p2 : defaultPageIndex);
1679
- };
1680
- table.resetPageSize = (defaultState) => {
1681
- var _table$initialState$p3, _table$initialState2;
1682
- table.setPageSize(defaultState ? defaultPageSize : (_table$initialState$p3 = (_table$initialState2 = table.initialState) == null || (_table$initialState2 = _table$initialState2.pagination) == null ? void 0 : _table$initialState2.pageSize) != null ? _table$initialState$p3 : defaultPageSize);
1683
- };
1684
- table.setPageSize = (updater) => {
1685
- table.setPagination((old) => {
1686
- const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
1687
- const topRowIndex = old.pageSize * old.pageIndex;
1688
- const pageIndex = Math.floor(topRowIndex / pageSize);
1689
- return {
1690
- ...old,
1691
- pageIndex,
1692
- pageSize
1693
- };
1694
- });
1695
- };
1696
- table.setPageCount = (updater) => table.setPagination((old) => {
1697
- var _table$options$pageCo;
1698
- let newPageCount = functionalUpdate(updater, (_table$options$pageCo = table.options.pageCount) != null ? _table$options$pageCo : -1);
1699
- if (typeof newPageCount === "number") {
1700
- newPageCount = Math.max(-1, newPageCount);
1701
- }
1702
- return {
1703
- ...old,
1704
- pageCount: newPageCount
1705
- };
1706
- });
1707
- table.getPageOptions = memo(() => [table.getPageCount()], (pageCount) => {
1708
- let pageOptions = [];
1709
- if (pageCount && pageCount > 0) {
1710
- pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
1711
- }
1712
- return pageOptions;
1713
- }, getMemoOptions(table.options, "debugTable"));
1714
- table.getCanPreviousPage = () => table.getState().pagination.pageIndex > 0;
1715
- table.getCanNextPage = () => {
1716
- const {
1717
- pageIndex
1718
- } = table.getState().pagination;
1719
- const pageCount = table.getPageCount();
1720
- if (pageCount === -1) {
1721
- return true;
1722
- }
1723
- if (pageCount === 0) {
1724
- return false;
1725
- }
1726
- return pageIndex < pageCount - 1;
1727
- };
1728
- table.previousPage = () => {
1729
- return table.setPageIndex((old) => old - 1);
1730
- };
1731
- table.nextPage = () => {
1732
- return table.setPageIndex((old) => {
1733
- return old + 1;
1734
- });
1735
- };
1736
- table.firstPage = () => {
1737
- return table.setPageIndex(0);
1738
- };
1739
- table.lastPage = () => {
1740
- return table.setPageIndex(table.getPageCount() - 1);
1741
- };
1742
- table.getPrePaginationRowModel = () => table.getExpandedRowModel();
1743
- table.getPaginationRowModel = () => {
1744
- if (!table._getPaginationRowModel && table.options.getPaginationRowModel) {
1745
- table._getPaginationRowModel = table.options.getPaginationRowModel(table);
1746
- }
1747
- if (table.options.manualPagination || !table._getPaginationRowModel) {
1748
- return table.getPrePaginationRowModel();
1749
- }
1750
- return table._getPaginationRowModel();
1751
- };
1752
- table.getPageCount = () => {
1753
- var _table$options$pageCo2;
1754
- return (_table$options$pageCo2 = table.options.pageCount) != null ? _table$options$pageCo2 : Math.ceil(table.getRowCount() / table.getState().pagination.pageSize);
1755
- };
1756
- table.getRowCount = () => {
1757
- var _table$options$rowCou;
1758
- return (_table$options$rowCou = table.options.rowCount) != null ? _table$options$rowCou : table.getPrePaginationRowModel().rows.length;
1759
- };
1760
- }
1761
- };
1762
- const getDefaultRowPinningState = () => ({
1763
- top: [],
1764
- bottom: []
1765
- });
1766
- const RowPinning = {
1767
- getInitialState: (state) => {
1768
- return {
1769
- rowPinning: getDefaultRowPinningState(),
1770
- ...state
1771
- };
1772
- },
1773
- getDefaultOptions: (table) => {
1774
- return {
1775
- onRowPinningChange: makeStateUpdater("rowPinning", table)
1776
- };
1777
- },
1778
- createRow: (row, table) => {
1779
- row.pin = (position, includeLeafRows, includeParentRows) => {
1780
- const leafRowIds = includeLeafRows ? row.getLeafRows().map((_ref) => {
1781
- let {
1782
- id
1783
- } = _ref;
1784
- return id;
1785
- }) : [];
1786
- const parentRowIds = includeParentRows ? row.getParentRows().map((_ref2) => {
1787
- let {
1788
- id
1789
- } = _ref2;
1790
- return id;
1791
- }) : [];
1792
- const rowIds = /* @__PURE__ */ new Set([...parentRowIds, row.id, ...leafRowIds]);
1793
- table.setRowPinning((old) => {
1794
- var _old$top3, _old$bottom3;
1795
- if (position === "bottom") {
1796
- var _old$top, _old$bottom;
1797
- return {
1798
- top: ((_old$top = old == null ? void 0 : old.top) != null ? _old$top : []).filter((d) => !(rowIds != null && rowIds.has(d))),
1799
- bottom: [...((_old$bottom = old == null ? void 0 : old.bottom) != null ? _old$bottom : []).filter((d) => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)]
1800
- };
1801
- }
1802
- if (position === "top") {
1803
- var _old$top2, _old$bottom2;
1804
- return {
1805
- top: [...((_old$top2 = old == null ? void 0 : old.top) != null ? _old$top2 : []).filter((d) => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)],
1806
- bottom: ((_old$bottom2 = old == null ? void 0 : old.bottom) != null ? _old$bottom2 : []).filter((d) => !(rowIds != null && rowIds.has(d)))
1807
- };
1808
- }
1809
- return {
1810
- top: ((_old$top3 = old == null ? void 0 : old.top) != null ? _old$top3 : []).filter((d) => !(rowIds != null && rowIds.has(d))),
1811
- bottom: ((_old$bottom3 = old == null ? void 0 : old.bottom) != null ? _old$bottom3 : []).filter((d) => !(rowIds != null && rowIds.has(d)))
1812
- };
1813
- });
1814
- };
1815
- row.getCanPin = () => {
1816
- var _ref3;
1817
- const {
1818
- enableRowPinning,
1819
- enablePinning
1820
- } = table.options;
1821
- if (typeof enableRowPinning === "function") {
1822
- return enableRowPinning(row);
1823
- }
1824
- return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
1825
- };
1826
- row.getIsPinned = () => {
1827
- const rowIds = [row.id];
1828
- const {
1829
- top,
1830
- bottom
1831
- } = table.getState().rowPinning;
1832
- const isTop = rowIds.some((d) => top == null ? void 0 : top.includes(d));
1833
- const isBottom = rowIds.some((d) => bottom == null ? void 0 : bottom.includes(d));
1834
- return isTop ? "top" : isBottom ? "bottom" : false;
1835
- };
1836
- row.getPinnedIndex = () => {
1837
- var _ref4, _visiblePinnedRowIds$;
1838
- const position = row.getIsPinned();
1839
- if (!position) return -1;
1840
- const visiblePinnedRowIds = (_ref4 = position === "top" ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map((_ref5) => {
1841
- let {
1842
- id
1843
- } = _ref5;
1844
- return id;
1845
- });
1846
- return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
1847
- };
1848
- },
1849
- createTable: (table) => {
1850
- table.setRowPinning = (updater) => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
1851
- table.resetRowPinning = (defaultState) => {
1852
- var _table$initialState$r, _table$initialState;
1853
- return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
1854
- };
1855
- table.getIsSomeRowsPinned = (position) => {
1856
- var _pinningState$positio;
1857
- const pinningState = table.getState().rowPinning;
1858
- if (!position) {
1859
- var _pinningState$top, _pinningState$bottom;
1860
- return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
1861
- }
1862
- return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1863
- };
1864
- table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
1865
- var _table$options$keepPi;
1866
- const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ? (
1867
- //get all rows that are pinned even if they would not be otherwise visible
1868
- //account for expanded parent rows, but not pagination or filtering
1869
- (pinnedRowIds != null ? pinnedRowIds : []).map((rowId) => {
1870
- const row = table.getRow(rowId, true);
1871
- return row.getIsAllParentsExpanded() ? row : null;
1872
- })
1873
- ) : (
1874
- //else get only visible rows that are pinned
1875
- (pinnedRowIds != null ? pinnedRowIds : []).map((rowId) => visibleRows.find((row) => row.id === rowId))
1876
- );
1877
- return rows.filter(Boolean).map((d) => ({
1878
- ...d,
1879
- position
1880
- }));
1881
- };
1882
- table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, "top"), getMemoOptions(table.options, "debugRows"));
1883
- table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, "bottom"), getMemoOptions(table.options, "debugRows"));
1884
- table.getCenterRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
1885
- const topAndBottom = /* @__PURE__ */ new Set([...top != null ? top : [], ...bottom != null ? bottom : []]);
1886
- return allRows.filter((d) => !topAndBottom.has(d.id));
1887
- }, getMemoOptions(table.options, "debugRows"));
1888
- }
1889
- };
1890
- const RowSelection = {
1891
- getInitialState: (state) => {
1892
- return {
1893
- rowSelection: {},
1894
- ...state
1895
- };
1896
- },
1897
- getDefaultOptions: (table) => {
1898
- return {
1899
- onRowSelectionChange: makeStateUpdater("rowSelection", table),
1900
- enableRowSelection: true,
1901
- enableMultiRowSelection: true,
1902
- enableSubRowSelection: true
1903
- // enableGroupingRowSelection: false,
1904
- // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
1905
- // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
1906
- };
1907
- },
1908
- createTable: (table) => {
1909
- table.setRowSelection = (updater) => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater);
1910
- table.resetRowSelection = (defaultState) => {
1911
- var _table$initialState$r;
1912
- return table.setRowSelection(defaultState ? {} : (_table$initialState$r = table.initialState.rowSelection) != null ? _table$initialState$r : {});
1913
- };
1914
- table.toggleAllRowsSelected = (value) => {
1915
- table.setRowSelection((old) => {
1916
- value = typeof value !== "undefined" ? value : !table.getIsAllRowsSelected();
1917
- const rowSelection = {
1918
- ...old
1919
- };
1920
- const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
1921
- if (value) {
1922
- preGroupedFlatRows.forEach((row) => {
1923
- if (!row.getCanSelect()) {
1924
- return;
1925
- }
1926
- rowSelection[row.id] = true;
1927
- });
1928
- } else {
1929
- preGroupedFlatRows.forEach((row) => {
1930
- delete rowSelection[row.id];
1931
- });
1932
- }
1933
- return rowSelection;
1934
- });
1935
- };
1936
- table.toggleAllPageRowsSelected = (value) => table.setRowSelection((old) => {
1937
- const resolvedValue = typeof value !== "undefined" ? value : !table.getIsAllPageRowsSelected();
1938
- const rowSelection = {
1939
- ...old
1940
- };
1941
- table.getRowModel().rows.forEach((row) => {
1942
- mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
1943
- });
1944
- return rowSelection;
1945
- });
1946
- table.getPreSelectedRowModel = () => table.getCoreRowModel();
1947
- table.getSelectedRowModel = memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
1948
- if (!Object.keys(rowSelection).length) {
1949
- return {
1950
- rows: [],
1951
- flatRows: [],
1952
- rowsById: {}
1953
- };
1954
- }
1955
- return selectRowsFn(table, rowModel);
1956
- }, getMemoOptions(table.options, "debugTable"));
1957
- table.getFilteredSelectedRowModel = memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
1958
- if (!Object.keys(rowSelection).length) {
1959
- return {
1960
- rows: [],
1961
- flatRows: [],
1962
- rowsById: {}
1963
- };
1964
- }
1965
- return selectRowsFn(table, rowModel);
1966
- }, getMemoOptions(table.options, "debugTable"));
1967
- table.getGroupedSelectedRowModel = memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
1968
- if (!Object.keys(rowSelection).length) {
1969
- return {
1970
- rows: [],
1971
- flatRows: [],
1972
- rowsById: {}
1973
- };
1974
- }
1975
- return selectRowsFn(table, rowModel);
1976
- }, getMemoOptions(table.options, "debugTable"));
1977
- table.getIsAllRowsSelected = () => {
1978
- const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
1979
- const {
1980
- rowSelection
1981
- } = table.getState();
1982
- let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
1983
- if (isAllRowsSelected) {
1984
- if (preGroupedFlatRows.some((row) => row.getCanSelect() && !rowSelection[row.id])) {
1985
- isAllRowsSelected = false;
1986
- }
1987
- }
1988
- return isAllRowsSelected;
1989
- };
1990
- table.getIsAllPageRowsSelected = () => {
1991
- const paginationFlatRows = table.getPaginationRowModel().flatRows.filter((row) => row.getCanSelect());
1992
- const {
1993
- rowSelection
1994
- } = table.getState();
1995
- let isAllPageRowsSelected = !!paginationFlatRows.length;
1996
- if (isAllPageRowsSelected && paginationFlatRows.some((row) => !rowSelection[row.id])) {
1997
- isAllPageRowsSelected = false;
1998
- }
1999
- return isAllPageRowsSelected;
2000
- };
2001
- table.getIsSomeRowsSelected = () => {
2002
- var _table$getState$rowSe;
2003
- const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
2004
- return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
2005
- };
2006
- table.getIsSomePageRowsSelected = () => {
2007
- const paginationFlatRows = table.getPaginationRowModel().flatRows;
2008
- return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter((row) => row.getCanSelect()).some((d) => d.getIsSelected() || d.getIsSomeSelected());
2009
- };
2010
- table.getToggleAllRowsSelectedHandler = () => {
2011
- return (e) => {
2012
- table.toggleAllRowsSelected(e.target.checked);
2013
- };
2014
- };
2015
- table.getToggleAllPageRowsSelectedHandler = () => {
2016
- return (e) => {
2017
- table.toggleAllPageRowsSelected(e.target.checked);
2018
- };
2019
- };
2020
- },
2021
- createRow: (row, table) => {
2022
- row.toggleSelected = (value, opts) => {
2023
- const isSelected = row.getIsSelected();
2024
- table.setRowSelection((old) => {
2025
- var _opts$selectChildren;
2026
- value = typeof value !== "undefined" ? value : !isSelected;
2027
- if (row.getCanSelect() && isSelected === value) {
2028
- return old;
2029
- }
2030
- const selectedRowIds = {
2031
- ...old
2032
- };
2033
- mutateRowIsSelected(selectedRowIds, row.id, value, (_opts$selectChildren = opts == null ? void 0 : opts.selectChildren) != null ? _opts$selectChildren : true, table);
2034
- return selectedRowIds;
2035
- });
2036
- };
2037
- row.getIsSelected = () => {
2038
- const {
2039
- rowSelection
2040
- } = table.getState();
2041
- return isRowSelected(row, rowSelection);
2042
- };
2043
- row.getIsSomeSelected = () => {
2044
- const {
2045
- rowSelection
2046
- } = table.getState();
2047
- return isSubRowSelected(row, rowSelection) === "some";
2048
- };
2049
- row.getIsAllSubRowsSelected = () => {
2050
- const {
2051
- rowSelection
2052
- } = table.getState();
2053
- return isSubRowSelected(row, rowSelection) === "all";
2054
- };
2055
- row.getCanSelect = () => {
2056
- var _table$options$enable;
2057
- if (typeof table.options.enableRowSelection === "function") {
2058
- return table.options.enableRowSelection(row);
2059
- }
2060
- return (_table$options$enable = table.options.enableRowSelection) != null ? _table$options$enable : true;
2061
- };
2062
- row.getCanSelectSubRows = () => {
2063
- var _table$options$enable2;
2064
- if (typeof table.options.enableSubRowSelection === "function") {
2065
- return table.options.enableSubRowSelection(row);
2066
- }
2067
- return (_table$options$enable2 = table.options.enableSubRowSelection) != null ? _table$options$enable2 : true;
2068
- };
2069
- row.getCanMultiSelect = () => {
2070
- var _table$options$enable3;
2071
- if (typeof table.options.enableMultiRowSelection === "function") {
2072
- return table.options.enableMultiRowSelection(row);
2073
- }
2074
- return (_table$options$enable3 = table.options.enableMultiRowSelection) != null ? _table$options$enable3 : true;
2075
- };
2076
- row.getToggleSelectedHandler = () => {
2077
- const canSelect = row.getCanSelect();
2078
- return (e) => {
2079
- var _target;
2080
- if (!canSelect) return;
2081
- row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
2082
- };
2083
- };
2084
- }
2085
- };
2086
- const mutateRowIsSelected = (selectedRowIds, id, value, includeChildren, table) => {
2087
- var _row$subRows;
2088
- const row = table.getRow(id, true);
2089
- if (value) {
2090
- if (!row.getCanMultiSelect()) {
2091
- Object.keys(selectedRowIds).forEach((key) => delete selectedRowIds[key]);
2092
- }
2093
- if (row.getCanSelect()) {
2094
- selectedRowIds[id] = true;
2095
- }
2096
- } else {
2097
- delete selectedRowIds[id];
2098
- }
2099
- if (includeChildren && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
2100
- row.subRows.forEach((row2) => mutateRowIsSelected(selectedRowIds, row2.id, value, includeChildren, table));
2101
- }
2102
- };
2103
- function selectRowsFn(table, rowModel) {
2104
- const rowSelection = table.getState().rowSelection;
2105
- const newSelectedFlatRows = [];
2106
- const newSelectedRowsById = {};
2107
- const recurseRows = function(rows, depth) {
2108
- return rows.map((row) => {
2109
- var _row$subRows2;
2110
- const isSelected = isRowSelected(row, rowSelection);
2111
- if (isSelected) {
2112
- newSelectedFlatRows.push(row);
2113
- newSelectedRowsById[row.id] = row;
2114
- }
2115
- if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2116
- row = {
2117
- ...row,
2118
- subRows: recurseRows(row.subRows)
2119
- };
2120
- }
2121
- if (isSelected) {
2122
- return row;
2123
- }
2124
- }).filter(Boolean);
2125
- };
2126
- return {
2127
- rows: recurseRows(rowModel.rows),
2128
- flatRows: newSelectedFlatRows,
2129
- rowsById: newSelectedRowsById
2130
- };
2131
- }
2132
- function isRowSelected(row, selection) {
2133
- var _selection$row$id;
2134
- return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
2135
- }
2136
- function isSubRowSelected(row, selection, table) {
2137
- var _row$subRows3;
2138
- if (!((_row$subRows3 = row.subRows) != null && _row$subRows3.length)) return false;
2139
- let allChildrenSelected = true;
2140
- let someSelected = false;
2141
- row.subRows.forEach((subRow) => {
2142
- if (someSelected && !allChildrenSelected) {
2143
- return;
2144
- }
2145
- if (subRow.getCanSelect()) {
2146
- if (isRowSelected(subRow, selection)) {
2147
- someSelected = true;
2148
- } else {
2149
- allChildrenSelected = false;
2150
- }
2151
- }
2152
- if (subRow.subRows && subRow.subRows.length) {
2153
- const subRowChildrenSelected = isSubRowSelected(subRow, selection);
2154
- if (subRowChildrenSelected === "all") {
2155
- someSelected = true;
2156
- } else if (subRowChildrenSelected === "some") {
2157
- someSelected = true;
2158
- allChildrenSelected = false;
2159
- } else {
2160
- allChildrenSelected = false;
2161
- }
2162
- }
2163
- });
2164
- return allChildrenSelected ? "all" : someSelected ? "some" : false;
2165
- }
2166
- const reSplitAlphaNumeric = /([0-9]+)/gm;
2167
- const alphanumeric = (rowA, rowB, columnId) => {
2168
- return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2169
- };
2170
- const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
2171
- return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2172
- };
2173
- const text = (rowA, rowB, columnId) => {
2174
- return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2175
- };
2176
- const textCaseSensitive = (rowA, rowB, columnId) => {
2177
- return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2178
- };
2179
- const datetime = (rowA, rowB, columnId) => {
2180
- const a = rowA.getValue(columnId);
2181
- const b = rowB.getValue(columnId);
2182
- return a > b ? 1 : a < b ? -1 : 0;
2183
- };
2184
- const basic = (rowA, rowB, columnId) => {
2185
- return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
2186
- };
2187
- function compareBasic(a, b) {
2188
- return a === b ? 0 : a > b ? 1 : -1;
2189
- }
2190
- function toString(a) {
2191
- if (typeof a === "number") {
2192
- if (isNaN(a) || a === Infinity || a === -Infinity) {
2193
- return "";
2194
- }
2195
- return String(a);
2196
- }
2197
- if (typeof a === "string") {
2198
- return a;
2199
- }
2200
- return "";
2201
- }
2202
- function compareAlphanumeric(aStr, bStr) {
2203
- const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
2204
- const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
2205
- while (a.length && b.length) {
2206
- const aa = a.shift();
2207
- const bb = b.shift();
2208
- const an = parseInt(aa, 10);
2209
- const bn = parseInt(bb, 10);
2210
- const combo = [an, bn].sort();
2211
- if (isNaN(combo[0])) {
2212
- if (aa > bb) {
2213
- return 1;
2214
- }
2215
- if (bb > aa) {
2216
- return -1;
2217
- }
2218
- continue;
2219
- }
2220
- if (isNaN(combo[1])) {
2221
- return isNaN(an) ? -1 : 1;
2222
- }
2223
- if (an > bn) {
2224
- return 1;
2225
- }
2226
- if (bn > an) {
2227
- return -1;
2228
- }
2229
- }
2230
- return a.length - b.length;
2231
- }
2232
- const sortingFns = {
2233
- alphanumeric,
2234
- alphanumericCaseSensitive,
2235
- text,
2236
- textCaseSensitive,
2237
- datetime,
2238
- basic
2239
- };
2240
- const RowSorting = {
2241
- getInitialState: (state) => {
2242
- return {
2243
- sorting: [],
2244
- ...state
2245
- };
2246
- },
2247
- getDefaultColumnDef: () => {
2248
- return {
2249
- sortingFn: "auto",
2250
- sortUndefined: 1
2251
- };
2252
- },
2253
- getDefaultOptions: (table) => {
2254
- return {
2255
- onSortingChange: makeStateUpdater("sorting", table),
2256
- isMultiSortEvent: (e) => {
2257
- return e.shiftKey;
2258
- }
2259
- };
2260
- },
2261
- createColumn: (column, table) => {
2262
- column.getAutoSortingFn = () => {
2263
- const firstRows = table.getFilteredRowModel().flatRows.slice(10);
2264
- let isString = false;
2265
- for (const row of firstRows) {
2266
- const value = row == null ? void 0 : row.getValue(column.id);
2267
- if (Object.prototype.toString.call(value) === "[object Date]") {
2268
- return sortingFns.datetime;
2269
- }
2270
- if (typeof value === "string") {
2271
- isString = true;
2272
- if (value.split(reSplitAlphaNumeric).length > 1) {
2273
- return sortingFns.alphanumeric;
2274
- }
2275
- }
2276
- }
2277
- if (isString) {
2278
- return sortingFns.text;
2279
- }
2280
- return sortingFns.basic;
2281
- };
2282
- column.getAutoSortDir = () => {
2283
- const firstRow = table.getFilteredRowModel().flatRows[0];
2284
- const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
2285
- if (typeof value === "string") {
2286
- return "asc";
2287
- }
2288
- return "desc";
2289
- };
2290
- column.getSortingFn = () => {
2291
- var _table$options$sortin, _table$options$sortin2;
2292
- if (!column) {
2293
- throw new Error();
2294
- }
2295
- return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === "auto" ? column.getAutoSortingFn() : (_table$options$sortin = (_table$options$sortin2 = table.options.sortingFns) == null ? void 0 : _table$options$sortin2[column.columnDef.sortingFn]) != null ? _table$options$sortin : sortingFns[column.columnDef.sortingFn];
2296
- };
2297
- column.toggleSorting = (desc, multi) => {
2298
- const nextSortingOrder = column.getNextSortingOrder();
2299
- const hasManualValue = typeof desc !== "undefined" && desc !== null;
2300
- table.setSorting((old) => {
2301
- const existingSorting = old == null ? void 0 : old.find((d) => d.id === column.id);
2302
- const existingIndex = old == null ? void 0 : old.findIndex((d) => d.id === column.id);
2303
- let newSorting = [];
2304
- let sortAction;
2305
- let nextDesc = hasManualValue ? desc : nextSortingOrder === "desc";
2306
- if (old != null && old.length && column.getCanMultiSort() && multi) {
2307
- if (existingSorting) {
2308
- sortAction = "toggle";
2309
- } else {
2310
- sortAction = "add";
2311
- }
2312
- } else {
2313
- if (old != null && old.length && existingIndex !== old.length - 1) {
2314
- sortAction = "replace";
2315
- } else if (existingSorting) {
2316
- sortAction = "toggle";
2317
- } else {
2318
- sortAction = "replace";
2319
- }
2320
- }
2321
- if (sortAction === "toggle") {
2322
- if (!hasManualValue) {
2323
- if (!nextSortingOrder) {
2324
- sortAction = "remove";
2325
- }
2326
- }
2327
- }
2328
- if (sortAction === "add") {
2329
- var _table$options$maxMul;
2330
- newSorting = [...old, {
2331
- id: column.id,
2332
- desc: nextDesc
2333
- }];
2334
- newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
2335
- } else if (sortAction === "toggle") {
2336
- newSorting = old.map((d) => {
2337
- if (d.id === column.id) {
2338
- return {
2339
- ...d,
2340
- desc: nextDesc
2341
- };
2342
- }
2343
- return d;
2344
- });
2345
- } else if (sortAction === "remove") {
2346
- newSorting = old.filter((d) => d.id !== column.id);
2347
- } else {
2348
- newSorting = [{
2349
- id: column.id,
2350
- desc: nextDesc
2351
- }];
2352
- }
2353
- return newSorting;
2354
- });
2355
- };
2356
- column.getFirstSortDir = () => {
2357
- var _ref, _column$columnDef$sor;
2358
- const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === "desc";
2359
- return sortDescFirst ? "desc" : "asc";
2360
- };
2361
- column.getNextSortingOrder = (multi) => {
2362
- var _table$options$enable, _table$options$enable2;
2363
- const firstSortDirection = column.getFirstSortDir();
2364
- const isSorted = column.getIsSorted();
2365
- if (!isSorted) {
2366
- return firstSortDirection;
2367
- }
2368
- if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && // If enableSortRemove, enable in general
2369
- (multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true)) {
2370
- return false;
2371
- }
2372
- return isSorted === "desc" ? "asc" : "desc";
2373
- };
2374
- column.getCanSort = () => {
2375
- var _column$columnDef$ena, _table$options$enable3;
2376
- return ((_column$columnDef$ena = column.columnDef.enableSorting) != null ? _column$columnDef$ena : true) && ((_table$options$enable3 = table.options.enableSorting) != null ? _table$options$enable3 : true) && !!column.accessorFn;
2377
- };
2378
- column.getCanMultiSort = () => {
2379
- var _ref2, _column$columnDef$ena2;
2380
- return (_ref2 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : table.options.enableMultiSort) != null ? _ref2 : !!column.accessorFn;
2381
- };
2382
- column.getIsSorted = () => {
2383
- var _table$getState$sorti;
2384
- const columnSort = (_table$getState$sorti = table.getState().sorting) == null ? void 0 : _table$getState$sorti.find((d) => d.id === column.id);
2385
- return !columnSort ? false : columnSort.desc ? "desc" : "asc";
2386
- };
2387
- column.getSortIndex = () => {
2388
- var _table$getState$sorti2, _table$getState$sorti3;
2389
- return (_table$getState$sorti2 = (_table$getState$sorti3 = table.getState().sorting) == null ? void 0 : _table$getState$sorti3.findIndex((d) => d.id === column.id)) != null ? _table$getState$sorti2 : -1;
2390
- };
2391
- column.clearSorting = () => {
2392
- table.setSorting((old) => old != null && old.length ? old.filter((d) => d.id !== column.id) : []);
2393
- };
2394
- column.getToggleSortingHandler = () => {
2395
- const canSort = column.getCanSort();
2396
- return (e) => {
2397
- if (!canSort) return;
2398
- e.persist == null || e.persist();
2399
- column.toggleSorting == null || column.toggleSorting(void 0, column.getCanMultiSort() ? table.options.isMultiSortEvent == null ? void 0 : table.options.isMultiSortEvent(e) : false);
2400
- };
2401
- };
2402
- },
2403
- createTable: (table) => {
2404
- table.setSorting = (updater) => table.options.onSortingChange == null ? void 0 : table.options.onSortingChange(updater);
2405
- table.resetSorting = (defaultState) => {
2406
- var _table$initialState$s, _table$initialState;
2407
- table.setSorting(defaultState ? [] : (_table$initialState$s = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) != null ? _table$initialState$s : []);
2408
- };
2409
- table.getPreSortedRowModel = () => table.getGroupedRowModel();
2410
- table.getSortedRowModel = () => {
2411
- if (!table._getSortedRowModel && table.options.getSortedRowModel) {
2412
- table._getSortedRowModel = table.options.getSortedRowModel(table);
2413
- }
2414
- if (table.options.manualSorting || !table._getSortedRowModel) {
2415
- return table.getPreSortedRowModel();
2416
- }
2417
- return table._getSortedRowModel();
2418
- };
2419
- }
2420
- };
2421
- const builtInFeatures = [
2422
- Headers,
2423
- ColumnVisibility,
2424
- ColumnOrdering,
2425
- ColumnPinning,
2426
- ColumnFaceting,
2427
- ColumnFiltering,
2428
- GlobalFaceting,
2429
- //depends on ColumnFaceting
2430
- GlobalFiltering,
2431
- //depends on ColumnFiltering
2432
- RowSorting,
2433
- ColumnGrouping,
2434
- //depends on RowSorting
2435
- RowExpanding,
2436
- RowPagination,
2437
- RowPinning,
2438
- RowSelection,
2439
- ColumnSizing
2440
- ];
2441
- function createTable(options) {
2442
- var _options$_features, _options$initialState;
2443
- const _features = [...builtInFeatures, ...(_options$_features = options._features) != null ? _options$_features : []];
2444
- let table = {
2445
- _features
2446
- };
2447
- const defaultOptions = table._features.reduce((obj, feature) => {
2448
- return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
2449
- }, {});
2450
- const mergeOptions = (options2) => {
2451
- if (table.options.mergeOptions) {
2452
- return table.options.mergeOptions(defaultOptions, options2);
2453
- }
2454
- return {
2455
- ...defaultOptions,
2456
- ...options2
2457
- };
2458
- };
2459
- const coreInitialState = {};
2460
- let initialState = {
2461
- ...coreInitialState,
2462
- ...(_options$initialState = options.initialState) != null ? _options$initialState : {}
2463
- };
2464
- table._features.forEach((feature) => {
2465
- var _feature$getInitialSt;
2466
- initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
2467
- });
2468
- const queued = [];
2469
- let queuedTimeout = false;
2470
- const coreInstance = {
2471
- _features,
2472
- options: {
2473
- ...defaultOptions,
2474
- ...options
2475
- },
2476
- initialState,
2477
- _queue: (cb) => {
2478
- queued.push(cb);
2479
- if (!queuedTimeout) {
2480
- queuedTimeout = true;
2481
- Promise.resolve().then(() => {
2482
- while (queued.length) {
2483
- queued.shift()();
2484
- }
2485
- queuedTimeout = false;
2486
- }).catch((error) => setTimeout(() => {
2487
- throw error;
2488
- }));
2489
- }
2490
- },
2491
- reset: () => {
2492
- table.setState(table.initialState);
2493
- },
2494
- setOptions: (updater) => {
2495
- const newOptions = functionalUpdate(updater, table.options);
2496
- table.options = mergeOptions(newOptions);
2497
- },
2498
- getState: () => {
2499
- return table.options.state;
2500
- },
2501
- setState: (updater) => {
2502
- table.options.onStateChange == null || table.options.onStateChange(updater);
2503
- },
2504
- _getRowId: (row, index, parent) => {
2505
- var _table$options$getRow;
2506
- return (_table$options$getRow = table.options.getRowId == null ? void 0 : table.options.getRowId(row, index, parent)) != null ? _table$options$getRow : `${parent ? [parent.id, index].join(".") : index}`;
2507
- },
2508
- getCoreRowModel: () => {
2509
- if (!table._getCoreRowModel) {
2510
- table._getCoreRowModel = table.options.getCoreRowModel(table);
2511
- }
2512
- return table._getCoreRowModel();
2513
- },
2514
- // The final calls start at the bottom of the model,
2515
- // expanded rows, which then work their way up
2516
- getRowModel: () => {
2517
- return table.getPaginationRowModel();
2518
- },
2519
- //in next version, we should just pass in the row model as the optional 2nd arg
2520
- getRow: (id, searchAll) => {
2521
- let row = (searchAll ? table.getPrePaginationRowModel() : table.getRowModel()).rowsById[id];
2522
- if (!row) {
2523
- row = table.getCoreRowModel().rowsById[id];
2524
- if (!row) {
2525
- throw new Error();
2526
- }
2527
- }
2528
- return row;
2529
- },
2530
- _getDefaultColumnDef: memo(() => [table.options.defaultColumn], (defaultColumn) => {
2531
- var _defaultColumn;
2532
- defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2533
- return {
2534
- header: (props) => {
2535
- const resolvedColumnDef = props.header.column.columnDef;
2536
- if (resolvedColumnDef.accessorKey) {
2537
- return resolvedColumnDef.accessorKey;
2538
- }
2539
- if (resolvedColumnDef.accessorFn) {
2540
- return resolvedColumnDef.id;
2541
- }
2542
- return null;
2543
- },
2544
- // footer: props => props.header.column.id,
2545
- cell: (props) => {
2546
- var _props$renderValue$to, _props$renderValue;
2547
- return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
2548
- },
2549
- ...table._features.reduce((obj, feature) => {
2550
- return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
2551
- }, {}),
2552
- ...defaultColumn
2553
- };
2554
- }, getMemoOptions(options, "debugColumns")),
2555
- _getColumnDefs: () => table.options.columns,
2556
- getAllColumns: memo(() => [table._getColumnDefs()], (columnDefs) => {
2557
- const recurseColumns = function(columnDefs2, parent, depth) {
2558
- if (depth === void 0) {
2559
- depth = 0;
2560
- }
2561
- return columnDefs2.map((columnDef) => {
2562
- const column = createColumn(table, columnDef, depth, parent);
2563
- const groupingColumnDef = columnDef;
2564
- column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
2565
- return column;
2566
- });
2567
- };
2568
- return recurseColumns(columnDefs);
2569
- }, getMemoOptions(options, "debugColumns")),
2570
- getAllFlatColumns: memo(() => [table.getAllColumns()], (allColumns) => {
2571
- return allColumns.flatMap((column) => {
2572
- return column.getFlatColumns();
2573
- });
2574
- }, getMemoOptions(options, "debugColumns")),
2575
- _getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], (flatColumns) => {
2576
- return flatColumns.reduce((acc, column) => {
2577
- acc[column.id] = column;
2578
- return acc;
2579
- }, {});
2580
- }, getMemoOptions(options, "debugColumns")),
2581
- getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns2) => {
2582
- let leafColumns = allColumns.flatMap((column) => column.getLeafColumns());
2583
- return orderColumns2(leafColumns);
2584
- }, getMemoOptions(options, "debugColumns")),
2585
- getColumn: (columnId) => {
2586
- const column = table._getAllFlatColumnsById()[columnId];
2587
- return column;
2588
- }
2589
- };
2590
- Object.assign(table, coreInstance);
2591
- for (let index = 0; index < table._features.length; index++) {
2592
- const feature = table._features[index];
2593
- feature == null || feature.createTable == null || feature.createTable(table);
2594
- }
2595
- return table;
2596
- }
2597
- function getCoreRowModel() {
2598
- return (table) => memo(() => [table.options.data], (data) => {
2599
- const rowModel = {
2600
- rows: [],
2601
- flatRows: [],
2602
- rowsById: {}
2603
- };
2604
- const accessRows = function(originalRows, depth, parentRow) {
2605
- if (depth === void 0) {
2606
- depth = 0;
2607
- }
2608
- const rows = [];
2609
- for (let i = 0; i < originalRows.length; i++) {
2610
- const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, void 0, parentRow == null ? void 0 : parentRow.id);
2611
- rowModel.flatRows.push(row);
2612
- rowModel.rowsById[row.id] = row;
2613
- rows.push(row);
2614
- if (table.options.getSubRows) {
2615
- var _row$originalSubRows;
2616
- row.originalSubRows = table.options.getSubRows(originalRows[i], i);
2617
- if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
2618
- row.subRows = accessRows(row.originalSubRows, depth + 1, row);
2619
- }
2620
- }
2621
- }
2622
- return rows;
2623
- };
2624
- rowModel.rows = accessRows(data);
2625
- return rowModel;
2626
- }, getMemoOptions(table.options, "debugTable", "getRowModel", () => table._autoResetPageIndex()));
2627
- }
2628
- /**
2629
- * vue-table
2630
- *
2631
- * Copyright (c) TanStack
2632
- *
2633
- * This source code is licensed under the MIT license found in the
2634
- * LICENSE.md file in the root directory of this source tree.
2635
- *
2636
- * @license MIT
2637
- */
2638
- function trueFn() {
2639
- return true;
2640
- }
2641
- const $PROXY = Symbol("merge-proxy");
2642
- const propTraps = {
2643
- get(_, property, receiver) {
2644
- if (property === $PROXY) return receiver;
2645
- return _.get(property);
2646
- },
2647
- has(_, property) {
2648
- return _.has(property);
2649
- },
2650
- set: trueFn,
2651
- deleteProperty: trueFn,
2652
- getOwnPropertyDescriptor(_, property) {
2653
- return {
2654
- configurable: true,
2655
- enumerable: true,
2656
- get() {
2657
- return _.get(property);
2658
- },
2659
- set: trueFn,
2660
- deleteProperty: trueFn
2661
- };
2662
- },
2663
- ownKeys(_) {
2664
- return _.keys();
2665
- }
2666
- };
2667
- function resolveSource(s) {
2668
- return "value" in s ? s.value : s;
2669
- }
2670
- function mergeProxy() {
2671
- for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
2672
- sources[_key] = arguments[_key];
2673
- }
2674
- return new Proxy({
2675
- get(property) {
2676
- for (let i = sources.length - 1; i >= 0; i--) {
2677
- const v = resolveSource(sources[i])[property];
2678
- if (v !== void 0) return v;
2679
- }
2680
- },
2681
- has(property) {
2682
- for (let i = sources.length - 1; i >= 0; i--) {
2683
- if (property in resolveSource(sources[i])) return true;
2684
- }
2685
- return false;
2686
- },
2687
- keys() {
2688
- const keys = [];
2689
- for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
2690
- return [...Array.from(new Set(keys))];
2691
- }
2692
- }, propTraps);
2693
- }
2694
- const FlexRender = defineComponent({
2695
- props: ["render", "props"],
2696
- setup: (props) => {
2697
- return () => {
2698
- if (typeof props.render === "function" || typeof props.render === "object") {
2699
- return h(props.render, props.props);
2700
- }
2701
- return props.render;
2702
- };
2703
- }
2704
- });
2705
- function getOptionsWithReactiveData(options) {
2706
- return mergeProxy(options, {
2707
- data: unref(options.data)
2708
- });
2709
- }
2710
- function useVueTable(initialOptions) {
2711
- const IS_REACTIVE = isRef(initialOptions.data);
2712
- const resolvedOptions = mergeProxy({
2713
- state: {},
2714
- // Dummy state
2715
- onStateChange: () => {
2716
- },
2717
- // noop
2718
- renderFallbackValue: null,
2719
- mergeOptions(defaultOptions, options) {
2720
- return IS_REACTIVE ? {
2721
- ...defaultOptions,
2722
- ...options
2723
- } : mergeProxy(defaultOptions, options);
2724
- }
2725
- }, IS_REACTIVE ? getOptionsWithReactiveData(initialOptions) : initialOptions);
2726
- const table = createTable(resolvedOptions);
2727
- if (IS_REACTIVE) {
2728
- const dataRef = shallowRef(initialOptions.data);
2729
- watch(dataRef, () => {
2730
- table.setState((prev) => ({
2731
- ...prev,
2732
- data: dataRef.value
2733
- }));
2734
- }, {
2735
- immediate: true
2736
- });
2737
- }
2738
- const state = ref(table.initialState);
2739
- watchEffect(() => {
2740
- table.setOptions((prev) => {
2741
- var _initialOptions$state;
2742
- const stateProxy = new Proxy({}, {
2743
- get: (_, prop) => state.value[prop]
2744
- });
2745
- return mergeProxy(prev, IS_REACTIVE ? getOptionsWithReactiveData(initialOptions) : initialOptions, {
2746
- // merge the initialState and `options.state`
2747
- // create a new proxy on each `setOptions` call
2748
- // and get the value from state on each property access
2749
- state: mergeProxy(stateProxy, (_initialOptions$state = initialOptions.state) != null ? _initialOptions$state : {}),
2750
- // Similarly, we'll maintain both our internal state and any user-provided
2751
- // state.
2752
- onStateChange: (updater) => {
2753
- if (updater instanceof Function) {
2754
- state.value = updater(state.value);
2755
- } else {
2756
- state.value = updater;
2757
- }
2758
- initialOptions.onStateChange == null || initialOptions.onStateChange(updater);
2759
- }
2760
- });
2761
- });
2762
- });
2763
- return table;
2764
- }
2765
- const _hoisted_1 = { class: "n8n-data-table-server-wrapper" };
2766
- const _hoisted_2 = { class: "table-scroll" };
2767
- const _hoisted_3 = ["onMousedown"];
2768
- const _hoisted_4 = ["onMousedown", "onTouchstart", "onDblclick"];
2769
- const _hoisted_5 = { key: 0 };
2770
- const _hoisted_6 = ["colspan"];
2771
- const _hoisted_7 = { key: 0 };
2772
- const _hoisted_8 = ["colspan"];
2773
- const _hoisted_9 = ["onClick"];
2774
- const _hoisted_10 = {
2775
- key: 0,
2776
- class: "table-pagination",
2777
- "data-test-id": "pagination"
2778
- };
2779
- const _hoisted_11 = { class: "table-pagination__sizes" };
2780
- const _sfc_main = /* @__PURE__ */ defineComponent({
2781
- __name: "N8nDataTableServer",
2782
- props: /* @__PURE__ */ mergeModels({
2783
- items: {},
2784
- headers: {},
2785
- itemsLength: {},
2786
- loading: { type: Boolean },
2787
- multiSort: { type: Boolean },
2788
- showSelect: { type: Boolean },
2789
- itemValue: { type: [Function, String], default: "id" },
2790
- returnObject: { type: Boolean },
2791
- itemSelectable: { type: [Boolean, Function], default: void 0 },
2792
- pageSizes: { default: () => [10, 25, 50, 100] }
2793
- }, {
2794
- "page": { default: 0 },
2795
- "pageModifiers": {},
2796
- "items-per-page": { default: 10 },
2797
- "items-per-pageModifiers": {},
2798
- "sort-by": { default: [], required: false },
2799
- "sort-byModifiers": {},
2800
- "selection": {},
2801
- "selectionModifiers": {}
2802
- }),
2803
- emits: /* @__PURE__ */ mergeModels(["update:options", "click:row"], ["update:page", "update:items-per-page", "update:sort-by", "update:selection"]),
2804
- setup(__props, { emit: __emit }) {
2805
- const props = __props;
2806
- const slots = useSlots();
2807
- const emit = __emit;
2808
- const data = shallowRef(props.items.concat());
2809
- watch(
2810
- () => props.items,
2811
- () => {
2812
- data.value = props.items.concat();
2813
- },
2814
- // the sync will NOT work without the deep watcher
2815
- { deep: true }
2816
- );
2817
- function itemKeySlot(info) {
2818
- const slotName = `item.${info.column.id}`;
2819
- return slots[slotName] ? slots[slotName]({ item: info.row.original, value: info.getValue() }) : info.getValue();
2820
- }
2821
- function isValueAccessor(column) {
2822
- return !!column.value;
2823
- }
2824
- function getHeaderTitle(column) {
2825
- const value = typeof column.value === "function" ? "" : column.value;
2826
- return column.title ?? column.key ?? value;
2827
- }
2828
- function isAccessorColumn(column) {
2829
- return typeof column.value === "function";
2830
- }
2831
- const getColumnMeta = (column) => {
2832
- return column.columnDef.meta ?? {};
2833
- };
2834
- const MIN_COLUMN_WIDTH = 75;
2835
- function getValueAccessor(column) {
2836
- if (isAccessorColumn(column)) {
2837
- return columnHelper.accessor(column.value, {
2838
- id: column.key,
2839
- cell: itemKeySlot,
2840
- header: () => getHeaderTitle(column),
2841
- enableSorting: !column.disableSort,
2842
- minSize: column.minWidth ?? MIN_COLUMN_WIDTH,
2843
- size: column.width,
2844
- meta: {
2845
- cellProps: {
2846
- align: column.align
2847
- }
2848
- }
2849
- });
2850
- } else {
2851
- return columnHelper.accessor(column.value, {
2852
- id: column.key ?? column.value,
2853
- cell: itemKeySlot,
2854
- header: () => getHeaderTitle(column),
2855
- enableSorting: !column.disableSort,
2856
- minSize: column.minWidth ?? MIN_COLUMN_WIDTH,
2857
- size: column.width,
2858
- meta: {
2859
- cellProps: {
2860
- align: column.align
2861
- }
2862
- }
2863
- });
2864
- }
2865
- }
2866
- function mapHeaders(columns) {
2867
- return columns.map((column, index) => {
2868
- if (isValueAccessor(column)) {
2869
- return getValueAccessor(column);
2870
- }
2871
- if (column.key) {
2872
- const accessor = column.key;
2873
- return columnHelper.accessor(column.key, {
2874
- id: accessor,
2875
- cell: itemKeySlot,
2876
- header: () => getHeaderTitle(column),
2877
- enableSorting: !column.disableSort,
2878
- minSize: column.minWidth ?? MIN_COLUMN_WIDTH,
2879
- size: column.width,
2880
- meta: {
2881
- cellProps: {
2882
- align: column.align
2883
- }
2884
- }
2885
- });
2886
- }
2887
- return columnHelper.display({
2888
- id: `display_column_${index}`,
2889
- header: () => getHeaderTitle(column),
2890
- size: column.width,
2891
- meta: {
2892
- cellProps: {
2893
- align: column.align
2894
- }
2895
- }
2896
- });
2897
- });
2898
- }
2899
- const columnsDefinition = computed(() => {
2900
- return [...props.showSelect ? [selectColumn] : [], ...mapHeaders(props.headers)];
2901
- });
2902
- const page = useModel(__props, "page");
2903
- watch(page, () => table.setPageIndex(page.value));
2904
- const itemsPerPage = useModel(__props, "items-per-page");
2905
- watch(itemsPerPage, () => table.setPageSize(itemsPerPage.value));
2906
- const pagination = computed({
2907
- get() {
2908
- return {
2909
- pageIndex: page.value,
2910
- pageSize: itemsPerPage.value
2911
- };
2912
- },
2913
- set(newValue) {
2914
- page.value = newValue.pageIndex;
2915
- itemsPerPage.value = newValue.pageSize;
2916
- }
2917
- });
2918
- const showPagination = computed(() => props.itemsLength > Math.min(...props.pageSizes));
2919
- const sortBy = useModel(__props, "sort-by");
2920
- function handleSortingChange(updaterOrValue) {
2921
- const newValue = typeof updaterOrValue === "function" ? updaterOrValue(sortBy.value) : updaterOrValue;
2922
- sortBy.value = newValue;
2923
- emit("update:options", {
2924
- page: page.value,
2925
- itemsPerPage: itemsPerPage.value,
2926
- sortBy: newValue
2927
- });
2928
- }
2929
- const SELECT_COLUMN_ID = "data-table-select";
2930
- const selectColumn = {
2931
- id: SELECT_COLUMN_ID,
2932
- enableResizing: false,
2933
- size: 38,
2934
- enablePinning: true,
2935
- header: ({ table: table2 }) => {
2936
- const checkboxRef = ref();
2937
- return h(ElCheckbox, {
2938
- ref: checkboxRef,
2939
- modelValue: table2.getIsAllRowsSelected(),
2940
- indeterminate: table2.getIsSomeRowsSelected(),
2941
- onChange: () => {
2942
- const input = checkboxRef.value?.$el.getElementsByTagName("input")[0];
2943
- if (!input) return;
2944
- table2.getToggleAllRowsSelectedHandler()?.({ target: input });
2945
- }
2946
- });
2947
- },
2948
- cell: ({ row }) => {
2949
- const checkboxRef = ref();
2950
- return h(ElCheckbox, {
2951
- ref: checkboxRef,
2952
- modelValue: row.getIsSelected(),
2953
- disabled: !row.getCanSelect(),
2954
- onChange: () => {
2955
- const input = checkboxRef.value?.$el.getElementsByTagName("input")[0];
2956
- if (!input) return;
2957
- row.getToggleSelectedHandler()?.({ target: input });
2958
- }
2959
- });
2960
- },
2961
- meta: {
2962
- cellProps: {
2963
- align: void 0
2964
- }
2965
- }
2966
- };
2967
- function getRowId(originalRow, index, parent) {
2968
- if (typeof props.itemValue === "function") {
2969
- return props.itemValue(originalRow, index, parent);
2970
- }
2971
- return String(get(originalRow, props.itemValue));
2972
- }
2973
- function handleRowSelectionChange(updaterOrValue) {
2974
- if (typeof updaterOrValue === "function") {
2975
- rowSelection.value = updaterOrValue(rowSelection.value);
2976
- } else {
2977
- rowSelection.value = updaterOrValue;
2978
- }
2979
- if (props.returnObject) {
2980
- selection.value = Object.keys(rowSelection.value).map((id) => table.getRow(id).original);
2981
- } else {
2982
- selection.value = Object.keys(rowSelection.value);
2983
- }
2984
- }
2985
- const selection = useModel(__props, "selection");
2986
- const rowSelection = ref(
2987
- (selection.value ?? []).reduce((acc, item, index) => {
2988
- const key = typeof item === "string" ? item : getRowId(item, index);
2989
- acc[key] = true;
2990
- return acc;
2991
- }, {})
2992
- );
2993
- const emitUpdateOptions = useThrottleFn(
2994
- (payload) => emit("update:options", payload),
2995
- 100
2996
- );
2997
- function handlePageSizeChange(newPageSize) {
2998
- const maxPage = Math.max(0, Math.ceil(props.itemsLength / newPageSize) - 1);
2999
- const newPage = Math.min(page.value, maxPage);
3000
- page.value = newPage;
3001
- itemsPerPage.value = newPageSize;
3002
- }
3003
- const columnHelper = createColumnHelper();
3004
- const table = useVueTable({
3005
- data,
3006
- columns: columnsDefinition.value,
3007
- get rowCount() {
3008
- return props.itemsLength;
3009
- },
3010
- state: {
3011
- get sorting() {
3012
- return sortBy.value;
3013
- },
3014
- get pagination() {
3015
- return pagination.value;
3016
- },
3017
- get rowSelection() {
3018
- return rowSelection.value;
3019
- }
3020
- },
3021
- getCoreRowModel: getCoreRowModel(),
3022
- onSortingChange: handleSortingChange,
3023
- onPaginationChange(updaterOrValue) {
3024
- const newValue = typeof updaterOrValue === "function" ? updaterOrValue(pagination.value) : updaterOrValue;
3025
- void emitUpdateOptions({
3026
- page: newValue.pageIndex,
3027
- itemsPerPage: newValue.pageSize,
3028
- sortBy: sortBy.value
3029
- });
3030
- },
3031
- manualSorting: true,
3032
- enableMultiSort: props.multiSort,
3033
- manualPagination: true,
3034
- columnResizeMode: "onChange",
3035
- columnResizeDirection: "ltr",
3036
- getRowId,
3037
- enableRowSelection: (row) => {
3038
- if (typeof props.itemSelectable === "undefined") {
3039
- return true;
3040
- }
3041
- if (typeof props.itemSelectable === "boolean") {
3042
- return props.itemSelectable;
3043
- }
3044
- if (typeof props.itemSelectable === "function") {
3045
- return props.itemSelectable(row.original);
3046
- }
3047
- return Boolean(get(row.original, props.itemSelectable));
3048
- },
3049
- onRowSelectionChange: handleRowSelectionChange
3050
- });
3051
- return (_ctx, _cache) => {
3052
- return openBlock(), createElementBlock("div", null, [
3053
- createBaseVNode("div", _hoisted_1, [
3054
- createBaseVNode("div", _hoisted_2, [
3055
- createBaseVNode("table", {
3056
- class: normalizeClass(["n8n-data-table-server", { "table--loading": _ctx.loading }]),
3057
- style: normalizeStyle({
3058
- width: `${unref(table).getCenterTotalSize()}px`,
3059
- borderSpacing: 0,
3060
- minWidth: "100%",
3061
- tableLayout: "fixed"
3062
- })
3063
- }, [
3064
- createBaseVNode("thead", {
3065
- style: { position: "sticky", top: 0, zIndex: 2 },
3066
- class: normalizeClass({ loading: _ctx.loading })
3067
- }, [
3068
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(table).getHeaderGroups(), (headerGroup) => {
3069
- return openBlock(), createElementBlock("tr", {
3070
- key: headerGroup.id
3071
- }, [
3072
- (openBlock(true), createElementBlock(Fragment, null, renderList(headerGroup.headers, (header) => {
3073
- return openBlock(), createElementBlock("th", {
3074
- key: header.id,
3075
- style: normalizeStyle({
3076
- cursor: header.column.getCanSort() ? "pointer" : void 0,
3077
- width: `${header.getSize()}px`
3078
- }),
3079
- onMousedown: ($event) => header.column.getToggleSortingHandler()?.($event)
3080
- }, [
3081
- !header.isPlaceholder ? (openBlock(), createBlock(unref(FlexRender), {
3082
- key: 0,
3083
- render: header.column.columnDef.header,
3084
- props: header.getContext()
3085
- }, null, 8, ["render", "props"])) : createCommentVNode("", true),
3086
- header.column.getCanSort() ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
3087
- createTextVNode(toDisplayString({ asc: "↑", desc: "↓" }[header.column.getIsSorted()]), 1)
3088
- ], 64)) : createCommentVNode("", true),
3089
- header.column.getCanResize() ? (openBlock(), createElementBlock("div", {
3090
- key: 2,
3091
- class: normalizeClass({ resizer: true, ["is-resizing"]: header.column.getIsResizing() }),
3092
- onMousedown: withModifiers(($event) => header.getResizeHandler()?.($event), ["stop"]),
3093
- onTouchstart: ($event) => header.getResizeHandler()?.($event),
3094
- onDblclick: ($event) => header.column.resetSize()
3095
- }, null, 42, _hoisted_4)) : createCommentVNode("", true)
3096
- ], 44, _hoisted_3);
3097
- }), 128))
3098
- ]);
3099
- }), 128)),
3100
- _ctx.loading ? (openBlock(), createElementBlock("tr", _hoisted_5, [
3101
- createBaseVNode("th", {
3102
- colspan: unref(table).getVisibleFlatColumns().length,
3103
- class: "loading-row"
3104
- }, _cache[2] || (_cache[2] = [
3105
- createBaseVNode("div", { class: "progress-bar" }, [
3106
- createBaseVNode("div", { class: "progress-bar-value" })
3107
- ], -1)
3108
- ]), 8, _hoisted_6)
3109
- ])) : createCommentVNode("", true)
3110
- ], 2),
3111
- createBaseVNode("tbody", null, [
3112
- unref(slots).cover ? (openBlock(), createElementBlock("tr", _hoisted_7, [
3113
- createBaseVNode("td", {
3114
- class: "cover",
3115
- colspan: unref(table).getVisibleFlatColumns().length
3116
- }, [
3117
- renderSlot(_ctx.$slots, "cover", {}, void 0, true)
3118
- ], 8, _hoisted_8)
3119
- ])) : createCommentVNode("", true),
3120
- _ctx.loading && !unref(table).getRowModel().rows.length ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(itemsPerPage.value, (item) => {
3121
- return openBlock(), createElementBlock("tr", { key: item }, [
3122
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(table).getVisibleFlatColumns(), (coll) => {
3123
- return openBlock(), createElementBlock("td", {
3124
- key: coll.id,
3125
- class: "el-skeleton is-animated"
3126
- }, [
3127
- createVNode(unref(ElSkeletonItem))
3128
- ]);
3129
- }), 128))
3130
- ]);
3131
- }), 128)) : unref(table).getRowModel().rows.length ? (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(unref(table).getRowModel().rows, (row) => {
3132
- return renderSlot(_ctx.$slots, "item", mergeProps({
3133
- key: row.id,
3134
- ref_for: true
3135
- }, { item: row.original, cells: row.getVisibleCells() }), () => [
3136
- createBaseVNode("tr", {
3137
- onClick: ($event) => emit("click:row", $event, { item: row.original })
3138
- }, [
3139
- (openBlock(true), createElementBlock(Fragment, null, renderList(row.getVisibleCells(), (cell) => {
3140
- return openBlock(), createElementBlock("td", {
3141
- key: cell.id,
3142
- class: normalizeClass({
3143
- [`cell-align--${getColumnMeta(cell.column).cellProps.align}`]: Boolean(
3144
- getColumnMeta(cell.column).cellProps.align
3145
- )
3146
- })
3147
- }, [
3148
- createVNode(unref(FlexRender), {
3149
- render: cell.column.columnDef.cell,
3150
- props: cell.getContext()
3151
- }, null, 8, ["render", "props"])
3152
- ], 2);
3153
- }), 128))
3154
- ], 8, _hoisted_9)
3155
- ], true);
3156
- }), 128)) : createCommentVNode("", true)
3157
- ])
3158
- ], 6)
3159
- ])
3160
- ]),
3161
- showPagination.value ? (openBlock(), createElementBlock("div", _hoisted_10, [
3162
- createVNode(unref(_sfc_main$1), {
3163
- "current-page": page.value + 1,
3164
- "page-size": itemsPerPage.value,
3165
- "page-sizes": _ctx.pageSizes,
3166
- layout: "prev, pager, next",
3167
- total: _ctx.itemsLength,
3168
- "onUpdate:currentPage": _cache[0] || (_cache[0] = ($event) => page.value = $event - 1)
3169
- }, null, 8, ["current-page", "page-size", "page-sizes", "total"]),
3170
- createBaseVNode("div", _hoisted_11, [
3171
- _cache[3] || (_cache[3] = createBaseVNode("div", { class: "table-pagination__sizes__label" }, "Page size", -1)),
3172
- createVNode(unref(ElSelect), {
3173
- modelValue: itemsPerPage.value,
3174
- "onUpdate:modelValue": [
3175
- _cache[1] || (_cache[1] = ($event) => itemsPerPage.value = $event),
3176
- handlePageSizeChange
3177
- ],
3178
- modelModifiers: { number: true },
3179
- class: "table-pagination__sizes__select",
3180
- size: "small",
3181
- teleported: false
3182
- }, {
3183
- default: withCtx(() => [
3184
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.pageSizes, (item) => {
3185
- return openBlock(), createBlock(unref(ElOption), {
3186
- key: item,
3187
- label: item,
3188
- value: item
3189
- }, null, 8, ["label", "value"]);
3190
- }), 128))
3191
- ]),
3192
- _: 1
3193
- }, 8, ["modelValue"])
3194
- ])
3195
- ])) : createCommentVNode("", true)
3196
- ]);
3197
- };
3198
- }
3199
- });
3200
- const N8nDataTableServer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-03a55eaa"]]);
3201
- export {
3202
- N8nDataTableServer as N
3203
- };