@ac-design/design-system 2.2.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/compat.css +421 -0
- package/dist/lib/components/AcAppSwitcher.vue.d.ts +1 -1
- package/dist/lib/components/AcAppSwitcher.vue_vue_type_script_setup_true_lang.js +23 -23
- package/dist/lib/components/AcAreaChart.vue.d.ts +1 -1
- package/dist/lib/components/AcBarChart.vue.d.ts +1 -1
- package/dist/lib/components/AcButton.vue.d.ts +25 -13
- package/dist/lib/components/AcButton.vue_vue_type_script_setup_true_lang.js +122 -71
- package/dist/lib/components/AcCard.vue.d.ts +11 -5
- package/dist/lib/components/AcCard.vue_vue_type_script_setup_true_lang.js +99 -51
- package/dist/lib/components/AcCellValue.vue.d.ts +3 -3
- package/dist/lib/components/AcCellValue.vue_vue_type_script_setup_true_lang.js +20 -20
- package/dist/lib/components/AcCheckBox.vue.d.ts +4 -1
- package/dist/lib/components/AcCheckBox.vue_vue_type_script_setup_true_lang.js +50 -50
- package/dist/lib/components/AcCircularProgress.vue.d.ts +1 -1
- package/dist/lib/components/AcCodeEditor.vue.d.ts +12 -0
- package/dist/lib/components/AcCodeEditor.vue_vue_type_script_setup_true_lang.js +240 -207
- package/dist/lib/components/AcColorInput.vue.d.ts +4 -4
- package/dist/lib/components/AcColorInput.vue_vue_type_script_setup_true_lang.js +72 -66
- package/dist/lib/components/AcCostSummary.vue.d.ts +1 -1
- package/dist/lib/components/AcDatePicker.vue.d.ts +41 -10
- package/dist/lib/components/AcDatePicker.vue_vue_type_script_setup_true_lang.js +554 -446
- package/dist/lib/components/AcDeleteModal.vue.d.ts +1 -1
- package/dist/lib/components/AcDonutChart.vue.d.ts +2 -2
- package/dist/lib/components/AcDropdown.vue.d.ts +1 -1
- package/dist/lib/components/AcDropdown.vue_vue_type_script_setup_true_lang.js +8 -8
- package/dist/lib/components/AcErrorState.vue.d.ts +1 -1
- package/dist/lib/components/AcFormFooter.vue_vue_type_script_setup_true_lang.js +8 -8
- package/dist/lib/components/AcGraphChart.vue.d.ts +2 -2
- package/dist/lib/components/AcHeader.vue.d.ts +1 -1
- package/dist/lib/components/AcInput.vue.d.ts +86 -44
- package/dist/lib/components/AcInput.vue_vue_type_script_setup_true_lang.js +319 -86
- package/dist/lib/components/AcKeyValueInput.vue.d.ts +34 -54
- package/dist/lib/components/AcKeyValueInput.vue_vue_type_script_setup_true_lang.js +134 -106
- package/dist/lib/components/AcLineChart.vue.d.ts +1 -1
- package/dist/lib/components/AcLocaleSwitcher.vue.d.ts +6 -0
- package/dist/lib/components/AcLocaleSwitcher.vue_vue_type_script_setup_true_lang.js +74 -58
- package/dist/lib/components/AcMapChart.vue.d.ts +2 -2
- package/dist/lib/components/AcModal.vue.d.ts +1 -1
- package/dist/lib/components/AcNavbar.vue.d.ts +2 -0
- package/dist/lib/components/AcNavbar.vue_vue_type_script_setup_true_lang.js +31 -25
- package/dist/lib/components/AcNotificationMenu.vue.d.ts +1 -1
- package/dist/lib/components/AcNotificationMenu.vue_vue_type_script_setup_true_lang.js +24 -24
- package/dist/lib/components/AcNumberInput.vue.d.ts +55 -45
- package/dist/lib/components/AcNumberInput.vue_vue_type_script_setup_true_lang.js +159 -99
- package/dist/lib/components/AcRadioCard.js +5 -0
- package/dist/lib/components/AcRadioCard.vue.d.ts +55 -0
- package/dist/lib/components/AcRadioCard.vue_vue_type_script_setup_true_lang.js +135 -0
- package/dist/lib/components/AcSelect.vue.d.ts +46 -6
- package/dist/lib/components/AcSelect.vue_vue_type_script_setup_true_lang.js +309 -197
- package/dist/lib/components/AcSidePanel.vue.d.ts +1 -1
- package/dist/lib/components/AcSidebar.vue.d.ts +9 -0
- package/dist/lib/components/AcSidebar.vue_vue_type_script_setup_true_lang.js +113 -94
- package/dist/lib/components/AcSidebarSection.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/lib/components/AcSlider.vue.d.ts +2 -2
- package/dist/lib/components/AcSwitch.vue_vue_type_script_setup_true_lang.js +23 -23
- package/dist/lib/components/AcTable.vue.d.ts +50 -5
- package/dist/lib/components/AcTable.vue_vue_type_script_setup_true_lang.js +257 -129
- package/dist/lib/components/AcTagInput.vue.d.ts +23 -4
- package/dist/lib/components/AcTagInput.vue_vue_type_script_setup_true_lang.js +126 -114
- package/dist/lib/components/AcTaintInput.js +5 -0
- package/dist/lib/components/AcTaintInput.vue.d.ts +44 -0
- package/dist/lib/components/AcTaintInput.vue_vue_type_script_setup_true_lang.js +208 -0
- package/dist/lib/components/AcTextarea.vue.d.ts +64 -4
- package/dist/lib/components/AcTextarea.vue_vue_type_script_setup_true_lang.js +159 -68
- package/dist/lib/components/AcThemeMode.vue.d.ts +10 -2
- package/dist/lib/components/AcThemeMode.vue_vue_type_script_setup_true_lang.js +53 -42
- package/dist/lib/components/AcTimePicker.vue.d.ts +36 -11
- package/dist/lib/components/AcTimePicker.vue_vue_type_script_setup_true_lang.js +232 -168
- package/dist/lib/components/AcTooltip.vue.d.ts +3 -3
- package/dist/lib/components/AcUserMenu.vue.d.ts +8 -0
- package/dist/lib/components/AcUserMenu.vue_vue_type_script_setup_true_lang.js +126 -109
- package/dist/lib/components/index.d.ts +2 -0
- package/dist/lib/components/types.d.ts +2 -0
- package/dist/lib/composables/useToast.d.ts +2 -2
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +51 -49
- package/package.json +1 -1
|
@@ -9,9 +9,26 @@ export interface Column {
|
|
|
9
9
|
type?: CellType;
|
|
10
10
|
/** A server-side column descriptor. Shows values with AcCellValue; a row value may be a server cell `{ data, link, color }`. */
|
|
11
11
|
descriptor?: ResourceColumn;
|
|
12
|
+
/** Extra classes for the column's header and cells, e.g. `w-20 lg:w-[120px]` for an actions column. */
|
|
13
|
+
class?: string | string[] | Record<string, boolean>;
|
|
14
|
+
/** Lets cell text wrap onto more lines. Cells stay on one line by default. */
|
|
15
|
+
wrap?: boolean;
|
|
16
|
+
/** Pads the header and cells 8px a side instead of 24px, e.g. for a column of icon buttons. */
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
/** How the table compares values when it sorts this column: `string` (case-insensitive text, as cloud-ui's BasicTable), `number` or `date`. `null` and missing values go last either way. Leave it out for natural text order. */
|
|
19
|
+
sortType?: "string" | "number" | "date";
|
|
20
|
+
/** Row field holding the cell's link, e.g. `"link"`: the value shows as a primary link (a `RouterLink` when the app has vue-router). */
|
|
21
|
+
link?: string;
|
|
22
|
+
/** With `link`, the target used when the row's link field is empty, e.g. `"#"` to keep such names looking and acting as links. Without it they show as plain styled text. */
|
|
23
|
+
linkFallback?: string;
|
|
24
|
+
}
|
|
25
|
+
/** One client-side filter: rows stay when the `key` value contains `searchText`, ignoring case. */
|
|
26
|
+
export interface TableSearch {
|
|
27
|
+
key: string;
|
|
28
|
+
searchText: string;
|
|
12
29
|
}
|
|
13
30
|
export interface Props<R> {
|
|
14
|
-
/** Column definitions: `{ key, label, sortable?, align?, width?, type?, descriptor? }`. `type` or `descriptor` shows values with AcCellValue. */
|
|
31
|
+
/** Column definitions: `{ key, label, sortable?, align?, width?, type?, descriptor?, class?, wrap?, compact? }`. `type` or `descriptor` shows values with AcCellValue. */
|
|
15
32
|
columns: Column[];
|
|
16
33
|
/** Row objects. Each column's `key` is read from the row. */
|
|
17
34
|
rows: R[];
|
|
@@ -35,19 +52,39 @@ export interface Props<R> {
|
|
|
35
52
|
rowActive?: (row: R) => boolean;
|
|
36
53
|
/** Greys a row out: it ignores clicks and its checkbox is disabled. */
|
|
37
54
|
rowDisabled?: (row: R) => boolean;
|
|
55
|
+
/** With `selectable`, decides per row whether it can be chosen. Other rows keep their look, links and clicks; only their checkbox is disabled, and the header checkbox skips them. */
|
|
56
|
+
rowSelectable?: (row: R) => boolean;
|
|
57
|
+
/** Extra classes for a row, e.g. `(row) => ({ "bg-danger/5": row.failed })`. */
|
|
58
|
+
rowClass?: (row: R) => string | string[] | Record<string, boolean>;
|
|
38
59
|
/** The table doesn't reorder rows itself: sort the whole list outside (all pages, or on the server) when `sort` fires or `v-model:sortBy` changes. Headers still show the arrow. */
|
|
39
60
|
manualSort?: boolean;
|
|
40
61
|
/** Drops the table's own frame (border, rounded corners, shadow) so it sits flush inside a card or section that already has one. Without it a table in a card draws a second box. */
|
|
41
62
|
flat?: boolean;
|
|
63
|
+
/** Drops the detail area's padding (24px a side, 16px above and below) and tinted fill, for an `expanded` slot that brings its own. */
|
|
64
|
+
expandedBare?: boolean;
|
|
42
65
|
/** Turns a server cell's link template into a URL, e.g. to fill `${username}` and `${clustername}` from the current route. */
|
|
43
66
|
resolveLink?: (link: string) => string;
|
|
67
|
+
/** Filters rows in the table: a row stays when every entry's `searchText` appears in its `key` value, ignoring case. Rows whose value is `null` or missing drop out, even for an empty `searchText`. */
|
|
68
|
+
search?: TableSearch[];
|
|
69
|
+
/** Splits rows into pages of this size, with a pager under the table once there's more than one page. Bind the page with `v-model:page`. Sorting and `search` work across every page. */
|
|
70
|
+
pageSize?: number;
|
|
71
|
+
/** Pads body cells 12px above and below and lets their text wrap, so rows holding buttons or badges stand 52px tall, as cloud-ui's BasicTable. */
|
|
72
|
+
relaxed?: boolean;
|
|
73
|
+
/** Cuts plain cell text longer than this many characters to that length plus "...", and shows the full value in a tooltip. */
|
|
74
|
+
truncate?: number;
|
|
75
|
+
/** Text for a plain cell whose value is `null` or `""`, e.g. `"-"`. A missing (`undefined`) value stays blank. */
|
|
76
|
+
placeholder?: string;
|
|
77
|
+
/** Which values get the `placeholder`: `empty` (`null` or `""`) or `falsy` (also `0` and `false`, as cloud-ui's BasicTable). A missing (`undefined`) value stays blank either way, and `link` columns never show it. */
|
|
78
|
+
placeholderFor?: "empty" | "falsy";
|
|
44
79
|
}
|
|
45
|
-
declare const __VLS_export: <Row extends Record<string, unknown
|
|
80
|
+
declare const __VLS_export: <Row extends Record<string, unknown>, Key = unknown>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
46
81
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<(Props<Row> & {
|
|
47
82
|
/** `rowKey` values of the chosen rows. Bind with `v-model:selected`. Rows that leave `rows` (another page, a search) stay chosen. */
|
|
48
|
-
selected?:
|
|
83
|
+
selected?: Key[];
|
|
49
84
|
/** `rowKey` values of the rows that are open. Bind with `v-model:expanded`. */
|
|
50
85
|
expanded?: unknown[];
|
|
86
|
+
/** The current page with `page-size`, starting at 1. Bind with `v-model:page`. A search or sort goes back to page 1. */
|
|
87
|
+
page?: number;
|
|
51
88
|
/** The sorted column and direction, or `null`. Bind with `v-model:sortBy` to set it from outside, e.g. to keep it across pages or in the URL. */
|
|
52
89
|
sortBy?: {
|
|
53
90
|
key: string;
|
|
@@ -55,8 +92,9 @@ declare const __VLS_export: <Row extends Record<string, unknown>>(__VLS_props: N
|
|
|
55
92
|
} | null;
|
|
56
93
|
}) & {
|
|
57
94
|
onSort?: ((key: string, mode: "desc" | "asc") => any) | undefined;
|
|
95
|
+
"onUpdate:page"?: ((value: number) => any) | undefined;
|
|
58
96
|
"onRow-click"?: ((row: Row) => any) | undefined;
|
|
59
|
-
"onUpdate:selected"?: ((value:
|
|
97
|
+
"onUpdate:selected"?: ((value: Key[]) => any) | undefined;
|
|
60
98
|
"onUpdate:expanded"?: ((value: unknown[]) => any) | undefined;
|
|
61
99
|
"onUpdate:sortBy"?: ((value: {
|
|
62
100
|
key: string;
|
|
@@ -75,14 +113,21 @@ declare const __VLS_export: <Row extends Record<string, unknown>>(__VLS_props: N
|
|
|
75
113
|
[key: `header-${string}`]: (props: {
|
|
76
114
|
column: Column;
|
|
77
115
|
}) => unknown;
|
|
116
|
+
[key: `before-${string}`]: (props: {
|
|
117
|
+
row: Row;
|
|
118
|
+
}) => unknown;
|
|
78
119
|
/** Detail area under an open row, for tables with `expandable`: `#expanded="{ row }"`. */
|
|
79
120
|
expanded?: (props: {
|
|
80
121
|
row: Row;
|
|
81
122
|
}) => unknown;
|
|
82
123
|
/** Content shown when `rows` is empty. */
|
|
83
124
|
empty?: () => unknown;
|
|
125
|
+
/** Row actions, e.g. edit and delete buttons: `#actions="{ row }"`. Adds a narrow last column, 80px wide (120px from 1024px). */
|
|
126
|
+
actions?: (props: {
|
|
127
|
+
row: Row;
|
|
128
|
+
}) => unknown;
|
|
84
129
|
};
|
|
85
|
-
emit: (((evt: "sort", key: string, mode: "desc" | "asc") => void) & ((evt: "row-click", row: Row) => void)) & (((event: "update:selected", value:
|
|
130
|
+
emit: (((evt: "sort", key: string, mode: "desc" | "asc") => void) & ((evt: "row-click", row: Row) => void)) & (((event: "update:page", value: number) => void) & ((event: "update:selected", value: Key[]) => void) & ((event: "update:expanded", value: unknown[]) => void) & ((event: "update:sortBy", value: {
|
|
86
131
|
key: string;
|
|
87
132
|
mode: "asc" | "desc";
|
|
88
133
|
} | null) => void));
|
|
@@ -1,41 +1,52 @@
|
|
|
1
|
-
import e from "./
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import e from "./AcTooltip.js";
|
|
2
|
+
import t from "./AcCellValue.js";
|
|
3
|
+
import n from "./AcPagination.js";
|
|
4
|
+
import { Fragment as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, getCurrentInstance as f, mergeModels as p, mergeProps as ee, normalizeClass as m, normalizeStyle as h, openBlock as g, renderList as _, renderSlot as v, resolveDynamicComponent as y, toDisplayString as b, unref as x, useId as te, useModel as S, useSlots as ne, watch as re, withCtx as C, withModifiers as w } from "vue";
|
|
5
|
+
import { Check as T, ChevronDown as ie, ChevronRight as ae, ChevronUp as oe, Minus as se } from "@lucide/vue";
|
|
4
6
|
//#region src/lib/components/AcTable.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var
|
|
7
|
+
var ce = { class: "ac-scrollbar" }, le = { class: "w-full border-separate border-spacing-0 text-base" }, ue = { class: "relative flex size-[18px]" }, de = [
|
|
6
8
|
"checked",
|
|
7
9
|
"indeterminate",
|
|
8
10
|
"disabled"
|
|
9
|
-
],
|
|
11
|
+
], fe = ["aria-sort", "onClick"], pe = { class: "inline-flex items-center gap-2" }, me = {
|
|
10
12
|
key: 0,
|
|
11
13
|
class: "h-11 border-b border-border pl-4 [tr:last-child_&]:border-0"
|
|
12
|
-
},
|
|
14
|
+
}, he = {
|
|
13
15
|
key: 1,
|
|
14
16
|
class: "h-11 border-b border-border pl-4 [tr:last-child_&]:border-0"
|
|
15
|
-
},
|
|
17
|
+
}, ge = {
|
|
18
|
+
key: 2,
|
|
19
|
+
class: "h-11 border-b border-border [tr:last-child_&]:border-0"
|
|
20
|
+
}, _e = [
|
|
16
21
|
"aria-current",
|
|
17
22
|
"aria-disabled",
|
|
18
23
|
"onClick"
|
|
19
|
-
],
|
|
24
|
+
], ve = [
|
|
20
25
|
"aria-expanded",
|
|
21
26
|
"aria-controls",
|
|
22
27
|
"aria-label",
|
|
23
28
|
"onClick"
|
|
24
|
-
],
|
|
29
|
+
], ye = { class: "relative flex size-[18px]" }, be = [
|
|
25
30
|
"checked",
|
|
26
31
|
"disabled",
|
|
27
32
|
"aria-label",
|
|
28
33
|
"onChange"
|
|
29
|
-
],
|
|
34
|
+
], xe = {
|
|
35
|
+
key: 2,
|
|
36
|
+
class: "flex min-w-0 items-center"
|
|
37
|
+
}, Se = {
|
|
38
|
+
key: 1,
|
|
39
|
+
class: "block truncate"
|
|
40
|
+
}, Ce = {
|
|
30
41
|
key: 0,
|
|
31
42
|
class: "group",
|
|
32
43
|
"data-testid": "ac-table-detail"
|
|
33
|
-
},
|
|
44
|
+
}, we = ["colspan"], Te = ["id", "aria-label"], Ee = {
|
|
34
45
|
key: 0,
|
|
35
46
|
class: "px-6 py-12 text-center text-muted"
|
|
36
|
-
},
|
|
47
|
+
}, E = "border-border", D = "peer size-[18px] cursor-pointer appearance-none rounded-4 border border-muted/70 bg-background align-middle transition-colors duration-150 hover:border-primary/60 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50", O = /*@__PURE__*/ d({
|
|
37
48
|
__name: "AcTable",
|
|
38
|
-
props: /*@__PURE__*/
|
|
49
|
+
props: /*@__PURE__*/ p({
|
|
39
50
|
columns: {},
|
|
40
51
|
rows: {},
|
|
41
52
|
rowKey: { default: "id" },
|
|
@@ -69,6 +80,14 @@ var ne = { class: "ac-scrollbar" }, re = { class: "w-full border-separate border
|
|
|
69
80
|
type: Function,
|
|
70
81
|
default: void 0
|
|
71
82
|
},
|
|
83
|
+
rowSelectable: {
|
|
84
|
+
type: Function,
|
|
85
|
+
default: void 0
|
|
86
|
+
},
|
|
87
|
+
rowClass: {
|
|
88
|
+
type: Function,
|
|
89
|
+
default: void 0
|
|
90
|
+
},
|
|
72
91
|
manualSort: {
|
|
73
92
|
type: Boolean,
|
|
74
93
|
default: !1
|
|
@@ -77,178 +96,256 @@ var ne = { class: "ac-scrollbar" }, re = { class: "w-full border-separate border
|
|
|
77
96
|
type: Boolean,
|
|
78
97
|
default: !1
|
|
79
98
|
},
|
|
99
|
+
expandedBare: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: !1
|
|
102
|
+
},
|
|
80
103
|
resolveLink: {
|
|
81
104
|
type: Function,
|
|
82
105
|
default: void 0
|
|
83
|
-
}
|
|
106
|
+
},
|
|
107
|
+
search: { default: void 0 },
|
|
108
|
+
pageSize: { default: void 0 },
|
|
109
|
+
relaxed: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: !1
|
|
112
|
+
},
|
|
113
|
+
truncate: { default: void 0 },
|
|
114
|
+
placeholder: { default: "" },
|
|
115
|
+
placeholderFor: { default: "empty" }
|
|
84
116
|
}, {
|
|
85
117
|
selected: { default: () => [] },
|
|
86
118
|
selectedModifiers: {},
|
|
87
119
|
expanded: { default: () => [] },
|
|
88
120
|
expandedModifiers: {},
|
|
121
|
+
page: { default: 1 },
|
|
122
|
+
pageModifiers: {},
|
|
89
123
|
sortBy: { default: null },
|
|
90
124
|
sortByModifiers: {}
|
|
91
125
|
}),
|
|
92
|
-
emits: /*@__PURE__*/
|
|
126
|
+
emits: /*@__PURE__*/ p(["row-click", "sort"], [
|
|
93
127
|
"update:selected",
|
|
94
128
|
"update:expanded",
|
|
129
|
+
"update:page",
|
|
95
130
|
"update:sortBy"
|
|
96
131
|
]),
|
|
97
|
-
setup(
|
|
98
|
-
let
|
|
132
|
+
setup(d, { emit: p }) {
|
|
133
|
+
let O = d, k = S(d, "selected"), A = S(d, "expanded"), j = S(d, "page"), M = p, N = ne(), P = f()?.appContext.components.RouterLink, De = te(), F = S(d, "sortBy"), I = i(() => F.value?.key ?? ""), L = i(() => F.value?.mode ?? "asc"), Oe = (e) => {
|
|
99
134
|
if (!e.sortable) return;
|
|
100
|
-
let t =
|
|
101
|
-
|
|
135
|
+
let t = I.value === e.key && L.value === "asc" ? "desc" : "asc";
|
|
136
|
+
F.value = {
|
|
102
137
|
key: e.key,
|
|
103
138
|
mode: t
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
139
|
+
}, M("sort", e.key, t);
|
|
140
|
+
}, R = i(() => {
|
|
141
|
+
let e = O.search ?? [];
|
|
142
|
+
return e.length ? O.rows.filter((t) => e.every((e) => {
|
|
143
|
+
let n = W(t[e.key]);
|
|
144
|
+
return n != null && String(n).toLowerCase().includes(e.searchText.toLowerCase());
|
|
145
|
+
})) : O.rows;
|
|
146
|
+
}), z = i(() => {
|
|
147
|
+
if (!I.value || O.manualSort) return R.value;
|
|
148
|
+
let e = I.value, t = L.value === "asc" ? 1 : -1, n = O.columns.find((t) => t.key === e)?.sortType;
|
|
149
|
+
return n ? [...R.value].sort((r, i) => {
|
|
150
|
+
let a = W(r[e]), o = W(i[e]);
|
|
151
|
+
return a == null ? 1 : o == null ? -1 : Ae(a, o, n) * t;
|
|
152
|
+
}) : [...R.value].sort((n, r) => String(W(n[e]) ?? "").localeCompare(String(W(r[e]) ?? ""), void 0, { numeric: !0 }) * t);
|
|
153
|
+
}), B = i(() => O.pageSize ? Math.max(1, Math.ceil(z.value.length / O.pageSize)) : 1), V = i(() => Math.min(Math.max(1, j.value), B.value)), H = i(() => {
|
|
154
|
+
if (!O.pageSize) return z.value;
|
|
155
|
+
let e = (V.value - 1) * O.pageSize;
|
|
156
|
+
return z.value.slice(e, e + O.pageSize);
|
|
109
157
|
});
|
|
110
|
-
function
|
|
158
|
+
function U(e) {
|
|
111
159
|
return typeof e == "object" && !!e && !Array.isArray(e) && "data" in e;
|
|
112
160
|
}
|
|
113
|
-
function
|
|
114
|
-
return
|
|
161
|
+
function W(e) {
|
|
162
|
+
return U(e) ? e.sort ?? e.data : e;
|
|
163
|
+
}
|
|
164
|
+
function ke(e) {
|
|
165
|
+
return O.placeholderFor === "falsy" ? !e : e === null || e === "";
|
|
166
|
+
}
|
|
167
|
+
function Ae(e, t, n) {
|
|
168
|
+
return n === "number" ? Number(e) - Number(t) : n === "date" ? new Date(String(e)).getTime() - new Date(String(t)).getTime() : String(e).toLowerCase().localeCompare(String(t).toLowerCase());
|
|
115
169
|
}
|
|
116
|
-
let
|
|
117
|
-
function
|
|
118
|
-
let e = new Set(
|
|
119
|
-
|
|
170
|
+
let G = (e) => !!O.rowDisabled?.(e), je = (e) => !G(e) && (!O.rowSelectable || O.rowSelectable(e)), K = i(() => H.value.filter(je).map((e) => e[O.rowKey])), q = i(() => new Set(k.value)), J = i(() => K.value.length > 0 && K.value.every((e) => q.value.has(e))), Me = i(() => !J.value && K.value.some((e) => q.value.has(e)));
|
|
171
|
+
function Ne() {
|
|
172
|
+
let e = new Set(K.value);
|
|
173
|
+
k.value = J.value ? k.value.filter((t) => !e.has(t)) : [...k.value, ...K.value.filter((e) => !q.value.has(e))];
|
|
120
174
|
}
|
|
121
|
-
function
|
|
122
|
-
let t = e[
|
|
123
|
-
|
|
175
|
+
function Pe(e) {
|
|
176
|
+
let t = e[O.rowKey];
|
|
177
|
+
k.value = q.value.has(t) ? k.value.filter((e) => e !== t) : [...k.value, t];
|
|
124
178
|
}
|
|
125
|
-
let
|
|
126
|
-
function
|
|
127
|
-
let t = e[
|
|
128
|
-
|
|
179
|
+
let Fe = i(() => new Set(A.value)), Y = (e) => O.expandable && Fe.value.has(e[O.rowKey]), Ie = (e) => !O.canExpand || O.canExpand(e), Le = (e) => `${De}-detail-${String(e[O.rowKey])}`, X = i(() => !!N.actions), Re = i(() => O.columns.length + +!!O.selectable + +!!O.expandable + +!!X.value);
|
|
180
|
+
function ze(e) {
|
|
181
|
+
let t = e[O.rowKey];
|
|
182
|
+
A.value = Fe.value.has(t) ? A.value.filter((e) => e !== t) : [...A.value, t];
|
|
129
183
|
}
|
|
130
|
-
function
|
|
131
|
-
let t = e[
|
|
132
|
-
return typeof n == "string" || typeof n == "number" ? n : String(e[
|
|
184
|
+
function Z(e) {
|
|
185
|
+
let t = e[O.columns[0]?.key ?? ""], n = U(t) ? t.data : t;
|
|
186
|
+
return typeof n == "string" || typeof n == "number" ? n : String(e[O.rowKey]);
|
|
133
187
|
}
|
|
134
|
-
let
|
|
188
|
+
let Be = i(() => O.expandable ? "py-3 [tbody_&]:h-[51px]" : "py-3"), Ve = (e) => e.wrap ?? O.relaxed ? "whitespace-normal" : "whitespace-nowrap";
|
|
189
|
+
function He(e) {
|
|
190
|
+
return !!(e.link || O.truncate || O.placeholder || N[`before-${e.key}`]);
|
|
191
|
+
}
|
|
192
|
+
function Ue(e) {
|
|
193
|
+
let t = String(e ?? "");
|
|
194
|
+
return O.truncate && t.length > O.truncate ? `${t.slice(0, O.truncate)}...` : t;
|
|
195
|
+
}
|
|
196
|
+
function We(e, t) {
|
|
197
|
+
let n = e[t.link] || t.linkFallback;
|
|
198
|
+
return typeof n != "string" || !n ? {
|
|
199
|
+
is: "span",
|
|
200
|
+
attrs: {}
|
|
201
|
+
} : P && !/^https?:/.test(n) ? {
|
|
202
|
+
is: P,
|
|
203
|
+
attrs: { to: n }
|
|
204
|
+
} : {
|
|
205
|
+
is: "a",
|
|
206
|
+
attrs: { href: n }
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
let Ge = i(() => ["overflow-hidden bg-surface", !O.flat && "rounded-10 border border-border"]), Q = (e) => ({
|
|
135
210
|
left: "text-left",
|
|
136
211
|
center: "text-center",
|
|
137
212
|
right: "text-right"
|
|
138
|
-
})[e.align ?? "left"];
|
|
139
|
-
return (
|
|
140
|
-
|
|
213
|
+
})[e.align ?? "left"], $ = (e) => e.compact ? "px-2" : "px-6";
|
|
214
|
+
return re(() => `${JSON.stringify(O.search?.map((e) => [e.key, e.searchText]) ?? [])}|${I.value}|${L.value}`, () => {
|
|
215
|
+
O.pageSize && (j.value = 1);
|
|
216
|
+
}), (i, f) => (g(), s("div", {
|
|
217
|
+
class: m(["w-full", !d.pageSize && Ge.value]),
|
|
141
218
|
"data-ac-ds": "",
|
|
142
219
|
"data-testid": "ac-table"
|
|
143
|
-
}, [
|
|
144
|
-
|
|
220
|
+
}, [c("div", { class: m(!!d.pageSize && Ge.value) }, [c("div", ce, [c("table", le, [c("thead", null, [c("tr", null, [
|
|
221
|
+
d.expandable ? (g(), s("th", {
|
|
145
222
|
key: 0,
|
|
146
223
|
scope: "col",
|
|
147
|
-
class:
|
|
148
|
-
}, [...
|
|
149
|
-
|
|
224
|
+
class: m(["h-11 w-10 border-b bg-surface-sunken/50 pr-0 pl-4", [E, !d.flat && "first:rounded-tl-10"]])
|
|
225
|
+
}, [...f[4] ||= [c("span", { class: "sr-only" }, "Expand", -1)]], 2)) : o("", !0),
|
|
226
|
+
d.selectable ? (g(), s("th", {
|
|
150
227
|
key: 1,
|
|
151
228
|
scope: "col",
|
|
152
|
-
class:
|
|
153
|
-
}, [
|
|
229
|
+
class: m(["h-11 w-10 border-b bg-surface-sunken/50 pr-1 pl-4", [E, !d.flat && "first:rounded-tl-10"]])
|
|
230
|
+
}, [c("span", ue, [c("input", {
|
|
154
231
|
type: "checkbox",
|
|
155
|
-
class:
|
|
156
|
-
checked:
|
|
157
|
-
indeterminate:
|
|
158
|
-
disabled:
|
|
232
|
+
class: m(D),
|
|
233
|
+
checked: J.value,
|
|
234
|
+
indeterminate: Me.value,
|
|
235
|
+
disabled: d.loading || !K.value.length,
|
|
159
236
|
"aria-label": "Select all rows",
|
|
160
|
-
onChange:
|
|
161
|
-
}, null, 40,
|
|
237
|
+
onChange: Ne
|
|
238
|
+
}, null, 40, de), (g(), a(y(Me.value ? x(se) : x(T)), {
|
|
162
239
|
class: "pointer-events-none absolute inset-0 m-auto size-3.5 text-white opacity-0 peer-checked:opacity-100 peer-indeterminate:opacity-100",
|
|
163
240
|
"stroke-width": 3,
|
|
164
241
|
"aria-hidden": "true"
|
|
165
|
-
}))])], 2)) :
|
|
166
|
-
(
|
|
242
|
+
}))])], 2)) : o("", !0),
|
|
243
|
+
(g(!0), s(r, null, _(d.columns, (e) => (g(), s("th", {
|
|
167
244
|
key: e.key,
|
|
168
245
|
scope: "col",
|
|
169
|
-
class:
|
|
170
|
-
|
|
171
|
-
!
|
|
246
|
+
class: m(["h-11 border-b bg-surface-sunken/50 text-base font-semibold whitespace-nowrap text-muted", [
|
|
247
|
+
E,
|
|
248
|
+
!d.flat && "first:rounded-tl-10 last:rounded-tr-10",
|
|
172
249
|
$(e),
|
|
250
|
+
Q(e),
|
|
251
|
+
d.relaxed && "py-3",
|
|
252
|
+
e.class,
|
|
173
253
|
e.sortable && "cursor-pointer select-none transition-colors hover:text-heading"
|
|
174
254
|
]]),
|
|
175
|
-
style:
|
|
176
|
-
"aria-sort":
|
|
177
|
-
onClick: (t) =>
|
|
178
|
-
}, [
|
|
255
|
+
style: h(e.width ? { width: e.width } : void 0),
|
|
256
|
+
"aria-sort": I.value === e.key ? L.value === "asc" ? "ascending" : "descending" : void 0,
|
|
257
|
+
onClick: (t) => Oe(e)
|
|
258
|
+
}, [c("span", pe, [v(i.$slots, `header-${e.key}`, { column: e }, () => [l(b(e.label), 1)]), e.sortable ? (g(), a(y(I.value === e.key && L.value === "asc" ? x(oe) : x(ie)), {
|
|
179
259
|
key: 0,
|
|
180
|
-
class:
|
|
260
|
+
class: m(["size-4 shrink-0", I.value === e.key ? "text-primary-strong" : "text-muted"]),
|
|
181
261
|
"aria-hidden": "true"
|
|
182
|
-
}, null, 8, ["class"])) :
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
262
|
+
}, null, 8, ["class"])) : o("", !0)])], 14, fe))), 128)),
|
|
263
|
+
X.value ? (g(), s("th", {
|
|
264
|
+
key: 2,
|
|
265
|
+
scope: "col",
|
|
266
|
+
class: m(["h-11 w-20 border-b bg-surface-sunken/50 px-2 lg:w-[120px]", [
|
|
267
|
+
E,
|
|
268
|
+
!d.flat && "last:rounded-tr-10",
|
|
269
|
+
d.relaxed && "py-3"
|
|
270
|
+
]])
|
|
271
|
+
}, [...f[5] ||= [c("span", { class: "sr-only" }, "Actions", -1)]], 2)) : o("", !0)
|
|
272
|
+
])]), c("tbody", null, [d.loading ? (g(!0), s(r, { key: 0 }, _(d.loaderRows, (e) => (g(), s("tr", { key: `loader-${e}` }, [
|
|
273
|
+
d.expandable ? (g(), s("td", me)) : o("", !0),
|
|
274
|
+
d.selectable ? (g(), s("td", he)) : o("", !0),
|
|
275
|
+
(g(!0), s(r, null, _(d.columns, (t, n) => (g(), s("td", {
|
|
187
276
|
key: t.key,
|
|
188
|
-
class: "h-11 border-b border-border
|
|
189
|
-
}, [
|
|
277
|
+
class: m(["h-11 border-b border-border [tr:last-child_&]:border-0", [$(t), t.class]])
|
|
278
|
+
}, [c("span", {
|
|
190
279
|
class: "block h-2.5 animate-pulse rounded-full bg-surface-sunken",
|
|
191
|
-
style:
|
|
192
|
-
}, null, 4)]))), 128))
|
|
193
|
-
|
|
280
|
+
style: h({ width: `${50 + (e * 17 + n * 23) % 40}%` })
|
|
281
|
+
}, null, 4)], 2))), 128)),
|
|
282
|
+
X.value ? (g(), s("td", ge)) : o("", !0)
|
|
283
|
+
]))), 128)) : (g(!0), s(r, { key: 1 }, _(H.value, (n, p) => (g(), s(r, { key: String(n[d.rowKey] ?? p) }, [c("tr", {
|
|
194
284
|
"data-testid": "ac-table-row",
|
|
195
|
-
class:
|
|
196
|
-
|
|
197
|
-
(
|
|
198
|
-
|
|
199
|
-
|
|
285
|
+
class: m(["group transition-colors duration-150", [
|
|
286
|
+
d.clickable && "cursor-pointer hover:bg-surface-sunken/40",
|
|
287
|
+
(d.rowActive?.(n) || d.selectable && q.value.has(n[d.rowKey])) && "bg-primary/5",
|
|
288
|
+
d.rowActive?.(n) && "shadow-[inset_0_0_0_1px_var(--color-primary)]",
|
|
289
|
+
G(n) && "pointer-events-none cursor-not-allowed opacity-50",
|
|
290
|
+
d.rowClass?.(n)
|
|
200
291
|
]]),
|
|
201
|
-
"aria-current":
|
|
202
|
-
"aria-disabled":
|
|
203
|
-
onClick: (e) =>
|
|
292
|
+
"aria-current": d.rowActive?.(n) ? "true" : void 0,
|
|
293
|
+
"aria-disabled": G(n) || void 0,
|
|
294
|
+
onClick: (e) => d.clickable && !G(n) && M("row-click", n)
|
|
204
295
|
}, [
|
|
205
|
-
|
|
296
|
+
d.expandable ? (g(), s("td", {
|
|
206
297
|
key: 0,
|
|
207
298
|
class: "h-11 w-10 border-b border-border pr-0 pl-4 group-last:border-0",
|
|
208
|
-
onClick:
|
|
209
|
-
}, [
|
|
299
|
+
onClick: f[0] ||= w(() => {}, ["stop"])
|
|
300
|
+
}, [Ie(n) ? (g(), s("button", {
|
|
210
301
|
key: 0,
|
|
211
302
|
type: "button",
|
|
212
303
|
class: "inline-flex size-7 cursor-pointer items-center justify-center rounded-8 text-muted transition-colors hover:bg-surface-sunken hover:text-heading focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
213
|
-
"aria-expanded": Y(
|
|
214
|
-
"aria-controls":
|
|
215
|
-
"aria-label": `${Y(
|
|
304
|
+
"aria-expanded": Y(n),
|
|
305
|
+
"aria-controls": Le(n),
|
|
306
|
+
"aria-label": `${Y(n) ? "Collapse" : "Expand"} ${Z(n)}`,
|
|
216
307
|
"data-testid": "ac-table-expand",
|
|
217
|
-
onClick: (e) =>
|
|
218
|
-
}, [
|
|
219
|
-
class:
|
|
308
|
+
onClick: (e) => ze(n)
|
|
309
|
+
}, [u(x(ae), {
|
|
310
|
+
class: m(["size-4 transition-transform duration-150 motion-reduce:transition-none", Y(n) && "rotate-90"]),
|
|
220
311
|
"aria-hidden": "true"
|
|
221
|
-
}, null, 8, ["class"])], 8,
|
|
222
|
-
|
|
312
|
+
}, null, 8, ["class"])], 8, ve)) : o("", !0)])) : o("", !0),
|
|
313
|
+
d.selectable ? (g(), s("td", {
|
|
223
314
|
key: 1,
|
|
224
315
|
class: "h-11 w-10 border-b border-border pr-1 pl-4 group-last:border-0",
|
|
225
|
-
onClick:
|
|
226
|
-
}, [
|
|
316
|
+
onClick: f[1] ||= w(() => {}, ["stop"])
|
|
317
|
+
}, [c("span", ye, [c("input", {
|
|
227
318
|
type: "checkbox",
|
|
228
|
-
class:
|
|
229
|
-
checked:
|
|
230
|
-
disabled:
|
|
231
|
-
"aria-label": `Select ${
|
|
232
|
-
onChange: (e) =>
|
|
233
|
-
}, null, 40,
|
|
319
|
+
class: m(D),
|
|
320
|
+
checked: q.value.has(n[d.rowKey]),
|
|
321
|
+
disabled: !je(n),
|
|
322
|
+
"aria-label": `Select ${Z(n)}`,
|
|
323
|
+
onChange: (e) => Pe(n)
|
|
324
|
+
}, null, 40, be), u(x(T), {
|
|
234
325
|
class: "pointer-events-none absolute inset-0 m-auto size-3.5 text-white opacity-0 peer-checked:opacity-100",
|
|
235
326
|
"stroke-width": 3,
|
|
236
327
|
"aria-hidden": "true"
|
|
237
|
-
})])])) :
|
|
238
|
-
(
|
|
239
|
-
key:
|
|
240
|
-
class:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
328
|
+
})])])) : o("", !0),
|
|
329
|
+
(g(!0), s(r, null, _(d.columns, (o) => (g(), s("td", {
|
|
330
|
+
key: o.key,
|
|
331
|
+
class: m(["h-11 border-b border-border text-body tabular-nums group-last:border-0", [
|
|
332
|
+
$(o),
|
|
333
|
+
Ve(o),
|
|
334
|
+
d.relaxed && Be.value,
|
|
335
|
+
Q(o),
|
|
336
|
+
o.class
|
|
337
|
+
]])
|
|
338
|
+
}, [v(i.$slots, `cell-${o.key}`, {
|
|
339
|
+
row: n,
|
|
340
|
+
value: n[o.key]
|
|
341
|
+
}, () => [o.type || o.descriptor ? (g(), a(t, {
|
|
245
342
|
key: 0,
|
|
246
|
-
value:
|
|
247
|
-
cell:
|
|
248
|
-
column:
|
|
249
|
-
type:
|
|
250
|
-
title:
|
|
251
|
-
"resolve-link":
|
|
343
|
+
value: U(n[o.key]) ? void 0 : n[o.key],
|
|
344
|
+
cell: U(n[o.key]) ? n[o.key] : void 0,
|
|
345
|
+
column: o.descriptor,
|
|
346
|
+
type: o.type,
|
|
347
|
+
title: o.label,
|
|
348
|
+
"resolve-link": d.resolveLink
|
|
252
349
|
}, null, 8, [
|
|
253
350
|
"value",
|
|
254
351
|
"cell",
|
|
@@ -256,17 +353,48 @@ var ne = { class: "ac-scrollbar" }, re = { class: "w-full border-separate border
|
|
|
256
353
|
"type",
|
|
257
354
|
"title",
|
|
258
355
|
"resolve-link"
|
|
259
|
-
])) : (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
356
|
+
])) : He(o) && n[o.key] === void 0 ? (g(), s(r, { key: 1 }, [], 64)) : He(o) ? (g(), s("span", xe, [v(i.$slots, `before-${o.key}`, { row: n }), !o.link && ke(n[o.key]) ? (g(), s(r, { key: 0 }, [l(b(d.placeholder), 1)], 64)) : (g(), a(e, {
|
|
357
|
+
key: 1,
|
|
358
|
+
content: String(n[o.key]),
|
|
359
|
+
disabled: !d.truncate,
|
|
360
|
+
placement: "top"
|
|
361
|
+
}, {
|
|
362
|
+
default: C(() => [o.link ? (g(), a(y(We(n, o).is), ee({
|
|
363
|
+
key: 0,
|
|
364
|
+
ref_for: !0
|
|
365
|
+
}, We(n, o).attrs, { class: "cursor-pointer truncate font-medium text-primary-strong no-underline hover:underline" }), {
|
|
366
|
+
default: C(() => [l(b(Ue(n[o.key])), 1)]),
|
|
367
|
+
_: 2
|
|
368
|
+
}, 1040)) : (g(), s("span", Se, b(Ue(n[o.key])), 1))]),
|
|
369
|
+
_: 2
|
|
370
|
+
}, 1032, ["content", "disabled"]))])) : (g(), s(r, { key: 3 }, [l(b(n[o.key]), 1)], 64))])], 2))), 128)),
|
|
371
|
+
X.value ? (g(), s("td", {
|
|
372
|
+
key: 2,
|
|
373
|
+
class: m(["h-11 w-20 border-b border-border px-2 group-last:border-0 lg:w-[120px]", d.relaxed ? [Be.value, "whitespace-normal"] : "whitespace-nowrap"]),
|
|
374
|
+
onClick: f[2] ||= w(() => {}, ["stop"])
|
|
375
|
+
}, [v(i.$slots, "actions", { row: n })], 2)) : o("", !0)
|
|
376
|
+
], 10, _e), Y(n) && Ie(n) ? (g(), s("tr", Ce, [c("td", {
|
|
377
|
+
colspan: Re.value,
|
|
378
|
+
class: m(["border-b border-border p-0 group-last:border-0", !d.expandedBare && "bg-surface-muted"])
|
|
379
|
+
}, [c("div", {
|
|
380
|
+
id: Le(n),
|
|
265
381
|
role: "region",
|
|
266
|
-
"aria-label": `Details for ${
|
|
267
|
-
class: "px-6 py-4
|
|
268
|
-
}, [
|
|
382
|
+
"aria-label": `Details for ${Z(n)}`,
|
|
383
|
+
class: m(["text-body", !d.expandedBare && "px-6 py-4"])
|
|
384
|
+
}, [v(i.$slots, "expanded", { row: n })], 10, Te)], 10, we)])) : o("", !0)], 64))), 128))])])]), !d.loading && !z.value.length ? (g(), s("div", Ee, [v(i.$slots, "empty", {}, () => [l(b(d.emptyText), 1)])])) : o("", !0)], 2), d.pageSize && B.value > 1 && !d.loading ? (g(), a(n, {
|
|
385
|
+
key: 0,
|
|
386
|
+
page: V.value,
|
|
387
|
+
"page-size": d.pageSize,
|
|
388
|
+
total: z.value.length,
|
|
389
|
+
"hide-page-size": "",
|
|
390
|
+
class: "border-t border-border px-6 py-4",
|
|
391
|
+
"onUpdate:page": f[3] ||= (e) => j.value = e
|
|
392
|
+
}, null, 8, [
|
|
393
|
+
"page",
|
|
394
|
+
"page-size",
|
|
395
|
+
"total"
|
|
396
|
+
])) : o("", !0)], 2));
|
|
269
397
|
}
|
|
270
398
|
});
|
|
271
399
|
//#endregion
|
|
272
|
-
export {
|
|
400
|
+
export { O as default };
|