@svar-ui/react-core 2.6.1 → 2.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svar-ui/react-core",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "description": "SVAR React Core library is a collection of customizable React UI components and form controls",
5
5
  "productTag": "core",
6
6
  "type": "module",
@@ -52,9 +52,9 @@
52
52
  "react-dom": ">=18"
53
53
  },
54
54
  "dependencies": {
55
- "@svar-ui/core-locales": "2.6.1",
56
- "@svar-ui/lib-dom": "0.14.0",
57
- "@svar-ui/lib-react": "1.2.2"
55
+ "@svar-ui/core-locales": "2.6.2",
56
+ "@svar-ui/lib-dom": "0.14.2",
57
+ "@svar-ui/lib-react": "1.3.1"
58
58
  },
59
59
  "homepage": "https://svar.dev/react/core/",
60
60
  "repository": {
package/types/index.d.ts CHANGED
@@ -1,8 +1,103 @@
1
1
  import type { ReactNode, FC } from 'react';
2
+ import type { TPosition } from '@svar-ui/lib-dom';
3
+
4
+ export type { ILocale, Terms, TPosition } from '@svar-ui/lib-dom';
5
+
6
+ export type TID = string | number;
7
+
8
+ // an item of the options list of select-like controls
9
+ export interface IOption {
10
+ id: TID;
11
+ label?: string;
12
+ }
13
+
14
+ export interface ITabOption extends IOption {
15
+ title?: string;
16
+ tooltip?: string;
17
+ icon?: string;
18
+ }
19
+
20
+ export interface DropdownOptions {
21
+ inline?: boolean;
22
+ position?: 'top' | 'right' | 'bottom' | 'left';
23
+ align?: 'start' | 'center' | 'end';
24
+ autoFit?: boolean;
25
+ css?: string;
26
+ width?: string | 'unset' | 'auto';
27
+ trackScroll?: boolean;
28
+ virtualized?: boolean;
29
+ }
30
+
31
+ export type TButtonType =
32
+ | ''
33
+ | 'primary'
34
+ | 'secondary'
35
+ | 'danger'
36
+ | 'link'
37
+ | 'primary block'
38
+ | 'secondary block'
39
+ | 'danger block'
40
+ | 'link block';
41
+
42
+ export type TCalendarButton = 'clear' | 'today' | 'done';
43
+
44
+ export type TDateFormat = string | ((value: Date) => string);
45
+
46
+ export interface IDateRange {
47
+ start: Date;
48
+ end?: Date | null;
49
+ }
50
+
51
+ export interface IUser {
52
+ id: string | number;
53
+ name?: string;
54
+ avatar?: string;
55
+ color?: string;
56
+ }
57
+
58
+ export type TPositionNoFit = Exclude<
59
+ TPosition,
60
+ 'bottom-fit' | 'top-fit' | 'center-fit'
61
+ >;
62
+
63
+ export type TooltipResolver = (
64
+ element: HTMLElement,
65
+ event: MouseEvent,
66
+ ) => Record<string, any> | string | null;
67
+
68
+ export type TTooltipContent = FC<Record<string, any>>;
69
+
70
+ // a message shown by showNotice() of the "wx-helpers" context
71
+ export interface INotice {
72
+ id?: TID;
73
+ text?: string;
74
+ type?: string;
75
+ expire?: number;
76
+ remove?: () => void;
77
+ }
78
+
79
+ // a dialog shown by showModal() of the "wx-helpers" context
80
+ export interface IModalMessage {
81
+ title?: string;
82
+ message?: string;
83
+ buttons?: boolean | string[];
84
+ }
85
+
86
+ export interface IModalEvent {
87
+ button?: string;
88
+ event: MouseEvent;
89
+ }
90
+
91
+ export interface IHelpers {
92
+ showNotice: (msg: INotice) => void;
93
+ showModal: (msg: IModalMessage) => Promise<unknown>;
94
+ }
95
+
96
+ export type TPortalMount = (handler: () => void) => void;
2
97
 
3
98
  export declare const TextArea: FC<{
4
99
  value?: string;
5
- id?: string | number;
100
+ id?: TID;
6
101
  placeholder?: string;
7
102
  title?: string;
8
103
  tooltip?: string;
@@ -14,15 +109,7 @@ export declare const TextArea: FC<{
14
109
  }>;
15
110
 
16
111
  export declare const Button: FC<{
17
- type?:
18
- | 'primary'
19
- | 'secondary'
20
- | 'danger'
21
- | 'link'
22
- | 'primary block'
23
- | 'secondary block'
24
- | 'danger block'
25
- | 'link block';
112
+ type?: TButtonType;
26
113
  css?: string;
27
114
  icon?: string;
28
115
  disabled?: boolean;
@@ -34,7 +121,7 @@ export declare const Button: FC<{
34
121
  }>;
35
122
 
36
123
  export declare const Checkbox: FC<{
37
- id?: string | number;
124
+ id?: TID;
38
125
  label?: string;
39
126
  inputValue?: string | number;
40
127
  value?: boolean;
@@ -44,17 +131,17 @@ export declare const Checkbox: FC<{
44
131
  }>;
45
132
 
46
133
  export declare const CheckboxGroup: FC<{
47
- options?: { id: string | number; label: string }[];
48
- value?: (string | number)[];
134
+ options?: IOption[];
135
+ value?: TID[];
49
136
  type?: 'inline' | 'grid';
50
137
  css?: string;
51
- onChange?: (ev: { value: (string | number)[] }) => void;
138
+ onChange?: (ev: { value: TID[] }) => void;
52
139
  }>;
53
140
 
54
141
  export declare const ColorSelect: FC<{
55
142
  colors?: string[];
56
143
  value?: string;
57
- id?: string | number;
144
+ id?: TID;
58
145
  clear?: boolean;
59
146
  placeholder?: string;
60
147
  title?: string;
@@ -75,7 +162,7 @@ export declare const ColorBoard: FC<{
75
162
 
76
163
  export declare const ColorPicker: FC<{
77
164
  value?: string;
78
- id?: string | number;
165
+ id?: TID;
79
166
  placeholder?: string;
80
167
  title?: string;
81
168
  tooltip?: string;
@@ -88,10 +175,10 @@ export declare const ColorPicker: FC<{
88
175
  }>;
89
176
 
90
177
  export declare const Combo: FC<{
91
- value?: string | number;
92
- id?: string | number;
93
- options?: { id: string | number; label: string }[];
94
- textOptions?: { id: string | number; label: string }[];
178
+ value?: TID;
179
+ id?: TID;
180
+ options?: IOption[];
181
+ textOptions?: IOption[] | null;
95
182
  textField?: string;
96
183
  placeholder?: string;
97
184
  title?: string;
@@ -100,21 +187,19 @@ export declare const Combo: FC<{
100
187
  error?: boolean;
101
188
  clear?: boolean;
102
189
  css?: string;
103
- dropdown?: DropdownOptions & {
104
- virtualized?: boolean;
105
- };
190
+ dropdown?: DropdownOptions;
106
191
  children?: ReactNode;
107
- onChange?: (ev: { value: string | number }) => void;
192
+ onChange?: (ev: { value: TID }) => void;
108
193
  }>;
109
194
 
110
195
  export declare const DatePicker: FC<{
111
196
  value?: Date;
112
- id?: string | number;
197
+ id?: TID;
113
198
  disabled?: boolean;
114
199
  error?: boolean;
115
200
  placeholder?: string;
116
- format?: string | ((value: Date) => string);
117
- buttons?: boolean | ('clear' | 'today')[];
201
+ format?: TDateFormat;
202
+ buttons?: boolean | TCalendarButton[];
118
203
  css?: string;
119
204
  title?: string;
120
205
  tooltip?: string;
@@ -125,21 +210,21 @@ export declare const DatePicker: FC<{
125
210
  }>;
126
211
 
127
212
  export declare const DateRangePicker: FC<{
128
- value?: { start: Date; end?: Date };
129
- id?: string | number;
213
+ value?: IDateRange | null;
214
+ id?: TID;
130
215
  disabled?: boolean;
131
216
  error?: boolean;
132
217
  placeholder?: string;
133
218
  css?: string;
134
219
  title?: string;
135
220
  tooltip?: string;
136
- format?: string | ((date: Date) => string);
221
+ format?: TDateFormat;
137
222
  months?: 1 | 2;
138
- buttons?: boolean | ('clear' | 'today' | 'done')[];
223
+ buttons?: boolean | TCalendarButton[];
139
224
  editable?: boolean | ((value: string) => Date | null);
140
225
  clear?: boolean;
141
226
  dropdown?: DropdownOptions;
142
- onChange?: (ev: { value: { start: Date; end: Date | null } | null }) => void;
227
+ onChange?: (ev: { value: IDateRange | null }) => void;
143
228
  }>;
144
229
 
145
230
  export declare const Icon: FC<{
@@ -151,10 +236,10 @@ export declare const Icon: FC<{
151
236
  }>;
152
237
 
153
238
  export declare const MultiCombo: FC<{
154
- id?: string | number;
155
- value?: (string | number)[];
156
- options?: { id: string | number; label: string }[];
157
- textOptions?: { id: string | number; label: string }[];
239
+ id?: TID;
240
+ value?: TID[];
241
+ options?: IOption[];
242
+ textOptions?: IOption[] | null;
158
243
  textField?: string;
159
244
  keepText?: boolean;
160
245
  placeholder?: string;
@@ -164,11 +249,9 @@ export declare const MultiCombo: FC<{
164
249
  error?: boolean;
165
250
  checkboxes?: boolean;
166
251
  css?: string;
167
- dropdown?: DropdownOptions & {
168
- virtualized?: boolean;
169
- };
252
+ dropdown?: DropdownOptions;
170
253
  children?: ReactNode;
171
- onChange?: (ev: { value: (string | number)[] }) => void;
254
+ onChange?: (ev: { value: TID[] }) => void;
172
255
  }>;
173
256
 
174
257
  export declare const Popup: FC<{
@@ -200,7 +283,7 @@ export declare const Pager: FC<{
200
283
  }>;
201
284
 
202
285
  export declare const RadioButton: FC<{
203
- id?: string | number;
286
+ id?: TID;
204
287
  label?: string;
205
288
  value?: boolean;
206
289
  name?: string;
@@ -211,17 +294,17 @@ export declare const RadioButton: FC<{
211
294
  }>;
212
295
 
213
296
  export declare const RadioButtonGroup: FC<{
214
- options?: { id: string | number; label: string }[];
215
- value?: string | number;
297
+ options?: IOption[];
298
+ value?: TID;
216
299
  type?: 'inline' | 'grid';
217
300
  css?: string;
218
- onChange?: (ev: { value: string | number }) => void;
301
+ onChange?: (ev: { value: TID }) => void;
219
302
  }>;
220
303
 
221
304
  export declare const RichSelect: FC<{
222
- value?: string | number;
223
- options?: { id: string | number; label: string }[];
224
- textOptions?: { id: string | number; label: string }[];
305
+ value?: TID;
306
+ options?: IOption[];
307
+ textOptions?: IOption[] | null;
225
308
  placeholder?: string;
226
309
  disabled?: boolean;
227
310
  error?: boolean;
@@ -230,30 +313,22 @@ export declare const RichSelect: FC<{
230
313
  textField?: string;
231
314
  clear?: boolean;
232
315
  css?: string;
233
- dropdown?: DropdownOptions & {
234
- virtualized?: boolean;
235
- };
316
+ dropdown?: DropdownOptions;
236
317
  children?: ReactNode;
237
- onChange?: (ev: { value: string | number }) => void;
318
+ onChange?: (ev: { value: TID }) => void;
238
319
  }>;
239
320
 
240
321
  export declare const Segmented: FC<{
241
- options?: {
242
- id: string | number;
243
- label: string;
244
- icon?: string;
245
- title?: string;
246
- tooltip?: string;
247
- }[];
248
- value?: string | number;
322
+ options?: ITabOption[];
323
+ value?: TID;
249
324
  css?: string;
250
325
  children?: ReactNode;
251
- onChange?: (ev: { value: string | number }) => void;
326
+ onChange?: (ev: { value: TID }) => void;
252
327
  }>;
253
328
 
254
329
  export declare const Select: FC<{
255
- value?: string | number;
256
- options?: { id: string | number; label: string }[];
330
+ value?: TID;
331
+ options?: IOption[];
257
332
  placeholder?: string;
258
333
  title?: string;
259
334
  tooltip?: string;
@@ -261,13 +336,13 @@ export declare const Select: FC<{
261
336
  error?: boolean;
262
337
  textField?: string;
263
338
  clear?: boolean;
264
- id?: string | number;
339
+ id?: TID;
265
340
  css?: string;
266
- onChange?: (ev: { value: string | number }) => void;
341
+ onChange?: (ev: { value: TID }) => void;
267
342
  }>;
268
343
 
269
344
  export declare const Slider: FC<{
270
- id?: string | number;
345
+ id?: TID;
271
346
  label?: string;
272
347
  width?: string;
273
348
  min?: number;
@@ -282,7 +357,7 @@ export declare const Slider: FC<{
282
357
  }>;
283
358
 
284
359
  export declare const Switch: FC<{
285
- id?: string | number;
360
+ id?: TID;
286
361
  value?: boolean;
287
362
  disabled?: boolean;
288
363
  css?: string;
@@ -290,22 +365,16 @@ export declare const Switch: FC<{
290
365
  }>;
291
366
 
292
367
  export declare const Tabs: FC<{
293
- options?: {
294
- id: string | number;
295
- label?: string;
296
- title?: string;
297
- tooltip?: string;
298
- icon?: string;
299
- }[];
300
- value?: string | number;
368
+ options?: ITabOption[];
369
+ value?: TID;
301
370
  type?: 'top' | 'bottom';
302
371
  css?: string;
303
- onChange?: (ev: { value: string | number }) => void;
372
+ onChange?: (ev: { value: TID }) => void;
304
373
  }>;
305
374
 
306
375
  export declare const Text: FC<{
307
376
  value?: string | number;
308
- id?: string | number;
377
+ id?: TID;
309
378
  readonly?: boolean;
310
379
  focus?: boolean;
311
380
  select?: boolean;
@@ -322,7 +391,7 @@ export declare const Text: FC<{
322
391
  }>;
323
392
 
324
393
  export declare const Counter: FC<{
325
- id?: string | number;
394
+ id?: TID;
326
395
  value?: number;
327
396
  step?: number;
328
397
  min?: number;
@@ -342,7 +411,7 @@ export declare const Field: FC<{
342
411
  error?: boolean;
343
412
  type?: 'checkbox' | 'slider' | 'switch';
344
413
  required?: boolean;
345
- id?: string | number;
414
+ id?: TID;
346
415
  css?: string;
347
416
  children?: ReactNode;
348
417
  }>;
@@ -351,14 +420,14 @@ export declare const Calendar: FC<{
351
420
  value?: Date;
352
421
  current?: Date;
353
422
  markers?: (date: Date) => string;
354
- buttons?: boolean | ('clear' | 'today')[];
423
+ buttons?: boolean | TCalendarButton[];
355
424
  css?: string;
356
425
  onChange?: (ev: { value: Date | null }) => void;
357
426
  }>;
358
427
 
359
428
  export declare const Month: FC<{
360
429
  value?: { start: Date; end: Date } | Date;
361
- current?: Date;
430
+ current: Date;
362
431
  part?: string;
363
432
  markers?: (date: Date) => string;
364
433
  onCancel?: () => void;
@@ -371,34 +440,26 @@ export declare const RangeCalendar: FC<{
371
440
  current?: Date;
372
441
  months?: 1 | 2;
373
442
  markers?: (date: Date) => string;
374
- buttons?: boolean | ('clear' | 'today' | 'done')[];
443
+ buttons?: boolean | TCalendarButton[];
375
444
  css?: string;
376
445
  onChange?: (ev: { start: Date | null; end: Date | null }) => void;
377
446
  }>;
378
447
 
379
448
  export declare const TimePicker: FC<{
380
449
  value?: Date;
381
- id?: string | number;
450
+ id?: TID;
382
451
  title?: string;
383
452
  tooltip?: string;
384
453
  css?: string;
385
454
  disabled?: boolean;
386
455
  error?: boolean;
387
- format?: string | ((value: Date) => string);
456
+ format?: TDateFormat;
388
457
  onChange?: (ev: { value: Date }) => void;
389
458
  }>;
390
459
 
391
460
  export declare const TwoState: FC<{
392
461
  value?: boolean;
393
- type?:
394
- | 'primary'
395
- | 'secondary'
396
- | 'danger'
397
- | 'link'
398
- | 'primary block'
399
- | 'secondary block'
400
- | 'danger block'
401
- | 'link block';
462
+ type?: TButtonType;
402
463
  icon?: string;
403
464
  disabled?: boolean;
404
465
  iconActive?: string;
@@ -420,8 +481,8 @@ export declare const Modal: FC<{
420
481
  footer?: ReactNode;
421
482
  css?: string;
422
483
  children?: ReactNode;
423
- onConfirm?: (ev: { button?: string; event: MouseEvent }) => void;
424
- onCancel?: (ev: { button?: string; event: MouseEvent }) => void;
484
+ onConfirm?: (ev: IModalEvent) => void;
485
+ onCancel?: (ev: IModalEvent) => void;
425
486
  }>;
426
487
 
427
488
  export declare const ModalArea: FC<{
@@ -473,29 +534,11 @@ export declare const Avatar: FC<{
473
534
  css?: string;
474
535
  }>;
475
536
 
476
- export interface DropdownOptions {
477
- inline?: boolean;
478
- position?: 'top' | 'right' | 'bottom' | 'left';
479
- align?: 'start' | 'center' | 'end';
480
- autoFit?: boolean;
481
- css?: string;
482
- width?: string | 'unset' | 'auto';
483
- trackScroll?: boolean;
484
- virtualized?: boolean;
485
- }
486
-
487
- export interface IUser {
488
- id: string | number;
489
- name?: string;
490
- avatar?: string;
491
- color?: string;
492
- }
493
-
494
537
  export declare const SuggestDropdown: FC<
495
538
  DropdownOptions & {
496
- items?: { id: string | number; label: string }[];
539
+ items?: IOption[];
497
540
  children?: ReactNode;
498
- onSelect?: (ev: { id: string | number | (string | number)[] }) => void;
541
+ onSelect?: (ev: { id: TID | TID[] }) => void;
499
542
  onReady?: (ev: {
500
543
  navigate?: (dir: number | null, ev?: KeyboardEvent) => void;
501
544
  keydown?: (ev: KeyboardEvent, dir: number) => void;
@@ -503,33 +546,20 @@ export declare const SuggestDropdown: FC<
503
546
  }) => void;
504
547
  multiselect?: boolean;
505
548
  checkboxes?: boolean;
506
- value?: string | number | (string | number)[];
549
+ value?: TID | TID[];
507
550
  virtualized?: boolean;
508
551
  }
509
552
  >;
510
553
 
511
- export type { ILocale, Terms, TPosition } from '@svar-ui/lib-dom';
512
- import type { TPosition } from '@svar-ui/lib-dom';
513
-
514
554
  export declare function popupContainer(node: HTMLElement): void;
515
555
 
516
- export type TPositionNoFit = Exclude<
517
- TPosition,
518
- 'bottom-fit' | 'top-fit' | 'center-fit'
519
- >;
520
-
521
- export type TooltipResolver = (
522
- element: HTMLElement,
523
- event: MouseEvent,
524
- ) => Record<string, any> | string | null;
525
-
526
556
  export declare const Tooltip: FC<{
527
557
  at?: TPositionNoFit;
528
558
  arrow?: boolean;
529
559
  touch?: boolean;
530
560
  overflow?: boolean;
531
561
  delay?: number;
532
- content?: FC<Record<string, any>> | null;
562
+ content?: TTooltipContent | null;
533
563
  resolver?: TooltipResolver;
534
564
  children?: ReactNode;
535
565
  css?: string;