analytica-frontend-lib 1.2.15 → 1.2.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/dist/AlertManager/index.css +16 -0
- package/dist/AlertManager/index.css.map +1 -1
- package/dist/AlertManager/index.js +108 -108
- package/dist/AlertManager/index.js.map +1 -1
- package/dist/AlertManager/index.mjs +101 -101
- package/dist/AlertManager/index.mjs.map +1 -1
- package/dist/AlertManagerView/index.js +13 -3
- package/dist/AlertManagerView/index.js.map +1 -1
- package/dist/AlertManagerView/index.mjs +13 -3
- package/dist/AlertManagerView/index.mjs.map +1 -1
- package/dist/Table/TablePagination/index.d.mts +64 -0
- package/dist/Table/TablePagination/index.d.ts +64 -0
- package/dist/Table/TablePagination/index.js +153 -0
- package/dist/Table/TablePagination/index.js.map +1 -0
- package/dist/Table/TablePagination/index.mjs +132 -0
- package/dist/Table/TablePagination/index.mjs.map +1 -0
- package/dist/Table/index.d.mts +3 -1
- package/dist/Table/index.d.ts +3 -1
- package/dist/Table/index.js +159 -27
- package/dist/Table/index.js.map +1 -1
- package/dist/Table/index.mjs +158 -27
- package/dist/Table/index.mjs.map +1 -1
- package/dist/index.css +16 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.js +1120 -984
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1115 -981
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +16 -0
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/Table/TablePagination.tsx
|
|
21
|
+
var TablePagination_exports = {};
|
|
22
|
+
__export(TablePagination_exports, {
|
|
23
|
+
default: () => TablePagination_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(TablePagination_exports);
|
|
26
|
+
var import_phosphor_react = require("phosphor-react");
|
|
27
|
+
|
|
28
|
+
// src/utils/utils.ts
|
|
29
|
+
var import_clsx = require("clsx");
|
|
30
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
31
|
+
function cn(...inputs) {
|
|
32
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/components/Table/TablePagination.tsx
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var TablePagination = ({
|
|
38
|
+
totalItems,
|
|
39
|
+
currentPage,
|
|
40
|
+
totalPages,
|
|
41
|
+
itemsPerPage,
|
|
42
|
+
itemsPerPageOptions = [10, 20, 50, 100],
|
|
43
|
+
onPageChange,
|
|
44
|
+
onItemsPerPageChange,
|
|
45
|
+
itemLabel = "itens",
|
|
46
|
+
className,
|
|
47
|
+
...props
|
|
48
|
+
}) => {
|
|
49
|
+
const startItem = (currentPage - 1) * itemsPerPage + 1;
|
|
50
|
+
const handlePrevious = () => {
|
|
51
|
+
if (currentPage > 1) {
|
|
52
|
+
onPageChange(currentPage - 1);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const handleNext = () => {
|
|
56
|
+
if (currentPage < totalPages) {
|
|
57
|
+
onPageChange(currentPage + 1);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const handleItemsPerPageChange = (e) => {
|
|
61
|
+
if (onItemsPerPageChange) {
|
|
62
|
+
onItemsPerPageChange(Number(e.target.value));
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const isFirstPage = currentPage === 1;
|
|
66
|
+
const isLastPage = currentPage === totalPages;
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
className: cn(
|
|
71
|
+
"flex flex-col sm:flex-row items-center gap-3 sm:gap-4 w-full bg-background-50 rounded-xl p-4",
|
|
72
|
+
"sm:justify-between",
|
|
73
|
+
className
|
|
74
|
+
),
|
|
75
|
+
...props,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "font-normal text-xs leading-[14px] text-text-800", children: [
|
|
78
|
+
startItem,
|
|
79
|
+
" de ",
|
|
80
|
+
totalItems,
|
|
81
|
+
" ",
|
|
82
|
+
itemLabel
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap sm:flex-nowrap items-center gap-2 sm:gap-4 justify-center sm:justify-start", children: [
|
|
85
|
+
onItemsPerPageChange && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative", children: [
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
87
|
+
"select",
|
|
88
|
+
{
|
|
89
|
+
value: itemsPerPage,
|
|
90
|
+
onChange: handleItemsPerPageChange,
|
|
91
|
+
className: "w-24 h-9 py-0 px-3 pr-8 bg-background border border-border-300 rounded appearance-none cursor-pointer font-normal text-sm leading-[21px] text-text-900",
|
|
92
|
+
"aria-label": "Items por p\xE1gina",
|
|
93
|
+
children: itemsPerPageOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", { value: option, children: [
|
|
94
|
+
option,
|
|
95
|
+
" itens"
|
|
96
|
+
] }, option))
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
100
|
+
import_phosphor_react.CaretDown,
|
|
101
|
+
{
|
|
102
|
+
size: 14,
|
|
103
|
+
weight: "regular",
|
|
104
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 text-background-600 pointer-events-none"
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
] }),
|
|
108
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "font-normal text-xs leading-[14px] text-text-950", children: [
|
|
109
|
+
"P\xE1gina ",
|
|
110
|
+
currentPage,
|
|
111
|
+
" de ",
|
|
112
|
+
totalPages
|
|
113
|
+
] }),
|
|
114
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
115
|
+
"button",
|
|
116
|
+
{
|
|
117
|
+
onClick: handlePrevious,
|
|
118
|
+
disabled: isFirstPage,
|
|
119
|
+
className: cn(
|
|
120
|
+
"flex flex-row justify-center items-center py-2 px-4 gap-2 rounded-3xl transition-all",
|
|
121
|
+
isFirstPage ? "opacity-50 cursor-not-allowed" : "hover:bg-primary-950/10 cursor-pointer"
|
|
122
|
+
),
|
|
123
|
+
"aria-label": "P\xE1gina anterior",
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_phosphor_react.CaretLeft, { size: 12, weight: "bold", className: "text-primary-950" }),
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "font-medium text-xs leading-[14px] text-primary-950", children: "Anterior" })
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
131
|
+
"button",
|
|
132
|
+
{
|
|
133
|
+
onClick: handleNext,
|
|
134
|
+
disabled: isLastPage,
|
|
135
|
+
className: cn(
|
|
136
|
+
"flex flex-row justify-center items-center py-2 px-4 gap-2 rounded-3xl transition-all",
|
|
137
|
+
isLastPage ? "opacity-50 cursor-not-allowed" : "hover:bg-primary-950/10 cursor-pointer"
|
|
138
|
+
),
|
|
139
|
+
"aria-label": "Pr\xF3xima p\xE1gina",
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "font-medium text-xs leading-[14px] text-primary-950", children: "Pr\xF3xima" }),
|
|
142
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_phosphor_react.CaretRight, { size: 12, weight: "bold", className: "text-primary-950" })
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
] })
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
TablePagination.displayName = "TablePagination";
|
|
152
|
+
var TablePagination_default = TablePagination;
|
|
153
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Table/TablePagination.tsx","../../../src/utils/utils.ts"],"sourcesContent":["import { HTMLAttributes, ChangeEvent } from 'react';\nimport { CaretLeft, CaretRight, CaretDown } from 'phosphor-react';\nimport { cn } from '../../utils/utils';\n\nexport interface TablePaginationProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Total number of items\n */\n totalItems: number;\n /**\n * Current page (1-based)\n */\n currentPage: number;\n /**\n * Total number of pages\n */\n totalPages: number;\n /**\n * Items per page\n */\n itemsPerPage: number;\n /**\n * Available options for items per page\n * @default [10, 20, 50, 100]\n */\n itemsPerPageOptions?: number[];\n /**\n * Callback when page changes\n */\n onPageChange: (page: number) => void;\n /**\n * Callback when items per page changes\n */\n onItemsPerPageChange?: (itemsPerPage: number) => void;\n /**\n * Customizable label for items (e.g., \"escolas\", \"alunos\", \"atividades\")\n * @default \"itens\"\n */\n itemLabel?: string;\n}\n\n/**\n * Table pagination component with navigation controls and items per page selector\n *\n * @example\n * ```tsx\n * import { TablePagination } from 'analytica-frontend-lib';\n *\n * <TablePagination\n * totalItems={1000}\n * currentPage={1}\n * totalPages={10}\n * itemsPerPage={10}\n * itemsPerPageOptions={[10, 20, 50, 100]}\n * onPageChange={(page) => setCurrentPage(page)}\n * onItemsPerPageChange={(items) => setItemsPerPage(items)}\n * itemLabel=\"escolas\"\n * />\n * ```\n */\nconst TablePagination = ({\n totalItems,\n currentPage,\n totalPages,\n itemsPerPage,\n itemsPerPageOptions = [10, 20, 50, 100],\n onPageChange,\n onItemsPerPageChange,\n itemLabel = 'itens',\n className,\n ...props\n}: TablePaginationProps) => {\n const startItem = (currentPage - 1) * itemsPerPage + 1;\n\n const handlePrevious = () => {\n if (currentPage > 1) {\n onPageChange(currentPage - 1);\n }\n };\n\n const handleNext = () => {\n if (currentPage < totalPages) {\n onPageChange(currentPage + 1);\n }\n };\n\n const handleItemsPerPageChange = (e: ChangeEvent<HTMLSelectElement>) => {\n if (onItemsPerPageChange) {\n onItemsPerPageChange(Number(e.target.value));\n }\n };\n\n const isFirstPage = currentPage === 1;\n const isLastPage = currentPage === totalPages;\n\n return (\n <div\n className={cn(\n 'flex flex-col sm:flex-row items-center gap-3 sm:gap-4 w-full bg-background-50 rounded-xl p-4',\n 'sm:justify-between',\n className\n )}\n {...props}\n >\n {/* Items count - isolado à esquerda no desktop */}\n <span className=\"font-normal text-xs leading-[14px] text-text-800\">\n {startItem} de {totalItems} {itemLabel}\n </span>\n\n {/* Grupo direita: selector + page info + botões */}\n <div className=\"flex flex-wrap sm:flex-nowrap items-center gap-2 sm:gap-4 justify-center sm:justify-start\">\n {/* Items per page selector */}\n {onItemsPerPageChange && (\n <div className=\"relative\">\n <select\n value={itemsPerPage}\n onChange={handleItemsPerPageChange}\n className=\"w-24 h-9 py-0 px-3 pr-8 bg-background border border-border-300 rounded appearance-none cursor-pointer font-normal text-sm leading-[21px] text-text-900\"\n aria-label=\"Items por página\"\n >\n {itemsPerPageOptions.map((option) => (\n <option key={option} value={option}>\n {option} itens\n </option>\n ))}\n </select>\n <CaretDown\n size={14}\n weight=\"regular\"\n className=\"absolute right-3 top-1/2 -translate-y-1/2 text-background-600 pointer-events-none\"\n />\n </div>\n )}\n\n {/* Page info */}\n <span className=\"font-normal text-xs leading-[14px] text-text-950\">\n Página {currentPage} de {totalPages}\n </span>\n\n {/* Previous button */}\n <button\n onClick={handlePrevious}\n disabled={isFirstPage}\n className={cn(\n 'flex flex-row justify-center items-center py-2 px-4 gap-2 rounded-3xl transition-all',\n isFirstPage\n ? 'opacity-50 cursor-not-allowed'\n : 'hover:bg-primary-950/10 cursor-pointer'\n )}\n aria-label=\"Página anterior\"\n >\n <CaretLeft size={12} weight=\"bold\" className=\"text-primary-950\" />\n <span className=\"font-medium text-xs leading-[14px] text-primary-950\">\n Anterior\n </span>\n </button>\n\n {/* Next button */}\n <button\n onClick={handleNext}\n disabled={isLastPage}\n className={cn(\n 'flex flex-row justify-center items-center py-2 px-4 gap-2 rounded-3xl transition-all',\n isLastPage\n ? 'opacity-50 cursor-not-allowed'\n : 'hover:bg-primary-950/10 cursor-pointer'\n )}\n aria-label=\"Próxima página\"\n >\n <span className=\"font-medium text-xs leading-[14px] text-primary-950\">\n Próxima\n </span>\n <CaretRight size={12} weight=\"bold\" className=\"text-primary-950\" />\n </button>\n </div>\n </div>\n );\n};\n\nTablePagination.displayName = 'TablePagination';\n\nexport default TablePagination;\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport { syncDropdownState } from './dropdown';\n\n/**\n * Retorna a cor hexadecimal com opacidade 0.3 (4d) se não estiver em dark mode.\n * Se estiver em dark mode, retorna a cor original.\n *\n * @param hexColor - Cor hexadecimal (ex: \"#0066b8\" ou \"0066b8\")\n * @param isDark - booleano indicando se está em dark mode\n * @returns string - cor hexadecimal com opacidade se necessário\n */\nexport function getSubjectColorWithOpacity(\n hexColor: string | undefined,\n isDark: boolean\n): string | undefined {\n if (!hexColor) return undefined;\n // Remove o '#' se existir\n let color = hexColor.replace(/^#/, '').toLowerCase();\n\n if (isDark) {\n // Se está em dark mode, sempre remove opacidade se existir\n if (color.length === 8) {\n color = color.slice(0, 6);\n }\n return `#${color}`;\n } else {\n // Se não está em dark mode (light mode)\n let resultColor: string;\n if (color.length === 6) {\n // Adiciona opacidade 0.3 (4D) para cores de 6 dígitos\n resultColor = `#${color}4d`;\n } else if (color.length === 8) {\n // Já tem opacidade, retorna como está\n resultColor = `#${color}`;\n } else {\n // Para outros tamanhos (3, 4, 5 dígitos), retorna como está\n resultColor = `#${color}`;\n }\n return resultColor;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAAiD;;;ACDjD,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADoGM;AA7CN,IAAM,kBAAkB,CAAC;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAsB,CAAC,IAAI,IAAI,IAAI,GAAG;AAAA,EACtC;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,GAAG;AACL,MAA4B;AAC1B,QAAM,aAAa,cAAc,KAAK,eAAe;AAErD,QAAM,iBAAiB,MAAM;AAC3B,QAAI,cAAc,GAAG;AACnB,mBAAa,cAAc,CAAC;AAAA,IAC9B;AAAA,EACF;AAEA,QAAM,aAAa,MAAM;AACvB,QAAI,cAAc,YAAY;AAC5B,mBAAa,cAAc,CAAC;AAAA,I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AAAA,cACC,SAAS;AAAA,cACT,UAAU;AAAA,cACV,WAAW;AAAA,gBACT;AAAA,gBACA,aACI,kCACA;AAAA,cACN;AAAA,cACA,cAAW;AAAA,cAEX;AAAA,4DAAC,UAAK,WAAU,uDAAsD,wBAEtE;AAAA,gBACA,4CAAC,oCAAW,MAAM,IAAI,QAAO,QAAO,WAAU,oBAAmB;AAAA;AAAA;AAAA,UACnE;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,gBAAgB,cAAc;AAE9B,IAAO,0BAAQ;","names":[]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// src/components/Table/TablePagination.tsx
|
|
2
|
+
import { CaretLeft, CaretRight, CaretDown } from "phosphor-react";
|
|
3
|
+
|
|
4
|
+
// src/utils/utils.ts
|
|
5
|
+
import { clsx } from "clsx";
|
|
6
|
+
import { twMerge } from "tailwind-merge";
|
|
7
|
+
function cn(...inputs) {
|
|
8
|
+
return twMerge(clsx(inputs));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/components/Table/TablePagination.tsx
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
var TablePagination = ({
|
|
14
|
+
totalItems,
|
|
15
|
+
currentPage,
|
|
16
|
+
totalPages,
|
|
17
|
+
itemsPerPage,
|
|
18
|
+
itemsPerPageOptions = [10, 20, 50, 100],
|
|
19
|
+
onPageChange,
|
|
20
|
+
onItemsPerPageChange,
|
|
21
|
+
itemLabel = "itens",
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}) => {
|
|
25
|
+
const startItem = (currentPage - 1) * itemsPerPage + 1;
|
|
26
|
+
const handlePrevious = () => {
|
|
27
|
+
if (currentPage > 1) {
|
|
28
|
+
onPageChange(currentPage - 1);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const handleNext = () => {
|
|
32
|
+
if (currentPage < totalPages) {
|
|
33
|
+
onPageChange(currentPage + 1);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const handleItemsPerPageChange = (e) => {
|
|
37
|
+
if (onItemsPerPageChange) {
|
|
38
|
+
onItemsPerPageChange(Number(e.target.value));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const isFirstPage = currentPage === 1;
|
|
42
|
+
const isLastPage = currentPage === totalPages;
|
|
43
|
+
return /* @__PURE__ */ jsxs(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className: cn(
|
|
47
|
+
"flex flex-col sm:flex-row items-center gap-3 sm:gap-4 w-full bg-background-50 rounded-xl p-4",
|
|
48
|
+
"sm:justify-between",
|
|
49
|
+
className
|
|
50
|
+
),
|
|
51
|
+
...props,
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsxs("span", { className: "font-normal text-xs leading-[14px] text-text-800", children: [
|
|
54
|
+
startItem,
|
|
55
|
+
" de ",
|
|
56
|
+
totalItems,
|
|
57
|
+
" ",
|
|
58
|
+
itemLabel
|
|
59
|
+
] }),
|
|
60
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap sm:flex-nowrap items-center gap-2 sm:gap-4 justify-center sm:justify-start", children: [
|
|
61
|
+
onItemsPerPageChange && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
62
|
+
/* @__PURE__ */ jsx(
|
|
63
|
+
"select",
|
|
64
|
+
{
|
|
65
|
+
value: itemsPerPage,
|
|
66
|
+
onChange: handleItemsPerPageChange,
|
|
67
|
+
className: "w-24 h-9 py-0 px-3 pr-8 bg-background border border-border-300 rounded appearance-none cursor-pointer font-normal text-sm leading-[21px] text-text-900",
|
|
68
|
+
"aria-label": "Items por p\xE1gina",
|
|
69
|
+
children: itemsPerPageOptions.map((option) => /* @__PURE__ */ jsxs("option", { value: option, children: [
|
|
70
|
+
option,
|
|
71
|
+
" itens"
|
|
72
|
+
] }, option))
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
CaretDown,
|
|
77
|
+
{
|
|
78
|
+
size: 14,
|
|
79
|
+
weight: "regular",
|
|
80
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 text-background-600 pointer-events-none"
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ jsxs("span", { className: "font-normal text-xs leading-[14px] text-text-950", children: [
|
|
85
|
+
"P\xE1gina ",
|
|
86
|
+
currentPage,
|
|
87
|
+
" de ",
|
|
88
|
+
totalPages
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ jsxs(
|
|
91
|
+
"button",
|
|
92
|
+
{
|
|
93
|
+
onClick: handlePrevious,
|
|
94
|
+
disabled: isFirstPage,
|
|
95
|
+
className: cn(
|
|
96
|
+
"flex flex-row justify-center items-center py-2 px-4 gap-2 rounded-3xl transition-all",
|
|
97
|
+
isFirstPage ? "opacity-50 cursor-not-allowed" : "hover:bg-primary-950/10 cursor-pointer"
|
|
98
|
+
),
|
|
99
|
+
"aria-label": "P\xE1gina anterior",
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsx(CaretLeft, { size: 12, weight: "bold", className: "text-primary-950" }),
|
|
102
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-xs leading-[14px] text-primary-950", children: "Anterior" })
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ jsxs(
|
|
107
|
+
"button",
|
|
108
|
+
{
|
|
109
|
+
onClick: handleNext,
|
|
110
|
+
disabled: isLastPage,
|
|
111
|
+
className: cn(
|
|
112
|
+
"flex flex-row justify-center items-center py-2 px-4 gap-2 rounded-3xl transition-all",
|
|
113
|
+
isLastPage ? "opacity-50 cursor-not-allowed" : "hover:bg-primary-950/10 cursor-pointer"
|
|
114
|
+
),
|
|
115
|
+
"aria-label": "Pr\xF3xima p\xE1gina",
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-xs leading-[14px] text-primary-950", children: "Pr\xF3xima" }),
|
|
118
|
+
/* @__PURE__ */ jsx(CaretRight, { size: 12, weight: "bold", className: "text-primary-950" })
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] })
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
TablePagination.displayName = "TablePagination";
|
|
128
|
+
var TablePagination_default = TablePagination;
|
|
129
|
+
export {
|
|
130
|
+
TablePagination_default as default
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Table/TablePagination.tsx","../../../src/utils/utils.ts"],"sourcesContent":["import { HTMLAttributes, ChangeEvent } from 'react';\nimport { CaretLeft, CaretRight, CaretDown } from 'phosphor-react';\nimport { cn } from '../../utils/utils';\n\nexport interface TablePaginationProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Total number of items\n */\n totalItems: number;\n /**\n * Current page (1-based)\n */\n currentPage: number;\n /**\n * Total number of pages\n */\n totalPages: number;\n /**\n * Items per page\n */\n itemsPerPage: number;\n /**\n * Available options for items per page\n * @default [10, 20, 50, 100]\n */\n itemsPerPageOptions?: number[];\n /**\n * Callback when page changes\n */\n onPageChange: (page: number) => void;\n /**\n * Callback when items per page changes\n */\n onItemsPerPageChange?: (itemsPerPage: number) => void;\n /**\n * Customizable label for items (e.g., \"escolas\", \"alunos\", \"atividades\")\n * @default \"itens\"\n */\n itemLabel?: string;\n}\n\n/**\n * Table pagination component with navigation controls and items per page selector\n *\n * @example\n * ```tsx\n * import { TablePagination } from 'analytica-frontend-lib';\n *\n * <TablePagination\n * totalItems={1000}\n * currentPage={1}\n * totalPages={10}\n * itemsPerPage={10}\n * itemsPerPageOptions={[10, 20, 50, 100]}\n * onPageChange={(page) => setCurrentPage(page)}\n * onItemsPerPageChange={(items) => setItemsPerPage(items)}\n * itemLabel=\"escolas\"\n * />\n * ```\n */\nconst TablePagination = ({\n totalItems,\n currentPage,\n totalPages,\n itemsPerPage,\n itemsPerPageOptions = [10, 20, 50, 100],\n onPageChange,\n onItemsPerPageChange,\n itemLabel = 'itens',\n className,\n ...props\n}: TablePaginationProps) => {\n const startItem = (currentPage - 1) * itemsPerPage + 1;\n\n const handlePrevious = () => {\n if (currentPage > 1) {\n onPageChange(currentPage - 1);\n }\n };\n\n const handleNext = () => {\n if (currentPage < totalPages) {\n onPageChange(currentPage + 1);\n }\n };\n\n const handleItemsPerPageChange = (e: ChangeEvent<HTMLSelectElement>) => {\n if (onItemsPerPageChange) {\n onItemsPerPageChange(Number(e.target.value));\n }\n };\n\n const isFirstPage = currentPage === 1;\n const isLastPage = currentPage === totalPages;\n\n return (\n <div\n className={cn(\n 'flex flex-col sm:flex-row items-center gap-3 sm:gap-4 w-full bg-background-50 rounded-xl p-4',\n 'sm:justify-between',\n className\n )}\n {...props}\n >\n {/* Items count - isolado à esquerda no desktop */}\n <span className=\"font-normal text-xs leading-[14px] text-text-800\">\n {startItem} de {totalItems} {itemLabel}\n </span>\n\n {/* Grupo direita: selector + page info + botões */}\n <div className=\"flex flex-wrap sm:flex-nowrap items-center gap-2 sm:gap-4 justify-center sm:justify-start\">\n {/* Items per page selector */}\n {onItemsPerPageChange && (\n <div className=\"relative\">\n <select\n value={itemsPerPage}\n onChange={handleItemsPerPageChange}\n className=\"w-24 h-9 py-0 px-3 pr-8 bg-background border border-border-300 rounded appearance-none cursor-pointer font-normal text-sm leading-[21px] text-text-900\"\n aria-label=\"Items por página\"\n >\n {itemsPerPageOptions.map((option) => (\n <option key={option} value={option}>\n {option} itens\n </option>\n ))}\n </select>\n <CaretDown\n size={14}\n weight=\"regular\"\n className=\"absolute right-3 top-1/2 -translate-y-1/2 text-background-600 pointer-events-none\"\n />\n </div>\n )}\n\n {/* Page info */}\n <span className=\"font-normal text-xs leading-[14px] text-text-950\">\n Página {currentPage} de {totalPages}\n </span>\n\n {/* Previous button */}\n <button\n onClick={handlePrevious}\n disabled={isFirstPage}\n className={cn(\n 'flex flex-row justify-center items-center py-2 px-4 gap-2 rounded-3xl transition-all',\n isFirstPage\n ? 'opacity-50 cursor-not-allowed'\n : 'hover:bg-primary-950/10 cursor-pointer'\n )}\n aria-label=\"Página anterior\"\n >\n <CaretLeft size={12} weight=\"bold\" className=\"text-primary-950\" />\n <span className=\"font-medium text-xs leading-[14px] text-primary-950\">\n Anterior\n </span>\n </button>\n\n {/* Next button */}\n <button\n onClick={handleNext}\n disabled={isLastPage}\n className={cn(\n 'flex flex-row justify-center items-center py-2 px-4 gap-2 rounded-3xl transition-all',\n isLastPage\n ? 'opacity-50 cursor-not-allowed'\n : 'hover:bg-primary-950/10 cursor-pointer'\n )}\n aria-label=\"Próxima página\"\n >\n <span className=\"font-medium text-xs leading-[14px] text-primary-950\">\n Próxima\n </span>\n <CaretRight size={12} weight=\"bold\" className=\"text-primary-950\" />\n </button>\n </div>\n </div>\n );\n};\n\nTablePagination.displayName = 'TablePagination';\n\nexport default TablePagination;\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport { syncDropdownState } from './dropdown';\n\n/**\n * Retorna a cor hexadecimal com opacidade 0.3 (4d) se não estiver em dark mode.\n * Se estiver em dark mode, retorna a cor original.\n *\n * @param hexColor - Cor hexadecimal (ex: \"#0066b8\" ou \"0066b8\")\n * @param isDark - booleano indicando se está em dark mode\n * @returns string - cor hexadecimal com opacidade se necessário\n */\nexport function getSubjectColorWithOpacity(\n hexColor: string | undefined,\n isDark: boolean\n): string | undefined {\n if (!hexColor) return undefined;\n // Remove o '#' se existir\n let color = hexColor.replace(/^#/, '').toLowerCase();\n\n if (isDark) {\n // Se está em dark mode, sempre remove opacidade se existir\n if (color.length === 8) {\n color = color.slice(0, 6);\n }\n return `#${color}`;\n } else {\n // Se não está em dark mode (light mode)\n let resultColor: string;\n if (color.length === 6) {\n // Adiciona opacidade 0.3 (4D) para cores de 6 dígitos\n resultColor = `#${color}4d`;\n } else if (color.length === 8) {\n // Já tem opacidade, retorna como está\n resultColor = `#${color}`;\n } else {\n // Para outros tamanhos (3, 4, 5 dígitos), retorna como está\n resultColor = `#${color}`;\n }\n return resultColor;\n }\n}\n"],"mappings":";AACA,SAAS,WAAW,YAAY,iBAAiB;;;ACDjD,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADoGM,SASM,KATN;AA7CN,IAAM,kBAAkB,CAAC;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAsB,CAAC,IAAI,IAAI,IAAI,GAAG;AAAA,EACtC;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,GAAG;AACL,MAA4B;AAC1B,QAAM,aAAa,cAAc,KAAK,eAAe;AAErD,QAAM,iBAAiB,MAAM;AAC3B,QAAI,cAAc,GAAG;AACnB,mBAAa,cAAc,CAAC;AAAA,IAC9B;AAAA,EACF;AAEA,QAAM,aAAa,MAAM;AACvB,QAAI,cAAc,YAAY;AAC5B,mBAAa,cAAc,CAAC;AAAA,IAC9B;AAAA,EACF;AAEA,QAAM,2BAA2B,CAAC,MAAsC;AACtE,QAAI,sBAAsB;AACxB,2BAAqB,OAAO,EAAE,OAAO,KAAK,CAAC;AAAA,IAC7C;AAAA,EACF;AAEA,QAAM,cAAc,gBAAgB;AACpC,QAAM,aAAa,gBAAgB;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAGJ;AAAA,6BAAC,UAAK,WAAU,oDACb;AAAA;AAAA,UAAU;AAAA,UAAK;AAAA,UAAW;AAAA,UAAE;AAA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1
1
|
import * as react from 'react';
|
|
2
2
|
import { HTMLAttributes, ThHTMLAttributes, TdHTMLAttributes } from 'react';
|
|
3
|
+
export { default as TablePagination, TablePaginationProps } from './TablePagination/index.mjs';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
3
5
|
|
|
4
6
|
type TableVariant = 'default' | 'borderless';
|
|
5
7
|
type TableRowState = 'default' | 'selected' | 'invalid' | 'disabled';
|
|
@@ -73,7 +75,7 @@ interface TableFooterProps extends HTMLAttributes<HTMLTableSectionElement> {
|
|
|
73
75
|
}
|
|
74
76
|
declare const TableFooter: react.ForwardRefExoticComponent<TableFooterProps & react.RefAttributes<HTMLTableSectionElement>>;
|
|
75
77
|
interface TableRowPropsExtended extends TableRowProps {
|
|
76
|
-
variant?: TableVariant;
|
|
78
|
+
variant?: TableVariant | 'defaultBorderless';
|
|
77
79
|
clickable?: boolean;
|
|
78
80
|
}
|
|
79
81
|
declare const TableRow: react.ForwardRefExoticComponent<TableRowPropsExtended & react.RefAttributes<HTMLTableRowElement>>;
|
package/dist/Table/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { HTMLAttributes, ThHTMLAttributes, TdHTMLAttributes } from 'react';
|
|
3
|
+
export { default as TablePagination, TablePaginationProps } from './TablePagination/index.js';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
3
5
|
|
|
4
6
|
type TableVariant = 'default' | 'borderless';
|
|
5
7
|
type TableRowState = 'default' | 'selected' | 'invalid' | 'disabled';
|
|
@@ -73,7 +75,7 @@ interface TableFooterProps extends HTMLAttributes<HTMLTableSectionElement> {
|
|
|
73
75
|
}
|
|
74
76
|
declare const TableFooter: react.ForwardRefExoticComponent<TableFooterProps & react.RefAttributes<HTMLTableSectionElement>>;
|
|
75
77
|
interface TableRowPropsExtended extends TableRowProps {
|
|
76
|
-
variant?: TableVariant;
|
|
78
|
+
variant?: TableVariant | 'defaultBorderless';
|
|
77
79
|
clickable?: boolean;
|
|
78
80
|
}
|
|
79
81
|
declare const TableRow: react.ForwardRefExoticComponent<TableRowPropsExtended & react.RefAttributes<HTMLTableRowElement>>;
|