@kwantis-id3/frontend-library 0.9.0 → 0.10.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.
@@ -1,14 +1,14 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  import { Interpolation } from "@emotion/styled";
3
3
  import React from "react";
4
- import { ThemeColors } from "../ThemeContext";
5
4
  import { Theme } from "@emotion/react";
5
+ import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
6
6
  export type AccordionProps = {
7
7
  title: string;
8
8
  children: React.ReactNode;
9
- color?: ThemeColors;
10
- iconColor?: ThemeColors;
11
- dividerColor?: ThemeColors;
9
+ color?: ThemeColorsExtended;
10
+ iconColor?: ThemeColorsExtended;
11
+ dividerColor?: ThemeColorsExtended;
12
12
  isOpen?: boolean;
13
13
  isLazy?: boolean;
14
14
  onClick?: () => void;
@@ -1,11 +1,11 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  import * as React from "react";
3
- import { ThemeColors } from "../ThemeContext/ThemeContext";
3
+ import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
4
4
  import { Interpolation } from "@emotion/styled";
5
5
  import { Theme } from "@emotion/react";
6
6
  export type ButtonVariants = "contained" | "outlined" | "text";
7
7
  export type ButtonProps = {
8
- color?: ThemeColors;
8
+ color?: ThemeColorsExtended;
9
9
  sx?: Interpolation<Theme>;
10
10
  variant?: ButtonVariants;
11
11
  onClick?: () => void;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ThemeColors } from "../ThemeContext";
2
+ import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
3
3
  export interface MultiSelectProps<Option = {
4
4
  label: string;
5
5
  value: string;
@@ -13,7 +13,7 @@ export interface MultiSelectProps<Option = {
13
13
  isSearchable?: boolean;
14
14
  isOptionDisabled?: (option: Option) => boolean;
15
15
  isLoading?: boolean;
16
- color?: ThemeColors;
16
+ color?: ThemeColorsExtended;
17
17
  htmlId?: string;
18
18
  className?: string;
19
19
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ThemeColors } from "../ThemeContext";
2
+ import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
3
3
  export interface SingleSelectProps<Option = {
4
4
  label: string;
5
5
  value: string;
@@ -13,7 +13,7 @@ export interface SingleSelectProps<Option = {
13
13
  isSearchable?: boolean;
14
14
  isOptionDisabled?: (option: Option) => boolean;
15
15
  isLoading?: boolean;
16
- color?: ThemeColors;
16
+ color?: ThemeColorsExtended;
17
17
  htmlId?: string;
18
18
  className?: string;
19
19
  }
@@ -1,13 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { ThemeColors } from "../ThemeContext";
2
+ import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
3
3
  export type SliderProps = {
4
4
  values: number[];
5
5
  min?: number;
6
6
  max?: number;
7
7
  onChange: (values: number[]) => void;
8
8
  onFinalChange?: (values: number[]) => void;
9
- color?: ThemeColors;
10
- unselectedColor?: ThemeColors;
9
+ color?: ThemeColorsExtended;
10
+ unselectedColor?: ThemeColorsExtended;
11
+ thumbColor?: ThemeColorsExtended;
11
12
  htmlId?: string;
12
13
  className?: string;
13
14
  showThumbValue?: boolean;
@@ -15,7 +15,20 @@ export interface ThemeColorsObject {
15
15
  type ThemeContextProps = {
16
16
  colors: ThemeColorsObject;
17
17
  };
18
+ interface Nothing {
19
+ }
20
+ type Union<T, U> = T | (U & Nothing);
18
21
  export type ThemeColors = keyof ThemeColorsObject;
22
+ export type ThemeColorsExtended = Union<ThemeColors, string>;
23
+ type ThemeProperties = {
24
+ colors: ThemeColorsObject;
25
+ /**
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
29
+ */
30
+ getColor: (color: ThemeColorsExtended) => Color;
31
+ };
19
32
  export declare const defaultThemeColors: {
20
33
  primary: {
21
34
  main: string;
@@ -49,5 +62,5 @@ export declare const defaultThemeColors: {
49
62
  export declare const ThemeContextProvider: (props: React.PropsWithChildren<{
50
63
  theme?: ThemeContextProps;
51
64
  }>) => JSX.Element;
52
- export declare const useThemeContext: () => ThemeContextProps;
65
+ export declare const useThemeContext: () => ThemeProperties;
53
66
  export {};
package/dist/index.d.ts CHANGED
@@ -21,15 +21,28 @@ interface ThemeColorsObject {
21
21
  type ThemeContextProps = {
22
22
  colors: ThemeColorsObject;
23
23
  };
24
+ interface Nothing {
25
+ }
26
+ type Union<T, U> = T | (U & Nothing);
24
27
  type ThemeColors = keyof ThemeColorsObject;
28
+ type ThemeColorsExtended = Union<ThemeColors, string>;
29
+ type ThemeProperties = {
30
+ colors: ThemeColorsObject;
31
+ /**
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
35
+ */
36
+ getColor: (color: ThemeColorsExtended) => Color;
37
+ };
25
38
  declare const ThemeContextProvider: (props: React__default.PropsWithChildren<{
26
39
  theme?: ThemeContextProps;
27
40
  }>) => JSX.Element;
28
- declare const useThemeContext: () => ThemeContextProps;
41
+ declare const useThemeContext: () => ThemeProperties;
29
42
 
30
43
  type ButtonVariants = "contained" | "outlined" | "text";
31
44
  type ButtonProps = {
32
- color?: ThemeColors;
45
+ color?: ThemeColorsExtended;
33
46
  sx?: Interpolation<Theme>;
34
47
  variant?: ButtonVariants;
35
48
  onClick?: () => void;
@@ -43,9 +56,9 @@ declare const Button: (props: ButtonProps) => _emotion_react_types_jsx_namespace
43
56
  type AccordionProps = {
44
57
  title: string;
45
58
  children: React__default.ReactNode;
46
- color?: ThemeColors;
47
- iconColor?: ThemeColors;
48
- dividerColor?: ThemeColors;
59
+ color?: ThemeColorsExtended;
60
+ iconColor?: ThemeColorsExtended;
61
+ dividerColor?: ThemeColorsExtended;
49
62
  isOpen?: boolean;
50
63
  isLazy?: boolean;
51
64
  onClick?: () => void;
@@ -68,7 +81,7 @@ interface SingleSelectProps<Option = {
68
81
  isSearchable?: boolean;
69
82
  isOptionDisabled?: (option: Option) => boolean;
70
83
  isLoading?: boolean;
71
- color?: ThemeColors;
84
+ color?: ThemeColorsExtended;
72
85
  htmlId?: string;
73
86
  className?: string;
74
87
  }
@@ -87,7 +100,7 @@ interface MultiSelectProps<Option = {
87
100
  isSearchable?: boolean;
88
101
  isOptionDisabled?: (option: Option) => boolean;
89
102
  isLoading?: boolean;
90
- color?: ThemeColors;
103
+ color?: ThemeColorsExtended;
91
104
  htmlId?: string;
92
105
  className?: string;
93
106
  }
@@ -99,8 +112,9 @@ type SliderProps = {
99
112
  max?: number;
100
113
  onChange: (values: number[]) => void;
101
114
  onFinalChange?: (values: number[]) => void;
102
- color?: ThemeColors;
103
- unselectedColor?: ThemeColors;
115
+ color?: ThemeColorsExtended;
116
+ unselectedColor?: ThemeColorsExtended;
117
+ thumbColor?: ThemeColorsExtended;
104
118
  htmlId?: string;
105
119
  className?: string;
106
120
  showThumbValue?: boolean;
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@kwantis-id3/frontend-library",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Kwantis frontend components collection",
5
5
  "author": {
6
6
  "name": "kwantis"
7
7
  },
8
8
  "license": "apache-2.0",
9
9
  "devDependencies": {
10
- "@emotion/react": "^11.10.6",
11
- "@emotion/styled": "^11.10.6",
12
10
  "@rollup/plugin-commonjs": "^24.0.1",
13
11
  "@rollup/plugin-node-resolve": "^15.0.1",
14
12
  "@rollup/plugin-typescript": "^11.0.0",
@@ -47,6 +45,8 @@
47
45
  "typescript": "^5.0.3"
48
46
  },
49
47
  "peerDependencies": {
48
+ "@emotion/react": ">= 11.10.0",
49
+ "@emotion/styled": ">= 11.10.0",
50
50
  "react": ">= 17.0.2"
51
51
  },
52
52
  "main": "dist/cjs/index.js",