monobill-mintui 0.3.21 → 0.3.24

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.js CHANGED
@@ -1,5 +1,5 @@
1
- import { g as q } from "./caret-right-DsNN5Epe.js";
2
- class $ extends HTMLElement {
1
+ import { g as $ } from "./caret-right-DsNN5Epe.js";
2
+ class q extends HTMLElement {
3
3
  constructor() {
4
4
  super(), this._darkModeObserver = null;
5
5
  }
@@ -86,7 +86,7 @@ class $ extends HTMLElement {
86
86
  this.innerHTML = o.trim();
87
87
  }
88
88
  }
89
- customElements.get("mint-spinner") || customElements.define("mint-spinner", $);
89
+ customElements.get("mint-spinner") || customElements.define("mint-spinner", q);
90
90
  class O extends HTMLElement {
91
91
  constructor() {
92
92
  super(), this._darkModeObserver = null;
@@ -139,7 +139,7 @@ class O extends HTMLElement {
139
139
  this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "", this.style.backgroundColor = "";
140
140
  return;
141
141
  }
142
- const e = q(t);
142
+ const e = $(t);
143
143
  if (!e) {
144
144
  console.warn(`Icon "${t}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${t}'`), this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "", this.style.backgroundColor = "";
145
145
  return;
@@ -5030,7 +5030,7 @@ class nt extends HTMLElement {
5030
5030
  "border-b",
5031
5031
  "border-gray-200",
5032
5032
  "dark:border-gray-700"
5033
- ]), m && c.classList.add("cursor-pointer", "hover:bg-gray-100", "dark:hover:bg-gray-700", "transition-colors"), d === 0 && c.classList.add("pl-6"), d === o.length - 1 && c.classList.add("pr-6");
5033
+ ]), m && c.classList.add("cursor-pointer", "bg-[#F7F7F7]", "dark:bg-gray-800", "hover:bg-gray-100", "dark:hover:bg-gray-700", "transition-colors"), d === 0 && c.classList.add("pl-6"), d === o.length - 1 && c.classList.add("pr-6");
5034
5034
  });
5035
5035
  }
5036
5036
  const a = t.querySelector("tbody");
@@ -5772,6 +5772,15 @@ class ht extends HTMLElement {
5772
5772
  attributeChangedCallback(t, e, i) {
5773
5773
  t === "configuration" && e !== i && (!this._configuration || typeof i == "string") && (this._parseConfiguration(), this.render());
5774
5774
  }
5775
+ /**
5776
+ * Public method to refresh the table data.
5777
+ * For paginated tables: refreshes the current page.
5778
+ * For loadMore tables: refreshes the entire table from the beginning.
5779
+ * For provided data tables: re-renders the table.
5780
+ */
5781
+ refresh() {
5782
+ this._configuration && (this._type === "ajax" ? this._configuration.loadMore ? (this._offset = 0, this._currentPage = 1, this._rowsToShow = this._perPage, this._rows = [], this._fetchData(void 0, !0, this._perPage, 0)) : this._fetchData(void 0, !0, this._perPage, this._offset) : this.render());
5783
+ }
5775
5784
  _parseConfiguration() {
5776
5785
  const t = this.getAttribute("configuration");
5777
5786
  if (!t) {
@@ -5902,14 +5911,20 @@ class ht extends HTMLElement {
5902
5911
  return this._configuration.loadMore ? t.slice(0, this._rowsToShow) : t.filter((s) => !this._perPage || s.page === this._currentPage);
5903
5912
  }
5904
5913
  _toggleSort(t) {
5914
+ var i;
5905
5915
  if (!this._configuration || !t.data || !t.sortable) return;
5906
5916
  const e = t.data;
5907
- this._sortTimeoutId !== null && (clearTimeout(this._sortTimeoutId), this._sortTimeoutId = null), this._sorting = !0, this._sortingColumn = t, this._updateSortIcons(), this._sortTimeoutId = window.setTimeout(() => {
5908
- var s;
5909
- if (this._sortTimeoutId = null, !this._configuration || !e || !t.sortable) return;
5910
- let i = this._configuration.sort || "asc";
5911
- ((s = this._configuration.sortBy) == null ? void 0 : s.toLowerCase()) === e.toLowerCase() && (i = i === "desc" ? "asc" : "desc"), this._configuration.sort = i, this._configuration.sortBy = e, this._updateSortIcons(), this._type === "ajax" ? (this._offset = 0, this._currentPage = 1, this._configuration.loadMore && (this._rowsToShow = this._perPage), this._fetching = !1, this._loading = !1, this._configuration.loadMore ? this._fetchData(void 0, !1, this._perPage, 0) : this._fetchData(void 0, !1, this._perPage, 0)) : (this._currentPage = 1, this._sorting = !1, this._sortingColumn = null, this._updateSortIcons(), this.render());
5912
- }, 300);
5917
+ if (this._sortTimeoutId !== null && (clearTimeout(this._sortTimeoutId), this._sortTimeoutId = null), this._sorting = !0, this._sortingColumn = t, this._updateSortIcons(), this._type === "ajax")
5918
+ this._sortTimeoutId = window.setTimeout(() => {
5919
+ var n;
5920
+ if (this._sortTimeoutId = null, !this._configuration || !e || !t.sortable) return;
5921
+ let s = this._configuration.sort || "asc";
5922
+ ((n = this._configuration.sortBy) == null ? void 0 : n.toLowerCase()) === e.toLowerCase() && (s = s === "desc" ? "asc" : "desc"), this._configuration.sort = s, this._configuration.sortBy = e, this._updateSortIcons(), this._offset = 0, this._currentPage = 1, this._configuration.loadMore && (this._rowsToShow = this._perPage), this._fetching = !1, this._loading = !1, this._configuration.loadMore ? this._fetchData(void 0, !1, this._perPage, 0) : this._fetchData(void 0, !1, this._perPage, 0);
5923
+ }, 10);
5924
+ else {
5925
+ let s = this._configuration.sort || "asc";
5926
+ ((i = this._configuration.sortBy) == null ? void 0 : i.toLowerCase()) === e.toLowerCase() && (s = s === "desc" ? "asc" : "desc"), this._configuration.sort = s, this._configuration.sortBy = e, this._currentPage = 1, this._sorting = !1, this._sortingColumn = null, this._updateSortIcons(), this.render();
5927
+ }
5913
5928
  }
5914
5929
  _getSortClass(t) {
5915
5930
  var e, i, s, n, r;
@@ -6157,27 +6172,27 @@ class ht extends HTMLElement {
6157
6172
  s += "</div>";
6158
6173
  }
6159
6174
  if (this._type === "ajax" && (!this._loaded || this._fetching || this._loading) && !this._fetchError && !this._sorting) {
6160
- s += '<div class="space-y-0 flex gap-2 flex-col"><div class="h-9 bg-gray-200 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-700 animate-pulse"></div>';
6161
- for (let r = 0; r < 3; r++)
6162
- s += '<div class="h-9 bg-gray-200 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-700 animate-pulse"></div>';
6163
- if (s += "</div>", this._configuration.perPage && !this._configuration.loadMore) {
6164
- if (!this._loaded)
6165
- s += '<div class="flex justify-end ' + (this._inMintCard ? "p-3.5" : "mt-4") + '">', s += "<nav>", s += '<ul class="flex gap-1">', s += '<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>', s += '<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>', s += '<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>', s += '<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>', s += "</ul>", s += "</nav>", s += "</div>";
6166
- else if (i > 1 || this._lastPage > 0) {
6167
- const r = this._lastPage > 0 ? this._lastPage : i;
6168
- if (r > 1) {
6169
- s += '<div class="flex justify-end ' + (this._inMintCard ? "p-3.5" : "mt-4") + '">', s += "<nav>", s += '<ul class="flex gap-1">', s += `<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage === 1 ? 'disabled="true"' : ""} data-action="page-prev"></mint-button></li>`;
6170
- for (let a = 1; a <= Math.min(2, r); a++) {
6175
+ s += '<mint-table class="table-section' + (this._inMintCard ? " rounded-t-none" : "") + '">', s += `<table id="${this._tableId}">`, s += "<thead><tr>", this._configuration.columns.forEach((r, a) => {
6176
+ r.hidden || (s += `<th width="${r.width || ""}" style="${this._getStyle(r)}" class="${this._getClasses(r)}" data-column-key="${a}">`, r.showLabel !== !1 && (s += '<div class="flex items-center">', s += `<div class="flex-1">${r.raw ? r.label : this._escapeHtml(r.label)}</div>`, r.sortable && (s += '<div class="ml-2 flex items-center">', s += '<mint-icon name="" class="w-4 h-4 text-gray-400"></mint-icon>', s += "</div>"), s += "</div>"), s += "</th>");
6177
+ }), s += "</tr></thead>", s += "<tbody>";
6178
+ for (let r = 0; r < this._perPage; r++)
6179
+ s += "<tr>", this._configuration.columns.forEach((a) => {
6180
+ a.hidden || (s += `<td style="${this._getStyle(a)}" class="${this._getClasses(a, !0)}">`, s += '<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div>', s += "</td>");
6181
+ }), s += "</tr>";
6182
+ if (s += "</tbody>", s += "</table>", s += "</mint-table>", this._configuration.perPage && !this._configuration.loadMore && (i > 1 || this._lastPage > 0)) {
6183
+ const r = this._lastPage > 0 ? this._lastPage : i;
6184
+ if (r > 1) {
6185
+ s += '<div class="flex justify-end ' + (this._inMintCard ? "p-3.5" : "mt-4") + '">', s += "<nav>", s += '<ul class="flex gap-1">', s += `<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage === 1 ? 'disabled="true"' : ""} data-action="page-prev"></mint-button></li>`;
6186
+ for (let a = 1; a <= Math.min(2, r); a++) {
6187
+ const o = this._currentPage === a ? ' disabled="true"' : "";
6188
+ s += `<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${a}">${a}</mint-button></li>`;
6189
+ }
6190
+ if (r > 2 && (s += '<li><span class="px-2">...</span></li>'), this._currentPage > 2 && this._currentPage < r - 1 && (s += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage - 1}">${this._currentPage - 1}</mint-button></li>`, s += `<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`, s += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage + 1}">${this._currentPage + 1}</mint-button></li>`), r > 2)
6191
+ for (let a = Math.max(r - 1, this._currentPage + 2); a <= r; a++) {
6171
6192
  const o = this._currentPage === a ? ' disabled="true"' : "";
6172
6193
  s += `<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${a}">${a}</mint-button></li>`;
6173
6194
  }
6174
- if (r > 2 && (s += '<li><span class="px-2">...</span></li>'), this._currentPage > 2 && this._currentPage < r - 1 && (s += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage - 1}">${this._currentPage - 1}</mint-button></li>`, s += `<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`, s += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage + 1}">${this._currentPage + 1}</mint-button></li>`), r > 2)
6175
- for (let a = Math.max(r - 1, this._currentPage + 2); a <= r; a++) {
6176
- const o = this._currentPage === a ? ' disabled="true"' : "";
6177
- s += `<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${a}">${a}</mint-button></li>`;
6178
- }
6179
- s += `<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage >= r ? 'disabled="true"' : ""} data-action="page-next"></mint-button></li>`, s += "</ul>", s += "</nav>", s += "</div>";
6180
- }
6195
+ s += `<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage >= r ? 'disabled="true"' : ""} data-action="page-next"></mint-button></li>`, s += "</ul>", s += "</nav>", s += "</div>";
6181
6196
  }
6182
6197
  }
6183
6198
  } else if (e.length > 0 || this._search.length > 0 || this._searching || this._fetchError) {
@@ -6387,7 +6402,7 @@ export {
6387
6402
  K as Popover,
6388
6403
  ht as ResourceTable,
6389
6404
  it as Select,
6390
- $ as Spinner,
6405
+ q as Spinner,
6391
6406
  V as Stack,
6392
6407
  z as Switch,
6393
6408
  nt as Table,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monobill-mintui",
3
- "version": "0.3.21",
3
+ "version": "0.3.24",
4
4
  "description": "A modern framework-agnostic UI kit built as Web Components. Requires Tailwind CSS.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",