@iclips/ui 1.0.1 → 1.0.3

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
@@ -5640,56 +5640,72 @@ function Switch({
5640
5640
  }
5641
5641
  );
5642
5642
  }
5643
- function Table({ className, ...props }) {
5644
- return /* @__PURE__ */ jsxRuntime.jsx(
5645
- "div",
5646
- {
5647
- "data-slot": "table-container",
5648
- className: "relative w-full overflow-x-auto",
5649
- children: /* @__PURE__ */ jsxRuntime.jsx(
5650
- "table",
5651
- {
5652
- "data-slot": "table",
5653
- className: cn("w-full caption-bottom text-sm", className),
5654
- ...props
5655
- }
5656
- )
5657
- }
5658
- );
5659
- }
5660
- function TableHeader({ className, ...props }) {
5661
- return /* @__PURE__ */ jsxRuntime.jsx(
5662
- "thead",
5663
- {
5664
- "data-slot": "table-header",
5665
- className: cn("[&_tr]:border-b", className),
5666
- ...props
5667
- }
5668
- );
5669
- }
5670
- function TableBody({ className, ...props }) {
5671
- return /* @__PURE__ */ jsxRuntime.jsx(
5672
- "tbody",
5673
- {
5674
- "data-slot": "table-body",
5675
- className: cn("[&_tr:last-child]:border-0", className),
5676
- ...props
5677
- }
5678
- );
5679
- }
5680
- function TableFooter({ className, ...props }) {
5681
- return /* @__PURE__ */ jsxRuntime.jsx(
5682
- "tfoot",
5683
- {
5684
- "data-slot": "table-footer",
5685
- className: cn(
5686
- "bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",
5687
- className
5688
- ),
5689
- ...props
5690
- }
5691
- );
5692
- }
5643
+ var Table = React7__namespace.forwardRef(
5644
+ ({ className, ...props }, ref) => {
5645
+ return /* @__PURE__ */ jsxRuntime.jsx(
5646
+ "div",
5647
+ {
5648
+ "data-slot": "table-container",
5649
+ className: "relative w-full overflow-x-auto",
5650
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5651
+ "table",
5652
+ {
5653
+ ref,
5654
+ "data-slot": "table",
5655
+ className: cn("w-full caption-bottom text-sm", className),
5656
+ ...props
5657
+ }
5658
+ )
5659
+ }
5660
+ );
5661
+ }
5662
+ );
5663
+ Table.displayName = "Table";
5664
+ var TableHeader = React7__namespace.forwardRef(
5665
+ ({ className, ...props }, ref) => {
5666
+ return /* @__PURE__ */ jsxRuntime.jsx(
5667
+ "thead",
5668
+ {
5669
+ ref,
5670
+ "data-slot": "table-header",
5671
+ className: cn("[&_tr]:border-b", className),
5672
+ ...props
5673
+ }
5674
+ );
5675
+ }
5676
+ );
5677
+ TableHeader.displayName = "TableHeader";
5678
+ var TableBody = React7__namespace.forwardRef(
5679
+ ({ className, ...props }, ref) => {
5680
+ return /* @__PURE__ */ jsxRuntime.jsx(
5681
+ "tbody",
5682
+ {
5683
+ ref,
5684
+ "data-slot": "table-body",
5685
+ className: cn("[&_tr:last-child]:border-0", className),
5686
+ ...props
5687
+ }
5688
+ );
5689
+ }
5690
+ );
5691
+ TableBody.displayName = "TableBody";
5692
+ var TableFooter = React7__namespace.forwardRef(
5693
+ ({ className, ...props }, ref) => {
5694
+ return /* @__PURE__ */ jsxRuntime.jsx(
5695
+ "tfoot",
5696
+ {
5697
+ ref,
5698
+ "data-slot": "table-footer",
5699
+ className: cn(
5700
+ "bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",
5701
+ className
5702
+ ),
5703
+ ...props
5704
+ }
5705
+ );
5706
+ }
5707
+ );
5708
+ TableFooter.displayName = "TableFooter";
5693
5709
  var TableRow = React7__namespace.forwardRef(({ className, ...props }, ref) => {
5694
5710
  return /* @__PURE__ */ jsxRuntime.jsx(
5695
5711
  "tr",
@@ -5705,44 +5721,261 @@ var TableRow = React7__namespace.forwardRef(({ className, ...props }, ref) => {
5705
5721
  );
5706
5722
  });
5707
5723
  TableRow.displayName = "TableRow";
5708
- function TableHead({ className, ...props }) {
5709
- return /* @__PURE__ */ jsxRuntime.jsx(
5710
- "th",
5711
- {
5712
- "data-slot": "table-head",
5713
- className: cn(
5714
- "text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
5715
- className
5716
- ),
5717
- ...props
5718
- }
5719
- );
5724
+ var TableHead = React7__namespace.forwardRef(
5725
+ ({ className, ...props }, ref) => {
5726
+ return /* @__PURE__ */ jsxRuntime.jsx(
5727
+ "th",
5728
+ {
5729
+ ref,
5730
+ "data-slot": "table-head",
5731
+ className: cn(
5732
+ "text-foreground h-10 px-2 text-left align-middle font-medium",
5733
+ "[&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
5734
+ className
5735
+ ),
5736
+ ...props
5737
+ }
5738
+ );
5739
+ }
5740
+ );
5741
+ TableHead.displayName = "TableHead";
5742
+ var TableCell = React7__namespace.forwardRef(
5743
+ ({ className, ...props }, ref) => {
5744
+ return /* @__PURE__ */ jsxRuntime.jsx(
5745
+ "td",
5746
+ {
5747
+ ref,
5748
+ "data-slot": "table-cell",
5749
+ className: cn(
5750
+ "p-2 align-middle",
5751
+ "[&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
5752
+ className
5753
+ ),
5754
+ ...props
5755
+ }
5756
+ );
5757
+ }
5758
+ );
5759
+ TableCell.displayName = "TableCell";
5760
+ var TableCaption = React7__namespace.forwardRef(
5761
+ ({ className, ...props }, ref) => {
5762
+ return /* @__PURE__ */ jsxRuntime.jsx(
5763
+ "caption",
5764
+ {
5765
+ ref,
5766
+ "data-slot": "table-caption",
5767
+ className: cn("text-muted-foreground mt-4 text-sm", className),
5768
+ ...props
5769
+ }
5770
+ );
5771
+ }
5772
+ );
5773
+ TableCaption.displayName = "TableCaption";
5774
+ var defaultLabels = {
5775
+ previous: "Anterior",
5776
+ next: "Pr\xF3xima",
5777
+ first: "Primeira",
5778
+ last: "\xDAltima",
5779
+ showing: "Mostrando",
5780
+ of: "de",
5781
+ results: "resultados",
5782
+ itemsPerPage: "Itens por p\xE1gina",
5783
+ page: "P\xE1gina"
5784
+ };
5785
+ var defaultPageSizeOptions = [10, 20, 30, 50, 100];
5786
+ function getPageNumbers(currentPage, totalPages, maxVisible = 5) {
5787
+ if (totalPages <= maxVisible) {
5788
+ return Array.from({ length: totalPages }, (_, i) => i + 1);
5789
+ }
5790
+ const pages = [];
5791
+ const halfVisible = Math.floor(maxVisible / 2);
5792
+ pages.push(1);
5793
+ let start = Math.max(2, currentPage - halfVisible);
5794
+ let end = Math.min(totalPages - 1, currentPage + halfVisible);
5795
+ if (currentPage <= halfVisible + 1) {
5796
+ end = maxVisible - 1;
5797
+ } else if (currentPage >= totalPages - halfVisible) {
5798
+ start = totalPages - maxVisible + 2;
5799
+ }
5800
+ if (start > 2) {
5801
+ pages.push("ellipsis");
5802
+ }
5803
+ for (let i = start; i <= end; i++) {
5804
+ pages.push(i);
5805
+ }
5806
+ if (end < totalPages - 1) {
5807
+ pages.push("ellipsis");
5808
+ }
5809
+ if (totalPages > 1) {
5810
+ pages.push(totalPages);
5811
+ }
5812
+ return pages;
5720
5813
  }
5721
- function TableCell({ className, ...props }) {
5722
- return /* @__PURE__ */ jsxRuntime.jsx(
5723
- "td",
5814
+ function TablePagination({
5815
+ currentPage,
5816
+ totalPages,
5817
+ pageSize,
5818
+ totalItems,
5819
+ onPageChange,
5820
+ onPageSizeChange,
5821
+ pageSizeOptions = defaultPageSizeOptions,
5822
+ maxVisiblePages = 5,
5823
+ showInfo = true,
5824
+ showPageNumbers = true,
5825
+ showPageSizeSelector = true,
5826
+ showFirstLastButtons = true,
5827
+ labels: customLabels,
5828
+ className
5829
+ }) {
5830
+ const labels = { ...defaultLabels, ...customLabels };
5831
+ const pages = getPageNumbers(currentPage, totalPages, maxVisiblePages);
5832
+ const startItem = (currentPage - 1) * pageSize + 1;
5833
+ const endItem = Math.min(currentPage * pageSize, totalItems);
5834
+ const hasPreviousPage = currentPage > 1;
5835
+ const hasNextPage = currentPage < totalPages;
5836
+ if (totalPages === 0) {
5837
+ return null;
5838
+ }
5839
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5840
+ "div",
5724
5841
  {
5725
- "data-slot": "table-cell",
5726
5842
  className: cn(
5727
- "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
5843
+ "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
5728
5844
  className
5729
5845
  ),
5730
- ...props
5846
+ role: "navigation",
5847
+ "aria-label": "Pagina\xE7\xE3o da tabela",
5848
+ children: [
5849
+ showInfo && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground order-2 sm:order-1", children: [
5850
+ labels.showing,
5851
+ " ",
5852
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-foreground", children: startItem }),
5853
+ " - ",
5854
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-foreground", children: endItem }),
5855
+ " ",
5856
+ labels.of,
5857
+ " ",
5858
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-foreground", children: totalItems }),
5859
+ " ",
5860
+ labels.results
5861
+ ] }),
5862
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4 order-1 sm:order-2", children: [
5863
+ showPageSizeSelector && onPageSizeChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
5864
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground whitespace-nowrap", children: labels.itemsPerPage }),
5865
+ /* @__PURE__ */ jsxRuntime.jsxs(
5866
+ Select,
5867
+ {
5868
+ value: String(pageSize),
5869
+ onValueChange: (value) => onPageSizeChange(Number(value)),
5870
+ children: [
5871
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 w-[70px]", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: pageSize }) }),
5872
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: pageSizeOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: String(option), children: option }, option)) })
5873
+ ]
5874
+ }
5875
+ )
5876
+ ] }),
5877
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-muted-foreground sm:hidden", children: [
5878
+ labels.page,
5879
+ " ",
5880
+ currentPage,
5881
+ " ",
5882
+ labels.of,
5883
+ " ",
5884
+ totalPages
5885
+ ] }),
5886
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
5887
+ showFirstLastButtons && /* @__PURE__ */ jsxRuntime.jsx(
5888
+ Button,
5889
+ {
5890
+ variant: "outline",
5891
+ size: "icon",
5892
+ className: "h-8 w-8",
5893
+ onClick: () => onPageChange(1),
5894
+ disabled: !hasPreviousPage,
5895
+ "aria-label": labels.first,
5896
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeft, { className: "h-4 w-4" })
5897
+ }
5898
+ ),
5899
+ /* @__PURE__ */ jsxRuntime.jsx(
5900
+ Button,
5901
+ {
5902
+ variant: "outline",
5903
+ size: "icon",
5904
+ className: "h-8 w-8",
5905
+ onClick: () => onPageChange(currentPage - 1),
5906
+ disabled: !hasPreviousPage,
5907
+ "aria-label": labels.previous,
5908
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" })
5909
+ }
5910
+ ),
5911
+ showPageNumbers && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden sm:flex items-center gap-1", children: pages.map(
5912
+ (page, index) => page === "ellipsis" ? /* @__PURE__ */ jsxRuntime.jsx(
5913
+ "span",
5914
+ {
5915
+ className: "flex items-center justify-center w-8 h-8 text-muted-foreground",
5916
+ "aria-hidden": true,
5917
+ children: "..."
5918
+ },
5919
+ `ellipsis-${index}`
5920
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
5921
+ Button,
5922
+ {
5923
+ variant: currentPage === page ? "default" : "outline",
5924
+ size: "icon",
5925
+ className: "h-8 w-8",
5926
+ onClick: () => onPageChange(page),
5927
+ "aria-label": `${labels.page} ${page}`,
5928
+ "aria-current": currentPage === page ? "page" : void 0,
5929
+ children: page
5930
+ },
5931
+ page
5932
+ )
5933
+ ) }),
5934
+ /* @__PURE__ */ jsxRuntime.jsx(
5935
+ Button,
5936
+ {
5937
+ variant: "outline",
5938
+ size: "icon",
5939
+ className: "h-8 w-8",
5940
+ onClick: () => onPageChange(currentPage + 1),
5941
+ disabled: !hasNextPage,
5942
+ "aria-label": labels.next,
5943
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" })
5944
+ }
5945
+ ),
5946
+ showFirstLastButtons && /* @__PURE__ */ jsxRuntime.jsx(
5947
+ Button,
5948
+ {
5949
+ variant: "outline",
5950
+ size: "icon",
5951
+ className: "h-8 w-8",
5952
+ onClick: () => onPageChange(totalPages),
5953
+ disabled: !hasNextPage,
5954
+ "aria-label": labels.last,
5955
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsRight, { className: "h-4 w-4" })
5956
+ }
5957
+ )
5958
+ ] })
5959
+ ] })
5960
+ ]
5731
5961
  }
5732
5962
  );
5733
5963
  }
5734
- function TableCaption({
5735
- className,
5736
- ...props
5737
- }) {
5738
- return /* @__PURE__ */ jsxRuntime.jsx(
5739
- "caption",
5740
- {
5741
- "data-slot": "table-caption",
5742
- className: cn("text-muted-foreground mt-4 text-sm", className),
5743
- ...props
5744
- }
5745
- );
5964
+ TablePagination.displayName = "TablePagination";
5965
+
5966
+ // components/ui/table-types.ts
5967
+ function calculatePaginationMetadata(config) {
5968
+ const { currentPage, pageSize, totalItems } = config;
5969
+ const totalPages = Math.ceil(totalItems / pageSize);
5970
+ const startIndex = (currentPage - 1) * pageSize;
5971
+ const endIndex = Math.min(startIndex + pageSize, totalItems);
5972
+ return {
5973
+ totalPages,
5974
+ startIndex,
5975
+ endIndex,
5976
+ hasNextPage: currentPage < totalPages,
5977
+ hasPreviousPage: currentPage > 1
5978
+ };
5746
5979
  }
5747
5980
  function Tabs({
5748
5981
  className,
@@ -6541,6 +6774,7 @@ exports.TableCell = TableCell;
6541
6774
  exports.TableFooter = TableFooter;
6542
6775
  exports.TableHead = TableHead;
6543
6776
  exports.TableHeader = TableHeader;
6777
+ exports.TablePagination = TablePagination;
6544
6778
  exports.TableRow = TableRow;
6545
6779
  exports.Tabs = Tabs;
6546
6780
  exports.TabsContent = TabsContent;
@@ -6561,8 +6795,10 @@ exports.UnderlineTabsList = UnderlineTabsList;
6561
6795
  exports.UnderlineTabsTrigger = UnderlineTabsTrigger;
6562
6796
  exports.badgeVariants = badgeVariants;
6563
6797
  exports.buttonVariants = buttonVariants;
6798
+ exports.calculatePaginationMetadata = calculatePaginationMetadata;
6564
6799
  exports.cn = cn;
6565
6800
  exports.dadosContratoExemplo = dadosContratoExemplo;
6801
+ exports.getPageNumbers = getPageNumbers;
6566
6802
  exports.navigationMenuTriggerStyle = navigationMenuTriggerStyle;
6567
6803
  exports.toggleVariants = toggleVariants;
6568
6804
  exports.useFormField = useFormField;