katucharts.js 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +106 -0
- package/README.md +1100 -0
- package/dist/__vite-optional-peer-dep_jspdf_katucharts-BDMct_Gn.js +4 -0
- package/dist/accessibility/A11yModule.d.ts +26 -0
- package/dist/axis/Axis.d.ts +140 -0
- package/dist/axis/AxisCoordinator.d.ts +38 -0
- package/dist/bio.d.ts +22 -0
- package/dist/components/Credits.d.ts +38 -0
- package/dist/components/Crosshair.d.ts +15 -0
- package/dist/components/DataLabels.d.ts +7 -0
- package/dist/components/ExportButton.d.ts +27 -0
- package/dist/components/Legend.d.ts +53 -0
- package/dist/components/TitleRenderer.d.ts +19 -0
- package/dist/components/Tooltip.d.ts +61 -0
- package/dist/core/Chart.d.ts +156 -0
- package/dist/core/EventBus.d.ts +14 -0
- package/dist/core/InteractionController.d.ts +62 -0
- package/dist/core/OptionsParser.d.ts +61 -0
- package/dist/core/Registry.d.ts +27 -0
- package/dist/core/SVGRenderer.d.ts +48 -0
- package/dist/core/ScrollablePlotOverlay.d.ts +31 -0
- package/dist/core/StackComputer.d.ts +25 -0
- package/dist/core/StateManager.d.ts +21 -0
- package/dist/core/UpdateScheduler.d.ts +28 -0
- package/dist/core/animationConstants.d.ts +20 -0
- package/dist/core/chartTypes.d.ts +46 -0
- package/dist/core/registerAll.d.ts +4 -0
- package/dist/core/registerBio.d.ts +4 -0
- package/dist/core/registerCore.d.ts +4 -0
- package/dist/core/registerFinance.d.ts +4 -0
- package/dist/core/registerFinancial.d.ts +4 -0
- package/dist/core/registerFlow.d.ts +4 -0
- package/dist/core/registerGeneral.d.ts +4 -0
- package/dist/datatable/DataTable.d.ts +162 -0
- package/dist/datatable/DataTableDefaults.d.ts +7 -0
- package/dist/datatable/api/TableApi.d.ts +35 -0
- package/dist/datatable/columns/ColumnDef.d.ts +16 -0
- package/dist/datatable/columns/ColumnManager.d.ts +31 -0
- package/dist/datatable/data/DataProcessor.d.ts +46 -0
- package/dist/datatable/data/DataSource.d.ts +26 -0
- package/dist/datatable/editing/CellEditor.d.ts +29 -0
- package/dist/datatable/export/TableExport.d.ts +23 -0
- package/dist/datatable/locales/en.d.ts +9 -0
- package/dist/datatable/locales/es.d.ts +6 -0
- package/dist/datatable/locales/index.d.ts +22 -0
- package/dist/datatable/locales/pt-BR.d.ts +6 -0
- package/dist/datatable/locales/resolveLocale.d.ts +16 -0
- package/dist/datatable/locales/zh.d.ts +6 -0
- package/dist/datatable/render/CellRenderer.d.ts +24 -0
- package/dist/datatable/render/HeaderRenderer.d.ts +51 -0
- package/dist/datatable/render/PaginationRenderer.d.ts +26 -0
- package/dist/datatable/render/SearchRenderer.d.ts +21 -0
- package/dist/datatable/render/TableRenderer.d.ts +81 -0
- package/dist/datatable/render/ToolbarRenderer.d.ts +34 -0
- package/dist/datatable/render/icons.d.ts +24 -0
- package/dist/datatable/render/popover.d.ts +15 -0
- package/dist/datatable/selection/SelectionManager.d.ts +29 -0
- package/dist/datatable/themes/TableTheme.d.ts +36 -0
- package/dist/datatable/themes/styleSheet.d.ts +16 -0
- package/dist/datatable.d.ts +19 -0
- package/dist/export/ChartExporter.d.ts +50 -0
- package/dist/export/Export.d.ts +76 -0
- package/dist/finance.d.ts +49 -0
- package/dist/index.d.ts +67 -0
- package/dist/indicators/Indicator.d.ts +23 -0
- package/dist/indicators/expandIndicators.d.ts +18 -0
- package/dist/indicators/moving-averages/DEMA.d.ts +10 -0
- package/dist/indicators/moving-averages/EMA.d.ts +12 -0
- package/dist/indicators/moving-averages/SMA.d.ts +11 -0
- package/dist/indicators/moving-averages/TEMA.d.ts +10 -0
- package/dist/indicators/moving-averages/WMA.d.ts +12 -0
- package/dist/indicators/oscillators/CCI.d.ts +11 -0
- package/dist/indicators/oscillators/MACD.d.ts +20 -0
- package/dist/indicators/oscillators/Momentum.d.ts +10 -0
- package/dist/indicators/oscillators/ROC.d.ts +10 -0
- package/dist/indicators/oscillators/RSI.d.ts +11 -0
- package/dist/indicators/oscillators/Stochastic.d.ts +20 -0
- package/dist/indicators/registry.d.ts +9 -0
- package/dist/indicators/trend/ADX.d.ts +11 -0
- package/dist/indicators/trend/IchimokuCloud.d.ts +14 -0
- package/dist/indicators/trend/PSAR.d.ts +11 -0
- package/dist/indicators/util.d.ts +8 -0
- package/dist/indicators/volatility/ATR.d.ts +11 -0
- package/dist/indicators/volatility/BollingerBands.d.ts +11 -0
- package/dist/indicators/volume/OBV.d.ts +11 -0
- package/dist/indicators/volume/VBP.d.ts +12 -0
- package/dist/indicators/volume/VWAP.d.ts +12 -0
- package/dist/interaction/Drilldown.d.ts +29 -0
- package/dist/interaction/HoverManager.d.ts +47 -0
- package/dist/interaction/Zoom.d.ts +68 -0
- package/dist/katucharts-bio.es.js +5861 -0
- package/dist/katucharts-bio.umd.js +1 -0
- package/dist/katucharts-datatable.es.js +3363 -0
- package/dist/katucharts-datatable.umd.js +296 -0
- package/dist/katucharts-finance.es.js +4364 -0
- package/dist/katucharts-finance.umd.js +1 -0
- package/dist/katucharts-react.es.js +35 -0
- package/dist/katucharts-react.umd.js +1 -0
- package/dist/katucharts.es.js +20531 -0
- package/dist/katucharts.umd.js +9 -0
- package/dist/layout/LayoutEngine.d.ts +44 -0
- package/dist/license/LicenseManager.d.ts +63 -0
- package/dist/options/defaults.d.ts +5 -0
- package/dist/react/KatuChartsReact.d.ts +16 -0
- package/dist/react.d.ts +2 -0
- package/dist/responsive/ResponsiveEngine.d.ts +15 -0
- package/dist/series/BaseSeries.d.ts +186 -0
- package/dist/series/bioinformatics/CircosChart.d.ts +4 -0
- package/dist/series/bioinformatics/ClusteredHeatmapChart.d.ts +22 -0
- package/dist/series/bioinformatics/ForestPlotChart.d.ts +21 -0
- package/dist/series/bioinformatics/KaplanMeierChart.d.ts +22 -0
- package/dist/series/bioinformatics/ManhattanChart.d.ts +34 -0
- package/dist/series/bioinformatics/PCoAChart.d.ts +22 -0
- package/dist/series/bioinformatics/PhyloTreeChart.d.ts +27 -0
- package/dist/series/bioinformatics/SequenceLogoChart.d.ts +21 -0
- package/dist/series/bioinformatics/ViolinChart.d.ts +23 -0
- package/dist/series/bioinformatics/VolcanoChart.d.ts +28 -0
- package/dist/series/bioinformatics/circos/CircosChart.d.ts +20 -0
- package/dist/series/bioinformatics/circos/CircosColorScales.d.ts +6 -0
- package/dist/series/bioinformatics/circos/CircosComparativeChart.d.ts +41 -0
- package/dist/series/bioinformatics/circos/CircosHeatmapChart.d.ts +31 -0
- package/dist/series/bioinformatics/circos/CircosLayoutEngine.d.ts +37 -0
- package/dist/series/bioinformatics/circos/CircosRules.d.ts +6 -0
- package/dist/series/bioinformatics/circos/CircosSpiralChart.d.ts +39 -0
- package/dist/series/bioinformatics/circos/CircosTypes.d.ts +131 -0
- package/dist/series/bioinformatics/circos/tracks/AreaTrackRenderer.d.ts +7 -0
- package/dist/series/bioinformatics/circos/tracks/ConnectorTrackRenderer.d.ts +7 -0
- package/dist/series/bioinformatics/circos/tracks/GlyphTrackRenderer.d.ts +7 -0
- package/dist/series/bioinformatics/circos/tracks/HeatmapTrackRenderer.d.ts +7 -0
- package/dist/series/bioinformatics/circos/tracks/HighlightTrackRenderer.d.ts +6 -0
- package/dist/series/bioinformatics/circos/tracks/HistogramTrackRenderer.d.ts +7 -0
- package/dist/series/bioinformatics/circos/tracks/LineTrackRenderer.d.ts +7 -0
- package/dist/series/bioinformatics/circos/tracks/LinkTrackRenderer.d.ts +8 -0
- package/dist/series/bioinformatics/circos/tracks/LollipopTrackRenderer.d.ts +9 -0
- package/dist/series/bioinformatics/circos/tracks/RibbonTrackRenderer.d.ts +9 -0
- package/dist/series/bioinformatics/circos/tracks/ScatterTrackRenderer.d.ts +7 -0
- package/dist/series/bioinformatics/circos/tracks/StackTrackRenderer.d.ts +7 -0
- package/dist/series/bioinformatics/circos/tracks/TextTrackRenderer.d.ts +8 -0
- package/dist/series/bioinformatics/circos/tracks/TileTrackRenderer.d.ts +7 -0
- package/dist/series/bioinformatics/circos/tracks/TrackAxesRenderer.d.ts +6 -0
- package/dist/series/bioinformatics/circos/tracks/TrackBackgroundRenderer.d.ts +5 -0
- package/dist/series/cartesian/AreaChart.d.ts +33 -0
- package/dist/series/cartesian/BoxPlotChart.d.ts +24 -0
- package/dist/series/cartesian/BubbleChart.d.ts +34 -0
- package/dist/series/cartesian/ColumnChart.d.ts +37 -0
- package/dist/series/cartesian/LineChart.d.ts +28 -0
- package/dist/series/cartesian/ScatterChart.d.ts +20 -0
- package/dist/series/cartesian/SplineChart.d.ts +9 -0
- package/dist/series/cartesian/WaterfallChart.d.ts +25 -0
- package/dist/series/financial/AreaRangeChart.d.ts +24 -0
- package/dist/series/financial/BaselineChart.d.ts +20 -0
- package/dist/series/financial/CandlestickChart.d.ts +55 -0
- package/dist/series/financial/ColumnRangeChart.d.ts +16 -0
- package/dist/series/financial/FlagsChart.d.ts +34 -0
- package/dist/series/financial/HeikinAshiChart.d.ts +11 -0
- package/dist/series/financial/HollowCandlestickChart.d.ts +17 -0
- package/dist/series/financial/KagiChart.d.ts +23 -0
- package/dist/series/financial/LineBreakChart.d.ts +23 -0
- package/dist/series/financial/PointAndFigureChart.d.ts +24 -0
- package/dist/series/financial/RenkoChart.d.ts +22 -0
- package/dist/series/financial/VBPChart.d.ts +18 -0
- package/dist/series/financial/VolumeChart.d.ts +15 -0
- package/dist/series/flow/DependencyWheelChart.d.ts +23 -0
- package/dist/series/flow/NetworkGraphChart.d.ts +18 -0
- package/dist/series/flow/SankeyChart.d.ts +24 -0
- package/dist/series/gauge/GaugeChart.d.ts +40 -0
- package/dist/series/heatmap/HeatmapChart.d.ts +18 -0
- package/dist/series/hierarchical/SunburstChart.d.ts +44 -0
- package/dist/series/hierarchical/TreegraphChart.d.ts +19 -0
- package/dist/series/hierarchical/TreemapChart.d.ts +20 -0
- package/dist/series/hierarchical/WordcloudChart.d.ts +19 -0
- package/dist/series/index.d.ts +45 -0
- package/dist/series/map/FlowmapChart.d.ts +33 -0
- package/dist/series/map/MapChart.d.ts +53 -0
- package/dist/series/map/MapPointChart.d.ts +26 -0
- package/dist/series/map/mapProjection.d.ts +46 -0
- package/dist/series/pie/PieChart.d.ts +53 -0
- package/dist/series/polar/PolarChart.d.ts +18 -0
- package/dist/series/race/BarRaceChart.d.ts +44 -0
- package/dist/series/timeline/TimelineChart.d.ts +23 -0
- package/dist/series/venn/VennChart.d.ts +28 -0
- package/dist/stock/DataGrouping.d.ts +21 -0
- package/dist/stock/Navigator.d.ts +25 -0
- package/dist/stock/RangeSelector.d.ts +9 -0
- package/dist/stock/StockController.d.ts +47 -0
- package/dist/stockcharts.d.ts +8 -0
- package/dist/streaming/StreamAdapter.d.ts +36 -0
- package/dist/types/datatable-options.d.ts +633 -0
- package/dist/types/options.d.ts +1333 -0
- package/dist/utils/CircularBuffer.d.ts +24 -0
- package/dist/utils/chartText.d.ts +18 -0
- package/dist/utils/color.d.ts +23 -0
- package/dist/utils/decimation.d.ts +19 -0
- package/dist/utils/deepMerge.d.ts +5 -0
- package/dist/utils/dom.d.ts +10 -0
- package/dist/utils/format.d.ts +42 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/math.d.ts +6 -0
- package/dist/utils/throttle.d.ts +2 -0
- package/package.json +95 -0
|
@@ -0,0 +1,3363 @@
|
|
|
1
|
+
class G {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
4
|
+
}
|
|
5
|
+
on(e, t) {
|
|
6
|
+
return this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push({ callback: t, once: !1 }), this;
|
|
7
|
+
}
|
|
8
|
+
once(e, t) {
|
|
9
|
+
return this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push({ callback: t, once: !0 }), this;
|
|
10
|
+
}
|
|
11
|
+
off(e, t) {
|
|
12
|
+
if (!t)
|
|
13
|
+
return this.listeners.delete(e), this;
|
|
14
|
+
const i = this.listeners.get(e);
|
|
15
|
+
return i && this.listeners.set(e, i.filter((s) => s.callback !== t)), this;
|
|
16
|
+
}
|
|
17
|
+
emit(e, ...t) {
|
|
18
|
+
const i = this.listeners.get(e);
|
|
19
|
+
if (!i) return this;
|
|
20
|
+
const s = [];
|
|
21
|
+
for (const r of i)
|
|
22
|
+
r.callback(...t), r.once && s.push(r);
|
|
23
|
+
return s.length && this.listeners.set(e, i.filter((r) => !s.includes(r))), this;
|
|
24
|
+
}
|
|
25
|
+
removeAllListeners() {
|
|
26
|
+
this.listeners.clear();
|
|
27
|
+
}
|
|
28
|
+
static mapEvent(e, t) {
|
|
29
|
+
return `${e}:${t.toLowerCase()}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function J(c) {
|
|
33
|
+
if (typeof c == "string") {
|
|
34
|
+
const e = document.getElementById(c);
|
|
35
|
+
if (!e) throw new Error(`KatuCharts: container element "${c}" not found`);
|
|
36
|
+
return e;
|
|
37
|
+
}
|
|
38
|
+
return c;
|
|
39
|
+
}
|
|
40
|
+
function E(c, e) {
|
|
41
|
+
const t = document.createElement("div");
|
|
42
|
+
return c && (t.className = c), e && e.appendChild(t), t;
|
|
43
|
+
}
|
|
44
|
+
function R(c) {
|
|
45
|
+
c && c.parentNode && c.parentNode.removeChild(c);
|
|
46
|
+
}
|
|
47
|
+
const U = 20;
|
|
48
|
+
function M(c) {
|
|
49
|
+
return typeof c == "object" && c !== null && !Array.isArray(c) && Object.getPrototypeOf(c) === Object.prototype;
|
|
50
|
+
}
|
|
51
|
+
function D(c, ...e) {
|
|
52
|
+
return H(c, e, 0);
|
|
53
|
+
}
|
|
54
|
+
function H(c, e, t) {
|
|
55
|
+
if (t > U) return c;
|
|
56
|
+
const i = { ...c };
|
|
57
|
+
for (const s of e)
|
|
58
|
+
if (s)
|
|
59
|
+
for (const r of Object.keys(s)) {
|
|
60
|
+
if (r === "__proto__" || r === "constructor" || r === "prototype") continue;
|
|
61
|
+
const n = s[r], a = i[r];
|
|
62
|
+
n !== void 0 && (n === null ? i[r] = null : M(n) && M(a) ? i[r] = H(a, [n], t + 1) : Array.isArray(n) ? i[r] = [...n] : i[r] = n);
|
|
63
|
+
}
|
|
64
|
+
return i;
|
|
65
|
+
}
|
|
66
|
+
function q(c, e) {
|
|
67
|
+
let t = 0, i = null;
|
|
68
|
+
return function(...s) {
|
|
69
|
+
const r = Date.now(), n = e - (r - t);
|
|
70
|
+
n <= 0 ? (i && (clearTimeout(i), i = null), t = r, c.apply(this, s)) : i || (i = setTimeout(() => {
|
|
71
|
+
t = Date.now(), i = null, c.apply(this, s);
|
|
72
|
+
}, n));
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function V(c, e) {
|
|
76
|
+
let t = null;
|
|
77
|
+
return function(...i) {
|
|
78
|
+
t && clearTimeout(t), t = setTimeout(() => {
|
|
79
|
+
c.apply(this, i);
|
|
80
|
+
}, e);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const K = {
|
|
84
|
+
data: [],
|
|
85
|
+
responsive: !0,
|
|
86
|
+
sorting: {
|
|
87
|
+
enabled: !0,
|
|
88
|
+
multiSort: !1,
|
|
89
|
+
defaultSort: []
|
|
90
|
+
},
|
|
91
|
+
filtering: {
|
|
92
|
+
enabled: !0,
|
|
93
|
+
position: "header"
|
|
94
|
+
},
|
|
95
|
+
search: {
|
|
96
|
+
enabled: !1,
|
|
97
|
+
placeholder: "Search...",
|
|
98
|
+
debounceMs: 300,
|
|
99
|
+
caseSensitive: !1
|
|
100
|
+
},
|
|
101
|
+
pagination: {
|
|
102
|
+
enabled: !0,
|
|
103
|
+
pageSize: 25,
|
|
104
|
+
pageSizes: [10, 25, 50, 100],
|
|
105
|
+
position: "bottom",
|
|
106
|
+
showPageSizeSelector: !0,
|
|
107
|
+
showPageInfo: !0,
|
|
108
|
+
showFirstLast: !0
|
|
109
|
+
},
|
|
110
|
+
selection: {
|
|
111
|
+
mode: "none",
|
|
112
|
+
checkbox: !1,
|
|
113
|
+
selectAll: !0,
|
|
114
|
+
preserveOnFilter: !1
|
|
115
|
+
},
|
|
116
|
+
editing: {
|
|
117
|
+
enabled: !1,
|
|
118
|
+
mode: "cell",
|
|
119
|
+
saveOnBlur: !0
|
|
120
|
+
},
|
|
121
|
+
columnPinning: { enabled: !1 },
|
|
122
|
+
columnResizing: { enabled: !0 },
|
|
123
|
+
columnReordering: { enabled: !1 },
|
|
124
|
+
columnVisibility: { enabled: !0 },
|
|
125
|
+
grouping: {
|
|
126
|
+
enabled: !1,
|
|
127
|
+
expanded: !0,
|
|
128
|
+
showCount: !0
|
|
129
|
+
},
|
|
130
|
+
virtualScroll: {
|
|
131
|
+
enabled: !1,
|
|
132
|
+
rowHeight: 36,
|
|
133
|
+
overscan: 10,
|
|
134
|
+
threshold: 1e3
|
|
135
|
+
},
|
|
136
|
+
masterDetail: {
|
|
137
|
+
enabled: !1,
|
|
138
|
+
expandOnRowClick: !1,
|
|
139
|
+
singleExpand: !1,
|
|
140
|
+
expandIcon: "▶",
|
|
141
|
+
collapseIcon: "▼"
|
|
142
|
+
},
|
|
143
|
+
treeData: {
|
|
144
|
+
enabled: !1,
|
|
145
|
+
childrenField: "children",
|
|
146
|
+
expandAll: !1,
|
|
147
|
+
indent: 20
|
|
148
|
+
},
|
|
149
|
+
contextMenu: {
|
|
150
|
+
enabled: !1
|
|
151
|
+
},
|
|
152
|
+
toolbar: {
|
|
153
|
+
enabled: !0,
|
|
154
|
+
position: "top",
|
|
155
|
+
items: ["search", "columnToggle", "export"]
|
|
156
|
+
},
|
|
157
|
+
exporting: {
|
|
158
|
+
enabled: !0,
|
|
159
|
+
formats: ["csv", "json", "clipboard"],
|
|
160
|
+
csv: {
|
|
161
|
+
delimiter: ",",
|
|
162
|
+
lineDelimiter: `
|
|
163
|
+
`,
|
|
164
|
+
decimalPoint: ".",
|
|
165
|
+
includeHeaders: !0,
|
|
166
|
+
onlyVisible: !0
|
|
167
|
+
},
|
|
168
|
+
json: {
|
|
169
|
+
indent: 2,
|
|
170
|
+
onlyVisible: !0
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
serverSide: {
|
|
174
|
+
enabled: !1,
|
|
175
|
+
method: "GET",
|
|
176
|
+
debounceMs: 300,
|
|
177
|
+
loadingText: "Loading..."
|
|
178
|
+
},
|
|
179
|
+
style: {
|
|
180
|
+
density: "normal",
|
|
181
|
+
stripedRows: !1,
|
|
182
|
+
showBorders: "horizontal"
|
|
183
|
+
},
|
|
184
|
+
/**
|
|
185
|
+
* UI strings are resolved per-locale at construction time (English base, then
|
|
186
|
+
* the matched locale pack, then these user overrides), so the defaults stay empty.
|
|
187
|
+
*/
|
|
188
|
+
lang: {}
|
|
189
|
+
}, Y = {
|
|
190
|
+
compact: 34,
|
|
191
|
+
normal: 44,
|
|
192
|
+
comfortable: 56
|
|
193
|
+
}, X = {
|
|
194
|
+
compact: 36,
|
|
195
|
+
normal: 44,
|
|
196
|
+
comfortable: 52
|
|
197
|
+
};
|
|
198
|
+
function Q(c) {
|
|
199
|
+
let e = 0, t = 0, i = 0, s = 0;
|
|
200
|
+
for (const n of c)
|
|
201
|
+
if (!(n == null || n === "")) {
|
|
202
|
+
if (s++, typeof n == "boolean") {
|
|
203
|
+
t++;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (typeof n == "number" || typeof n == "string" && !isNaN(Number(n)) && n.trim() !== "") {
|
|
207
|
+
e++;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (n instanceof Date) {
|
|
211
|
+
i++;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (typeof n == "string") {
|
|
215
|
+
const a = Date.parse(n);
|
|
216
|
+
if (!isNaN(a) && n.length >= 8 && /\d/.test(n) && /[-/T]/.test(n)) {
|
|
217
|
+
i++;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (s === 0) return "string";
|
|
223
|
+
const r = 0.7;
|
|
224
|
+
return t / s >= r ? "boolean" : i / s >= r ? "date" : e / s >= r ? "number" : "string";
|
|
225
|
+
}
|
|
226
|
+
function Z(c) {
|
|
227
|
+
if (!c.length) return [];
|
|
228
|
+
const e = c[0];
|
|
229
|
+
if (Array.isArray(e))
|
|
230
|
+
return e.map((n, a) => ({
|
|
231
|
+
field: String(a),
|
|
232
|
+
title: `Column ${a + 1}`
|
|
233
|
+
}));
|
|
234
|
+
const t = Object.keys(e), i = Math.min(c.length, 100), s = c.slice(0, i), r = [];
|
|
235
|
+
for (const n of t) {
|
|
236
|
+
const a = e[n];
|
|
237
|
+
if (a !== null && typeof a == "object" && !Array.isArray(a) && !(a instanceof Date))
|
|
238
|
+
continue;
|
|
239
|
+
const o = s.map((d) => d[n]), l = Q(o);
|
|
240
|
+
r.push({
|
|
241
|
+
field: n,
|
|
242
|
+
title: j(n),
|
|
243
|
+
type: l
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return r;
|
|
247
|
+
}
|
|
248
|
+
function j(c) {
|
|
249
|
+
return c.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()).trim();
|
|
250
|
+
}
|
|
251
|
+
function ee(c) {
|
|
252
|
+
switch (c) {
|
|
253
|
+
case "number":
|
|
254
|
+
return "right";
|
|
255
|
+
case "boolean":
|
|
256
|
+
return "center";
|
|
257
|
+
default:
|
|
258
|
+
return "left";
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function S(c, e) {
|
|
262
|
+
return e.accessorFn ? e.accessorFn(c) : c == null ? void 0 : c[e.field];
|
|
263
|
+
}
|
|
264
|
+
const L = {
|
|
265
|
+
number: { min: 80, ideal: 100, cap: 170 },
|
|
266
|
+
boolean: { min: 64, ideal: 84, cap: 120 },
|
|
267
|
+
date: { min: 100, ideal: 128, cap: 190 },
|
|
268
|
+
string: { min: 96, ideal: 140, cap: 320 },
|
|
269
|
+
html: { min: 96, ideal: 160, cap: 360 }
|
|
270
|
+
}, te = 7.4, ie = 34;
|
|
271
|
+
function se(c, e, t) {
|
|
272
|
+
const i = L[e] ?? L.string, s = c.sortable === !1 ? 0 : 18;
|
|
273
|
+
let r = String(c.title ?? c.field ?? "").length;
|
|
274
|
+
const n = t.length > 30 ? t.slice(0, 30) : t;
|
|
275
|
+
for (const o of n) {
|
|
276
|
+
const l = S(o, c);
|
|
277
|
+
if (l == null) continue;
|
|
278
|
+
const d = String(l).length;
|
|
279
|
+
d > r && (r = d);
|
|
280
|
+
}
|
|
281
|
+
let a = Math.round(r * te + ie + s);
|
|
282
|
+
return (c.cell || c.formatter || e === "number" || e === "boolean") && (a = Math.max(a, i.ideal)), Math.min(i.cap, Math.max(i.min, a));
|
|
283
|
+
}
|
|
284
|
+
function re(c, e, t = [], i = 0) {
|
|
285
|
+
const s = c.map((r, n) => {
|
|
286
|
+
var w;
|
|
287
|
+
const a = r.field ?? r.accessorKey ?? r.id ?? String(n), o = r.id ?? r.accessorKey ?? r.field ?? String(n), l = r.title ?? (typeof r.header == "string" ? r.header : void 0) ?? j(a), d = r.type ?? "string", h = r.width ?? (r.size != null ? r.size : void 0), u = r.minWidth ?? r.minSize, g = r.maxWidth ?? r.maxSize, p = h !== void 0, f = p ? ae(h, ((w = L[d]) == null ? void 0 : w.ideal) ?? 140, e) : Math.min(g ?? 1 / 0, Math.max(u ?? 0, se(r, d, t))), y = r.sortable ?? r.enableSorting ?? !0, x = r.filterable ?? r.enableColumnFilter ?? !0, k = r.enableHiding ?? !0;
|
|
288
|
+
return {
|
|
289
|
+
...r,
|
|
290
|
+
field: a,
|
|
291
|
+
id: o,
|
|
292
|
+
title: l,
|
|
293
|
+
type: d,
|
|
294
|
+
width: h,
|
|
295
|
+
minWidth: u,
|
|
296
|
+
maxWidth: g,
|
|
297
|
+
align: r.align ?? ee(d),
|
|
298
|
+
visible: r.visible !== !1,
|
|
299
|
+
sortable: y !== !1,
|
|
300
|
+
filterable: x !== !1,
|
|
301
|
+
enableHiding: k,
|
|
302
|
+
resizable: r.resizable !== !1,
|
|
303
|
+
reorderable: r.reorderable !== !1,
|
|
304
|
+
pinned: r.pinned ?? null,
|
|
305
|
+
_index: n,
|
|
306
|
+
_computedWidth: f,
|
|
307
|
+
_explicitWidth: p,
|
|
308
|
+
_visible: r.visible !== !1,
|
|
309
|
+
_sortDirection: null,
|
|
310
|
+
_sortPriority: -1,
|
|
311
|
+
_filterValue: null,
|
|
312
|
+
_pinnedOffset: 0
|
|
313
|
+
};
|
|
314
|
+
});
|
|
315
|
+
return ne(s, e, i), s;
|
|
316
|
+
}
|
|
317
|
+
function ne(c, e, t) {
|
|
318
|
+
const i = c.filter((d) => d._visible);
|
|
319
|
+
if (!i.length || e <= 0) return;
|
|
320
|
+
const s = e - t - 2, r = i.reduce((d, h) => d + h._computedWidth, 0);
|
|
321
|
+
let n = s - r;
|
|
322
|
+
if (n <= 0) return;
|
|
323
|
+
const a = i.filter((d) => !d._explicitWidth && (d.type === "string" || d.type === "html") && d.align !== "right");
|
|
324
|
+
let o = a.length ? a : i.filter((d) => !d._explicitWidth);
|
|
325
|
+
if (!o.length) return;
|
|
326
|
+
const l = new Map(o.map((d) => [d, Math.max(160, d._computedWidth)]));
|
|
327
|
+
for (; n > 1 && o.length; ) {
|
|
328
|
+
const d = o.reduce((g, p) => g + (l.get(p) || 0), 0);
|
|
329
|
+
if (d <= 0) break;
|
|
330
|
+
let h = 0;
|
|
331
|
+
const u = [];
|
|
332
|
+
if (o.forEach((g) => {
|
|
333
|
+
const p = Math.round(n * ((l.get(g) || 0) / d)), f = Math.min(p, l.get(g) || 0);
|
|
334
|
+
g._computedWidth += f, l.set(g, (l.get(g) || 0) - f), h += f, (l.get(g) || 0) > 0 && u.push(g);
|
|
335
|
+
}), h <= 0) break;
|
|
336
|
+
n -= h, o = u;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function ae(c, e, t) {
|
|
340
|
+
if (c === void 0) return e;
|
|
341
|
+
if (typeof c == "number") return c;
|
|
342
|
+
if (c.endsWith("%")) {
|
|
343
|
+
const i = parseFloat(c) / 100;
|
|
344
|
+
return Math.floor(t * i);
|
|
345
|
+
}
|
|
346
|
+
return c.endsWith("px") ? parseFloat(c) : e;
|
|
347
|
+
}
|
|
348
|
+
function oe(c) {
|
|
349
|
+
return c.filter((e) => e._visible);
|
|
350
|
+
}
|
|
351
|
+
function $(c) {
|
|
352
|
+
const e = oe(c);
|
|
353
|
+
let t = 0;
|
|
354
|
+
for (const s of e)
|
|
355
|
+
s.pinned === "left" && (s._pinnedOffset = t, t += s._computedWidth);
|
|
356
|
+
let i = 0;
|
|
357
|
+
for (let s = e.length - 1; s >= 0; s--) {
|
|
358
|
+
const r = e[s];
|
|
359
|
+
r.pinned === "right" && (r._pinnedOffset = i, i += r._computedWidth);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
class A {
|
|
363
|
+
constructor(e, t) {
|
|
364
|
+
this.responsiveHidden = /* @__PURE__ */ new Set(), this.columns = e, this.events = t;
|
|
365
|
+
}
|
|
366
|
+
getColumns() {
|
|
367
|
+
return this.columns;
|
|
368
|
+
}
|
|
369
|
+
setColumns(e) {
|
|
370
|
+
this.columns = e;
|
|
371
|
+
}
|
|
372
|
+
getVisibleColumns() {
|
|
373
|
+
return this.columns.filter((e) => e._visible);
|
|
374
|
+
}
|
|
375
|
+
showColumn(e) {
|
|
376
|
+
const t = this.find(e);
|
|
377
|
+
t && (t._visible = !0, t.visible = !0, this.responsiveHidden.delete(e), this.recalcPinning(), this.events.emit("column:show", { field: e }));
|
|
378
|
+
}
|
|
379
|
+
hideColumn(e) {
|
|
380
|
+
const t = this.find(e);
|
|
381
|
+
t && (t._visible = !1, t.visible = !1, this.recalcPinning(), this.events.emit("column:hide", { field: e }));
|
|
382
|
+
}
|
|
383
|
+
toggleColumn(e, t) {
|
|
384
|
+
t ? this.showColumn(e) : this.hideColumn(e);
|
|
385
|
+
}
|
|
386
|
+
pinColumn(e, t) {
|
|
387
|
+
const i = this.find(e);
|
|
388
|
+
i && (i.pinned = t, this.recalcPinning(), this.events.emit("column:pin", { field: e, direction: t }));
|
|
389
|
+
}
|
|
390
|
+
reorderColumn(e, t) {
|
|
391
|
+
const i = this.columns.findIndex((r) => r.field === e);
|
|
392
|
+
if (i < 0 || t < 0 || t >= this.columns.length) return;
|
|
393
|
+
const [s] = this.columns.splice(i, 1);
|
|
394
|
+
this.columns.splice(t, 0, s), this.columns.forEach((r, n) => {
|
|
395
|
+
r._index = n;
|
|
396
|
+
}), this.recalcPinning(), this.events.emit("column:reorder", { field: e, fromIndex: i, toIndex: t });
|
|
397
|
+
}
|
|
398
|
+
resizeColumn(e, t) {
|
|
399
|
+
const i = this.find(e);
|
|
400
|
+
i && (i._computedWidth = Math.max(i.minWidth ?? 40, Math.min(i.maxWidth ?? 2e3, t)), this.recalcPinning());
|
|
401
|
+
}
|
|
402
|
+
updateColumn(e, t) {
|
|
403
|
+
const i = this.find(e);
|
|
404
|
+
i && (Object.assign(i, t), t.visible !== void 0 && (i._visible = t.visible), this.recalcPinning());
|
|
405
|
+
}
|
|
406
|
+
applyResponsiveHiding(e) {
|
|
407
|
+
const t = this.columns.filter((r) => r._visible && !this.responsiveHidden.has(r.field)), i = t.reduce((r, n) => r + n._computedWidth, 0), s = [];
|
|
408
|
+
if (i > e) {
|
|
409
|
+
const r = [...t].filter((a) => a.priority !== void 0).sort((a, o) => (a.priority ?? 1 / 0) - (o.priority ?? 1 / 0));
|
|
410
|
+
let n = i;
|
|
411
|
+
for (const a of r) {
|
|
412
|
+
if (n <= e) break;
|
|
413
|
+
a._visible = !1, this.responsiveHidden.add(a.field), n -= a._computedWidth, s.push(a.field);
|
|
414
|
+
}
|
|
415
|
+
} else
|
|
416
|
+
for (const r of this.responsiveHidden) {
|
|
417
|
+
const n = this.find(r);
|
|
418
|
+
n && n.visible !== !1 && (n._visible = !0, this.responsiveHidden.delete(r));
|
|
419
|
+
}
|
|
420
|
+
return s.length && this.recalcPinning(), s;
|
|
421
|
+
}
|
|
422
|
+
setSortState(e) {
|
|
423
|
+
for (const t of this.columns)
|
|
424
|
+
t._sortDirection = null, t._sortPriority = -1;
|
|
425
|
+
e.forEach(({ column: t, direction: i }, s) => {
|
|
426
|
+
const r = this.find(t);
|
|
427
|
+
r && (r._sortDirection = i, r._sortPriority = e.length > 1 ? s : -1);
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
setFilterValue(e, t) {
|
|
431
|
+
const i = this.find(e);
|
|
432
|
+
i && (i._filterValue = t);
|
|
433
|
+
}
|
|
434
|
+
clearFilters() {
|
|
435
|
+
for (const e of this.columns)
|
|
436
|
+
e._filterValue = null;
|
|
437
|
+
}
|
|
438
|
+
find(e) {
|
|
439
|
+
return this.columns.find((t) => t.field === e);
|
|
440
|
+
}
|
|
441
|
+
recalcPinning() {
|
|
442
|
+
$(this.columns);
|
|
443
|
+
}
|
|
444
|
+
destroy() {
|
|
445
|
+
this.columns = [], this.responsiveHidden.clear();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
class le {
|
|
449
|
+
constructor(e) {
|
|
450
|
+
this.rawData = [], this.options = e;
|
|
451
|
+
}
|
|
452
|
+
loadSync() {
|
|
453
|
+
return this.options.chart ? this.rawData = this.extractChartData(this.options.chart) : Array.isArray(this.options.data) && (this.rawData = this.normalizeData(this.options.data)), { data: this.rawData, total: this.rawData.length };
|
|
454
|
+
}
|
|
455
|
+
async load() {
|
|
456
|
+
var e, t;
|
|
457
|
+
return (e = this.options.serverSide) != null && e.enabled && this.options.serverSide.url ? this.loadServerSide({
|
|
458
|
+
page: 1,
|
|
459
|
+
pageSize: ((t = this.options.pagination) == null ? void 0 : t.pageSize) ?? 25,
|
|
460
|
+
sort: [],
|
|
461
|
+
filters: {},
|
|
462
|
+
search: ""
|
|
463
|
+
}) : this.loadSync();
|
|
464
|
+
}
|
|
465
|
+
async loadServerSide(e) {
|
|
466
|
+
const t = this.options.serverSide, i = t.url, s = t.method ?? "GET", r = {
|
|
467
|
+
"Content-Type": "application/json",
|
|
468
|
+
...t.headers ?? {}
|
|
469
|
+
}, n = t.requestMapper ? t.requestMapper(e) : e;
|
|
470
|
+
let a;
|
|
471
|
+
if (s === "GET") {
|
|
472
|
+
const l = new URLSearchParams();
|
|
473
|
+
for (const [d, h] of Object.entries(n))
|
|
474
|
+
l.set(d, typeof h == "object" ? JSON.stringify(h) : String(h));
|
|
475
|
+
a = await fetch(`${i}?${l.toString()}`, { method: s, headers: r });
|
|
476
|
+
} else
|
|
477
|
+
a = await fetch(i, {
|
|
478
|
+
method: s,
|
|
479
|
+
headers: r,
|
|
480
|
+
body: JSON.stringify(n)
|
|
481
|
+
});
|
|
482
|
+
if (!a.ok)
|
|
483
|
+
throw new Error(`DataTable: server request failed with status ${a.status}`);
|
|
484
|
+
const o = await a.json();
|
|
485
|
+
return t.responseMapper ? t.responseMapper(o) : {
|
|
486
|
+
data: o.data ?? o,
|
|
487
|
+
total: o.total ?? o.length ?? 0
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
setData(e) {
|
|
491
|
+
return this.rawData = this.normalizeData(e), { data: this.rawData, total: this.rawData.length };
|
|
492
|
+
}
|
|
493
|
+
getData() {
|
|
494
|
+
return this.rawData;
|
|
495
|
+
}
|
|
496
|
+
addRow(e, t) {
|
|
497
|
+
const i = this.normalizeRow(e);
|
|
498
|
+
t !== void 0 && t >= 0 && t <= this.rawData.length ? this.rawData.splice(t, 0, i) : this.rawData.push(i);
|
|
499
|
+
}
|
|
500
|
+
removeRow(e) {
|
|
501
|
+
if (e >= 0 && e < this.rawData.length)
|
|
502
|
+
return this.rawData.splice(e, 1)[0];
|
|
503
|
+
}
|
|
504
|
+
updateRow(e, t) {
|
|
505
|
+
e >= 0 && e < this.rawData.length && Object.assign(this.rawData[e], t);
|
|
506
|
+
}
|
|
507
|
+
updateCell(e, t, i) {
|
|
508
|
+
e >= 0 && e < this.rawData.length && (this.rawData[e][t] = i);
|
|
509
|
+
}
|
|
510
|
+
normalizeData(e) {
|
|
511
|
+
return e.length ? Array.isArray(e[0]) ? e.map((t, i) => {
|
|
512
|
+
const s = {};
|
|
513
|
+
return t.forEach((r, n) => {
|
|
514
|
+
s[String(n)] = r;
|
|
515
|
+
}), s;
|
|
516
|
+
}) : e.map((t) => ({ ...t })) : [];
|
|
517
|
+
}
|
|
518
|
+
normalizeRow(e) {
|
|
519
|
+
if (Array.isArray(e)) {
|
|
520
|
+
const t = {};
|
|
521
|
+
return e.forEach((i, s) => {
|
|
522
|
+
t[String(s)] = i;
|
|
523
|
+
}), t;
|
|
524
|
+
}
|
|
525
|
+
return { ...e };
|
|
526
|
+
}
|
|
527
|
+
extractChartData(e) {
|
|
528
|
+
var t, i;
|
|
529
|
+
try {
|
|
530
|
+
if (typeof e.getDataRows == "function") {
|
|
531
|
+
const s = e.getDataRows();
|
|
532
|
+
if (s.length < 2) return [];
|
|
533
|
+
const r = s[0];
|
|
534
|
+
return s.slice(1).map((n) => {
|
|
535
|
+
const a = {};
|
|
536
|
+
return r.forEach((o, l) => {
|
|
537
|
+
a[o] = n[l];
|
|
538
|
+
}), a;
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
if (e.series) {
|
|
542
|
+
const s = typeof e.series == "function" ? e.series() : e.series, r = [];
|
|
543
|
+
for (const n of s) {
|
|
544
|
+
const a = n.data ?? ((t = n.options) == null ? void 0 : t.data) ?? [], o = n.name ?? ((i = n.options) == null ? void 0 : i.name) ?? "Series";
|
|
545
|
+
for (const l of a)
|
|
546
|
+
typeof l == "object" && l !== null ? r.push({ series: o, ...l }) : r.push({ series: o, value: l });
|
|
547
|
+
}
|
|
548
|
+
return r;
|
|
549
|
+
}
|
|
550
|
+
} catch {
|
|
551
|
+
}
|
|
552
|
+
return [];
|
|
553
|
+
}
|
|
554
|
+
updateOptions(e) {
|
|
555
|
+
this.options = e;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
const T = ["search", "filter", "group", "sort", "aggregate", "paginate", "window"];
|
|
559
|
+
class ce {
|
|
560
|
+
constructor() {
|
|
561
|
+
this.caches = /* @__PURE__ */ new Map(), this.dirtyFrom = 0;
|
|
562
|
+
}
|
|
563
|
+
invalidate(e) {
|
|
564
|
+
const t = T.indexOf(e);
|
|
565
|
+
t >= 0 && t < this.dirtyFrom ? this.dirtyFrom = t : t >= 0 && (this.dirtyFrom = Math.min(this.dirtyFrom, t));
|
|
566
|
+
}
|
|
567
|
+
invalidateAll() {
|
|
568
|
+
this.dirtyFrom = 0, this.caches.clear();
|
|
569
|
+
}
|
|
570
|
+
process(e, t, i) {
|
|
571
|
+
var u;
|
|
572
|
+
let s = e;
|
|
573
|
+
this.shouldRun("search") ? (s = this.applySearch(s, t, i), this.caches.set("search", s)) : s = this.caches.get("search") ?? s, this.shouldRun("filter") ? (s = this.applyFilters(s, t, i), this.caches.set("filter", s)) : s = this.caches.get("filter") ?? s;
|
|
574
|
+
const r = s.length;
|
|
575
|
+
let n;
|
|
576
|
+
this.shouldRun("group") || this.shouldRun("sort") ? ((u = i.treeData) != null && u.enabled ? n = this.flattenTree(s, i.treeData) : i.groupBy.length > 0 ? n = this.applyGrouping(s, i) : n = s.map((g, p) => this.makeDataRow(g, p)), n = this.applySorting(n, t, i), this.caches.set("sort", n)) : n = this.caches.get("sort") ?? s.map((g, p) => this.makeDataRow(g, p));
|
|
577
|
+
const a = this.computeAggregates(s, t), o = this.extractGroups(n);
|
|
578
|
+
let l, d = i.page, h = 1;
|
|
579
|
+
if (i.paginationEnabled && !i.virtualEnabled) {
|
|
580
|
+
h = Math.max(1, Math.ceil(r / i.pageSize)), d > h && (d = h);
|
|
581
|
+
const g = (d - 1) * i.pageSize;
|
|
582
|
+
l = this.applyPagination(n, g, i.pageSize);
|
|
583
|
+
} else i.virtualEnabled ? l = this.applyVirtualWindow(n, i) : l = n;
|
|
584
|
+
return this.dirtyFrom = T.length, {
|
|
585
|
+
rows: l,
|
|
586
|
+
totalFiltered: r,
|
|
587
|
+
totalAll: e.length,
|
|
588
|
+
aggregates: a,
|
|
589
|
+
groups: o
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
shouldRun(e) {
|
|
593
|
+
return T.indexOf(e) >= this.dirtyFrom;
|
|
594
|
+
}
|
|
595
|
+
applySearch(e, t, i) {
|
|
596
|
+
const s = i.search.trim();
|
|
597
|
+
if (!s) return e;
|
|
598
|
+
const r = i.searchColumns ? t.filter((a) => i.searchColumns.includes(a.field)) : t.filter((a) => a._visible && a.type !== "html"), n = i.caseSensitive ? s : s.toLowerCase();
|
|
599
|
+
return e.filter((a) => {
|
|
600
|
+
for (const o of r) {
|
|
601
|
+
const l = S(a, o);
|
|
602
|
+
if (l == null) continue;
|
|
603
|
+
if ((i.caseSensitive ? String(l) : String(l).toLowerCase()).includes(n)) return !0;
|
|
604
|
+
}
|
|
605
|
+
return !1;
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
applyFilters(e, t, i) {
|
|
609
|
+
const s = Object.entries(i.filters).filter(([r, n]) => n != null && n !== "");
|
|
610
|
+
return s.length ? e.filter((r) => {
|
|
611
|
+
for (const [n, a] of s) {
|
|
612
|
+
const o = t.find((d) => d.field === n);
|
|
613
|
+
if (!o) continue;
|
|
614
|
+
if (o.filterFn) {
|
|
615
|
+
if (!o.filterFn(r, n, a)) return !1;
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
const l = S(r, o);
|
|
619
|
+
if (!this.matchesFilter(l, a, o)) return !1;
|
|
620
|
+
}
|
|
621
|
+
return !0;
|
|
622
|
+
}) : e;
|
|
623
|
+
}
|
|
624
|
+
matchesFilter(e, t, i) {
|
|
625
|
+
if (t == null || t === "") return !0;
|
|
626
|
+
switch (i.filterType ?? this.inferFilterType(i)) {
|
|
627
|
+
case "text":
|
|
628
|
+
return e == null ? !1 : String(e).toLowerCase().includes(String(t).toLowerCase());
|
|
629
|
+
case "number": {
|
|
630
|
+
const r = Number(e);
|
|
631
|
+
if (isNaN(r)) return !1;
|
|
632
|
+
if (typeof t == "object" && t !== null) {
|
|
633
|
+
const { min: n, max: a } = t;
|
|
634
|
+
return !(n != null && r < Number(n) || a != null && r > Number(a));
|
|
635
|
+
}
|
|
636
|
+
return r === Number(t);
|
|
637
|
+
}
|
|
638
|
+
case "boolean":
|
|
639
|
+
return typeof t == "boolean" ? !!e === t : String(e) === String(t);
|
|
640
|
+
case "multiselect":
|
|
641
|
+
case "faceted":
|
|
642
|
+
return Array.isArray(t) ? t.length === 0 || t.map(String).includes(String(e)) : String(e) === String(t);
|
|
643
|
+
case "select":
|
|
644
|
+
return Array.isArray(t) ? t.length === 0 || t.includes(e) : String(e) === String(t);
|
|
645
|
+
case "date":
|
|
646
|
+
case "daterange": {
|
|
647
|
+
const r = new Date(e).getTime();
|
|
648
|
+
if (isNaN(r)) return !1;
|
|
649
|
+
if (typeof t == "object" && t !== null) {
|
|
650
|
+
const { from: n, to: a } = t;
|
|
651
|
+
return !(n && r < new Date(n).getTime() || a && r > new Date(a).getTime());
|
|
652
|
+
}
|
|
653
|
+
return new Date(e).toDateString() === new Date(t).toDateString();
|
|
654
|
+
}
|
|
655
|
+
case "numberrange": {
|
|
656
|
+
const r = Number(e);
|
|
657
|
+
if (isNaN(r)) return !1;
|
|
658
|
+
const { min: n, max: a } = t;
|
|
659
|
+
return !(n != null && r < Number(n) || a != null && r > Number(a));
|
|
660
|
+
}
|
|
661
|
+
default:
|
|
662
|
+
return !0;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
inferFilterType(e) {
|
|
666
|
+
switch (e.type) {
|
|
667
|
+
case "number":
|
|
668
|
+
return "number";
|
|
669
|
+
case "date":
|
|
670
|
+
return "date";
|
|
671
|
+
case "boolean":
|
|
672
|
+
return "boolean";
|
|
673
|
+
default:
|
|
674
|
+
return "text";
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
applySorting(e, t, i) {
|
|
678
|
+
if (!i.sort.length) return e;
|
|
679
|
+
const s = e.filter((n) => n._type === "data"), r = e.filter((n) => n._type !== "data");
|
|
680
|
+
return s.sort((n, a) => {
|
|
681
|
+
for (const { column: o, direction: l } of i.sort) {
|
|
682
|
+
if (!l) continue;
|
|
683
|
+
const d = t.find((f) => f.field === o), h = l === "asc" ? 1 : -1, u = d ? S(n._data, d) : n._data[o], g = d ? S(a._data, d) : a._data[o];
|
|
684
|
+
let p;
|
|
685
|
+
if (d != null && d.comparator ? p = d.comparator(u, g) : p = this.defaultCompare(u, g, d == null ? void 0 : d.type), p !== 0) return p * h;
|
|
686
|
+
}
|
|
687
|
+
return 0;
|
|
688
|
+
}), r.length === 0 ? s : this.reinterlaceGrouped(s, r, i);
|
|
689
|
+
}
|
|
690
|
+
defaultCompare(e, t, i) {
|
|
691
|
+
if (e == null && t == null) return 0;
|
|
692
|
+
if (e == null) return -1;
|
|
693
|
+
if (t == null) return 1;
|
|
694
|
+
switch (i) {
|
|
695
|
+
case "number":
|
|
696
|
+
return Number(e) - Number(t);
|
|
697
|
+
case "date":
|
|
698
|
+
return new Date(e).getTime() - new Date(t).getTime();
|
|
699
|
+
case "boolean":
|
|
700
|
+
return e === t ? 0 : e ? -1 : 1;
|
|
701
|
+
default:
|
|
702
|
+
return String(e).localeCompare(String(t));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
reinterlaceGrouped(e, t, i) {
|
|
706
|
+
if (t.length === 0) return e;
|
|
707
|
+
const s = [], r = /* @__PURE__ */ new Map();
|
|
708
|
+
for (const a of t)
|
|
709
|
+
if (a._type === "group-header") {
|
|
710
|
+
const o = `${a._groupColumn}:${a._groupValue}`;
|
|
711
|
+
r.set(o, a);
|
|
712
|
+
}
|
|
713
|
+
let n = null;
|
|
714
|
+
for (const a of e) {
|
|
715
|
+
for (const [o, l] of r) {
|
|
716
|
+
const [d] = o.split(":"), h = a._data[d], u = `${d}:${h}`;
|
|
717
|
+
u !== n && r.has(u) && (s.push(r.get(u)), n = u);
|
|
718
|
+
}
|
|
719
|
+
s.push(a);
|
|
720
|
+
}
|
|
721
|
+
return s;
|
|
722
|
+
}
|
|
723
|
+
applyGrouping(e, t) {
|
|
724
|
+
const i = t.groupBy[0];
|
|
725
|
+
if (!i) return e.map((a, o) => this.makeDataRow(a, o));
|
|
726
|
+
const s = /* @__PURE__ */ new Map();
|
|
727
|
+
for (const a of e) {
|
|
728
|
+
const o = a[i];
|
|
729
|
+
s.has(o) || s.set(o, []), s.get(o).push(a);
|
|
730
|
+
}
|
|
731
|
+
const r = [];
|
|
732
|
+
let n = 0;
|
|
733
|
+
for (const [a, o] of s) {
|
|
734
|
+
const l = `${i}:${a}`, d = t.groupExpanded.has(l) ? t.groupExpanded.get(l) : !0;
|
|
735
|
+
if (r.push({
|
|
736
|
+
_type: "group-header",
|
|
737
|
+
_index: n++,
|
|
738
|
+
_originalIndex: -1,
|
|
739
|
+
_data: {},
|
|
740
|
+
_depth: 0,
|
|
741
|
+
_groupValue: a,
|
|
742
|
+
_groupColumn: i,
|
|
743
|
+
_groupCount: o.length,
|
|
744
|
+
_expanded: d,
|
|
745
|
+
_visible: !0
|
|
746
|
+
}), d)
|
|
747
|
+
for (const h of o)
|
|
748
|
+
r.push(this.makeDataRow(h, n++));
|
|
749
|
+
}
|
|
750
|
+
return r;
|
|
751
|
+
}
|
|
752
|
+
flattenTree(e, t) {
|
|
753
|
+
const i = t.childrenField ?? "children", s = [];
|
|
754
|
+
let r = 0;
|
|
755
|
+
const n = (a, o, l) => {
|
|
756
|
+
for (const d of a) {
|
|
757
|
+
const h = d[i], u = Array.isArray(h) && h.length > 0, g = t.expandAll !== !1, p = {
|
|
758
|
+
_type: "data",
|
|
759
|
+
_index: r++,
|
|
760
|
+
_originalIndex: r - 1,
|
|
761
|
+
_data: d,
|
|
762
|
+
_depth: o,
|
|
763
|
+
_expanded: u ? g : void 0,
|
|
764
|
+
_visible: !0,
|
|
765
|
+
_parentKey: l
|
|
766
|
+
};
|
|
767
|
+
s.push(p), u && g && n(h, o + 1, `${l}:${r - 1}`);
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
return n(e, 0, ""), s;
|
|
771
|
+
}
|
|
772
|
+
applyPagination(e, t, i) {
|
|
773
|
+
return e.slice(t, t + i);
|
|
774
|
+
}
|
|
775
|
+
applyVirtualWindow(e, t) {
|
|
776
|
+
const { scrollTop: i, viewportHeight: s, virtualRowHeight: r, virtualOverscan: n } = t, a = Math.max(0, Math.floor(i / r) - n), o = Math.ceil(s / r) + n * 2;
|
|
777
|
+
return e.slice(a, a + o);
|
|
778
|
+
}
|
|
779
|
+
computeAggregates(e, t) {
|
|
780
|
+
const i = {};
|
|
781
|
+
for (const s of t) {
|
|
782
|
+
if (!s.aggregate) continue;
|
|
783
|
+
const r = e.map((o) => S(o, s)).filter((o) => o != null), n = r.map(Number).filter((o) => !isNaN(o));
|
|
784
|
+
let a;
|
|
785
|
+
if (typeof s.aggregate == "function")
|
|
786
|
+
a = s.aggregate(r);
|
|
787
|
+
else
|
|
788
|
+
switch (s.aggregate) {
|
|
789
|
+
case "sum":
|
|
790
|
+
a = n.reduce((o, l) => o + l, 0);
|
|
791
|
+
break;
|
|
792
|
+
case "avg":
|
|
793
|
+
a = n.length ? n.reduce((o, l) => o + l, 0) / n.length : 0;
|
|
794
|
+
break;
|
|
795
|
+
case "count":
|
|
796
|
+
a = r.length;
|
|
797
|
+
break;
|
|
798
|
+
case "min":
|
|
799
|
+
a = n.length ? Math.min(...n) : null;
|
|
800
|
+
break;
|
|
801
|
+
case "max":
|
|
802
|
+
a = n.length ? Math.max(...n) : null;
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
i[s.field] = { value: a, type: s.aggregate };
|
|
806
|
+
}
|
|
807
|
+
return i;
|
|
808
|
+
}
|
|
809
|
+
extractGroups(e) {
|
|
810
|
+
const t = [];
|
|
811
|
+
for (const i of e)
|
|
812
|
+
i._type === "group-header" && t.push({
|
|
813
|
+
column: i._groupColumn,
|
|
814
|
+
value: i._groupValue,
|
|
815
|
+
count: i._groupCount,
|
|
816
|
+
expanded: i._expanded,
|
|
817
|
+
rows: [],
|
|
818
|
+
aggregates: {}
|
|
819
|
+
});
|
|
820
|
+
return t;
|
|
821
|
+
}
|
|
822
|
+
makeDataRow(e, t) {
|
|
823
|
+
return {
|
|
824
|
+
_type: "data",
|
|
825
|
+
_index: t,
|
|
826
|
+
_originalIndex: t,
|
|
827
|
+
_data: e,
|
|
828
|
+
_depth: 0,
|
|
829
|
+
_visible: !0
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
const F = {
|
|
834
|
+
default: {},
|
|
835
|
+
bordered: { dataset: { "data-borders": "both" } },
|
|
836
|
+
minimal: { dataset: { "data-borders": "none" }, vars: { "--kdt-header-bg": "transparent" } },
|
|
837
|
+
"striped-dark": { dataset: { "data-theme": "dark", "data-striped": "true" } }
|
|
838
|
+
};
|
|
839
|
+
class de {
|
|
840
|
+
constructor(e = {}) {
|
|
841
|
+
this.style = { ...e }, this.layout = e.layout ?? "default";
|
|
842
|
+
}
|
|
843
|
+
get density() {
|
|
844
|
+
return this.style.density ?? "normal";
|
|
845
|
+
}
|
|
846
|
+
get rowHeight() {
|
|
847
|
+
return this.style.rowHeight ?? Y[this.density];
|
|
848
|
+
}
|
|
849
|
+
get headerHeight() {
|
|
850
|
+
return this.style.headerHeight ?? X[this.density];
|
|
851
|
+
}
|
|
852
|
+
getLayout() {
|
|
853
|
+
return this.layout;
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* CSS custom properties applied to the root element, derived from style
|
|
857
|
+
* options. Anything left unset falls back to the stylesheet defaults.
|
|
858
|
+
*/
|
|
859
|
+
cssVariables(e, t) {
|
|
860
|
+
var a;
|
|
861
|
+
const i = this.style, s = {}, r = (o, l) => {
|
|
862
|
+
l != null && l !== !1 && l !== "" && (s[o] = String(l));
|
|
863
|
+
};
|
|
864
|
+
r("--kdt-font-family", i.fontFamily), r("--kdt-font-size", i.fontSize), r("--kdt-header-font-size", i.headerFontSize), r("--kdt-header-font-weight", i.headerFontWeight), i.borderColor && (r("--kdt-border", i.borderColor), r("--kdt-input", i.borderColor)), r("--kdt-bg", i.background), r("--kdt-fg", i.foreground), r("--kdt-muted", i.mutedColor), r("--kdt-muted-fg", i.mutedForeground), r("--kdt-accent", i.accentColor), r("--kdt-primary", i.primaryColor), r("--kdt-radius", typeof i.radius == "number" ? `${i.radius}px` : i.radius), i.stripedRows && i.alternateRowColor && r("--kdt-stripe-bg", i.alternateRowColor), i.hoverRowColor && r("--kdt-hover-bg", i.hoverRowColor), i.selectedRowColor && r("--kdt-selected-bg", i.selectedRowColor), i.rowHeight && r("--kdt-row-height", `${i.rowHeight}px`), i.headerHeight && r("--kdt-header-height", `${i.headerHeight}px`);
|
|
865
|
+
const n = (a = F[this.layout]) == null ? void 0 : a.vars;
|
|
866
|
+
return n && Object.assign(s, n), i.cssVars && Object.assign(s, i.cssVars), typeof e == "number" ? s.width = `${e}px` : typeof e == "string" && (s.width = e), typeof t == "number" ? s.height = `${t}px` : typeof t == "string" && (s.height = t), s;
|
|
867
|
+
}
|
|
868
|
+
/** `data-*` flags applied to the root element. */
|
|
869
|
+
rootDataset() {
|
|
870
|
+
var s;
|
|
871
|
+
const e = { "data-density": this.density }, t = this.style.showBorders;
|
|
872
|
+
t === !1 || t === "none" ? e["data-borders"] = "none" : t === "vertical" ? e["data-borders"] = "vertical" : t === "both" ? e["data-borders"] = "both" : e["data-borders"] = "horizontal", this.style.stripedRows && (e["data-striped"] = "true"), this.style.theme && (e["data-theme"] = this.style.theme);
|
|
873
|
+
const i = (s = F[this.layout]) == null ? void 0 : s.dataset;
|
|
874
|
+
return i && Object.assign(e, i), e;
|
|
875
|
+
}
|
|
876
|
+
get userContainerStyle() {
|
|
877
|
+
return this.style.containerStyle;
|
|
878
|
+
}
|
|
879
|
+
get userTableStyle() {
|
|
880
|
+
return this.style.tableStyle;
|
|
881
|
+
}
|
|
882
|
+
get userHeaderRowStyle() {
|
|
883
|
+
return this.style.headerStyle;
|
|
884
|
+
}
|
|
885
|
+
get userHeaderCellStyle() {
|
|
886
|
+
return this.style.headerCellStyle;
|
|
887
|
+
}
|
|
888
|
+
get userBodyStyle() {
|
|
889
|
+
return this.style.bodyStyle;
|
|
890
|
+
}
|
|
891
|
+
get userCellStyle() {
|
|
892
|
+
return this.style.cellStyle;
|
|
893
|
+
}
|
|
894
|
+
rowStyle(e) {
|
|
895
|
+
const t = this.style.rowStyle;
|
|
896
|
+
if (t)
|
|
897
|
+
return typeof t == "function" ? t.call(e) : t;
|
|
898
|
+
}
|
|
899
|
+
update(e) {
|
|
900
|
+
e.layout && (this.layout = e.layout), Object.assign(this.style, e);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
const N = "katucharts-datatable-styles", he = `
|
|
904
|
+
.katucharts-datatable {
|
|
905
|
+
--kdt-font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
906
|
+
--kdt-font-size: 14px;
|
|
907
|
+
--kdt-radius: 8px;
|
|
908
|
+
|
|
909
|
+
--kdt-bg: #ffffff;
|
|
910
|
+
--kdt-popover-bg: #ffffff;
|
|
911
|
+
--kdt-fg: #09090b;
|
|
912
|
+
--kdt-muted: #f4f4f5;
|
|
913
|
+
--kdt-muted-fg: #71717a;
|
|
914
|
+
--kdt-border: #e4e4e7;
|
|
915
|
+
--kdt-input: #e4e4e7;
|
|
916
|
+
--kdt-accent: #f4f4f5;
|
|
917
|
+
--kdt-accent-fg: #18181b;
|
|
918
|
+
--kdt-primary: #18181b;
|
|
919
|
+
--kdt-primary-fg: #fafafa;
|
|
920
|
+
--kdt-ring: #a1a1aa;
|
|
921
|
+
|
|
922
|
+
--kdt-header-bg: transparent;
|
|
923
|
+
--kdt-header-fg: var(--kdt-muted-fg);
|
|
924
|
+
--kdt-header-font-size: 13px;
|
|
925
|
+
--kdt-header-font-weight: 500;
|
|
926
|
+
--kdt-hover-bg: var(--kdt-muted);
|
|
927
|
+
--kdt-selected-bg: var(--kdt-muted);
|
|
928
|
+
--kdt-stripe-bg: transparent;
|
|
929
|
+
|
|
930
|
+
--kdt-row-height: 44px;
|
|
931
|
+
--kdt-header-height: 44px;
|
|
932
|
+
--kdt-cell-px: 16px;
|
|
933
|
+
--kdt-cell-py: 10px;
|
|
934
|
+
|
|
935
|
+
position: relative;
|
|
936
|
+
box-sizing: border-box;
|
|
937
|
+
width: 100%;
|
|
938
|
+
font-family: var(--kdt-font-family);
|
|
939
|
+
font-size: var(--kdt-font-size);
|
|
940
|
+
color: var(--kdt-fg);
|
|
941
|
+
background: var(--kdt-bg);
|
|
942
|
+
border: 1px solid var(--kdt-border);
|
|
943
|
+
border-radius: var(--kdt-radius);
|
|
944
|
+
overflow: hidden;
|
|
945
|
+
}
|
|
946
|
+
.katucharts-datatable *,
|
|
947
|
+
.katucharts-datatable *::before,
|
|
948
|
+
.katucharts-datatable *::after { box-sizing: border-box; }
|
|
949
|
+
|
|
950
|
+
/* ── density ───────────────────────────────────────────────── */
|
|
951
|
+
.katucharts-datatable[data-density="compact"] {
|
|
952
|
+
--kdt-row-height: 34px; --kdt-header-height: 36px; --kdt-cell-px: 12px; --kdt-cell-py: 4px;
|
|
953
|
+
}
|
|
954
|
+
.katucharts-datatable[data-density="comfortable"] {
|
|
955
|
+
--kdt-row-height: 56px; --kdt-header-height: 52px; --kdt-cell-px: 20px; --kdt-cell-py: 14px;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/* ── dark theme ────────────────────────────────────────────── */
|
|
959
|
+
.katucharts-datatable[data-theme="dark"] {
|
|
960
|
+
--kdt-bg: #09090b;
|
|
961
|
+
--kdt-popover-bg: #18181b;
|
|
962
|
+
--kdt-fg: #fafafa;
|
|
963
|
+
--kdt-muted: #27272a;
|
|
964
|
+
--kdt-muted-fg: #a1a1aa;
|
|
965
|
+
--kdt-border: #27272a;
|
|
966
|
+
--kdt-input: #27272a;
|
|
967
|
+
--kdt-accent: #27272a;
|
|
968
|
+
--kdt-accent-fg: #fafafa;
|
|
969
|
+
--kdt-primary: #fafafa;
|
|
970
|
+
--kdt-primary-fg: #18181b;
|
|
971
|
+
--kdt-ring: #52525b;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/* ── toolbar ───────────────────────────────────────────────── */
|
|
975
|
+
.katucharts-dt-toolbar {
|
|
976
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
977
|
+
gap: 12px; flex-wrap: wrap;
|
|
978
|
+
padding: 12px;
|
|
979
|
+
background: var(--kdt-bg);
|
|
980
|
+
border-bottom: 1px solid var(--kdt-border);
|
|
981
|
+
}
|
|
982
|
+
.katucharts-dt-toolbar-group { display: flex; align-items: center; gap: 8px; }
|
|
983
|
+
.katucharts-dt-toolbar-group--left { flex: 1 1 auto; }
|
|
984
|
+
|
|
985
|
+
/* ── title ─────────────────────────────────────────────────── */
|
|
986
|
+
.katucharts-dt-title {
|
|
987
|
+
padding: 16px 16px 4px; font-size: 16px; font-weight: 600; color: var(--kdt-fg);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/* ── search ────────────────────────────────────────────────── */
|
|
991
|
+
.katucharts-dt-search { position: relative; display: flex; align-items: center; }
|
|
992
|
+
.katucharts-dt-search-icon {
|
|
993
|
+
position: absolute; left: 10px; display: flex; pointer-events: none; color: var(--kdt-muted-fg);
|
|
994
|
+
}
|
|
995
|
+
.katucharts-dt-search-icon svg { width: 15px; height: 15px; }
|
|
996
|
+
.katucharts-dt-search .katucharts-dt-input { padding-left: 32px; min-width: 220px; }
|
|
997
|
+
|
|
998
|
+
/* ── inputs / selects ──────────────────────────────────────── */
|
|
999
|
+
.katucharts-dt-input,
|
|
1000
|
+
.katucharts-dt-select {
|
|
1001
|
+
height: 36px;
|
|
1002
|
+
padding: 0 10px;
|
|
1003
|
+
font-family: inherit;
|
|
1004
|
+
font-size: 13px;
|
|
1005
|
+
color: var(--kdt-fg);
|
|
1006
|
+
background: var(--kdt-bg);
|
|
1007
|
+
border: 1px solid var(--kdt-input);
|
|
1008
|
+
border-radius: calc(var(--kdt-radius) - 2px);
|
|
1009
|
+
outline: none;
|
|
1010
|
+
transition: border-color .15s ease, box-shadow .15s ease;
|
|
1011
|
+
}
|
|
1012
|
+
.katucharts-dt-input::placeholder { color: var(--kdt-muted-fg); }
|
|
1013
|
+
.katucharts-dt-input:focus,
|
|
1014
|
+
.katucharts-dt-select:focus { border-color: var(--kdt-ring); box-shadow: 0 0 0 2px color-mix(in srgb, var(--kdt-ring) 35%, transparent); }
|
|
1015
|
+
.katucharts-dt-select { cursor: pointer; padding-right: 24px; }
|
|
1016
|
+
|
|
1017
|
+
/* ── buttons ───────────────────────────────────────────────── */
|
|
1018
|
+
.katucharts-dt-btn {
|
|
1019
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
|
|
1020
|
+
height: 36px; min-width: 36px; padding: 0 12px;
|
|
1021
|
+
font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1;
|
|
1022
|
+
color: var(--kdt-fg); background: var(--kdt-bg);
|
|
1023
|
+
border: 1px solid var(--kdt-border); border-radius: calc(var(--kdt-radius) - 2px);
|
|
1024
|
+
cursor: pointer; user-select: none; white-space: nowrap;
|
|
1025
|
+
transition: background-color .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease;
|
|
1026
|
+
}
|
|
1027
|
+
.katucharts-dt-btn:hover:not(:disabled) { background: var(--kdt-accent); color: var(--kdt-accent-fg); }
|
|
1028
|
+
.katucharts-dt-btn:disabled { opacity: .45; cursor: default; }
|
|
1029
|
+
.katucharts-dt-btn.is-active { background: var(--kdt-primary); color: var(--kdt-primary-fg); border-color: var(--kdt-primary); }
|
|
1030
|
+
.katucharts-dt-btn svg { width: 15px; height: 15px; }
|
|
1031
|
+
|
|
1032
|
+
/* ── dropdown menus ────────────────────────────────────────── */
|
|
1033
|
+
.katucharts-dt-menu {
|
|
1034
|
+
position: absolute; top: calc(100% + 4px); right: 0; z-index: 100;
|
|
1035
|
+
min-width: 180px; max-height: 320px; overflow: auto; padding: 4px;
|
|
1036
|
+
background: var(--kdt-popover-bg, #fff); color: var(--kdt-fg);
|
|
1037
|
+
border: 1px solid var(--kdt-border); border-radius: var(--kdt-radius);
|
|
1038
|
+
box-shadow: 0 10px 24px -8px rgba(0,0,0,.25), 0 2px 6px -2px rgba(0,0,0,.12);
|
|
1039
|
+
}
|
|
1040
|
+
.katucharts-dt-menu-label { padding: 6px 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--kdt-muted-fg); }
|
|
1041
|
+
.katucharts-dt-menu-sep { height: 1px; margin: 4px 0; background: var(--kdt-border); border: 0; }
|
|
1042
|
+
.katucharts-dt-menu-item {
|
|
1043
|
+
display: flex; align-items: center; gap: 8px;
|
|
1044
|
+
padding: 7px 8px; font-size: 13px; border-radius: calc(var(--kdt-radius) - 4px);
|
|
1045
|
+
cursor: pointer; white-space: nowrap; color: var(--kdt-fg);
|
|
1046
|
+
}
|
|
1047
|
+
.katucharts-dt-menu-item:hover,
|
|
1048
|
+
.katucharts-dt-menu-item.is-active { background: var(--kdt-accent); color: var(--kdt-accent-fg); }
|
|
1049
|
+
.katucharts-dt-menu-item input { cursor: pointer; }
|
|
1050
|
+
|
|
1051
|
+
/* ── table scaffold ────────────────────────────────────────── */
|
|
1052
|
+
.katucharts-dt-table-area { position: relative; }
|
|
1053
|
+
.katucharts-dt-table-container { position: relative; }
|
|
1054
|
+
.katucharts-dt-header-scroll { overflow: hidden; }
|
|
1055
|
+
.katucharts-dt-body-scroll { overflow: auto; position: relative; }
|
|
1056
|
+
.katucharts-datatable table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
|
|
1057
|
+
|
|
1058
|
+
/* ── header ────────────────────────────────────────────────── */
|
|
1059
|
+
.katucharts-dt-header-row { background: var(--kdt-header-bg); }
|
|
1060
|
+
.katucharts-dt-th {
|
|
1061
|
+
position: relative;
|
|
1062
|
+
height: var(--kdt-header-height);
|
|
1063
|
+
padding: 0 var(--kdt-cell-px);
|
|
1064
|
+
font-size: var(--kdt-header-font-size);
|
|
1065
|
+
font-weight: var(--kdt-header-font-weight);
|
|
1066
|
+
color: var(--kdt-header-fg);
|
|
1067
|
+
text-align: left; vertical-align: middle;
|
|
1068
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
1069
|
+
user-select: none;
|
|
1070
|
+
border-bottom: 1px solid var(--kdt-border);
|
|
1071
|
+
}
|
|
1072
|
+
.katucharts-dt-th.is-sortable { cursor: pointer; }
|
|
1073
|
+
.katucharts-dt-th.is-sortable:hover { color: var(--kdt-fg); }
|
|
1074
|
+
.katucharts-dt-th-inner { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
|
|
1075
|
+
.katucharts-dt-th-custom { display: block; width: 100%; }
|
|
1076
|
+
.katucharts-dt-th[data-align="right"] { text-align: right; }
|
|
1077
|
+
.katucharts-dt-th[data-align="right"] .katucharts-dt-th-inner { flex-direction: row-reverse; }
|
|
1078
|
+
.katucharts-dt-th[data-align="center"] { text-align: center; }
|
|
1079
|
+
.katucharts-dt-th[data-align="center"] .katucharts-dt-th-inner { justify-content: center; }
|
|
1080
|
+
|
|
1081
|
+
.katucharts-dt-sort-icon { display: inline-flex; flex: none; color: var(--kdt-muted-fg); opacity: .55; transition: opacity .15s ease, color .15s ease; }
|
|
1082
|
+
.katucharts-dt-sort-icon svg { width: 14px; height: 14px; }
|
|
1083
|
+
.katucharts-dt-th.is-sorted .katucharts-dt-sort-icon { opacity: 1; color: var(--kdt-fg); }
|
|
1084
|
+
.katucharts-dt-sort-badge { font-size: 9px; line-height: 1; padding: 1px 3px; border-radius: 6px; background: var(--kdt-muted); color: var(--kdt-muted-fg); }
|
|
1085
|
+
|
|
1086
|
+
/* ── filter row ────────────────────────────────────────────── */
|
|
1087
|
+
.katucharts-dt-filter-row > td { padding: 6px var(--kdt-cell-px) 10px; border-bottom: 1px solid var(--kdt-border); }
|
|
1088
|
+
.katucharts-dt-filter-input { height: 32px; width: 100%; font-size: 12px; }
|
|
1089
|
+
.katucharts-dt-filter-range { display: flex; gap: 6px; }
|
|
1090
|
+
.katucharts-dt-filter-range .katucharts-dt-input { width: 50%; }
|
|
1091
|
+
|
|
1092
|
+
/* ── body rows / cells ─────────────────────────────────────── */
|
|
1093
|
+
.katucharts-dt-row { height: var(--kdt-row-height); transition: background-color .12s ease; }
|
|
1094
|
+
.katucharts-dt-row > td { border-bottom: 1px solid var(--kdt-border); }
|
|
1095
|
+
.katucharts-datatable[data-borders="none"] .katucharts-dt-row > td,
|
|
1096
|
+
.katucharts-datatable[data-borders="none"] .katucharts-dt-th { border-bottom-color: transparent; }
|
|
1097
|
+
.katucharts-datatable[data-borders="vertical"] .katucharts-dt-td:not(:last-child),
|
|
1098
|
+
.katucharts-datatable[data-borders="vertical"] .katucharts-dt-th:not(:last-child),
|
|
1099
|
+
.katucharts-datatable[data-borders="both"] .katucharts-dt-td:not(:last-child),
|
|
1100
|
+
.katucharts-datatable[data-borders="both"] .katucharts-dt-th:not(:last-child) { border-right: 1px solid var(--kdt-border); }
|
|
1101
|
+
.katucharts-datatable[data-striped="true"] .katucharts-dt-row:nth-child(even) { background: var(--kdt-stripe-bg); }
|
|
1102
|
+
.katucharts-dt-row:hover { background: var(--kdt-hover-bg); }
|
|
1103
|
+
.katucharts-dt-row.is-selected,
|
|
1104
|
+
.katucharts-dt-row.is-selected:hover { background: var(--kdt-selected-bg); }
|
|
1105
|
+
.katucharts-dt-td {
|
|
1106
|
+
padding: var(--kdt-cell-py) var(--kdt-cell-px);
|
|
1107
|
+
vertical-align: middle;
|
|
1108
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
1109
|
+
}
|
|
1110
|
+
.katucharts-dt-td[data-align="right"] { text-align: right; }
|
|
1111
|
+
.katucharts-dt-td[data-align="center"] { text-align: center; }
|
|
1112
|
+
|
|
1113
|
+
/* ── selection checkbox cells ──────────────────────────────── */
|
|
1114
|
+
.katucharts-dt-checkbox-cell { width: 44px; padding: 0; text-align: center; }
|
|
1115
|
+
.katucharts-dt-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--kdt-primary); }
|
|
1116
|
+
|
|
1117
|
+
/* ── group header rows ─────────────────────────────────────── */
|
|
1118
|
+
.katucharts-dt-group-header > td {
|
|
1119
|
+
padding: var(--kdt-cell-py) var(--kdt-cell-px);
|
|
1120
|
+
font-weight: 600; cursor: pointer; user-select: none;
|
|
1121
|
+
background: var(--kdt-muted); border-bottom: 1px solid var(--kdt-border);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/* ── detail rows ───────────────────────────────────────────── */
|
|
1125
|
+
.katucharts-dt-detail > td { padding: 12px var(--kdt-cell-px); background: var(--kdt-muted); }
|
|
1126
|
+
|
|
1127
|
+
/* ── empty / loading ───────────────────────────────────────── */
|
|
1128
|
+
.katucharts-dt-nodata { padding: 48px 20px; text-align: center; color: var(--kdt-muted-fg); font-size: 14px; }
|
|
1129
|
+
.katucharts-dt-loading {
|
|
1130
|
+
position: absolute; inset: 0; z-index: 10;
|
|
1131
|
+
display: flex; align-items: center; justify-content: center; gap: 8px;
|
|
1132
|
+
background: color-mix(in srgb, var(--kdt-bg) 75%, transparent);
|
|
1133
|
+
color: var(--kdt-muted-fg); font-size: 14px;
|
|
1134
|
+
}
|
|
1135
|
+
.katucharts-dt-spinner {
|
|
1136
|
+
width: 16px; height: 16px; border-radius: 50%;
|
|
1137
|
+
border: 2px solid var(--kdt-border); border-top-color: var(--kdt-fg);
|
|
1138
|
+
animation: katucharts-dt-spin .7s linear infinite;
|
|
1139
|
+
}
|
|
1140
|
+
@keyframes katucharts-dt-spin { to { transform: rotate(360deg); } }
|
|
1141
|
+
|
|
1142
|
+
/* ── resize handle ─────────────────────────────────────────── */
|
|
1143
|
+
.katucharts-dt-resize-handle {
|
|
1144
|
+
position: absolute; top: 0; right: 0; bottom: 0; width: 6px;
|
|
1145
|
+
cursor: col-resize; user-select: none; touch-action: none; z-index: 1;
|
|
1146
|
+
}
|
|
1147
|
+
.katucharts-dt-resize-handle::after {
|
|
1148
|
+
content: ""; position: absolute; top: 25%; bottom: 25%; right: 2px; width: 2px;
|
|
1149
|
+
background: var(--kdt-border); border-radius: 2px; opacity: 0; transition: opacity .15s ease;
|
|
1150
|
+
}
|
|
1151
|
+
.katucharts-dt-resize-handle:hover::after { opacity: 1; background: var(--kdt-ring); }
|
|
1152
|
+
|
|
1153
|
+
/* ── pinned columns ────────────────────────────────────────── */
|
|
1154
|
+
.katucharts-dt-th.is-pinned,
|
|
1155
|
+
.katucharts-dt-td.is-pinned { position: sticky; z-index: 2; background: var(--kdt-bg); }
|
|
1156
|
+
.katucharts-dt-th.is-pinned { z-index: 3; }
|
|
1157
|
+
|
|
1158
|
+
/* ── pagination / footer ───────────────────────────────────── */
|
|
1159
|
+
.katucharts-dt-footer {
|
|
1160
|
+
display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
|
|
1161
|
+
padding: 12px; border-top: 1px solid var(--kdt-border);
|
|
1162
|
+
font-size: 13px; color: var(--kdt-muted-fg); background: var(--kdt-bg);
|
|
1163
|
+
}
|
|
1164
|
+
.katucharts-dt-footer-section { display: flex; align-items: center; gap: 8px; }
|
|
1165
|
+
.katucharts-dt-page-size { display: flex; align-items: center; gap: 8px; }
|
|
1166
|
+
.katucharts-dt-page-size-btn { height: 32px; padding: 0 8px; gap: 4px; font-weight: 500; }
|
|
1167
|
+
.katucharts-dt-page-size-btn svg { width: 14px; height: 14px; color: var(--kdt-muted-fg); }
|
|
1168
|
+
.katucharts-dt-pagination { display: flex; align-items: center; gap: 4px; }
|
|
1169
|
+
.katucharts-dt-ellipsis { padding: 0 4px; color: var(--kdt-muted-fg); }
|
|
1170
|
+
.katucharts-dt-pagination .katucharts-dt-btn { height: 32px; min-width: 32px; padding: 0 8px; }
|
|
1171
|
+
|
|
1172
|
+
/* ── faceted filter badges ─────────────────────────────────── */
|
|
1173
|
+
.katucharts-dt-facet-count {
|
|
1174
|
+
display: inline-flex; align-items: center; height: 18px; padding: 0 6px; margin-left: 2px;
|
|
1175
|
+
font-size: 11px; font-weight: 600; border-radius: 6px;
|
|
1176
|
+
background: var(--kdt-muted); color: var(--kdt-accent-fg);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
/* ── floating layers (rendered at <body>, so unscoped) ─────── */
|
|
1180
|
+
.katucharts-dt-context-menu {
|
|
1181
|
+
position: fixed; z-index: 1000; min-width: 180px; padding: 4px;
|
|
1182
|
+
font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px;
|
|
1183
|
+
background: #fff; color: #18181b;
|
|
1184
|
+
border: 1px solid #e4e4e7; border-radius: 8px;
|
|
1185
|
+
box-shadow: 0 10px 24px -8px rgba(0,0,0,.25), 0 2px 6px -2px rgba(0,0,0,.12);
|
|
1186
|
+
}
|
|
1187
|
+
.katucharts-dt-context-menu-item {
|
|
1188
|
+
display: flex; align-items: center; gap: 8px;
|
|
1189
|
+
padding: 7px 8px; border-radius: 4px; cursor: pointer;
|
|
1190
|
+
}
|
|
1191
|
+
.katucharts-dt-context-menu-item:hover { background: #f4f4f5; }
|
|
1192
|
+
.katucharts-dt-context-menu-item.is-disabled { color: #a1a1aa; opacity: .6; cursor: default; }
|
|
1193
|
+
.katucharts-dt-context-menu-item.is-disabled:hover { background: transparent; }
|
|
1194
|
+
.katucharts-dt-context-menu-sep { height: 1px; margin: 4px 0; background: #e4e4e7; border: 0; }
|
|
1195
|
+
`;
|
|
1196
|
+
function ue(c = document) {
|
|
1197
|
+
if (c.getElementById(N)) return;
|
|
1198
|
+
const e = c.createElement("style");
|
|
1199
|
+
e.id = N, e.textContent = he, c.head.appendChild(e);
|
|
1200
|
+
}
|
|
1201
|
+
function P(c, e) {
|
|
1202
|
+
const t = e.field;
|
|
1203
|
+
return {
|
|
1204
|
+
id: e.id ?? t,
|
|
1205
|
+
columnDef: e,
|
|
1206
|
+
getCanSort: () => e.sortable !== !1,
|
|
1207
|
+
getCanHide: () => e.enableHiding !== !1,
|
|
1208
|
+
getIsSorted: () => c.getSortDirection(t) ?? !1,
|
|
1209
|
+
toggleSorting: (i) => c.toggleSort(t, i),
|
|
1210
|
+
clearSorting: () => c.clearColumnSort(t),
|
|
1211
|
+
getIsVisible: () => c.isColumnVisible(t),
|
|
1212
|
+
toggleVisibility: (i) => c.setColumnVisible(t, i ?? !c.isColumnVisible(t)),
|
|
1213
|
+
getFilterValue: () => c.getFilterValue(t),
|
|
1214
|
+
setFilterValue: (i) => c.setColumnFilter(t, i)
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
function pe(c, e) {
|
|
1218
|
+
return {
|
|
1219
|
+
id: String(e._originalIndex),
|
|
1220
|
+
index: e._originalIndex,
|
|
1221
|
+
original: e._data,
|
|
1222
|
+
getValue: (t) => e._data[t],
|
|
1223
|
+
renderValue: (t) => e._data[t],
|
|
1224
|
+
getIsSelected: () => c.isRowSelected(e._originalIndex),
|
|
1225
|
+
toggleSelected: (t) => c.setRowSelected(e._originalIndex, t ?? !c.isRowSelected(e._originalIndex))
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
function ge(c) {
|
|
1229
|
+
const e = () => c.getInternalColumns().map((t) => P(c, t));
|
|
1230
|
+
return {
|
|
1231
|
+
getColumn: (t) => {
|
|
1232
|
+
const i = c.getInternalColumns().find((s) => (s.id ?? s.field) === t || s.field === t);
|
|
1233
|
+
return i ? P(c, i) : void 0;
|
|
1234
|
+
},
|
|
1235
|
+
getAllColumns: e,
|
|
1236
|
+
getAllLeafColumns: e,
|
|
1237
|
+
getIsAllPageRowsSelected: () => c.isAllPageSelected(),
|
|
1238
|
+
getIsSomePageRowsSelected: () => c.isSomePageSelected(),
|
|
1239
|
+
toggleAllPageRowsSelected: (t) => c.toggleAllPageSelected(t ?? !c.isAllPageSelected()),
|
|
1240
|
+
getState: () => {
|
|
1241
|
+
const t = c.getPageInfo();
|
|
1242
|
+
return { pagination: { pageIndex: t.page - 1, pageSize: t.pageSize } };
|
|
1243
|
+
},
|
|
1244
|
+
nextPage: () => c.goToPage(c.getPageInfo().page + 1),
|
|
1245
|
+
previousPage: () => c.goToPage(c.getPageInfo().page - 1),
|
|
1246
|
+
setPageIndex: (t) => c.goToPage(t + 1),
|
|
1247
|
+
setPageSize: (t) => c.setPageSizeValue(t),
|
|
1248
|
+
getCanNextPage: () => c.getPageInfo().page < c.getPageInfo().totalPages,
|
|
1249
|
+
getCanPreviousPage: () => c.getPageInfo().page > 1,
|
|
1250
|
+
getPageCount: () => c.getPageInfo().totalPages
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
class fe {
|
|
1254
|
+
constructor(e, t) {
|
|
1255
|
+
this.api = null, this.host = null, this.theme = e, this.formatters = t ?? {};
|
|
1256
|
+
}
|
|
1257
|
+
setApi(e, t) {
|
|
1258
|
+
this.api = e, this.host = t;
|
|
1259
|
+
}
|
|
1260
|
+
createCell(e, t, i, s, r) {
|
|
1261
|
+
const n = document.createElement("td");
|
|
1262
|
+
n.className = "katucharts-dt-td", s.align && n.setAttribute("data-align", s.align), s._computedWidth && (n.style.width = `${s._computedWidth}px`), s.pinned && (n.classList.add("is-pinned"), s.pinned === "left" ? n.style.left = `${s._pinnedOffset}px` : n.style.right = `${s._pinnedOffset}px`);
|
|
1263
|
+
const a = this.theme.userCellStyle;
|
|
1264
|
+
if (a && Object.assign(n.style, a), s.cellStyle) {
|
|
1265
|
+
const h = typeof s.cellStyle == "function" ? s.cellStyle.call({ value: t, row: i._data, column: s, rowIndex: r }) : s.cellStyle;
|
|
1266
|
+
Object.assign(n.style, h);
|
|
1267
|
+
}
|
|
1268
|
+
const o = this.computeClass(t, i._data, s);
|
|
1269
|
+
o && (n.className += ` ${o}`);
|
|
1270
|
+
const l = this.computeTooltip(t, i._data, s);
|
|
1271
|
+
if (l && (n.title = l), s.cell && this.api) {
|
|
1272
|
+
const h = {
|
|
1273
|
+
row: pe(this.host, i),
|
|
1274
|
+
column: this.api.getColumn(s.id ?? s.field),
|
|
1275
|
+
table: this.api,
|
|
1276
|
+
getValue: () => t,
|
|
1277
|
+
renderValue: () => t
|
|
1278
|
+
}, u = s.cell(h);
|
|
1279
|
+
return u instanceof Node ? n.appendChild(u) : n.innerHTML = String(u ?? ""), e.appendChild(n), n;
|
|
1280
|
+
}
|
|
1281
|
+
const d = this.formatValue(t, i._data, s, r);
|
|
1282
|
+
return s.type === "html" ? n.innerHTML = d : n.textContent = d, e.appendChild(n), n;
|
|
1283
|
+
}
|
|
1284
|
+
formatValue(e, t, i, s) {
|
|
1285
|
+
if (e == null) return "";
|
|
1286
|
+
if (i.formatter) {
|
|
1287
|
+
const r = { value: e, row: t, column: i, rowIndex: s };
|
|
1288
|
+
return i.formatter.call(r);
|
|
1289
|
+
}
|
|
1290
|
+
if (i.type && this.formatters[i.type])
|
|
1291
|
+
return this.formatters[i.type](e);
|
|
1292
|
+
switch (i.type) {
|
|
1293
|
+
case "number":
|
|
1294
|
+
return this.defaultNumberFormat(e);
|
|
1295
|
+
case "date":
|
|
1296
|
+
return this.defaultDateFormat(e);
|
|
1297
|
+
case "boolean":
|
|
1298
|
+
return this.defaultBooleanFormat(e);
|
|
1299
|
+
default:
|
|
1300
|
+
return typeof e == "object" && e !== null ? Array.isArray(e) ? `[${e.length} items]` : JSON.stringify(e) : String(e);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
defaultNumberFormat(e) {
|
|
1304
|
+
const t = Number(e);
|
|
1305
|
+
return isNaN(t) ? String(e) : Number.isInteger(t) ? t.toLocaleString() : t.toLocaleString(void 0, { minimumFractionDigits: 0, maximumFractionDigits: 2 });
|
|
1306
|
+
}
|
|
1307
|
+
defaultDateFormat(e) {
|
|
1308
|
+
const t = e instanceof Date ? e : new Date(e);
|
|
1309
|
+
return isNaN(t.getTime()) ? String(e) : t.toLocaleDateString();
|
|
1310
|
+
}
|
|
1311
|
+
defaultBooleanFormat(e) {
|
|
1312
|
+
return this.formatters.boolean ? this.formatters.boolean(e) : e ? "✔" : "✘";
|
|
1313
|
+
}
|
|
1314
|
+
computeClass(e, t, i) {
|
|
1315
|
+
return i.cellClass ? typeof i.cellClass == "function" ? i.cellClass.call({ value: e, row: t }) : i.cellClass : "";
|
|
1316
|
+
}
|
|
1317
|
+
computeTooltip(e, t, i) {
|
|
1318
|
+
return i.cellTooltip ? i.cellTooltip === !0 ? e != null ? String(e) : "" : typeof i.cellTooltip == "function" ? i.cellTooltip.call({ value: e, row: t }) : "" : "";
|
|
1319
|
+
}
|
|
1320
|
+
updateFormatters(e) {
|
|
1321
|
+
this.formatters = e;
|
|
1322
|
+
}
|
|
1323
|
+
resolveValue(e, t) {
|
|
1324
|
+
return S(e, t);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
const b = (c) => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${c}</svg>`, v = {
|
|
1328
|
+
sortAsc: b('<path d="m18 15-6-6-6 6"/>'),
|
|
1329
|
+
sortDesc: b('<path d="m6 9 6 6 6-6"/>'),
|
|
1330
|
+
sortNone: b('<path d="m8 9 4-4 4 4"/><path d="m16 15-4 4-4-4"/>'),
|
|
1331
|
+
search: b('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>'),
|
|
1332
|
+
columns: b('<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/><path d="M15 3v18"/>'),
|
|
1333
|
+
download: b('<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>'),
|
|
1334
|
+
sliders: b('<line x1="4" x2="4" y1="21" y2="14"/><line x1="4" x2="4" y1="10" y2="3"/><line x1="12" x2="12" y1="21" y2="12"/><line x1="12" x2="12" y1="8" y2="3"/><line x1="20" x2="20" y1="21" y2="16"/><line x1="20" x2="20" y1="12" y2="3"/><line x1="2" x2="6" y1="14" y2="14"/><line x1="10" x2="14" y1="8" y2="8"/><line x1="18" x2="22" y1="16" y2="16"/>'),
|
|
1335
|
+
expand: b('<path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/>'),
|
|
1336
|
+
x: b('<path d="M18 6 6 18"/><path d="m6 6 12 12"/>'),
|
|
1337
|
+
chevronLeft: b('<path d="m15 18-6-6 6-6"/>'),
|
|
1338
|
+
chevronRight: b('<path d="m9 18 6-6-6-6"/>'),
|
|
1339
|
+
chevronDown: b('<path d="m6 9 6 6 6-6"/>'),
|
|
1340
|
+
chevronsUpDown: b('<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>'),
|
|
1341
|
+
chevronsLeft: b('<path d="m11 17-5-5 5-5"/><path d="m18 17-5-5 5-5"/>'),
|
|
1342
|
+
chevronsRight: b('<path d="m6 17 5-5-5-5"/><path d="m13 17 5-5-5-5"/>'),
|
|
1343
|
+
plusCircle: b('<circle cx="12" cy="12" r="10"/><path d="M8 12h8"/><path d="M12 8v8"/>')
|
|
1344
|
+
}, me = [
|
|
1345
|
+
"--kdt-font-family",
|
|
1346
|
+
"--kdt-font-size",
|
|
1347
|
+
"--kdt-radius",
|
|
1348
|
+
"--kdt-bg",
|
|
1349
|
+
"--kdt-popover-bg",
|
|
1350
|
+
"--kdt-fg",
|
|
1351
|
+
"--kdt-muted",
|
|
1352
|
+
"--kdt-muted-fg",
|
|
1353
|
+
"--kdt-border",
|
|
1354
|
+
"--kdt-accent",
|
|
1355
|
+
"--kdt-accent-fg",
|
|
1356
|
+
"--kdt-primary"
|
|
1357
|
+
];
|
|
1358
|
+
function C(c, e, t = {}) {
|
|
1359
|
+
const i = c.closest(".katucharts-datatable");
|
|
1360
|
+
if (i) {
|
|
1361
|
+
const a = getComputedStyle(i);
|
|
1362
|
+
for (const o of me) {
|
|
1363
|
+
const l = a.getPropertyValue(o);
|
|
1364
|
+
l && e.style.setProperty(o, l);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
e.style.position = "fixed", e.style.zIndex = "1000", document.body.appendChild(e);
|
|
1368
|
+
const s = () => {
|
|
1369
|
+
const a = c.getBoundingClientRect();
|
|
1370
|
+
e.style.top = `${a.bottom + 4}px`, (t.align ?? "left") === "right" ? (e.style.left = "auto", e.style.right = `${window.innerWidth - a.right}px`) : (e.style.right = "auto", e.style.left = `${a.left}px`);
|
|
1371
|
+
};
|
|
1372
|
+
s();
|
|
1373
|
+
const r = (a) => {
|
|
1374
|
+
!e.contains(a.target) && !c.contains(a.target) && n.close();
|
|
1375
|
+
}, n = {
|
|
1376
|
+
element: e,
|
|
1377
|
+
close() {
|
|
1378
|
+
e.remove(), window.removeEventListener("scroll", s, !0), window.removeEventListener("resize", s), document.removeEventListener("mousedown", r);
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
return setTimeout(() => {
|
|
1382
|
+
window.addEventListener("scroll", s, !0), window.addEventListener("resize", s), document.addEventListener("mousedown", r);
|
|
1383
|
+
}, 0), n;
|
|
1384
|
+
}
|
|
1385
|
+
class be {
|
|
1386
|
+
constructor(e, t, i = {}) {
|
|
1387
|
+
this.thead = null, this.filterRow = null, this.resizing = !1, this.api = null, this.host = null, this.theme = e, this.events = t, this.lang = i;
|
|
1388
|
+
}
|
|
1389
|
+
/** Swap the active locale strings; takes effect on the next render. */
|
|
1390
|
+
setLang(e) {
|
|
1391
|
+
this.lang = e;
|
|
1392
|
+
}
|
|
1393
|
+
render(e, t, i) {
|
|
1394
|
+
var n;
|
|
1395
|
+
this.thead && this.thead.remove(), this.thead = document.createElement("thead"), this.thead.className = "katucharts-dt-header", this.api = i.api ?? null, this.host = i.host ?? null, (n = i.headerGroups) != null && n.length && this.renderHeaderGroups(i.headerGroups, t);
|
|
1396
|
+
const s = document.createElement("tr");
|
|
1397
|
+
s.className = "katucharts-dt-header-row", this.theme.userHeaderRowStyle && Object.assign(s.style, this.theme.userHeaderRowStyle);
|
|
1398
|
+
const r = t.filter((a) => a._visible);
|
|
1399
|
+
i.selectionCheckbox && s.appendChild(this.createCheckboxHeader());
|
|
1400
|
+
for (const a of r)
|
|
1401
|
+
s.appendChild(this.createHeaderCell(a, i));
|
|
1402
|
+
return this.thead.appendChild(s), i.filteringEnabled && i.filterPosition === "header" && (this.filterRow = this.createFilterRow(r, i.selectionCheckbox), this.thead.appendChild(this.filterRow)), e.appendChild(this.thead), this.thead;
|
|
1403
|
+
}
|
|
1404
|
+
createHeaderCell(e, t) {
|
|
1405
|
+
const i = document.createElement("th");
|
|
1406
|
+
i.className = "katucharts-dt-th", i.setAttribute("data-field", e.field), e.align && i.setAttribute("data-align", e.headerAlign ?? e.align), e._computedWidth && (i.style.width = `${e._computedWidth}px`), this.theme.userHeaderCellStyle && Object.assign(i.style, this.theme.userHeaderCellStyle), e.headerStyle && Object.assign(i.style, e.headerStyle), e.pinned && (i.classList.add("is-pinned"), e.pinned === "left" ? i.style.left = `${e._pinnedOffset}px` : i.style.right = `${e._pinnedOffset}px`);
|
|
1407
|
+
const s = t.sortingEnabled && e.sortable;
|
|
1408
|
+
if (e._sortDirection && i.classList.add("is-sorted"), typeof e.header == "function" && this.api && this.host) {
|
|
1409
|
+
const r = { column: this.api.getColumn(e.id ?? e.field), table: this.api }, n = e.header(r), a = document.createElement("div");
|
|
1410
|
+
a.className = "katucharts-dt-th-custom", n instanceof Node ? a.appendChild(n) : a.innerHTML = String(n ?? ""), i.appendChild(a);
|
|
1411
|
+
} else {
|
|
1412
|
+
const r = document.createElement("span");
|
|
1413
|
+
r.className = "katucharts-dt-th-inner";
|
|
1414
|
+
const n = document.createElement("span");
|
|
1415
|
+
e.headerFormatter ? n.innerHTML = e.headerFormatter.call({ column: e }) : n.textContent = e.title ?? e.field, r.appendChild(n), s && r.appendChild(this.createSortIcon(e)), i.appendChild(r), s && (i.classList.add("is-sortable"), i.addEventListener("click", (a) => {
|
|
1416
|
+
if (this.resizing) return;
|
|
1417
|
+
const o = a.target;
|
|
1418
|
+
o.tagName === "INPUT" || o.tagName === "SELECT" || this.events.emit("header:sort", { field: e.field, shiftKey: a.shiftKey });
|
|
1419
|
+
}));
|
|
1420
|
+
}
|
|
1421
|
+
return e.headerTooltip && (i.title = e.headerTooltip), t.resizingEnabled && e.resizable && i.appendChild(this.createResizeHandle(e, i)), i;
|
|
1422
|
+
}
|
|
1423
|
+
createSortIcon(e) {
|
|
1424
|
+
const t = document.createElement("span");
|
|
1425
|
+
if (t.className = "katucharts-dt-sort-icon", e._sortDirection === "asc" ? t.innerHTML = v.sortAsc : e._sortDirection === "desc" ? t.innerHTML = v.sortDesc : t.innerHTML = v.sortNone, e._sortPriority >= 0 && e._sortDirection) {
|
|
1426
|
+
const i = document.createElement("span");
|
|
1427
|
+
i.className = "katucharts-dt-sort-badge", i.textContent = String(e._sortPriority + 1), t.appendChild(i);
|
|
1428
|
+
}
|
|
1429
|
+
return t;
|
|
1430
|
+
}
|
|
1431
|
+
createResizeHandle(e, t) {
|
|
1432
|
+
const i = document.createElement("div");
|
|
1433
|
+
return i.className = "katucharts-dt-resize-handle", i.addEventListener("mousedown", (s) => {
|
|
1434
|
+
s.preventDefault(), s.stopPropagation(), this.resizing = !0;
|
|
1435
|
+
const r = s.clientX, n = e._computedWidth, a = (l) => {
|
|
1436
|
+
const d = l.clientX - r, h = Math.max(e.minWidth ?? 40, Math.min(e.maxWidth ?? 2e3, n + d));
|
|
1437
|
+
e._computedWidth = h, t.style.width = `${h}px`, this.events.emit("column:resizing", { field: e.field, width: h });
|
|
1438
|
+
}, o = () => {
|
|
1439
|
+
document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", o), setTimeout(() => {
|
|
1440
|
+
this.resizing = !1;
|
|
1441
|
+
}, 50), this.events.emit("column:resize", { field: e.field, width: e._computedWidth });
|
|
1442
|
+
};
|
|
1443
|
+
document.addEventListener("mousemove", a), document.addEventListener("mouseup", o);
|
|
1444
|
+
}), i;
|
|
1445
|
+
}
|
|
1446
|
+
createCheckboxHeader() {
|
|
1447
|
+
const e = document.createElement("th");
|
|
1448
|
+
e.className = "katucharts-dt-th katucharts-dt-checkbox-cell";
|
|
1449
|
+
const t = document.createElement("input");
|
|
1450
|
+
return t.type = "checkbox", t.className = "katucharts-dt-checkbox", t.setAttribute("aria-label", this.lang.selectAllRows ?? "Select all rows"), t.addEventListener("change", () => {
|
|
1451
|
+
this.events.emit("selection:toggleAll", { checked: t.checked });
|
|
1452
|
+
}), e.appendChild(t), e;
|
|
1453
|
+
}
|
|
1454
|
+
createFilterRow(e, t) {
|
|
1455
|
+
const i = document.createElement("tr");
|
|
1456
|
+
if (i.className = "katucharts-dt-filter-row", t) {
|
|
1457
|
+
const s = document.createElement("td");
|
|
1458
|
+
s.className = "katucharts-dt-checkbox-cell", i.appendChild(s);
|
|
1459
|
+
}
|
|
1460
|
+
for (const s of e) {
|
|
1461
|
+
const r = document.createElement("td");
|
|
1462
|
+
s.filterable && r.appendChild(this.createFilterInput(s)), i.appendChild(r);
|
|
1463
|
+
}
|
|
1464
|
+
return i;
|
|
1465
|
+
}
|
|
1466
|
+
createFilterInput(e) {
|
|
1467
|
+
switch (e.filterType ?? this.inferFilterType(e)) {
|
|
1468
|
+
case "select":
|
|
1469
|
+
return this.createSelectFilter(e);
|
|
1470
|
+
case "multiselect":
|
|
1471
|
+
case "faceted":
|
|
1472
|
+
return this.createFacetedFilter(e);
|
|
1473
|
+
case "boolean":
|
|
1474
|
+
return this.createBooleanFilter(e);
|
|
1475
|
+
case "number":
|
|
1476
|
+
case "numberrange":
|
|
1477
|
+
return this.createNumberFilter(e);
|
|
1478
|
+
case "date":
|
|
1479
|
+
case "daterange":
|
|
1480
|
+
return this.createDateFilter(e);
|
|
1481
|
+
default:
|
|
1482
|
+
return this.createTextFilter(e);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
createTextFilter(e) {
|
|
1486
|
+
const t = document.createElement("input");
|
|
1487
|
+
return t.type = "text", t.className = "katucharts-dt-input katucharts-dt-filter-input", t.placeholder = this.lang.filterPlaceholder ?? "Filter…", e._filterValue && (t.value = e._filterValue), t.addEventListener("input", () => {
|
|
1488
|
+
this.events.emit("filter:input", { field: e.field, value: t.value || null });
|
|
1489
|
+
}), t;
|
|
1490
|
+
}
|
|
1491
|
+
createNumberFilter(e) {
|
|
1492
|
+
const t = document.createElement("div");
|
|
1493
|
+
t.className = "katucharts-dt-filter-range";
|
|
1494
|
+
const i = document.createElement("input");
|
|
1495
|
+
i.type = "number", i.placeholder = this.lang.rangeMin ?? "Min", i.className = "katucharts-dt-input katucharts-dt-filter-input";
|
|
1496
|
+
const s = document.createElement("input");
|
|
1497
|
+
s.type = "number", s.placeholder = this.lang.rangeMax ?? "Max", s.className = "katucharts-dt-input katucharts-dt-filter-input", e._filterValue && typeof e._filterValue == "object" && (e._filterValue.min != null && (i.value = String(e._filterValue.min)), e._filterValue.max != null && (s.value = String(e._filterValue.max)));
|
|
1498
|
+
const r = () => {
|
|
1499
|
+
const n = i.value || s.value ? { min: i.value ? Number(i.value) : null, max: s.value ? Number(s.value) : null } : null;
|
|
1500
|
+
this.events.emit("filter:input", { field: e.field, value: n });
|
|
1501
|
+
};
|
|
1502
|
+
return i.addEventListener("input", r), s.addEventListener("input", r), t.appendChild(i), t.appendChild(s), t;
|
|
1503
|
+
}
|
|
1504
|
+
createDateFilter(e) {
|
|
1505
|
+
const t = document.createElement("input");
|
|
1506
|
+
return t.type = "date", t.className = "katucharts-dt-input katucharts-dt-filter-input", e._filterValue && (t.value = e._filterValue), t.addEventListener("change", () => {
|
|
1507
|
+
this.events.emit("filter:input", { field: e.field, value: t.value || null });
|
|
1508
|
+
}), t;
|
|
1509
|
+
}
|
|
1510
|
+
createSelectFilter(e) {
|
|
1511
|
+
const t = [{ label: this.lang.filterAll ?? "All", value: null }];
|
|
1512
|
+
for (const i of e.filterOptions ?? []) t.push({ label: String(i), value: i });
|
|
1513
|
+
return this.createSingleSelectFilter(e, t);
|
|
1514
|
+
}
|
|
1515
|
+
createBooleanFilter(e) {
|
|
1516
|
+
return this.createSingleSelectFilter(e, [
|
|
1517
|
+
{ label: this.lang.filterAll ?? "All", value: null },
|
|
1518
|
+
{ label: this.lang.filterTrue ?? "True", value: !0 },
|
|
1519
|
+
{ label: this.lang.filterFalse ?? "False", value: !1 }
|
|
1520
|
+
]);
|
|
1521
|
+
}
|
|
1522
|
+
/** A single-select column filter rendered as a themed dropdown (not a native <select>). */
|
|
1523
|
+
createSingleSelectFilter(e, t) {
|
|
1524
|
+
const i = document.createElement("div");
|
|
1525
|
+
i.style.position = "relative";
|
|
1526
|
+
const s = document.createElement("button");
|
|
1527
|
+
s.type = "button", s.className = "katucharts-dt-btn katucharts-dt-filter-input", s.style.width = "100%", s.style.justifyContent = "space-between";
|
|
1528
|
+
const r = () => t.find((l) => l.value === e._filterValue || String(l.value) === String(e._filterValue)) ?? t[0], n = () => {
|
|
1529
|
+
s.innerHTML = `<span>${r().label}</span>${v.chevronDown}`;
|
|
1530
|
+
};
|
|
1531
|
+
n();
|
|
1532
|
+
let a = null;
|
|
1533
|
+
const o = () => {
|
|
1534
|
+
a == null || a.close(), a = null;
|
|
1535
|
+
};
|
|
1536
|
+
return s.addEventListener("click", (l) => {
|
|
1537
|
+
if (l.stopPropagation(), a) {
|
|
1538
|
+
o();
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
const d = document.createElement("div");
|
|
1542
|
+
d.className = "katucharts-dt-menu";
|
|
1543
|
+
for (const h of t) {
|
|
1544
|
+
const u = document.createElement("div");
|
|
1545
|
+
u.className = "katucharts-dt-menu-item", h === r() && u.classList.add("is-active"), u.textContent = h.label, u.addEventListener("click", () => {
|
|
1546
|
+
e._filterValue = h.value, n(), o(), this.events.emit("filter:input", { field: e.field, value: h.value });
|
|
1547
|
+
}), d.appendChild(u);
|
|
1548
|
+
}
|
|
1549
|
+
a = C(s, d, { align: "left" });
|
|
1550
|
+
}), i.appendChild(s), i;
|
|
1551
|
+
}
|
|
1552
|
+
/** A faceted multi-select filter: button + checkbox menu. */
|
|
1553
|
+
createFacetedFilter(e) {
|
|
1554
|
+
const t = document.createElement("div");
|
|
1555
|
+
t.style.position = "relative";
|
|
1556
|
+
const i = new Set(
|
|
1557
|
+
Array.isArray(e._filterValue) ? e._filterValue.map(String) : []
|
|
1558
|
+
), s = document.createElement("button");
|
|
1559
|
+
s.type = "button", s.className = "katucharts-dt-btn katucharts-dt-filter-input", s.style.width = "100%", s.style.justifyContent = "space-between";
|
|
1560
|
+
const r = () => {
|
|
1561
|
+
if (s.innerHTML = `<span style="display:inline-flex;align-items:center;gap:6px">${v.plusCircle}<span>${e.title ?? e.field}</span></span>`, i.size) {
|
|
1562
|
+
const o = document.createElement("span");
|
|
1563
|
+
o.className = "katucharts-dt-facet-count", o.textContent = String(i.size), s.appendChild(o);
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
r();
|
|
1567
|
+
let n = null;
|
|
1568
|
+
const a = () => {
|
|
1569
|
+
n == null || n.close(), n = null;
|
|
1570
|
+
};
|
|
1571
|
+
return s.addEventListener("click", (o) => {
|
|
1572
|
+
if (o.stopPropagation(), n) {
|
|
1573
|
+
a();
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
const l = document.createElement("div");
|
|
1577
|
+
l.className = "katucharts-dt-menu";
|
|
1578
|
+
for (const d of e.filterOptions ?? []) {
|
|
1579
|
+
const h = String(d), u = document.createElement("label");
|
|
1580
|
+
u.className = "katucharts-dt-menu-item", i.has(h) && u.classList.add("is-active");
|
|
1581
|
+
const g = document.createElement("input");
|
|
1582
|
+
g.type = "checkbox", g.checked = i.has(h), g.addEventListener("change", () => {
|
|
1583
|
+
g.checked ? (i.add(h), u.classList.add("is-active")) : (i.delete(h), u.classList.remove("is-active")), r(), this.events.emit("filter:input", {
|
|
1584
|
+
field: e.field,
|
|
1585
|
+
value: i.size ? [...i] : null
|
|
1586
|
+
});
|
|
1587
|
+
});
|
|
1588
|
+
const p = document.createElement("span");
|
|
1589
|
+
p.textContent = h, u.appendChild(g), u.appendChild(p), l.appendChild(u);
|
|
1590
|
+
}
|
|
1591
|
+
n = C(s, l, { align: "left" });
|
|
1592
|
+
}), t.appendChild(s), t;
|
|
1593
|
+
}
|
|
1594
|
+
renderHeaderGroups(e, t) {
|
|
1595
|
+
if (!this.thead) return;
|
|
1596
|
+
const i = document.createElement("tr");
|
|
1597
|
+
i.className = "katucharts-dt-header-row";
|
|
1598
|
+
const s = t.filter((n) => n._visible), r = /* @__PURE__ */ new Set();
|
|
1599
|
+
for (const n of e) {
|
|
1600
|
+
const a = n.columns.filter((l) => s.some((d) => d.field === l)).length;
|
|
1601
|
+
if (a === 0) continue;
|
|
1602
|
+
const o = document.createElement("th");
|
|
1603
|
+
o.className = "katucharts-dt-th", o.colSpan = a, o.style.textAlign = "center", o.textContent = n.title, n.style && Object.assign(o.style, n.style), i.appendChild(o), n.columns.forEach((l) => r.add(l));
|
|
1604
|
+
}
|
|
1605
|
+
for (const n of s)
|
|
1606
|
+
if (!r.has(n.field)) {
|
|
1607
|
+
const a = document.createElement("th");
|
|
1608
|
+
a.className = "katucharts-dt-th", i.appendChild(a);
|
|
1609
|
+
}
|
|
1610
|
+
this.thead.appendChild(i);
|
|
1611
|
+
}
|
|
1612
|
+
inferFilterType(e) {
|
|
1613
|
+
switch (e.type) {
|
|
1614
|
+
case "number":
|
|
1615
|
+
return "number";
|
|
1616
|
+
case "date":
|
|
1617
|
+
return "date";
|
|
1618
|
+
case "boolean":
|
|
1619
|
+
return "boolean";
|
|
1620
|
+
default:
|
|
1621
|
+
return "text";
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
updateSelectAllCheckbox(e, t) {
|
|
1625
|
+
if (!this.thead) return;
|
|
1626
|
+
const i = this.thead.querySelector('input[type="checkbox"]');
|
|
1627
|
+
i && (i.checked = e, i.indeterminate = !e && t);
|
|
1628
|
+
}
|
|
1629
|
+
destroy() {
|
|
1630
|
+
this.thead && (this.thead.remove(), this.thead = null), this.filterRow = null;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
class ve {
|
|
1634
|
+
constructor(e, t, i, s = {}) {
|
|
1635
|
+
this.tableContainer = null, this.headerScrollContainer = null, this.bodyScrollContainer = null, this.headerTable = null, this.bodyTable = null, this.tbody = null, this.colgroup = null, this.headerColgroup = null, this.spacer = null, this.loadingOverlay = null, this.currentRows = [], this.virtualEnabled = !1, this.virtualRowHeight = 44, this.virtualOverscan = 10, this.totalRows = 0, this.theme = e, this.events = t, this.lang = s, this.cellRenderer = new fe(e, i), this.headerRenderer = new be(e, t, s);
|
|
1636
|
+
}
|
|
1637
|
+
/** Swap the active locale strings; takes effect on the next render. */
|
|
1638
|
+
setLang(e) {
|
|
1639
|
+
this.lang = e, this.headerRenderer.setLang(e);
|
|
1640
|
+
}
|
|
1641
|
+
render(e, t, i, s) {
|
|
1642
|
+
var n, a, o, l;
|
|
1643
|
+
this.cleanup(), this.cellRenderer.setApi(s.api ?? null, s.host ?? null), this.tableContainer = document.createElement("div"), this.tableContainer.className = "katucharts-dt-table-container", this.virtualEnabled = ((n = s.virtualScroll) == null ? void 0 : n.enabled) === !0 || ((a = s.virtualScroll) == null ? void 0 : a.threshold) != null && i.totalFiltered >= s.virtualScroll.threshold, this.virtualRowHeight = ((o = s.virtualScroll) == null ? void 0 : o.rowHeight) ?? this.theme.rowHeight, this.virtualOverscan = ((l = s.virtualScroll) == null ? void 0 : l.overscan) ?? 10, this.totalRows = i.totalFiltered;
|
|
1644
|
+
const r = (s.selectionCheckbox ? 44 : 0) + t.filter((d) => d._visible).reduce((d, h) => d + h._computedWidth, 0);
|
|
1645
|
+
if (this.headerScrollContainer = document.createElement("div"), this.headerScrollContainer.className = "katucharts-dt-header-scroll", this.headerTable = document.createElement("table"), this.headerTable.style.width = `${r}px`, s.tableClass && (this.headerTable.className = s.tableClass), this.theme.userTableStyle && Object.assign(this.headerTable.style, this.theme.userTableStyle), this.headerColgroup = this.createColgroup(t, s.selectionCheckbox), this.headerTable.appendChild(this.headerColgroup), this.headerRenderer.render(this.headerTable, t, {
|
|
1646
|
+
sortingEnabled: s.sortingEnabled,
|
|
1647
|
+
filteringEnabled: s.filteringEnabled,
|
|
1648
|
+
filterPosition: s.filterPosition,
|
|
1649
|
+
resizingEnabled: s.resizingEnabled,
|
|
1650
|
+
selectionCheckbox: s.selectionCheckbox,
|
|
1651
|
+
headerGroups: s.headerGroups,
|
|
1652
|
+
api: s.api,
|
|
1653
|
+
host: s.host
|
|
1654
|
+
}), this.headerScrollContainer.appendChild(this.headerTable), this.tableContainer.appendChild(this.headerScrollContainer), this.bodyScrollContainer = document.createElement("div"), this.bodyScrollContainer.className = "katucharts-dt-body-scroll", s.bodyClass && (this.bodyScrollContainer.className += ` ${s.bodyClass}`), this.theme.userBodyStyle && Object.assign(this.bodyScrollContainer.style, this.theme.userBodyStyle), s.height != null && (this.bodyScrollContainer.style.maxHeight = typeof s.height == "number" ? `${s.height}px` : s.height), this.virtualEnabled && (this.spacer = document.createElement("div"), this.spacer.style.height = `${this.totalRows * this.virtualRowHeight}px`, this.spacer.style.width = `${r}px`, this.spacer.style.position = "relative", this.bodyScrollContainer.appendChild(this.spacer)), this.bodyTable = document.createElement("table"), this.bodyTable.style.width = `${r}px`, s.tableClass && (this.bodyTable.className = s.tableClass), this.theme.userTableStyle && Object.assign(this.bodyTable.style, this.theme.userTableStyle), this.virtualEnabled && (this.bodyTable.style.position = "absolute", this.bodyTable.style.top = "0", this.bodyTable.style.left = "0"), this.colgroup = this.createColgroup(t, s.selectionCheckbox), this.bodyTable.appendChild(this.colgroup), this.tbody = document.createElement("tbody"), i.rows.length === 0 ? this.renderNoData(s.noDataText, t, s) : this.renderRows(i.rows, t, s), this.bodyTable.appendChild(this.tbody), this.virtualEnabled && this.spacer ? this.spacer.appendChild(this.bodyTable) : this.bodyScrollContainer.appendChild(this.bodyTable), this.tableContainer.appendChild(this.bodyScrollContainer), this.bodyScrollContainer.addEventListener("scroll", () => {
|
|
1655
|
+
this.headerScrollContainer && (this.headerScrollContainer.scrollLeft = this.bodyScrollContainer.scrollLeft), this.events.emit("scroll", {
|
|
1656
|
+
scrollTop: this.bodyScrollContainer.scrollTop,
|
|
1657
|
+
scrollLeft: this.bodyScrollContainer.scrollLeft
|
|
1658
|
+
});
|
|
1659
|
+
}), this.virtualEnabled) {
|
|
1660
|
+
const d = q(() => {
|
|
1661
|
+
this.events.emit("virtual:scroll", {
|
|
1662
|
+
scrollTop: this.bodyScrollContainer.scrollTop,
|
|
1663
|
+
viewportHeight: this.bodyScrollContainer.clientHeight
|
|
1664
|
+
});
|
|
1665
|
+
}, 16);
|
|
1666
|
+
this.bodyScrollContainer.addEventListener("scroll", d);
|
|
1667
|
+
}
|
|
1668
|
+
this.loadingOverlay = document.createElement("div"), this.loadingOverlay.className = "katucharts-dt-loading", this.loadingOverlay.style.display = "none", this.loadingOverlay.innerHTML = `<span class="katucharts-dt-spinner"></span><span>${s.loadingText}</span>`, this.tableContainer.appendChild(this.loadingOverlay), e.appendChild(this.tableContainer), this.currentRows = i.rows;
|
|
1669
|
+
}
|
|
1670
|
+
updateRows(e, t, i) {
|
|
1671
|
+
this.tbody && (this.cellRenderer.setApi(i.api ?? null, i.host ?? null), this.tbody.innerHTML = "", this.totalRows = e.totalFiltered, this.virtualEnabled && this.spacer && (this.spacer.style.height = `${this.totalRows * this.virtualRowHeight}px`), e.rows.length === 0 ? this.renderNoData(i.noDataText, t, i) : this.renderRows(e.rows, t, i), this.currentRows = e.rows);
|
|
1672
|
+
}
|
|
1673
|
+
renderRows(e, t, i) {
|
|
1674
|
+
var r, n, a;
|
|
1675
|
+
const s = t.filter((o) => o._visible);
|
|
1676
|
+
for (let o = 0; o < e.length; o++) {
|
|
1677
|
+
const l = e[o];
|
|
1678
|
+
if (l._type === "group-header") {
|
|
1679
|
+
this.renderGroupHeader(l, s.length, i);
|
|
1680
|
+
continue;
|
|
1681
|
+
}
|
|
1682
|
+
if (l._type !== "data") continue;
|
|
1683
|
+
const d = document.createElement("tr");
|
|
1684
|
+
d.className = "katucharts-dt-row";
|
|
1685
|
+
const h = i.selectedIndices.has(l._originalIndex);
|
|
1686
|
+
h && d.classList.add("is-selected"), this.virtualEnabled && (d.style.height = `${this.virtualRowHeight}px`);
|
|
1687
|
+
const u = this.theme.rowStyle({ row: l._data, rowIndex: l._originalIndex });
|
|
1688
|
+
if (u && Object.assign(d.style, u), d.addEventListener("mouseenter", () => this.events.emit("row:mouseenter", { row: l._data, rowIndex: l._originalIndex })), d.addEventListener("mouseleave", () => this.events.emit("row:mouseleave", { row: l._data, rowIndex: l._originalIndex })), i.selectionCheckbox && i.selectionMode !== "none") {
|
|
1689
|
+
const p = document.createElement("td");
|
|
1690
|
+
p.className = "katucharts-dt-td katucharts-dt-checkbox-cell";
|
|
1691
|
+
const f = document.createElement("input");
|
|
1692
|
+
f.type = "checkbox", f.className = "katucharts-dt-checkbox", f.checked = h, f.setAttribute("aria-label", this.lang.selectRow ?? "Select row"), f.addEventListener("click", (y) => y.stopPropagation()), f.addEventListener("change", () => {
|
|
1693
|
+
this.events.emit("selection:checkbox", {
|
|
1694
|
+
rowIndex: l._originalIndex,
|
|
1695
|
+
row: l._data,
|
|
1696
|
+
checked: f.checked
|
|
1697
|
+
});
|
|
1698
|
+
}), p.appendChild(f), d.appendChild(p);
|
|
1699
|
+
}
|
|
1700
|
+
const g = (r = i.treeData) != null && r.enabled && l._depth > 0 ? l._depth * (i.treeData.indent ?? 20) : 0;
|
|
1701
|
+
for (let p = 0; p < s.length; p++) {
|
|
1702
|
+
const f = s[p], y = this.cellRenderer.resolveValue(l._data, f), x = this.cellRenderer.createCell(d, y, l, f, o);
|
|
1703
|
+
if (p === 0 && g > 0 && (x.style.paddingLeft = `${g + 16}px`), p === 0 && ((n = i.treeData) != null && n.enabled) && l._expanded !== void 0) {
|
|
1704
|
+
const k = document.createElement("span");
|
|
1705
|
+
k.textContent = l._expanded ? "▼ " : "▶ ", k.style.cursor = "pointer", k.style.marginRight = "4px", k.addEventListener("click", (w) => {
|
|
1706
|
+
w.stopPropagation(), this.events.emit("tree:toggle", { rowIndex: l._originalIndex, expanded: !l._expanded });
|
|
1707
|
+
}), x.insertBefore(k, x.firstChild);
|
|
1708
|
+
}
|
|
1709
|
+
x.addEventListener("click", (k) => {
|
|
1710
|
+
this.events.emit("cell:click", {
|
|
1711
|
+
value: y,
|
|
1712
|
+
row: l._data,
|
|
1713
|
+
column: f,
|
|
1714
|
+
rowIndex: l._originalIndex,
|
|
1715
|
+
colIndex: p,
|
|
1716
|
+
originalEvent: k
|
|
1717
|
+
});
|
|
1718
|
+
}), x.addEventListener("dblclick", (k) => {
|
|
1719
|
+
this.events.emit("cell:dblclick", {
|
|
1720
|
+
value: y,
|
|
1721
|
+
row: l._data,
|
|
1722
|
+
column: f,
|
|
1723
|
+
rowIndex: l._originalIndex,
|
|
1724
|
+
colIndex: p,
|
|
1725
|
+
originalEvent: k,
|
|
1726
|
+
td: x
|
|
1727
|
+
});
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
d.addEventListener("click", (p) => this.events.emit("row:click", { row: l._data, rowIndex: l._originalIndex, originalEvent: p })), d.addEventListener("dblclick", (p) => this.events.emit("row:dblclick", { row: l._data, rowIndex: l._originalIndex, originalEvent: p })), d.addEventListener("contextmenu", (p) => this.events.emit("row:contextmenu", { row: l._data, rowIndex: l._originalIndex, originalEvent: p })), d.setAttribute("data-row-index", String(l._originalIndex)), this.tbody.appendChild(d), (a = i.masterDetail) != null && a.enabled && l._expanded && this.renderDetailRow(l, s.length + (i.selectionCheckbox ? 1 : 0), i.masterDetail);
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
renderGroupHeader(e, t, i) {
|
|
1734
|
+
var o, l;
|
|
1735
|
+
const s = document.createElement("tr");
|
|
1736
|
+
s.className = "katucharts-dt-group-header";
|
|
1737
|
+
const r = document.createElement("td");
|
|
1738
|
+
r.colSpan = t + (i.selectionCheckbox ? 1 : 0);
|
|
1739
|
+
const n = e._expanded ? "▼" : "▶", a = ((o = i.grouping) == null ? void 0 : o.showCount) !== !1 ? ` (${e._groupCount})` : "";
|
|
1740
|
+
(l = i.grouping) != null && l.headerFormatter ? r.innerHTML = i.grouping.headerFormatter.call({
|
|
1741
|
+
value: e._groupValue,
|
|
1742
|
+
column: e._groupColumn,
|
|
1743
|
+
count: e._groupCount
|
|
1744
|
+
}) : r.textContent = `${n} ${e._groupColumn}: ${e._groupValue}${a}`, r.addEventListener("click", () => {
|
|
1745
|
+
this.events.emit("group:toggle", {
|
|
1746
|
+
groupValue: e._groupValue,
|
|
1747
|
+
groupColumn: e._groupColumn,
|
|
1748
|
+
expanded: !e._expanded
|
|
1749
|
+
});
|
|
1750
|
+
}), s.appendChild(r), this.tbody.appendChild(s);
|
|
1751
|
+
}
|
|
1752
|
+
renderDetailRow(e, t, i) {
|
|
1753
|
+
const s = document.createElement("tr");
|
|
1754
|
+
s.className = "katucharts-dt-detail";
|
|
1755
|
+
const r = document.createElement("td");
|
|
1756
|
+
if (r.colSpan = t, i.height && i.height !== "auto" && (r.style.height = `${i.height}px`, r.style.overflow = "auto"), i.renderer) {
|
|
1757
|
+
const n = i.renderer(e._data, r);
|
|
1758
|
+
n instanceof HTMLElement && r.appendChild(n);
|
|
1759
|
+
}
|
|
1760
|
+
s.appendChild(r), this.tbody.appendChild(s);
|
|
1761
|
+
}
|
|
1762
|
+
renderNoData(e, t, i) {
|
|
1763
|
+
const s = document.createElement("tr"), r = document.createElement("td");
|
|
1764
|
+
r.className = "katucharts-dt-nodata", r.colSpan = t.filter((n) => n._visible).length + (i.selectionCheckbox ? 1 : 0) || 1, r.textContent = e, s.appendChild(r), this.tbody.appendChild(s);
|
|
1765
|
+
}
|
|
1766
|
+
createColgroup(e, t) {
|
|
1767
|
+
const i = document.createElement("colgroup");
|
|
1768
|
+
if (t) {
|
|
1769
|
+
const s = document.createElement("col");
|
|
1770
|
+
s.style.width = "44px", i.appendChild(s);
|
|
1771
|
+
}
|
|
1772
|
+
for (const s of e) {
|
|
1773
|
+
if (!s._visible) continue;
|
|
1774
|
+
const r = document.createElement("col");
|
|
1775
|
+
r.style.width = `${s._computedWidth}px`, i.appendChild(r);
|
|
1776
|
+
}
|
|
1777
|
+
return i;
|
|
1778
|
+
}
|
|
1779
|
+
updateVirtualPosition(e) {
|
|
1780
|
+
if (!this.virtualEnabled || !this.bodyTable) return;
|
|
1781
|
+
const t = Math.max(0, Math.floor(e / this.virtualRowHeight) - this.virtualOverscan);
|
|
1782
|
+
this.bodyTable.style.top = `${t * this.virtualRowHeight}px`;
|
|
1783
|
+
}
|
|
1784
|
+
showLoading(e) {
|
|
1785
|
+
if (this.loadingOverlay && (this.loadingOverlay.style.display = "flex", e)) {
|
|
1786
|
+
const t = this.loadingOverlay.querySelector("span:last-child");
|
|
1787
|
+
t && (t.textContent = e);
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
hideLoading() {
|
|
1791
|
+
this.loadingOverlay && (this.loadingOverlay.style.display = "none");
|
|
1792
|
+
}
|
|
1793
|
+
scrollToRow(e) {
|
|
1794
|
+
var t;
|
|
1795
|
+
if (this.bodyScrollContainer)
|
|
1796
|
+
if (this.virtualEnabled)
|
|
1797
|
+
this.bodyScrollContainer.scrollTop = e * this.virtualRowHeight;
|
|
1798
|
+
else {
|
|
1799
|
+
const i = (t = this.tbody) == null ? void 0 : t.querySelector(`[data-row-index="${e}"]`);
|
|
1800
|
+
i && i.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
getHeaderRenderer() {
|
|
1804
|
+
return this.headerRenderer;
|
|
1805
|
+
}
|
|
1806
|
+
getBodyScrollContainer() {
|
|
1807
|
+
return this.bodyScrollContainer;
|
|
1808
|
+
}
|
|
1809
|
+
cleanup() {
|
|
1810
|
+
this.headerRenderer.destroy(), this.tableContainer && (this.tableContainer.remove(), this.tableContainer = null), this.headerTable = null, this.bodyTable = null, this.tbody = null, this.colgroup = null, this.headerColgroup = null, this.spacer = null, this.bodyScrollContainer = null, this.headerScrollContainer = null, this.loadingOverlay = null;
|
|
1811
|
+
}
|
|
1812
|
+
destroy() {
|
|
1813
|
+
this.cleanup(), this.currentRows = [];
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
class ke {
|
|
1817
|
+
constructor(e, t, i = {}) {
|
|
1818
|
+
this.container = null, this.pageSizePopover = null, this.theme = e, this.events = t, this.lang = i;
|
|
1819
|
+
}
|
|
1820
|
+
/** Swap the active locale strings; takes effect on the next render. */
|
|
1821
|
+
setLang(e) {
|
|
1822
|
+
this.lang = e;
|
|
1823
|
+
}
|
|
1824
|
+
render(e, t, i) {
|
|
1825
|
+
var n;
|
|
1826
|
+
this.container && this.container.remove(), this.closePageSizeMenu(), this.container = document.createElement("div"), this.container.className = "katucharts-dt-footer";
|
|
1827
|
+
const s = document.createElement("div");
|
|
1828
|
+
if (s.className = "katucharts-dt-footer-section", i.showPageInfo !== !1) {
|
|
1829
|
+
const a = document.createElement("span");
|
|
1830
|
+
a.className = "katucharts-dt-page-info", a.textContent = this.formatPageInfo(t), s.appendChild(a);
|
|
1831
|
+
}
|
|
1832
|
+
i.showPageSizeSelector !== !1 && ((n = i.pageSizes) != null && n.length) && s.appendChild(this.createPageSizeSelector(t.pageSize, i.pageSizes));
|
|
1833
|
+
const r = document.createElement("div");
|
|
1834
|
+
r.className = "katucharts-dt-pagination", i.showFirstLast !== !1 && r.appendChild(this.createIconButton(v.chevronsLeft, 1, t.page <= 1, "First page")), r.appendChild(this.createIconButton(v.chevronLeft, t.page - 1, t.page <= 1, "Previous page"));
|
|
1835
|
+
for (const a of this.getPageNumbers(t.page, t.totalPages))
|
|
1836
|
+
if (a === -1) {
|
|
1837
|
+
const o = document.createElement("span");
|
|
1838
|
+
o.className = "katucharts-dt-ellipsis", o.textContent = "…", r.appendChild(o);
|
|
1839
|
+
} else
|
|
1840
|
+
r.appendChild(this.createTextButton(String(a), a, !1, a === t.page));
|
|
1841
|
+
return r.appendChild(this.createIconButton(v.chevronRight, t.page + 1, t.page >= t.totalPages, "Next page")), i.showFirstLast !== !1 && r.appendChild(this.createIconButton(v.chevronsRight, t.totalPages, t.page >= t.totalPages, "Last page")), this.container.appendChild(s), this.container.appendChild(r), e.appendChild(this.container), this.container;
|
|
1842
|
+
}
|
|
1843
|
+
createButton(e, t, i, s) {
|
|
1844
|
+
const r = document.createElement("button");
|
|
1845
|
+
return r.type = "button", r.className = "katucharts-dt-btn", i && r.classList.add("is-active"), r.disabled = t, s && r.setAttribute("aria-label", s), t || r.addEventListener("click", () => this.events.emit("page:change", { page: e })), r;
|
|
1846
|
+
}
|
|
1847
|
+
createIconButton(e, t, i, s) {
|
|
1848
|
+
const r = this.createButton(t, i, !1, s);
|
|
1849
|
+
return r.innerHTML = e, r;
|
|
1850
|
+
}
|
|
1851
|
+
createTextButton(e, t, i, s) {
|
|
1852
|
+
const r = this.createButton(t, i, s);
|
|
1853
|
+
return r.textContent = e, r;
|
|
1854
|
+
}
|
|
1855
|
+
createPageSizeSelector(e, t) {
|
|
1856
|
+
const i = document.createElement("div");
|
|
1857
|
+
i.className = "katucharts-dt-page-size";
|
|
1858
|
+
const s = document.createElement("span");
|
|
1859
|
+
s.textContent = this.lang.pageSizeLabel ?? "Rows per page:", i.appendChild(s);
|
|
1860
|
+
const r = document.createElement("button");
|
|
1861
|
+
return r.type = "button", r.className = "katucharts-dt-btn katucharts-dt-page-size-btn", r.setAttribute("aria-label", this.lang.pageSizeLabel ?? "Rows per page"), r.innerHTML = `<span>${e}</span>${v.chevronsUpDown}`, r.addEventListener("click", () => {
|
|
1862
|
+
if (this.pageSizePopover) {
|
|
1863
|
+
this.closePageSizeMenu();
|
|
1864
|
+
return;
|
|
1865
|
+
}
|
|
1866
|
+
const n = document.createElement("div");
|
|
1867
|
+
n.className = "katucharts-dt-menu", n.style.minWidth = "72px";
|
|
1868
|
+
for (const a of t) {
|
|
1869
|
+
const o = document.createElement("div");
|
|
1870
|
+
o.className = "katucharts-dt-menu-item", a === e && o.classList.add("is-active"), o.textContent = String(a), o.addEventListener("click", () => {
|
|
1871
|
+
this.closePageSizeMenu(), this.events.emit("page:sizechange", { pageSize: a });
|
|
1872
|
+
}), n.appendChild(o);
|
|
1873
|
+
}
|
|
1874
|
+
this.pageSizePopover = C(r, n, { align: "left" });
|
|
1875
|
+
}), i.appendChild(r), i;
|
|
1876
|
+
}
|
|
1877
|
+
closePageSizeMenu() {
|
|
1878
|
+
this.pageSizePopover && (this.pageSizePopover.close(), this.pageSizePopover = null);
|
|
1879
|
+
}
|
|
1880
|
+
getPageNumbers(e, t) {
|
|
1881
|
+
if (t <= 7) return Array.from({ length: t }, (n, a) => a + 1);
|
|
1882
|
+
const i = [1];
|
|
1883
|
+
e > 3 && i.push(-1);
|
|
1884
|
+
const s = Math.max(2, e - 1), r = Math.min(t - 1, e + 1);
|
|
1885
|
+
for (let n = s; n <= r; n++) i.push(n);
|
|
1886
|
+
return e < t - 2 && i.push(-1), i.push(t), i;
|
|
1887
|
+
}
|
|
1888
|
+
formatPageInfo(e) {
|
|
1889
|
+
return (this.lang.pageInfo ?? "Showing {from}-{to} of {total}").replace("{from}", String(e.from)).replace("{to}", String(e.to)).replace("{total}", String(e.totalRows));
|
|
1890
|
+
}
|
|
1891
|
+
update(e, t, i) {
|
|
1892
|
+
this.render(i, e, t);
|
|
1893
|
+
}
|
|
1894
|
+
destroy() {
|
|
1895
|
+
this.closePageSizeMenu(), this.container && (this.container.remove(), this.container = null);
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
class xe {
|
|
1899
|
+
constructor(e, t, i = {}) {
|
|
1900
|
+
this.input = null, this.container = null, this.theme = e, this.events = t, this.lang = i;
|
|
1901
|
+
}
|
|
1902
|
+
/** Swap the active locale strings; takes effect on the next render. */
|
|
1903
|
+
setLang(e) {
|
|
1904
|
+
this.lang = e;
|
|
1905
|
+
}
|
|
1906
|
+
render(e, t) {
|
|
1907
|
+
this.container && this.container.remove(), this.container = document.createElement("div"), this.container.className = "katucharts-dt-search";
|
|
1908
|
+
const i = document.createElement("span");
|
|
1909
|
+
i.className = "katucharts-dt-search-icon", i.innerHTML = v.search, this.container.appendChild(i), this.input = document.createElement("input"), this.input.type = "text", this.input.className = "katucharts-dt-input", this.input.placeholder = t.placeholder ?? this.lang.search ?? "Search…", t.inputStyle && Object.assign(this.input.style, t.inputStyle);
|
|
1910
|
+
const s = V((r) => {
|
|
1911
|
+
this.events.emit("search:change", { query: r });
|
|
1912
|
+
}, t.debounceMs ?? 300);
|
|
1913
|
+
return this.input.addEventListener("input", () => s(this.input.value)), this.input.addEventListener("keydown", (r) => {
|
|
1914
|
+
r.key === "Escape" && (this.input.value = "", this.events.emit("search:change", { query: "" }));
|
|
1915
|
+
}), this.container.appendChild(this.input), e.appendChild(this.container), this.container;
|
|
1916
|
+
}
|
|
1917
|
+
setValue(e) {
|
|
1918
|
+
this.input && (this.input.value = e);
|
|
1919
|
+
}
|
|
1920
|
+
getValue() {
|
|
1921
|
+
var e;
|
|
1922
|
+
return ((e = this.input) == null ? void 0 : e.value) ?? "";
|
|
1923
|
+
}
|
|
1924
|
+
focus() {
|
|
1925
|
+
var e;
|
|
1926
|
+
(e = this.input) == null || e.focus();
|
|
1927
|
+
}
|
|
1928
|
+
destroy() {
|
|
1929
|
+
this.container && (this.container.remove(), this.container = null), this.input = null;
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
class ye {
|
|
1933
|
+
constructor(e, t, i = {}) {
|
|
1934
|
+
this.container = null, this.popover = null, this.hasActiveFilters = !1, this.resetButton = null, this.theme = e, this.events = t, this.searchRenderer = new xe(e, t, i), this.lang = i;
|
|
1935
|
+
}
|
|
1936
|
+
/** Swap the active locale strings; takes effect on the next render. */
|
|
1937
|
+
setLang(e) {
|
|
1938
|
+
this.lang = e, this.searchRenderer.setLang(e);
|
|
1939
|
+
}
|
|
1940
|
+
setActiveFilters(e) {
|
|
1941
|
+
this.hasActiveFilters = e;
|
|
1942
|
+
}
|
|
1943
|
+
/** Toggle the reset button live, without re-rendering the toolbar. */
|
|
1944
|
+
setResetVisible(e) {
|
|
1945
|
+
this.hasActiveFilters = e, this.resetButton && (this.resetButton.style.display = e ? "" : "none");
|
|
1946
|
+
}
|
|
1947
|
+
render(e, t, i, s, r) {
|
|
1948
|
+
this.container && this.container.remove(), this.closeDropdown(), this.container = document.createElement("div"), this.container.className = "katucharts-dt-toolbar";
|
|
1949
|
+
const n = document.createElement("div");
|
|
1950
|
+
n.className = "katucharts-dt-toolbar-group katucharts-dt-toolbar-group--left";
|
|
1951
|
+
const a = document.createElement("div");
|
|
1952
|
+
a.className = "katucharts-dt-toolbar-group";
|
|
1953
|
+
const o = t.items ?? ["search", "columnToggle", "export"];
|
|
1954
|
+
for (const l of o)
|
|
1955
|
+
switch (l) {
|
|
1956
|
+
case "search":
|
|
1957
|
+
i.enabled !== !1 && this.searchRenderer.render(n, i);
|
|
1958
|
+
break;
|
|
1959
|
+
case "reset":
|
|
1960
|
+
n.appendChild(this.createResetButton());
|
|
1961
|
+
break;
|
|
1962
|
+
case "columnToggle":
|
|
1963
|
+
a.appendChild(this.createColumnToggle(r));
|
|
1964
|
+
break;
|
|
1965
|
+
case "export":
|
|
1966
|
+
s.enabled !== !1 && a.appendChild(this.createExportDropdown(s));
|
|
1967
|
+
break;
|
|
1968
|
+
case "density":
|
|
1969
|
+
a.appendChild(this.createDensityToggle());
|
|
1970
|
+
break;
|
|
1971
|
+
case "fullscreen":
|
|
1972
|
+
a.appendChild(this.createFullscreenButton());
|
|
1973
|
+
break;
|
|
1974
|
+
}
|
|
1975
|
+
if (t.customItems)
|
|
1976
|
+
for (const l of t.customItems) {
|
|
1977
|
+
const d = document.createElement("button");
|
|
1978
|
+
d.className = "katucharts-dt-btn", d.innerHTML = l.content, l.style && Object.assign(d.style, l.style), l.onClick && d.addEventListener("click", l.onClick), (l.position === "left" ? n : a).appendChild(d);
|
|
1979
|
+
}
|
|
1980
|
+
return this.container.appendChild(n), this.container.appendChild(a), e.appendChild(this.container), this.container;
|
|
1981
|
+
}
|
|
1982
|
+
button(e, t) {
|
|
1983
|
+
const i = document.createElement("button");
|
|
1984
|
+
return i.type = "button", i.className = "katucharts-dt-btn", i.innerHTML = `${t ?? ""}<span>${e}</span>`, i;
|
|
1985
|
+
}
|
|
1986
|
+
createResetButton() {
|
|
1987
|
+
const e = this.button(this.lang.resetFilters ?? "Reset", v.x);
|
|
1988
|
+
return e.addEventListener("click", () => this.events.emit("filters:reset")), e.style.display = this.hasActiveFilters ? "" : "none", this.resetButton = e, e;
|
|
1989
|
+
}
|
|
1990
|
+
toggleMenu(e, t) {
|
|
1991
|
+
if (this.popover) {
|
|
1992
|
+
this.closeDropdown();
|
|
1993
|
+
return;
|
|
1994
|
+
}
|
|
1995
|
+
this.popover = C(e, t(), { align: "right" });
|
|
1996
|
+
}
|
|
1997
|
+
createColumnToggle(e) {
|
|
1998
|
+
const t = document.createElement("div");
|
|
1999
|
+
t.style.position = "relative";
|
|
2000
|
+
const i = this.button(this.lang.columns ?? "Columns", v.columns);
|
|
2001
|
+
return i.addEventListener("click", () => this.toggleMenu(i, () => {
|
|
2002
|
+
const s = document.createElement("div");
|
|
2003
|
+
s.className = "katucharts-dt-menu";
|
|
2004
|
+
const r = document.createElement("div");
|
|
2005
|
+
r.className = "katucharts-dt-menu-label", r.textContent = this.lang.toggleColumns ?? "Toggle columns", s.appendChild(r);
|
|
2006
|
+
for (const n of e) {
|
|
2007
|
+
if (n.enableHiding === !1) continue;
|
|
2008
|
+
const a = document.createElement("label");
|
|
2009
|
+
a.className = "katucharts-dt-menu-item";
|
|
2010
|
+
const o = document.createElement("input");
|
|
2011
|
+
o.type = "checkbox", o.checked = n._visible, o.addEventListener("change", () => {
|
|
2012
|
+
this.events.emit("column:visibility", { field: n.field, visible: o.checked });
|
|
2013
|
+
});
|
|
2014
|
+
const l = document.createElement("span");
|
|
2015
|
+
l.textContent = n.title ?? n.field, a.appendChild(o), a.appendChild(l), s.appendChild(a);
|
|
2016
|
+
}
|
|
2017
|
+
return s;
|
|
2018
|
+
})), t.appendChild(i), t;
|
|
2019
|
+
}
|
|
2020
|
+
createExportDropdown(e) {
|
|
2021
|
+
const t = document.createElement("div");
|
|
2022
|
+
t.style.position = "relative";
|
|
2023
|
+
const i = this.button(this.lang.exportButton ?? "Export", v.download);
|
|
2024
|
+
return i.addEventListener("click", () => this.toggleMenu(i, () => {
|
|
2025
|
+
const s = document.createElement("div");
|
|
2026
|
+
s.className = "katucharts-dt-menu";
|
|
2027
|
+
const r = e.formats ?? ["csv", "json", "clipboard"], n = {
|
|
2028
|
+
csv: this.lang.exportCSV ?? "Export CSV",
|
|
2029
|
+
json: this.lang.exportJSON ?? "Export JSON",
|
|
2030
|
+
clipboard: this.lang.copyClipboard ?? "Copy to clipboard",
|
|
2031
|
+
html: this.lang.exportHTML ?? "Export HTML"
|
|
2032
|
+
};
|
|
2033
|
+
for (const a of r) {
|
|
2034
|
+
const o = document.createElement("div");
|
|
2035
|
+
o.className = "katucharts-dt-menu-item", o.textContent = n[a] ?? a, o.addEventListener("click", () => {
|
|
2036
|
+
this.events.emit("export:trigger", { format: a }), this.closeDropdown();
|
|
2037
|
+
}), s.appendChild(o);
|
|
2038
|
+
}
|
|
2039
|
+
return s;
|
|
2040
|
+
})), t.appendChild(i), t;
|
|
2041
|
+
}
|
|
2042
|
+
createDensityToggle() {
|
|
2043
|
+
const e = document.createElement("div");
|
|
2044
|
+
e.style.position = "relative";
|
|
2045
|
+
const t = this.button(this.lang.density ?? "Density", v.sliders);
|
|
2046
|
+
return t.addEventListener("click", () => this.toggleMenu(t, () => {
|
|
2047
|
+
const i = document.createElement("div");
|
|
2048
|
+
i.className = "katucharts-dt-menu";
|
|
2049
|
+
const s = ["compact", "normal", "comfortable"], r = {
|
|
2050
|
+
compact: this.lang.densityCompact ?? "Compact",
|
|
2051
|
+
normal: this.lang.densityNormal ?? "Normal",
|
|
2052
|
+
comfortable: this.lang.densityComfortable ?? "Comfortable"
|
|
2053
|
+
};
|
|
2054
|
+
for (const n of s) {
|
|
2055
|
+
const a = document.createElement("div");
|
|
2056
|
+
a.className = "katucharts-dt-menu-item", n === this.theme.density && a.classList.add("is-active"), a.textContent = r[n], a.addEventListener("click", () => {
|
|
2057
|
+
this.events.emit("density:change", { density: n }), this.closeDropdown();
|
|
2058
|
+
}), i.appendChild(a);
|
|
2059
|
+
}
|
|
2060
|
+
return i;
|
|
2061
|
+
})), e.appendChild(t), e;
|
|
2062
|
+
}
|
|
2063
|
+
createFullscreenButton() {
|
|
2064
|
+
const e = this.button("", v.expand);
|
|
2065
|
+
return e.addEventListener("click", () => this.events.emit("fullscreen:toggle")), e;
|
|
2066
|
+
}
|
|
2067
|
+
closeDropdown() {
|
|
2068
|
+
this.popover && (this.popover.close(), this.popover = null);
|
|
2069
|
+
}
|
|
2070
|
+
getSearchRenderer() {
|
|
2071
|
+
return this.searchRenderer;
|
|
2072
|
+
}
|
|
2073
|
+
destroy() {
|
|
2074
|
+
this.closeDropdown(), this.searchRenderer.destroy(), this.container && (this.container.remove(), this.container = null);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
class Se {
|
|
2078
|
+
constructor(e, t, i = !1) {
|
|
2079
|
+
this.selectedIndices = /* @__PURE__ */ new Set(), this.lastClickedIndex = -1, this.mode = e, this.events = t, this.preserveOnFilter = i;
|
|
2080
|
+
}
|
|
2081
|
+
handleRowClick(e, t, i) {
|
|
2082
|
+
if (this.mode === "none") return;
|
|
2083
|
+
const s = this.selectedIndices.has(e), r = [], n = [];
|
|
2084
|
+
if (this.mode === "single") {
|
|
2085
|
+
for (const a of this.selectedIndices)
|
|
2086
|
+
a !== e && n.push(a);
|
|
2087
|
+
this.selectedIndices.clear(), s ? n.push(t) : (this.selectedIndices.add(e), r.push(t));
|
|
2088
|
+
} else if (this.mode === "multi")
|
|
2089
|
+
if (i.shiftKey && this.lastClickedIndex >= 0) {
|
|
2090
|
+
const a = Math.min(this.lastClickedIndex, e), o = Math.max(this.lastClickedIndex, e);
|
|
2091
|
+
for (let l = a; l <= o; l++)
|
|
2092
|
+
this.selectedIndices.has(l) || this.selectedIndices.add(l);
|
|
2093
|
+
} else if (i.ctrlKey || i.metaKey)
|
|
2094
|
+
s ? (this.selectedIndices.delete(e), n.push(t)) : (this.selectedIndices.add(e), r.push(t));
|
|
2095
|
+
else {
|
|
2096
|
+
for (const a of this.selectedIndices)
|
|
2097
|
+
a !== e && n.push(a);
|
|
2098
|
+
this.selectedIndices.clear(), s || (this.selectedIndices.add(e), r.push(t));
|
|
2099
|
+
}
|
|
2100
|
+
this.lastClickedIndex = e, this.emitChange(r, n);
|
|
2101
|
+
}
|
|
2102
|
+
handleCheckboxToggle(e, t, i) {
|
|
2103
|
+
i ? (this.selectedIndices.add(e), this.emitChange([t], [])) : (this.selectedIndices.delete(e), this.emitChange([], [t]));
|
|
2104
|
+
}
|
|
2105
|
+
selectAll(e) {
|
|
2106
|
+
const t = [];
|
|
2107
|
+
for (const i of e)
|
|
2108
|
+
i._type === "data" && !this.selectedIndices.has(i._originalIndex) && (this.selectedIndices.add(i._originalIndex), t.push(i._data));
|
|
2109
|
+
t.length && this.emitChange(t, []);
|
|
2110
|
+
}
|
|
2111
|
+
deselectAll() {
|
|
2112
|
+
const e = Array.from(this.selectedIndices);
|
|
2113
|
+
this.selectedIndices.clear(), e.length && this.emitChange([], e);
|
|
2114
|
+
}
|
|
2115
|
+
selectRow(e) {
|
|
2116
|
+
const t = Array.isArray(e) ? e : [e], i = [];
|
|
2117
|
+
for (const s of t)
|
|
2118
|
+
this.selectedIndices.has(s) || (this.selectedIndices.add(s), i.push(s));
|
|
2119
|
+
i.length && this.emitChange(i, []);
|
|
2120
|
+
}
|
|
2121
|
+
deselectRow(e) {
|
|
2122
|
+
const t = Array.isArray(e) ? e : [e], i = [];
|
|
2123
|
+
for (const s of t)
|
|
2124
|
+
this.selectedIndices.delete(s) && i.push(s);
|
|
2125
|
+
i.length && this.emitChange([], i);
|
|
2126
|
+
}
|
|
2127
|
+
isSelected(e) {
|
|
2128
|
+
return this.selectedIndices.has(e);
|
|
2129
|
+
}
|
|
2130
|
+
getSelectedIndices() {
|
|
2131
|
+
return Array.from(this.selectedIndices).sort((e, t) => e - t);
|
|
2132
|
+
}
|
|
2133
|
+
getSelectedData(e) {
|
|
2134
|
+
return this.getSelectedIndices().filter((t) => t >= 0 && t < e.length).map((t) => e[t]);
|
|
2135
|
+
}
|
|
2136
|
+
getCount() {
|
|
2137
|
+
return this.selectedIndices.size;
|
|
2138
|
+
}
|
|
2139
|
+
isAllSelected(e) {
|
|
2140
|
+
return e > 0 && this.selectedIndices.size >= e;
|
|
2141
|
+
}
|
|
2142
|
+
isSomeSelected() {
|
|
2143
|
+
return this.selectedIndices.size > 0;
|
|
2144
|
+
}
|
|
2145
|
+
clearOnFilter() {
|
|
2146
|
+
this.preserveOnFilter || this.selectedIndices.clear();
|
|
2147
|
+
}
|
|
2148
|
+
setMode(e) {
|
|
2149
|
+
if (this.mode = e, e === "none" && this.selectedIndices.clear(), e === "single" && this.selectedIndices.size > 1) {
|
|
2150
|
+
const t = this.selectedIndices.values().next().value;
|
|
2151
|
+
this.selectedIndices.clear(), t !== void 0 && this.selectedIndices.add(t);
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
emitChange(e, t) {
|
|
2155
|
+
this.events.emit("selection:change", {
|
|
2156
|
+
selected: Array.from(this.selectedIndices),
|
|
2157
|
+
added: e,
|
|
2158
|
+
removed: t
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
destroy() {
|
|
2162
|
+
this.selectedIndices.clear();
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
class m {
|
|
2166
|
+
static exportCSV(e, t, i, s) {
|
|
2167
|
+
const r = m.toCSV(e, t, i), n = new Blob([r], { type: "text/csv;charset=utf-8;" });
|
|
2168
|
+
m.downloadBlob(n, (s ?? "export") + ".csv");
|
|
2169
|
+
}
|
|
2170
|
+
static exportJSON(e, t, i, s) {
|
|
2171
|
+
const r = m.toJSON(e, t, i), n = new Blob([r], { type: "application/json;charset=utf-8;" });
|
|
2172
|
+
m.downloadBlob(n, (s ?? "export") + ".json");
|
|
2173
|
+
}
|
|
2174
|
+
static copyToClipboard(e, t) {
|
|
2175
|
+
const i = m.toCSV(e, t, { delimiter: " " });
|
|
2176
|
+
navigator.clipboard ? navigator.clipboard.writeText(i).catch(() => {
|
|
2177
|
+
m.fallbackCopy(i);
|
|
2178
|
+
}) : m.fallbackCopy(i);
|
|
2179
|
+
}
|
|
2180
|
+
static exportHTML(e, t, i) {
|
|
2181
|
+
const s = m.toHTML(e, t), r = new Blob([s], { type: "text/html;charset=utf-8;" });
|
|
2182
|
+
m.downloadBlob(r, (i ?? "export") + ".html");
|
|
2183
|
+
}
|
|
2184
|
+
static toCSV(e, t, i) {
|
|
2185
|
+
const s = (i == null ? void 0 : i.delimiter) ?? ",", r = (i == null ? void 0 : i.lineDelimiter) ?? `
|
|
2186
|
+
`, n = (i == null ? void 0 : i.includeHeaders) !== !1, a = t.filter((l) => l._visible), o = [];
|
|
2187
|
+
n && o.push(a.map((l) => m.escapeCSV(l.title ?? l.field, s)).join(s));
|
|
2188
|
+
for (const l of e) {
|
|
2189
|
+
const d = a.map((h) => {
|
|
2190
|
+
const u = l[h.field];
|
|
2191
|
+
return m.escapeCSV(u != null ? String(u) : "", s);
|
|
2192
|
+
});
|
|
2193
|
+
o.push(d.join(s));
|
|
2194
|
+
}
|
|
2195
|
+
return o.join(r);
|
|
2196
|
+
}
|
|
2197
|
+
static toJSON(e, t, i) {
|
|
2198
|
+
const s = (i == null ? void 0 : i.indent) ?? 2, r = t.filter((a) => a._visible), n = e.map((a) => {
|
|
2199
|
+
const o = {};
|
|
2200
|
+
for (const l of r)
|
|
2201
|
+
o[l.field] = a[l.field];
|
|
2202
|
+
return o;
|
|
2203
|
+
});
|
|
2204
|
+
return JSON.stringify(n, null, s);
|
|
2205
|
+
}
|
|
2206
|
+
static toHTML(e, t) {
|
|
2207
|
+
const i = t.filter((r) => r._visible), s = [
|
|
2208
|
+
'<!DOCTYPE html><html><head><meta charset="utf-8">',
|
|
2209
|
+
"<style>table{border-collapse:collapse;width:100%;font-family:sans-serif;font-size:13px}",
|
|
2210
|
+
"th,td{border:1px solid #ddd;padding:6px 10px;text-align:left}",
|
|
2211
|
+
"th{background:#f5f5f5;font-weight:600}tr:nth-child(even){background:#fafafa}</style>",
|
|
2212
|
+
"</head><body><table>",
|
|
2213
|
+
"<thead><tr>"
|
|
2214
|
+
];
|
|
2215
|
+
for (const r of i)
|
|
2216
|
+
s.push(`<th>${m.escapeHTML(r.title ?? r.field)}</th>`);
|
|
2217
|
+
s.push("</tr></thead><tbody>");
|
|
2218
|
+
for (const r of e) {
|
|
2219
|
+
s.push("<tr>");
|
|
2220
|
+
for (const n of i) {
|
|
2221
|
+
const a = r[n.field];
|
|
2222
|
+
s.push(`<td>${m.escapeHTML(a != null ? String(a) : "")}</td>`);
|
|
2223
|
+
}
|
|
2224
|
+
s.push("</tr>");
|
|
2225
|
+
}
|
|
2226
|
+
return s.push("</tbody></table></body></html>"), s.join("");
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Escapes a CSV field: neutralizes spreadsheet formula injection by prefixing
|
|
2230
|
+
* cells that begin with =, +, -, @, tab or CR with a single quote (plain
|
|
2231
|
+
* numbers exempted), then quotes per RFC 4180 when the field contains the
|
|
2232
|
+
* delimiter, a double quote, or a line break.
|
|
2233
|
+
*/
|
|
2234
|
+
static escapeCSV(e, t) {
|
|
2235
|
+
let i = e;
|
|
2236
|
+
return /^[=+\-@\t\r]/.test(i) && !/^-?\d+(?:[.,]\d+)?$/.test(i) && (i = "'" + i), i.includes(t) || i.includes('"') || i.includes(`
|
|
2237
|
+
`) || i.includes("\r") ? '"' + i.replace(/"/g, '""') + '"' : i;
|
|
2238
|
+
}
|
|
2239
|
+
static escapeHTML(e) {
|
|
2240
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2241
|
+
}
|
|
2242
|
+
static downloadBlob(e, t) {
|
|
2243
|
+
const i = URL.createObjectURL(e), s = document.createElement("a");
|
|
2244
|
+
s.href = i, s.download = t, s.style.display = "none", document.body.appendChild(s), s.click(), setTimeout(() => {
|
|
2245
|
+
document.body.removeChild(s), URL.revokeObjectURL(i);
|
|
2246
|
+
}, 100);
|
|
2247
|
+
}
|
|
2248
|
+
static fallbackCopy(e) {
|
|
2249
|
+
const t = document.createElement("textarea");
|
|
2250
|
+
t.value = e, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
class we {
|
|
2254
|
+
constructor(e, t, i) {
|
|
2255
|
+
this.activeEditor = null, this.events = e, this.theme = t, this.options = i;
|
|
2256
|
+
}
|
|
2257
|
+
startEditing(e, t, i, s, r) {
|
|
2258
|
+
if (!this.options.enabled || s.editable === !1) return;
|
|
2259
|
+
this.activeEditor && this.commitOrCancel();
|
|
2260
|
+
const n = this.createEditor(e, t, i, s);
|
|
2261
|
+
n && (this.activeEditor = {
|
|
2262
|
+
td: e,
|
|
2263
|
+
column: s,
|
|
2264
|
+
rowIndex: r,
|
|
2265
|
+
row: i,
|
|
2266
|
+
originalValue: t,
|
|
2267
|
+
element: n.element,
|
|
2268
|
+
getValue: n.getValue,
|
|
2269
|
+
destroy: n.destroy
|
|
2270
|
+
}, e.textContent = "", e.appendChild(n.element), (n.element instanceof HTMLInputElement || n.element instanceof HTMLSelectElement) && n.element.focus(), this.events.emit("cell:edit:start", { row: i, column: s.field, value: t, rowIndex: r }));
|
|
2271
|
+
}
|
|
2272
|
+
createEditor(e, t, i, s) {
|
|
2273
|
+
const r = s.editor ?? this.inferEditorType(s);
|
|
2274
|
+
if (typeof r == "function") {
|
|
2275
|
+
const n = r(e, t, i, s);
|
|
2276
|
+
return {
|
|
2277
|
+
element: e.lastElementChild ?? e,
|
|
2278
|
+
getValue: n.getValue,
|
|
2279
|
+
destroy: n.destroy
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
switch (r) {
|
|
2283
|
+
case "text":
|
|
2284
|
+
return this.createTextEditor(t);
|
|
2285
|
+
case "number":
|
|
2286
|
+
return this.createNumberEditor(t);
|
|
2287
|
+
case "select":
|
|
2288
|
+
return this.createSelectEditor(t, s);
|
|
2289
|
+
case "date":
|
|
2290
|
+
return this.createDateEditor(t);
|
|
2291
|
+
case "checkbox":
|
|
2292
|
+
return this.createCheckboxEditor(t);
|
|
2293
|
+
default:
|
|
2294
|
+
return this.createTextEditor(t);
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
createTextEditor(e) {
|
|
2298
|
+
const t = document.createElement("input");
|
|
2299
|
+
return t.type = "text", t.value = e != null ? String(e) : "", this.styleEditorInput(t), this.attachEditorEvents(t), {
|
|
2300
|
+
element: t,
|
|
2301
|
+
getValue: () => t.value,
|
|
2302
|
+
destroy: () => t.remove()
|
|
2303
|
+
};
|
|
2304
|
+
}
|
|
2305
|
+
createNumberEditor(e) {
|
|
2306
|
+
const t = document.createElement("input");
|
|
2307
|
+
return t.type = "number", t.value = e != null ? String(e) : "", this.styleEditorInput(t), this.attachEditorEvents(t), {
|
|
2308
|
+
element: t,
|
|
2309
|
+
getValue: () => t.value ? Number(t.value) : null,
|
|
2310
|
+
destroy: () => t.remove()
|
|
2311
|
+
};
|
|
2312
|
+
}
|
|
2313
|
+
createSelectEditor(e, t) {
|
|
2314
|
+
const i = document.createElement("select");
|
|
2315
|
+
this.styleEditorInput(i);
|
|
2316
|
+
const s = t.editorOptions ?? t.filterOptions ?? [];
|
|
2317
|
+
for (const r of s) {
|
|
2318
|
+
const n = document.createElement("option");
|
|
2319
|
+
n.value = String(r), n.textContent = String(r), String(r) === String(e) && (n.selected = !0), i.appendChild(n);
|
|
2320
|
+
}
|
|
2321
|
+
return i.addEventListener("change", () => this.commit()), i.addEventListener("keydown", (r) => {
|
|
2322
|
+
r.key === "Escape" && this.cancel();
|
|
2323
|
+
}), i.addEventListener("blur", () => {
|
|
2324
|
+
this.options.saveOnBlur !== !1 ? this.commit() : this.cancel();
|
|
2325
|
+
}), {
|
|
2326
|
+
element: i,
|
|
2327
|
+
getValue: () => i.value,
|
|
2328
|
+
destroy: () => i.remove()
|
|
2329
|
+
};
|
|
2330
|
+
}
|
|
2331
|
+
createDateEditor(e) {
|
|
2332
|
+
const t = document.createElement("input");
|
|
2333
|
+
if (t.type = "date", e) {
|
|
2334
|
+
const i = new Date(e);
|
|
2335
|
+
isNaN(i.getTime()) || (t.value = i.toISOString().split("T")[0]);
|
|
2336
|
+
}
|
|
2337
|
+
return this.styleEditorInput(t), this.attachEditorEvents(t), {
|
|
2338
|
+
element: t,
|
|
2339
|
+
getValue: () => t.value,
|
|
2340
|
+
destroy: () => t.remove()
|
|
2341
|
+
};
|
|
2342
|
+
}
|
|
2343
|
+
createCheckboxEditor(e) {
|
|
2344
|
+
const t = document.createElement("input");
|
|
2345
|
+
return t.type = "checkbox", t.checked = !!e, t.style.cursor = "pointer", t.addEventListener("change", () => this.commit()), t.addEventListener("keydown", (i) => {
|
|
2346
|
+
i.key === "Escape" && this.cancel();
|
|
2347
|
+
}), {
|
|
2348
|
+
element: t,
|
|
2349
|
+
getValue: () => t.checked,
|
|
2350
|
+
destroy: () => t.remove()
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
styleEditorInput(e) {
|
|
2354
|
+
Object.assign(e.style, {
|
|
2355
|
+
width: "100%",
|
|
2356
|
+
padding: "2px 4px",
|
|
2357
|
+
border: "2px solid #3b82f6",
|
|
2358
|
+
borderRadius: "3px",
|
|
2359
|
+
fontSize: "inherit",
|
|
2360
|
+
fontFamily: "inherit",
|
|
2361
|
+
boxSizing: "border-box",
|
|
2362
|
+
outline: "none",
|
|
2363
|
+
backgroundColor: "#fff"
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
attachEditorEvents(e) {
|
|
2367
|
+
e.addEventListener("keydown", (t) => {
|
|
2368
|
+
t.key === "Enter" ? (t.preventDefault(), this.commit()) : t.key === "Escape" ? this.cancel() : t.key === "Tab" && (t.preventDefault(), this.commit(), this.events.emit("cell:edit:tab", { shiftKey: t.shiftKey }));
|
|
2369
|
+
}), e.addEventListener("blur", () => {
|
|
2370
|
+
setTimeout(() => {
|
|
2371
|
+
this.activeEditor && this.activeEditor.element === e && (this.options.saveOnBlur !== !1 ? this.commit() : this.cancel());
|
|
2372
|
+
}, 100);
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
2375
|
+
commit() {
|
|
2376
|
+
if (!this.activeEditor) return;
|
|
2377
|
+
const { column: e, rowIndex: t, row: i, originalValue: s, td: r } = this.activeEditor, n = this.activeEditor.getValue();
|
|
2378
|
+
if (e.validator) {
|
|
2379
|
+
const a = e.validator(n, i);
|
|
2380
|
+
if (a !== !0) {
|
|
2381
|
+
const o = typeof a == "string" ? a : "Validation failed";
|
|
2382
|
+
this.showValidationError(r, o);
|
|
2383
|
+
return;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
this.activeEditor.destroy(), r.textContent = n != null ? String(n) : "", n !== s && this.events.emit("cell:edit:commit", {
|
|
2387
|
+
row: i,
|
|
2388
|
+
column: e.field,
|
|
2389
|
+
oldValue: s,
|
|
2390
|
+
newValue: n,
|
|
2391
|
+
rowIndex: t
|
|
2392
|
+
}), this.activeEditor = null;
|
|
2393
|
+
}
|
|
2394
|
+
cancel() {
|
|
2395
|
+
if (!this.activeEditor) return;
|
|
2396
|
+
const { column: e, row: t, originalValue: i, td: s } = this.activeEditor;
|
|
2397
|
+
this.activeEditor.destroy(), s.textContent = i != null ? String(i) : "", this.events.emit("cell:edit:cancel", {
|
|
2398
|
+
row: t,
|
|
2399
|
+
column: e.field,
|
|
2400
|
+
value: i
|
|
2401
|
+
}), this.activeEditor = null;
|
|
2402
|
+
}
|
|
2403
|
+
commitOrCancel() {
|
|
2404
|
+
this.options.saveOnBlur !== !1 ? this.commit() : this.cancel();
|
|
2405
|
+
}
|
|
2406
|
+
showValidationError(e, t) {
|
|
2407
|
+
e.style.outline = "2px solid #ef4444", e.title = t, setTimeout(() => {
|
|
2408
|
+
e.style.outline = "", e.title = "";
|
|
2409
|
+
}, 2e3);
|
|
2410
|
+
}
|
|
2411
|
+
isEditing() {
|
|
2412
|
+
return this.activeEditor !== null;
|
|
2413
|
+
}
|
|
2414
|
+
inferEditorType(e) {
|
|
2415
|
+
switch (e.type) {
|
|
2416
|
+
case "number":
|
|
2417
|
+
return "number";
|
|
2418
|
+
case "date":
|
|
2419
|
+
return "date";
|
|
2420
|
+
case "boolean":
|
|
2421
|
+
return "checkbox";
|
|
2422
|
+
default:
|
|
2423
|
+
return "text";
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
destroy() {
|
|
2427
|
+
this.activeEditor && (this.activeEditor.destroy(), this.activeEditor = null);
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
const B = {
|
|
2431
|
+
search: "Search...",
|
|
2432
|
+
noData: "No data available",
|
|
2433
|
+
loading: "Loading...",
|
|
2434
|
+
pageInfo: "Showing {from}-{to} of {total}",
|
|
2435
|
+
pageSizeLabel: "Rows per page:",
|
|
2436
|
+
firstPage: "«",
|
|
2437
|
+
lastPage: "»",
|
|
2438
|
+
previousPage: "‹",
|
|
2439
|
+
nextPage: "›",
|
|
2440
|
+
selectAll: "Select all",
|
|
2441
|
+
columns: "Columns",
|
|
2442
|
+
exportCSV: "Export CSV",
|
|
2443
|
+
exportJSON: "Export JSON",
|
|
2444
|
+
copyClipboard: "Copy to clipboard",
|
|
2445
|
+
resetFilters: "Reset filters",
|
|
2446
|
+
of: "of",
|
|
2447
|
+
rows: "rows",
|
|
2448
|
+
showing: "Showing",
|
|
2449
|
+
filterPlaceholder: "Filter…",
|
|
2450
|
+
filterAll: "All",
|
|
2451
|
+
filterTrue: "True",
|
|
2452
|
+
filterFalse: "False",
|
|
2453
|
+
rangeMin: "Min",
|
|
2454
|
+
rangeMax: "Max",
|
|
2455
|
+
selectAllRows: "Select all rows",
|
|
2456
|
+
selectRow: "Select row",
|
|
2457
|
+
toggleColumns: "Toggle columns",
|
|
2458
|
+
exportButton: "Export",
|
|
2459
|
+
exportHTML: "Export HTML",
|
|
2460
|
+
density: "Density",
|
|
2461
|
+
densityCompact: "Compact",
|
|
2462
|
+
densityNormal: "Normal",
|
|
2463
|
+
densityComfortable: "Comfortable"
|
|
2464
|
+
}, z = {
|
|
2465
|
+
search: "Pesquisar...",
|
|
2466
|
+
noData: "Nenhum dado disponível",
|
|
2467
|
+
loading: "Carregando...",
|
|
2468
|
+
pageInfo: "Exibindo {from}-{to} de {total}",
|
|
2469
|
+
pageSizeLabel: "Linhas por página:",
|
|
2470
|
+
selectAll: "Selecionar tudo",
|
|
2471
|
+
columns: "Colunas",
|
|
2472
|
+
exportCSV: "Exportar CSV",
|
|
2473
|
+
exportJSON: "Exportar JSON",
|
|
2474
|
+
copyClipboard: "Copiar para a área de transferência",
|
|
2475
|
+
resetFilters: "Redefinir filtros",
|
|
2476
|
+
of: "de",
|
|
2477
|
+
rows: "linhas",
|
|
2478
|
+
showing: "Exibindo",
|
|
2479
|
+
filterPlaceholder: "Filtrar…",
|
|
2480
|
+
filterAll: "Todos",
|
|
2481
|
+
filterTrue: "Verdadeiro",
|
|
2482
|
+
filterFalse: "Falso",
|
|
2483
|
+
rangeMin: "Mín",
|
|
2484
|
+
rangeMax: "Máx",
|
|
2485
|
+
selectAllRows: "Selecionar todas as linhas",
|
|
2486
|
+
selectRow: "Selecionar linha",
|
|
2487
|
+
toggleColumns: "Alternar colunas",
|
|
2488
|
+
exportButton: "Exportar",
|
|
2489
|
+
exportHTML: "Exportar HTML",
|
|
2490
|
+
density: "Densidade",
|
|
2491
|
+
densityCompact: "Compacto",
|
|
2492
|
+
densityNormal: "Normal",
|
|
2493
|
+
densityComfortable: "Confortável"
|
|
2494
|
+
}, Ce = {
|
|
2495
|
+
search: "Buscar...",
|
|
2496
|
+
noData: "Sin datos disponibles",
|
|
2497
|
+
loading: "Cargando...",
|
|
2498
|
+
pageInfo: "Mostrando {from}-{to} de {total}",
|
|
2499
|
+
pageSizeLabel: "Filas por página:",
|
|
2500
|
+
selectAll: "Seleccionar todo",
|
|
2501
|
+
columns: "Columnas",
|
|
2502
|
+
exportCSV: "Exportar CSV",
|
|
2503
|
+
exportJSON: "Exportar JSON",
|
|
2504
|
+
copyClipboard: "Copiar al portapapeles",
|
|
2505
|
+
resetFilters: "Restablecer filtros",
|
|
2506
|
+
of: "de",
|
|
2507
|
+
rows: "filas",
|
|
2508
|
+
showing: "Mostrando",
|
|
2509
|
+
filterPlaceholder: "Filtrar…",
|
|
2510
|
+
filterAll: "Todos",
|
|
2511
|
+
filterTrue: "Verdadero",
|
|
2512
|
+
filterFalse: "Falso",
|
|
2513
|
+
rangeMin: "Mín",
|
|
2514
|
+
rangeMax: "Máx",
|
|
2515
|
+
selectAllRows: "Seleccionar todas las filas",
|
|
2516
|
+
selectRow: "Seleccionar fila",
|
|
2517
|
+
toggleColumns: "Alternar columnas",
|
|
2518
|
+
exportButton: "Exportar",
|
|
2519
|
+
exportHTML: "Exportar HTML",
|
|
2520
|
+
density: "Densidad",
|
|
2521
|
+
densityCompact: "Compacto",
|
|
2522
|
+
densityNormal: "Normal",
|
|
2523
|
+
densityComfortable: "Cómodo"
|
|
2524
|
+
}, Ee = {
|
|
2525
|
+
search: "搜索...",
|
|
2526
|
+
noData: "暂无数据",
|
|
2527
|
+
loading: "加载中...",
|
|
2528
|
+
pageInfo: "显示第 {from}-{to} 项,共 {total} 项",
|
|
2529
|
+
pageSizeLabel: "每页行数:",
|
|
2530
|
+
selectAll: "全选",
|
|
2531
|
+
columns: "列",
|
|
2532
|
+
exportCSV: "导出 CSV",
|
|
2533
|
+
exportJSON: "导出 JSON",
|
|
2534
|
+
copyClipboard: "复制到剪贴板",
|
|
2535
|
+
resetFilters: "重置筛选",
|
|
2536
|
+
of: "/",
|
|
2537
|
+
rows: "行",
|
|
2538
|
+
showing: "显示",
|
|
2539
|
+
filterPlaceholder: "筛选…",
|
|
2540
|
+
filterAll: "全部",
|
|
2541
|
+
filterTrue: "是",
|
|
2542
|
+
filterFalse: "否",
|
|
2543
|
+
rangeMin: "最小",
|
|
2544
|
+
rangeMax: "最大",
|
|
2545
|
+
selectAllRows: "全选所有行",
|
|
2546
|
+
selectRow: "选择行",
|
|
2547
|
+
toggleColumns: "切换列",
|
|
2548
|
+
exportButton: "导出",
|
|
2549
|
+
exportHTML: "导出 HTML",
|
|
2550
|
+
density: "密度",
|
|
2551
|
+
densityCompact: "紧凑",
|
|
2552
|
+
densityNormal: "正常",
|
|
2553
|
+
densityComfortable: "宽松"
|
|
2554
|
+
}, W = {
|
|
2555
|
+
en: B,
|
|
2556
|
+
"pt-BR": z,
|
|
2557
|
+
pt: z,
|
|
2558
|
+
es: Ce,
|
|
2559
|
+
zh: Ee
|
|
2560
|
+
};
|
|
2561
|
+
function Te(c, e) {
|
|
2562
|
+
W[c] = e;
|
|
2563
|
+
}
|
|
2564
|
+
function _(c) {
|
|
2565
|
+
return W[c];
|
|
2566
|
+
}
|
|
2567
|
+
function I(c = {}) {
|
|
2568
|
+
const e = c.locale && c.locale !== "auto" ? c.locale : Re(), t = e ? _(e) : void 0;
|
|
2569
|
+
return {
|
|
2570
|
+
...B,
|
|
2571
|
+
...t ?? {},
|
|
2572
|
+
...c.langOverrides ?? {}
|
|
2573
|
+
};
|
|
2574
|
+
}
|
|
2575
|
+
function Re() {
|
|
2576
|
+
if (typeof navigator > "u") return "en";
|
|
2577
|
+
const c = [];
|
|
2578
|
+
Array.isArray(navigator.languages) && c.push(...navigator.languages), navigator.language && c.push(navigator.language);
|
|
2579
|
+
for (const e of c) {
|
|
2580
|
+
if (!e) continue;
|
|
2581
|
+
if (_(e)) return e;
|
|
2582
|
+
const t = e.split("-")[0];
|
|
2583
|
+
if (t !== e && _(t)) return t;
|
|
2584
|
+
}
|
|
2585
|
+
return "en";
|
|
2586
|
+
}
|
|
2587
|
+
class O {
|
|
2588
|
+
constructor(e, t = {}) {
|
|
2589
|
+
var s, r, n, a, o, l, d;
|
|
2590
|
+
this.columns = [], this.currentResult = null, this.currentPage = 1, this.searchQuery = "", this.sortState = [], this.filterState = {}, this.groupExpanded = /* @__PURE__ */ new Map(), this.resizeObserver = null, this.destroyed = !1, this.lastResponsiveWidth = 0, this.refreshing = !1, this.serverTotal = 0, this.initialVisibility = null, this.container = J(e), this.options = D(K, t), this.resolvedLang = I({ locale: this.options.locale, langOverrides: this.options.lang }), this.events = new G(), ue(this.container.ownerDocument ?? document), this.applyInitialState(), this.currentPageSize = ((r = (s = this.options.initialState) == null ? void 0 : s.pagination) == null ? void 0 : r.pageSize) ?? ((n = this.options.pagination) == null ? void 0 : n.pageSize) ?? 25, this.theme = new de(this.options.style), this.tableApi = ge(this), this.dataSource = new le(this.options), this.processor = new ce();
|
|
2591
|
+
const i = {};
|
|
2592
|
+
if (this.options.formatters)
|
|
2593
|
+
for (const [h, u] of Object.entries(this.options.formatters))
|
|
2594
|
+
u && (i[h] = u);
|
|
2595
|
+
this.tableRenderer = new ve(this.theme, this.events, i, this.resolvedLang), this.paginationRenderer = new ke(this.theme, this.events, this.resolvedLang), this.toolbarRenderer = new ye(this.theme, this.events, this.resolvedLang), this.selectionManager = new Se(
|
|
2596
|
+
((a = this.options.selection) == null ? void 0 : a.mode) ?? "none",
|
|
2597
|
+
this.events,
|
|
2598
|
+
(o = this.options.selection) == null ? void 0 : o.preserveOnFilter
|
|
2599
|
+
), this.cellEditor = new we(this.events, this.theme, this.options.editing ?? { enabled: !1 }), this.rootEl = E("katucharts-datatable", this.container), this.applyRootStyling(), this.tableArea = E("katucharts-dt-table-area", this.rootEl), this.columnManager = new A([], this.events), this.wireEvents(), (d = (l = this.options.sorting) == null ? void 0 : l.defaultSort) != null && d.length && (this.sortState = this.options.sorting.defaultSort.map((h) => ({
|
|
2600
|
+
column: h.column,
|
|
2601
|
+
direction: h.direction
|
|
2602
|
+
}))), this.init();
|
|
2603
|
+
}
|
|
2604
|
+
/**
|
|
2605
|
+
* Fold a TanStack-style `initialState` block into the matching option
|
|
2606
|
+
* groups so the starting page size, sort, hidden columns and filters are
|
|
2607
|
+
* honoured on first render.
|
|
2608
|
+
*/
|
|
2609
|
+
applyInitialState() {
|
|
2610
|
+
var t, i;
|
|
2611
|
+
const e = this.options.initialState;
|
|
2612
|
+
if (e && (((t = e.pagination) == null ? void 0 : t.pageSize) != null && (this.options.pagination = { ...this.options.pagination, pageSize: e.pagination.pageSize }), (i = e.sorting) != null && i.length && (this.options.sorting = {
|
|
2613
|
+
...this.options.sorting,
|
|
2614
|
+
defaultSort: e.sorting.map((s) => ({
|
|
2615
|
+
column: s.column ?? s.id,
|
|
2616
|
+
direction: s.direction ?? (s.desc ? "desc" : "asc")
|
|
2617
|
+
}))
|
|
2618
|
+
}), e.columnVisibility && (this.initialVisibility = e.columnVisibility), e.columnFilters)) {
|
|
2619
|
+
const s = Array.isArray(e.columnFilters) ? Object.fromEntries(e.columnFilters.map((r) => [r.id, r.value])) : e.columnFilters;
|
|
2620
|
+
this.filterState = { ...s };
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
/** Apply theme variables, data flags, class hooks and explicit container style to the root. */
|
|
2624
|
+
applyRootStyling() {
|
|
2625
|
+
const e = this.options.classNames;
|
|
2626
|
+
e != null && e.root && (this.rootEl.className += ` ${e.root}`);
|
|
2627
|
+
const t = this.theme.cssVariables(this.options.width, this.options.height);
|
|
2628
|
+
for (const [i, s] of Object.entries(t)) this.rootEl.style.setProperty(i, s);
|
|
2629
|
+
for (const [i, s] of Object.entries(this.theme.rootDataset()))
|
|
2630
|
+
this.rootEl.setAttribute(i, s);
|
|
2631
|
+
this.theme.userContainerStyle && Object.assign(this.rootEl.style, this.theme.userContainerStyle);
|
|
2632
|
+
}
|
|
2633
|
+
init() {
|
|
2634
|
+
var t;
|
|
2635
|
+
if ((t = this.options.serverSide) != null && t.enabled && this.options.serverSide.url) {
|
|
2636
|
+
this.initAsync();
|
|
2637
|
+
return;
|
|
2638
|
+
}
|
|
2639
|
+
const { data: e } = this.dataSource.loadSync();
|
|
2640
|
+
this.initColumns(e), this.renderFull(), this.setupResponsive(), this.bindUserEvents(), this.events.emit("datatable:load", {});
|
|
2641
|
+
}
|
|
2642
|
+
async initAsync() {
|
|
2643
|
+
try {
|
|
2644
|
+
this.showLoading();
|
|
2645
|
+
const { data: e, total: t } = await this.dataSource.load();
|
|
2646
|
+
this.serverTotal = t, this.initColumns(e), this.renderFull(), this.setupResponsive(), this.bindUserEvents(), this.hideLoading(), this.events.emit("datatable:load", {});
|
|
2647
|
+
} catch (e) {
|
|
2648
|
+
this.hideLoading(), console.error("DataTable: initialization failed", e);
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
initColumns(e) {
|
|
2652
|
+
var n;
|
|
2653
|
+
const t = this.options.columns, i = t && t.length > 0 ? t : Z(e), s = this.rootEl.clientWidth || 800, r = ((n = this.options.selection) == null ? void 0 : n.checkbox) === !0 ? 44 : 0;
|
|
2654
|
+
this.columns = re(i, s, e, r);
|
|
2655
|
+
for (const a of this.columns)
|
|
2656
|
+
if ((a.type === "boolean" || a.filterType === "select" || a.filterType === "multiselect" || a.filterType === "faceted") && !a.filterOptions) {
|
|
2657
|
+
const l = [...new Set(e.map((d) => d[a.field]).filter((d) => d != null))];
|
|
2658
|
+
a.filterOptions = l.sort();
|
|
2659
|
+
}
|
|
2660
|
+
if (this.initialVisibility)
|
|
2661
|
+
for (const a of this.columns) {
|
|
2662
|
+
const o = this.initialVisibility[a.id ?? a.field];
|
|
2663
|
+
o !== void 0 && (a._visible = o, a.visible = o);
|
|
2664
|
+
}
|
|
2665
|
+
$(this.columns), this.columnManager = new A(this.columns, this.events), this.columnManager.setSortState(this.sortState);
|
|
2666
|
+
}
|
|
2667
|
+
renderFull() {
|
|
2668
|
+
var i, s, r, n, a, o, l, d;
|
|
2669
|
+
this.rootEl.innerHTML = "", this.tableArea = E("katucharts-dt-table-area", this.rootEl);
|
|
2670
|
+
const e = this.options.classNames;
|
|
2671
|
+
if ((i = this.options.title) != null && i.text) {
|
|
2672
|
+
const h = document.createElement("div");
|
|
2673
|
+
h.className = "katucharts-dt-title", e != null && e.title && (h.className += ` ${e.title}`), h.textContent = this.options.title.text, this.options.title.style && Object.assign(h.style, this.options.title.style), this.rootEl.insertBefore(h, this.tableArea);
|
|
2674
|
+
}
|
|
2675
|
+
if (((s = this.options.toolbar) == null ? void 0 : s.enabled) !== !1) {
|
|
2676
|
+
this.toolbarRenderer.setActiveFilters(Object.keys(this.filterState).length > 0), this.toolbarRenderer.render(
|
|
2677
|
+
this.rootEl,
|
|
2678
|
+
{ ...this.options.toolbar, items: this.resolveToolbarItems() },
|
|
2679
|
+
this.options.search ?? {},
|
|
2680
|
+
this.options.exporting ?? {},
|
|
2681
|
+
this.columns
|
|
2682
|
+
);
|
|
2683
|
+
const h = this.rootEl.querySelector(".katucharts-dt-toolbar");
|
|
2684
|
+
e != null && e.toolbar && (h.className += ` ${e.toolbar}`), this.rootEl.insertBefore(h, this.tableArea);
|
|
2685
|
+
}
|
|
2686
|
+
const t = this.processData();
|
|
2687
|
+
if (this.currentResult = t, this.tableRenderer.render(this.tableArea, this.columns, t, {
|
|
2688
|
+
height: this.computeBodyHeight(),
|
|
2689
|
+
sortingEnabled: ((r = this.options.sorting) == null ? void 0 : r.enabled) !== !1,
|
|
2690
|
+
filteringEnabled: this.isFilteringEnabled(),
|
|
2691
|
+
filterPosition: ((n = this.options.filtering) == null ? void 0 : n.position) ?? "header",
|
|
2692
|
+
resizingEnabled: ((a = this.options.columnResizing) == null ? void 0 : a.enabled) !== !1,
|
|
2693
|
+
selectionMode: ((o = this.options.selection) == null ? void 0 : o.mode) ?? "none",
|
|
2694
|
+
selectionCheckbox: ((l = this.options.selection) == null ? void 0 : l.checkbox) === !0,
|
|
2695
|
+
grouping: this.options.grouping,
|
|
2696
|
+
masterDetail: this.options.masterDetail,
|
|
2697
|
+
treeData: this.options.treeData,
|
|
2698
|
+
virtualScroll: this.options.virtualScroll,
|
|
2699
|
+
headerGroups: this.options.headerGroups,
|
|
2700
|
+
selectedIndices: new Set(this.selectionManager.getSelectedIndices()),
|
|
2701
|
+
noDataText: this.resolvedLang.noData,
|
|
2702
|
+
loadingText: this.resolvedLang.loading,
|
|
2703
|
+
api: this.tableApi,
|
|
2704
|
+
host: this,
|
|
2705
|
+
bodyClass: e == null ? void 0 : e.body,
|
|
2706
|
+
tableClass: e == null ? void 0 : e.table
|
|
2707
|
+
}), ((d = this.options.pagination) == null ? void 0 : d.enabled) !== !1 && !this.isVirtualEnabled()) {
|
|
2708
|
+
const h = this.getPageInfo();
|
|
2709
|
+
this.paginationRenderer.render(this.rootEl, h, this.options.pagination);
|
|
2710
|
+
const u = this.rootEl.querySelector(".katucharts-dt-footer");
|
|
2711
|
+
u && (e != null && e.footer) && (u.className += ` ${e.footer}`);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
isFilteringEnabled() {
|
|
2715
|
+
var e, t;
|
|
2716
|
+
return ((e = this.options.filtering) == null ? void 0 : e.enabled) === !1 ? !1 : ((t = this.options.filtering) == null ? void 0 : t.showFilterRow) !== !1;
|
|
2717
|
+
}
|
|
2718
|
+
/**
|
|
2719
|
+
* Resolve which toolbar items to show. The column-toggle and export buttons
|
|
2720
|
+
* are opt-out via their feature flags (`columnVisibility.enabled` /
|
|
2721
|
+
* `exporting.enabled`), and a "reset filters" item is added automatically
|
|
2722
|
+
* when filtering is active and not opted out.
|
|
2723
|
+
*/
|
|
2724
|
+
resolveToolbarItems() {
|
|
2725
|
+
var s, r, n, a, o;
|
|
2726
|
+
let e = [...((s = this.options.toolbar) == null ? void 0 : s.items) ?? ["search", "columnToggle", "export"]];
|
|
2727
|
+
return ((r = this.options.columnVisibility) == null ? void 0 : r.enabled) === !1 && (e = e.filter((l) => l !== "columnToggle")), ((n = this.options.exporting) == null ? void 0 : n.enabled) === !1 && (e = e.filter((l) => l !== "export")), ((a = this.options.filtering) == null ? void 0 : a.enabled) !== !1 && ((o = this.options.filtering) == null ? void 0 : o.showReset) !== !1 && !e.includes("reset") && e.push("reset"), e;
|
|
2728
|
+
}
|
|
2729
|
+
processData() {
|
|
2730
|
+
var t, i, s, r, n, a, o;
|
|
2731
|
+
const e = {
|
|
2732
|
+
search: this.searchQuery,
|
|
2733
|
+
searchColumns: (t = this.options.search) == null ? void 0 : t.columns,
|
|
2734
|
+
caseSensitive: ((i = this.options.search) == null ? void 0 : i.caseSensitive) ?? !1,
|
|
2735
|
+
filters: this.filterState,
|
|
2736
|
+
sort: this.sortState,
|
|
2737
|
+
groupBy: (s = this.options.grouping) != null && s.enabled ? this.options.grouping.columns ?? [] : [],
|
|
2738
|
+
groupExpanded: this.groupExpanded,
|
|
2739
|
+
page: this.currentPage,
|
|
2740
|
+
pageSize: this.currentPageSize,
|
|
2741
|
+
paginationEnabled: ((r = this.options.pagination) == null ? void 0 : r.enabled) !== !1,
|
|
2742
|
+
scrollTop: 0,
|
|
2743
|
+
viewportHeight: 0,
|
|
2744
|
+
virtualEnabled: this.isVirtualEnabled(),
|
|
2745
|
+
virtualRowHeight: ((n = this.options.virtualScroll) == null ? void 0 : n.rowHeight) ?? this.theme.rowHeight,
|
|
2746
|
+
virtualOverscan: ((a = this.options.virtualScroll) == null ? void 0 : a.overscan) ?? 10,
|
|
2747
|
+
treeData: (o = this.options.treeData) != null && o.enabled ? this.options.treeData : void 0
|
|
2748
|
+
};
|
|
2749
|
+
return this.processor.process(this.dataSource.getData(), this.columns, e);
|
|
2750
|
+
}
|
|
2751
|
+
isVirtualEnabled() {
|
|
2752
|
+
var t, i;
|
|
2753
|
+
if ((t = this.options.virtualScroll) != null && t.enabled) return !0;
|
|
2754
|
+
const e = ((i = this.options.virtualScroll) == null ? void 0 : i.threshold) ?? 1e3;
|
|
2755
|
+
return this.dataSource.getData().length >= e;
|
|
2756
|
+
}
|
|
2757
|
+
computeBodyHeight() {
|
|
2758
|
+
if (this.options.height) {
|
|
2759
|
+
const e = typeof this.options.height == "number" ? this.options.height : void 0;
|
|
2760
|
+
if (e) return Math.max(100, e - 120);
|
|
2761
|
+
}
|
|
2762
|
+
if (this.isVirtualEnabled()) return 400;
|
|
2763
|
+
}
|
|
2764
|
+
wireEvents() {
|
|
2765
|
+
this.events.on("header:sort", ({ field: e, shiftKey: t }) => {
|
|
2766
|
+
this.handleSort(e, t);
|
|
2767
|
+
}), this.events.on("filter:input", ({ field: e, value: t }) => {
|
|
2768
|
+
this.handleFilter(e, t);
|
|
2769
|
+
}), this.events.on("search:change", ({ query: e }) => {
|
|
2770
|
+
this.handleSearch(e);
|
|
2771
|
+
}), this.events.on("page:change", ({ page: e }) => {
|
|
2772
|
+
this.goToPage(e);
|
|
2773
|
+
}), this.events.on("page:sizechange", ({ pageSize: e }) => {
|
|
2774
|
+
this.setPageSize(e);
|
|
2775
|
+
}), this.events.on("row:click", (e) => {
|
|
2776
|
+
var t;
|
|
2777
|
+
((t = this.options.selection) == null ? void 0 : t.mode) !== "none" && this.selectionManager.handleRowClick(e.rowIndex, e.row, e.originalEvent);
|
|
2778
|
+
}), this.events.on("selection:checkbox", ({ rowIndex: e, row: t, checked: i }) => {
|
|
2779
|
+
this.selectionManager.handleCheckboxToggle(e, t, i);
|
|
2780
|
+
}), this.events.on("selection:toggleAll", ({ checked: e }) => {
|
|
2781
|
+
e && this.currentResult ? this.selectionManager.selectAll(this.currentResult.rows) : this.selectionManager.deselectAll(), this.refreshRows();
|
|
2782
|
+
}), this.events.on("selection:change", () => {
|
|
2783
|
+
var t;
|
|
2784
|
+
if (this.refreshing) return;
|
|
2785
|
+
this.refreshRows();
|
|
2786
|
+
const e = this.tableRenderer.getHeaderRenderer();
|
|
2787
|
+
e && e.updateSelectAllCheckbox(
|
|
2788
|
+
this.selectionManager.isAllSelected(((t = this.currentResult) == null ? void 0 : t.totalFiltered) ?? 0),
|
|
2789
|
+
this.selectionManager.isSomeSelected()
|
|
2790
|
+
);
|
|
2791
|
+
}), this.events.on("column:visibility", ({ field: e, visible: t }) => {
|
|
2792
|
+
this.columnManager.toggleColumn(e, t), this.renderFull();
|
|
2793
|
+
}), this.events.on("column:resize", ({ field: e, width: t }) => {
|
|
2794
|
+
this.columnManager.resizeColumn(e, t);
|
|
2795
|
+
}), this.events.on("export:trigger", ({ format: e }) => {
|
|
2796
|
+
var t;
|
|
2797
|
+
switch (e) {
|
|
2798
|
+
case "csv":
|
|
2799
|
+
this.exportCSV();
|
|
2800
|
+
break;
|
|
2801
|
+
case "json":
|
|
2802
|
+
this.exportJSON();
|
|
2803
|
+
break;
|
|
2804
|
+
case "clipboard":
|
|
2805
|
+
this.copyToClipboard();
|
|
2806
|
+
break;
|
|
2807
|
+
case "html":
|
|
2808
|
+
m.exportHTML(this.getExportData(), this.columns, (t = this.options.exporting) == null ? void 0 : t.filename);
|
|
2809
|
+
break;
|
|
2810
|
+
}
|
|
2811
|
+
}), this.events.on("density:change", ({ density: e }) => {
|
|
2812
|
+
this.theme.update({ density: e }), this.rootEl.setAttribute("data-density", e), this.renderFull();
|
|
2813
|
+
}), this.events.on("filters:reset", () => {
|
|
2814
|
+
this.clearFilter(), this.renderFull();
|
|
2815
|
+
}), this.events.on("cell:dblclick", (e) => {
|
|
2816
|
+
var t;
|
|
2817
|
+
(t = this.options.editing) != null && t.enabled && this.cellEditor.startEditing(e.td, e.value, e.row, e.column, e.rowIndex);
|
|
2818
|
+
}), this.events.on("cell:edit:commit", ({ row: e, column: t, oldValue: i, newValue: s, rowIndex: r }) => {
|
|
2819
|
+
this.dataSource.updateCell(r, t, s), this.processor.invalidateAll(), this.refreshRows();
|
|
2820
|
+
}), this.events.on("group:toggle", ({ groupValue: e, groupColumn: t, expanded: i }) => {
|
|
2821
|
+
const s = `${t}:${e}`;
|
|
2822
|
+
this.groupExpanded.set(s, i), this.processor.invalidate("group"), this.refreshRows();
|
|
2823
|
+
}), this.events.on("virtual:scroll", ({ scrollTop: e, viewportHeight: t }) => {
|
|
2824
|
+
this.tableRenderer.updateVirtualPosition(e);
|
|
2825
|
+
}), this.events.on("fullscreen:toggle", () => {
|
|
2826
|
+
var e, t;
|
|
2827
|
+
document.fullscreenElement === this.rootEl ? document.exitFullscreen() : (t = (e = this.rootEl).requestFullscreen) == null || t.call(e);
|
|
2828
|
+
}), this.events.on("row:contextmenu", (e) => {
|
|
2829
|
+
var t, i;
|
|
2830
|
+
(t = this.options.contextMenu) != null && t.enabled && ((i = this.options.contextMenu.items) != null && i.length) && (e.originalEvent.preventDefault(), this.showContextMenu(e));
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
bindUserEvents() {
|
|
2834
|
+
const e = this.options.events;
|
|
2835
|
+
if (!e) return;
|
|
2836
|
+
const t = {
|
|
2837
|
+
load: "datatable:load",
|
|
2838
|
+
dataLoad: "datatable:dataload",
|
|
2839
|
+
rowClick: "row:click",
|
|
2840
|
+
cellClick: "cell:click",
|
|
2841
|
+
rowDblClick: "row:dblclick",
|
|
2842
|
+
selectionChange: "selection:change",
|
|
2843
|
+
sortChange: "sort:change",
|
|
2844
|
+
filterChange: "filter:change",
|
|
2845
|
+
pageChange: "page:changed",
|
|
2846
|
+
columnResize: "column:resize",
|
|
2847
|
+
columnReorder: "column:reorder",
|
|
2848
|
+
cellEdit: "cell:edit:commit",
|
|
2849
|
+
cellEditCancel: "cell:edit:cancel",
|
|
2850
|
+
groupToggle: "group:toggle",
|
|
2851
|
+
searchChange: "search:changed",
|
|
2852
|
+
scroll: "scroll",
|
|
2853
|
+
destroy: "datatable:destroy"
|
|
2854
|
+
};
|
|
2855
|
+
for (const [i, s] of Object.entries(t)) {
|
|
2856
|
+
const r = e[i];
|
|
2857
|
+
r && this.events.on(s, r.bind(this));
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
handleSort(e, t) {
|
|
2861
|
+
var i, s;
|
|
2862
|
+
if (t && ((i = this.options.sorting) != null && i.multiSort)) {
|
|
2863
|
+
const r = this.sortState.findIndex((n) => n.column === e);
|
|
2864
|
+
if (r >= 0) {
|
|
2865
|
+
const n = this.sortState[r].direction;
|
|
2866
|
+
n === "asc" ? this.sortState[r].direction = "desc" : n === "desc" && this.sortState.splice(r, 1);
|
|
2867
|
+
} else
|
|
2868
|
+
this.sortState.push({ column: e, direction: "asc" });
|
|
2869
|
+
} else {
|
|
2870
|
+
const r = this.sortState.length === 1 && this.sortState[0].column === e ? this.sortState[0].direction : null;
|
|
2871
|
+
r === null ? this.sortState = [{ column: e, direction: "asc" }] : r === "asc" ? this.sortState = [{ column: e, direction: "desc" }] : this.sortState = [];
|
|
2872
|
+
}
|
|
2873
|
+
this.columnManager.setSortState(this.sortState), this.processor.invalidate("sort"), this.currentPage = 1, this.refreshRows(), this.events.emit("sort:change", {
|
|
2874
|
+
column: e,
|
|
2875
|
+
direction: ((s = this.sortState.find((r) => r.column === e)) == null ? void 0 : s.direction) ?? null,
|
|
2876
|
+
multiSort: [...this.sortState]
|
|
2877
|
+
});
|
|
2878
|
+
}
|
|
2879
|
+
handleFilter(e, t) {
|
|
2880
|
+
t == null || t === "" ? delete this.filterState[e] : this.filterState[e] = t, this.columnManager.setFilterValue(e, t), this.selectionManager.clearOnFilter(), this.processor.invalidate("filter"), this.currentPage = 1, this.refreshRows(), this.toolbarRenderer.setResetVisible(Object.keys(this.filterState).length > 0), this.events.emit("filter:change", {
|
|
2881
|
+
column: e,
|
|
2882
|
+
value: t,
|
|
2883
|
+
allFilters: { ...this.filterState }
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2886
|
+
handleSearch(e) {
|
|
2887
|
+
this.searchQuery = e, this.selectionManager.clearOnFilter(), this.processor.invalidate("search"), this.currentPage = 1, this.refreshRows(), this.events.emit("search:changed", { query: e });
|
|
2888
|
+
}
|
|
2889
|
+
refreshRows() {
|
|
2890
|
+
var t, i, s;
|
|
2891
|
+
if (this.refreshing) return;
|
|
2892
|
+
this.refreshing = !0;
|
|
2893
|
+
const e = this.processData();
|
|
2894
|
+
this.currentResult = e, this.tableRenderer.updateRows(e, this.columns, {
|
|
2895
|
+
selectionMode: ((t = this.options.selection) == null ? void 0 : t.mode) ?? "none",
|
|
2896
|
+
selectionCheckbox: ((i = this.options.selection) == null ? void 0 : i.checkbox) === !0,
|
|
2897
|
+
grouping: this.options.grouping,
|
|
2898
|
+
masterDetail: this.options.masterDetail,
|
|
2899
|
+
treeData: this.options.treeData,
|
|
2900
|
+
selectedIndices: new Set(this.selectionManager.getSelectedIndices()),
|
|
2901
|
+
noDataText: this.resolvedLang.noData,
|
|
2902
|
+
api: this.tableApi,
|
|
2903
|
+
host: this
|
|
2904
|
+
}), ((s = this.options.pagination) == null ? void 0 : s.enabled) !== !1 && !this.isVirtualEnabled() && this.paginationRenderer.update(this.getPageInfo(), this.options.pagination, this.rootEl), this.refreshing = !1;
|
|
2905
|
+
}
|
|
2906
|
+
getExportData() {
|
|
2907
|
+
var t, i, s;
|
|
2908
|
+
return ((i = (t = this.options.exporting) == null ? void 0 : t.csv) == null ? void 0 : i.onlyVisible) ?? !0 ? ((s = this.currentResult) == null ? void 0 : s.rows.filter((r) => r._type === "data").map((r) => r._data)) ?? [] : this.dataSource.getData();
|
|
2909
|
+
}
|
|
2910
|
+
setupResponsive() {
|
|
2911
|
+
this.options.responsive !== !1 && (this.lastResponsiveWidth = this.rootEl.clientWidth, this.resizeObserver = new ResizeObserver(
|
|
2912
|
+
V(() => {
|
|
2913
|
+
if (this.destroyed) return;
|
|
2914
|
+
const e = this.rootEl.clientWidth;
|
|
2915
|
+
Math.abs(e - this.lastResponsiveWidth) < 2 || (this.lastResponsiveWidth = e, this.columnManager.applyResponsiveHiding(e), this.renderFull());
|
|
2916
|
+
}, 250)
|
|
2917
|
+
), this.resizeObserver.observe(this.container));
|
|
2918
|
+
}
|
|
2919
|
+
showContextMenu(e) {
|
|
2920
|
+
const t = this.options.contextMenu.items, i = document.createElement("div");
|
|
2921
|
+
i.className = "katucharts-dt-context-menu", i.style.left = `${e.originalEvent.clientX}px`, i.style.top = `${e.originalEvent.clientY}px`;
|
|
2922
|
+
for (const r of t) {
|
|
2923
|
+
if (r.separator) {
|
|
2924
|
+
const o = document.createElement("hr");
|
|
2925
|
+
o.className = "katucharts-dt-context-menu-sep", i.appendChild(o);
|
|
2926
|
+
continue;
|
|
2927
|
+
}
|
|
2928
|
+
if (r.visible && !r.visible(e.row, e.column)) continue;
|
|
2929
|
+
const n = document.createElement("div"), a = r.disabled ? r.disabled(e.row, e.column) : !1;
|
|
2930
|
+
n.className = "katucharts-dt-context-menu-item", a && n.classList.add("is-disabled"), n.textContent = r.label, a || n.addEventListener("click", () => {
|
|
2931
|
+
r.action(e.row, e.column, e.originalEvent), R(i);
|
|
2932
|
+
}), i.appendChild(n);
|
|
2933
|
+
}
|
|
2934
|
+
document.body.appendChild(i);
|
|
2935
|
+
const s = (r) => {
|
|
2936
|
+
i.contains(r.target) || (R(i), document.removeEventListener("click", s));
|
|
2937
|
+
};
|
|
2938
|
+
setTimeout(() => document.addEventListener("click", s), 0);
|
|
2939
|
+
}
|
|
2940
|
+
getInternalColumns() {
|
|
2941
|
+
return this.columns;
|
|
2942
|
+
}
|
|
2943
|
+
getRawData() {
|
|
2944
|
+
return this.dataSource.getData();
|
|
2945
|
+
}
|
|
2946
|
+
toggleSort(e, t) {
|
|
2947
|
+
t === void 0 ? this.handleSort(e, !1) : this.sort(e, t ? "desc" : "asc");
|
|
2948
|
+
}
|
|
2949
|
+
setSort(e, t) {
|
|
2950
|
+
this.sort(e, t);
|
|
2951
|
+
}
|
|
2952
|
+
clearColumnSort(e) {
|
|
2953
|
+
this.sortState = this.sortState.filter((t) => t.column !== e), this.columnManager.setSortState(this.sortState), this.processor.invalidate("sort"), this.refreshRows();
|
|
2954
|
+
}
|
|
2955
|
+
getSortDirection(e) {
|
|
2956
|
+
var t;
|
|
2957
|
+
return ((t = this.sortState.find((i) => i.column === e)) == null ? void 0 : t.direction) ?? null;
|
|
2958
|
+
}
|
|
2959
|
+
getFilterValue(e) {
|
|
2960
|
+
return this.filterState[e] ?? null;
|
|
2961
|
+
}
|
|
2962
|
+
setColumnFilter(e, t) {
|
|
2963
|
+
this.handleFilter(e, t);
|
|
2964
|
+
}
|
|
2965
|
+
isColumnVisible(e) {
|
|
2966
|
+
var t;
|
|
2967
|
+
return ((t = this.columns.find((i) => i.field === e || i.id === e)) == null ? void 0 : t._visible) ?? !0;
|
|
2968
|
+
}
|
|
2969
|
+
setColumnVisible(e, t) {
|
|
2970
|
+
this.columnManager.toggleColumn(e, t), this.renderFull();
|
|
2971
|
+
}
|
|
2972
|
+
isRowSelected(e) {
|
|
2973
|
+
return this.selectionManager.isSelected(e);
|
|
2974
|
+
}
|
|
2975
|
+
setRowSelected(e, t) {
|
|
2976
|
+
t ? this.selectRow(e) : this.deselectRow(e);
|
|
2977
|
+
}
|
|
2978
|
+
isAllPageSelected() {
|
|
2979
|
+
var e;
|
|
2980
|
+
return this.selectionManager.isAllSelected(((e = this.currentResult) == null ? void 0 : e.totalFiltered) ?? 0);
|
|
2981
|
+
}
|
|
2982
|
+
isSomePageSelected() {
|
|
2983
|
+
return this.selectionManager.isSomeSelected();
|
|
2984
|
+
}
|
|
2985
|
+
toggleAllPageSelected(e) {
|
|
2986
|
+
e ? this.selectAll() : this.deselectAll();
|
|
2987
|
+
}
|
|
2988
|
+
setPageSizeValue(e) {
|
|
2989
|
+
this.setPageSize(e);
|
|
2990
|
+
}
|
|
2991
|
+
/** The TanStack Table-compatible facade for use in custom integrations. */
|
|
2992
|
+
getTableApi() {
|
|
2993
|
+
return this.tableApi;
|
|
2994
|
+
}
|
|
2995
|
+
/**
|
|
2996
|
+
* Replace all table data. Columns are re-detected if not explicitly set.
|
|
2997
|
+
* Use this to feed data from any source (your own fetch, websocket, etc.)
|
|
2998
|
+
*/
|
|
2999
|
+
setData(e) {
|
|
3000
|
+
this.dataSource.setData(e), this.initColumns(e), this.processor.invalidateAll(), this.currentPage = 1, this.renderFull(), this.events.emit("datatable:dataload", { data: e });
|
|
3001
|
+
}
|
|
3002
|
+
/**
|
|
3003
|
+
* Load data from a URL. Fetches JSON and calls setData().
|
|
3004
|
+
* Supports GET/POST, custom headers, and response mapping.
|
|
3005
|
+
*/
|
|
3006
|
+
async loadFromUrl(e, t) {
|
|
3007
|
+
this.showLoading();
|
|
3008
|
+
try {
|
|
3009
|
+
const i = (t == null ? void 0 : t.method) ?? "GET", s = {
|
|
3010
|
+
"Content-Type": "application/json",
|
|
3011
|
+
...(t == null ? void 0 : t.headers) ?? {}
|
|
3012
|
+
}, r = { method: i, headers: s };
|
|
3013
|
+
i === "POST" && (t != null && t.body) && (r.body = JSON.stringify(t.body));
|
|
3014
|
+
const n = await fetch(e, r);
|
|
3015
|
+
if (!n.ok) throw new Error(`HTTP ${n.status}`);
|
|
3016
|
+
const a = await n.json();
|
|
3017
|
+
let o, l;
|
|
3018
|
+
if (t != null && t.responseMapper) {
|
|
3019
|
+
const d = t.responseMapper(a);
|
|
3020
|
+
o = d.data, l = d.total;
|
|
3021
|
+
} else Array.isArray(a) ? o = a : a.data && Array.isArray(a.data) ? (o = a.data, l = a.total ?? a.count ?? a.data.length) : a.results && Array.isArray(a.results) ? (o = a.results, l = a.total ?? a.count ?? a.results.length) : o = [a];
|
|
3022
|
+
l !== void 0 && (this.serverTotal = l), this.setData(o), this.hideLoading();
|
|
3023
|
+
} catch (i) {
|
|
3024
|
+
this.hideLoading(), console.error("DataTable: loadFromUrl failed", i), this.events.emit("datatable:error", { error: i, url: e });
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
getData() {
|
|
3028
|
+
return this.dataSource.getData();
|
|
3029
|
+
}
|
|
3030
|
+
getFilteredData() {
|
|
3031
|
+
var e;
|
|
3032
|
+
return ((e = this.currentResult) == null ? void 0 : e.rows.filter((t) => t._type === "data").map((t) => t._data)) ?? [];
|
|
3033
|
+
}
|
|
3034
|
+
getSelectedData() {
|
|
3035
|
+
return this.selectionManager.getSelectedData(this.dataSource.getData());
|
|
3036
|
+
}
|
|
3037
|
+
addRow(e, t) {
|
|
3038
|
+
this.dataSource.addRow(e, t), this.processor.invalidateAll(), this.refreshRows();
|
|
3039
|
+
}
|
|
3040
|
+
removeRow(e) {
|
|
3041
|
+
if (typeof e == "function") {
|
|
3042
|
+
const t = this.dataSource.getData();
|
|
3043
|
+
for (let i = t.length - 1; i >= 0; i--)
|
|
3044
|
+
e(t[i]) && this.dataSource.removeRow(i);
|
|
3045
|
+
} else
|
|
3046
|
+
this.dataSource.removeRow(e);
|
|
3047
|
+
this.processor.invalidateAll(), this.refreshRows();
|
|
3048
|
+
}
|
|
3049
|
+
updateRow(e, t) {
|
|
3050
|
+
this.dataSource.updateRow(e, t), this.processor.invalidateAll(), this.refreshRows();
|
|
3051
|
+
}
|
|
3052
|
+
updateCell(e, t, i) {
|
|
3053
|
+
this.dataSource.updateCell(e, t, i), this.processor.invalidateAll(), this.refreshRows();
|
|
3054
|
+
}
|
|
3055
|
+
getRow(e) {
|
|
3056
|
+
return this.dataSource.getData()[e];
|
|
3057
|
+
}
|
|
3058
|
+
getRowCount() {
|
|
3059
|
+
return this.dataSource.getData().length;
|
|
3060
|
+
}
|
|
3061
|
+
getFilteredRowCount() {
|
|
3062
|
+
var e;
|
|
3063
|
+
return ((e = this.currentResult) == null ? void 0 : e.totalFiltered) ?? 0;
|
|
3064
|
+
}
|
|
3065
|
+
getColumns() {
|
|
3066
|
+
return this.columns.map((e) => ({
|
|
3067
|
+
field: e.field,
|
|
3068
|
+
title: e.title,
|
|
3069
|
+
type: e.type,
|
|
3070
|
+
width: e._computedWidth,
|
|
3071
|
+
visible: e._visible,
|
|
3072
|
+
pinned: e.pinned,
|
|
3073
|
+
align: e.align
|
|
3074
|
+
}));
|
|
3075
|
+
}
|
|
3076
|
+
updateColumn(e, t) {
|
|
3077
|
+
this.columnManager.updateColumn(e, t), this.renderFull();
|
|
3078
|
+
}
|
|
3079
|
+
showColumn(e) {
|
|
3080
|
+
this.columnManager.showColumn(e), this.renderFull();
|
|
3081
|
+
}
|
|
3082
|
+
hideColumn(e) {
|
|
3083
|
+
this.columnManager.hideColumn(e), this.renderFull();
|
|
3084
|
+
}
|
|
3085
|
+
pinColumn(e, t) {
|
|
3086
|
+
this.columnManager.pinColumn(e, t), this.renderFull();
|
|
3087
|
+
}
|
|
3088
|
+
sort(e, t) {
|
|
3089
|
+
if (t)
|
|
3090
|
+
this.sortState = [{ column: e, direction: t }];
|
|
3091
|
+
else {
|
|
3092
|
+
this.handleSort(e, !1);
|
|
3093
|
+
return;
|
|
3094
|
+
}
|
|
3095
|
+
this.columnManager.setSortState(this.sortState), this.processor.invalidate("sort"), this.currentPage = 1, this.refreshRows();
|
|
3096
|
+
}
|
|
3097
|
+
clearSort() {
|
|
3098
|
+
this.sortState = [], this.columnManager.setSortState([]), this.processor.invalidate("sort"), this.refreshRows();
|
|
3099
|
+
}
|
|
3100
|
+
getSortState() {
|
|
3101
|
+
return [...this.sortState];
|
|
3102
|
+
}
|
|
3103
|
+
setFilter(e, t) {
|
|
3104
|
+
this.handleFilter(e, t);
|
|
3105
|
+
}
|
|
3106
|
+
clearFilter(e) {
|
|
3107
|
+
e ? (delete this.filterState[e], this.columnManager.setFilterValue(e, null)) : (this.filterState = {}, this.columnManager.clearFilters()), this.processor.invalidate("filter"), this.currentPage = 1, this.refreshRows(), this.toolbarRenderer.setResetVisible(Object.keys(this.filterState).length > 0);
|
|
3108
|
+
}
|
|
3109
|
+
getFilterState() {
|
|
3110
|
+
return { ...this.filterState };
|
|
3111
|
+
}
|
|
3112
|
+
search(e) {
|
|
3113
|
+
this.handleSearch(e), this.toolbarRenderer.getSearchRenderer().setValue(e);
|
|
3114
|
+
}
|
|
3115
|
+
clearSearch() {
|
|
3116
|
+
this.search("");
|
|
3117
|
+
}
|
|
3118
|
+
goToPage(e) {
|
|
3119
|
+
const t = this.getPageInfo();
|
|
3120
|
+
this.currentPage = Math.max(1, Math.min(e, t.totalPages)), this.processor.invalidate("paginate"), this.refreshRows(), this.events.emit("page:changed", {
|
|
3121
|
+
page: this.currentPage,
|
|
3122
|
+
pageSize: this.currentPageSize,
|
|
3123
|
+
totalPages: t.totalPages
|
|
3124
|
+
});
|
|
3125
|
+
}
|
|
3126
|
+
setPageSize(e) {
|
|
3127
|
+
this.currentPageSize = e, this.currentPage = 1, this.processor.invalidateAll(), this.refreshRows();
|
|
3128
|
+
}
|
|
3129
|
+
getPageInfo() {
|
|
3130
|
+
var r;
|
|
3131
|
+
const e = ((r = this.currentResult) == null ? void 0 : r.totalFiltered) ?? 0, t = Math.max(1, Math.ceil(e / this.currentPageSize)), i = e > 0 ? (this.currentPage - 1) * this.currentPageSize + 1 : 0, s = Math.min(this.currentPage * this.currentPageSize, e);
|
|
3132
|
+
return {
|
|
3133
|
+
page: this.currentPage,
|
|
3134
|
+
pageSize: this.currentPageSize,
|
|
3135
|
+
totalPages: t,
|
|
3136
|
+
totalRows: e,
|
|
3137
|
+
from: i,
|
|
3138
|
+
to: s
|
|
3139
|
+
};
|
|
3140
|
+
}
|
|
3141
|
+
selectRow(e) {
|
|
3142
|
+
this.selectionManager.selectRow(e), this.refreshRows();
|
|
3143
|
+
}
|
|
3144
|
+
deselectRow(e) {
|
|
3145
|
+
this.selectionManager.deselectRow(e), this.refreshRows();
|
|
3146
|
+
}
|
|
3147
|
+
selectAll() {
|
|
3148
|
+
this.currentResult && (this.selectionManager.selectAll(this.currentResult.rows), this.refreshRows());
|
|
3149
|
+
}
|
|
3150
|
+
deselectAll() {
|
|
3151
|
+
this.selectionManager.deselectAll(), this.refreshRows();
|
|
3152
|
+
}
|
|
3153
|
+
getSelectedRows() {
|
|
3154
|
+
return this.selectionManager.getSelectedData(this.dataSource.getData());
|
|
3155
|
+
}
|
|
3156
|
+
getSelectedIndices() {
|
|
3157
|
+
return this.selectionManager.getSelectedIndices();
|
|
3158
|
+
}
|
|
3159
|
+
groupBy(e) {
|
|
3160
|
+
this.options.grouping = { ...this.options.grouping, enabled: !0, columns: e }, this.processor.invalidateAll(), this.renderFull();
|
|
3161
|
+
}
|
|
3162
|
+
ungroup() {
|
|
3163
|
+
this.options.grouping = { ...this.options.grouping, enabled: !1, columns: [] }, this.groupExpanded.clear(), this.processor.invalidateAll(), this.renderFull();
|
|
3164
|
+
}
|
|
3165
|
+
expandGroup(e) {
|
|
3166
|
+
for (const [t] of this.groupExpanded)
|
|
3167
|
+
t.endsWith(`:${e}`) && this.groupExpanded.set(t, !0);
|
|
3168
|
+
this.processor.invalidate("group"), this.refreshRows();
|
|
3169
|
+
}
|
|
3170
|
+
collapseGroup(e) {
|
|
3171
|
+
for (const [t] of this.groupExpanded)
|
|
3172
|
+
t.endsWith(`:${e}`) && this.groupExpanded.set(t, !1);
|
|
3173
|
+
this.processor.invalidate("group"), this.refreshRows();
|
|
3174
|
+
}
|
|
3175
|
+
expandAll() {
|
|
3176
|
+
for (const [e] of this.groupExpanded)
|
|
3177
|
+
this.groupExpanded.set(e, !0);
|
|
3178
|
+
this.processor.invalidate("group"), this.refreshRows();
|
|
3179
|
+
}
|
|
3180
|
+
collapseAll() {
|
|
3181
|
+
for (const [e] of this.groupExpanded)
|
|
3182
|
+
this.groupExpanded.set(e, !1);
|
|
3183
|
+
this.processor.invalidate("group"), this.refreshRows();
|
|
3184
|
+
}
|
|
3185
|
+
exportCSV(e) {
|
|
3186
|
+
var t, i;
|
|
3187
|
+
m.exportCSV(this.getExportData(), this.columns, { ...(t = this.options.exporting) == null ? void 0 : t.csv, ...e }, (i = this.options.exporting) == null ? void 0 : i.filename), this.events.emit("export:csv");
|
|
3188
|
+
}
|
|
3189
|
+
exportJSON(e) {
|
|
3190
|
+
var t, i;
|
|
3191
|
+
m.exportJSON(this.getExportData(), this.columns, { ...(t = this.options.exporting) == null ? void 0 : t.json, ...e }, (i = this.options.exporting) == null ? void 0 : i.filename), this.events.emit("export:json");
|
|
3192
|
+
}
|
|
3193
|
+
copyToClipboard() {
|
|
3194
|
+
m.copyToClipboard(this.getExportData(), this.columns), this.events.emit("export:clipboard");
|
|
3195
|
+
}
|
|
3196
|
+
getCSV() {
|
|
3197
|
+
var e;
|
|
3198
|
+
return m.toCSV(this.getExportData(), this.columns, (e = this.options.exporting) == null ? void 0 : e.csv);
|
|
3199
|
+
}
|
|
3200
|
+
getJSON() {
|
|
3201
|
+
var e;
|
|
3202
|
+
return m.toJSON(this.getExportData(), this.columns, (e = this.options.exporting) == null ? void 0 : e.json);
|
|
3203
|
+
}
|
|
3204
|
+
getHTML() {
|
|
3205
|
+
return m.toHTML(this.getExportData(), this.columns);
|
|
3206
|
+
}
|
|
3207
|
+
update(e) {
|
|
3208
|
+
this.options = D(this.options, e), (e.locale !== void 0 || e.lang !== void 0) && (this.resolvedLang = I({ locale: this.options.locale, langOverrides: this.options.lang }), this.tableRenderer.setLang(this.resolvedLang), this.paginationRenderer.setLang(this.resolvedLang), this.toolbarRenderer.setLang(this.resolvedLang)), e.style && this.theme.update(e.style), e.data && (this.dataSource.setData(e.data), this.initColumns(e.data)), this.processor.invalidateAll(), this.renderFull();
|
|
3209
|
+
}
|
|
3210
|
+
/** Switch the active locale at runtime and redraw. Existing `lang` overrides are kept. */
|
|
3211
|
+
setLocale(e) {
|
|
3212
|
+
this.update({ locale: e });
|
|
3213
|
+
}
|
|
3214
|
+
redraw() {
|
|
3215
|
+
this.processor.invalidateAll(), this.renderFull();
|
|
3216
|
+
}
|
|
3217
|
+
showLoading(e) {
|
|
3218
|
+
this.tableRenderer.showLoading(e);
|
|
3219
|
+
}
|
|
3220
|
+
hideLoading() {
|
|
3221
|
+
this.tableRenderer.hideLoading();
|
|
3222
|
+
}
|
|
3223
|
+
scrollToRow(e) {
|
|
3224
|
+
this.tableRenderer.scrollToRow(e);
|
|
3225
|
+
}
|
|
3226
|
+
trigger(e, t) {
|
|
3227
|
+
switch (e) {
|
|
3228
|
+
case "sort":
|
|
3229
|
+
t != null && t.column && this.sort(t.column, t.direction);
|
|
3230
|
+
break;
|
|
3231
|
+
case "filter":
|
|
3232
|
+
t != null && t.column && this.setFilter(t.column, t.value);
|
|
3233
|
+
break;
|
|
3234
|
+
case "clearFilters":
|
|
3235
|
+
this.clearFilter();
|
|
3236
|
+
break;
|
|
3237
|
+
case "search":
|
|
3238
|
+
this.search((t == null ? void 0 : t.query) ?? "");
|
|
3239
|
+
break;
|
|
3240
|
+
case "clearSearch":
|
|
3241
|
+
this.clearSearch();
|
|
3242
|
+
break;
|
|
3243
|
+
case "goToPage":
|
|
3244
|
+
t != null && t.page && this.goToPage(t.page);
|
|
3245
|
+
break;
|
|
3246
|
+
case "nextPage":
|
|
3247
|
+
this.goToPage(this.currentPage + 1);
|
|
3248
|
+
break;
|
|
3249
|
+
case "prevPage":
|
|
3250
|
+
this.goToPage(this.currentPage - 1);
|
|
3251
|
+
break;
|
|
3252
|
+
case "firstPage":
|
|
3253
|
+
this.goToPage(1);
|
|
3254
|
+
break;
|
|
3255
|
+
case "lastPage":
|
|
3256
|
+
this.goToPage(this.getPageInfo().totalPages);
|
|
3257
|
+
break;
|
|
3258
|
+
case "setPageSize":
|
|
3259
|
+
t != null && t.size && this.setPageSize(t.size);
|
|
3260
|
+
break;
|
|
3261
|
+
case "selectAll":
|
|
3262
|
+
this.selectAll();
|
|
3263
|
+
break;
|
|
3264
|
+
case "deselectAll":
|
|
3265
|
+
this.deselectAll();
|
|
3266
|
+
break;
|
|
3267
|
+
case "selectRow":
|
|
3268
|
+
(t == null ? void 0 : t.index) != null && this.selectRow(t.index);
|
|
3269
|
+
break;
|
|
3270
|
+
case "deselectRow":
|
|
3271
|
+
(t == null ? void 0 : t.index) != null && this.deselectRow(t.index);
|
|
3272
|
+
break;
|
|
3273
|
+
case "addRow":
|
|
3274
|
+
t != null && t.row && this.addRow(t.row, t.index);
|
|
3275
|
+
break;
|
|
3276
|
+
case "removeRow":
|
|
3277
|
+
(t == null ? void 0 : t.index) != null && this.removeRow(t.index);
|
|
3278
|
+
break;
|
|
3279
|
+
case "updateRow":
|
|
3280
|
+
(t == null ? void 0 : t.index) != null && (t != null && t.data) && this.updateRow(t.index, t.data);
|
|
3281
|
+
break;
|
|
3282
|
+
case "updateCell":
|
|
3283
|
+
(t == null ? void 0 : t.rowIndex) != null && (t != null && t.column) && this.updateCell(t.rowIndex, t.column, t.value);
|
|
3284
|
+
break;
|
|
3285
|
+
case "exportCSV":
|
|
3286
|
+
this.exportCSV(t);
|
|
3287
|
+
break;
|
|
3288
|
+
case "exportJSON":
|
|
3289
|
+
this.exportJSON(t);
|
|
3290
|
+
break;
|
|
3291
|
+
case "copyToClipboard":
|
|
3292
|
+
this.copyToClipboard();
|
|
3293
|
+
break;
|
|
3294
|
+
case "showColumn":
|
|
3295
|
+
t != null && t.field && this.showColumn(t.field);
|
|
3296
|
+
break;
|
|
3297
|
+
case "hideColumn":
|
|
3298
|
+
t != null && t.field && this.hideColumn(t.field);
|
|
3299
|
+
break;
|
|
3300
|
+
case "pinColumn":
|
|
3301
|
+
t != null && t.field && this.pinColumn(t.field, t.direction ?? null);
|
|
3302
|
+
break;
|
|
3303
|
+
case "groupBy":
|
|
3304
|
+
t != null && t.columns && this.groupBy(t.columns);
|
|
3305
|
+
break;
|
|
3306
|
+
case "ungroup":
|
|
3307
|
+
this.ungroup();
|
|
3308
|
+
break;
|
|
3309
|
+
case "expandAll":
|
|
3310
|
+
this.expandAll();
|
|
3311
|
+
break;
|
|
3312
|
+
case "collapseAll":
|
|
3313
|
+
this.collapseAll();
|
|
3314
|
+
break;
|
|
3315
|
+
case "showLoading":
|
|
3316
|
+
this.showLoading(t == null ? void 0 : t.text);
|
|
3317
|
+
break;
|
|
3318
|
+
case "hideLoading":
|
|
3319
|
+
this.hideLoading();
|
|
3320
|
+
break;
|
|
3321
|
+
case "scrollToRow":
|
|
3322
|
+
(t == null ? void 0 : t.index) != null && this.scrollToRow(t.index);
|
|
3323
|
+
break;
|
|
3324
|
+
case "redraw":
|
|
3325
|
+
this.redraw();
|
|
3326
|
+
break;
|
|
3327
|
+
case "setDensity":
|
|
3328
|
+
t != null && t.density && (this.theme.update({ density: t.density }), this.renderFull());
|
|
3329
|
+
break;
|
|
3330
|
+
case "setData":
|
|
3331
|
+
t != null && t.data && this.setData(t.data);
|
|
3332
|
+
break;
|
|
3333
|
+
case "loadFromUrl":
|
|
3334
|
+
t != null && t.url && this.loadFromUrl(t.url, t);
|
|
3335
|
+
break;
|
|
3336
|
+
default:
|
|
3337
|
+
this.events.emit(`action:${e}`, t);
|
|
3338
|
+
break;
|
|
3339
|
+
}
|
|
3340
|
+
return this;
|
|
3341
|
+
}
|
|
3342
|
+
on(e, t) {
|
|
3343
|
+
return this.events.on(e, t), this;
|
|
3344
|
+
}
|
|
3345
|
+
off(e, t) {
|
|
3346
|
+
return this.events.off(e, t), this;
|
|
3347
|
+
}
|
|
3348
|
+
destroy() {
|
|
3349
|
+
this.destroyed = !0, this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.cellEditor.destroy(), this.selectionManager.destroy(), this.tableRenderer.destroy(), this.paginationRenderer.destroy(), this.toolbarRenderer.destroy(), this.columnManager.destroy(), this.events.emit("datatable:destroy", {}), this.events.removeAllListeners(), R(this.rootEl);
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
const Le = {
|
|
3353
|
+
name: "datatable",
|
|
3354
|
+
init(c) {
|
|
3355
|
+
c.dataTable = (e, t) => new O(e, t), c._DataTable = O;
|
|
3356
|
+
}
|
|
3357
|
+
};
|
|
3358
|
+
export {
|
|
3359
|
+
O as DataTable,
|
|
3360
|
+
Le as DataTableModule,
|
|
3361
|
+
Te as registerLocale,
|
|
3362
|
+
I as resolveLocale
|
|
3363
|
+
};
|