@kwantis-id3/frontend-library 0.20.1 → 0.20.3

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.
@@ -4,19 +4,35 @@ import React from "react";
4
4
  import { Theme } from "@emotion/react";
5
5
  import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
6
6
  export type AccordionProps = {
7
+ /** Text of the accordion trigger */
7
8
  title: string;
9
+ /** Content of the accordion */
8
10
  children: React.ReactNode;
11
+ /** Custom trigger component */
9
12
  customTrigger?: React.ReactNode;
13
+ /** Works only if uncontrolled (isOpen props is not present) */
14
+ defaultOpen?: boolean;
15
+ /** Color of the accordion */
10
16
  color?: ThemeColorsExtended;
17
+ /** Color of the icon */
11
18
  iconColor?: ThemeColorsExtended;
19
+ /** Color of the divider */
12
20
  dividerColor?: ThemeColorsExtended;
21
+ /** Hide the icon */
13
22
  hideIcon?: boolean;
23
+ /** Hide the divider */
14
24
  hideDivider?: boolean;
25
+ /** Pass your state value here if the Accordion needs to be Controlled */
15
26
  isOpen?: boolean;
27
+ /** Lazy render the content of the accordion */
16
28
  isLazy?: boolean;
29
+ /** onClick handler */
17
30
  onClick?: () => void;
31
+ /** onOpen handler */
18
32
  onOpen?: () => void;
33
+ /** onClose handler */
19
34
  onClose?: () => void;
35
+ /** Custom styles */
20
36
  sx?: Interpolation<Theme>;
21
37
  };
22
38
  export declare const Accordion: (props: AccordionProps) => import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
@@ -5,14 +5,22 @@ 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 of the button */
8
9
  color?: ThemeColorsExtended;
10
+ /** Type of the button */
9
11
  type?: "button" | "submit" | "reset";
12
+ /** Custom styles */
10
13
  sx?: Interpolation<Theme>;
14
+ /** Variant of the button, either `contained`, `outlined` or `text` */
11
15
  variant?: ButtonVariants;
16
+ /** onClick handler */
12
17
  onClick?: () => void;
13
18
  className?: string;
19
+ /** HTML id */
14
20
  htmlId?: string;
21
+ /** Disabled state */
15
22
  disabled?: boolean;
23
+ /** Elements to render as children */
16
24
  children?: React.ReactNode;
17
25
  };
18
26
  export declare const Button: (props: ButtonProps) => import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
@@ -1,5 +1,12 @@
1
1
  import React from "react";
2
2
  import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
3
+ /**
4
+ * @property {string} value - The value displayed in the dropdown item
5
+ * @property {ThemeColorsExtended} color - The color of the dropdown item
6
+ * @property {string} textColor - The text color of the dropdown item
7
+ * @property {DropdownItem[]} children - The children of the dropdown item
8
+ * @property {() => void} onClick - The onClick handler of the dropdown item
9
+ */
3
10
  export type DropdownItem = {
4
11
  value: string;
5
12
  color?: ThemeColorsExtended;
@@ -8,11 +15,17 @@ export type DropdownItem = {
8
15
  onClick?: () => void;
9
16
  };
10
17
  export type DropdownProps = {
18
+ /** The content of the dropdown */
11
19
  content: DropdownItem[];
20
+ /** The trigger element of the dropdown. Clicking on this item will open the dropdown */
12
21
  trigger: React.ReactNode;
22
+ /** The color of the dropdown */
13
23
  color?: ThemeColorsExtended;
24
+ /** The hover color of the dropdown */
14
25
  hoverColor?: ThemeColorsExtended;
26
+ /** Controls wether the dropdown should extend towards the left or the right */
15
27
  direction?: "left" | "right";
28
+ /** The mobile breakpoint, by default it's 768px */
16
29
  mobileBreakpoint?: number;
17
30
  };
18
31
  export declare const DropdownDesktop: (props: DropdownProps) => JSX.Element;
@@ -2,20 +2,30 @@
2
2
  import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
3
3
  export type TInputType = "text" | "number" | "password" | "email" | "image" | "search" | "tel" | "url" | "date" | "datetime-local" | "month" | "week" | "time" | "color";
4
4
  interface TextFieldProps {
5
+ /** The value of the input */
5
6
  value?: string | number;
7
+ /** The name of the input */
6
8
  name?: string;
9
+ /** The onChange handler of the input */
7
10
  onChange?: (value: string) => void;
11
+ /** The placeholder of the input */
8
12
  placeholder?: string;
13
+ /** The HTML id of the input */
9
14
  htmlId?: string;
15
+ /** Classname given to the container div */
10
16
  containerClassName?: string;
17
+ /** Classname of the input element */
11
18
  className?: string;
19
+ /** Disables the input */
12
20
  isDisabled?: boolean;
21
+ /** The color of the input */
13
22
  color?: ThemeColorsExtended;
14
23
  required?: boolean;
15
24
  pattern?: string;
16
25
  readonly?: boolean;
17
26
  autoFocus?: boolean;
18
27
  list?: string;
28
+ /** The type of the input (only string or number based inputs are currently supported) */
19
29
  type?: TInputType;
20
30
  }
21
31
  export declare const InputField: (props: TextFieldProps) => JSX.Element;
@@ -1,8 +1,12 @@
1
1
  import React from "react";
2
2
  interface ModalProps {
3
+ /** The content of the modal */
3
4
  children: React.ReactNode;
5
+ /** The state of the modal */
4
6
  isOpen: boolean;
7
+ /** The handler to change the state of the modal */
5
8
  setIsOpen: (isOpen: boolean) => void;
9
+ /** The handler to be called when the modal is closed */
6
10
  onClose?: () => void;
7
11
  }
8
12
  declare const Modal: React.FC<ModalProps>;
@@ -4,21 +4,41 @@ export interface MultiSelectProps<Option = {
4
4
  label: string;
5
5
  value: string;
6
6
  }> {
7
+ /** The options of the select, an array of objects `{ label: string; value: string }` */
7
8
  options: Option[];
9
+ /** The onChange handler of the select */
8
10
  onChange?: (option: Option[] | null) => void;
11
+ /** The value of the select */
9
12
  value?: readonly Option[] | null;
13
+ /** The name of the select */
10
14
  name?: string;
15
+ /** The placeholder of the select */
11
16
  placeholder?: string;
17
+ /** Disables the select */
12
18
  isDisabled?: boolean;
19
+ /** Wether the select should be clearable */
13
20
  isClearable?: boolean;
21
+ /** Wether the select should be searchable */
14
22
  isSearchable?: boolean;
23
+ /**
24
+ * A function that returns a boolean indicating wether the option should be disabled
25
+ * @param option - The option to check
26
+ * @returns boolean - true if the option should be disabled, false otherwise
27
+ */
15
28
  isOptionDisabled?: (option: Option) => boolean;
29
+ /** Wether the select is loading */
16
30
  isLoading?: boolean;
31
+ /** The color of the select */
17
32
  color?: ThemeColorsExtended;
33
+ /** The HTML id of the container */
18
34
  containerId?: string;
35
+ /** The HTML id of the select */
19
36
  htmlId?: string;
37
+ /** The class name of the select */
20
38
  className?: string;
39
+ /** The position of the menu */
21
40
  menuPosition?: "fixed" | "absolute";
41
+ /** Wether the select is required */
22
42
  required?: boolean;
23
43
  }
24
44
  export declare const MultiSelect: <Option>(props: MultiSelectProps<Option>) => JSX.Element;
@@ -4,22 +4,43 @@ export interface SingleSelectProps<Option = {
4
4
  label: string;
5
5
  value: string;
6
6
  }> {
7
+ /** The options of the select, an array of objects `{ label: string; value: string }` */
7
8
  options: Option[];
9
+ /** The onChange handler of the select */
8
10
  onChange?: (option: Option | null) => void;
11
+ /** The value of the select */
9
12
  value?: Option | null;
13
+ /** The name of the select */
10
14
  name?: string;
15
+ /** The placeholder of the select */
11
16
  placeholder?: string;
17
+ /** Disables the select */
12
18
  isDisabled?: boolean;
19
+ /** Wether the select should be clearable */
13
20
  isClearable?: boolean;
21
+ /** Wether the select should be searchable */
14
22
  isSearchable?: boolean;
23
+ /**
24
+ * A function that returns a boolean indicating wether the option should be disabled
25
+ * @param option - The option to check
26
+ * @returns boolean - true if the option should be disabled, false otherwise
27
+ */
15
28
  isOptionDisabled?: (option: Option) => boolean;
29
+ /** Wether the select is loading */
16
30
  isLoading?: boolean;
31
+ /** The color of the select */
17
32
  color?: ThemeColorsExtended;
33
+ /** The HTML id of the container */
18
34
  containerId?: string;
35
+ /** The HTML id of the select */
19
36
  htmlId?: string;
37
+ /** The class name of the select */
20
38
  className?: string;
39
+ /** The class name of the input */
21
40
  inputClassName?: string;
41
+ /** The position of the menu */
22
42
  menuPosition?: "fixed" | "absolute";
43
+ /** Wether the select is required */
23
44
  required?: boolean;
24
45
  }
25
46
  export declare const SingleSelect: <Option>(props: SingleSelectProps<Option>) => JSX.Element;
@@ -1,20 +1,35 @@
1
1
  /// <reference types="react" />
2
2
  import { ThemeColorsExtended } from "../ThemeContext/ThemeContext";
3
3
  export type SliderProps = {
4
+ /** The values of the slider. */
4
5
  values: number[];
6
+ /** The minimum value of the slider. */
5
7
  min?: number;
8
+ /** The maximum value of the slider. */
6
9
  max?: number;
10
+ /** The onChange handler of the slider (called each time the thumb moves of one position) */
7
11
  onChange: (values: number[]) => void;
12
+ /** The onFinalChange handler of the slider. (called only when the thumb is released) */
8
13
  onFinalChange?: (values: number[]) => void;
14
+ /** The color of the slider */
9
15
  color?: ThemeColorsExtended;
16
+ /** The color of the section not included in the range */
10
17
  unselectedColor?: ThemeColorsExtended;
18
+ /** The color of the thumb */
11
19
  thumbColor?: ThemeColorsExtended;
20
+ /** The HTML id of the slider */
12
21
  htmlId?: string;
22
+ /** The class name of the slider */
13
23
  className?: string;
24
+ /** Wether the thumb value should be displayed */
14
25
  showThumbValue?: boolean;
26
+ /** Wether the min and max values should be calculated automatically based on the values */
15
27
  autoCalculateMinMax?: boolean;
28
+ /** The step of the slider. Defaults to 1 */
16
29
  step?: number;
30
+ /** Disables the slider */
17
31
  disabled?: boolean;
32
+ /** Wether the thumbs can overlap */
18
33
  allowOverlap?: boolean;
19
34
  };
20
35
  export declare const Slider: (props: SliderProps) => JSX.Element;
package/dist/index.d.ts CHANGED
@@ -42,52 +42,86 @@ declare const useThemeContext: () => ThemeProperties;
42
42
 
43
43
  type ButtonVariants = "contained" | "outlined" | "text";
44
44
  type ButtonProps = {
45
+ /** Color of the button */
45
46
  color?: ThemeColorsExtended;
47
+ /** Type of the button */
46
48
  type?: "button" | "submit" | "reset";
49
+ /** Custom styles */
47
50
  sx?: Interpolation<Theme>;
51
+ /** Variant of the button, either `contained`, `outlined` or `text` */
48
52
  variant?: ButtonVariants;
53
+ /** onClick handler */
49
54
  onClick?: () => void;
50
55
  className?: string;
56
+ /** HTML id */
51
57
  htmlId?: string;
58
+ /** Disabled state */
52
59
  disabled?: boolean;
60
+ /** Elements to render as children */
53
61
  children?: React$1.ReactNode;
54
62
  };
55
63
  declare const Button: (props: ButtonProps) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
56
64
 
57
65
  type AccordionProps = {
66
+ /** Text of the accordion trigger */
58
67
  title: string;
68
+ /** Content of the accordion */
59
69
  children: React__default.ReactNode;
70
+ /** Custom trigger component */
60
71
  customTrigger?: React__default.ReactNode;
72
+ /** Works only if uncontrolled (isOpen props is not present) */
73
+ defaultOpen?: boolean;
74
+ /** Color of the accordion */
61
75
  color?: ThemeColorsExtended;
76
+ /** Color of the icon */
62
77
  iconColor?: ThemeColorsExtended;
78
+ /** Color of the divider */
63
79
  dividerColor?: ThemeColorsExtended;
80
+ /** Hide the icon */
64
81
  hideIcon?: boolean;
82
+ /** Hide the divider */
65
83
  hideDivider?: boolean;
84
+ /** Pass your state value here if the Accordion needs to be Controlled */
66
85
  isOpen?: boolean;
86
+ /** Lazy render the content of the accordion */
67
87
  isLazy?: boolean;
88
+ /** onClick handler */
68
89
  onClick?: () => void;
90
+ /** onOpen handler */
69
91
  onOpen?: () => void;
92
+ /** onClose handler */
70
93
  onClose?: () => void;
94
+ /** Custom styles */
71
95
  sx?: Interpolation<Theme>;
72
96
  };
73
97
  declare const Accordion: (props: AccordionProps) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
74
98
 
75
99
  type TInputType = "text" | "number" | "password" | "email" | "image" | "search" | "tel" | "url" | "date" | "datetime-local" | "month" | "week" | "time" | "color";
76
100
  interface TextFieldProps {
101
+ /** The value of the input */
77
102
  value?: string | number;
103
+ /** The name of the input */
78
104
  name?: string;
105
+ /** The onChange handler of the input */
79
106
  onChange?: (value: string) => void;
107
+ /** The placeholder of the input */
80
108
  placeholder?: string;
109
+ /** The HTML id of the input */
81
110
  htmlId?: string;
111
+ /** Classname given to the container div */
82
112
  containerClassName?: string;
113
+ /** Classname of the input element */
83
114
  className?: string;
115
+ /** Disables the input */
84
116
  isDisabled?: boolean;
117
+ /** The color of the input */
85
118
  color?: ThemeColorsExtended;
86
119
  required?: boolean;
87
120
  pattern?: string;
88
121
  readonly?: boolean;
89
122
  autoFocus?: boolean;
90
123
  list?: string;
124
+ /** The type of the input (only string or number based inputs are currently supported) */
91
125
  type?: TInputType;
92
126
  }
93
127
  declare const InputField: (props: TextFieldProps) => JSX.Element;
@@ -96,22 +130,43 @@ interface SingleSelectProps<Option = {
96
130
  label: string;
97
131
  value: string;
98
132
  }> {
133
+ /** The options of the select, an array of objects `{ label: string; value: string }` */
99
134
  options: Option[];
135
+ /** The onChange handler of the select */
100
136
  onChange?: (option: Option | null) => void;
137
+ /** The value of the select */
101
138
  value?: Option | null;
139
+ /** The name of the select */
102
140
  name?: string;
141
+ /** The placeholder of the select */
103
142
  placeholder?: string;
143
+ /** Disables the select */
104
144
  isDisabled?: boolean;
145
+ /** Wether the select should be clearable */
105
146
  isClearable?: boolean;
147
+ /** Wether the select should be searchable */
106
148
  isSearchable?: boolean;
149
+ /**
150
+ * A function that returns a boolean indicating wether the option should be disabled
151
+ * @param option - The option to check
152
+ * @returns boolean - true if the option should be disabled, false otherwise
153
+ */
107
154
  isOptionDisabled?: (option: Option) => boolean;
155
+ /** Wether the select is loading */
108
156
  isLoading?: boolean;
157
+ /** The color of the select */
109
158
  color?: ThemeColorsExtended;
159
+ /** The HTML id of the container */
110
160
  containerId?: string;
161
+ /** The HTML id of the select */
111
162
  htmlId?: string;
163
+ /** The class name of the select */
112
164
  className?: string;
165
+ /** The class name of the input */
113
166
  inputClassName?: string;
167
+ /** The position of the menu */
114
168
  menuPosition?: "fixed" | "absolute";
169
+ /** Wether the select is required */
115
170
  required?: boolean;
116
171
  }
117
172
  declare const SingleSelect: <Option>(props: SingleSelectProps<Option>) => JSX.Element;
@@ -120,44 +175,86 @@ interface MultiSelectProps<Option = {
120
175
  label: string;
121
176
  value: string;
122
177
  }> {
178
+ /** The options of the select, an array of objects `{ label: string; value: string }` */
123
179
  options: Option[];
180
+ /** The onChange handler of the select */
124
181
  onChange?: (option: Option[] | null) => void;
182
+ /** The value of the select */
125
183
  value?: readonly Option[] | null;
184
+ /** The name of the select */
126
185
  name?: string;
186
+ /** The placeholder of the select */
127
187
  placeholder?: string;
188
+ /** Disables the select */
128
189
  isDisabled?: boolean;
190
+ /** Wether the select should be clearable */
129
191
  isClearable?: boolean;
192
+ /** Wether the select should be searchable */
130
193
  isSearchable?: boolean;
194
+ /**
195
+ * A function that returns a boolean indicating wether the option should be disabled
196
+ * @param option - The option to check
197
+ * @returns boolean - true if the option should be disabled, false otherwise
198
+ */
131
199
  isOptionDisabled?: (option: Option) => boolean;
200
+ /** Wether the select is loading */
132
201
  isLoading?: boolean;
202
+ /** The color of the select */
133
203
  color?: ThemeColorsExtended;
204
+ /** The HTML id of the container */
134
205
  containerId?: string;
206
+ /** The HTML id of the select */
135
207
  htmlId?: string;
208
+ /** The class name of the select */
136
209
  className?: string;
210
+ /** The position of the menu */
137
211
  menuPosition?: "fixed" | "absolute";
212
+ /** Wether the select is required */
138
213
  required?: boolean;
139
214
  }
140
215
  declare const MultiSelect: <Option>(props: MultiSelectProps<Option>) => JSX.Element;
141
216
 
142
217
  type SliderProps = {
218
+ /** The values of the slider. */
143
219
  values: number[];
220
+ /** The minimum value of the slider. */
144
221
  min?: number;
222
+ /** The maximum value of the slider. */
145
223
  max?: number;
224
+ /** The onChange handler of the slider (called each time the thumb moves of one position) */
146
225
  onChange: (values: number[]) => void;
226
+ /** The onFinalChange handler of the slider. (called only when the thumb is released) */
147
227
  onFinalChange?: (values: number[]) => void;
228
+ /** The color of the slider */
148
229
  color?: ThemeColorsExtended;
230
+ /** The color of the section not included in the range */
149
231
  unselectedColor?: ThemeColorsExtended;
232
+ /** The color of the thumb */
150
233
  thumbColor?: ThemeColorsExtended;
234
+ /** The HTML id of the slider */
151
235
  htmlId?: string;
236
+ /** The class name of the slider */
152
237
  className?: string;
238
+ /** Wether the thumb value should be displayed */
153
239
  showThumbValue?: boolean;
240
+ /** Wether the min and max values should be calculated automatically based on the values */
154
241
  autoCalculateMinMax?: boolean;
242
+ /** The step of the slider. Defaults to 1 */
155
243
  step?: number;
244
+ /** Disables the slider */
156
245
  disabled?: boolean;
246
+ /** Wether the thumbs can overlap */
157
247
  allowOverlap?: boolean;
158
248
  };
159
249
  declare const Slider: (props: SliderProps) => JSX.Element;
160
250
 
251
+ /**
252
+ * @property {string} value - The value displayed in the dropdown item
253
+ * @property {ThemeColorsExtended} color - The color of the dropdown item
254
+ * @property {string} textColor - The text color of the dropdown item
255
+ * @property {DropdownItem[]} children - The children of the dropdown item
256
+ * @property {() => void} onClick - The onClick handler of the dropdown item
257
+ */
161
258
  type DropdownItem = {
162
259
  value: string;
163
260
  color?: ThemeColorsExtended;
@@ -166,19 +263,29 @@ type DropdownItem = {
166
263
  onClick?: () => void;
167
264
  };
168
265
  type DropdownProps = {
266
+ /** The content of the dropdown */
169
267
  content: DropdownItem[];
268
+ /** The trigger element of the dropdown. Clicking on this item will open the dropdown */
170
269
  trigger: React__default.ReactNode;
270
+ /** The color of the dropdown */
171
271
  color?: ThemeColorsExtended;
272
+ /** The hover color of the dropdown */
172
273
  hoverColor?: ThemeColorsExtended;
274
+ /** Controls wether the dropdown should extend towards the left or the right */
173
275
  direction?: "left" | "right";
276
+ /** The mobile breakpoint, by default it's 768px */
174
277
  mobileBreakpoint?: number;
175
278
  };
176
279
  declare const Dropdown: (props: DropdownProps) => JSX.Element;
177
280
 
178
281
  interface ModalProps {
282
+ /** The content of the modal */
179
283
  children: React__default.ReactNode;
284
+ /** The state of the modal */
180
285
  isOpen: boolean;
286
+ /** The handler to change the state of the modal */
181
287
  setIsOpen: (isOpen: boolean) => void;
288
+ /** The handler to be called when the modal is closed */
182
289
  onClose?: () => void;
183
290
  }
184
291
  declare const Modal: React__default.FC<ModalProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwantis-id3/frontend-library",
3
- "version": "0.20.1",
3
+ "version": "0.20.3",
4
4
  "description": "Kwantis frontend components collection",
5
5
  "scriptsComments": {
6
6
  "storybook": "Starts storybook in development mode",