@indico-data/design-system 3.18.0 → 3.19.0
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/lib/components/forms/date/datePicker/types.d.ts +7 -0
- package/lib/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.d.ts +3 -0
- package/lib/components/forms/date/iconTriggerDatePicker/types.d.ts +5 -0
- package/lib/components/forms/date/inputDatePicker/SingleInputDatePicker.d.ts +2 -1
- package/lib/components/forms/date/inputDateRangePicker/InputDateRangePicker.d.ts +3 -0
- package/lib/components/forms/date/inputDateRangePicker/types.d.ts +7 -0
- package/lib/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.d.ts +2 -1
- package/lib/components/forms/select/Select.d.ts +3 -1
- package/lib/components/forms/select/types.d.ts +10 -0
- package/lib/components/forms/subcomponents/Label.d.ts +4 -0
- package/lib/components/forms/subcomponents/types.d.ts +5 -0
- package/lib/components/forms/timePicker/TimePicker.d.ts +4 -1
- package/lib/components/forms/timePicker/types.d.ts +5 -0
- package/lib/components/modal/ConfirmationModal.d.ts +1 -1
- package/lib/components/modal/Modal.d.ts +1 -1
- package/lib/components/modal/Modal.stories.d.ts +4 -0
- package/lib/components/modal/types.d.ts +19 -5
- package/lib/components/pagination/Pagination.d.ts +1 -1
- package/lib/components/pagination/index.d.ts +1 -0
- package/lib/components/pagination/types.d.ts +13 -0
- package/lib/components/stepper/Stepper.d.ts +1 -1
- package/lib/components/stepper/components/BackNavigation.d.ts +2 -1
- package/lib/components/stepper/components/NextNavigation.d.ts +3 -1
- package/lib/components/stepper/types.d.ts +11 -0
- package/lib/components/table/LoadingComponent.d.ts +5 -1
- package/lib/components/table/components/HorizontalStickyHeader.d.ts +4 -1
- package/lib/components/table/hooks/usePinnedColumnsManager.d.ts +2 -2
- package/lib/components/table/types.d.ts +18 -0
- package/lib/components/table/utils/processColumns.d.ts +2 -2
- package/lib/components/tanstackTable/TankstackTable.types.d.ts +19 -2
- package/lib/components/tanstackTable/TanstackTable.d.ts +1 -1
- package/lib/components/tanstackTable/components/NoResults/NoResults.d.ts +2 -1
- package/lib/components/tanstackTable/components/TablePagination/TablePagination.d.ts +3 -1
- package/lib/index.d.ts +143 -23
- package/lib/index.esm.js +130 -60
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +130 -60
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/button/Button.tsx +4 -18
- package/src/components/button/__tests__/Button.test.tsx +30 -28
- package/src/components/forms/date/datePicker/DatePicker.stories.tsx +10 -0
- package/src/components/forms/date/datePicker/DatePicker.tsx +9 -2
- package/src/components/forms/date/datePicker/types.ts +8 -0
- package/src/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.stories.tsx +10 -0
- package/src/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.tsx +12 -1
- package/src/components/forms/date/iconTriggerDatePicker/types.ts +5 -0
- package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.tsx +4 -3
- package/src/components/forms/date/inputDatePicker/__tests__/SingleInputDatePicker.test.tsx +2 -0
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.stories.tsx +10 -0
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.tsx +14 -2
- package/src/components/forms/date/inputDateRangePicker/types.ts +7 -0
- package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.tsx +3 -2
- package/src/components/forms/input/Input.tsx +1 -0
- package/src/components/forms/numberInput/NumberInput.tsx +1 -0
- package/src/components/forms/passwordInput/PasswordInput.tsx +7 -1
- package/src/components/forms/select/Select.stories.tsx +6 -5
- package/src/components/forms/select/Select.tsx +15 -1
- package/src/components/forms/select/types.ts +11 -0
- package/src/components/forms/subcomponents/Label.tsx +20 -3
- package/src/components/forms/subcomponents/types.ts +5 -0
- package/src/components/forms/textarea/Textarea.tsx +1 -0
- package/src/components/forms/timePicker/TimePicker.stories.tsx +10 -0
- package/src/components/forms/timePicker/TimePicker.tsx +10 -1
- package/src/components/forms/timePicker/types.ts +5 -0
- package/src/components/modal/ConfirmationModal.tsx +19 -14
- package/src/components/modal/Modal.stories.tsx +53 -22
- package/src/components/modal/Modal.tsx +8 -2
- package/src/components/modal/types.ts +21 -5
- package/src/components/pagination/Pagination.stories.tsx +11 -0
- package/src/components/pagination/Pagination.tsx +14 -5
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pagination/types.ts +14 -0
- package/src/components/stepper/Stepper.stories.tsx +11 -0
- package/src/components/stepper/Stepper.tsx +16 -2
- package/src/components/stepper/components/BackNavigation.tsx +5 -3
- package/src/components/stepper/components/NextNavigation.tsx +15 -5
- package/src/components/stepper/types.ts +12 -0
- package/src/components/table/LoadingComponent.tsx +6 -2
- package/src/components/table/Table.stories.tsx +10 -0
- package/src/components/table/Table.tsx +12 -2
- package/src/components/table/components/HorizontalStickyHeader.tsx +12 -1
- package/src/components/table/hooks/usePinnedColumnsManager.ts +3 -2
- package/src/components/table/types.ts +20 -0
- package/src/components/table/utils/processColumns.tsx +3 -1
- package/src/components/tanstackTable/TankstackTable.types.ts +20 -2
- package/src/components/tanstackTable/TanstackTable.stories.tsx +8 -6
- package/src/components/tanstackTable/TanstackTable.tsx +21 -11
- package/src/components/tanstackTable/components/NoResults/NoResults.tsx +9 -3
- package/src/components/tanstackTable/components/TablePagination/TablePagination.tsx +4 -1
- package/src/index.ts +1 -1
- package/src/storybook/formArgTypes.ts +10 -0
- package/src/storybookDocs/Permafrost.mdx +8 -0
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
+
/** Customizable text for Stepper. */
|
|
4
|
+
export interface StepperText {
|
|
5
|
+
/** Label for the "Previous Step" button. Default: "Previous Step" */
|
|
6
|
+
previousStep?: string;
|
|
7
|
+
/** Label for the "Next Step" button. Default: "Next Step" */
|
|
8
|
+
nextStep?: string;
|
|
9
|
+
/** Label for the "Finish" button. Default: "Finish" */
|
|
10
|
+
finish?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
export interface StepperProps {
|
|
4
14
|
/** An array of step objects that define the stepper navigation. */
|
|
5
15
|
steps: Step[];
|
|
@@ -18,6 +28,8 @@ export interface StepperProps {
|
|
|
18
28
|
children: React.ReactNode;
|
|
19
29
|
/** The function to call when a step is clicked ont he legend. */
|
|
20
30
|
onStepClick: (step: number) => void;
|
|
31
|
+
/** Customizable display text. */
|
|
32
|
+
text?: StepperText;
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
export interface StepperLegendProps {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface LoadingComponentProps {
|
|
2
|
+
loadingText: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const LoadingComponent = ({ loadingText }: LoadingComponentProps) => {
|
|
6
|
+
return <div className="table-loading">{loadingText}</div>;
|
|
3
7
|
};
|
|
@@ -494,6 +494,16 @@ const meta: Meta = {
|
|
|
494
494
|
disable: true,
|
|
495
495
|
},
|
|
496
496
|
},
|
|
497
|
+
text: {
|
|
498
|
+
control: 'object',
|
|
499
|
+
description: 'Customizable text.',
|
|
500
|
+
table: {
|
|
501
|
+
category: 'i18n Text',
|
|
502
|
+
type: {
|
|
503
|
+
summary: '{ loading?: string; unpinColumn?: string; pinColumn?: string }',
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
},
|
|
497
507
|
},
|
|
498
508
|
};
|
|
499
509
|
|
|
@@ -4,10 +4,16 @@ import DataTable, {
|
|
|
4
4
|
Alignment as RDTAlignment,
|
|
5
5
|
} from 'react-data-table-component';
|
|
6
6
|
import { LoadingComponent } from './LoadingComponent';
|
|
7
|
-
import { TableProps } from './types';
|
|
7
|
+
import { TableProps, TableText } from './types';
|
|
8
8
|
import { TablePagination } from './components/TablePagination';
|
|
9
9
|
import { usePinnedColumnsManager } from './hooks/usePinnedColumnsManager';
|
|
10
10
|
|
|
11
|
+
const DEFAULT_TEXT: Required<TableText> = {
|
|
12
|
+
loading: 'Loading...',
|
|
13
|
+
unpinColumn: 'Unpin column',
|
|
14
|
+
pinColumn: 'Pin column',
|
|
15
|
+
};
|
|
16
|
+
|
|
11
17
|
export const Table = <T,>(props: TableProps<T>) => {
|
|
12
18
|
const {
|
|
13
19
|
responsive = true,
|
|
@@ -26,14 +32,18 @@ export const Table = <T,>(props: TableProps<T>) => {
|
|
|
26
32
|
columns: initialColumns,
|
|
27
33
|
canPinColumns = false,
|
|
28
34
|
onPinnedColumnsChange,
|
|
35
|
+
text: textProp,
|
|
29
36
|
...rest
|
|
30
37
|
} = props;
|
|
31
38
|
|
|
39
|
+
const text = { ...DEFAULT_TEXT, ...textProp };
|
|
40
|
+
|
|
32
41
|
// Turns on/off column pinning.
|
|
33
42
|
const { columnsWithPinning } = usePinnedColumnsManager(
|
|
34
43
|
initialColumns,
|
|
35
44
|
canPinColumns,
|
|
36
45
|
onPinnedColumnsChange,
|
|
46
|
+
{ unpinColumn: text.unpinColumn, pinColumn: text.pinColumn },
|
|
37
47
|
);
|
|
38
48
|
|
|
39
49
|
const combinedClassName = classNames(className, {
|
|
@@ -59,7 +69,7 @@ export const Table = <T,>(props: TableProps<T>) => {
|
|
|
59
69
|
disabled={isDisabled}
|
|
60
70
|
noDataComponent={noDataComponent}
|
|
61
71
|
progressPending={isLoading}
|
|
62
|
-
progressComponent={<LoadingComponent />}
|
|
72
|
+
progressComponent={<LoadingComponent loadingText={text.loading} />}
|
|
63
73
|
pagination
|
|
64
74
|
paginationComponent={(props) => (
|
|
65
75
|
<TablePagination {...props} totalEntriesText={totalEntriesText} />
|
|
@@ -5,6 +5,13 @@ import {
|
|
|
5
5
|
applyStickyStylesToTableHeader,
|
|
6
6
|
clearStickyStyles,
|
|
7
7
|
} from './helpers';
|
|
8
|
+
import { HorizontalStickyHeaderText } from '../types';
|
|
9
|
+
|
|
10
|
+
const DEFAULT_TEXT: Required<HorizontalStickyHeaderText> = {
|
|
11
|
+
unpinColumn: 'Unpin column',
|
|
12
|
+
pinColumn: 'Pin column',
|
|
13
|
+
};
|
|
14
|
+
|
|
8
15
|
interface HorizontalStickyHeaderProps {
|
|
9
16
|
children: React.ReactNode;
|
|
10
17
|
position: number;
|
|
@@ -12,6 +19,8 @@ interface HorizontalStickyHeaderProps {
|
|
|
12
19
|
isPinned?: boolean;
|
|
13
20
|
forceUpdate?: number;
|
|
14
21
|
pinnedColumnIds: string[];
|
|
22
|
+
/** Customizable display text. */
|
|
23
|
+
text?: HorizontalStickyHeaderText;
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
const HorizontalStickyHeader = ({
|
|
@@ -20,7 +29,9 @@ const HorizontalStickyHeader = ({
|
|
|
20
29
|
onPinColumn,
|
|
21
30
|
isPinned = false,
|
|
22
31
|
pinnedColumnIds,
|
|
32
|
+
text: textProp,
|
|
23
33
|
}: HorizontalStickyHeaderProps) => {
|
|
34
|
+
const text = { ...DEFAULT_TEXT, ...textProp };
|
|
24
35
|
useEffect(() => {
|
|
25
36
|
const calculateWidth = async () => {
|
|
26
37
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
@@ -46,7 +57,7 @@ const HorizontalStickyHeader = ({
|
|
|
46
57
|
size="sm"
|
|
47
58
|
iconLeft="pin"
|
|
48
59
|
onClick={() => onPinColumn?.(`sticky-column-${position}`)}
|
|
49
|
-
ariaLabel={isPinned ?
|
|
60
|
+
ariaLabel={isPinned ? text.unpinColumn : text.pinColumn}
|
|
50
61
|
className={`table__column--${isPinned ? 'is-pinned' : 'is-not-pinned'} table__column__pin-action`}
|
|
51
62
|
/>
|
|
52
63
|
<div className="table__header-content">{children}</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useCallback, useMemo } from 'react';
|
|
2
|
-
import { TableColumn } from '../types';
|
|
2
|
+
import { TableColumn, HorizontalStickyHeaderText } from '../types';
|
|
3
3
|
import { sortPinnedColumns, getPreviousHeadersWidth } from '../components/helpers';
|
|
4
4
|
import { processColumns } from '../utils/processColumns';
|
|
5
5
|
|
|
@@ -11,6 +11,7 @@ export const usePinnedColumnsManager = <T>(
|
|
|
11
11
|
columns: TableColumn<T>[],
|
|
12
12
|
canPinColumns: boolean,
|
|
13
13
|
onPinnedColumnsChange?: (pinnedColumnIds: string[]) => void,
|
|
14
|
+
text?: HorizontalStickyHeaderText,
|
|
14
15
|
) => {
|
|
15
16
|
const pinnedColumnIds = columns.filter((column) => column.isPinned).map((column) => column.id);
|
|
16
17
|
|
|
@@ -137,7 +138,7 @@ export const usePinnedColumnsManager = <T>(
|
|
|
137
138
|
|
|
138
139
|
// Process columns for rendering with pin state
|
|
139
140
|
const columnsWithPinning = canPinColumns
|
|
140
|
-
? sortPinnedColumns(processColumns(columns, dataColumnIds, togglePinnedColumn), dataColumnIds)
|
|
141
|
+
? sortPinnedColumns(processColumns(columns, dataColumnIds, togglePinnedColumn, text), dataColumnIds)
|
|
141
142
|
: columns;
|
|
142
143
|
|
|
143
144
|
return {
|
|
@@ -19,6 +19,24 @@ export interface PinnableColumn<T> extends RDTTableColumn<T> {
|
|
|
19
19
|
|
|
20
20
|
export type TableColumn<T> = PinnableColumn<T>;
|
|
21
21
|
|
|
22
|
+
/** Customizable text for Table. */
|
|
23
|
+
export interface TableText {
|
|
24
|
+
/** Text to display while loading. Default: "Loading..." */
|
|
25
|
+
loading?: string;
|
|
26
|
+
/** Aria label for unpinning a column. Default: "Unpin column" */
|
|
27
|
+
unpinColumn?: string;
|
|
28
|
+
/** Aria label for pinning a column. Default: "Pin column" */
|
|
29
|
+
pinColumn?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Customizable text for HorizontalStickyHeader. */
|
|
33
|
+
export interface HorizontalStickyHeaderText {
|
|
34
|
+
/** Aria label for unpinning a column. Default: "Unpin column" */
|
|
35
|
+
unpinColumn?: string;
|
|
36
|
+
/** Aria label for pinning a column. Default: "Pin column" */
|
|
37
|
+
pinColumn?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
22
40
|
export interface TableProps<T>
|
|
23
41
|
extends Omit<IDataTableProps<T>, 'paginationComponent' | 'direction' | 'subHeaderAlign'> {
|
|
24
42
|
/** The columns to display in the table. All columns require a unique id property. For pinned columns, please see the pinned example below. */
|
|
@@ -39,4 +57,6 @@ export interface TableProps<T>
|
|
|
39
57
|
canPinColumns?: boolean;
|
|
40
58
|
/** Callback that receives the IDs of the pinned columns when they change. */
|
|
41
59
|
onPinnedColumnsChange?: (pinnedColumnIds: any[]) => void;
|
|
60
|
+
/** Customizable display text. */
|
|
61
|
+
text?: TableText;
|
|
42
62
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TableColumn } from '../types';
|
|
1
|
+
import { TableColumn, HorizontalStickyHeaderText } from '../types';
|
|
2
2
|
import HorizontalStickyHeader from '../components/HorizontalStickyHeader';
|
|
3
3
|
import { getPinnedColumnStyles } from '../components/helpers';
|
|
4
4
|
|
|
@@ -6,6 +6,7 @@ export const processColumns = <T,>(
|
|
|
6
6
|
columns: TableColumn<T>[],
|
|
7
7
|
pinnedColumnIds: string[],
|
|
8
8
|
togglePinnedColumn: (id: string) => void,
|
|
9
|
+
text?: HorizontalStickyHeaderText,
|
|
9
10
|
): TableColumn<T>[] => {
|
|
10
11
|
return columns.map((column, index) => {
|
|
11
12
|
const dataColumnId = `sticky-column-${index}`;
|
|
@@ -18,6 +19,7 @@ export const processColumns = <T,>(
|
|
|
18
19
|
isPinned={isPinned}
|
|
19
20
|
onPinColumn={() => togglePinnedColumn(column.id)}
|
|
20
21
|
pinnedColumnIds={pinnedColumnIds}
|
|
22
|
+
text={text}
|
|
21
23
|
>
|
|
22
24
|
{column.name}
|
|
23
25
|
</HorizontalStickyHeader>
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { Row, ColumnDef, SortingState } from '@tanstack/react-table';
|
|
2
2
|
|
|
3
|
+
/** Customizable text for TanstackTable. */
|
|
4
|
+
export interface TanstackTableText {
|
|
5
|
+
/** Message while table is loading. Default: "Table is loading..." */
|
|
6
|
+
loading?: string;
|
|
7
|
+
/** Message when no results found. Default: "No results found." */
|
|
8
|
+
noResults?: string;
|
|
9
|
+
/** Message when there's an error loading data. Default: "There was an error loading the data." */
|
|
10
|
+
error?: string;
|
|
11
|
+
/** Text for reset filters button. Default: "Reset filters" */
|
|
12
|
+
resetFilters?: string;
|
|
13
|
+
/** Singular entry text. Default: "entry" */
|
|
14
|
+
entry?: string;
|
|
15
|
+
/** Plural entries text. Default: "entries" */
|
|
16
|
+
entries?: string;
|
|
17
|
+
/** "of" text in pagination (e.g., "5 of 10 entries"). Default: "of" */
|
|
18
|
+
of?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
3
21
|
export type WithPaginationProps = {
|
|
4
22
|
/** Number of rows to display per pagination page. */
|
|
5
23
|
rowsPerPage: number;
|
|
@@ -51,8 +69,6 @@ export type Props<T extends object> = {
|
|
|
51
69
|
hasFilters?: boolean;
|
|
52
70
|
/** When this is true, the table is considered to be in a loading state. */
|
|
53
71
|
isLoading?: boolean;
|
|
54
|
-
/** Message to display when the table is loading. */
|
|
55
|
-
isLoadingMessage?: string;
|
|
56
72
|
/** Columns that are pinned by default. */
|
|
57
73
|
defaultPinnedColumns?: string[];
|
|
58
74
|
/** Callback when a row is clicked. */
|
|
@@ -69,4 +85,6 @@ export type Props<T extends object> = {
|
|
|
69
85
|
onSelectAllChange?: (isSelected: boolean) => void;
|
|
70
86
|
/** You may pass a default sorting state to the table. This will be used to sort the table by default. This is useful if you want to sort the table by a column by default. */
|
|
71
87
|
defaultSorting?: SortingState;
|
|
88
|
+
/** Customizable display text. */
|
|
89
|
+
text?: TanstackTableText;
|
|
72
90
|
} & PaginationProps;
|
|
@@ -19,7 +19,6 @@ const meta: Meta = {
|
|
|
19
19
|
clearFilters: () => {},
|
|
20
20
|
hasFilters: false,
|
|
21
21
|
isLoading: false,
|
|
22
|
-
isLoadingMessage: 'Table is loading...',
|
|
23
22
|
enableRowSelection: true,
|
|
24
23
|
showPagination: false,
|
|
25
24
|
onClickRow: null,
|
|
@@ -116,12 +115,15 @@ const meta: Meta = {
|
|
|
116
115
|
defaultValue: { summary: 'false' },
|
|
117
116
|
},
|
|
118
117
|
},
|
|
119
|
-
|
|
120
|
-
control:
|
|
118
|
+
text: {
|
|
119
|
+
control: 'object',
|
|
120
|
+
description: 'Customizable text.',
|
|
121
121
|
table: {
|
|
122
|
-
category: '
|
|
123
|
-
type: {
|
|
124
|
-
|
|
122
|
+
category: 'i18n Text',
|
|
123
|
+
type: {
|
|
124
|
+
summary:
|
|
125
|
+
'{ loading?: string; noResults?: string; error?: string; resetFilters?: string; entry?: string; entries?: string; of?: string }',
|
|
126
|
+
},
|
|
125
127
|
},
|
|
126
128
|
},
|
|
127
129
|
defaultPinnedColumns: {
|
|
@@ -12,12 +12,22 @@ import { ActionBar } from './components/ActionBar';
|
|
|
12
12
|
import { NoResults } from './components/NoResults';
|
|
13
13
|
import { isNil } from 'lodash';
|
|
14
14
|
import { TablePagination } from './components/TablePagination';
|
|
15
|
-
import { Props } from './TankstackTable.types';
|
|
15
|
+
import { Props, TanstackTableText } from './TankstackTable.types';
|
|
16
16
|
import { useTanstackTable } from './useTanstackTable';
|
|
17
17
|
import { TableHeader } from './components/TableHeader';
|
|
18
18
|
import { TableBody } from './components/TableBody';
|
|
19
19
|
import { TableLoading } from './components/TableLoading/TableLoading';
|
|
20
20
|
|
|
21
|
+
const DEFAULT_TEXT: Required<TanstackTableText> = {
|
|
22
|
+
loading: 'Table is loading...',
|
|
23
|
+
noResults: 'No results found.',
|
|
24
|
+
error: 'There was an error loading the data.',
|
|
25
|
+
resetFilters: 'Reset filters',
|
|
26
|
+
entry: 'entry',
|
|
27
|
+
entries: 'entries',
|
|
28
|
+
of: 'of',
|
|
29
|
+
};
|
|
30
|
+
|
|
21
31
|
export function TanstackTable<T extends object>({
|
|
22
32
|
columns: defaultColumns,
|
|
23
33
|
data,
|
|
@@ -34,15 +44,16 @@ export function TanstackTable<T extends object>({
|
|
|
34
44
|
hasFilters,
|
|
35
45
|
showPagination = true,
|
|
36
46
|
isLoading = false,
|
|
37
|
-
isLoadingMessage = 'Table is loading...',
|
|
38
47
|
defaultPinnedColumns,
|
|
39
48
|
onRowClick,
|
|
40
49
|
activeRows = [],
|
|
41
50
|
isStriped = true,
|
|
42
51
|
actionBarClassName,
|
|
43
52
|
defaultSorting,
|
|
53
|
+
text: textProp,
|
|
44
54
|
...rest
|
|
45
55
|
}: Props<T & { id: string }>) {
|
|
56
|
+
const text = { ...DEFAULT_TEXT, ...textProp };
|
|
46
57
|
const {
|
|
47
58
|
columns,
|
|
48
59
|
defaultData,
|
|
@@ -120,11 +131,8 @@ export function TanstackTable<T extends object>({
|
|
|
120
131
|
<NoResults
|
|
121
132
|
clearFilters={clearFilters}
|
|
122
133
|
hasFilters={hasFilters}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
? error?.errorMessage ?? 'There was an error isLoading the data.'
|
|
126
|
-
: 'No results found.'
|
|
127
|
-
}
|
|
134
|
+
resetFiltersText={text.resetFilters}
|
|
135
|
+
message={hasErrorAndIsNotLoading ? error?.errorMessage ?? text.error : text.noResults}
|
|
128
136
|
/>
|
|
129
137
|
</td>
|
|
130
138
|
</tr>
|
|
@@ -132,7 +140,7 @@ export function TanstackTable<T extends object>({
|
|
|
132
140
|
}
|
|
133
141
|
|
|
134
142
|
if (isLoading) {
|
|
135
|
-
return <TableLoading columns={columns} message={
|
|
143
|
+
return <TableLoading columns={columns} message={text.loading} />;
|
|
136
144
|
}
|
|
137
145
|
|
|
138
146
|
return (
|
|
@@ -169,10 +177,12 @@ export function TanstackTable<T extends object>({
|
|
|
169
177
|
onChangePage={onChangePage}
|
|
170
178
|
rowsPerPage={rowsPerPage}
|
|
171
179
|
totalEntriesText={
|
|
172
|
-
totalEntriesText ??
|
|
173
|
-
|
|
174
|
-
|
|
180
|
+
totalEntriesText ??
|
|
181
|
+
(rowCount === 1
|
|
182
|
+
? `1 ${text.entry}`
|
|
183
|
+
: `${totalRowsOnPage} ${text.of} ${rowCount} ${text.entries}`)
|
|
175
184
|
}
|
|
185
|
+
text={{ of: text.of }}
|
|
176
186
|
/>
|
|
177
187
|
) : null}
|
|
178
188
|
</div>
|
|
@@ -4,16 +4,22 @@ type Props = {
|
|
|
4
4
|
clearFilters?: () => void;
|
|
5
5
|
hasFilters?: boolean;
|
|
6
6
|
message: string;
|
|
7
|
+
resetFiltersText?: string;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
|
-
export function NoResults({
|
|
10
|
+
export function NoResults({
|
|
11
|
+
clearFilters,
|
|
12
|
+
hasFilters,
|
|
13
|
+
message,
|
|
14
|
+
resetFiltersText = 'Reset filters',
|
|
15
|
+
}: Props) {
|
|
10
16
|
return (
|
|
11
17
|
<div className="tanstack-table__no-results" data-testid="tanstack-table-no-results">
|
|
12
18
|
<p className="tanstack-table__no-results__text">{message}</p>
|
|
13
19
|
{hasFilters && (
|
|
14
20
|
<p className="tanstack-table__no-results__text">
|
|
15
|
-
<Button ariaLabel=
|
|
16
|
-
|
|
21
|
+
<Button ariaLabel={resetFiltersText} variant="link" onClick={clearFilters}>
|
|
22
|
+
{resetFiltersText}
|
|
17
23
|
</Button>
|
|
18
24
|
</p>
|
|
19
25
|
)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pagination as PaginationComponent } from '../../../pagination';
|
|
1
|
+
import { Pagination as PaginationComponent, PaginationText } from '../../../pagination';
|
|
2
2
|
import { Row, Col } from '../../../grid';
|
|
3
3
|
|
|
4
4
|
interface TablePaginationProps {
|
|
@@ -7,6 +7,7 @@ interface TablePaginationProps {
|
|
|
7
7
|
onChangePage: (page: number) => void;
|
|
8
8
|
currentPage: number;
|
|
9
9
|
totalEntriesText?: string;
|
|
10
|
+
text?: PaginationText;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export const TablePagination = ({
|
|
@@ -15,6 +16,7 @@ export const TablePagination = ({
|
|
|
15
16
|
onChangePage,
|
|
16
17
|
currentPage,
|
|
17
18
|
totalEntriesText,
|
|
19
|
+
text,
|
|
18
20
|
}: TablePaginationProps) => {
|
|
19
21
|
const totalPages = Math.ceil(rowCount / rowsPerPage);
|
|
20
22
|
|
|
@@ -37,6 +39,7 @@ export const TablePagination = ({
|
|
|
37
39
|
totalPages={totalPages}
|
|
38
40
|
currentPage={currentPage}
|
|
39
41
|
onChange={(page) => onChangePage(page)}
|
|
42
|
+
text={text}
|
|
40
43
|
/>
|
|
41
44
|
</Col>
|
|
42
45
|
</Row>
|
package/src/index.ts
CHANGED
|
@@ -51,7 +51,7 @@ export type {
|
|
|
51
51
|
SortingFn,
|
|
52
52
|
} from '@tanstack/react-table';
|
|
53
53
|
export type { DateRange } from 'react-day-picker';
|
|
54
|
-
export type { SelectOption } from './components/forms/select/types';
|
|
54
|
+
export type { SelectOption, SelectText } from './components/forms/select/types';
|
|
55
55
|
|
|
56
56
|
// Functions
|
|
57
57
|
export {
|
|
@@ -46,6 +46,16 @@ const labelArgTypes: ArgTypes = {
|
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
|
+
text: {
|
|
50
|
+
control: 'object',
|
|
51
|
+
description: 'Customizable text.',
|
|
52
|
+
table: {
|
|
53
|
+
category: 'i18n Text',
|
|
54
|
+
type: {
|
|
55
|
+
summary: '{ required?: string }',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
49
59
|
};
|
|
50
60
|
|
|
51
61
|
const baseInputArgTypes: ArgTypes = {
|
|
@@ -62,6 +62,14 @@ import { Icon } from '@indico-data/design-system';
|
|
|
62
62
|
<Icon name="indico-o" />;
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
### The `text` Prop
|
|
66
|
+
|
|
67
|
+
Components expose generic UI strings via a `text` prop to enable i18n. These are strings that are the same regardless of context (like "Loading...", "Close", "Next Page"). All have English defaults, pass custom values to override:
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
<Select text={{ placeholder: 'Choisir...', noOptions: 'Aucune option' }} />
|
|
71
|
+
```
|
|
72
|
+
|
|
65
73
|
### Utility Classes
|
|
66
74
|
|
|
67
75
|
Utility classes are pre-defined CSS classes that provide quick and easy styling options for common design patterns. They help maintain consistency and speed up development by offering ready-to-use styles for margins, typography, and more. For a complete list of available utility classes and their usage, see our [Utility Classes documentation](/docs/utility-classes-overview--docs).
|