@astryx-vue/core 0.2.0 → 0.2.2
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/dist/AppShell/index.js +1 -1
- package/dist/{AppShell-EiGyPFbA.js → AppShell-Cb41gIAj.js} +2 -2
- package/dist/Avatar/index.d.ts +1 -1
- package/dist/Avatar/index.js +1 -1
- package/dist/Avatar-jmHInHwj.js +244 -0
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/AvatarGroup/index.js +1 -1
- package/dist/{AvatarGroup-CZcgAMjM.js → AvatarGroup-QyzSrpYA.js} +8 -7
- package/dist/Badge/index.d.ts +2 -1
- package/dist/Badge/index.js +1 -1
- package/dist/Badge-CjDQPF5g.js +30 -0
- package/dist/Banner/index.d.ts +1 -1
- package/dist/Breadcrumbs/index.d.ts +2 -2
- package/dist/Breadcrumbs/index.js +1 -1
- package/dist/{Breadcrumbs-C3YZFQ9w.js → Breadcrumbs-CTQ7fjDn.js} +45 -11
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/Calendar/index.d.ts +2 -2
- package/dist/Calendar/index.js +1 -1
- package/dist/Calendar-BFaI5AMv.js +352 -0
- package/dist/Card/index.d.ts +1 -1
- package/dist/Carousel/index.js +1 -1
- package/dist/{Carousel-BTtHkKea.js → Carousel-X0cuQkvg.js} +2 -2
- package/dist/Chat/index.d.ts +2 -2
- package/dist/Chat/index.js +2 -2
- package/dist/Chat-M0tiGrNT.js +3148 -0
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxList/index.d.ts +1 -1
- package/dist/CheckboxList/index.js +1 -1
- package/dist/Citation/index.js +1 -1
- package/dist/{Citation-DijdbUUu.js → Citation-C1veUk5p.js} +2 -2
- package/dist/ClickableCard/index.d.ts +1 -1
- package/dist/Code/index.js +1 -1
- package/dist/{CodeBlock-CxTb6j9_.js → CodeBlock-DesTJAkm.js} +1 -1
- package/dist/Collapsible/index.js +1 -1
- package/dist/{Collapsible-9MC08X39.js → Collapsible-BestK35V.js} +1 -1
- package/dist/CommandPalette/index.js +1 -1
- package/dist/{CommandPalette-BD2iODF5.js → CommandPalette-BArt97V8.js} +1 -1
- package/dist/ComplexSelector/index.d.ts +1 -1
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/{ComplexSelector-D9iXd5cH.js → ComplexSelector-CAoig1RK.js} +2 -2
- package/dist/ContextMenu/index.d.ts +2 -2
- package/dist/ContextMenu/index.js +1 -1
- package/dist/{ContextMenu-HS_WqYIg.js → ContextMenu-9Im6i43E.js} +101 -63
- package/dist/DateInput/index.d.ts +2 -2
- package/dist/DateInput/index.js +1 -1
- package/dist/DateInput-BLocxqC3.js +376 -0
- package/dist/DateRangeInput/index.d.ts +1 -1
- package/dist/DateRangeInput/index.js +1 -1
- package/dist/{DateRangeInput-1bhPGG2s.js → DateRangeInput-DwDy3eRo.js} +2 -2
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.js +1 -1
- package/dist/{DateTimeInput-SnPdgk6P.js → DateTimeInput-BYiaC9bn.js} +5 -3
- package/dist/DropdownMenu/index.d.ts +3 -2
- package/dist/DropdownMenu/index.js +3 -2
- package/dist/DropdownMenu-Ddfr-aEC.js +164 -0
- package/dist/{DropdownMenu-UJGych6v.js → DropdownMenu-Dh-WAHKb.js} +63 -16
- package/dist/FileInput/index.d.ts +1 -1
- package/dist/FileInput/index.js +1 -1
- package/dist/{FileInput-BQiwE-GB.js → FileInput-DLO6V12n.js} +2 -2
- package/dist/Icon/index.d.ts +4 -3
- package/dist/Icon/index.js +3 -2
- package/dist/Icon/plugin.d.ts +45 -0
- package/dist/Icon/plugin.js +177 -0
- package/dist/Icon-CJKjdJy-.js +198 -0
- package/dist/Lightbox/index.js +1 -1
- package/dist/{Lightbox-CshKoB0r.js → Lightbox-CdFCS_EA.js} +2 -2
- package/dist/Link/index.d.ts +1 -1
- package/dist/Link/index.js +1 -1
- package/dist/Link-DqdQZ37C.js +141 -0
- package/dist/Markdown/index.js +1 -1
- package/dist/{Markdown-D-Ua055V.js → Markdown-BqKloI3w.js} +3 -3
- package/dist/MetadataList/index.js +1 -1
- package/dist/{MetadataList-sYph_d8Q.js → MetadataList-CvZkmisf.js} +1 -1
- package/dist/MobileNav/index.js +1 -1
- package/dist/{MobileNavToggle-DD9D01aj.js → MobileNavToggle-Bwi0qXXM.js} +1 -1
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-BVrK5kkk.js → MoreMenu-BwJaJrkB.js} +2 -2
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-DiYov9sF.js → MultiSelector-C-ETfFy_.js} +2 -2
- package/dist/NumberInput/index.d.ts +2 -2
- package/dist/NumberInput/index.js +1 -1
- package/dist/NumberInput-DjetVB8O.js +210 -0
- package/dist/Outline/index.js +1 -1
- package/dist/{Outline-DQfEBxlc.js → Outline-Bz9c-u5y.js} +1 -1
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/OverflowList/index.js +1 -1
- package/dist/{OverflowList-BU5VCntl.js → OverflowList-ED-KN9Y5.js} +1 -1
- package/dist/Overlay/index.d.ts +1 -1
- package/dist/Pagination/index.d.ts +2 -2
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-HdhtykeF.js → Pagination-Cb66HMEf.js} +76 -22
- package/dist/PowerSearch/index.d.ts +2 -0
- package/dist/PowerSearch/index.js +2 -0
- package/dist/PowerSearch-CjU8y4mi.js +2386 -0
- package/dist/ProgressBar/index.d.ts +1 -1
- package/dist/ProgressBar/index.js +1 -1
- package/dist/{ProgressBar-ChDp-7oe.js → ProgressBar-DO9Chic6.js} +31 -11
- package/dist/Radio/index.d.ts +1 -1
- package/dist/RadioList/index.d.ts +1 -1
- package/dist/Resizable/index.d.ts +1 -1
- package/dist/Resizable/index.js +1 -1
- package/dist/{Resizable-BhSMfO5B.js → Resizable-D-TBCg0Y.js} +1 -1
- package/dist/ScrollableArea/index.d.ts +1 -1
- package/dist/SelectableCard/index.d.ts +1 -1
- package/dist/Selector/index.d.ts +2 -2
- package/dist/Selector/index.js +1 -1
- package/dist/Selector-DE2IEFML.js +468 -0
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +1 -1
- package/dist/{SideNav-B-Om6Bz3.js → SideNav-DonEfiAx.js} +17 -17
- package/dist/Stepper/index.js +1 -1
- package/dist/{Stepper-BZ_8SEZt.js → Stepper-D2ZIcUNx.js} +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/TabList/index.d.ts +1 -1
- package/dist/TabList/index.js +1 -1
- package/dist/{TabList-Cnc2Hs1H.js → TabList-D3F-stq-.js} +10 -3
- package/dist/Table/index.d.ts +3 -3
- package/dist/Table/index.js +2 -2
- package/dist/Table-CrP2Uffq.js +1982 -0
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-Cv9UVbzS.js → TextArea-CPwSytdO.js} +12 -6
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/Thumbnail/index.js +1 -1
- package/dist/{Thumbnail-Dc1UpykG.js → Thumbnail-BC5JGPGZ.js} +11 -11
- package/dist/{TimeField-C7t9Knq9.js → TimeField-DpHFrNv0.js} +2 -2
- package/dist/TimeInput/index.d.ts +1 -1
- package/dist/TimeInput/index.js +1 -1
- package/dist/{TimeInput-BXxCOY98.js → TimeInput-DJLV0_4z.js} +1 -1
- package/dist/Timestamp/index.d.ts +1 -1
- package/dist/Timestamp/index.js +2 -1
- package/dist/{Timestamp-DlZSmgCJ.js → Timestamp-GKNjjt5g.js} +4 -121
- package/dist/Toast/index.d.ts +2 -2
- package/dist/Toast/index.js +1 -1
- package/dist/{Toast-BKXPvEMp.js → Toast-C2ML-bmi.js} +37 -7
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/Token/index.js +1 -1
- package/dist/{Token-wt4e80IM.js → Token-Chu_eCVs.js} +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-nmTqdS9n.js → Tokenizer-DRDpvQ_l.js} +3 -3
- 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-notp-mJx.js → TopNav-CEyWddtA.js} +3 -3
- package/dist/TreeList/index.js +1 -1
- package/dist/{TreeList-s1xBQ0qq.js → TreeList-COS8US8e.js} +3 -3
- package/dist/Typeahead/index.js +1 -1
- package/dist/{Typeahead-VAuiCurV.js → Typeahead-P7cCqtaQ.js} +3 -3
- package/dist/{useTypeaheadMenu-Ba7XpcZl.js → TypeaheadMenu-CGvo0Tud.js} +107 -107
- package/dist/composables/index.d.ts +3 -3
- package/dist/{context-Dbo22sck.js → context-CiKncNSH.js} +184 -6
- package/dist/formatInstant-BDWUIxS7.js +119 -0
- package/dist/{index-SMh42NI8.d.ts → index-B1TG2GPS.d.ts} +2 -2
- package/dist/{index-DRmb-oUa.d.ts → index-B9WzWqzk.d.ts} +3 -29
- package/dist/{index-BuubzuE8.d.ts → index-BDZCJ9ri.d.ts} +2 -2
- package/dist/{index-z4p2k9VR.d.ts → index-Bgv4ZmBl.d.ts} +20 -2
- package/dist/{index-BoRIw-bP.d.ts → index-Bt7ewoz2.d.ts} +32 -2
- package/dist/{index-uQrLBZfF.d.ts → index-Bu3oXIIS.d.ts} +24 -0
- package/dist/index-CJlBAXwj.d.ts +100 -0
- package/dist/{index-DT9S92sh.d.ts → index-CNjbOgty.d.ts} +15 -0
- package/dist/{index-DXSs3rwa.d.ts → index-CngORuiq.d.ts} +137 -2
- package/dist/index-Cs5pcwY3.d.ts +416 -0
- package/dist/{index-NzLDrOkk.d.ts → index-D4I_obqR.d.ts} +14 -1
- package/dist/{index-BtPZKO20.d.ts → index-DGXviOlp.d.ts} +49 -7
- package/dist/{index-CTolyeii.d.ts → index-DN7MXPHM.d.ts} +15 -1
- package/dist/{index-C6iJwTL0.d.ts → index-DNRBbwp_.d.ts} +165 -55
- package/dist/{index-C59PdX9L.d.ts → index-DWH_HzXi.d.ts} +1 -1
- package/dist/{index-BfOtLyNH.d.ts → index-D_nYxnNv.d.ts} +1 -1
- package/dist/{index-Bn_odHQ9.d.ts → index-Dg3ZmwEg.d.ts} +12 -1
- package/dist/{index-BiMGXtD-.d.ts → index-DimuSES0.d.ts} +14 -1
- package/dist/{index-DEeJowZf.d.ts → index-cGagYM1g.d.ts} +15 -2
- package/dist/{index-Ck8qy6Rf.d.ts → index-c_TaW8mM.d.ts} +24 -2
- package/dist/index-kVhSuA9t.d.ts +902 -0
- package/dist/{index-1uRMrk63.d.ts → index-nCEmW6wa.d.ts} +1 -1
- package/dist/{index-DoFCm2Q2.d.ts → index-qiZtHnGK.d.ts} +26 -0
- package/dist/{index-Bainr_3n.d.ts → index-u5ozu0G7.d.ts} +2 -2
- package/dist/index.d.ts +79 -76
- package/dist/index.js +111 -100
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/power-search-DrDfcoL1.d.ts +68 -0
- package/dist/registry-B1ObuP--.d.ts +45 -0
- package/dist/registry-C7OZb0PJ.js +135 -0
- package/dist/{types-JktRxujg.d.ts → types-Cp4liug-.d.ts} +66 -3
- package/dist/{index-B8MbfMwV.d.ts → types-DDAAT1Xd.d.ts} +36 -82
- package/dist/types-DIYwbkpe.d.ts +33 -0
- package/dist/{types-DZoEm_DG.d.ts → types-pnljWjEE.d.ts} +23 -6
- package/dist/{useResizable-CeESZS1v.d.ts → useResizable-CUoNPmUw.d.ts} +1 -1
- package/package.json +10 -1
- package/styles/avatar.css +14 -0
- package/styles/badge.css +8 -0
- package/styles/breadcrumbs.css +6 -1
- package/styles/button.css +13 -0
- package/styles/calendar.css +16 -0
- package/styles/card.css +2 -0
- package/styles/chat.css +474 -3
- package/styles/dropdown-menu.css +11 -0
- package/styles/icon.css +58 -8
- package/styles/link.css +5 -0
- package/styles/number-input.css +22 -0
- package/styles/pagination.css +45 -1
- package/styles/power-search.css +303 -0
- package/styles/progress-bar.css +4 -0
- package/styles/selector.css +58 -0
- package/styles/tab-list.css +15 -0
- package/styles/table.css +304 -1
- package/styles/text-area.css +17 -0
- package/styles/text-input.css +5 -0
- package/styles/toast.css +7 -0
- package/styles/toolbar.css +11 -0
- package/styles.css +1 -0
- package/dist/Avatar-5s3HSrtN.js +0 -136
- package/dist/Badge-Ba0EwsTj.js +0 -19
- package/dist/Calendar-BG7wEsro.js +0 -277
- package/dist/Chat-DjNxw5gv.js +0 -1051
- package/dist/DateInput-DE2TN1Rq.js +0 -250
- package/dist/Icon-Dfr4k6-S.js +0 -86
- package/dist/Link-CprjOuTI.js +0 -92
- package/dist/NumberInput-CTYiQxHq.js +0 -147
- package/dist/Selector-Da-2BO3q.js +0 -325
- package/dist/Table-D-LhAy_J.js +0 -967
- package/dist/index-DJo-BmXZ.d.ts +0 -431
- package/dist/index-DtjAdYEc.d.ts +0 -68
- package/dist/{CheckboxList-EsIEXjK_.js → CheckboxList-BbCPiend.js} +1 -1
package/dist/Table-D-LhAy_J.js
DELETED
|
@@ -1,967 +0,0 @@
|
|
|
1
|
-
import { t as _sfc_main$10 } from "./Button-DrqeomlE.js";
|
|
2
|
-
import { a as useAstryxMessages } from "./context-Dbo22sck.js";
|
|
3
|
-
import { t as _sfc_main$11 } from "./IconButton-BNQuz9W_.js";
|
|
4
|
-
import { t as _sfc_main$12 } from "./Icon-Dfr4k6-S.js";
|
|
5
|
-
import { t as _sfc_main$13 } from "./CheckboxInput-CMsEE1_4.js";
|
|
6
|
-
import { t as _sfc_main$14 } from "./Popover-Crhk9PNP.js";
|
|
7
|
-
import { t as _sfc_main$15 } from "./Pagination-HdhtykeF.js";
|
|
8
|
-
import { t as _sfc_main$16 } from "./Selector-Da-2BO3q.js";
|
|
9
|
-
import { t as _sfc_main$17 } from "./TextInput-BasnjVvy.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 };
|