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

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,23 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { ReactNode } from "react";
3
+ export type DrawerProps = {
4
+ /** Position of the drawer */
5
+ anchor: "top" | "right" | "bottom" | "left";
6
+ /** Trigger showed when drawer is closed */
7
+ closedTrigger?: ReactNode;
8
+ /** Trigger showed when drawer is open */
9
+ openTrigger?: ReactNode;
10
+ /** Component to be rendered when Drawer is open */
11
+ openContent?: ReactNode;
12
+ /** Component to be rendered when Drawer is closed */
13
+ closedContent?: ReactNode;
14
+ /** Min open of the drawer as number of pixels. If not defined the minOpen will be the height of closedContent if present, otherwise 0px */
15
+ minOpen?: number;
16
+ /** Max open of the drawer as number of pixels. If not defined the maxOpen will be the height of openContent with limit at 90vh/vw */
17
+ maxOpen?: number;
18
+ /** Background color */
19
+ bgColor?: string;
20
+ /** Trigger hover color */
21
+ triggerHoverColor?: string;
22
+ };
23
+ export declare const Drawer: ({ anchor, openContent, closedContent, openTrigger, closedTrigger, minOpen, maxOpen, bgColor, triggerHoverColor, }: DrawerProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ export declare const DrawerBody: import("@emotion/styled").StyledComponent<{
2
+ theme?: import("@emotion/react").Theme;
3
+ as?: React.ElementType;
4
+ } & {
5
+ $anchor: "top" | "right" | "bottom" | "left";
6
+ $isOpen: boolean;
7
+ $minOpen?: string;
8
+ $maxOpen?: string;
9
+ $bgColor?: string;
10
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
11
+ export declare const DrawerContent: import("@emotion/styled").StyledComponent<{
12
+ theme?: import("@emotion/react").Theme;
13
+ as?: React.ElementType;
14
+ } & {
15
+ $anchor: "top" | "right" | "bottom" | "left";
16
+ $isOpen: boolean;
17
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
18
+ export declare const Trigger: import("@emotion/styled").StyledComponent<{
19
+ theme?: import("@emotion/react").Theme;
20
+ as?: React.ElementType;
21
+ } & {
22
+ $anchor: "top" | "right" | "bottom" | "left";
23
+ $bgColor?: string;
24
+ $triggerHoverColor?: string;
25
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1 @@
1
+ export { Drawer, DrawerProps } from "./Drawer";
@@ -2,8 +2,6 @@ import React from "react";
2
2
  interface TextFieldProps extends React.InputHTMLAttributes<HTMLInputElement> {
3
3
  /** Classname given to the container div */
4
4
  containerClassName?: string;
5
- /** Disables the input */
6
- isDisabled?: boolean;
7
5
  /** The color of the input */
8
6
  color?: string;
9
7
  /** Change the styles of the input field */
@@ -0,0 +1,4 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { FC } from "react";
3
+ import { TControlledTreeViewProps } from "./TreeViewInterfaces";
4
+ export declare const ControlledTreeView: FC<TControlledTreeViewProps>;
@@ -0,0 +1,3 @@
1
+ import { TTreeViewItem } from "./TreeViewInterfaces";
2
+ export declare const getRootItems: (items: TTreeViewItem[]) => TTreeViewItem[];
3
+ export declare const getChildrenItems: (items: TTreeViewItem[], parentId: string) => TTreeViewItem[];
@@ -0,0 +1,78 @@
1
+ import { Interpolation, Theme } from "@emotion/react";
2
+ import React from "react";
3
+ /**
4
+ * A callback to customize how items are rendered
5
+ * @property isOpen: A boolean indicating if the item is expanded
6
+ * @property hasChildren: A boolean indicating if the item has children
7
+ * @property item: the entire item object
8
+ */
9
+ export type TCustomRenderProps = {
10
+ isOpen: boolean;
11
+ item: TTreeViewItem;
12
+ };
13
+ /**
14
+ * A callback to customize how the content of the items is rendered
15
+ * @extends TCustomRenderProps
16
+ * @property icon: The icon of the item. If the renderIcon callback is provided, this will be the result of that callback
17
+ * @property title: The title of the item. If the renderTitle callback is provided, this will be the result of that callback
18
+ */
19
+ export type TRenderTriggerProps = TCustomRenderProps & {
20
+ icon: React.ReactNode;
21
+ title: React.ReactNode;
22
+ };
23
+ type TTreeItemFunctions = {
24
+ /** A callback to customize how the titles are rendered */
25
+ renderTitle?: (props: TCustomRenderProps) => React.ReactNode;
26
+ /** A callback to customize how the icons are rendered */
27
+ renderIcon?: (props: TCustomRenderProps) => React.ReactNode;
28
+ /** A callback to customize how the content of the items is rendered */
29
+ renderTrigger?: (props: TRenderTriggerProps) => React.ReactNode;
30
+ /** A callback executed when an item is focused. An item gets focused when you click on it. Focusing and item will also select it. */
31
+ onFocusItem?: (item: TTreeViewItem) => void;
32
+ /** A callback executed when an item is selected. To select an item, ctrl+click on it. */
33
+ onSelectItems?: (item: string[]) => void;
34
+ /** A callback executed when an item is expanded */
35
+ onExpandItem?: (item: TTreeViewItem) => void;
36
+ /** A callback executed when an item is collapsed */
37
+ onCollapseItem?: (item: TTreeViewItem) => void;
38
+ /** A callback to handle the expansion of items without children */
39
+ onMissingChildren?: (item: TTreeViewItem) => void;
40
+ };
41
+ type TTreeViewProps = TTreeItemFunctions & {
42
+ /** An array representing the items that the tree needs to render */
43
+ items: TTreeViewItem[];
44
+ /** Disable multi-selection possibility */
45
+ isMultiSelectionDisabled?: boolean;
46
+ /** Custom styles */
47
+ sx?: Interpolation<Theme>;
48
+ };
49
+ export type TUncontrolledTreeViewProps = TTreeViewProps & {
50
+ items: TTreeViewItem[];
51
+ };
52
+ export type TControlledTreeViewProps = TTreeViewProps & {
53
+ /** The current state of the Tree View. */
54
+ viewState: TViewState;
55
+ };
56
+ export type TViewState = {
57
+ /** The list of ids of items that are selected */
58
+ selectedItems?: string[];
59
+ /** The list of ids of items that are expanded */
60
+ expandedItems?: string[];
61
+ /** The focused item */
62
+ focusedItem?: string;
63
+ };
64
+ export type TTreeViewItem = TTreeItemFunctions & {
65
+ /** Item identifier */
66
+ id: string;
67
+ /** Item name */
68
+ name: string;
69
+ /** The possible children of this item */
70
+ children?: string[];
71
+ /** If the item should be rendered as a folder even with no children */
72
+ isFolder?: boolean;
73
+ /** A callback to fetch children asynchronously */
74
+ childrenAsync?: () => Promise<TTreeViewItem[]>;
75
+ /** Custom styles */
76
+ sx?: Interpolation<Theme>;
77
+ };
78
+ export {};
@@ -0,0 +1,24 @@
1
+ export declare const TreeView: 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 TreeItemsWrapper: import("@emotion/styled").StyledComponent<{
6
+ theme?: import("@emotion/react").Theme;
7
+ as?: React.ElementType;
8
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
9
+ export declare const TreeItemTrigger: import("@emotion/styled").StyledComponent<{
10
+ theme?: import("@emotion/react").Theme;
11
+ as?: React.ElementType;
12
+ } & {
13
+ $isFocused: boolean;
14
+ $isExpanded: boolean;
15
+ $isSelected: boolean;
16
+ }, import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, {}>;
17
+ export declare const TreeItemChildren: import("@emotion/styled").StyledComponent<{
18
+ theme?: import("@emotion/react").Theme;
19
+ as?: React.ElementType;
20
+ } & import("react").ClassAttributes<HTMLUListElement> & import("react").HTMLAttributes<HTMLUListElement> & {
21
+ theme?: import("@emotion/react").Theme;
22
+ } & {
23
+ $isExpanded: boolean;
24
+ }, {}, {}>;
@@ -0,0 +1,3 @@
1
+ import { FC } from "react";
2
+ import { TUncontrolledTreeViewProps } from "./TreeViewInterfaces";
3
+ export declare const UncontrolledTreeView: FC<TUncontrolledTreeViewProps>;
@@ -0,0 +1,3 @@
1
+ export * from "./TreeViewInterfaces";
2
+ export * from "./ControlledTreeView";
3
+ export * from "./UncontrolledTreeView";
@@ -11,3 +11,5 @@ export { Tag, TTagProps } from "./Tag";
11
11
  export { Card, CardHeader, CardContent, CardFooter, CardIndicators, CardMediaSection, TCardSectionProps, } from "./Card";
12
12
  export { Table, renderCell, TTableProps, TTableCell, TCellValues, TTableRow, } from "./Table";
13
13
  export { MultiViewList, TMultiViewListProps } from "./MultiViewList";
14
+ export { ControlledTreeView, UncontrolledTreeView, TControlledTreeViewProps, TUncontrolledTreeViewProps, TViewState, TTreeViewItem, TCustomRenderProps, } from "./TreeView";
15
+ export { Drawer, DrawerProps } from "./Drawer";
@@ -6,15 +6,25 @@
6
6
  export declare const getContrastColor: (color: string) => string;
7
7
  /**
8
8
  *
9
- * @param color the color to darken
9
+ * @param color a color
10
10
  * @param strength the strength (0-100) to darken the color
11
11
  * @returns the color darkened by the strength
12
12
  */
13
13
  export declare const darkenColor: (color: string, strength?: number) => string;
14
14
  /**
15
15
  *
16
- * @param color the color to lighten
16
+ * @param color a color
17
17
  * @param strength the strength (0-100) to lighten the color
18
18
  * @returns the color lightened by the strength
19
19
  */
20
20
  export declare const lightenColor: (color: string, strength?: number) => string;
21
+ /**
22
+ * @param color a color
23
+ * @returns the hover color, based on if the color is dark or light
24
+ */
25
+ export declare const getHoverColor: (color: string) => string;
26
+ /**
27
+ * @param color a color
28
+ * @returns the active color, based on if the color is dark or light
29
+ */
30
+ export declare const getActiveColor: (color: string) => string;
@@ -2,6 +2,4 @@ import useIsMobile from "./isMobile";
2
2
  export { transientOptions } from "./transientOptions";
3
3
  export { styled } from "./styled";
4
4
  export { useIsMobile };
5
- export { getContrastColor } from "./colors";
6
- export { darkenColor } from "./colors";
7
- export { lightenColor } from "./colors";
5
+ export { getContrastColor, darkenColor, lightenColor, getHoverColor, getActiveColor } from "./colors";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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, { PropsWithChildren, FC } from 'react';
3
+ import React__default, { PropsWithChildren, FC, ReactNode } from 'react';
4
4
  import { Interpolation, CreateStyled } from '@emotion/styled';
5
5
  import { Theme, Interpolation as Interpolation$1 } from '@emotion/react';
6
6
  import { ColumnDef } from '@tanstack/react-table';
@@ -169,8 +169,6 @@ declare const Accordion: React__default.FC<TAccordionProps>;
169
169
  interface TextFieldProps extends React__default.InputHTMLAttributes<HTMLInputElement> {
170
170
  /** Classname given to the container div */
171
171
  containerClassName?: string;
172
- /** Disables the input */
173
- isDisabled?: boolean;
174
172
  /** The color of the input */
175
173
  color?: string;
176
174
  /** Change the styles of the input field */
@@ -447,6 +445,110 @@ type TMultiViewListProps<Cell extends TCellValues, Row extends TTableRow<Cell>>
447
445
 
448
446
  declare const MultiViewList: <Cell extends TCellValues, Row extends TTableRow<Cell>>(props: TMultiViewListProps<Cell, Row>) => _emotion_react_jsx_runtime.JSX.Element;
449
447
 
448
+ /**
449
+ * A callback to customize how items are rendered
450
+ * @property isOpen: A boolean indicating if the item is expanded
451
+ * @property hasChildren: A boolean indicating if the item has children
452
+ * @property item: the entire item object
453
+ */
454
+ type TCustomRenderProps = {
455
+ isOpen: boolean;
456
+ item: TTreeViewItem;
457
+ };
458
+ /**
459
+ * A callback to customize how the content of the items is rendered
460
+ * @extends TCustomRenderProps
461
+ * @property icon: The icon of the item. If the renderIcon callback is provided, this will be the result of that callback
462
+ * @property title: The title of the item. If the renderTitle callback is provided, this will be the result of that callback
463
+ */
464
+ type TRenderTriggerProps = TCustomRenderProps & {
465
+ icon: React__default.ReactNode;
466
+ title: React__default.ReactNode;
467
+ };
468
+ type TTreeItemFunctions = {
469
+ /** A callback to customize how the titles are rendered */
470
+ renderTitle?: (props: TCustomRenderProps) => React__default.ReactNode;
471
+ /** A callback to customize how the icons are rendered */
472
+ renderIcon?: (props: TCustomRenderProps) => React__default.ReactNode;
473
+ /** A callback to customize how the content of the items is rendered */
474
+ renderTrigger?: (props: TRenderTriggerProps) => React__default.ReactNode;
475
+ /** A callback executed when an item is focused. An item gets focused when you click on it. Focusing and item will also select it. */
476
+ onFocusItem?: (item: TTreeViewItem) => void;
477
+ /** A callback executed when an item is selected. To select an item, ctrl+click on it. */
478
+ onSelectItems?: (item: string[]) => void;
479
+ /** A callback executed when an item is expanded */
480
+ onExpandItem?: (item: TTreeViewItem) => void;
481
+ /** A callback executed when an item is collapsed */
482
+ onCollapseItem?: (item: TTreeViewItem) => void;
483
+ /** A callback to handle the expansion of items without children */
484
+ onMissingChildren?: (item: TTreeViewItem) => void;
485
+ };
486
+ type TTreeViewProps = TTreeItemFunctions & {
487
+ /** An array representing the items that the tree needs to render */
488
+ items: TTreeViewItem[];
489
+ /** Disable multi-selection possibility */
490
+ isMultiSelectionDisabled?: boolean;
491
+ /** Custom styles */
492
+ sx?: Interpolation$1<Theme>;
493
+ };
494
+ type TUncontrolledTreeViewProps = TTreeViewProps & {
495
+ items: TTreeViewItem[];
496
+ };
497
+ type TControlledTreeViewProps = TTreeViewProps & {
498
+ /** The current state of the Tree View. */
499
+ viewState: TViewState;
500
+ };
501
+ type TViewState = {
502
+ /** The list of ids of items that are selected */
503
+ selectedItems?: string[];
504
+ /** The list of ids of items that are expanded */
505
+ expandedItems?: string[];
506
+ /** The focused item */
507
+ focusedItem?: string;
508
+ };
509
+ type TTreeViewItem = TTreeItemFunctions & {
510
+ /** Item identifier */
511
+ id: string;
512
+ /** Item name */
513
+ name: string;
514
+ /** The possible children of this item */
515
+ children?: string[];
516
+ /** If the item should be rendered as a folder even with no children */
517
+ isFolder?: boolean;
518
+ /** A callback to fetch children asynchronously */
519
+ childrenAsync?: () => Promise<TTreeViewItem[]>;
520
+ /** Custom styles */
521
+ sx?: Interpolation$1<Theme>;
522
+ };
523
+
524
+ /** @jsxImportSource @emotion/react */
525
+
526
+ declare const ControlledTreeView: FC<TControlledTreeViewProps>;
527
+
528
+ declare const UncontrolledTreeView: FC<TUncontrolledTreeViewProps>;
529
+
530
+ type DrawerProps = {
531
+ /** Position of the drawer */
532
+ anchor: "top" | "right" | "bottom" | "left";
533
+ /** Trigger showed when drawer is closed */
534
+ closedTrigger?: ReactNode;
535
+ /** Trigger showed when drawer is open */
536
+ openTrigger?: ReactNode;
537
+ /** Component to be rendered when Drawer is open */
538
+ openContent?: ReactNode;
539
+ /** Component to be rendered when Drawer is closed */
540
+ closedContent?: ReactNode;
541
+ /** Min open of the drawer as number of pixels. If not defined the minOpen will be the height of closedContent if present, otherwise 0px */
542
+ minOpen?: number;
543
+ /** Max open of the drawer as number of pixels. If not defined the maxOpen will be the height of openContent with limit at 90vh/vw */
544
+ maxOpen?: number;
545
+ /** Background color */
546
+ bgColor?: string;
547
+ /** Trigger hover color */
548
+ triggerHoverColor?: string;
549
+ };
550
+ declare const Drawer: ({ anchor, openContent, closedContent, openTrigger, closedTrigger, minOpen, maxOpen, bgColor, triggerHoverColor, }: DrawerProps) => _emotion_react_jsx_runtime.JSX.Element;
551
+
450
552
  /**
451
553
  * Hook to check if the screen is mobile. The default breakpoint is 768px.
452
554
  * @param {number=} mobileBreakpoint breakpoint width to check against
@@ -473,17 +575,27 @@ declare const styled: CreateStyled;
473
575
  declare const getContrastColor: (color: string) => string;
474
576
  /**
475
577
  *
476
- * @param color the color to darken
578
+ * @param color a color
477
579
  * @param strength the strength (0-100) to darken the color
478
580
  * @returns the color darkened by the strength
479
581
  */
480
582
  declare const darkenColor: (color: string, strength?: number) => string;
481
583
  /**
482
584
  *
483
- * @param color the color to lighten
585
+ * @param color a color
484
586
  * @param strength the strength (0-100) to lighten the color
485
587
  * @returns the color lightened by the strength
486
588
  */
487
589
  declare const lightenColor: (color: string, strength?: number) => string;
590
+ /**
591
+ * @param color a color
592
+ * @returns the hover color, based on if the color is dark or light
593
+ */
594
+ declare const getHoverColor: (color: string) => string;
595
+ /**
596
+ * @param color a color
597
+ * @returns the active color, based on if the color is dark or light
598
+ */
599
+ declare const getActiveColor: (color: string) => string;
488
600
 
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 };
601
+ export { Accordion, Button, ButtonProps, Card, CardContent, CardFooter, CardHeader, CardIndicators, CardMediaSection, ControlledTreeView, Drawer, DrawerProps, 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, TControlledTreeViewProps, TCustomRenderProps, TIndicatorProps, TIndicatorVariants, TMultiViewListProps, TTableCell, TTableProps, TTableRow, TTagProps, TThemeMode, TTreeViewItem, TUncontrolledTreeViewProps, TViewState, Table, Tag, ThemeContextProvider, UncontrolledTreeView, darkenColor, defaultDarkPalette, defaultLightPalette, getActiveColor, getContrastColor, getHoverColor, 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.5",
3
+ "version": "1.0.0-rc.7",
4
4
  "description": "Kwantis frontend components collection",
5
5
  "scriptsComments": {
6
6
  "storybook": "Starts storybook in development mode",