@kwantis-id3/frontend-library 0.14.2 → 0.16.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.
@@ -6,9 +6,12 @@ import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
6
6
  export type AccordionProps = {
7
7
  title: string;
8
8
  children: React.ReactNode;
9
+ customTrigger?: React.ReactNode;
9
10
  color?: ThemeColorsExtended;
10
11
  iconColor?: ThemeColorsExtended;
11
12
  dividerColor?: ThemeColorsExtended;
13
+ hideIcon?: boolean;
14
+ hideDivider?: boolean;
12
15
  isOpen?: boolean;
13
16
  isLazy?: boolean;
14
17
  onClick?: () => void;
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
3
+ type DropdownItem = {
4
+ value: string;
5
+ color?: ThemeColorsExtended;
6
+ textColor?: string;
7
+ children?: DropdownItem[];
8
+ onClick?: () => void;
9
+ };
10
+ export type DropdownProps = {
11
+ content: DropdownItem[];
12
+ trigger: React.ReactNode;
13
+ color?: ThemeColorsExtended;
14
+ hoverColor?: ThemeColorsExtended;
15
+ direction?: "left" | "right";
16
+ mobileBreakpoint?: number;
17
+ };
18
+ export declare const DropdownDesktop: (props: DropdownProps) => JSX.Element;
19
+ type DropdownItemProps = DropdownItem & {
20
+ direction?: string;
21
+ hoverColor?: string;
22
+ };
23
+ declare const DropdownItem: (props: DropdownItemProps) => JSX.Element;
24
+ export declare const Dropdown: (props: DropdownProps) => JSX.Element;
25
+ export {};
@@ -0,0 +1,50 @@
1
+ /// <reference types="react" />
2
+ export declare const DropdownContainer: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("..").ThemeContextProps | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
+ export declare const DropdownTrigger: import("@emotion/styled").StyledComponent<{
7
+ theme?: import("..").ThemeContextProps | undefined;
8
+ as?: import("react").ElementType<any> | undefined;
9
+ } & {
10
+ $textColor: string;
11
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
12
+ export declare const DropdownBody: import("@emotion/styled").StyledComponent<{
13
+ theme?: import("..").ThemeContextProps | undefined;
14
+ as?: import("react").ElementType<any> | undefined;
15
+ } & {
16
+ $direction: string;
17
+ $isOpen: boolean;
18
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
19
+ export declare const DropdownItemContainer: import("@emotion/styled").StyledComponent<{
20
+ theme?: import("..").ThemeContextProps | undefined;
21
+ as?: import("react").ElementType<any> | undefined;
22
+ } & {
23
+ $bgColor: string;
24
+ $textColor: string;
25
+ $hoverColor: string;
26
+ $hoverTextColor: string;
27
+ $direction: string;
28
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
29
+ export declare const DropdownBodyMobile: import("@emotion/styled").StyledComponent<{
30
+ theme?: import("..").ThemeContextProps | undefined;
31
+ as?: import("react").ElementType<any> | undefined;
32
+ } & {
33
+ $isOpen: boolean;
34
+ $bgColor: string;
35
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
36
+ export declare const DropdownItemMobileContainer: import("@emotion/styled").StyledComponent<{
37
+ theme?: import("..").ThemeContextProps | undefined;
38
+ as?: import("react").ElementType<any> | undefined;
39
+ } & {
40
+ $bgColor: string;
41
+ $textColor: string;
42
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
43
+ export declare const AccordionBody: import("@emotion/styled").StyledComponent<{
44
+ theme?: import("..").ThemeContextProps | undefined;
45
+ as?: import("react").ElementType<any> | undefined;
46
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
47
+ export declare const ClickableItemMobile: import("@emotion/styled").StyledComponent<{
48
+ theme?: import("..").ThemeContextProps | undefined;
49
+ as?: import("react").ElementType<any> | undefined;
50
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1 @@
1
+ export { Dropdown, DropdownProps } from "./Dropdown";
@@ -24,8 +24,8 @@ type ThemeProperties = {
24
24
  colors: ThemeColorsObject;
25
25
  /**
26
26
  *
27
- * @param color one of the theme keys OR a string representing a color (hex, rgb, hsl, etc)
28
- * @returns a valid color object. If color is not valid, will return the primary color
27
+ * @param color one of the theme keys, a path to a specific color in the theme, OR a string representing a color (hex, rgb, hsl, etc)
28
+ * @returns a valid color object. If color is not valid, will return the primary color.
29
29
  */
30
30
  getColor: (color: ThemeColorsExtended) => Color;
31
31
  };
@@ -62,5 +62,17 @@ export declare const defaultThemeColors: {
62
62
  export declare const ThemeContextProvider: (props: React.PropsWithChildren<{
63
63
  theme?: ThemeContextProps;
64
64
  }>) => JSX.Element;
65
+ type NestedObject<T> = {
66
+ [key: string]: T | NestedObject<T>;
67
+ };
68
+ /**
69
+ * Returns the value of a nested object given a string path
70
+ * This function is supposed to be used ONLY to retrieve values from the theme object
71
+ *
72
+ * @param object the object to search
73
+ * @param path a string representing the path to the value
74
+ * @returns the value of the nested object
75
+ */
76
+ export declare function getObjectValueByPath<T>(obj: NestedObject<T>, path: string): T | undefined;
65
77
  export declare const useThemeContext: () => ThemeProperties;
66
78
  export {};
@@ -4,3 +4,4 @@ export { Accordion, AccordionProps } from "./Accordion";
4
4
  export { TextField } from "./TextField";
5
5
  export { SingleSelect, SingleSelectProps, MultiSelect, MultiSelectProps, } from "./SelectFilter";
6
6
  export { Slider, SliderProps } from "./Slider";
7
+ export { Dropdown, DropdownProps } from "./Dropdown";
@@ -1,2 +1,4 @@
1
+ import useIsMobile from "./isMobile";
1
2
  export { transientOptions } from "./transientOptions";
2
3
  export { styled } from "./styled";
4
+ export { useIsMobile };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hook to check if the screen is mobile. The default breakpoint is 768px.
3
+ * @param {number=} mobileBreakpoint breakpoint width to check against
4
+ * @returns boolean
5
+ */
6
+ declare const useIsMobile: (mobileBreakpoint?: number) => boolean;
7
+ export default useIsMobile;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { PropsOf } from '@emotion/react';
3
- import { CreateStyledComponent, StyledOptions, FilteringStyledOptions } from '@emotion/styled';
4
- import { ThemeContextProps } from '../components';
2
+ import { PropsOf } from "@emotion/react";
3
+ import { CreateStyledComponent, StyledOptions, FilteringStyledOptions } from "@emotion/styled";
4
+ import { ThemeContextProps } from "../components";
5
5
  export type StyledTags = {
6
6
  [Tag in keyof JSX.IntrinsicElements]: CreateStyledComponent<{
7
7
  theme?: ThemeContextProps;
package/dist/index.d.ts CHANGED
@@ -30,8 +30,8 @@ type ThemeProperties = {
30
30
  colors: ThemeColorsObject;
31
31
  /**
32
32
  *
33
- * @param color one of the theme keys OR a string representing a color (hex, rgb, hsl, etc)
34
- * @returns a valid color object. If color is not valid, will return the primary color
33
+ * @param color one of the theme keys, a path to a specific color in the theme, OR a string representing a color (hex, rgb, hsl, etc)
34
+ * @returns a valid color object. If color is not valid, will return the primary color.
35
35
  */
36
36
  getColor: (color: ThemeColorsExtended) => Color;
37
37
  };
@@ -56,9 +56,12 @@ declare const Button: (props: ButtonProps) => _emotion_react_types_jsx_namespace
56
56
  type AccordionProps = {
57
57
  title: string;
58
58
  children: React__default.ReactNode;
59
+ customTrigger?: React__default.ReactNode;
59
60
  color?: ThemeColorsExtended;
60
61
  iconColor?: ThemeColorsExtended;
61
62
  dividerColor?: ThemeColorsExtended;
63
+ hideIcon?: boolean;
64
+ hideDivider?: boolean;
62
65
  isOpen?: boolean;
63
66
  isLazy?: boolean;
64
67
  onClick?: () => void;
@@ -136,6 +139,35 @@ type SliderProps = {
136
139
  };
137
140
  declare const Slider: (props: SliderProps) => JSX.Element;
138
141
 
142
+ type DropdownProps = {
143
+ content: DropdownItem[];
144
+ trigger: React__default.ReactNode;
145
+ color?: ThemeColorsExtended;
146
+ hoverColor?: ThemeColorsExtended;
147
+ direction?: "left" | "right";
148
+ mobileBreakpoint?: number;
149
+ };
150
+ type DropdownItemProps = DropdownItem & {
151
+ direction?: string;
152
+ hoverColor?: string;
153
+ };
154
+ type DropdownItem = {
155
+ value: string;
156
+ color?: ThemeColorsExtended;
157
+ textColor?: string;
158
+ children?: DropdownItem[];
159
+ onClick?: () => void;
160
+ };
161
+ declare const DropdownItem: (props: DropdownItemProps) => JSX.Element;
162
+ declare const Dropdown: (props: DropdownProps) => JSX.Element;
163
+
164
+ /**
165
+ * Hook to check if the screen is mobile. The default breakpoint is 768px.
166
+ * @param {number=} mobileBreakpoint breakpoint width to check against
167
+ * @returns boolean
168
+ */
169
+ declare const useIsMobile: (mobileBreakpoint?: number) => boolean;
170
+
139
171
  declare const transientOptions: Parameters<CreateStyled$1>[1];
140
172
 
141
173
  type StyledTags = {
@@ -174,4 +206,4 @@ interface CreateStyled extends BaseCreateStyled, StyledTags {
174
206
  }
175
207
  declare const styled: CreateStyled;
176
208
 
177
- export { Accordion, AccordionProps, Button, ButtonProps, MultiSelect, MultiSelectProps, SingleSelect, SingleSelectProps, Slider, SliderProps, TextField, ThemeColors, ThemeColorsObject, ThemeContextProps, ThemeContextProvider, styled, transientOptions, useThemeContext };
209
+ export { Accordion, AccordionProps, Button, ButtonProps, Dropdown, DropdownProps, MultiSelect, MultiSelectProps, SingleSelect, SingleSelectProps, Slider, SliderProps, TextField, ThemeColors, ThemeColorsObject, ThemeContextProps, ThemeContextProvider, styled, transientOptions, useIsMobile, useThemeContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwantis-id3/frontend-library",
3
- "version": "0.14.2",
3
+ "version": "0.16.0",
4
4
  "description": "Kwantis frontend components collection",
5
5
  "author": {
6
6
  "name": "kwantis"
@@ -19,6 +19,7 @@
19
19
  "@storybook/testing-library": "0.2.2",
20
20
  "@testing-library/jest-dom": "^5.16.5",
21
21
  "@testing-library/react": "^14.0.0",
22
+ "@testing-library/user-event": "^14.5.1",
22
23
  "@types/jest": "^29.5.0",
23
24
  "@types/react": "^18.0.33",
24
25
  "@types/testing-library__jest-dom": "^5.14.5",
@@ -66,7 +67,6 @@
66
67
  "tinycolor2": "^1.6.0"
67
68
  },
68
69
  "readme": "ERROR: No README data found!",
69
- "_id": "@kwantis-id3/frontend-library@0.6.1",
70
70
  "scripts": {
71
71
  "rollup": "rollup -c",
72
72
  "test": "jest",