@steroidsjs/core 3.0.0-beta.104 → 3.0.0-beta.106

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.
Files changed (48) hide show
  1. package/docs-autogen-result.json +3192 -1582
  2. package/hooks/useDataProvider.d.ts +17 -2
  3. package/hooks/useList.d.ts +53 -8
  4. package/hooks/useList.js +1 -1
  5. package/hooks/useSaveCursorPosition.js +4 -2
  6. package/package.json +1 -1
  7. package/ui/content/Accordion/Accordion.d.ts +5 -2
  8. package/ui/content/Alert/Alert.d.ts +5 -2
  9. package/ui/content/Badge/Badge.d.ts +5 -1
  10. package/ui/content/Calendar/Calendar.d.ts +6 -1
  11. package/ui/content/Card/Card.d.ts +31 -25
  12. package/ui/content/Chart/Chart.d.ts +10 -2
  13. package/ui/content/Chat/Chat.d.ts +24 -22
  14. package/ui/content/CopyToClipboard/CopyToClipboard.d.ts +3 -3
  15. package/ui/content/Detail/Detail.d.ts +15 -2
  16. package/ui/content/Kanban/hooks/useKanban.d.ts +33 -26
  17. package/ui/form/CheckboxListField/CheckboxListField.d.ts +14 -2
  18. package/ui/form/DateField/useDateRange.d.ts +1 -0
  19. package/ui/form/DateField/useDateRange.js +8 -1
  20. package/ui/form/DateRangeField/DateRangeField.d.ts +11 -1
  21. package/ui/form/DateRangeField/DateRangeField.js +2 -0
  22. package/ui/form/DateTimeRangeField/DateTimeRangeField.d.ts +11 -1
  23. package/ui/form/DateTimeRangeField/DateTimeRangeField.js +2 -0
  24. package/ui/form/DropDownField/DropDownField.d.ts +19 -3
  25. package/ui/form/Field/Field.d.ts +9 -1
  26. package/ui/form/Field/Field.js +1 -1
  27. package/ui/form/Field/fieldWrapper.d.ts +9 -1
  28. package/ui/form/FieldList/FieldList.d.ts +5 -1
  29. package/ui/form/Form/Form.d.ts +21 -3
  30. package/ui/form/ImageField/ImageField.d.ts +9 -1
  31. package/ui/form/InputField/InputField.d.ts +5 -2
  32. package/ui/form/InputField/InputField.js +10 -3
  33. package/ui/form/SliderField/SliderField.d.ts +10 -2
  34. package/ui/form/TimeRangeField/TimeRangeField.d.ts +10 -1
  35. package/ui/form/TimeRangeField/TimeRangeField.js +3 -1
  36. package/ui/layout/Tooltip/Tooltip.d.ts +4 -1
  37. package/ui/list/ControlsColumn/ControlsColumn.d.ts +16 -2
  38. package/ui/list/FlexGrid/FlexGrid.d.ts +11 -1
  39. package/ui/list/Grid/Grid.d.ts +42 -6
  40. package/ui/list/LayoutNames/LayoutNames.d.ts +11 -1
  41. package/ui/list/TreeTable/TreeTable.d.ts +39 -15
  42. package/ui/list/TreeTable/TreeTable.js +6 -3
  43. package/ui/modal/Modal/Modal.d.ts +7 -1
  44. package/ui/nav/Breadcrumbs/Breadcrumbs.d.ts +11 -1
  45. package/ui/nav/ButtonGroup/ButtonGroup.d.ts +13 -4
  46. package/ui/nav/Controls/Controls.d.ts +7 -1
  47. package/ui/nav/Nav/Nav.d.ts +15 -2
  48. package/ui/nav/Tree/Tree.d.ts +16 -2
@@ -52,7 +52,17 @@ export interface IDataProvider {
52
52
  export interface IDataProviderConfig {
53
53
  /**
54
54
  * Коллекция элементов
55
- * @example [{id: 1, label: 'Krasnoyarsk'}, {id: 2, label: 'Moscow'}]
55
+ * @example
56
+ * [
57
+ * {
58
+ * id: 1,
59
+ * label: 'Krasnoyarsk'
60
+ * },
61
+ * {
62
+ * id: 2,
63
+ * label: 'Moscow'
64
+ * }
65
+ * ]
56
66
  */
57
67
  items?: DataProviderItems;
58
68
  /**
@@ -67,7 +77,12 @@ export interface IDataProviderConfig {
67
77
  query?: string;
68
78
  /**
69
79
  * Настройки поиска
70
- * @example {enable: true, minLength: 2, delay: 100}
80
+ * @example
81
+ * {
82
+ * enable: true,
83
+ * minLength: 2,
84
+ * delay: 100
85
+ * }
71
86
  */
72
87
  autoComplete?: boolean | IAutoCompleteConfig;
73
88
  /**
@@ -49,27 +49,53 @@ export interface IListConfig {
49
49
  actionMethod?: HttpMethod;
50
50
  /**
51
51
  * Подключение пагинации
52
- * @example {loadMore: true}
52
+ * @example
53
+ * {
54
+ * loadMore: true
55
+ * }
53
56
  */
54
57
  pagination?: boolean | IPaginationProps;
55
58
  /**
56
59
  * Переключение количества элементов в списке
57
- * @example {sizes: [3, 6, 9], defaultValue: 3}
60
+ * @example
61
+ * {
62
+ * sizes: [3, 6, 9],
63
+ * defaultValue: 3
64
+ * }
58
65
  */
59
66
  paginationSize?: boolean | IPaginationSizeProps;
60
67
  /**
61
68
  * Подключение сортировки
62
- * @example {enable: true, defaultSort: 'startDate'}
69
+ * @example
70
+ * {
71
+ * enable: true,
72
+ * defaultSort: 'startDate'
73
+ * }
63
74
  */
64
75
  sort?: boolean | ISortConfig;
65
76
  /**
66
77
  * Варианты расположения элементов коллекции
67
- * @example {items: [{id: 'list', label: 'List'}, {id: 'grid', label: 'Grid'}]}
78
+ * @example
79
+ * {
80
+ * items: [
81
+ * {
82
+ * id: 'list',
83
+ * label: 'List'
84
+ * },
85
+ * {
86
+ * id: 'grid',
87
+ * label: 'Grid'
88
+ * }
89
+ * ]
90
+ * }
68
91
  */
69
92
  layout?: boolean | ILayoutNamesProps;
70
93
  /**
71
94
  * Заглушка в случае отсутствия элементов
72
- * @example {text: 'Записи не найдены'}
95
+ * @example
96
+ * {
97
+ * text: 'Записи не найдены'
98
+ * }
73
99
  */
74
100
  empty?: boolean | string | IEmptyProps;
75
101
  /**
@@ -79,7 +105,15 @@ export interface IListConfig {
79
105
  isLoading?: boolean;
80
106
  /**
81
107
  * Форма для поиска элементов
82
- * @example {fields: ['title'], model: {attributes: ['title:string:Название']}}
108
+ * @example
109
+ * {
110
+ * fields: ['title'],
111
+ * model: {
112
+ * attributes: [
113
+ * 'title:string:Название'
114
+ * ]
115
+ * }
116
+ * }
83
117
  */
84
118
  searchForm?: Omit<IFormProps, 'formId'> & {
85
119
  formId?: string;
@@ -124,7 +158,10 @@ export interface IListConfig {
124
158
  scope?: string[];
125
159
  /**
126
160
  * Дополнительные параметры, значения которых нужно передавать в запросе для получения данных
127
- * @example {tagName: 'MarketReviews'}
161
+ * @example
162
+ * {
163
+ * tagName: 'MarketReviews'
164
+ * }
128
165
  */
129
166
  query?: Record<string, unknown>;
130
167
  /**
@@ -133,7 +170,15 @@ export interface IListConfig {
133
170
  model?: string;
134
171
  /**
135
172
  * Модель для синхронизации значений формы с адресной строкой
136
- * @example {attributes: [{attribute: 'isMilesAvailable', type: boolean}]}
173
+ * @example
174
+ * {
175
+ * attributes: [
176
+ * {
177
+ * attribute: 'isMilesAvailable',
178
+ * type: boolean
179
+ * }
180
+ * ]
181
+ * }
137
182
  */
138
183
  searchModel?: string;
139
184
  /**
package/hooks/useList.js CHANGED
@@ -118,7 +118,7 @@ var prepareItemsToTree = function (sourceItems, openedTreeItems, currentPage, it
118
118
  var uniqueId = (0, list_1.getTreeItemUniqId)(item, index, parentId);
119
119
  var isOpened = !!openedTreeItems[uniqueId];
120
120
  var hasItems = !!(item.items && item.items.length > 0);
121
- treeItems.push(__assign(__assign({}, item), { uniqueId: uniqueId, level: currentLevel, isOpened: isOpened, hasItems: hasItems, onTreeItemClick: onTreeItemClick }));
121
+ treeItems.push(__assign(__assign({}, item), { uniqueId: uniqueId, level: currentLevel, isOpened: isOpened, hasItems: hasItems, onClick: function () { return onTreeItemClick(uniqueId, item); } }));
122
122
  if (isOpened) {
123
123
  treeItems = treeItems.concat((0, exports.prepareItemsToTree)(item.items, openedTreeItems, currentPage, itemsOnPage, onTreeItemClick, uniqueId, currentLevel + 1)).filter(Boolean);
124
124
  }
@@ -21,8 +21,10 @@ function useSaveCursorPosition(inputParams) {
21
21
  var onChange = react_1["default"].useCallback(function (event, value) {
22
22
  var _a, _b;
23
23
  if (value === void 0) { value = null; }
24
- setCursor((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.selectionStart);
25
- inputParams.onChange(value || ((_b = event.target) === null || _b === void 0 ? void 0 : _b.value));
24
+ if (event) {
25
+ setCursor((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.selectionStart);
26
+ }
27
+ inputParams.onChange.call(null, value || ((_b = event === null || event === void 0 ? void 0 : event.target) === null || _b === void 0 ? void 0 : _b.value));
26
28
  }, [inputParams]);
27
29
  return {
28
30
  inputRef: inputRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "3.0.0-beta.104",
3
+ "version": "3.0.0-beta.106",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  export interface IAccordionIcon {
3
3
  /**
4
4
  * Пользовательская иконка открытия
5
- * @example 'user
5
+ * @example 'user'
6
6
  */
7
7
  open: React.ReactElement | string;
8
8
  /**
@@ -64,7 +64,10 @@ export interface IAccordionProps extends IUiComponent {
64
64
  activeKey?: number;
65
65
  /**
66
66
  * Вызываемая функция при каждом изменении состояния
67
- * @example {() => {console.log('success')}}
67
+ * @example
68
+ * {
69
+ * () => { console.log('success') }
70
+ * }
68
71
  */
69
72
  onChange?: () => void;
70
73
  /**
@@ -18,7 +18,7 @@ import React from 'react';
18
18
  export interface IAlertProps extends IUiComponent {
19
19
  /**
20
20
  * Дочерние элементы
21
- * @example {<span>children</span>}
21
+ * @example { <span>children</span> }
22
22
  */
23
23
  children?: React.ReactNode;
24
24
  /**
@@ -45,7 +45,10 @@ export interface IAlertProps extends IUiComponent {
45
45
  showIcon?: boolean;
46
46
  /**
47
47
  * Callback функция вызываемая при нажатии на кнопку закрытия
48
- * @example {() => console.log('this is callback')}
48
+ * @example
49
+ * {
50
+ * () => console.log('this is callback')
51
+ * }
49
52
  */
50
53
  onClose?: () => void;
51
54
  /**
@@ -47,7 +47,11 @@ export interface IBadgeProps extends IUiComponent {
47
47
  message?: string;
48
48
  /**
49
49
  * Нужно ли отображать счетчик
50
- * @example {isEnable: true, content: 'Hello from counter!'}
50
+ * @example
51
+ * {
52
+ * isEnable: true,
53
+ * content: 'Hello from counter!',
54
+ * }
51
55
  */
52
56
  counter: boolean | ICounter;
53
57
  /**
@@ -29,7 +29,12 @@ export interface ICalendarProps extends IUiComponent {
29
29
  onChange?: (date: string) => void;
30
30
  /**
31
31
  * Свойства для компонента DayPickerInput
32
- * @example {dayPickerProps: {showWeekNumbers: true}}
32
+ * @example
33
+ * {
34
+ * dayPickerProps: {
35
+ * showWeekNumbers: true
36
+ * }
37
+ * }
33
38
  */
34
39
  pickerProps?: DayPickerProps | any;
35
40
  /**
@@ -38,6 +38,10 @@ export interface ICardHeader {
38
38
  * футер, коллекцию ссылок и коллекцию кнопок.
39
39
  */
40
40
  export interface ICardProps extends IUiComponent {
41
+ /**
42
+ * Коллекция кнопок
43
+ */
44
+ buttons?: IButtonProps[];
41
45
  /**
42
46
  * Дочерние элементы
43
47
  */
@@ -52,46 +56,48 @@ export interface ICardProps extends IUiComponent {
52
56
  * @example 'Scroll to see more...'
53
57
  */
54
58
  description?: string;
59
+ /**
60
+ * Контент футера
61
+ */
62
+ footer?: {
63
+ head: string;
64
+ subhead: string;
65
+ };
55
66
  /**
56
67
  * Контент хедера
57
68
  * @example
58
69
  * avatar: {
59
- * src: 'Kate.png',
60
- * status: true,
70
+ * src: 'Kate.png',
71
+ * status: true,
61
72
  * },
62
73
  * head: 'Header',
63
74
  * subhead: 'Subhead',
64
75
  * menu: {
65
76
  * dropDownProps: {
66
- position: 'bottom',
67
- closeMode: 'click-any',
68
- },
69
- items: [
70
- {label: 'Вырезать', icon: 'cut', onClick: voidFunction},
71
- {label: 'Копировать', icon: 'copy', hasBorder: true, onClick: voidFunction},
72
- {label: 'Показать историю изменений', hasBorder: true, onClick: voidFunction},
73
- {label: 'Редактировать', icon: 'edit', onClick: voidFunction},
74
- {label: 'Удалить', icon: 'trash', onClick: voidFunction},
75
- ],
76
- icon: 'menu_dots',
77
+ * position: 'bottom',
78
+ * closeMode: 'click-any',
79
+ * },
80
+ * items: [
81
+ * {
82
+ * label: 'Вырезать',
83
+ * icon: 'cut',
84
+ * onClick: voidFunction
85
+ * },
86
+ * {
87
+ * label: 'Копировать',
88
+ * icon: 'copy',
89
+ * hasBorder: true
90
+ * onClick: voidFunction
91
+ * },
92
+ * ],
93
+ * icon: 'menu_dots',
77
94
  * },
78
95
  */
79
96
  header?: ICardHeader;
80
97
  /**
81
- * Контент футера
98
+ * Коллекция ссылок
82
99
  */
83
- footer?: {
84
- head: string;
85
- subhead: string;
86
- };
87
- /**
88
- * Коллекция ссылок
89
- */
90
100
  links?: ILinkProps[];
91
- /**
92
- * Коллекция кнопок
93
- */
94
- buttons?: IButtonProps[];
95
101
  /**
96
102
  * Заголовок карточки
97
103
  * @example 'Main card'
@@ -16,12 +16,20 @@ export interface IChartProps extends IUiComponent {
16
16
  chartComponent: any;
17
17
  /**
18
18
  * Данные для графика
19
- * @example [{id: 1, value: 15}, {id: 2, value: 30}]
19
+ * @example
20
+ * [
21
+ * {id: 1, value: 15},
22
+ * {id: 2, value: 30}
23
+ * ]
20
24
  */
21
25
  data?: Record<string, any>[];
22
26
  /**
23
27
  * Конфигурация, настройки отображения графика
24
- * @example {lineWidth: 3, pointSize: 10}
28
+ * @example
29
+ * {
30
+ * lineWidth: 3,
31
+ * pointSize: 10
32
+ * }
25
33
  */
26
34
  config?: Record<string, any>;
27
35
  /**
@@ -26,35 +26,37 @@ export interface IChatProps extends IUiComponent {
26
26
  chatId: string;
27
27
  /**
28
28
  * Коллекция сообщений
29
- * @example [
29
+ * @example
30
+ * [
30
31
  * {
31
- * id: 1,
32
- * text: 'Всем привет!',
33
- * user: {
34
- * id: 1,
35
- * firstName: 'Olga',
36
- * lastName: 'Petrova',
37
- * avatar: {
38
- * src: 'images.com/image.png',
39
- * status: true,
40
- * },
41
- * },
42
- * timestamp: '2023-10-25T12:38:00',
32
+ * id: 1,
33
+ * text: 'Всем привет!',
34
+ * user: {
35
+ * id: 1,
36
+ * firstName: 'Olga',
37
+ * lastName: 'Petrova',
38
+ * avatar: {
39
+ * src: 'images.com/image.png',
40
+ * status: true,
43
41
  * },
42
+ * },
43
+ * timestamp: '2023-10-25T12:38:00',
44
+ * },
44
45
  * ]
45
46
  */
46
47
  messages: IChatMessage[];
47
48
  /**
48
49
  * Данные о текущем пользователе, нужны для отправки сообщений и определения сообщений пользователя
49
- * @example {
50
- * id: 1,
51
- * firstName: 'Olga',
52
- * lastName: 'Petrova',
53
- * avatar: {
54
- * src: 'images.com/image.png',
55
- * status: true,
56
- * },
57
- * }
50
+ * @example
51
+ * {
52
+ * id: 1,
53
+ * firstName: 'Olga',
54
+ * lastName: 'Petrova',
55
+ * avatar: {
56
+ * src: 'images.com/image.png',
57
+ * status: true,
58
+ * },
59
+ * }
58
60
  */
59
61
  currentUser: IChatUser;
60
62
  /**
@@ -33,9 +33,9 @@ export interface ICopyToClipboardProps extends IUiComponent {
33
33
  * message: 'Some value has been copied to buffer',
34
34
  * level: 'info',
35
35
  * params: {
36
- * position: 'top-left',
37
- * timeOut: 100,
38
- * }
36
+ * position: 'top-left',
37
+ * timeOut: 100,
38
+ * }
39
39
  * }
40
40
  */
41
41
  notification?: string | {
@@ -58,7 +58,16 @@ export interface IDetailProps extends IUiComponent {
58
58
  layout?: DetailLayoutEnum;
59
59
  /**
60
60
  * Перестраивать таблицу при ресайзе
61
- * @example {enable: true, media: [{breakpoint: 600, column: 2}]}
61
+ * @example
62
+ * {
63
+ * enable: true,
64
+ * media: [
65
+ * {
66
+ * breakpoint: 600,
67
+ * column: 2
68
+ * }
69
+ * ]
70
+ * }
62
71
  */
63
72
  responsive?: boolean | IDetailResponsive;
64
73
  /**
@@ -73,7 +82,11 @@ export interface IDetailProps extends IUiComponent {
73
82
  title?: string | React.ReactNode;
74
83
  /**
75
84
  * Контролы, которые нужно расположить рядом с таблицей
76
- * @example [{label: __(('Edit')), onClick: () => props.onClick()}]
85
+ * @example
86
+ * [{
87
+ * label: __(('Edit')),
88
+ * onClick: () => props.onClick()
89
+ * }]
77
90
  */
78
91
  controls?: IControlItem[];
79
92
  /**
@@ -7,18 +7,24 @@ export interface IKanbanConfig {
7
7
  kanbanId?: string;
8
8
  /**
9
9
  * Коллекция с наименованиями и свойствами колонок в таблице
10
- * @example [
11
- * {
12
- * id: 1,
13
- * title: 'column 1',
14
- * tasks: [{ content: 'item 1', id: 1 }],
15
- * },
16
- * {
17
- * id: 2,
18
- * title: 'column 2',
19
- * tasks: [],
20
- * }
21
- * ]
10
+ * @example
11
+ * [
12
+ * {
13
+ * id: 1,
14
+ * title: 'column 1',
15
+ * tasks: [
16
+ * {
17
+ * content: 'item 1',
18
+ * id: 1
19
+ * }
20
+ * ],
21
+ * },
22
+ * {
23
+ * id: 2,
24
+ * title: 'column 2',
25
+ * tasks: [],
26
+ * }
27
+ * ]
22
28
  */
23
29
  columns: IKanbanColumn[];
24
30
  /**
@@ -32,20 +38,21 @@ export interface IKanbanConfig {
32
38
  /**
33
39
  * Обработчик события окончания перетаскивания карточки или колонки
34
40
  * В result передается объект с информацией о событии
35
- * @example {
36
- * draggableId: 1,
37
- * type: 'task',
38
- * source: {
39
- * index: 0,
40
- * droppableId: 2
41
- * },
42
- * reason: 'DROP',
43
- * mode: 'FLUID',
44
- * destination: {
45
- * droppableId: 2,
46
- * index: 1
47
- * },
48
- * combine: null
41
+ * @example
42
+ * {
43
+ * draggableId: 1,
44
+ * type: 'task',
45
+ * source: {
46
+ * index: 0,
47
+ * droppableId: 2
48
+ * },
49
+ * reason: 'DROP',
50
+ * mode: 'FLUID',
51
+ * destination: {
52
+ * droppableId: 2,
53
+ * index: 1
54
+ * },
55
+ * combine: null
49
56
  * }
50
57
  */
51
58
  onDragEnd?: (result: IDragEndResult) => void;
@@ -20,7 +20,7 @@ type CheckboxFieldListItems = string | ({
20
20
  export interface ICheckboxListFieldProps extends IFieldWrapperInputProps, Omit<IDataProviderConfig, 'items'>, Omit<IDataSelectConfig, 'items'>, IUiComponent {
21
21
  /**
22
22
  * Свойства для элемента input
23
- * @example {onKeyDown: ...}
23
+ * @example { onKeyDown: ... }
24
24
  */
25
25
  inputProps?: any;
26
26
  /**
@@ -29,7 +29,19 @@ export interface ICheckboxListFieldProps extends IFieldWrapperInputProps, Omit<I
29
29
  orientation?: Orientation;
30
30
  /**
31
31
  * Коллекция элементов
32
- * @example [{id: 1, label: 'Krasnoyarsk', color: 'red'}, {id: 2, label: 'Moscow', color: 'purple'}]
32
+ * @example
33
+ * [
34
+ * {
35
+ * id: 1,
36
+ * label: 'Krasnoyarsk',
37
+ * color: 'red'
38
+ * },
39
+ * {
40
+ * id: 2,
41
+ * label: 'Moscow',
42
+ * color: 'purple'
43
+ * }
44
+ * ]
33
45
  */
34
46
  items: CheckboxFieldListItems;
35
47
  [key: string]: any;
@@ -9,6 +9,7 @@ interface IUseDateRangeProps extends Pick<IDateInputStateInput, 'displayFormat'
9
9
  inputTo: any;
10
10
  inputFrom: any;
11
11
  useSmartFocus: boolean;
12
+ hasInitialFocus: boolean;
12
13
  }
13
14
  export default function useDateRange(props: IUseDateRangeProps): {
14
15
  focus: "to" | "from";
@@ -21,6 +21,7 @@ var calendar_1 = require("@steroidsjs/core/utils/calendar");
21
21
  function useDateRange(props) {
22
22
  // Tracking focus for input being edited
23
23
  var _a = (0, react_1.useState)('from'), focus = _a[0], setFocus = _a[1];
24
+ var isFirstMount = (0, react_use_1.useFirstMountState)();
24
25
  // Local refs to handle auto-focus
25
26
  var valueFromRef = (0, react_1.useRef)('');
26
27
  var valueToRef = (0, react_1.useRef)('');
@@ -57,6 +58,9 @@ function useDateRange(props) {
57
58
  var prevValueFrom = (0, react_use_1.usePrevious)(props.inputFrom.value);
58
59
  var prevValueTo = (0, react_use_1.usePrevious)(props.inputTo.value);
59
60
  (0, react_1.useEffect)(function () {
61
+ if (!props.hasInitialFocus && isFirstMount) {
62
+ return;
63
+ }
60
64
  if (props.useSmartFocus) {
61
65
  if (focus === 'from' && !valueToRef.current && prevValueFrom !== props.inputFrom.value) {
62
66
  valueFromRef.current = props.inputFrom.value;
@@ -67,8 +71,11 @@ function useDateRange(props) {
67
71
  inputFromRef.current.focus();
68
72
  }
69
73
  }
74
+ else if (props.hasInitialFocus && isFirstMount) {
75
+ inputFromRef.current.focus();
76
+ }
70
77
  // eslint-disable-next-line max-len
71
- }, [focus, onClose, prevValueFrom, prevValueTo, props, props.inputFrom.onChange, props.inputFrom.value, props.inputTo.onChange, props.inputTo.value]);
78
+ }, [focus, isFirstMount, onClose, prevValueFrom, prevValueTo, props, props.inputFrom.onChange, props.inputFrom.value, props.inputTo.onChange, props.inputTo.value]);
72
79
  // Swap start and end dates if start date is later than end date
73
80
  (0, react_1.useEffect)(function () {
74
81
  if (props.inputFrom.value
@@ -22,7 +22,12 @@ export interface IDateRangeFieldProps extends IDateInputStateInput, Omit<IFieldW
22
22
  attributeTo?: string;
23
23
  /**
24
24
  * Свойства для компонента DayPickerInput
25
- * @example {dayPickerProps: {showWeekNumbers: true}}
25
+ * @example
26
+ * {
27
+ * dayPickerProps: {
28
+ * showWeekNumbers: true
29
+ * }
30
+ * }
26
31
  */
27
32
  pickerProps?: any;
28
33
  /**
@@ -62,6 +67,11 @@ export interface IDateRangeFieldProps extends IDateInputStateInput, Omit<IFieldW
62
67
  * Свойства для компонента Calendar
63
68
  */
64
69
  calendarProps?: ICalendarProps;
70
+ /**
71
+ * Устанавливать ли фокус и показывать календарь сразу после рендера страницы
72
+ * @example true
73
+ */
74
+ hasInitialFocus?: boolean;
65
75
  [key: string]: any;
66
76
  }
67
77
  export interface IDateRangeFieldViewProps extends IDateInputStateOutput, Omit<IFieldWrapperOutputProps, 'input'>, Pick<IDateRangeFieldProps, 'size' | 'icon' | 'errors' | 'showRemove' | 'calendarProps' | 'className' | 'disabled' | 'noBorder' | 'style'> {
@@ -63,6 +63,7 @@ function DateRangeField(props) {
63
63
  inputFrom: props.inputFrom,
64
64
  inputTo: props.inputTo,
65
65
  useSmartFocus: true,
66
+ hasInitialFocus: props.hasInitialFocus,
66
67
  displayFormat: props.displayFormat,
67
68
  valueFormat: props.valueFormat
68
69
  }), focus = _c.focus, onClose = _c.onClose, onClear = _c.onClear, extendedInputPropsFrom = _c.extendedInputPropsFrom, extendedInputPropsTo = _c.extendedInputPropsTo;
@@ -84,6 +85,7 @@ DateRangeField.defaultProps = {
84
85
  displayFormat: 'DD.MM.YYYY',
85
86
  valueFormat: 'YYYY-MM-DD',
86
87
  showRemove: true,
88
+ hasInitialFocus: false,
87
89
  icon: true,
88
90
  noBorder: false,
89
91
  size: 'md'
@@ -24,7 +24,12 @@ export interface IDateTimeRangeFieldProps extends Omit<IDateInputStateInput, 'in
24
24
  attributeTo?: string;
25
25
  /**
26
26
  * Свойства для компонента DayPickerInput
27
- * @example {dayPickerProps: {showWeekNumbers: true}}
27
+ * @example
28
+ * {
29
+ * dayPickerProps: {
30
+ * showWeekNumbers: true
31
+ * }
32
+ * }
28
33
  */
29
34
  pickerProps?: any;
30
35
  /**
@@ -43,6 +48,11 @@ export interface IDateTimeRangeFieldProps extends Omit<IDateInputStateInput, 'in
43
48
  * Свойства для компонента Calendar
44
49
  */
45
50
  calendarProps?: ICalendarProps;
51
+ /**
52
+ * Устанавливать ли фокус и показывать календарь сразу после рендера страницы
53
+ * @example true
54
+ */
55
+ hasInitialFocus?: boolean;
46
56
  [key: string]: any;
47
57
  }
48
58
  export interface IDateTimeRangeFieldViewProps extends IDateInputStateOutput, Omit<IFieldWrapperOutputProps, 'input'>, Pick<IDateRangeFieldProps, 'size' | 'icon' | 'errors' | 'showRemove' | 'calendarProps' | 'className' | 'disabled' | 'noBorder' | 'style'> {