pallote-react 0.16.6 → 0.16.8

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.
@@ -1,4 +1,5 @@
1
1
  import { ReactNode, HTMLAttributes } from 'react';
2
+ import { type TableCellKind } from './TableCell';
2
3
  export type DataTableFilterType = 'text' | 'select';
3
4
  export interface DataTableColumnDef<TData> {
4
5
  accessorKey: keyof TData & string;
@@ -8,6 +9,8 @@ export interface DataTableColumnDef<TData> {
8
9
  filterType?: DataTableFilterType;
9
10
  filterOptions?: string[];
10
11
  cell?: (value: TData[keyof TData & string], row: TData) => ReactNode;
12
+ className?: string;
13
+ kind?: TableCellKind;
11
14
  }
12
15
  export interface DataTableProps<TData> extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
13
16
  data: TData[];
@@ -21,5 +24,6 @@ export interface DataTableProps<TData> extends Omit<HTMLAttributes<HTMLDivElemen
21
24
  dense?: boolean;
22
25
  border?: boolean;
23
26
  className?: string;
27
+ kind?: TableCellKind;
24
28
  }
25
- export declare function DataTable<TData extends Record<string, unknown>>({ data, columns: columnDefs, enableSearch, searchPlaceholder, pageSize: initialPageSize, pageSizeOptions, striped, hasHover, dense, border, className, ...props }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
29
+ export declare function DataTable<TData extends Record<string, unknown>>({ data, columns: columnDefs, enableSearch, searchPlaceholder, pageSize: initialPageSize, pageSizeOptions, striped, hasHover, dense, border, kind: defaultKind, className, ...props }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,8 @@
1
1
  import { TdHTMLAttributes, ReactNode } from 'react';
2
- type TableCellKind = 'default' | 'number' | 'action';
2
+ export type TableCellKind = 'default' | 'number' | 'action';
3
3
  export interface TableCellProps extends TdHTMLAttributes<HTMLTableCellElement> {
4
4
  kind?: TableCellKind;
5
5
  className?: string;
6
6
  children?: ReactNode;
7
7
  }
8
8
  export declare const TableCell: ({ kind, className, children, ...props }: TableCellProps) => import("react/jsx-runtime").JSX.Element;
9
- export {};
package/dist/index.d.ts CHANGED
@@ -92,7 +92,7 @@ export type { SwitchProps } from './components/Switch';
92
92
  export type { TabProps } from './components/Tab';
93
93
  export type { TableProps } from './components/Table';
94
94
  export type { TableBodyProps } from './components/TableBody';
95
- export type { TableCellProps } from './components/TableCell';
95
+ export type { TableCellProps, TableCellKind } from './components/TableCell';
96
96
  export type { TablePaginationProps } from './components/TablePagination';
97
97
  export type { TableHeadProps } from './components/TableHead';
98
98
  export type { TableRowProps } from './components/TableRow';
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import classnames from 'classnames';
4
4
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { useReactTable, getPaginationRowModel, getFilteredRowModel, getSortedRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
7
+ import { MagnifyingGlassIcon, CaretDownIcon, CaretUpIcon } from '@phosphor-icons/react';
7
8
  import SyntaxHighlighter from 'react-syntax-highlighter';
8
9
 
9
10
  const Color = ({ fill, stroke, customFill, customStroke, className, children, ...props }) => {
@@ -123,7 +124,7 @@ const Accordion = ({ size = 'md', allowMultiple = false, transparent, className,
123
124
  }) }) }));
124
125
  };
125
126
 
126
- const o$6 = createContext({
127
+ const o$4 = createContext({
127
128
  color: "currentColor",
128
129
  size: "1em",
129
130
  weight: "regular",
@@ -147,7 +148,7 @@ const p = e$9.forwardRef(
147
148
  weight: f = "regular",
148
149
  mirrored: g = false,
149
150
  ...w
150
- } = e$9.useContext(o$6);
151
+ } = e$9.useContext(o$4);
151
152
  return /* @__PURE__ */ e$9.createElement(
152
153
  "svg",
153
154
  {
@@ -235,7 +236,7 @@ const AccordionItem = ({ icon, label, disabled, className, children, isOpen = fa
235
236
  ]), ...props, children: [jsxs("button", { type: "button", id: headerId, className: classnames('accordion_control'), onClick: handleClick, onKeyDown: handleKeyDown, "aria-expanded": isOpen, "aria-controls": panelId, "aria-disabled": disabled ? true : undefined, disabled: disabled, children: [icon ? jsx("span", { className: "accordion_icon", "aria-hidden": "true", children: icon }) : null, jsx(Text, { className: "accordion_header", variant: labelVariant, weight: "bold", children: label }), jsx(e$8, { className: "accordion_icon accordion_icon-arrow", "aria-hidden": "true" })] }), jsx("div", { id: panelId, ref: contentRef, role: "region", "aria-labelledby": headerId, className: classnames('accordion_content'), style: { maxHeight }, hidden: !isOpen, children: children })] }));
236
237
  };
237
238
 
238
- const a$8 = /* @__PURE__ */ new Map([
239
+ const a$6 = /* @__PURE__ */ new Map([
239
240
  [
240
241
  "bold",
241
242
  /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z" }))
@@ -268,7 +269,7 @@ const a$8 = /* @__PURE__ */ new Map([
268
269
  ]
269
270
  ]);
270
271
 
271
- const e$7 = e$9.forwardRef((r, t) => /* @__PURE__ */ e$9.createElement(p, { ref: t, ...r, weights: a$8 }));
272
+ const e$7 = e$9.forwardRef((r, t) => /* @__PURE__ */ e$9.createElement(p, { ref: t, ...r, weights: a$6 }));
272
273
  e$7.displayName = "XIcon";
273
274
 
274
275
  const Alert = ({ color = 'success', variant = 'toast', title, subtitle, dense, noIcon, show, onClose, className, ...props }) => {
@@ -463,66 +464,6 @@ const Chip = ({ color = 'default', dense, avatar, disabled, onClose, className,
463
464
  ]), role: "listitem", "aria-disabled": disabled ? true : undefined, ...props, children: [avatar ? (jsx("img", { className: classnames('chip_avatar'), src: avatar, alt: "", "aria-hidden": "true" })) : null, children, onClose ? (jsx("button", { type: "button", className: classnames('chip_close'), onClick: onClose, disabled: disabled, "aria-label": "Remove", children: jsx(e$7, { size: dense ? 16 : 20, "aria-hidden": "true" }) })) : null] }) }));
464
465
  };
465
466
 
466
- const a$7 = /* @__PURE__ */ new Map([
467
- [
468
- "bold",
469
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z" }))
470
- ],
471
- [
472
- "duotone",
473
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M208,160H48l80-80Z", opacity: "0.2" }), /* @__PURE__ */ e$9.createElement("path", { d: "M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z" }))
474
- ],
475
- [
476
- "fill",
477
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z" }))
478
- ],
479
- [
480
- "light",
481
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z" }))
482
- ],
483
- [
484
- "regular",
485
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z" }))
486
- ],
487
- [
488
- "thin",
489
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z" }))
490
- ]
491
- ]);
492
-
493
- const o$5 = e$9.forwardRef((r, t) => /* @__PURE__ */ e$9.createElement(p, { ref: t, ...r, weights: a$7 }));
494
- o$5.displayName = "CaretUpIcon";
495
-
496
- const a$6 = /* @__PURE__ */ new Map([
497
- [
498
- "bold",
499
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z" }))
500
- ],
501
- [
502
- "duotone",
503
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z", opacity: "0.2" }), /* @__PURE__ */ e$9.createElement("path", { d: "M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z" }))
504
- ],
505
- [
506
- "fill",
507
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z" }))
508
- ],
509
- [
510
- "light",
511
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z" }))
512
- ],
513
- [
514
- "regular",
515
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z" }))
516
- ],
517
- [
518
- "thin",
519
- /* @__PURE__ */ e$9.createElement(e$9.Fragment, null, /* @__PURE__ */ e$9.createElement("path", { d: "M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z" }))
520
- ]
521
- ]);
522
-
523
- const o$4 = e$9.forwardRef((s, n) => /* @__PURE__ */ e$9.createElement(p, { ref: n, ...s, weights: a$6 }));
524
- o$4.displayName = "MagnifyingGlassIcon";
525
-
526
467
  const DenseContext = createContext(false);
527
468
  const Table = ({ striped, hasHover, dense, border, className, children, ...props }) => {
528
469
  return (jsx(DenseContext.Provider, { value: dense ?? false, children: jsx("div", { className: classnames([
@@ -859,7 +800,7 @@ function ColumnFilter({ header }) {
859
800
  }
860
801
  return (jsx(Input, { dense: true, id: `filter-${header.id}`, label: `Filter ${header.column.columnDef.header}`, hideLabel: true, placeholder: "Filter...", className: "datatable_filter", value: filterValue, onChange: (e) => header.column.setFilterValue(e.target.value || undefined) }));
861
802
  }
862
- function DataTable({ data, columns: columnDefs, enableSearch, searchPlaceholder = 'Search...', pageSize: initialPageSize = 10, pageSizeOptions = [10, 25, 50, 100], striped, hasHover = true, dense, border, className, ...props }) {
803
+ function DataTable({ data, columns: columnDefs, enableSearch, searchPlaceholder = 'Search...', pageSize: initialPageSize = 10, pageSizeOptions = [10, 25, 50, 100], striped, hasHover = true, dense, border, kind: defaultKind, className, ...props }) {
863
804
  const [sorting, setSorting] = useState([]);
864
805
  const [columnFilters, setColumnFilters] = useState([]);
865
806
  const [globalFilter, setGlobalFilter] = useState('');
@@ -874,6 +815,8 @@ function DataTable({ data, columns: columnDefs, enableSearch, searchPlaceholder
874
815
  meta: {
875
816
  filterType: col.filterType ?? 'text',
876
817
  filterOptions: col.filterOptions,
818
+ className: col.className,
819
+ kind: col.kind,
877
820
  },
878
821
  })), [columnDefs]);
879
822
  const table = useReactTable({
@@ -892,11 +835,23 @@ function DataTable({ data, columns: columnDefs, enableSearch, searchPlaceholder
892
835
  },
893
836
  });
894
837
  const hasFilters = columnDefs.some(col => col.enableFiltering === true);
895
- return (jsxs("div", { className: classnames('datatable', className), ...props, children: [enableSearch && (jsx("div", { className: "datatable_search", children: jsx(Input, { id: "datatable-search", label: "Search", hideLabel: true, placeholder: searchPlaceholder, icon: jsx(o$4, {}), value: globalFilter, onChange: (e) => setGlobalFilter(e.target.value) }) })), jsxs(Table, { striped: striped, hasHover: hasHover, dense: dense, border: border, children: [jsxs(TableHead, { children: [table.getHeaderGroups().map(headerGroup => (jsx(TableRow, { children: headerGroup.headers.map(header => (jsx(TableCell, { className: classnames({
896
- 'datatable_sortable': header.column.getCanSort()
897
- }), onClick: header.column.getToggleSortingHandler(), "aria-sort": header.column.getIsSorted() === 'asc' ? 'ascending'
898
- : header.column.getIsSorted() === 'desc' ? 'descending'
899
- : undefined, children: jsxs("span", { className: "datatable_headerContent", children: [flexRender(header.column.columnDef.header, header.getContext()), header.column.getCanSort() && (jsx("span", { className: "datatable_sortIcon", "aria-hidden": "true", children: header.column.getIsSorted() === 'asc' ? (jsx(e$8, { size: 12 })) : header.column.getIsSorted() === 'desc' ? (jsx(o$5, { size: 12 })) : (jsx(e$8, { size: 12, className: "datatable_sortIcon-inactive" })) }))] }) }, header.id))) }, headerGroup.id))), hasFilters && (jsx(TableRow, { className: "datatable_filterRow", children: table.getHeaderGroups()[0].headers.map(header => (jsx(TableCell, { children: header.column.getCanFilter() ? (jsx(ColumnFilter, { header: header })) : null }, `filter-${header.id}`))) }))] }), jsx(TableBody, { children: table.getRowModel().rows.length === 0 ? (jsx(TableRow, { children: jsx(TableCell, { colSpan: columnDefs.length, className: "datatable_empty", children: "No results found" }) })) : (table.getRowModel().rows.map(row => (jsx(TableRow, { children: row.getVisibleCells().map(cell => (jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id)))) })] }), jsx(TablePagination, { pageIndex: table.getState().pagination.pageIndex, pageCount: table.getPageCount(), pageSize: table.getState().pagination.pageSize, pageSizeOptions: pageSizeOptions, totalRows: table.getFilteredRowModel().rows.length, onPageChange: (page) => table.setPageIndex(page), onPageSizeChange: (size) => table.setPageSize(size) })] }));
838
+ return (jsxs("div", { className: classnames('datatable', className), ...props, children: [enableSearch && (jsx("div", { className: "datatable_search", children: jsx(Input, { id: "datatable-search", label: "Search", hideLabel: true, placeholder: searchPlaceholder, icon: jsx(MagnifyingGlassIcon, {}), value: globalFilter, onChange: (e) => setGlobalFilter(e.target.value) }) })), jsxs(Table, { striped: striped, hasHover: hasHover, dense: dense, border: border, children: [jsxs(TableHead, { children: [table.getHeaderGroups().map(headerGroup => (jsx(TableRow, { children: headerGroup.headers.map(header => {
839
+ const meta = header.column.columnDef.meta;
840
+ const cellKind = meta?.kind ?? defaultKind ?? 'default';
841
+ return (jsx(TableCell, { kind: cellKind, className: classnames(meta?.className, {
842
+ 'datatable_sortable': header.column.getCanSort()
843
+ }), onClick: header.column.getToggleSortingHandler(), "aria-sort": header.column.getIsSorted() === 'asc' ? 'ascending'
844
+ : header.column.getIsSorted() === 'desc' ? 'descending'
845
+ : undefined, children: jsxs("span", { className: "datatable_headerContent", children: [flexRender(header.column.columnDef.header, header.getContext()), header.column.getCanSort() && (jsx("span", { className: "datatable_sortIcon", "aria-hidden": "true", children: header.column.getIsSorted() === 'asc' ? (jsx(CaretDownIcon, { size: 12 })) : header.column.getIsSorted() === 'desc' ? (jsx(CaretUpIcon, { size: 12 })) : (jsx(CaretDownIcon, { size: 12, className: "datatable_sortIcon-inactive" })) }))] }) }, header.id));
846
+ }) }, headerGroup.id))), hasFilters && (jsx(TableRow, { className: "datatable_filterRow", children: table.getHeaderGroups()[0].headers.map(header => {
847
+ const meta = header.column.columnDef.meta;
848
+ const cellKind = meta?.kind ?? defaultKind ?? 'default';
849
+ return (jsx(TableCell, { kind: cellKind, className: meta?.className, children: header.column.getCanFilter() ? (jsx(ColumnFilter, { header: header })) : null }, `filter-${header.id}`));
850
+ }) }))] }), jsx(TableBody, { children: table.getRowModel().rows.length === 0 ? (jsx(TableRow, { children: jsx(TableCell, { colSpan: columnDefs.length, className: "datatable_empty", children: "No results found" }) })) : (table.getRowModel().rows.map(row => (jsx(TableRow, { children: row.getVisibleCells().map(cell => {
851
+ const meta = cell.column.columnDef.meta;
852
+ const cellKind = meta?.kind ?? defaultKind ?? 'default';
853
+ return (jsx(TableCell, { kind: cellKind, className: meta?.className, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
854
+ }) }, row.id)))) })] }), jsx(TablePagination, { pageIndex: table.getState().pagination.pageIndex, pageCount: table.getPageCount(), pageSize: table.getState().pagination.pageSize, pageSizeOptions: pageSizeOptions, totalRows: table.getFilteredRowModel().rows.length, onPageChange: (page) => table.setPageIndex(page), onPageSizeChange: (size) => table.setPageSize(size) })] }));
900
855
  }
901
856
 
902
857
  const Divider = ({ direction = 'landscape', padding = 'md', className, ...props }) => {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pallote-react",
3
- "version": "0.16.6",
3
+ "version": "0.16.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pallote-react",
3
- "version": "0.16.6",
3
+ "version": "0.16.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",