pallote-react 0.16.8 → 0.16.10
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,13 +1,18 @@
|
|
|
1
1
|
import { ReactNode, HTMLAttributes } from 'react';
|
|
2
2
|
import { type TableCellKind } from './TableCell';
|
|
3
3
|
export type DataTableFilterType = 'text' | 'select';
|
|
4
|
+
/** Option value for filtering; label is shown in the dropdown. Use when row values are raw (e.g. in_progress) but you want formatted labels (e.g. In progress). */
|
|
5
|
+
export type DataTableFilterOption = string | {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
4
9
|
export interface DataTableColumnDef<TData> {
|
|
5
10
|
accessorKey: keyof TData & string;
|
|
6
11
|
header: string;
|
|
7
12
|
enableSorting?: boolean;
|
|
8
13
|
enableFiltering?: boolean;
|
|
9
14
|
filterType?: DataTableFilterType;
|
|
10
|
-
filterOptions?:
|
|
15
|
+
filterOptions?: DataTableFilterOption[];
|
|
11
16
|
cell?: (value: TData[keyof TData & string], row: TData) => ReactNode;
|
|
12
17
|
className?: string;
|
|
13
18
|
kind?: TableCellKind;
|
|
@@ -5,9 +5,8 @@ export interface SectionProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
5
5
|
align?: SectionAlign;
|
|
6
6
|
color?: SectionColor;
|
|
7
7
|
landing?: boolean;
|
|
8
|
-
header?: boolean;
|
|
9
8
|
className?: string;
|
|
10
9
|
children: ReactNode;
|
|
11
10
|
}
|
|
12
|
-
export declare const Section: ({ align, color, landing,
|
|
11
|
+
export declare const Section: ({ align, color, landing, className, children, ...props }: SectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
12
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
type
|
|
2
|
+
type TitleLevel = 1 | 2 | 3;
|
|
3
3
|
export interface SectionHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
label?: string;
|
|
5
5
|
title: string;
|
|
6
|
-
|
|
7
|
-
titleComponent?: TitleComponent;
|
|
6
|
+
titleLevel?: TitleLevel;
|
|
8
7
|
subtitle?: ReactNode;
|
|
9
8
|
actions?: ReactNode;
|
|
9
|
+
actionsPosition?: 'right' | 'bottom';
|
|
10
10
|
className?: string;
|
|
11
11
|
}
|
|
12
|
-
export declare const SectionHeader: ({ label, title,
|
|
12
|
+
export declare const SectionHeader: ({ label, title, titleLevel, subtitle, actions, actionsPosition, className, ...props }: SectionHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export type { CardMediaProps } from './components/CardMedia';
|
|
|
68
68
|
export type { CheckboxProps } from './components/Checkbox';
|
|
69
69
|
export type { CheckboxesProps } from './components/Checkboxes';
|
|
70
70
|
export type { ChipProps } from './components/Chip';
|
|
71
|
-
export type { DataTableProps, DataTableColumnDef, DataTableFilterType } from './components/DataTable';
|
|
71
|
+
export type { DataTableProps, DataTableColumnDef, DataTableFilterType, DataTableFilterOption } from './components/DataTable';
|
|
72
72
|
export type { DividerProps } from './components/Divider';
|
|
73
73
|
export type { InputProps } from './components/Input';
|
|
74
74
|
export type { InputLabelProps } from './components/InputLabel';
|
package/dist/index.js
CHANGED
|
@@ -790,15 +790,19 @@ const Input = ({ onChange, type = 'text', id, placeholder, label = 'Input', icon
|
|
|
790
790
|
: null), ...props })] }));
|
|
791
791
|
};
|
|
792
792
|
|
|
793
|
+
function normalizeFilterOption(opt) {
|
|
794
|
+
return typeof opt === 'string' ? { value: opt, label: opt } : opt;
|
|
795
|
+
}
|
|
793
796
|
function ColumnFilter({ header }) {
|
|
794
797
|
const columnDef = header.column.columnDef.meta;
|
|
795
798
|
const filterType = columnDef?.filterType ?? 'text';
|
|
796
799
|
const filterOptions = columnDef?.filterOptions ?? [];
|
|
797
800
|
const filterValue = header.column.getFilterValue() ?? '';
|
|
798
801
|
if (filterType === 'select') {
|
|
799
|
-
|
|
802
|
+
const options = filterOptions.map(normalizeFilterOption);
|
|
803
|
+
return (jsxs(Select, { dense: true, id: `filter-${header.id}`, label: `Filter ${header.column.columnDef.header}`, hideLabel: true, className: "datatable_filter", value: filterValue, onChange: (e) => header.column.setFilterValue(e.target.value || undefined), children: [jsx("option", { value: "", children: "All" }), options.map(({ value, label }) => (jsx("option", { value: value, children: label }, value)))] }));
|
|
800
804
|
}
|
|
801
|
-
return (jsx(Input, { dense: true, id: `filter-${header.id}`, label: `Filter ${header.column.columnDef.header}`, hideLabel: true, placeholder: "
|
|
805
|
+
return (jsx(Input, { dense: true, id: `filter-${header.id}`, label: `Filter ${header.column.columnDef.header}`, hideLabel: true, placeholder: "Search column", className: "datatable_filter", value: filterValue, onChange: (e) => header.column.setFilterValue(e.target.value || undefined) }));
|
|
802
806
|
}
|
|
803
807
|
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 }) {
|
|
804
808
|
const [sorting, setSorting] = useState([]);
|
|
@@ -941,26 +945,31 @@ const Nav = ({ direction, dense, className, children, ...props }) => {
|
|
|
941
945
|
]), ...props, children: jsx("div", { className: 'nav_container', children: children }) }));
|
|
942
946
|
};
|
|
943
947
|
|
|
944
|
-
const SectionHeader = ({ label, title,
|
|
948
|
+
const SectionHeader = ({ label, title, titleLevel = 2, subtitle, actions, actionsPosition, className, ...props }) => {
|
|
949
|
+
const titleVariant = titleLevel === 1 ? 'h2' : titleLevel === 2 ? 'h3' : 'h4';
|
|
950
|
+
const titleComponent = titleLevel === 1 ? 'h1' : titleLevel === 2 ? 'h2' : 'h3';
|
|
945
951
|
return (jsxs("div", { className: classnames([
|
|
946
952
|
'section_header',
|
|
953
|
+
`section_header-${titleLevel}`,
|
|
947
954
|
className
|
|
948
|
-
]), ...props, children: [label ? jsx(Text, { className: classnames('section_label'), children: label }) : null, jsx(Text, { className: "section_title", component: titleComponent
|
|
955
|
+
]), ...props, children: [label ? jsx(Text, { className: classnames('section_label'), children: label }) : null, jsxs("div", { className: "section_titleWrapper", children: [jsx(Text, { className: "section_title", variant: titleVariant, component: titleComponent, children: title }), actions && actionsPosition === 'right' ? (jsx(Display, { hide: "tablet", children: jsx("div", { className: "section_actions", children: actions }) })) : null] }), subtitle ? jsx("div", { className: classnames('section_subtitle'), children: subtitle }) : null, actions ? (actionsPosition === 'right' ? (jsx(Display, { show: "tablet", children: jsx("div", { className: "section_actions", children: actions }) })) : (jsx("div", { className: "section_actions", children: actions }))) : null] }));
|
|
949
956
|
};
|
|
950
957
|
|
|
951
|
-
const Section = ({ align = 'left', color = 'default', landing,
|
|
958
|
+
const Section = ({ align = 'left', color = 'default', landing, className, children, ...props }) => {
|
|
952
959
|
return (jsx("div", { className: classnames([
|
|
953
960
|
'section',
|
|
954
961
|
{
|
|
955
962
|
[`section-${align}`]: align,
|
|
956
963
|
[`section-${color}`]: color,
|
|
957
|
-
'section-landing': landing
|
|
958
|
-
'section-header': header
|
|
964
|
+
'section-landing': landing
|
|
959
965
|
},
|
|
960
966
|
className
|
|
961
|
-
]), ...props, children: jsx("div", { className: 'section_container', children:
|
|
962
|
-
if (
|
|
963
|
-
|
|
967
|
+
]), ...props, children: jsx("div", { className: 'section_container', children: Children.map(children, child => {
|
|
968
|
+
if (isValidElement(child) && child.type === SectionHeader) {
|
|
969
|
+
const currentTitleLevel = child.props.titleLevel;
|
|
970
|
+
return cloneElement(child, {
|
|
971
|
+
titleLevel: currentTitleLevel ?? (landing ? 1 : 2)
|
|
972
|
+
});
|
|
964
973
|
}
|
|
965
974
|
return child;
|
|
966
975
|
}) }) }));
|
package/dist/package.json
CHANGED