opus-toolkit-components 1.6.9 → 1.7.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.
package/lib/index.d.ts CHANGED
@@ -3,186 +3,344 @@ declare module "opus-toolkit-components" {
3
3
 
4
4
  // Accordion
5
5
  export interface AccordionProps {
6
- items?: any[];
7
- className?: string;
6
+ title: string | React.ReactNode;
7
+ handleToggle?: (index: number) => void;
8
+ activeIndex?: number;
9
+ index: number;
10
+ isPreview?: boolean;
11
+ isLocked?: boolean;
12
+ onExitPreview?: () => void;
13
+ content: React.ReactNode;
14
+ preview?: React.ReactNode;
15
+ isPill?: boolean;
16
+ pillText?: string;
17
+ pillStatus?: "success" | "warning" | "error" | "info" | string;
18
+ pillIcon?: React.ReactNode;
19
+ disabled?: boolean;
8
20
  }
21
+
9
22
  export const Accordion: React.ComponentType<AccordionProps>;
10
23
 
11
- // Button
12
- export interface ButtonProps {
13
- children?: React.ReactNode;
14
- variant?: string;
15
- rank?: string;
16
- disabled?: boolean;
17
- onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
24
+ // BarLayout
25
+ export interface BarLayoutProps {
26
+ left?: React.ReactNode;
27
+ center?: React.ReactNode;
28
+ right?: React.ReactNode;
18
29
  className?: string;
30
+ }
31
+
32
+ export const BarLayout: React.ComponentType<BarLayoutProps>;
33
+
34
+ // Button
35
+ export type ButtonRank =
36
+ | "primary"
37
+ | "secondary"
38
+ | "tertiary"
39
+ | "outline"
40
+ | "destructive";
41
+
42
+ export type ButtonState = "default" | "disabled";
43
+
44
+ export type ButtonSize = "sm" | "md" | "lg" | "xl" | string;
45
+
46
+ export type IconComponent = (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
47
+
48
+ export interface ButtonProps
49
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {
50
+ type?: "button" | "submit" | "reset";
51
+ rank?: ButtonRank;
52
+ state?: ButtonState;
53
+ text?: string;
54
+ size?: ButtonSize;
19
55
  name?: string;
20
- ["data-cy"]?: string;
56
+ dataCy?: string;
57
+ tabIndex?: number;
58
+ isFullWidth?: boolean;
59
+ icon?: IconComponent;
60
+ iconPosition?: "left" | "right";
61
+ isIconAnimated?: boolean;
62
+ isSaving?: boolean;
63
+ savingText?: string;
64
+ className?: string;
65
+ title?: string;
66
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
21
67
  }
68
+
22
69
  export const Button: React.ComponentType<ButtonProps>;
23
70
 
24
71
  // Card
25
- export interface CardProps {
26
- children?: React.ReactNode;
72
+ export type CardIntent =
73
+ | "default"
74
+ | "info"
75
+ | "warning"
76
+ | "success"
77
+ | "error"
78
+ | "brand"
79
+ | "brandSecondary";
80
+
81
+ export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
82
+ intent?: CardIntent;
27
83
  className?: string;
84
+ children?: React.ReactNode;
28
85
  }
86
+
29
87
  export const Card: React.ComponentType<CardProps>;
30
88
 
31
- // Input
32
- export interface InputProps {
33
- name?: string;
34
- value?: string | number;
35
- placeholder?: string;
36
- onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
37
- className?: string;
38
- ["data-cy"]?: string;
89
+ // CookieBanner
90
+ export interface CookieBannerProps {
91
+ logo?: string;
92
+ policyTxt?: string;
93
+ linkTxt?: string;
94
+ isVisible?: boolean;
95
+ onAccept?: () => void;
96
+ onLearnMore?: () => void;
97
+ intent?: string;
39
98
  }
40
- export const Input: React.ComponentType<InputProps>;
41
99
 
42
- // DatePicker
43
- export interface DatePickerProps {
44
- name?: string;
45
- initialDate?: Date | string;
46
- label?: string;
47
- onChange?: (event: any) => void;
100
+ export const CookieBanner: React.ComponentType<CookieBannerProps>;
101
+
102
+ // Footer
103
+ export interface FooterProps {
104
+ left?: React.ReactNode;
105
+ center?: React.ReactNode;
106
+ right?: React.ReactNode;
48
107
  className?: string;
49
108
  }
50
- export const DatePicker: React.ComponentType<DatePickerProps>;
51
109
 
52
- // Radio
53
- export interface RadioButtonProps {
54
- name?: string;
55
- value?: string;
56
- checked?: boolean;
57
- onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
58
- }
59
- export const RadioButton: React.ComponentType<RadioButtonProps>;
110
+ export const Footer: React.ComponentType<FooterProps>;
60
111
 
61
112
  // Checkbox
62
- export interface CheckboxProps {
63
- name?: string;
64
- checked?: boolean;
65
- onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
66
- label?: string;
113
+
114
+ export interface CheckboxChangeEvent {
115
+ target: {
116
+ name: string;
117
+ value: boolean;
118
+ };
119
+ }
120
+
121
+ export interface CheckboxProps
122
+ extends React.HTMLAttributes<HTMLDivElement> {
123
+ label: string;
124
+ name: string;
125
+ onChange?: (event: CheckboxChangeEvent) => void;
126
+ value?: boolean;
127
+ isValid?: boolean;
128
+ errorMessage?: string;
129
+ disabled?: boolean;
130
+ title?: string;
131
+ dataCy?: string;
67
132
  }
133
+
68
134
  export const Checkbox: React.ComponentType<CheckboxProps>;
69
135
 
70
- // Table
71
- export interface TableProps {
72
- columns: any[];
73
- data: any[];
74
- className?: string;
136
+ // Datepicker
137
+ export interface DatePickerChangeEvent {
138
+ target: {
139
+ name: string;
140
+ value: string;
141
+ };
75
142
  }
76
- export const Table: React.ComponentType<TableProps>;
77
143
 
78
- // Dropdown
79
- export interface DropdownProps {
144
+ export interface DatePickerProps
145
+ extends React.HTMLAttributes<HTMLDivElement> {
146
+ initialDate?: string;
147
+ label?: string;
148
+ isValid?: boolean;
149
+ errorMessage?: string;
80
150
  name?: string;
151
+ onChange?: (event: DatePickerChangeEvent) => void;
81
152
  value?: string;
82
- options?: { label: string; value: string }[];
83
- onChange?: (event: any) => void;
84
153
  className?: string;
85
- ["data-cy"]?: string;
154
+ title?: string;
155
+ required?: boolean;
156
+ dataCy?: string;
157
+ disabled?: boolean;
86
158
  }
87
- export const Dropdown: React.ComponentType<DropdownProps>;
88
159
 
89
- // Navbar
90
- export interface NavbarProps {
91
- children?: React.ReactNode;
92
- className?: string;
160
+ export const DatePicker: React.ComponentType<DatePickerProps>;
161
+
162
+ // Dropdown
163
+ export interface DropdownItem {
164
+ label: string;
165
+ value: string | number;
93
166
  }
94
- export const Navbar: React.ComponentType<NavbarProps>;
95
167
 
96
- // Modal
97
- export interface ModalProps {
98
- open: boolean;
99
- onClose: () => void;
100
- children?: React.ReactNode;
101
- title?: string;
102
- className?: string;
168
+ export interface DropdownChangeEvent {
169
+ target: {
170
+ name: string;
171
+ value: string | number;
172
+ };
103
173
  }
104
- export const Modal: React.ComponentType<ModalProps>;
105
174
 
106
- // Loader
107
- export interface LoaderProps {
108
- size?: number | string;
175
+ export type IconComponent = (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
176
+
177
+ export interface DropdownProps
178
+ extends React.HTMLAttributes<HTMLDivElement> {
179
+ items?: DropdownItem[];
180
+ label?: string;
181
+ isValid?: boolean;
182
+ required?: boolean;
183
+ placeholder?: string;
184
+ name?: string;
109
185
  className?: string;
186
+ title?: string;
187
+ tabIndex?: string | number;
188
+ onChange?: (event: DropdownChangeEvent) => void;
189
+ value?: string | number;
190
+ Icon?: IconComponent;
191
+ errorMessage?: string;
192
+ disabled?: boolean;
193
+ dataCy?: string;
110
194
  }
111
- export const Loader: React.ComponentType<LoaderProps>;
112
195
 
113
- // Pill
114
- export interface PillProps {
196
+ export const Dropdown: React.ComponentType<DropdownProps>;
197
+
198
+ // Input
199
+ export type IconComponent = (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
200
+
201
+ export type CustomComponent = (props: any) => JSX.Element;
202
+
203
+ export interface InputProps
204
+ extends React.InputHTMLAttributes<HTMLInputElement> {
115
205
  label: string;
116
- variant?: string;
206
+ placeholder?: string;
207
+ type?:
208
+ | "text"
209
+ | "email"
210
+ | "password"
211
+ | "number"
212
+ | "search"
213
+ | "tel"
214
+ | "url"
215
+ | "date"
216
+ | "datetime-local"
217
+ | "month"
218
+ | "time"
219
+ | "week"
220
+ | string;
221
+ tabIndex?: string | number;
222
+ title?: string;
223
+ name?: string;
224
+ isValid?: boolean;
225
+ errorMessage?: string;
226
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
117
227
  className?: string;
228
+ value?: string | number;
229
+ Icon?: IconComponent;
230
+ iconPosition?: "left" | "right";
231
+ isAnimated?: boolean;
232
+ required?: boolean;
233
+ disabled?: boolean;
234
+ shouldRenderCustomComponent?: boolean;
235
+ customComponent?: CustomComponent;
236
+ customComponentProps?: Record<string, any>;
237
+ dataCy?: string;
118
238
  }
119
- export const Pill: React.ComponentType<PillProps>;
120
239
 
121
- // CookieBanner
122
- export interface CookieBannerProps {
123
- message?: string;
124
- acceptLabel?: string;
125
- declineLabel?: string;
126
- onAccept?: () => void;
127
- onDecline?: () => void;
240
+ export const Input: React.ForwardRefExoticComponent<
241
+ InputProps & React.RefAttributes<HTMLInputElement>
242
+ >;
243
+
244
+ // Radios
245
+ export interface RadioOption {
246
+ value: string | number;
247
+ label: string;
128
248
  }
129
- export const CookieBanner: React.ComponentType<CookieBannerProps>;
130
249
 
131
- // Text
132
- export interface TextProps {
133
- variant?: string;
134
- as?: keyof JSX.IntrinsicElements;
135
- children?: React.ReactNode;
136
- className?: string;
250
+ export interface RadioChangeEvent {
251
+ target: {
252
+ name: string;
253
+ value: string | number;
254
+ };
137
255
  }
138
- export const Text: React.ComponentType<TextProps>;
139
256
 
140
- // Sidebar
141
- export interface SidebarProps {
142
- open?: boolean;
143
- onClose?: () => void;
144
- children?: React.ReactNode;
257
+ export interface RadioButtonProps
258
+ extends React.HTMLAttributes<HTMLDivElement> {
259
+ label: string;
260
+ options?: RadioOption[];
261
+ name: string;
262
+ value?: string | number;
263
+ onChange?: (event: RadioChangeEvent) => void;
264
+ className?: string;
265
+ tabIndex?: string | number;
266
+ title?: string;
267
+ isValid?: boolean;
268
+ errorMessage?: string;
269
+ required?: boolean;
270
+ dataCy?: string;
271
+ disabled?: boolean;
145
272
  }
146
- export const Sidebar: React.ComponentType<SidebarProps>;
273
+
274
+ export const RadioButton: React.FC<RadioButtonProps>;
147
275
 
148
276
  // Header
149
- export interface HeaderProps {
150
- title?: string;
151
- actions?: React.ReactNode;
277
+ export interface HeaderProps extends React.HTMLAttributes<HTMLDivElement> {
278
+ title: string;
279
+ center?: React.ReactNode;
280
+ right?: React.ReactNode;
152
281
  className?: string;
153
282
  }
154
- export const Header: React.ComponentType<HeaderProps>;
283
+
284
+ export const Header: React.FC<HeaderProps>;
155
285
 
156
286
  // Icon
157
- export interface IconProps {
158
- name: string;
159
- size?: number | string;
287
+ export type HeroIconName = keyof typeof HeroIcons;
288
+ export type C247IconName = keyof typeof C247Icons;
289
+ export type IconName = HeroIconName | C247IconName;
290
+
291
+ export type IconLibrary = "hero" | "c247";
292
+
293
+ export interface IconProps extends React.SVGProps<SVGSVGElement> {
294
+ name: IconName;
295
+ library?: IconLibrary;
296
+ size?: number;
160
297
  className?: string;
298
+ color?: string;
161
299
  }
162
- export const Icon: React.ComponentType<IconProps>;
163
300
 
164
- // Footer
165
- export interface FooterProps {
166
- left?: React.ReactNode;
167
- center?: React.ReactNode;
168
- right?: React.ReactNode;
301
+ export const Icon: React.FC<IconProps>;
302
+
303
+ // Loader
304
+ export interface LoaderProps {
305
+ isLoading: boolean;
306
+ loaderText?: string;
307
+ customLoader?: React.ReactNode;
169
308
  className?: string;
170
309
  }
171
- export const Footer: React.ComponentType<FooterProps>;
172
310
 
173
- // BarLayout
174
- export interface BarLayoutProps {
175
- left?: React.ReactNode;
176
- center?: React.ReactNode;
177
- right?: React.ReactNode;
311
+ export const Loader: React.FC<LoaderProps>;
312
+
313
+ // Modal
314
+ export interface ModalProps {
315
+ isOpen: boolean;
316
+ onClose?: () => void;
317
+ isLoading?: boolean;
318
+ loaderText?: string;
319
+ header?: React.ReactNode;
320
+ hideHeader?: boolean;
321
+ body?: React.ReactNode;
322
+ footer?: React.ReactNode;
323
+ hideFooter?: boolean;
178
324
  className?: string;
325
+ footerClassName?: string;
326
+ headerClassName?: string;
179
327
  }
180
- export const BarLayout: React.ComponentType<BarLayoutProps>;
328
+
329
+ export const Modal: React.FC<ModalProps>;
330
+
331
+ // Navbar
332
+ export interface NavbarProps {
333
+ children?: React.ReactNode;
334
+ logo?: string;
335
+ className?: string;
336
+ maxWidth?: string;
337
+ }
338
+
339
+ export const Navbar: React.FC<NavbarProps>;
181
340
 
182
341
  // PageTemplate
183
342
  export interface PageTemplateProps {
184
343
  headerTitle?: string;
185
- headerLeft?: React.ReactNode;
186
344
  headerCenter?: React.ReactNode;
187
345
  headerRight?: React.ReactNode;
188
346
 
@@ -190,17 +348,116 @@ declare module "opus-toolkit-components" {
190
348
  footerCenter?: React.ReactNode;
191
349
  footerRight?: React.ReactNode;
192
350
 
193
- children?: React.ReactNode;
351
+ children: React.ReactNode;
194
352
  className?: string;
195
353
  }
196
- export const PageTemplate: React.ComponentType<PageTemplateProps>;
354
+
355
+ export const PageTemplate: React.FC<PageTemplateProps>;
356
+
357
+ // Pills
358
+ export interface PillProps extends React.HTMLAttributes<HTMLSpanElement> {
359
+ text?: string;
360
+ status?: 'primary' | 'danger' | 'warning' | 'success' | 'info' | 'notice';
361
+ className?: string;
362
+ icon?: (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
363
+ }
364
+
365
+ export const Pill: React.FC<PillProps>;
197
366
 
198
367
  // ProfileCard
199
- export interface ProfileCardProps {
368
+ export interface ProfileCardUser {
369
+ name: string;
370
+ role: string;
371
+ }
372
+
373
+ export interface ProfileCardProps extends React.HTMLAttributes<HTMLDivElement> {
374
+ user: ProfileCardUser;
375
+ href?: string;
376
+ }
377
+
378
+ export const ProfileCard: React.FC<ProfileCardProps>;
379
+
380
+ // Sidebar
381
+ export interface SidebarMenuItem {
382
+ key: string | number;
383
+ name: string;
384
+ icon?: string;
385
+ href?: string;
386
+ }
387
+
388
+ export interface SidebarMenuGroup {
389
+ key: string | number;
200
390
  name: string;
201
- description?: string;
202
- avatarUrl?: string;
391
+ children: SidebarMenuItem[];
392
+ }
393
+
394
+ export type SidebarMenu = SidebarMenuItem | SidebarMenuGroup;
395
+
396
+ export interface SidebarUser {
397
+ id: string | number;
398
+ name: string;
399
+ role: string;
400
+ avatar?: string;
401
+ }
402
+
403
+ export interface SidebarProps extends React.HTMLAttributes<HTMLDivElement> {
404
+ menus: SidebarMenu[];
405
+ user: SidebarUser;
406
+ activeItem?: string | number | null;
407
+ onItemClick?: (key: string | number) => void;
408
+ logo?: string;
409
+ searchValue?: string;
410
+ onSearchChange?: (value: string) => void;
411
+ }
412
+
413
+ export const Sidebar: React.FC<SidebarProps>;
414
+
415
+ // Table
416
+ export interface TableColumn {
417
+ key: string;
418
+ header: string;
419
+ render?: (row: any) => React.ReactNode;
420
+ }
421
+
422
+ export interface TableProps extends React.HTMLAttributes<HTMLDivElement> {
423
+ data?: TableColumn[];
424
+ rows?: any[];
203
425
  className?: string;
426
+ rowClassName?: string;
427
+ cellClassName?: string;
428
+ headRowClassName?: string;
429
+ headCellClassName?: string;
430
+ rowKeyExtractor?: (row: any, index: number) => string | number;
204
431
  }
205
- export const ProfileCard: React.ComponentType<ProfileCardProps>;
206
- }
432
+
433
+ export const Table: React.FC<TableProps>;
434
+
435
+ // Text
436
+ export type TextVariant =
437
+ | "h1"
438
+ | "h2"
439
+ | "h3"
440
+ | "h4"
441
+ | "h5"
442
+ | "h6"
443
+ | "body"
444
+ | "small"
445
+ | "caption"
446
+ | "label";
447
+
448
+ export type TextAs = keyof JSX.IntrinsicElements | React.ComponentType<any>;
449
+
450
+ export interface TextProps extends React.HTMLAttributes<HTMLElement> {
451
+ variant?: TextVariant;
452
+ as?: TextAs;
453
+ className?: string;
454
+ color?: string;
455
+ children?: React.ReactNode;
456
+ name?: string;
457
+ dataCy?: string;
458
+ }
459
+
460
+ export const Text: React.FC<TextProps>;
461
+
462
+
463
+ }
@@ -63579,7 +63579,7 @@ __webpack_require__.r(__webpack_exports__);
63579
63579
 
63580
63580
 
63581
63581
 
63582
- module.exports = __webpack_exports__;
63582
+ module.exports = __webpack_exports__.named;
63583
63583
  /******/ })()
63584
63584
  ;
63585
63585
  //# sourceMappingURL=opus-components.main.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opus-toolkit-components",
3
- "version": "1.6.9",
3
+ "version": "1.7.0",
4
4
  "private": false,
5
5
  "peerDependencies": {
6
6
  "react": "^17.0.0 || ^18.0.0",