@andreagiugni/tailwind-dashboard-ui 0.5.16 → 0.5.17
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/README.md +1 -1
- package/dist/index.cjs +67 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -733,15 +733,63 @@ var alignClass = {
|
|
|
733
733
|
right: "text-right"
|
|
734
734
|
};
|
|
735
735
|
function SortIcon({
|
|
736
|
-
|
|
737
|
-
direction
|
|
736
|
+
state
|
|
738
737
|
}) {
|
|
739
|
-
const
|
|
740
|
-
const
|
|
741
|
-
return /* @__PURE__ */ jsxs(
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
738
|
+
const active = "text-brand-500";
|
|
739
|
+
const inactive = "text-gray-400 dark:text-gray-500";
|
|
740
|
+
return /* @__PURE__ */ jsxs(
|
|
741
|
+
"span",
|
|
742
|
+
{
|
|
743
|
+
"data-sort-state": state,
|
|
744
|
+
className: "inline-flex shrink-0 flex-col items-center -space-y-1",
|
|
745
|
+
children: [
|
|
746
|
+
/* @__PURE__ */ jsx(
|
|
747
|
+
"svg",
|
|
748
|
+
{
|
|
749
|
+
"data-sort-direction": "asc",
|
|
750
|
+
width: "12",
|
|
751
|
+
height: "12",
|
|
752
|
+
viewBox: "0 0 12 12",
|
|
753
|
+
fill: "none",
|
|
754
|
+
"aria-hidden": "true",
|
|
755
|
+
className: state === "asc" ? active : inactive,
|
|
756
|
+
children: /* @__PURE__ */ jsx(
|
|
757
|
+
"path",
|
|
758
|
+
{
|
|
759
|
+
d: "M3.5 7.25 6 4.75l2.5 2.5",
|
|
760
|
+
stroke: "currentColor",
|
|
761
|
+
strokeWidth: "1.5",
|
|
762
|
+
strokeLinecap: "round",
|
|
763
|
+
strokeLinejoin: "round"
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
}
|
|
767
|
+
),
|
|
768
|
+
/* @__PURE__ */ jsx(
|
|
769
|
+
"svg",
|
|
770
|
+
{
|
|
771
|
+
"data-sort-direction": "desc",
|
|
772
|
+
width: "12",
|
|
773
|
+
height: "12",
|
|
774
|
+
viewBox: "0 0 12 12",
|
|
775
|
+
fill: "none",
|
|
776
|
+
"aria-hidden": "true",
|
|
777
|
+
className: state === "desc" ? active : inactive,
|
|
778
|
+
children: /* @__PURE__ */ jsx(
|
|
779
|
+
"path",
|
|
780
|
+
{
|
|
781
|
+
d: "m3.5 4.75 2.5 2.5 2.5-2.5",
|
|
782
|
+
stroke: "currentColor",
|
|
783
|
+
strokeWidth: "1.5",
|
|
784
|
+
strokeLinecap: "round",
|
|
785
|
+
strokeLinejoin: "round"
|
|
786
|
+
}
|
|
787
|
+
)
|
|
788
|
+
}
|
|
789
|
+
)
|
|
790
|
+
]
|
|
791
|
+
}
|
|
792
|
+
);
|
|
745
793
|
}
|
|
746
794
|
function DataDrivenTable({
|
|
747
795
|
data,
|
|
@@ -791,10 +839,14 @@ function DataDrivenTable({
|
|
|
791
839
|
const pageRows = pagination ? filtered.slice(start, start + pageSize) : filtered;
|
|
792
840
|
const toggleSort = (col) => {
|
|
793
841
|
if (!col.sortable) return;
|
|
794
|
-
if (sortKey
|
|
795
|
-
else {
|
|
842
|
+
if (sortKey !== col.key) {
|
|
796
843
|
setSortKey(col.key);
|
|
797
844
|
setSortDir("asc");
|
|
845
|
+
} else if (sortDir === "asc") {
|
|
846
|
+
setSortDir("desc");
|
|
847
|
+
} else {
|
|
848
|
+
setSortKey(void 0);
|
|
849
|
+
setSortDir("asc");
|
|
798
850
|
}
|
|
799
851
|
setPage(1);
|
|
800
852
|
};
|
|
@@ -872,8 +924,9 @@ function DataDrivenTable({
|
|
|
872
924
|
TableCell,
|
|
873
925
|
{
|
|
874
926
|
isHeader: true,
|
|
927
|
+
"aria-sort": col.sortable ? isActive ? sortDir === "asc" ? "ascending" : "descending" : "none" : void 0,
|
|
875
928
|
className: cn(
|
|
876
|
-
"whitespace-nowrap px-5 py-3 text-xs font-semibold text-gray-
|
|
929
|
+
"whitespace-nowrap px-5 py-3 text-xs font-semibold text-gray-500 dark:text-gray-400",
|
|
877
930
|
alignClass[col.align ?? "left"],
|
|
878
931
|
col.className
|
|
879
932
|
),
|
|
@@ -883,10 +936,10 @@ function DataDrivenTable({
|
|
|
883
936
|
type: "button",
|
|
884
937
|
onClick: () => toggleSort(col),
|
|
885
938
|
"aria-label": `Sort by ${typeof col.header === "string" ? col.header : col.key}`,
|
|
886
|
-
className: "inline-flex select-none items-center gap-
|
|
939
|
+
className: "inline-flex select-none items-center gap-2 text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",
|
|
887
940
|
children: [
|
|
888
|
-
|
|
889
|
-
|
|
941
|
+
/* @__PURE__ */ jsx(SortIcon, { state: isActive ? sortDir : "none" }),
|
|
942
|
+
col.header
|
|
890
943
|
]
|
|
891
944
|
}
|
|
892
945
|
) : col.header
|