@astryx-vue/core 0.1.0 → 0.1.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/README.md +1 -1
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/Calendar/index.js +1 -1
- package/dist/{Calendar-DpYFXwgb.js → Calendar-BEyrkUtr.js} +2 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-Bfd-YPAK.js → Chat-CO3mCs9A.js} +2 -2
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxList/index.d.ts +2 -0
- package/dist/CheckboxList/index.js +2 -0
- package/dist/CheckboxList-BL2sDOWK.js +174 -0
- package/dist/Citation/index.js +1 -1
- package/dist/{Citation-DaDd1teb.js → Citation-BqwJvw7o.js} +2 -2
- package/dist/Code/index.js +1 -1
- package/dist/{CodeBlock-CK-NWM_1.js → CodeBlock-BQdooQy2.js} +1 -1
- package/dist/Collapsible/index.js +1 -1
- package/dist/{Collapsible-ByXCGhT8.js → Collapsible-BYg9soTk.js} +1 -1
- package/dist/ContextMenu/index.d.ts +1 -1
- package/dist/ContextMenu/index.js +1 -1
- package/dist/{ContextMenu-BJh99Exj.js → ContextMenu-dA-ppaRQ.js} +284 -12
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-zJAdXByM.js → DateInput-BOIb0zAp.js} +18 -10
- package/dist/DateRangeInput/index.d.ts +2 -0
- package/dist/DateRangeInput/index.js +2 -0
- package/dist/DateRangeInput-DLcbgUBi.js +385 -0
- package/dist/DateTimeInput/index.d.ts +2 -0
- package/dist/DateTimeInput/index.js +2 -0
- package/dist/DateTimeInput-RitYX_Yx.js +196 -0
- package/dist/Divider/index.d.ts +1 -1
- package/dist/DropdownMenu/index.d.ts +1 -1
- package/dist/DropdownMenu/index.js +1 -1
- package/dist/{DropdownMenu-C3j2zaEn.js → DropdownMenu-B0gogrvG.js} +2 -2
- package/dist/Field/index.d.ts +2 -2
- package/dist/Field/index.js +1 -2
- package/dist/FieldStatus/index.d.ts +2 -0
- package/dist/FieldStatus/index.js +2 -0
- package/dist/FileInput/index.d.ts +2 -0
- package/dist/FileInput/index.js +2 -0
- package/dist/FileInput-CYvEV503.js +238 -0
- package/dist/{Icon-B6qNgBP9.js → Icon-5MdZQ18k.js} +10 -2
- package/dist/List/index.d.ts +1 -1
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.js +1 -1
- package/dist/{Markdown-DyKIwAL_.js → Markdown-Dnlp8cVx.js} +2 -2
- package/dist/MetadataList/index.d.ts +2 -0
- package/dist/MetadataList/index.js +2 -0
- package/dist/MetadataList-DIsqS1Qb.js +124 -0
- package/dist/MobileNav/index.js +1 -1
- package/dist/{MobileNavToggle-BK2iRJF-.js → MobileNavToggle-aUZiDwHm.js} +1 -1
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-BjUsVWWk.js → MoreMenu-BXL6Dqsu.js} +2 -2
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-CKTbTj1A.js → MultiSelector-Bh8or2S6.js} +2 -2
- package/dist/NavItem/index.d.ts +1 -1
- package/dist/NavMenu/index.d.ts +1 -1
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-DU3_rw7z.js → NumberInput-C3S-4dIu.js} +1 -1
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/OverflowList/index.js +1 -1
- package/dist/{OverflowList-B2T5UtiQ.js → OverflowList-Kr4iJrNV.js} +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-qCgNwwhr.js → Pagination-BRStpeSB.js} +2 -2
- package/dist/Popover/index.d.ts +1 -1
- package/dist/Radio/index.d.ts +2 -2
- package/dist/Radio/index.js +2 -2
- package/dist/{Radio-BioQfwHQ.js → RadioGroup-DS6oTV_j.js} +21 -88
- package/dist/RadioList/index.d.ts +2 -0
- package/dist/RadioList/index.js +2 -0
- package/dist/RadioList-pwr93I-z.js +122 -0
- package/dist/SegmentedControl/index.d.ts +1 -1
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.js +1 -1
- package/dist/{Selector-C6sPJMtH.js → Selector-DvEUIVEC.js} +1 -1
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +1 -1
- package/dist/{SideNav-D9lnn-sM.js → SideNav-B7LX4RcP.js} +2 -2
- package/dist/Stack/index.d.ts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Table/index.d.ts +2 -0
- package/dist/Table/index.js +2 -0
- package/dist/Table-D5zWaITo.js +967 -0
- package/dist/Text/index.d.ts +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/Thumbnail/index.d.ts +2 -0
- package/dist/Thumbnail/index.js +2 -0
- package/dist/Thumbnail-DMOgWncm.js +163 -0
- package/dist/TimeField-DeQ1ukHl.js +214 -0
- package/dist/TimeInput/index.d.ts +2 -0
- package/dist/TimeInput/index.js +2 -0
- package/dist/TimeInput-jb1nLqZk.js +121 -0
- package/dist/Timestamp/index.d.ts +2 -0
- package/dist/Timestamp/index.js +2 -0
- package/dist/Timestamp-DrWwVQBL.js +465 -0
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/Token/index.d.ts +1 -1
- package/dist/Token/index.js +1 -1
- package/dist/{Token-Ctf9jekS.js → Token-CV2J94bn.js} +1 -1
- package/dist/Tokenizer/index.d.ts +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-D5MPgau0.js → Tokenizer-DF9r4hTW.js} +2 -2
- package/dist/Toolbar/index.d.ts +1 -1
- package/dist/TopNav/index.d.ts +1 -1
- package/dist/TopNav/index.js +1 -1
- package/dist/{TopNav-CjbMCbkC.js → TopNav-BH_s3uap.js} +3 -3
- package/dist/TreeList/index.d.ts +2 -0
- package/dist/TreeList/index.js +2 -0
- package/dist/TreeList-D9cR-w7r.js +506 -0
- package/dist/Typeahead/index.d.ts +1 -1
- package/dist/Typeahead/index.js +1 -1
- package/dist/{Typeahead-BMoU3hfx.js → Typeahead-s4DC1Qem.js} +2 -2
- package/dist/composables/index.d.ts +2 -2
- package/dist/composables/index.js +4 -1
- package/dist/{locale-56lkR7OK.js → context-BshXcNYX.js} +183 -18
- package/dist/{index-DjOdQv5B.d.ts → index--dh0s8Li.d.ts} +1 -1
- package/dist/{index-Cdi82rTW.d.ts → index-12ObcW99.d.ts} +6 -2
- package/dist/{index-JeZ0YTyd.d.ts → index-5R_pi3eT.d.ts} +2 -2
- package/dist/{index-Cc2HGODZ.d.ts → index-AkMWQ97a.d.ts} +3 -3
- package/dist/{index-CvLlWLIZ.d.ts → index-B4OOtNP8.d.ts} +4 -4
- package/dist/{index-_1-uvr27.d.ts → index-B8MbfMwV.d.ts} +1 -1
- package/dist/{index-MPcg1Pm4.d.ts → index-BKr7yvVv.d.ts} +1 -1
- package/dist/{index-CxspvLBl.d.ts → index-Bc0dgVM5.d.ts} +5 -5
- package/dist/{index-4FM5lQdV.d.ts → index-BlWLperN.d.ts} +1 -1
- package/dist/{index-DBcbfStA.d.ts → index-BnNh5Iml.d.ts} +84 -1
- package/dist/{index-Cp0NlzQv.d.ts → index-Bovw9_8d.d.ts} +1 -1
- package/dist/{index-CnVbMebA.d.ts → index-Bqb_Fyju.d.ts} +3 -3
- package/dist/{index-HV6W3xCx.d.ts → index-Byar3h1e.d.ts} +1 -1
- package/dist/{index-BQuN_dWR.d.ts → index-BzqRns96.d.ts} +1 -1
- package/dist/{index-C0S2Xzoi.d.ts → index-CNcQmDrK.d.ts} +93 -0
- package/dist/{index-CaHXYQ_E.d.ts → index-CQ9F1f_F.d.ts} +535 -137
- package/dist/index-CR6sUmRT.d.ts +356 -0
- package/dist/index-C_2Z65Rp.d.ts +67 -0
- package/dist/{index-Dw21t7Uf.d.ts → index-CsJpQElv.d.ts} +1 -1
- package/dist/index-CtlkhQ55.d.ts +36 -0
- package/dist/{index-C8NW9xre.d.ts → index-D3V7yRUP.d.ts} +7 -7
- package/dist/index-Da7Jm8Ht.d.ts +10 -0
- package/dist/{index-CPhDtlv-.d.ts → index-FEy8qFSD.d.ts} +3 -3
- package/dist/{index-BeJqhW4l.d.ts → index-Q4gqBSIZ.d.ts} +2 -2
- package/dist/{index-Cz9ZHVf6.d.ts → index-g03bmR4K.d.ts} +3 -3
- package/dist/{index-COxy6LEW.d.ts → index-gW0HW02U.d.ts} +1 -1
- package/dist/{index-BQa836Vz.d.ts → index-iBLzInje.d.ts} +6 -14
- package/dist/index-utZGF4GR.d.ts +79 -0
- package/dist/index.d.ts +54 -49
- package/dist/index.js +86 -64
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +2 -1
- package/dist/locale-Cpk_nrLA.js +18 -0
- package/dist/useFileSelection-BPtaegqK.js +58 -0
- package/dist/useMonthGrid-CmJsZTcB.js +139 -0
- package/dist/useTimeValue-DWk6oTAZ.js +113 -0
- package/package.json +49 -1
- package/styles/bordered-control.css +87 -0
- package/styles/calendar.css +8 -2
- package/styles/checkbox-list.css +15 -0
- package/styles/date-range-input.css +163 -0
- package/styles/date-time-input.css +40 -0
- package/styles/field.css +2 -3
- package/styles/file-input.css +87 -0
- package/styles/icon.css +32 -0
- package/styles/metadata-list.css +107 -0
- package/styles/number-input.css +6 -0
- package/styles/radio.css +32 -0
- package/styles/selector.css +10 -0
- package/styles/table.css +256 -0
- package/styles/text-area.css +6 -1
- package/styles/text-input.css +6 -0
- package/styles/thumbnail.css +151 -0
- package/styles/time-input.css +51 -0
- package/styles/timestamp.css +93 -0
- package/styles/tree-list.css +229 -0
- package/styles.css +11 -0
|
@@ -0,0 +1,967 @@
|
|
|
1
|
+
import { t as _sfc_main$10 } from "./Button-DrqeomlE.js";
|
|
2
|
+
import { t as _sfc_main$11 } from "./IconButton-BNQuz9W_.js";
|
|
3
|
+
import { a as useAstryxMessages } from "./context-BshXcNYX.js";
|
|
4
|
+
import { t as _sfc_main$12 } from "./Icon-5MdZQ18k.js";
|
|
5
|
+
import { t as _sfc_main$13 } from "./CheckboxInput-C86o3XoG.js";
|
|
6
|
+
import { t as _sfc_main$14 } from "./Popover-Crhk9PNP.js";
|
|
7
|
+
import { t as _sfc_main$15 } from "./Pagination-BRStpeSB.js";
|
|
8
|
+
import { t as _sfc_main$16 } from "./Selector-DvEUIVEC.js";
|
|
9
|
+
import { t as _sfc_main$17 } from "./TextInput-B0IKC7g5.js";
|
|
10
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, h, normalizeClass, normalizeStyle, openBlock, ref, renderList, renderSlot, toDisplayString, toValue, unref, watch, withCtx } from "vue";
|
|
11
|
+
import "../styles/table.css";
|
|
12
|
+
function proportional(value = 1, options) {
|
|
13
|
+
return {
|
|
14
|
+
type: "proportional",
|
|
15
|
+
value,
|
|
16
|
+
minWidth: options?.minWidth ?? 120
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function pixel(value) {
|
|
20
|
+
return {
|
|
21
|
+
type: "pixel",
|
|
22
|
+
value
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function flexibleMin(width) {
|
|
26
|
+
return width?.minWidth ?? (width == null ? 60 : 120);
|
|
27
|
+
}
|
|
28
|
+
function planColumnSpace(columns) {
|
|
29
|
+
let totalProportion = 0;
|
|
30
|
+
let pixelTotal = 0;
|
|
31
|
+
const flexible = [];
|
|
32
|
+
for (const column of columns) {
|
|
33
|
+
const width = column.width;
|
|
34
|
+
if (width?.type === "pixel") pixelTotal += width.value;
|
|
35
|
+
else {
|
|
36
|
+
const proportion = width?.value ?? 1;
|
|
37
|
+
totalProportion += proportion;
|
|
38
|
+
flexible.push({
|
|
39
|
+
proportion,
|
|
40
|
+
minWidth: flexibleMin(width)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let maxProportionalSpace = 0;
|
|
45
|
+
if (totalProportion > 0) for (const column of flexible) {
|
|
46
|
+
const required = column.minWidth * totalProportion / column.proportion;
|
|
47
|
+
if (required > maxProportionalSpace) maxProportionalSpace = required;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
totalProportion,
|
|
51
|
+
pixelTotal,
|
|
52
|
+
maxProportionalSpace
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function resolveColumnWidths(columns) {
|
|
56
|
+
const { totalProportion, pixelTotal, maxProportionalSpace } = planColumnSpace(columns);
|
|
57
|
+
const result = /* @__PURE__ */ new Map();
|
|
58
|
+
for (const column of columns) {
|
|
59
|
+
const width = column.width;
|
|
60
|
+
const style = {};
|
|
61
|
+
if (width?.type === "pixel") {
|
|
62
|
+
style.width = `${width.value}px`;
|
|
63
|
+
style.minWidth = `${width.value}px`;
|
|
64
|
+
} else {
|
|
65
|
+
const proportion = width?.value ?? 1;
|
|
66
|
+
if (totalProportion > 0) style.width = `${proportion / totalProportion * 100}%`;
|
|
67
|
+
style.minWidth = `${flexibleMin(width)}px`;
|
|
68
|
+
}
|
|
69
|
+
result.set(column.key, { style });
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
columns: result,
|
|
73
|
+
tableMinWidth: pixelTotal + maxProportionalSpace
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function capitalize(value) {
|
|
77
|
+
if (value.length === 0) return value;
|
|
78
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
79
|
+
}
|
|
80
|
+
function cellText(value) {
|
|
81
|
+
if (value == null) return "";
|
|
82
|
+
if (value instanceof Date) return value.toISOString();
|
|
83
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
|
|
84
|
+
return "";
|
|
85
|
+
}
|
|
86
|
+
function paginateData(data, page, pageSize) {
|
|
87
|
+
const size = Number.isFinite(pageSize) ? Math.max(1, Math.floor(pageSize)) : 10;
|
|
88
|
+
const start = ((Number.isFinite(page) ? Math.max(1, Math.floor(page)) : 1) - 1) * size;
|
|
89
|
+
return data.slice(start, start + size);
|
|
90
|
+
}
|
|
91
|
+
function contentLength(value) {
|
|
92
|
+
if (typeof value === "string") return value.length;
|
|
93
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value).length;
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
function longestWord(value) {
|
|
97
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return 0;
|
|
98
|
+
return String(value).split(/\s+/).reduce((max, word) => Math.max(max, word.length), 0);
|
|
99
|
+
}
|
|
100
|
+
function generateColumns(data) {
|
|
101
|
+
const first = data[0];
|
|
102
|
+
if (first == null) return [];
|
|
103
|
+
const keys = Object.keys(first);
|
|
104
|
+
const sample = data.slice(0, Math.min(5, data.length));
|
|
105
|
+
return keys.map((key) => {
|
|
106
|
+
const header = capitalize(key);
|
|
107
|
+
let maxContent = header.length;
|
|
108
|
+
let maxWord = header.length;
|
|
109
|
+
for (const row of sample) {
|
|
110
|
+
maxContent = Math.max(maxContent, contentLength(row[key]));
|
|
111
|
+
maxWord = Math.max(maxWord, longestWord(row[key]));
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
key,
|
|
115
|
+
header,
|
|
116
|
+
width: proportional(maxContent <= 6 ? 1 : maxContent <= 15 ? 2 : 3, { minWidth: Math.max(Math.max(header.length, maxWord) * 8, 60) })
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function sortRows(rows, sort, columns = []) {
|
|
121
|
+
if (sort.length === 0) return [...rows];
|
|
122
|
+
const comparators = /* @__PURE__ */ new Map();
|
|
123
|
+
for (const column of columns) {
|
|
124
|
+
const sortable = column.sortable;
|
|
125
|
+
const key = sortable == null || sortable === false || sortable === true ? column.key : sortable.sortKey ?? column.key;
|
|
126
|
+
if (typeof sortable === "object" && sortable.compare) comparators.set(key, sortable.compare);
|
|
127
|
+
}
|
|
128
|
+
const copy = [...rows];
|
|
129
|
+
copy.sort((a, b) => {
|
|
130
|
+
for (const entry of sort) {
|
|
131
|
+
const custom = comparators.get(entry.sortKey);
|
|
132
|
+
const result = custom ? custom(a, b) : compareValues(a[entry.sortKey], b[entry.sortKey]);
|
|
133
|
+
if (result !== 0) return entry.direction === "ascending" ? result : -result;
|
|
134
|
+
}
|
|
135
|
+
return 0;
|
|
136
|
+
});
|
|
137
|
+
return copy;
|
|
138
|
+
}
|
|
139
|
+
function compareValues(a, b) {
|
|
140
|
+
if (a == null && b == null) return 0;
|
|
141
|
+
if (a == null) return 1;
|
|
142
|
+
if (b == null) return -1;
|
|
143
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
144
|
+
return String(a).localeCompare(String(b));
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/Table/plugins/columnResize.ts
|
|
148
|
+
function useTableColumnResize(config) {
|
|
149
|
+
return {
|
|
150
|
+
widthFor(column) {
|
|
151
|
+
return toValue(config).columnWidths[column.key];
|
|
152
|
+
},
|
|
153
|
+
onColumnResizeEnd(key, width) {
|
|
154
|
+
toValue(config).onColumnResizeEnd({ [key]: Math.max(60, Math.round(width)) });
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/Table/plugins/columnSettings.ts
|
|
160
|
+
function useTableColumnSettingsState(config) {
|
|
161
|
+
function setActiveColumnKeys(keys) {
|
|
162
|
+
const locked = config.columns.filter((column) => column.isAlwaysVisible).map((column) => column.key);
|
|
163
|
+
const next = [...keys];
|
|
164
|
+
for (const key of locked) if (!next.includes(key)) next.unshift(key);
|
|
165
|
+
config.onChangeActiveColumnKeys(next);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
get activeColumnKeys() {
|
|
169
|
+
return toValue(config.activeColumnKeys);
|
|
170
|
+
},
|
|
171
|
+
setActiveColumnKeys,
|
|
172
|
+
columnSettingsConfig: {
|
|
173
|
+
columns: config.columns,
|
|
174
|
+
get activeColumnKeys() {
|
|
175
|
+
return toValue(config.activeColumnKeys);
|
|
176
|
+
},
|
|
177
|
+
onChangeActiveColumnKeys: setActiveColumnKeys
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function useTableColumnSettings(config) {
|
|
182
|
+
return { transformColumns(columns) {
|
|
183
|
+
const current = toValue(config);
|
|
184
|
+
const order = new Map(current.activeColumnKeys.map((key, index) => [key, index]));
|
|
185
|
+
return columns.filter((column) => order.has(column.key)).sort((a, b) => (order.get(a.key) ?? 0) - (order.get(b.key) ?? 0));
|
|
186
|
+
} };
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/Table/plugins/filtering.ts
|
|
190
|
+
function useTableFilterState(initial = {}) {
|
|
191
|
+
const filters = ref({ ...initial });
|
|
192
|
+
function onFilterChange(key, value) {
|
|
193
|
+
const next = { ...filters.value };
|
|
194
|
+
if (value == null || value === "" || Array.isArray(value) && value.length === 0) delete next[key];
|
|
195
|
+
else next[key] = value;
|
|
196
|
+
filters.value = next;
|
|
197
|
+
}
|
|
198
|
+
function clearAll() {
|
|
199
|
+
filters.value = {};
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
filters,
|
|
203
|
+
onFilterChange,
|
|
204
|
+
clearAll
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function applyTableFilters(rows, filters, fields = []) {
|
|
208
|
+
const kinds = new Map(fields.map((field) => [field.key, field.type]));
|
|
209
|
+
const active = Object.entries(filters).filter(([, value]) => value != null && value !== "" && !(Array.isArray(value) && value.length === 0));
|
|
210
|
+
if (active.length === 0) return [...rows];
|
|
211
|
+
return rows.filter((row) => active.every(([key, value]) => {
|
|
212
|
+
const cell = String(row[key] ?? "").toLowerCase();
|
|
213
|
+
if ((kinds.get(key) ?? (Array.isArray(value) ? "enum" : "string")) === "enum") return (Array.isArray(value) ? value : [value]).some((item) => cell === item.toLowerCase());
|
|
214
|
+
return cell.includes(String(value).toLowerCase());
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
function useTableFiltering(config) {
|
|
218
|
+
return { filterFor(column) {
|
|
219
|
+
if (column.filter == null) return null;
|
|
220
|
+
const current = toValue(config);
|
|
221
|
+
const fieldKey = column.filter;
|
|
222
|
+
const field = current.fields.find((item) => item.key === fieldKey);
|
|
223
|
+
if (field == null) return null;
|
|
224
|
+
return {
|
|
225
|
+
variant: current.variant ?? "popover",
|
|
226
|
+
field,
|
|
227
|
+
value: current.filters[fieldKey] ?? null,
|
|
228
|
+
onChange(value) {
|
|
229
|
+
toValue(config).onFilterChange(fieldKey, value);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
} };
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/Table/plugins/pagination.ts
|
|
236
|
+
function useTablePagination(config) {
|
|
237
|
+
function controls() {
|
|
238
|
+
const current = toValue(config);
|
|
239
|
+
if ((current.position ?? "below") === "none") return null;
|
|
240
|
+
const pageSize = current.pageSize ?? 10;
|
|
241
|
+
return h("div", {
|
|
242
|
+
"class": "astryx-table__pagination",
|
|
243
|
+
"data-align": current.align ?? "center"
|
|
244
|
+
}, [h(_sfc_main$15, {
|
|
245
|
+
"page": current.page,
|
|
246
|
+
pageSize,
|
|
247
|
+
"total": current.totalItems ?? 0,
|
|
248
|
+
"showSizeChanger": current.pageSizeOptions != null && current.onPageSizeChange != null,
|
|
249
|
+
"pageSizeOptions": current.pageSizeOptions,
|
|
250
|
+
"aria-label": current.label,
|
|
251
|
+
"onUpdate:page": (page) => toValue(config).onPageChange(page),
|
|
252
|
+
"onUpdate:pageSize": (size) => toValue(config).onPageSizeChange?.(size)
|
|
253
|
+
})]);
|
|
254
|
+
}
|
|
255
|
+
return { below() {
|
|
256
|
+
const position = toValue(config).position ?? "below";
|
|
257
|
+
if (position === "above" || position === "none") return null;
|
|
258
|
+
return controls();
|
|
259
|
+
} };
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/Table/plugins/selection.ts
|
|
263
|
+
function rowId(row, idKey) {
|
|
264
|
+
return String(row[idKey] ?? "");
|
|
265
|
+
}
|
|
266
|
+
function useTableSelectionState(config) {
|
|
267
|
+
const selectable = computed(() => toValue(config.data));
|
|
268
|
+
return { selectionConfig: {
|
|
269
|
+
getIsItemSelected: (item) => toValue(config.selectedKeys).has(rowId(item, config.idKey)),
|
|
270
|
+
onSelectItem: ({ item, isSelected }) => {
|
|
271
|
+
const next = new Set(toValue(config.selectedKeys));
|
|
272
|
+
const id = rowId(item, config.idKey);
|
|
273
|
+
if (isSelected) next.add(id);
|
|
274
|
+
else next.delete(id);
|
|
275
|
+
config.setSelectedKeys(next);
|
|
276
|
+
},
|
|
277
|
+
onSelectAll: ({ isAllSelected }) => {
|
|
278
|
+
config.setSelectedKeys(isAllSelected ? new Set(toValue(config.data).map((item) => rowId(item, config.idKey))) : /* @__PURE__ */ new Set());
|
|
279
|
+
},
|
|
280
|
+
getIsAllSelected: () => {
|
|
281
|
+
const rows = toValue(config.data);
|
|
282
|
+
const selected = toValue(config.selectedKeys);
|
|
283
|
+
return rows.length > 0 && rows.every((item) => selected.has(rowId(item, config.idKey)));
|
|
284
|
+
},
|
|
285
|
+
getIsIndeterminate: () => {
|
|
286
|
+
const rows = toValue(config.data);
|
|
287
|
+
const selected = toValue(config.selectedKeys);
|
|
288
|
+
const count = rows.filter((item) => selected.has(rowId(item, config.idKey))).length;
|
|
289
|
+
return count > 0 && count < rows.length;
|
|
290
|
+
},
|
|
291
|
+
getRowLabel: config.getRowLabel,
|
|
292
|
+
hasRowHighlight: config.hasRowHighlight,
|
|
293
|
+
get rows() {
|
|
294
|
+
return selectable.value;
|
|
295
|
+
}
|
|
296
|
+
} };
|
|
297
|
+
}
|
|
298
|
+
function useTableSelection(config) {
|
|
299
|
+
return { selection: {
|
|
300
|
+
isAllSelected: () => toValue(config).getIsAllSelected(),
|
|
301
|
+
isIndeterminate: () => toValue(config).getIsIndeterminate?.() ?? false,
|
|
302
|
+
isSelected: (row) => toValue(config).getIsItemSelected(row),
|
|
303
|
+
isSelectable: (row) => toValue(config).getIsItemSelectable?.(row) ?? true,
|
|
304
|
+
selectAll: (selected) => toValue(config).onSelectAll({ isAllSelected: selected }),
|
|
305
|
+
selectRow: (row, selected) => toValue(config).onSelectItem({
|
|
306
|
+
item: row,
|
|
307
|
+
isSelected: selected
|
|
308
|
+
}),
|
|
309
|
+
rowLabel: (row) => toValue(config).getRowLabel?.(row) ?? "",
|
|
310
|
+
hasRowHighlight: toValue(config).hasRowHighlight
|
|
311
|
+
} };
|
|
312
|
+
}
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/Table/plugins/sortable.ts
|
|
315
|
+
function useTableSortableState(options) {
|
|
316
|
+
const sort = ref(options.defaultSort ?? []);
|
|
317
|
+
return {
|
|
318
|
+
sortedData: computed(() => sortRows(toValue(options.data), sort.value, toValue(options.columns) ?? [])),
|
|
319
|
+
sort,
|
|
320
|
+
sortConfig: {
|
|
321
|
+
get sort() {
|
|
322
|
+
return sort.value;
|
|
323
|
+
},
|
|
324
|
+
onSortChange(next) {
|
|
325
|
+
sort.value = next;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function sortKeyOf(column) {
|
|
331
|
+
if (!column.sortable) return null;
|
|
332
|
+
if (column.sortable === true) return column.key;
|
|
333
|
+
return column.sortable.sortKey ?? column.key;
|
|
334
|
+
}
|
|
335
|
+
function headerLabel(column) {
|
|
336
|
+
return column.header ?? column.key;
|
|
337
|
+
}
|
|
338
|
+
function nextDirection(current, allowUnsorted) {
|
|
339
|
+
if (current == null) return "ascending";
|
|
340
|
+
if (current === "ascending") return "descending";
|
|
341
|
+
return allowUnsorted ? null : "ascending";
|
|
342
|
+
}
|
|
343
|
+
function useTableSortable(config) {
|
|
344
|
+
const messages = useAstryxMessages();
|
|
345
|
+
return { sortFor(column) {
|
|
346
|
+
const key = sortKeyOf(column);
|
|
347
|
+
if (key == null) return null;
|
|
348
|
+
const current = toValue(config);
|
|
349
|
+
const index = current.sort.findIndex((entry) => entry.sortKey === key);
|
|
350
|
+
const direction = index >= 0 ? current.sort[index].direction : null;
|
|
351
|
+
const rank = current.sort.length > 1 && index >= 0 ? index + 1 : null;
|
|
352
|
+
const label = headerLabel(column);
|
|
353
|
+
const action = direction == null ? messages.value.table.sortAscending : direction === "ascending" ? messages.value.table.sortDescending : messages.value.table.clearSort;
|
|
354
|
+
return {
|
|
355
|
+
direction,
|
|
356
|
+
rank,
|
|
357
|
+
label: `${messages.value.table.sortBy(label)}. ${action}`,
|
|
358
|
+
onClick(event) {
|
|
359
|
+
const latest = toValue(config);
|
|
360
|
+
const allowUnsorted = latest.allowUnsortedState ?? true;
|
|
361
|
+
const multi = (latest.isMultiSortEnabled ?? false) && event.shiftKey;
|
|
362
|
+
const existing = latest.sort.findIndex((entry) => entry.sortKey === key);
|
|
363
|
+
const direction = nextDirection(existing >= 0 ? latest.sort[existing].direction : null, allowUnsorted);
|
|
364
|
+
if (!multi) {
|
|
365
|
+
latest.onSortChange(direction == null ? [] : [{
|
|
366
|
+
sortKey: key,
|
|
367
|
+
direction
|
|
368
|
+
}]);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const next = latest.sort.filter((entry) => entry.sortKey !== key);
|
|
372
|
+
if (direction != null) next.push({
|
|
373
|
+
sortKey: key,
|
|
374
|
+
direction
|
|
375
|
+
});
|
|
376
|
+
latest.onSortChange(next);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
} };
|
|
380
|
+
}
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/Table/TableFilterControl.vue
|
|
383
|
+
const _hoisted_1$6 = { class: "astryx-table__filter" };
|
|
384
|
+
const _hoisted_2$2 = { class: "astryx-table__filter-popover" };
|
|
385
|
+
const _hoisted_3$1 = { class: "astryx-table__filter-actions" };
|
|
386
|
+
const _sfc_main$9 = /*@__PURE__*/ defineComponent({
|
|
387
|
+
__name: "TableFilterControl",
|
|
388
|
+
props: { filter: {} },
|
|
389
|
+
setup(__props) {
|
|
390
|
+
const props = __props;
|
|
391
|
+
const messages = useAstryxMessages();
|
|
392
|
+
const draft = ref(typeof props.filter.value === "string" ? props.filter.value : "");
|
|
393
|
+
watch(() => props.filter.value, (value) => {
|
|
394
|
+
draft.value = typeof value === "string" ? value : "";
|
|
395
|
+
});
|
|
396
|
+
function commit(value) {
|
|
397
|
+
props.filter.onChange(value);
|
|
398
|
+
}
|
|
399
|
+
function onInlineInput(value) {
|
|
400
|
+
draft.value = value;
|
|
401
|
+
commit(value === "" ? null : value);
|
|
402
|
+
}
|
|
403
|
+
return (_ctx, _cache) => {
|
|
404
|
+
return openBlock(), createElementBlock("div", _hoisted_1$6, [__props.filter.variant === "inline" && __props.filter.field.type === "string" ? (openBlock(), createBlock(_sfc_main$17, {
|
|
405
|
+
key: 0,
|
|
406
|
+
"model-value": draft.value,
|
|
407
|
+
label: __props.filter.field.label,
|
|
408
|
+
"is-label-hidden": "",
|
|
409
|
+
size: "sm",
|
|
410
|
+
placeholder: __props.filter.field.label,
|
|
411
|
+
"onUpdate:modelValue": onInlineInput
|
|
412
|
+
}, null, 8, [
|
|
413
|
+
"model-value",
|
|
414
|
+
"label",
|
|
415
|
+
"placeholder"
|
|
416
|
+
])) : __props.filter.variant === "inline" ? (openBlock(), createBlock(_sfc_main$16, {
|
|
417
|
+
key: 1,
|
|
418
|
+
"model-value": draft.value || null,
|
|
419
|
+
label: __props.filter.field.label,
|
|
420
|
+
size: "sm",
|
|
421
|
+
placeholder: unref(messages).table.filterAll,
|
|
422
|
+
options: __props.filter.field.options ?? [],
|
|
423
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = (value) => commit(value == null || value === "" ? null : String(value)))
|
|
424
|
+
}, null, 8, [
|
|
425
|
+
"model-value",
|
|
426
|
+
"label",
|
|
427
|
+
"placeholder",
|
|
428
|
+
"options"
|
|
429
|
+
])) : (openBlock(), createBlock(_sfc_main$14, {
|
|
430
|
+
key: 2,
|
|
431
|
+
label: __props.filter.field.label,
|
|
432
|
+
"has-close-button": false,
|
|
433
|
+
width: 240
|
|
434
|
+
}, {
|
|
435
|
+
content: withCtx(() => [createElementVNode("div", _hoisted_2$2, [__props.filter.field.type === "string" ? (openBlock(), createBlock(_sfc_main$17, {
|
|
436
|
+
key: 0,
|
|
437
|
+
"model-value": draft.value,
|
|
438
|
+
label: __props.filter.field.label,
|
|
439
|
+
"is-label-hidden": "",
|
|
440
|
+
size: "sm",
|
|
441
|
+
placeholder: __props.filter.field.label,
|
|
442
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = (value) => draft.value = value)
|
|
443
|
+
}, null, 8, [
|
|
444
|
+
"model-value",
|
|
445
|
+
"label",
|
|
446
|
+
"placeholder"
|
|
447
|
+
])) : (openBlock(), createBlock(_sfc_main$16, {
|
|
448
|
+
key: 1,
|
|
449
|
+
"model-value": draft.value || null,
|
|
450
|
+
label: __props.filter.field.label,
|
|
451
|
+
size: "sm",
|
|
452
|
+
placeholder: unref(messages).table.filterAll,
|
|
453
|
+
options: __props.filter.field.options ?? [],
|
|
454
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = (value) => draft.value = value == null ? "" : String(value))
|
|
455
|
+
}, null, 8, [
|
|
456
|
+
"model-value",
|
|
457
|
+
"label",
|
|
458
|
+
"placeholder",
|
|
459
|
+
"options"
|
|
460
|
+
])), createElementVNode("div", _hoisted_3$1, [createVNode(_sfc_main$10, {
|
|
461
|
+
variant: "ghost",
|
|
462
|
+
size: "sm",
|
|
463
|
+
label: unref(messages).table.reset,
|
|
464
|
+
onClick: _cache[3] || (_cache[3] = ($event) => {
|
|
465
|
+
draft.value = "";
|
|
466
|
+
commit(null);
|
|
467
|
+
})
|
|
468
|
+
}, {
|
|
469
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(messages).table.reset), 1)]),
|
|
470
|
+
_: 1
|
|
471
|
+
}, 8, ["label"]), createVNode(_sfc_main$10, {
|
|
472
|
+
variant: "primary",
|
|
473
|
+
size: "sm",
|
|
474
|
+
label: unref(messages).table.apply,
|
|
475
|
+
onClick: _cache[4] || (_cache[4] = ($event) => commit(draft.value === "" ? null : draft.value))
|
|
476
|
+
}, {
|
|
477
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(messages).table.apply), 1)]),
|
|
478
|
+
_: 1
|
|
479
|
+
}, 8, ["label"])])])]),
|
|
480
|
+
default: withCtx(() => [createVNode(_sfc_main$11, {
|
|
481
|
+
variant: "ghost",
|
|
482
|
+
size: "sm",
|
|
483
|
+
label: __props.filter.field.label
|
|
484
|
+
}, {
|
|
485
|
+
default: withCtx(() => [createVNode(_sfc_main$12, {
|
|
486
|
+
icon: "funnel",
|
|
487
|
+
size: "sm"
|
|
488
|
+
})]),
|
|
489
|
+
_: 1
|
|
490
|
+
}, 8, ["label"])]),
|
|
491
|
+
_: 1
|
|
492
|
+
}, 8, ["label"]))]);
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region src/Table/TableData.vue
|
|
498
|
+
const _hoisted_1$5 = ["aria-label"];
|
|
499
|
+
const _hoisted_2$1 = [
|
|
500
|
+
"data-density",
|
|
501
|
+
"data-dividers",
|
|
502
|
+
"data-striped",
|
|
503
|
+
"data-hover",
|
|
504
|
+
"data-overflow",
|
|
505
|
+
"data-valign"
|
|
506
|
+
];
|
|
507
|
+
const _hoisted_3 = {
|
|
508
|
+
key: 0,
|
|
509
|
+
class: "astryx-table__select",
|
|
510
|
+
scope: "col"
|
|
511
|
+
};
|
|
512
|
+
const _hoisted_4 = ["data-align", "aria-sort"];
|
|
513
|
+
const _hoisted_5 = { class: "astryx-table__header" };
|
|
514
|
+
const _hoisted_6 = [
|
|
515
|
+
"data-align",
|
|
516
|
+
"aria-label",
|
|
517
|
+
"onClick"
|
|
518
|
+
];
|
|
519
|
+
const _hoisted_7 = ["data-active"];
|
|
520
|
+
const _hoisted_8 = {
|
|
521
|
+
key: 0,
|
|
522
|
+
class: "astryx-table__sort-rank"
|
|
523
|
+
};
|
|
524
|
+
const _hoisted_9 = { key: 1 };
|
|
525
|
+
const _hoisted_10 = ["onPointerdown"];
|
|
526
|
+
const _hoisted_11 = { key: 0 };
|
|
527
|
+
const _hoisted_12 = ["colspan"];
|
|
528
|
+
const _hoisted_13 = ["aria-selected"];
|
|
529
|
+
const _hoisted_14 = {
|
|
530
|
+
key: 0,
|
|
531
|
+
class: "astryx-table__select"
|
|
532
|
+
};
|
|
533
|
+
const _hoisted_15 = ["data-align"];
|
|
534
|
+
const _sfc_main$8 = /*@__PURE__*/ defineComponent({
|
|
535
|
+
__name: "TableData",
|
|
536
|
+
props: {
|
|
537
|
+
rows: {},
|
|
538
|
+
columns: {},
|
|
539
|
+
plugins: {},
|
|
540
|
+
idKey: {},
|
|
541
|
+
label: {},
|
|
542
|
+
density: {},
|
|
543
|
+
dividers: {},
|
|
544
|
+
isStriped: { type: Boolean },
|
|
545
|
+
hasHover: { type: Boolean },
|
|
546
|
+
textOverflow: {},
|
|
547
|
+
verticalAlign: {},
|
|
548
|
+
minWidth: {}
|
|
549
|
+
},
|
|
550
|
+
setup(__props) {
|
|
551
|
+
const props = __props;
|
|
552
|
+
const messages = useAstryxMessages();
|
|
553
|
+
const dragWidths = ref({});
|
|
554
|
+
const resolvedColumns = computed(() => props.plugins.reduce((columns, plugin) => plugin.transformColumns?.(columns) ?? columns, [...props.columns]));
|
|
555
|
+
const widths = computed(() => resolveColumnWidths(resolvedColumns.value));
|
|
556
|
+
const selection = computed(() => props.plugins.find((plugin) => plugin.selection)?.selection);
|
|
557
|
+
const resizable = computed(() => props.plugins.some((plugin) => plugin.onColumnResizeEnd));
|
|
558
|
+
function styleFor(column) {
|
|
559
|
+
const base = { ...widths.value.columns.get(column.key)?.style ?? {} };
|
|
560
|
+
const override = props.plugins.map((plugin) => plugin.widthFor?.(column)).find((value) => value != null) ?? dragWidths.value[column.key];
|
|
561
|
+
if (override != null) {
|
|
562
|
+
base.width = `${override}px`;
|
|
563
|
+
base.minWidth = `${override}px`;
|
|
564
|
+
}
|
|
565
|
+
return base;
|
|
566
|
+
}
|
|
567
|
+
function sortFor(column) {
|
|
568
|
+
for (const plugin of props.plugins) {
|
|
569
|
+
const sort = plugin.sortFor?.(column);
|
|
570
|
+
if (sort) return sort;
|
|
571
|
+
}
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
function filterFor(column) {
|
|
575
|
+
for (const plugin of props.plugins) {
|
|
576
|
+
const filter = plugin.filterFor?.(column);
|
|
577
|
+
if (filter) return filter;
|
|
578
|
+
}
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
function rowKey(row, index) {
|
|
582
|
+
const id = row[props.idKey];
|
|
583
|
+
return id == null ? index : String(id);
|
|
584
|
+
}
|
|
585
|
+
function selected(row) {
|
|
586
|
+
return selection.value?.isSelected(row) === true && selection.value.hasRowHighlight !== false;
|
|
587
|
+
}
|
|
588
|
+
const CellContent = defineComponent({
|
|
589
|
+
name: "AstryxTableCellContent",
|
|
590
|
+
props: {
|
|
591
|
+
column: {
|
|
592
|
+
type: Object,
|
|
593
|
+
required: true
|
|
594
|
+
},
|
|
595
|
+
row: {
|
|
596
|
+
type: Object,
|
|
597
|
+
required: true
|
|
598
|
+
},
|
|
599
|
+
index: {
|
|
600
|
+
type: Number,
|
|
601
|
+
required: true
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
setup(cellProps) {
|
|
605
|
+
return () => {
|
|
606
|
+
const column = cellProps.column;
|
|
607
|
+
const row = cellProps.row;
|
|
608
|
+
const rendered = column.renderCell?.(row, cellProps.index);
|
|
609
|
+
if (rendered == null) return cellText(row[column.key]);
|
|
610
|
+
return rendered;
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
const PluginFooter = defineComponent({
|
|
615
|
+
name: "AstryxTablePluginFooter",
|
|
616
|
+
props: { plugin: {
|
|
617
|
+
type: Object,
|
|
618
|
+
required: true
|
|
619
|
+
} },
|
|
620
|
+
setup(footerProps) {
|
|
621
|
+
return () => footerProps.plugin.below?.() ?? null;
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
function startResize(event, column) {
|
|
625
|
+
const handle = event.currentTarget;
|
|
626
|
+
if (!(handle instanceof HTMLElement)) return;
|
|
627
|
+
const cell = handle.closest("th");
|
|
628
|
+
if (cell == null) return;
|
|
629
|
+
const startX = event.clientX;
|
|
630
|
+
const startWidth = cell.getBoundingClientRect().width;
|
|
631
|
+
handle.setPointerCapture(event.pointerId);
|
|
632
|
+
const move = (moveEvent) => {
|
|
633
|
+
if (!(moveEvent instanceof PointerEvent)) return;
|
|
634
|
+
const next = Math.max(60, startWidth + moveEvent.clientX - startX);
|
|
635
|
+
dragWidths.value = {
|
|
636
|
+
...dragWidths.value,
|
|
637
|
+
[column.key]: next
|
|
638
|
+
};
|
|
639
|
+
};
|
|
640
|
+
const stop = (upEvent) => {
|
|
641
|
+
handle.removeEventListener("pointermove", move);
|
|
642
|
+
handle.removeEventListener("pointerup", stop);
|
|
643
|
+
const width = dragWidths.value[column.key] ?? startWidth;
|
|
644
|
+
for (const plugin of props.plugins) plugin.onColumnResizeEnd?.(column.key, width);
|
|
645
|
+
if (upEvent instanceof PointerEvent && handle.hasPointerCapture(upEvent.pointerId)) handle.releasePointerCapture(upEvent.pointerId);
|
|
646
|
+
};
|
|
647
|
+
handle.addEventListener("pointermove", move);
|
|
648
|
+
handle.addEventListener("pointerup", stop);
|
|
649
|
+
}
|
|
650
|
+
const columnCount = computed(() => resolvedColumns.value.length + (selection.value ? 1 : 0));
|
|
651
|
+
return (_ctx, _cache) => {
|
|
652
|
+
return openBlock(), createElementBlock("div", {
|
|
653
|
+
class: "astryx-table-scroll",
|
|
654
|
+
role: "group",
|
|
655
|
+
"aria-label": __props.label
|
|
656
|
+
}, [createElementVNode("table", {
|
|
657
|
+
class: "astryx-table",
|
|
658
|
+
"data-density": __props.density,
|
|
659
|
+
"data-dividers": __props.dividers,
|
|
660
|
+
"data-striped": __props.isStriped || void 0,
|
|
661
|
+
"data-hover": __props.hasHover || void 0,
|
|
662
|
+
"data-overflow": __props.textOverflow,
|
|
663
|
+
"data-valign": __props.verticalAlign,
|
|
664
|
+
style: normalizeStyle(__props.minWidth ? { minWidth: `${Math.max(__props.minWidth, widths.value.tableMinWidth)}px` } : { minWidth: `${widths.value.tableMinWidth}px` })
|
|
665
|
+
}, [createElementVNode("thead", null, [createElementVNode("tr", null, [selection.value ? (openBlock(), createElementBlock("th", _hoisted_3, [createVNode(_sfc_main$13, {
|
|
666
|
+
"model-value": selection.value.isIndeterminate() ? "indeterminate" : selection.value.isAllSelected(),
|
|
667
|
+
label: unref(messages).table.selectAllRows,
|
|
668
|
+
"is-label-hidden": "",
|
|
669
|
+
size: "sm",
|
|
670
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = (value) => selection.value?.selectAll(value === true))
|
|
671
|
+
}, null, 8, ["model-value", "label"])])) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(resolvedColumns.value, (column) => {
|
|
672
|
+
return openBlock(), createElementBlock("th", {
|
|
673
|
+
key: column.key,
|
|
674
|
+
scope: "col",
|
|
675
|
+
"data-align": column.align,
|
|
676
|
+
style: normalizeStyle(styleFor(column)),
|
|
677
|
+
"aria-sort": sortFor(column)?.direction ?? void 0
|
|
678
|
+
}, [createElementVNode("div", _hoisted_5, [sortFor(column) ? (openBlock(), createElementBlock("button", {
|
|
679
|
+
key: 0,
|
|
680
|
+
type: "button",
|
|
681
|
+
class: "astryx-table__sort",
|
|
682
|
+
"data-align": column.align,
|
|
683
|
+
"aria-label": sortFor(column)?.label,
|
|
684
|
+
onClick: ($event) => sortFor(column)?.onClick($event)
|
|
685
|
+
}, [
|
|
686
|
+
createElementVNode("span", null, toDisplayString(column.header ?? column.key), 1),
|
|
687
|
+
createElementVNode("span", {
|
|
688
|
+
class: "astryx-table__sort-icon",
|
|
689
|
+
"data-active": sortFor(column)?.direction != null || void 0
|
|
690
|
+
}, [createVNode(_sfc_main$12, {
|
|
691
|
+
icon: sortFor(column)?.direction === "descending" ? "arrowDown" : "arrowUp",
|
|
692
|
+
size: "sm"
|
|
693
|
+
}, null, 8, ["icon"])], 8, _hoisted_7),
|
|
694
|
+
sortFor(column)?.rank ? (openBlock(), createElementBlock("span", _hoisted_8, toDisplayString(sortFor(column)?.rank), 1)) : createCommentVNode("v-if", true)
|
|
695
|
+
], 8, _hoisted_6)) : (openBlock(), createElementBlock("span", _hoisted_9, toDisplayString(column.header ?? column.key), 1)), filterFor(column) ? (openBlock(), createBlock(_sfc_main$9, {
|
|
696
|
+
key: 2,
|
|
697
|
+
filter: filterFor(column)
|
|
698
|
+
}, null, 8, ["filter"])) : createCommentVNode("v-if", true)]), resizable.value ? (openBlock(), createElementBlock("span", {
|
|
699
|
+
key: 0,
|
|
700
|
+
class: "astryx-table__resize",
|
|
701
|
+
onPointerdown: ($event) => startResize($event, column)
|
|
702
|
+
}, null, 40, _hoisted_10)) : createCommentVNode("v-if", true)], 12, _hoisted_4);
|
|
703
|
+
}), 128))])]), createElementVNode("tbody", null, [__props.rows.length === 0 ? (openBlock(), createElementBlock("tr", _hoisted_11, [createElementVNode("td", {
|
|
704
|
+
class: "astryx-table__empty",
|
|
705
|
+
colspan: columnCount.value
|
|
706
|
+
}, [renderSlot(_ctx.$slots, "empty", {}, () => [createTextVNode(toDisplayString(unref(messages).table.noData), 1)])], 8, _hoisted_12)])) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.rows, (row, index) => {
|
|
707
|
+
return openBlock(), createElementBlock("tr", {
|
|
708
|
+
key: rowKey(row, index),
|
|
709
|
+
"aria-selected": selected(row) ? "true" : void 0
|
|
710
|
+
}, [selection.value ? (openBlock(), createElementBlock("td", _hoisted_14, [selection.value.isSelectable?.(row) !== false ? (openBlock(), createBlock(_sfc_main$13, {
|
|
711
|
+
key: 0,
|
|
712
|
+
"model-value": selection.value.isSelected(row),
|
|
713
|
+
label: selection.value.rowLabel?.(row) ? unref(messages).table.selectRowNamed(selection.value.rowLabel(row)) : unref(messages).table.selectRow,
|
|
714
|
+
"is-label-hidden": "",
|
|
715
|
+
size: "sm",
|
|
716
|
+
"onUpdate:modelValue": (value) => selection.value?.selectRow(row, value === true)
|
|
717
|
+
}, null, 8, [
|
|
718
|
+
"model-value",
|
|
719
|
+
"label",
|
|
720
|
+
"onUpdate:modelValue"
|
|
721
|
+
])) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(resolvedColumns.value, (column) => {
|
|
722
|
+
return openBlock(), createElementBlock("td", {
|
|
723
|
+
key: column.key,
|
|
724
|
+
"data-align": column.align,
|
|
725
|
+
style: normalizeStyle(column.verticalAlign ? { verticalAlign: column.verticalAlign } : void 0)
|
|
726
|
+
}, [createVNode(unref(CellContent), {
|
|
727
|
+
column,
|
|
728
|
+
row,
|
|
729
|
+
index
|
|
730
|
+
}, null, 8, [
|
|
731
|
+
"column",
|
|
732
|
+
"row",
|
|
733
|
+
"index"
|
|
734
|
+
])], 12, _hoisted_15);
|
|
735
|
+
}), 128))], 8, _hoisted_13);
|
|
736
|
+
}), 128))])], 12, _hoisted_2$1), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.plugins, (plugin, index) => {
|
|
737
|
+
return openBlock(), createBlock(unref(PluginFooter), {
|
|
738
|
+
key: index,
|
|
739
|
+
plugin
|
|
740
|
+
}, null, 8, ["plugin"]);
|
|
741
|
+
}), 128))], 8, _hoisted_1$5);
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
//#endregion
|
|
746
|
+
//#region src/Table/Table.vue
|
|
747
|
+
const _hoisted_1$4 = ["aria-label"];
|
|
748
|
+
const _hoisted_2 = [
|
|
749
|
+
"data-density",
|
|
750
|
+
"data-dividers",
|
|
751
|
+
"data-striped",
|
|
752
|
+
"data-hover",
|
|
753
|
+
"data-overflow",
|
|
754
|
+
"data-valign"
|
|
755
|
+
];
|
|
756
|
+
const _sfc_main$7 = /*@__PURE__*/ defineComponent({
|
|
757
|
+
name: "AstryxTable",
|
|
758
|
+
inheritAttrs: false,
|
|
759
|
+
__name: "Table",
|
|
760
|
+
props: {
|
|
761
|
+
data: {},
|
|
762
|
+
columns: {},
|
|
763
|
+
idKey: { default: "id" },
|
|
764
|
+
density: { default: "balanced" },
|
|
765
|
+
dividers: { default: "rows" },
|
|
766
|
+
isStriped: {
|
|
767
|
+
type: Boolean,
|
|
768
|
+
default: false
|
|
769
|
+
},
|
|
770
|
+
hasHover: {
|
|
771
|
+
type: Boolean,
|
|
772
|
+
default: false
|
|
773
|
+
},
|
|
774
|
+
verticalAlign: { default: "middle" },
|
|
775
|
+
textOverflow: { default: "wrap" },
|
|
776
|
+
plugins: {},
|
|
777
|
+
label: {}
|
|
778
|
+
},
|
|
779
|
+
setup(__props) {
|
|
780
|
+
const props = __props;
|
|
781
|
+
const messages = useAstryxMessages();
|
|
782
|
+
const plugins = computed(() => Object.values(props.plugins ?? {}).filter((plugin) => plugin != null));
|
|
783
|
+
const dataMode = computed(() => props.data != null);
|
|
784
|
+
const columns = computed(() => props.columns ?? []);
|
|
785
|
+
return (_ctx, _cache) => {
|
|
786
|
+
return dataMode.value ? (openBlock(), createBlock(_sfc_main$8, {
|
|
787
|
+
key: 0,
|
|
788
|
+
class: normalizeClass(_ctx.$attrs.class),
|
|
789
|
+
style: normalizeStyle(_ctx.$attrs.style),
|
|
790
|
+
rows: __props.data ?? [],
|
|
791
|
+
columns: columns.value,
|
|
792
|
+
plugins: plugins.value,
|
|
793
|
+
"id-key": __props.idKey,
|
|
794
|
+
label: __props.label ?? unref(messages).table.label,
|
|
795
|
+
density: __props.density,
|
|
796
|
+
dividers: __props.dividers,
|
|
797
|
+
"is-striped": __props.isStriped,
|
|
798
|
+
"has-hover": __props.hasHover,
|
|
799
|
+
"text-overflow": __props.textOverflow,
|
|
800
|
+
"vertical-align": __props.verticalAlign
|
|
801
|
+
}, createSlots({ _: 2 }, [_ctx.$slots.empty ? {
|
|
802
|
+
name: "empty",
|
|
803
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "empty")]),
|
|
804
|
+
key: "0"
|
|
805
|
+
} : void 0]), 1032, [
|
|
806
|
+
"class",
|
|
807
|
+
"style",
|
|
808
|
+
"rows",
|
|
809
|
+
"columns",
|
|
810
|
+
"plugins",
|
|
811
|
+
"id-key",
|
|
812
|
+
"label",
|
|
813
|
+
"density",
|
|
814
|
+
"dividers",
|
|
815
|
+
"is-striped",
|
|
816
|
+
"has-hover",
|
|
817
|
+
"text-overflow",
|
|
818
|
+
"vertical-align"
|
|
819
|
+
])) : (openBlock(), createElementBlock("div", {
|
|
820
|
+
key: 1,
|
|
821
|
+
class: "astryx-table-scroll",
|
|
822
|
+
role: "group",
|
|
823
|
+
"aria-label": __props.label ?? unref(messages).table.label
|
|
824
|
+
}, [createElementVNode("table", {
|
|
825
|
+
class: normalizeClass(["astryx-table", _ctx.$attrs.class]),
|
|
826
|
+
style: normalizeStyle(_ctx.$attrs.style),
|
|
827
|
+
"data-density": __props.density,
|
|
828
|
+
"data-dividers": __props.dividers,
|
|
829
|
+
"data-striped": __props.isStriped || void 0,
|
|
830
|
+
"data-hover": __props.hasHover || void 0,
|
|
831
|
+
"data-overflow": __props.textOverflow,
|
|
832
|
+
"data-valign": __props.verticalAlign
|
|
833
|
+
}, [renderSlot(_ctx.$slots, "default")], 14, _hoisted_2)], 8, _hoisted_1$4));
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
//#endregion
|
|
838
|
+
//#region src/Table/TableBody.vue
|
|
839
|
+
const _sfc_main$6 = /*@__PURE__*/ defineComponent({
|
|
840
|
+
name: "AstryxTableBody",
|
|
841
|
+
__name: "TableBody",
|
|
842
|
+
setup(__props) {
|
|
843
|
+
return (_ctx, _cache) => {
|
|
844
|
+
return openBlock(), createElementBlock("tbody", null, [renderSlot(_ctx.$slots, "default")]);
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
//#endregion
|
|
849
|
+
//#region src/Table/TableCell.vue
|
|
850
|
+
const _hoisted_1$3 = [
|
|
851
|
+
"data-align",
|
|
852
|
+
"colspan",
|
|
853
|
+
"rowspan",
|
|
854
|
+
"headers"
|
|
855
|
+
];
|
|
856
|
+
const _sfc_main$5 = /*@__PURE__*/ defineComponent({
|
|
857
|
+
name: "AstryxTableCell",
|
|
858
|
+
__name: "TableCell",
|
|
859
|
+
props: {
|
|
860
|
+
align: {},
|
|
861
|
+
colSpan: {},
|
|
862
|
+
rowSpan: {},
|
|
863
|
+
headers: {}
|
|
864
|
+
},
|
|
865
|
+
setup(__props) {
|
|
866
|
+
return (_ctx, _cache) => {
|
|
867
|
+
return openBlock(), createElementBlock("td", {
|
|
868
|
+
"data-align": __props.align,
|
|
869
|
+
colspan: __props.colSpan,
|
|
870
|
+
rowspan: __props.rowSpan,
|
|
871
|
+
headers: __props.headers
|
|
872
|
+
}, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_1$3);
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region src/Table/TableFooter.vue
|
|
878
|
+
const _sfc_main$4 = /*@__PURE__*/ defineComponent({
|
|
879
|
+
name: "AstryxTableFooter",
|
|
880
|
+
__name: "TableFooter",
|
|
881
|
+
setup(__props) {
|
|
882
|
+
return (_ctx, _cache) => {
|
|
883
|
+
return openBlock(), createElementBlock("tfoot", null, [renderSlot(_ctx.$slots, "default")]);
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
//#endregion
|
|
888
|
+
//#region src/Table/TableHeader.vue
|
|
889
|
+
const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
890
|
+
name: "AstryxTableHeader",
|
|
891
|
+
__name: "TableHeader",
|
|
892
|
+
setup(__props) {
|
|
893
|
+
return (_ctx, _cache) => {
|
|
894
|
+
return openBlock(), createElementBlock("thead", null, [renderSlot(_ctx.$slots, "default")]);
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
//#endregion
|
|
899
|
+
//#region src/Table/TableHeaderCell.vue
|
|
900
|
+
const _hoisted_1$2 = [
|
|
901
|
+
"data-align",
|
|
902
|
+
"colspan",
|
|
903
|
+
"rowspan"
|
|
904
|
+
];
|
|
905
|
+
const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
906
|
+
name: "AstryxTableHeaderCell",
|
|
907
|
+
__name: "TableHeaderCell",
|
|
908
|
+
props: {
|
|
909
|
+
align: {},
|
|
910
|
+
colSpan: {},
|
|
911
|
+
rowSpan: {},
|
|
912
|
+
headers: {}
|
|
913
|
+
},
|
|
914
|
+
setup(__props) {
|
|
915
|
+
return (_ctx, _cache) => {
|
|
916
|
+
return openBlock(), createElementBlock("th", {
|
|
917
|
+
scope: "col",
|
|
918
|
+
"data-align": __props.align,
|
|
919
|
+
colspan: __props.colSpan,
|
|
920
|
+
rowspan: __props.rowSpan
|
|
921
|
+
}, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_1$2);
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
//#endregion
|
|
926
|
+
//#region src/Table/TableRow.vue
|
|
927
|
+
const _hoisted_1$1 = ["data-header-row"];
|
|
928
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
929
|
+
name: "AstryxTableRow",
|
|
930
|
+
__name: "TableRow",
|
|
931
|
+
props: { isHeaderRow: { type: Boolean } },
|
|
932
|
+
setup(__props) {
|
|
933
|
+
return (_ctx, _cache) => {
|
|
934
|
+
return openBlock(), createElementBlock("tr", { "data-header-row": __props.isHeaderRow || void 0 }, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_1$1);
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region src/Table/TableSelectionToolbar.vue
|
|
940
|
+
const _hoisted_1 = ["aria-label"];
|
|
941
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
942
|
+
name: "AstryxTableSelectionToolbar",
|
|
943
|
+
__name: "TableSelectionToolbar",
|
|
944
|
+
props: { count: {} },
|
|
945
|
+
emits: ["clear"],
|
|
946
|
+
setup(__props, { emit: __emit }) {
|
|
947
|
+
const emit = __emit;
|
|
948
|
+
const messages = useAstryxMessages();
|
|
949
|
+
return (_ctx, _cache) => {
|
|
950
|
+
return openBlock(), createElementBlock("div", {
|
|
951
|
+
class: "astryx-table-selection-toolbar",
|
|
952
|
+
role: "region",
|
|
953
|
+
"aria-label": unref(messages).table.bulkActionsLabel
|
|
954
|
+
}, [
|
|
955
|
+
createElementVNode("span", null, toDisplayString(unref(messages).table.selectedCount(__props.count)), 1),
|
|
956
|
+
renderSlot(_ctx.$slots, "default"),
|
|
957
|
+
createElementVNode("button", {
|
|
958
|
+
type: "button",
|
|
959
|
+
class: "astryx-table__sort",
|
|
960
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("clear"))
|
|
961
|
+
}, toDisplayString(unref(messages).table.clearAll), 1)
|
|
962
|
+
], 8, _hoisted_1);
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
//#endregion
|
|
967
|
+
export { paginateData as C, sortRows as D, resolveColumnWidths as E, generateColumns as S, proportional as T, useTableColumnSettings as _, _sfc_main$4 as a, capitalize as b, _sfc_main$7 as c, useTableSelection as d, useTableSelectionState as f, useTableFiltering as g, useTableFilterState as h, _sfc_main$3 as i, useTableSortable as l, applyTableFilters as m, _sfc_main$1 as n, _sfc_main$5 as o, useTablePagination as p, _sfc_main$2 as r, _sfc_main$6 as s, _sfc_main as t, useTableSortableState as u, useTableColumnSettingsState as v, pixel as w, cellText as x, useTableColumnResize as y };
|