@sebgroup/green-react 2.6.2 → 3.0.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.
- package/index.esm.js +1946 -875
- package/package.json +4 -4
- package/src/index.d.ts +1 -0
- package/src/lib/datepicker/datepicker.d.ts +18 -2
- package/src/lib/dropdown/dropdown.d.ts +3 -1
- package/src/lib/stepper/stepper.d.ts +10 -3
- package/src/lib/table/components/Table.d.ts +13 -0
- package/src/lib/table/components/context/TableContextProvider.d.ts +19 -0
- package/src/lib/table/components/index.d.ts +9 -0
- package/src/lib/table/components/parts/TableBody/TableBody.d.ts +4 -0
- package/src/lib/table/components/parts/TableBody/index.d.ts +1 -0
- package/src/lib/table/components/parts/TableCell/TableCell.d.ts +3 -0
- package/src/lib/table/components/parts/TableCell/index.d.ts +1 -0
- package/src/lib/table/components/parts/TableHeader/TableHeader.d.ts +4 -0
- package/src/lib/table/components/parts/TableHeader/index.d.ts +1 -0
- package/src/lib/table/components/parts/TableHeaderCell/TableHeaderCell.d.ts +9 -0
- package/src/lib/table/components/parts/TableHeaderCell/index.d.ts +1 -0
- package/src/lib/table/components/parts/TableRow/TableRow.d.ts +15 -0
- package/src/lib/table/components/parts/TableRow/index.d.ts +1 -0
- package/src/lib/table/components/parts/helperFunctions/helperFunctions.d.ts +51 -0
- package/src/lib/table/components/parts/helperFunctions/index.d.ts +1 -0
- package/src/lib/table/components/table-typings.d.ts +14 -0
- package/src/lib/table/story/multiple-story-tables.d.ts +17 -0
- package/src/lib/datepicker/hook.d.ts +0 -12
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebgroup/green-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": "^17 || ^18",
|
|
6
6
|
"react-dom": "^17 || ^18"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@sebgroup/green-core": "^1.
|
|
10
|
-
"@sebgroup/chlorophyll": "^
|
|
11
|
-
"@sebgroup/extract": "^
|
|
9
|
+
"@sebgroup/green-core": "^1.4.1",
|
|
10
|
+
"@sebgroup/chlorophyll": "^3.0.1",
|
|
11
|
+
"@sebgroup/extract": "^3.0.0",
|
|
12
12
|
"@lit/react": "^1.0.2",
|
|
13
13
|
"classnames": "^2.3.2"
|
|
14
14
|
},
|
package/src/index.d.ts
CHANGED
|
@@ -18,4 +18,5 @@ export * from './lib/tabs/tabs';
|
|
|
18
18
|
export * from './lib/modal/modal';
|
|
19
19
|
export * from './lib/context-menu/context-menu';
|
|
20
20
|
export * from './types';
|
|
21
|
+
export * from './lib/table/components';
|
|
21
22
|
export { AlertRibbon as Alert } from './lib/alert-ribbon/alert-ribbon';
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
1
|
+
import { GdsDatepicker } from '@sebgroup/green-core';
|
|
2
|
+
export declare const CoreDatepicker: import("@lit/react").ReactWebComponent<GdsDatepicker, {
|
|
3
|
+
onchange: string;
|
|
4
|
+
}>;
|
|
5
|
+
export interface DatepickerOptions {
|
|
6
|
+
label?: string;
|
|
7
|
+
onChange?: (value: any) => void;
|
|
8
|
+
minDate?: Date;
|
|
9
|
+
maxDate?: Date;
|
|
10
|
+
value?: Date;
|
|
11
|
+
showWeeks?: boolean;
|
|
12
|
+
testId?: string;
|
|
13
|
+
/** @deprecated Use `value` instead */
|
|
14
|
+
selectedDate?: Date;
|
|
15
|
+
/** @deprecated Use `value` instead */
|
|
16
|
+
currentDate?: Date;
|
|
17
|
+
}
|
|
18
|
+
export declare const Datepicker: ({ label, onChange, minDate, maxDate, value, showWeeks, testId, selectedDate, currentDate, ...props }: DatepickerOptions) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -28,6 +28,8 @@ export interface DropdownArgs {
|
|
|
28
28
|
useValue?: string;
|
|
29
29
|
validator?: IValidator;
|
|
30
30
|
value?: any;
|
|
31
|
+
/** Force width of the popover to match trigger */
|
|
32
|
+
syncPopoverWidth?: boolean;
|
|
31
33
|
}
|
|
32
34
|
export interface DropdownTexts {
|
|
33
35
|
placeholder?: string;
|
|
@@ -45,5 +47,5 @@ export declare const CoreOption: import("@lit/react").ReactWebComponent<GdsOptio
|
|
|
45
47
|
export interface DropdownProps extends DropdownArgs {
|
|
46
48
|
onChange?: OnChange;
|
|
47
49
|
}
|
|
48
|
-
export declare const Dropdown: ({ compareWith, display, id, informationLabel, label, multiSelect, onChange, options, searchFilter, searchable, texts, useValue, validator, value, }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare const Dropdown: ({ compareWith, display, id, informationLabel, label, multiSelect, onChange, options, searchFilter, searchable, texts, useValue, validator, value, syncPopoverWidth, }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
49
51
|
export default Dropdown;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { IValidator
|
|
2
|
-
|
|
1
|
+
import { IValidator } from '@sebgroup/extract';
|
|
2
|
+
import { ChangeEventHandler, DetailedHTMLProps, InputHTMLAttributes } from 'react';
|
|
3
|
+
export interface StepperProps extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
|
|
4
|
+
id?: string;
|
|
5
|
+
value?: string | number;
|
|
6
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
3
7
|
label?: string;
|
|
4
8
|
description?: string;
|
|
5
9
|
statusMessage?: string;
|
|
6
10
|
validator?: IValidator;
|
|
11
|
+
onIncrease?: () => void;
|
|
12
|
+
onDecrease?: () => void;
|
|
13
|
+
testId?: string;
|
|
7
14
|
}
|
|
8
|
-
export declare function Stepper({ id, label, description, statusMessage, validator, value, onChange,
|
|
15
|
+
export declare function Stepper({ id, label, description, statusMessage, validator, value, onChange, onIncrease, onDecrease, testId, ...props }: StepperProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SortedColumn } from './context/TableContextProvider';
|
|
3
|
+
export declare type TableProps = JSX.IntrinsicElements['table'] & {
|
|
4
|
+
/** callback when row is selected */
|
|
5
|
+
onRowSelect?: (event: React.ChangeEvent<HTMLInputElement>, rowKey: string) => void;
|
|
6
|
+
/** callback when row is expanded */
|
|
7
|
+
onRowExpand?: (isExpanded: boolean, rowKey: string) => void;
|
|
8
|
+
/** callback when column is sorted */
|
|
9
|
+
onSort?: (sortedColumn: SortedColumn) => void;
|
|
10
|
+
/** preset sorted column */
|
|
11
|
+
sortedColumn?: SortedColumn | null;
|
|
12
|
+
};
|
|
13
|
+
export declare const Table: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<TableProps, "ref"> & React.RefAttributes<HTMLTableElement>>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SortDirection } from '../table-typings';
|
|
3
|
+
export interface SortedColumn<T = any> {
|
|
4
|
+
accessor?: keyof T;
|
|
5
|
+
sortDirection: SortDirection;
|
|
6
|
+
}
|
|
7
|
+
export interface TableState {
|
|
8
|
+
sortedColumn: SortedColumn | null;
|
|
9
|
+
expandedRows: Array<string>;
|
|
10
|
+
}
|
|
11
|
+
export declare type TableContextType = {
|
|
12
|
+
tableState: TableState;
|
|
13
|
+
setTableState: (newState: TableState) => void;
|
|
14
|
+
onRowSelect?: (event: React.ChangeEvent<HTMLInputElement>, rowKey: string) => void;
|
|
15
|
+
onRowExpand?: (isExpanded: boolean, rowKey: string) => void;
|
|
16
|
+
onSort?: (sortedColumn: SortedColumn) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const TableContext: React.Context<TableContextType>;
|
|
19
|
+
export declare const useTableContext: () => TableContextType;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './table-typings';
|
|
2
|
+
export * from './context/TableContextProvider';
|
|
3
|
+
export * from './parts/helperFunctions';
|
|
4
|
+
export * from './parts/TableCell';
|
|
5
|
+
export * from './parts/TableBody';
|
|
6
|
+
export * from './parts/TableHeader';
|
|
7
|
+
export * from './parts/TableHeaderCell';
|
|
8
|
+
export * from './parts/TableRow';
|
|
9
|
+
export * from './Table';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type TableBodyProps = JSX.IntrinsicElements['tbody'];
|
|
3
|
+
declare const TableBody: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
4
|
+
export { TableBody };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TableBody";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type TableCellProps = JSX.IntrinsicElements['td'];
|
|
3
|
+
export declare const TableCell: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, "ref"> & React.RefAttributes<HTMLTableCellElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TableCell";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type TableHeaderProps = JSX.IntrinsicElements['thead'];
|
|
3
|
+
declare const TableHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
4
|
+
export { TableHeader };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TableHeader";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SortDirection } from '../../table-typings';
|
|
3
|
+
export declare type TableHeaderCellProps<T = any> = JSX.IntrinsicElements['th'] & {
|
|
4
|
+
accessor?: keyof T;
|
|
5
|
+
disableSort?: boolean;
|
|
6
|
+
sortDirection?: SortDirection;
|
|
7
|
+
};
|
|
8
|
+
declare const TableHeaderCell: React.ForwardRefExoticComponent<Omit<TableHeaderCellProps<any>, "ref"> & React.RefAttributes<HTMLTableCellElement>>;
|
|
9
|
+
export { TableHeaderCell };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TableHeaderCell';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type TableRowProps = JSX.IntrinsicElements['tr'] & {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
indeterminate?: boolean;
|
|
5
|
+
isHeaderRow?: boolean;
|
|
6
|
+
hideSelect?: boolean;
|
|
7
|
+
uniqueKey?: string;
|
|
8
|
+
parentKey?: string;
|
|
9
|
+
isExpanded?: boolean;
|
|
10
|
+
isSubRow?: boolean;
|
|
11
|
+
collapseButtonProps?: JSX.IntrinsicElements['button'];
|
|
12
|
+
checkboxProps?: JSX.IntrinsicElements['input'];
|
|
13
|
+
};
|
|
14
|
+
declare const TableRow: React.ForwardRefExoticComponent<Omit<TableRowProps, "ref"> & React.RefAttributes<HTMLTableRowElement>>;
|
|
15
|
+
export { TableRow };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TableRow';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FilterColumn, GenericTableRow, SortDirection } from '../../table-typings';
|
|
3
|
+
/**
|
|
4
|
+
* sum the total of columns or cols in a row
|
|
5
|
+
* @param colsLength the length of the columns
|
|
6
|
+
* @param useSelection add a column for selection checkboxes
|
|
7
|
+
* @param useShowActionColumn add another column for action columns
|
|
8
|
+
* @param useGroupBy add another columns for groupby
|
|
9
|
+
*/
|
|
10
|
+
export declare function sumCols(colsLength: number, useSelection?: boolean, useShowActionColumn?: boolean, useGroupBy?: boolean): number;
|
|
11
|
+
/**
|
|
12
|
+
* sort array of tabke rows
|
|
13
|
+
* @param items table rows array
|
|
14
|
+
* @param columnName the target column name
|
|
15
|
+
* @param sortDirection the sort direction
|
|
16
|
+
* @return Array of tableRow
|
|
17
|
+
*/
|
|
18
|
+
export declare function sortArray<T>(items: T[] | undefined, columnName: keyof T, sortDirection: SortDirection): Array<T>;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param data table data
|
|
22
|
+
* @param filterColumns filter columns
|
|
23
|
+
*/
|
|
24
|
+
export declare function filterArrayByColumns<T>(data: Array<T>, filterColumns: Array<FilterColumn<T>>): Array<T>;
|
|
25
|
+
/**
|
|
26
|
+
* search text in array of table row
|
|
27
|
+
* @param data the array of table rows
|
|
28
|
+
* @param keyword The keyword to search in the array
|
|
29
|
+
* @param searchFields the target field to search
|
|
30
|
+
*/
|
|
31
|
+
export declare function searchTextByColumns<T>(data: Array<T>, keyword: string, searchFields: Array<keyof T>): Array<T>;
|
|
32
|
+
/**
|
|
33
|
+
* paginate data
|
|
34
|
+
* @param data table data
|
|
35
|
+
* @param offset page size
|
|
36
|
+
* @param currentPage current page index
|
|
37
|
+
*/
|
|
38
|
+
export declare function paginate<T = any>(data: Array<T>, offset: number, currentPage: number): T[];
|
|
39
|
+
export interface RowSelectOutput<T = any> {
|
|
40
|
+
data: Array<GenericTableRow<T>>;
|
|
41
|
+
isAllSelected: boolean;
|
|
42
|
+
isIndeterminate: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* on row select
|
|
46
|
+
* @param event input event
|
|
47
|
+
* @param data rows of data
|
|
48
|
+
* @param rowUniqueAccessor row unique accessor
|
|
49
|
+
* @param rowId row id value
|
|
50
|
+
*/
|
|
51
|
+
export declare function onRowSelect<T = any>(event: React.ChangeEvent<HTMLInputElement>, data: Array<GenericTableRow<T>>, rowUniqueAccessor: keyof GenericTableRow<T>, rowId: string): RowSelectOutput<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./helperFunctions";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum SortDirection {
|
|
2
|
+
ASC = "ASC",
|
|
3
|
+
DESC = "DESC"
|
|
4
|
+
}
|
|
5
|
+
export interface FilterColumn<T = any> {
|
|
6
|
+
accessor: keyof T;
|
|
7
|
+
value: any;
|
|
8
|
+
}
|
|
9
|
+
export declare type GenericTableRow<T = any> = T & {
|
|
10
|
+
id?: string;
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
expanded?: boolean;
|
|
13
|
+
indeterminate?: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { TableHeaderCellProps, GenericTableRow } from '../components';
|
|
3
|
+
interface SuperHeroData {
|
|
4
|
+
id: ReactNode;
|
|
5
|
+
firstName: ReactNode;
|
|
6
|
+
lastName: ReactNode;
|
|
7
|
+
superHero: ReactNode;
|
|
8
|
+
rowContentDetails?: GenericTableRow<SuperHeroData>[];
|
|
9
|
+
}
|
|
10
|
+
declare type SuperHeroRowData = GenericTableRow<SuperHeroData>;
|
|
11
|
+
declare type SuperHeroColumnDataT = Omit<TableHeaderCellProps<SuperHeroRowData>, 'ref'> & React.RefAttributes<HTMLTableCellElement>;
|
|
12
|
+
export declare const columnData: SuperHeroColumnDataT[];
|
|
13
|
+
export declare const rowData: SuperHeroRowData[];
|
|
14
|
+
export declare const SortableTable: () => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const SelectableTable: () => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const ExpandableTable: () => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
|
-
import { Datepicker, DatepickerData, DatepickerOptions, DatepickerState } from '@sebgroup/extract';
|
|
3
|
-
interface HookResult {
|
|
4
|
-
datepicker: Datepicker;
|
|
5
|
-
data: DatepickerData;
|
|
6
|
-
state: DatepickerState;
|
|
7
|
-
}
|
|
8
|
-
interface DatepickerHook {
|
|
9
|
-
(datepickerRef: RefObject<HTMLElement>, datepickerDialogRef: RefObject<HTMLElement>, dateInputRef: RefObject<HTMLInputElement>, datepickerTriggerRef: RefObject<HTMLButtonElement>, options?: DatepickerOptions): HookResult;
|
|
10
|
-
}
|
|
11
|
-
export declare const useDatepicker: DatepickerHook;
|
|
12
|
-
export {};
|