@indico-data/design-system 2.3.2 → 2.4.1

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,78 +1,10 @@
1
- import React from 'react';
2
- import { TableColumn } from 'react-data-table-component';
3
- type LocalDirection = 'auto' | 'ltr' | 'rtl';
4
- type LocalAlignment = 'left' | 'right' | 'center';
5
- interface TableProps {
6
- columns: TableColumn<any>[];
7
- data: Record<string, any>[];
8
- responsive?: boolean;
9
- direction?: LocalDirection;
10
- subHeaderAlign?: LocalAlignment;
11
- subHeaderWrap?: boolean;
12
- pagination?: boolean;
13
- selectableRows?: boolean;
14
- keyField?: string;
15
- title?: string | React.ReactNode;
16
- striped?: boolean;
17
- highlightOnHover?: boolean;
18
- pointerOnHover?: boolean;
19
- dense?: boolean;
20
- persistTableHead?: boolean;
21
- noDataComponent?: string | React.ReactNode;
1
+ import { TableProps as RDTTableProps, Direction as RDTDirection, Alignment as RDTAlignment } from 'react-data-table-component';
2
+ export type Direction = `${RDTDirection}`;
3
+ export type Alignment = `${RDTAlignment}`;
4
+ export type TableProps<T> = Omit<RDTTableProps<T>, 'disabled' | 'progressPending' | 'direction' | 'subHeaderAlign'> & {
22
5
  isDisabled?: boolean;
23
- onRowClicked?: (row: Record<string, any>, event: React.MouseEvent) => void;
24
- onRowDoubleClicked?: (row: Record<string, any>, event: React.MouseEvent) => void;
25
- onRowMouseEnter?: (row: Record<string, any>, event: React.MouseEvent) => void;
26
- onRowMouseLeave?: (row: Record<string, any>, event: React.MouseEvent) => void;
27
- defaultSortFieldId?: string | number;
28
- defaultSortAsc?: boolean;
29
- sortIcon?: React.ReactNode;
30
- sortServer?: boolean;
31
- sortFunction?: any;
32
- onSort?: any;
33
- selectableRowsVisibleOnly?: boolean;
34
- selectableRowsHighlight?: boolean;
35
- selectableRowsSingle?: boolean;
36
- selectableRowsNoSelectAll?: boolean;
37
- selectableRowsComponent?: any;
38
- selectableRowsComponentProps?: Record<string, any>;
39
- clearSelectedRows?: boolean;
40
- selectableRowSelected?: (row: Record<string, any>) => boolean;
41
- selectableRowDisabled?: (row: Record<string, any>) => boolean;
42
- onSelectedRowsChange?: any;
43
- expandableRows?: boolean;
44
- expandableIcon?: any;
45
- expandableRowsComponent?: any;
46
- expandableRowDisabled?: any;
47
- expandableRowExpanded?: any;
48
- expandableRowsComponentProps?: Record<string, any>;
49
- expandOnRowClicked?: boolean;
50
- expandOnRowDoubleClicked?: boolean;
51
- expandableRowsHideExpander?: boolean;
52
- expandableInheritConditionalStyles?: boolean;
53
- onRowExpandToggled?: any;
54
- paginationServer?: boolean;
55
- paginationServerOptions?: Record<string, any>;
56
- paginationDefaultPage?: number;
57
- paginationResetDefaultPage?: boolean;
58
- paginationTotalRows?: number;
59
- paginationPerPage?: number;
60
- paginationRowsPerPageOptions?: number[];
61
- paginationComponent?: any;
62
- paginationComponentOptions?: Record<string, any>;
63
- paginationIconFirstPage?: any;
64
- paginationIconLastPage?: any;
65
- paginationIconNext?: any;
66
- paginationIconPrevious?: any;
67
- onChangePage?: any;
68
- onChangeRowsPerPage?: any;
69
- actions?: any;
70
- noHeader?: boolean;
71
- fixedHeader?: boolean;
72
- fixedHeaderScrollHeight?: string;
73
- subHeader?: boolean;
74
- subHeaderComponent?: any;
75
6
  isLoading?: boolean;
76
- }
77
- export declare const Table: (props: TableProps) => import("react/jsx-runtime").JSX.Element;
78
- export {};
7
+ direction: Direction;
8
+ subHeaderAlign: Alignment;
9
+ };
10
+ export declare const Table: <T>(props: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
  import { Table } from './Table';
3
+ import { SampleDataRow } from './sampleData';
3
4
  declare const meta: Meta;
4
5
  export default meta;
5
- type Story = StoryObj<typeof Table>;
6
+ type Story = StoryObj<typeof Table<SampleDataRow>>;
6
7
  export declare const Default: Story;
@@ -1,8 +1,9 @@
1
- export declare const sampleData: {
1
+ export interface SampleDataRow {
2
2
  name: string;
3
3
  class: string;
4
4
  age: number;
5
5
  weapon: string;
6
6
  backstory: string;
7
7
  favoriteMeal: string;
8
- }[];
8
+ }
9
+ export declare const sampleData: SampleDataRow[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "2.3.2",
3
+ "version": "2.4.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -22,7 +22,7 @@
22
22
  "all-releases": "npm view @indico-data/design-system versions",
23
23
  "latest-release": "npm dist-tags ls @indico-data/design-system",
24
24
  "generate-icons": "node scripts/generateIconTypes.js",
25
- "postinstall": "yarn generate-icons"
25
+ "postinstall": "node scripts/generateIconTypes.js"
26
26
  },
27
27
  "lint-staged": {
28
28
  "**/*": "prettier --write --ignore-unknown"
@@ -1,7 +1,6 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
  import { Table } from './Table';
3
- import { sampleData } from './sampleData';
4
- import React from 'react';
3
+ import { SampleDataRow, sampleData } from './sampleData';
5
4
 
6
5
  const meta: Meta = {
7
6
  title: 'Layout/Table',
@@ -106,6 +105,17 @@ const meta: Meta = {
106
105
  defaultValue: { summary: 'false' },
107
106
  },
108
107
  },
108
+ noTableHead: {
109
+ control: 'boolean',
110
+ description: 'Hides the the sort columns and titles (TableHead)',
111
+ table: {
112
+ category: 'Styling',
113
+ type: {
114
+ summary: 'boolean',
115
+ },
116
+ defaultValue: { summary: 'false' },
117
+ },
118
+ },
109
119
  onSort: {
110
120
  control: false,
111
121
  description: 'Callback to access the sort state when a column is clicked. Returns',
@@ -481,16 +491,7 @@ const meta: Meta = {
481
491
 
482
492
  export default meta;
483
493
 
484
- type Story = StoryObj<typeof Table>;
485
-
486
- interface DataRow {
487
- name: string;
488
- class: string;
489
- age: number;
490
- weapon: string;
491
- backstory: string;
492
- favoriteMeal: string;
493
- }
494
+ type Story = StoryObj<typeof Table<SampleDataRow>>;
494
495
 
495
496
  export const Default: Story = {
496
497
  args: {
@@ -507,10 +508,10 @@ export const Default: Story = {
507
508
  title: 'Character List',
508
509
  dense: true,
509
510
  noHeader: false,
511
+ noTableHead: false,
510
512
  noDataComponent: null,
511
513
  expandableRows: false,
512
514
  clearSelectedRows: false,
513
- onSort: false,
514
515
  subHeader: false,
515
516
  subHeaderComponent: null,
516
517
  paginationPerPage: 10,
@@ -541,7 +542,7 @@ export const Default: Story = {
541
542
  selector: (row) => row.favoriteMeal,
542
543
  },
543
544
  ],
544
- data: sampleData as DataRow[],
545
+ data: sampleData,
545
546
  },
546
547
  render: ({ ...args }) => <Table {...args} />,
547
548
  };
@@ -1,86 +1,25 @@
1
- import React from 'react';
2
- import DataTable, { TableColumn, Direction, Alignment } from 'react-data-table-component';
3
- import { LoadingComponent } from './LoadingComponent';
4
-
5
- type LocalDirection = 'auto' | 'ltr' | 'rtl';
6
- type LocalAlignment = 'left' | 'right' | 'center';
7
- interface TableProps {
8
- columns: TableColumn<any>[];
9
- data: Record<string, any>[];
10
- responsive?: boolean;
11
- direction?: LocalDirection;
12
- subHeaderAlign?: LocalAlignment;
13
- subHeaderWrap?: boolean;
14
- pagination?: boolean;
15
- selectableRows?: boolean;
16
- keyField?: string;
17
- title?: string | React.ReactNode;
18
- striped?: boolean;
19
- highlightOnHover?: boolean;
20
- pointerOnHover?: boolean;
21
- dense?: boolean;
22
- persistTableHead?: boolean;
23
- noDataComponent?: string | React.ReactNode;
24
- isDisabled?: boolean;
25
- onRowClicked?: (row: Record<string, any>, event: React.MouseEvent) => void;
26
- onRowDoubleClicked?: (row: Record<string, any>, event: React.MouseEvent) => void;
27
- onRowMouseEnter?: (row: Record<string, any>, event: React.MouseEvent) => void;
28
- onRowMouseLeave?: (row: Record<string, any>, event: React.MouseEvent) => void;
29
- defaultSortFieldId?: string | number;
30
- defaultSortAsc?: boolean;
31
- sortIcon?: React.ReactNode;
32
- sortServer?: boolean;
33
- sortFunction?: any;
34
- onSort?: any;
35
- selectableRowsVisibleOnly?: boolean;
36
- selectableRowsHighlight?: boolean;
37
- selectableRowsSingle?: boolean;
38
- selectableRowsNoSelectAll?: boolean;
39
- selectableRowsComponent?: any;
40
- selectableRowsComponentProps?: Record<string, any>;
41
- clearSelectedRows?: boolean;
42
- selectableRowSelected?: (row: Record<string, any>) => boolean;
43
- selectableRowDisabled?: (row: Record<string, any>) => boolean;
44
- onSelectedRowsChange?: any;
45
- expandableRows?: boolean;
46
- expandableIcon?: any;
47
- expandableRowsComponent?: any;
48
- expandableRowDisabled?: any;
49
- expandableRowExpanded?: any;
50
- expandableRowsComponentProps?: Record<string, any>;
51
- expandOnRowClicked?: boolean;
52
- expandOnRowDoubleClicked?: boolean;
53
- expandableRowsHideExpander?: boolean;
54
- expandableInheritConditionalStyles?: boolean;
55
- onRowExpandToggled?: any;
1
+ import DataTable, {
2
+ TableProps as RDTTableProps,
3
+ Direction as RDTDirection,
4
+ Alignment as RDTAlignment,
5
+ } from 'react-data-table-component';
56
6
 
57
- paginationServer?: boolean;
58
- paginationServerOptions?: Record<string, any>;
59
- paginationDefaultPage?: number;
60
- paginationResetDefaultPage?: boolean;
61
- paginationTotalRows?: number;
62
- paginationPerPage?: number;
63
- paginationRowsPerPageOptions?: number[];
64
- paginationComponent?: any;
65
- paginationComponentOptions?: Record<string, any>;
66
- paginationIconFirstPage?: any;
67
- paginationIconLastPage?: any;
68
- paginationIconNext?: any;
69
- paginationIconPrevious?: any;
70
- onChangePage?: any;
71
- onChangeRowsPerPage?: any;
7
+ import { LoadingComponent } from './LoadingComponent';
72
8
 
73
- actions?: any;
74
- noHeader?: boolean;
75
- fixedHeader?: boolean;
76
- fixedHeaderScrollHeight?: string;
77
- subHeader?: boolean;
78
- subHeaderComponent?: any;
9
+ export type Direction = `${RDTDirection}`;
10
+ export type Alignment = `${RDTAlignment}`;
79
11
 
12
+ export type TableProps<T> = Omit<
13
+ RDTTableProps<T>,
14
+ 'disabled' | 'progressPending' | 'direction' | 'subHeaderAlign'
15
+ > & {
16
+ isDisabled?: boolean;
80
17
  isLoading?: boolean;
81
- }
18
+ direction: Direction;
19
+ subHeaderAlign: Alignment;
20
+ };
82
21
 
83
- export const Table = (props: TableProps) => {
22
+ export const Table = <T,>(props: TableProps<T>) => {
84
23
  const {
85
24
  responsive = true,
86
25
  direction = 'auto',
@@ -96,8 +35,8 @@ export const Table = (props: TableProps) => {
96
35
  <div className="table-wrapper">
97
36
  <DataTable
98
37
  responsive={responsive}
99
- direction={direction as Direction}
100
- subHeaderAlign={subHeaderAlign as Alignment}
38
+ direction={direction as RDTDirection}
39
+ subHeaderAlign={subHeaderAlign as RDTAlignment}
101
40
  keyField={keyField}
102
41
  striped={striped}
103
42
  className={`${striped ? 'pf__table--striped' : ''}`}
@@ -1,4 +1,13 @@
1
- export const sampleData = [
1
+ export interface SampleDataRow {
2
+ name: string;
3
+ class: string;
4
+ age: number;
5
+ weapon: string;
6
+ backstory: string;
7
+ favoriteMeal: string;
8
+ }
9
+
10
+ export const sampleData: SampleDataRow[] = [
2
11
  {
3
12
  name: 'Thalion',
4
13
  class: 'Ranger',