pam-grid 1.1.1 → 1.2.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/index.mjs CHANGED
@@ -17,6 +17,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
17
17
  function PamDropdown({
18
18
  trigger,
19
19
  items,
20
+ title,
20
21
  placement = "bottom-start",
21
22
  offset = 6,
22
23
  disabled = false,
@@ -118,7 +119,7 @@ function PamDropdown({
118
119
  return /* @__PURE__ */ jsxs(Fragment, { children: [
119
120
  /* @__PURE__ */ jsx("span", { ref: triggerRef, className: `pam-dropdown-trigger ${className}`, children: /* @__PURE__ */ jsx("span", { onClick: toggle, style: { display: "inline-flex" }, children: trigger }) }),
120
121
  open && createPortal(
121
- /* @__PURE__ */ jsx(
122
+ /* @__PURE__ */ jsxs(
122
123
  "div",
123
124
  {
124
125
  ref: menuRef,
@@ -127,17 +128,20 @@ function PamDropdown({
127
128
  top: pos.top,
128
129
  left: pos.left
129
130
  },
130
- children: /* @__PURE__ */ jsx(
131
- PamDropdownList,
132
- {
133
- items,
134
- closeOnItemClick,
135
- onClose: close,
136
- openSubKeys,
137
- setOpenSubKeys,
138
- level: 0
139
- }
140
- )
131
+ children: [
132
+ title && /* @__PURE__ */ jsx("div", { className: "pam-dropdown-title", children: title }),
133
+ /* @__PURE__ */ jsx("div", { className: "pam-list-wrapper", children: /* @__PURE__ */ jsx(
134
+ PamDropdownList,
135
+ {
136
+ items,
137
+ closeOnItemClick,
138
+ onClose: close,
139
+ openSubKeys,
140
+ setOpenSubKeys,
141
+ level: 0
142
+ }
143
+ ) })
144
+ ]
141
145
  }
142
146
  ),
143
147
  portalRoot
@@ -573,62 +577,71 @@ var FacetFilter = ({
573
577
  if (facetLoading?.[columnKey]) {
574
578
  return /* @__PURE__ */ jsx3("div", { className: "p-3 text-center", children: /* @__PURE__ */ jsx3("p", { className: "text-secondary", children: "Loading..." }) });
575
579
  }
576
- return /* @__PURE__ */ jsxs3("div", { className: "pam-grid-facet-filter", style: { width: 240 }, children: [
577
- /* @__PURE__ */ jsx3("div", { className: "mb-2", children: /* @__PURE__ */ jsx3(
578
- "input",
579
- {
580
- type: "search",
581
- className: "form-control form-control-sm",
582
- placeholder: "Search...",
583
- value: search,
584
- onChange: (e) => setSearch(e.target.value)
585
- }
586
- ) }),
587
- /* @__PURE__ */ jsxs3(
588
- "div",
589
- {
590
- className: "list-group list-group-flush text-truncate",
591
- style: {
592
- maxHeight: 220,
593
- overflowY: "auto"
594
- },
595
- children: [
596
- filteredItems.map((item) => {
597
- const checked = selected.some((s) => s.id === item.id);
598
- return /* @__PURE__ */ jsxs3(
599
- "label",
600
- {
601
- className: "list-group-item list-group-item-action d-flex align-items-center gap-2 py-2",
602
- children: [
603
- /* @__PURE__ */ jsx3(
604
- "input",
605
- {
606
- type: "checkbox",
607
- className: "form-check-input mt-0",
608
- checked,
609
- onChange: () => toggleFacetFilter(columnKey, item)
610
- }
611
- ),
612
- /* @__PURE__ */ jsx3("span", { className: "flex-grow-1", children: item.name }),
613
- checked && /* @__PURE__ */ jsx3("i", { className: "bx bx-check text-primary" })
614
- ]
615
- },
616
- item.id
617
- );
618
- }),
619
- !filteredItems.length && /* @__PURE__ */ jsx3("div", { className: "text-center text-muted py-3 small", children: "No results" })
620
- ]
621
- }
622
- ),
623
- selected.length > 0 && /* @__PURE__ */ jsx3("div", { className: "pt-2 border-top mt-2 d-flex justify-content-end", children: /* @__PURE__ */ jsx3(
624
- "button",
625
- {
626
- className: "btn btn-sm btn-label-secondary",
627
- onClick: clearFacetFilters,
628
- children: "Clear"
629
- }
630
- ) })
631
- ] });
580
+ return /* @__PURE__ */ jsxs3(
581
+ "div",
582
+ {
583
+ className: "pam-grid-facet-filter",
584
+ style: { width: 240 },
585
+ onClick: (e) => e.stopPropagation(),
586
+ onMouseDown: (e) => e.stopPropagation(),
587
+ children: [
588
+ /* @__PURE__ */ jsx3("div", { className: "mb-2", children: /* @__PURE__ */ jsx3(
589
+ "input",
590
+ {
591
+ type: "search",
592
+ className: "form-control form-control-sm",
593
+ placeholder: "Search...",
594
+ value: search,
595
+ onChange: (e) => setSearch(e.target.value)
596
+ }
597
+ ) }),
598
+ /* @__PURE__ */ jsxs3(
599
+ "div",
600
+ {
601
+ className: "list-group list-group-flush text-truncate",
602
+ style: {
603
+ maxHeight: 220,
604
+ overflowY: "auto"
605
+ },
606
+ children: [
607
+ filteredItems.map((item) => {
608
+ const checked = selected.some((s) => s.id === item.id);
609
+ return /* @__PURE__ */ jsxs3(
610
+ "label",
611
+ {
612
+ className: "list-group-item list-group-item-action d-flex align-items-center gap-2 py-2",
613
+ children: [
614
+ /* @__PURE__ */ jsx3(
615
+ "input",
616
+ {
617
+ type: "checkbox",
618
+ className: "form-check-input mt-0",
619
+ checked,
620
+ onChange: () => toggleFacetFilter(columnKey, item)
621
+ }
622
+ ),
623
+ /* @__PURE__ */ jsx3("span", { className: "flex-grow-1", children: item.name }),
624
+ checked && /* @__PURE__ */ jsx3("i", { className: "bx bx-check text-primary" })
625
+ ]
626
+ },
627
+ item.id
628
+ );
629
+ }),
630
+ !filteredItems.length && /* @__PURE__ */ jsx3("div", { className: "text-center text-muted py-3 small", children: "No results" })
631
+ ]
632
+ }
633
+ ),
634
+ selected.length > 0 && /* @__PURE__ */ jsx3("div", { className: "pt-2 border-top mt-2 d-flex justify-content-end", children: /* @__PURE__ */ jsx3(
635
+ "button",
636
+ {
637
+ className: "btn btn-sm btn-label-secondary",
638
+ onClick: clearFacetFilters,
639
+ children: "Clear"
640
+ }
641
+ ) })
642
+ ]
643
+ }
644
+ );
632
645
  };
633
646
  var FacetFilter_default = FacetFilter;
634
647
 
@@ -1347,6 +1360,7 @@ var PamGrid = ({
1347
1360
  rows,
1348
1361
  page,
1349
1362
  totalPages,
1363
+ totalRecord,
1350
1364
  pageSize,
1351
1365
  setPage,
1352
1366
  setPageSize,
@@ -1707,20 +1721,32 @@ var PamGrid = ({
1707
1721
  ),
1708
1722
  features.pagination && /* @__PURE__ */ jsxs10("div", { className: "d-flex justify-content-between align-items-center mt-2", children: [
1709
1723
  /* @__PURE__ */ jsxs10("div", { className: "d-flex flex-row align-items-center gap-2", children: [
1710
- features.pageSizeSelector && /* @__PURE__ */ jsx13(
1711
- "select",
1712
- {
1713
- className: "form-select form-select-sm",
1714
- style: { width: "80px" },
1715
- value: pageSize,
1716
- onChange: (e) => setPageSize(Number(e.target.value)),
1717
- children: [20, 50, 100].map((n) => /* @__PURE__ */ jsx13("option", { value: n, children: n }, n))
1718
- }
1719
- ),
1720
- " ",
1721
- /* @__PURE__ */ jsxs10("small", { children: [
1722
- rows.length,
1723
- " Record"
1724
+ /* @__PURE__ */ jsxs10("small", { className: "text-secondary", children: [
1725
+ "Showing ",
1726
+ rows.length === 0 ? 0 : (page - 1) * pageSize + 1,
1727
+ " - ",
1728
+ (page - 1) * pageSize + rows.length,
1729
+ " of ",
1730
+ totalRecord
1731
+ ] }),
1732
+ features.pageSizeSelector && /* @__PURE__ */ jsxs10("div", { className: "d-flex align-items-center gap-2 ms-2", children: [
1733
+ /* @__PURE__ */ jsx13(
1734
+ PamDropdown,
1735
+ {
1736
+ placement: "top-start",
1737
+ trigger: /* @__PURE__ */ jsxs10("button", { className: "btn btn-sm border bg-white d-flex align-items-center gap-1", children: [
1738
+ pageSize,
1739
+ " ",
1740
+ /* @__PURE__ */ jsx13("i", { className: "bx bx-chevron-down text-muted" })
1741
+ ] }),
1742
+ items: [20, 50, 100].map((n) => ({
1743
+ key: String(n),
1744
+ label: String(n),
1745
+ onClick: () => setPageSize(n)
1746
+ }))
1747
+ }
1748
+ ),
1749
+ /* @__PURE__ */ jsx13("small", { className: "text-secondary", children: "per page" })
1724
1750
  ] })
1725
1751
  ] }),
1726
1752
  /* @__PURE__ */ jsx13("div", { children: /* @__PURE__ */ jsx13(
@@ -2038,6 +2064,7 @@ function useGridCore({
2038
2064
  }) {
2039
2065
  const [page, setPage] = useState6(1);
2040
2066
  const [pageSize, setPageSize] = useState6(initialPageSize);
2067
+ const [totalRecord, setTotalRecord] = useState6(0);
2041
2068
  const [search, setSearch] = useState6("");
2042
2069
  const [debouncedSearch, setDebouncedSearch] = useState6("");
2043
2070
  const [groupBy, setGroupBy] = useState6(null);
@@ -2356,6 +2383,8 @@ function useGridCore({
2356
2383
  setPageSize,
2357
2384
  totalRows,
2358
2385
  totalPages,
2386
+ totalRecord,
2387
+ setTotalRecord,
2359
2388
  // search
2360
2389
  search,
2361
2390
  setSearch,