@lifesg/react-design-system 2.2.0-canary.1 → 2.2.0-canary.2

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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@lifesg/react-design-system/data-table",
3
+ "private": true,
4
+ "main": "../cjs/index.js",
5
+ "module": "./index.js",
6
+ "types": "./index.d.ts"
7
+ }
@@ -0,0 +1,62 @@
1
+ import { CSSProperties, ReactNode } from "react";
2
+ import { ErrorDisplayAttributes } from "../error-display/types";
3
+ export interface DataTableProps {
4
+ id?: string | undefined;
5
+ "data-testid"?: string | undefined;
6
+ /** Configuration for each header */
7
+ headers: HeaderProps[];
8
+ rows?: RowProps[] | undefined;
9
+ className?: string | undefined;
10
+ selectedIds?: string[] | undefined;
11
+ disabledIds?: string[] | undefined;
12
+ /** Enables a checkbox for each row */
13
+ enableMultiSelect?: boolean | undefined;
14
+ /** Enables a select all checkbox */
15
+ enableSelectAll?: boolean | undefined;
16
+ /** Specifies if an action bar is visible when one or more rows are selected */
17
+ enableActionBar?: boolean | undefined;
18
+ /** Specifies if the header is fixed to the top */
19
+ enableStickyHeader?: boolean | undefined;
20
+ /** Custom content to be rendered within the action bar */
21
+ actionBarContent?: ReactNode | undefined;
22
+ loadState?: LoadStateType | undefined;
23
+ onSelect?: ((rowId: string, isSelected: boolean) => void) | undefined;
24
+ onSelectAll?: ((isAllSelected: boolean) => void) | undefined;
25
+ onHeaderClick?: ((fieldKey: string) => void) | undefined;
26
+ onClearSelectionClick?: (() => void) | undefined;
27
+ /** Specifies the sort indicator display state for each column **/
28
+ sortIndicators?: SortIndicatorsProps | undefined;
29
+ /** Specifies if every alternate row has a different background colour */
30
+ alternatingRows?: boolean | undefined;
31
+ /** Override props for the empty view display */
32
+ emptyView?: ErrorDisplayAttributes | undefined;
33
+ /** Returns a custom view to be rendered when the table is empty */
34
+ renderCustomEmptyView?: (() => ReactNode) | undefined;
35
+ }
36
+ export type LoadStateType = "loading" | "success";
37
+ export type SortIndicatorType = "asc" | "desc";
38
+ export interface SortIndicatorsProps {
39
+ [fieldKey: string]: SortIndicatorType;
40
+ }
41
+ /**
42
+ * When a string is specified, it will be used as the header label and
43
+ * the key of the value in the row item object.
44
+ *
45
+ * For additional customisation, pass a `HeaderItemProps` object
46
+ */
47
+ export type HeaderProps = string | HeaderItemProps;
48
+ interface HeaderItemProps {
49
+ fieldKey: string;
50
+ label: string | ReactNode;
51
+ clickable?: boolean | undefined;
52
+ style?: CSSProperties | undefined;
53
+ }
54
+ export interface RowProps {
55
+ id: string | number;
56
+ /** data with key matching fieldKey in `HeaderProps` */
57
+ [fieldKey: string]: string | number | ReactNode | ((row: RowProps, renderProps: RowRenderProps) => ReactNode) | undefined;
58
+ }
59
+ interface RowRenderProps {
60
+ isSelected: boolean;
61
+ }
62
+ export {};
@@ -319,5 +319,5 @@ import{jsxs as e,Fragment as t,jsx as r}from"react/jsx-runtime";import i,{keyfra
319
319
  width: 100%;
320
320
  margin: 2rem auto 0;
321
321
  }
322
- `,Br=t=>{var{type:i,img:n,title:a,description:o,actionButton:s,additionalProps:g,imageOnly:c}=t,d=l(t,["type","img","title","description","actionButton","additionalProps","imageOnly"]);const p=E.get(i),h=d["data-testid"]||"error-display",u=()=>{if("maintenance"===i){const e=g;return g&&e.dateString?p.renderDescription(e):o||void 0}return o||void 0};if(!p)return null;const f=Object.assign(Object.assign(Object.assign(Object.assign({},p),n&&{img:n}),a&&{title:a}),u()&&{description:u()});return e(mr,Object.assign({},d,{"data-testid":h},{children:[r(yr,Object.assign({},f.img,{alt:"","data-id":"error-display-image"})),!c&&(f.title||f.description?e(Fr,{children:[f.title&&r(vr,Object.assign({"data-testid":`${h}--title`,"data-id":"error-display-title"},{children:f.title})),f.description&&r(br,Object.assign({"data-testid":`${h}--description`,"data-id":"error-display-description"},{children:"string"==typeof f.description?r("p",{children:f.description}):f.description}))]}):null),s&&(()=>{const e=Object.assign({children:"Proceed"},s);return r(Sr,Object.assign({},e))})()]}))};export{Br as ErrorDisplay};
322
+ `,Br=t=>{var{type:i,img:n,title:a,description:o,actionButton:s,additionalProps:g,imageOnly:c}=t,d=l(t,["type","img","title","description","actionButton","additionalProps","imageOnly"]);const p=E.get(i),h=d["data-testid"]||"error-display",u=()=>{if("maintenance"===i){const e=g;return g&&e.dateString?p.renderDescription(e):o||void 0}return o||void 0};if(!p)return null;const f=Object.assign(Object.assign(Object.assign(Object.assign({},p),n&&{img:n}),a&&{title:a}),u()&&{description:u()});return e(mr,Object.assign({},d,{"data-testid":h},{children:[r(yr,Object.assign({},f.img,{alt:"","data-id":"error-display-image"})),!c&&(f.title||f.description?e(Fr,{children:[f.title&&("string"==typeof f.title?r(vr,Object.assign({"data-testid":`${h}--title`,"data-id":"error-display-title"},{children:f.title})):f.title),f.description&&r(br,Object.assign({"data-testid":`${h}--description`,"data-id":"error-display-description"},{children:"string"==typeof f.description?r("p",{children:f.description}):f.description}))]}):null),s&&(()=>{const e=Object.assign({children:"Proceed"},s);return r(Sr,Object.assign({},e))})()]}))};export{Br as ErrorDisplay};
323
323
  //# sourceMappingURL=index.js.map