@kwantis-id3/frontend-library 1.0.0-rc.3 → 1.0.0-rc.5

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,37 +1,3 @@
1
- /** @jsxImportSource @emotion/react */
2
- import { Interpolation } from "@emotion/styled";
3
1
  import React from "react";
4
- import { Theme } from "@emotion/react";
5
- export type AccordionProps = {
6
- /** Text of the accordion trigger */
7
- title: string;
8
- /** Content of the accordion */
9
- children: React.ReactNode;
10
- /** Custom trigger component */
11
- customTrigger?: React.ReactNode;
12
- /** Works only if uncontrolled (isOpen props is not present) */
13
- defaultOpen?: boolean;
14
- /** Color of the accordion */
15
- color?: string;
16
- /** Color of the icon */
17
- iconColor?: string;
18
- /** Color of the divider */
19
- dividerColor?: string;
20
- /** Hide the icon */
21
- hideIcon?: boolean;
22
- /** Hide the divider */
23
- hideDivider?: boolean;
24
- /** Pass your state value here if the Accordion needs to be Controlled */
25
- isOpen?: boolean;
26
- /** Lazy render the content of the accordion */
27
- isLazy?: boolean;
28
- /** onClick handler */
29
- onClick?: () => void;
30
- /** onOpen handler */
31
- onOpen?: () => void;
32
- /** onClose handler */
33
- onClose?: () => void;
34
- /** Custom styles */
35
- sx?: Interpolation<Theme>;
36
- };
37
- export declare const Accordion: (props: AccordionProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ import { TAccordionProps } from "./AccordionInterfaces";
3
+ export declare const Accordion: React.FC<TAccordionProps>;
@@ -0,0 +1,21 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ export type TAccordionProps = PropsWithChildren & {
3
+ /** Title to be used if no custom trigger is passed */
4
+ title: string;
5
+ /** Pass your state value here if the Accordion needs to be Controlled */
6
+ isOpen?: boolean;
7
+ /** Default open state if the accordion is Uncontrolled */
8
+ defaultOpen?: boolean;
9
+ /** Callback function to be called when the Accordion is clicked */
10
+ onClick?: () => void;
11
+ /** Callback function to be called when the Accordion opens */
12
+ onOpen?: () => void;
13
+ /** Callback function to be called when the Accordion closes */
14
+ onClose?: () => void;
15
+ /** Custom trigger element */
16
+ trigger?: (isOpen: boolean) => React.ReactNode;
17
+ /** Variant of the Accordion. Default has everything wrapped in borders, while light just renders the content and the title without setting colors
18
+ * @default "default"
19
+ */
20
+ variant?: "default" | "light";
21
+ };
@@ -1,23 +1,32 @@
1
- export declare const Divider: import("@emotion/styled").StyledComponent<{
1
+ export declare const AccordionGroup: import("@emotion/styled").StyledComponent<{
2
2
  theme?: import("@emotion/react").Theme;
3
3
  as?: React.ElementType;
4
- } & {
5
- $color: string;
6
4
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
7
- export declare const TitleDiv: import("@emotion/styled").StyledComponent<{
5
+ export declare const StyledAccordion: import("@emotion/styled").StyledComponent<{
8
6
  theme?: import("@emotion/react").Theme;
9
7
  as?: React.ElementType;
10
8
  } & {
11
- $color: string;
12
- $textColor: string;
9
+ $variant: "default" | "light";
10
+ $isOpen: boolean;
13
11
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
14
- export declare const IconContainer: import("@emotion/styled").StyledComponent<{
12
+ export declare const StyledAccordionHeader: import("@emotion/styled").StyledComponent<{
15
13
  theme?: import("@emotion/react").Theme;
16
14
  as?: React.ElementType;
17
15
  } & {
18
- $iconColor: string;
16
+ $variant: "default" | "light";
17
+ $isOpen: boolean;
18
+ }, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
19
+ export declare const StyledAccordionContent: import("@emotion/styled").StyledComponent<{
20
+ theme?: import("@emotion/react").Theme;
21
+ as?: React.ElementType;
22
+ } & {
23
+ $isOpen: boolean;
24
+ $variant: "default" | "light";
25
+ $defaultHeight: string;
19
26
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
20
- export declare const TitleH2: import("@emotion/styled").StyledComponent<{
27
+ export declare const Icon: import("@emotion/styled").StyledComponent<{
21
28
  theme?: import("@emotion/react").Theme;
22
29
  as?: React.ElementType;
23
- }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, {}>;
30
+ } & {
31
+ $isOpen: boolean;
32
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
@@ -1 +1,2 @@
1
- export { Accordion, AccordionProps } from "./Accordion";
1
+ export { Accordion } from "./Accordion";
2
+ export * from "./AccordionInterfaces";
@@ -12,6 +12,8 @@ export type ButtonProps = {
12
12
  sx?: Interpolation<Theme>;
13
13
  /** Variant of the button, either `contained`, `outlined` or `text` */
14
14
  variant?: ButtonVariants;
15
+ /** The button size; either "large" or "small" */
16
+ size?: "small" | "large";
15
17
  /** onClick handler */
16
18
  onClick?: () => void;
17
19
  className?: string;
@@ -0,0 +1,3 @@
1
+ import { TMultiViewListProps } from "./MultiViewListInterfaces";
2
+ import { TCellValues, TTableRow } from "../Table";
3
+ export declare const MultiViewList: <Cell extends TCellValues, Row extends TTableRow<Cell>>(props: TMultiViewListProps<Cell, Row>) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { TCellValues, TTableProps, TTableRow } from "../Table";
3
+ export type TMultiViewListProps<Cell extends TCellValues, Row extends TTableRow<Cell>> = TTableProps<Cell, Row> & {
4
+ mode: "table" | "cards";
5
+ cardComponent: (item: Row) => React.ReactNode;
6
+ };
@@ -0,0 +1,4 @@
1
+ export declare const StyledCardsContainer: import("@emotion/styled").StyledComponent<{
2
+ theme?: import("@emotion/react").Theme;
3
+ as?: React.ElementType;
4
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,2 @@
1
+ export * from "./MultiViewListInterfaces";
2
+ export { MultiViewList } from "./MultiViewList";
@@ -0,0 +1,7 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { Column, Table } from "@tanstack/react-table";
3
+ import { TCellValues, TTableRow } from "./TableInterfaces";
4
+ export declare function DebouncedFilter<T extends TTableRow<TCellValues>>({ column, table, }: {
5
+ column: Column<T, unknown>;
6
+ table: Table<T>;
7
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ export declare function DebouncedInput({ value: initialValue, onChange, debounce, ...props }: {
3
+ value: string | number;
4
+ onChange: (value: string | number) => void;
5
+ debounce?: number;
6
+ } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange">): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { TCellValues, TTableProps, TTableRow } from "./TableInterfaces";
2
+ export declare const Table: <Cell extends TCellValues, Row extends TTableRow<Cell>>(props: TTableProps<Cell, Row>) => import("@emotion/react/jsx-runtime").JSX.Element;
3
+ export declare const renderCell: (value: string | number | boolean | null) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { ColumnDef } from "@tanstack/react-table";
2
+ export type TCellValues = string | number | boolean | null;
3
+ export type TTableProps<Cell extends TCellValues, Row extends TTableRow<Cell>> = {
4
+ columns: ColumnDef<Row, Cell>[];
5
+ data: Row[] | undefined;
6
+ };
7
+ export type TTableCell<T extends TCellValues> = {
8
+ value: T;
9
+ bgColor?: string | null;
10
+ textColor?: string | null;
11
+ };
12
+ export type TTableRow<T extends TCellValues> = {
13
+ info?: {
14
+ bgColor?: string | null;
15
+ textColor?: string | null;
16
+ [key: string]: string | number | boolean | null | undefined;
17
+ };
18
+ cells: {
19
+ [key: string]: TTableCell<T>;
20
+ };
21
+ };
@@ -0,0 +1,14 @@
1
+ export declare const TableWrapper: import("@emotion/styled").StyledComponent<{
2
+ theme?: import("@emotion/react").Theme;
3
+ as?: React.ElementType;
4
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
5
+ export declare const StyledTable: import("@emotion/styled").StyledComponent<{
6
+ theme?: import("@emotion/react").Theme;
7
+ as?: React.ElementType;
8
+ } & {
9
+ $mobileBreakpoint: number;
10
+ }, import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, {}>;
11
+ export declare const StyledCell: import("@emotion/styled").StyledComponent<{
12
+ theme?: import("@emotion/react").Theme;
13
+ as?: React.ElementType;
14
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,2 @@
1
+ export * from "./TableInterfaces";
2
+ export { Table, renderCell } from "./Table";
@@ -1,6 +1,6 @@
1
1
  export { Button, ButtonProps } from "./Button";
2
2
  export * from "./ThemeContext";
3
- export { Accordion, AccordionProps } from "./Accordion";
3
+ export { Accordion, TAccordionProps } from "./Accordion";
4
4
  export { InputField } from "./InputField";
5
5
  export { SingleSelect, SingleSelectProps, MultiSelect, MultiSelectProps, } from "./SelectFilter";
6
6
  export { Slider, SliderProps } from "./Slider";
@@ -9,3 +9,5 @@ export { Modal } from "./Modal";
9
9
  export { TIndicatorProps, TIndicatorVariants, Indicator } from "./Indicator";
10
10
  export { Tag, TTagProps } from "./Tag";
11
11
  export { Card, CardHeader, CardContent, CardFooter, CardIndicators, CardMediaSection, TCardSectionProps, } from "./Card";
12
+ export { Table, renderCell, TTableProps, TTableCell, TCellValues, TTableRow, } from "./Table";
13
+ export { MultiViewList, TMultiViewListProps } from "./MultiViewList";
@@ -1,5 +1,54 @@
1
+ import { TCellValues, TTableRow } from "../components/index";
1
2
  import React from "react";
2
3
  import { IThemeContextProps } from "../components/ThemeContext/ThemeInterfaces";
3
4
  import { RenderHookResult, RenderResult } from "@testing-library/react";
5
+ import { ColumnDef } from "@tanstack/react-table";
4
6
  export declare const renderWithTheme: (ui: React.ReactElement, themeProps?: IThemeContextProps) => RenderResult;
5
7
  export declare function renderHookWithTheme<T, R>(hook: (props: T) => R, themeProps?: IThemeContextProps): RenderHookResult<R, T>;
8
+ export declare const headingStyle: {
9
+ padding: string;
10
+ margin: string;
11
+ fontWeight: string;
12
+ };
13
+ export declare const templateColumns: ColumnDef<TTableRow<TCellValues>, TCellValues>[];
14
+ export declare const templateTableData: {
15
+ cells: {
16
+ well_name: {
17
+ value: string;
18
+ };
19
+ is_live: {
20
+ value: boolean;
21
+ };
22
+ well_profile: {
23
+ value: string;
24
+ };
25
+ country: {
26
+ value: string;
27
+ };
28
+ spud: {
29
+ value: string;
30
+ };
31
+ rig: {
32
+ value: string;
33
+ };
34
+ rig_type: {
35
+ value: string;
36
+ };
37
+ bu: {
38
+ value: string;
39
+ };
40
+ contractor: {
41
+ value: string;
42
+ };
43
+ data_quality: {
44
+ value: number;
45
+ };
46
+ last_sensors_data: {
47
+ value: string;
48
+ };
49
+ last_ddr: {
50
+ value: string;
51
+ };
52
+ };
53
+ }[];
54
+ export declare const TemplateCard: (item: TTableRow<TCellValues>) => import("@emotion/react/jsx-runtime").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
- import React__default, { FC, PropsWithChildren } from 'react';
3
+ import React__default, { PropsWithChildren, FC } from 'react';
4
4
  import { Interpolation, CreateStyled } from '@emotion/styled';
5
5
  import { Theme, Interpolation as Interpolation$1 } from '@emotion/react';
6
+ import { ColumnDef } from '@tanstack/react-table';
6
7
 
7
8
  type ButtonVariants = "contained" | "outlined" | "text";
8
9
  type ButtonProps = {
@@ -14,6 +15,8 @@ type ButtonProps = {
14
15
  sx?: Interpolation<Theme>;
15
16
  /** Variant of the button, either `contained`, `outlined` or `text` */
16
17
  variant?: ButtonVariants;
18
+ /** The button size; either "large" or "small" */
19
+ size?: "small" | "large";
17
20
  /** onClick handler */
18
21
  onClick?: () => void;
19
22
  className?: string;
@@ -140,39 +143,28 @@ declare const defaultDarkPalette: IPalette;
140
143
  declare const ThemeContextProvider: ({ palettes, defaultMode, children, }: React__default.PropsWithChildren<IThemeContextProps>) => JSX.Element;
141
144
  declare const useThemeContext: () => IThemeContextValue;
142
145
 
143
- type AccordionProps = {
144
- /** Text of the accordion trigger */
146
+ type TAccordionProps = PropsWithChildren & {
147
+ /** Title to be used if no custom trigger is passed */
145
148
  title: string;
146
- /** Content of the accordion */
147
- children: React__default.ReactNode;
148
- /** Custom trigger component */
149
- customTrigger?: React__default.ReactNode;
150
- /** Works only if uncontrolled (isOpen props is not present) */
151
- defaultOpen?: boolean;
152
- /** Color of the accordion */
153
- color?: string;
154
- /** Color of the icon */
155
- iconColor?: string;
156
- /** Color of the divider */
157
- dividerColor?: string;
158
- /** Hide the icon */
159
- hideIcon?: boolean;
160
- /** Hide the divider */
161
- hideDivider?: boolean;
162
149
  /** Pass your state value here if the Accordion needs to be Controlled */
163
150
  isOpen?: boolean;
164
- /** Lazy render the content of the accordion */
165
- isLazy?: boolean;
166
- /** onClick handler */
151
+ /** Default open state if the accordion is Uncontrolled */
152
+ defaultOpen?: boolean;
153
+ /** Callback function to be called when the Accordion is clicked */
167
154
  onClick?: () => void;
168
- /** onOpen handler */
155
+ /** Callback function to be called when the Accordion opens */
169
156
  onOpen?: () => void;
170
- /** onClose handler */
157
+ /** Callback function to be called when the Accordion closes */
171
158
  onClose?: () => void;
172
- /** Custom styles */
173
- sx?: Interpolation<Theme>;
159
+ /** Custom trigger element */
160
+ trigger?: (isOpen: boolean) => React__default.ReactNode;
161
+ /** Variant of the Accordion. Default has everything wrapped in borders, while light just renders the content and the title without setting colors
162
+ * @default "default"
163
+ */
164
+ variant?: "default" | "light";
174
165
  };
175
- declare const Accordion: (props: AccordionProps) => _emotion_react_jsx_runtime.JSX.Element;
166
+
167
+ declare const Accordion: React__default.FC<TAccordionProps>;
176
168
 
177
169
  interface TextFieldProps extends React__default.InputHTMLAttributes<HTMLInputElement> {
178
170
  /** Classname given to the container div */
@@ -424,6 +416,37 @@ declare const CardFooter: FC<TCardSectionProps>;
424
416
  declare const CardIndicators: FC<TCardSectionProps>;
425
417
  declare const CardMediaSection: FC<TCardSectionProps>;
426
418
 
419
+ type TCellValues = string | number | boolean | null;
420
+ type TTableProps<Cell extends TCellValues, Row extends TTableRow<Cell>> = {
421
+ columns: ColumnDef<Row, Cell>[];
422
+ data: Row[] | undefined;
423
+ };
424
+ type TTableCell<T extends TCellValues> = {
425
+ value: T;
426
+ bgColor?: string | null;
427
+ textColor?: string | null;
428
+ };
429
+ type TTableRow<T extends TCellValues> = {
430
+ info?: {
431
+ bgColor?: string | null;
432
+ textColor?: string | null;
433
+ [key: string]: string | number | boolean | null | undefined;
434
+ };
435
+ cells: {
436
+ [key: string]: TTableCell<T>;
437
+ };
438
+ };
439
+
440
+ declare const Table: <Cell extends TCellValues, Row extends TTableRow<Cell>>(props: TTableProps<Cell, Row>) => _emotion_react_jsx_runtime.JSX.Element;
441
+ declare const renderCell: (value: string | number | boolean | null) => _emotion_react_jsx_runtime.JSX.Element;
442
+
443
+ type TMultiViewListProps<Cell extends TCellValues, Row extends TTableRow<Cell>> = TTableProps<Cell, Row> & {
444
+ mode: "table" | "cards";
445
+ cardComponent: (item: Row) => React__default.ReactNode;
446
+ };
447
+
448
+ declare const MultiViewList: <Cell extends TCellValues, Row extends TTableRow<Cell>>(props: TMultiViewListProps<Cell, Row>) => _emotion_react_jsx_runtime.JSX.Element;
449
+
427
450
  /**
428
451
  * Hook to check if the screen is mobile. The default breakpoint is 768px.
429
452
  * @param {number=} mobileBreakpoint breakpoint width to check against
@@ -463,4 +486,4 @@ declare const darkenColor: (color: string, strength?: number) => string;
463
486
  */
464
487
  declare const lightenColor: (color: string, strength?: number) => string;
465
488
 
466
- export { Accordion, AccordionProps, Button, ButtonProps, Card, CardContent, CardFooter, CardHeader, CardIndicators, CardMediaSection, Dropdown, DropdownItem, DropdownProps, IBackgroundColors, ICommonColors, IIndicatorColors, IPalette, IStandardPaletteColor, ITagColors, IThemeContextProps, IThemeContextValue, Indicator, InputField, Modal, MultiSelect, MultiSelectProps, SingleSelect, SingleSelectProps, Slider, SliderProps, TCardSectionProps, TColorScale, TIndicatorProps, TIndicatorVariants, TTagProps, TThemeMode, Tag, ThemeContextProvider, darkenColor, defaultDarkPalette, defaultLightPalette, getContrastColor, lightenColor, styled, transientOptions, useIsMobile, useThemeContext };
489
+ export { Accordion, Button, ButtonProps, Card, CardContent, CardFooter, CardHeader, CardIndicators, CardMediaSection, Dropdown, DropdownItem, DropdownProps, IBackgroundColors, ICommonColors, IIndicatorColors, IPalette, IStandardPaletteColor, ITagColors, IThemeContextProps, IThemeContextValue, Indicator, InputField, Modal, MultiSelect, MultiSelectProps, MultiViewList, SingleSelect, SingleSelectProps, Slider, SliderProps, TAccordionProps, TCardSectionProps, TCellValues, TColorScale, TIndicatorProps, TIndicatorVariants, TMultiViewListProps, TTableCell, TTableProps, TTableRow, TTagProps, TThemeMode, Table, Tag, ThemeContextProvider, darkenColor, defaultDarkPalette, defaultLightPalette, getContrastColor, lightenColor, renderCell, styled, transientOptions, useIsMobile, useThemeContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwantis-id3/frontend-library",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.5",
4
4
  "description": "Kwantis frontend components collection",
5
5
  "scriptsComments": {
6
6
  "storybook": "Starts storybook in development mode",
@@ -55,7 +55,7 @@
55
55
  "@storybook/testing-library": "0.2.2",
56
56
  "@testing-library/jest-dom": "^5.16.5",
57
57
  "@testing-library/react": "^16.2.0",
58
- "@testing-library/user-event": "^14.5.1",
58
+ "@testing-library/user-event": "^14.6.1",
59
59
  "@types/react": "^18.0.33",
60
60
  "@types/testing-library__jest-dom": "^5.14.5",
61
61
  "@types/tinycolor2": "^1.4.3",
@@ -82,12 +82,14 @@
82
82
  "vitest": "^3.0.5"
83
83
  },
84
84
  "peerDependencies": {
85
+ "@tanstack/react-table": "^8.0.0",
85
86
  "react": ">= 17.0.2"
86
87
  },
87
88
  "main": "dist/cjs/index.js",
88
89
  "module": "dist/esm/index.js",
89
90
  "files": [
90
- "dist"
91
+ "dist",
92
+ "src/types"
91
93
  ],
92
94
  "types": "dist/index.d.ts",
93
95
  "dependencies": {
@@ -0,0 +1,8 @@
1
+ import "@emotion/styled";
2
+ import { IThemeContextValue } from "../components/ThemeContext/ThemeInterfaces";
3
+
4
+ // override the default theme
5
+ declare module "@emotion/react" {
6
+ // eslint-disable-next-line
7
+ export interface Theme extends IThemeContextValue {}
8
+ }
@@ -0,0 +1,7 @@
1
+ import "@tanstack/react-table";
2
+
3
+ declare module "@tanstack/react-table" {
4
+ interface ColumnMeta<TData extends RowData, TValue> {
5
+ isHidden?: boolean;
6
+ }
7
+ }