achery-ui 0.5.8 → 0.5.9

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/index.cjs CHANGED
@@ -1065,6 +1065,7 @@ function Table({
1065
1065
  onPageSizeChange,
1066
1066
  pageSizeOptions,
1067
1067
  paginationWindow = 2,
1068
+ height,
1068
1069
  toolbar: toolbar2,
1069
1070
  emptyState: emptyState2,
1070
1071
  className
@@ -1100,81 +1101,88 @@ function Table({
1100
1101
  const totalPages = pageSize && totalRows ? Math.ceil(totalRows / pageSize) : null;
1101
1102
  const isFirstPage = pageIndex === 0;
1102
1103
  const isLastPage = totalPages !== null ? pageIndex >= totalPages - 1 : true;
1103
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: [tableWrapper, className].filter(Boolean).join(" "), children: [
1104
- toolbar2 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: toolbar, children: toolbar2 }),
1105
- /* @__PURE__ */ jsxRuntime.jsx(
1106
- "div",
1107
- {
1108
- className: tableScroll,
1109
- style: pageSize ? { minHeight: 37 + pageSize * 38 } : void 0,
1110
- children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: table, children: [
1111
- /* @__PURE__ */ jsxRuntime.jsx("thead", { className: thead, children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsxs(
1112
- "th",
1104
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1105
+ "div",
1106
+ {
1107
+ className: [tableWrapper, className].filter(Boolean).join(" "),
1108
+ style: height ? { height, display: "flex", flexDirection: "column" } : void 0,
1109
+ children: [
1110
+ toolbar2 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: toolbar, children: toolbar2 }),
1111
+ /* @__PURE__ */ jsxRuntime.jsx(
1112
+ "div",
1113
+ {
1114
+ className: tableScroll,
1115
+ style: height ? { flex: 1, overflowY: "auto", minHeight: 0 } : pageSize ? { minHeight: 37 + pageSize * 38 } : void 0,
1116
+ children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: table, children: [
1117
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { className: thead, children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsxs(
1118
+ "th",
1119
+ {
1120
+ className: col.sortable ? thSortable : th,
1121
+ style: col.width ? { width: col.width } : void 0,
1122
+ onClick: col.sortable ? () => handleSort(col.key) : void 0,
1123
+ "aria-sort": activeSortKey === col.key ? activeSortDir === "asc" ? "ascending" : "descending" : void 0,
1124
+ children: [
1125
+ col.label,
1126
+ col.sortable && activeSortKey === col.key && activeSortDir && /* @__PURE__ */ jsxRuntime.jsx("span", { className: sortIndicator, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(Glyph, { name: activeSortDir === "asc" ? "arrow-up" : "arrow-right", size: 10 }) })
1127
+ ]
1128
+ },
1129
+ col.key
1130
+ )) }) }),
1131
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: data.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: columns.length, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: emptyState, children: emptyState2 ?? "No data." }) }) }) : sortedData.map((row) => {
1132
+ const key = rowKey(row);
1133
+ const isSelected = selectedKeys?.includes(key) ?? false;
1134
+ return /* @__PURE__ */ jsxRuntime.jsx(
1135
+ "tr",
1136
+ {
1137
+ className: tr,
1138
+ "data-selected": isSelected,
1139
+ onClick: onRowClick ? () => onRowClick(key, row) : void 0,
1140
+ style: onRowClick ? { cursor: "pointer" } : void 0,
1141
+ children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: col.mono ? tdMono : td, children: col.render ? col.render(row) : String(row[col.key] ?? "") }, col.key))
1142
+ },
1143
+ key
1144
+ );
1145
+ }) })
1146
+ ] })
1147
+ }
1148
+ ),
1149
+ pageSize && totalPages !== null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: pagination, children: [
1150
+ pageSizeOptions && /* @__PURE__ */ jsxRuntime.jsx(
1151
+ "select",
1113
1152
  {
1114
- className: col.sortable ? thSortable : th,
1115
- style: col.width ? { width: col.width } : void 0,
1116
- onClick: col.sortable ? () => handleSort(col.key) : void 0,
1117
- "aria-sort": activeSortKey === col.key ? activeSortDir === "asc" ? "ascending" : "descending" : void 0,
1118
- children: [
1119
- col.label,
1120
- col.sortable && activeSortKey === col.key && activeSortDir && /* @__PURE__ */ jsxRuntime.jsx("span", { className: sortIndicator, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(Glyph, { name: activeSortDir === "asc" ? "arrow-up" : "arrow-right", size: 10 }) })
1121
- ]
1122
- },
1123
- col.key
1124
- )) }) }),
1125
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: data.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: columns.length, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: emptyState, children: emptyState2 ?? "No data." }) }) }) : sortedData.map((row) => {
1126
- const key = rowKey(row);
1127
- const isSelected = selectedKeys?.includes(key) ?? false;
1128
- return /* @__PURE__ */ jsxRuntime.jsx(
1129
- "tr",
1130
- {
1131
- className: tr,
1132
- "data-selected": isSelected,
1133
- onClick: onRowClick ? () => onRowClick(key, row) : void 0,
1134
- style: onRowClick ? { cursor: "pointer" } : void 0,
1135
- children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: col.mono ? tdMono : td, children: col.render ? col.render(row) : String(row[col.key] ?? "") }, col.key))
1136
- },
1137
- key
1138
- );
1139
- }) })
1153
+ className: pageSizeSelect,
1154
+ value: pageSize,
1155
+ onChange: (e) => onPageSizeChange?.(Number(e.target.value)),
1156
+ "aria-label": "Rows per page",
1157
+ children: pageSizeOptions.map((n) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: n, children: [
1158
+ n,
1159
+ " / page"
1160
+ ] }, n))
1161
+ }
1162
+ ),
1163
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: paginationControls, children: [
1164
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: pageNavButton, onClick: () => onPageChange?.(0), disabled: isFirstPage, "aria-label": "First page", children: "\xAB" }),
1165
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: pageNavButton, onClick: () => onPageChange?.(pageIndex - 1), disabled: isFirstPage, "aria-label": "Previous page", children: "\u2039" }),
1166
+ buildPageWindow(pageIndex, totalPages, paginationWindow).map(
1167
+ (entry, i) => entry === null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: paginationEllipsis, children: "\u2026" }, `ellipsis-${i}`) : /* @__PURE__ */ jsxRuntime.jsx(
1168
+ "button",
1169
+ {
1170
+ className: entry === pageIndex ? pageButtonActive : pageButton,
1171
+ onClick: () => onPageChange?.(entry),
1172
+ "aria-label": `Page ${entry + 1}`,
1173
+ "aria-current": entry === pageIndex ? "page" : void 0,
1174
+ children: entry + 1
1175
+ },
1176
+ entry
1177
+ )
1178
+ ),
1179
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: pageNavButton, onClick: () => onPageChange?.(pageIndex + 1), disabled: isLastPage, "aria-label": "Next page", children: "\u203A" }),
1180
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: pageNavButton, onClick: () => onPageChange?.(totalPages - 1), disabled: isLastPage, "aria-label": "Last page", children: "\xBB" })
1181
+ ] })
1140
1182
  ] })
1141
- }
1142
- ),
1143
- pageSize && totalPages !== null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: pagination, children: [
1144
- pageSizeOptions && /* @__PURE__ */ jsxRuntime.jsx(
1145
- "select",
1146
- {
1147
- className: pageSizeSelect,
1148
- value: pageSize,
1149
- onChange: (e) => onPageSizeChange?.(Number(e.target.value)),
1150
- "aria-label": "Rows per page",
1151
- children: pageSizeOptions.map((n) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: n, children: [
1152
- n,
1153
- " / page"
1154
- ] }, n))
1155
- }
1156
- ),
1157
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: paginationControls, children: [
1158
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: pageNavButton, onClick: () => onPageChange?.(0), disabled: isFirstPage, "aria-label": "First page", children: "\xAB" }),
1159
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: pageNavButton, onClick: () => onPageChange?.(pageIndex - 1), disabled: isFirstPage, "aria-label": "Previous page", children: "\u2039" }),
1160
- buildPageWindow(pageIndex, totalPages, paginationWindow).map(
1161
- (entry, i) => entry === null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: paginationEllipsis, children: "\u2026" }, `ellipsis-${i}`) : /* @__PURE__ */ jsxRuntime.jsx(
1162
- "button",
1163
- {
1164
- className: entry === pageIndex ? pageButtonActive : pageButton,
1165
- onClick: () => onPageChange?.(entry),
1166
- "aria-label": `Page ${entry + 1}`,
1167
- "aria-current": entry === pageIndex ? "page" : void 0,
1168
- children: entry + 1
1169
- },
1170
- entry
1171
- )
1172
- ),
1173
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: pageNavButton, onClick: () => onPageChange?.(pageIndex + 1), disabled: isLastPage, "aria-label": "Next page", children: "\u203A" }),
1174
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: pageNavButton, onClick: () => onPageChange?.(totalPages - 1), disabled: isLastPage, "aria-label": "Last page", children: "\xBB" })
1175
- ] })
1176
- ] })
1177
- ] });
1183
+ ]
1184
+ }
1185
+ );
1178
1186
  }
1179
1187
  var body2 = "Modal_body__1kcb5si8";
1180
1188
  var bodyScrollable = "Modal_bodyScrollable__1kcb5sie";