@steroidsjs/core 3.0.0-beta.103 → 3.0.0-beta.105

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 (62) hide show
  1. package/components/HttpComponent.d.ts +4 -4
  2. package/components/JwtHttpComponent.d.ts +2 -2
  3. package/components/LocaleComponent.d.ts +5 -5
  4. package/components/ResourceComponent.d.ts +2 -2
  5. package/components/WebSocketComponent.d.ts +6 -6
  6. package/docs-autogen-result.json +10480 -4175
  7. package/en.json +119 -110
  8. package/hooks/useDataProvider.d.ts +17 -2
  9. package/hooks/useFile.d.ts +1 -0
  10. package/hooks/useFile.js +2 -0
  11. package/hooks/useList.d.ts +53 -8
  12. package/hooks/useList.js +1 -1
  13. package/package.json +2 -1
  14. package/ui/content/Accordion/Accordion.d.ts +5 -2
  15. package/ui/content/Alert/Alert.d.ts +5 -2
  16. package/ui/content/Badge/Badge.d.ts +5 -1
  17. package/ui/content/Calendar/Calendar.d.ts +6 -1
  18. package/ui/content/Card/Card.d.ts +31 -25
  19. package/ui/content/Chart/Chart.d.ts +10 -2
  20. package/ui/content/Chat/Chat.d.ts +24 -22
  21. package/ui/content/CopyToClipboard/CopyToClipboard.d.ts +3 -3
  22. package/ui/content/Detail/Detail.d.ts +15 -2
  23. package/ui/content/DropDown/DropDown.d.ts +1 -1
  24. package/ui/content/DropDown/DropDown.js +4 -4
  25. package/ui/content/Kanban/hooks/useKanban.d.ts +33 -26
  26. package/ui/form/CheckboxListField/CheckboxListField.d.ts +14 -2
  27. package/ui/form/DateField/useDateRange.d.ts +1 -0
  28. package/ui/form/DateField/useDateRange.js +8 -1
  29. package/ui/form/DateRangeField/DateRangeField.d.ts +11 -1
  30. package/ui/form/DateRangeField/DateRangeField.js +2 -0
  31. package/ui/form/DateTimeRangeField/DateTimeRangeField.d.ts +11 -1
  32. package/ui/form/DateTimeRangeField/DateTimeRangeField.js +2 -0
  33. package/ui/form/DropDownField/DropDownField.d.ts +19 -3
  34. package/ui/form/Field/Field.d.ts +9 -1
  35. package/ui/form/Field/Field.js +1 -1
  36. package/ui/form/Field/fieldWrapper.d.ts +9 -1
  37. package/ui/form/FieldList/FieldList.d.ts +5 -1
  38. package/ui/form/Form/Form.d.ts +21 -3
  39. package/ui/form/Form/Form.js +4 -1
  40. package/ui/form/ImageField/ImageField.d.ts +9 -1
  41. package/ui/form/InputField/InputField.d.ts +5 -2
  42. package/ui/form/NumberField/NumberField.js +34 -7
  43. package/ui/form/SliderField/SliderField.d.ts +10 -2
  44. package/ui/form/TimeRangeField/TimeRangeField.d.ts +10 -1
  45. package/ui/form/TimeRangeField/TimeRangeField.js +3 -1
  46. package/ui/layout/Tooltip/Tooltip.d.ts +4 -1
  47. package/ui/list/ControlsColumn/ControlsColumn.d.ts +16 -2
  48. package/ui/list/FlexGrid/FlexGrid.d.ts +11 -1
  49. package/ui/list/Grid/Grid.d.ts +42 -6
  50. package/ui/list/LayoutNames/LayoutNames.d.ts +11 -1
  51. package/ui/list/TreeTable/TreeTable.d.ts +39 -15
  52. package/ui/list/TreeTable/TreeTable.js +6 -3
  53. package/ui/modal/Modal/Modal.d.ts +7 -1
  54. package/ui/nav/Breadcrumbs/Breadcrumbs.d.ts +11 -1
  55. package/ui/nav/ButtonGroup/ButtonGroup.d.ts +13 -4
  56. package/ui/nav/Controls/Controls.d.ts +7 -1
  57. package/ui/nav/Nav/Nav.d.ts +15 -2
  58. package/ui/nav/Router/Router.js +3 -0
  59. package/ui/nav/Tree/Tree.d.ts +16 -2
  60. package/utils/calculateComponentAbsolutePosition.js +57 -21
  61. package/utils/form.d.ts +1 -0
  62. package/utils/form.js +16 -1
@@ -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
  /**
@@ -36,7 +36,7 @@ export interface IDropDownViewProps extends IDropDownProps, IAbsolutePositioning
36
36
  /**
37
37
  * Рассчет абсолютной позиции
38
38
  */
39
- calculatePosition: (componentSize: ClientRect) => void;
39
+ calculatePosition?: (dropDownDimensions: Record<string, any>, arrowDimensions: Record<string, any>) => void;
40
40
  /**
41
41
  * Ссылка на view
42
42
  */
@@ -45,7 +45,7 @@ var TooltipPortalInner_1 = __importDefault(require("../../layout/Tooltip/Tooltip
45
45
  var useAbsolutePositioning_1 = __importDefault(require("../../../hooks/useAbsolutePositioning"));
46
46
  function DropDown(props) {
47
47
  var components = (0, hooks_1.useComponents)();
48
- var _a = (0, useAbsolutePositioning_1["default"])(props), isComponentExist = _a.isComponentExist, isComponentVisible = _a.isComponentVisible, calculateAbsolutePosition = _a.calculateAbsolutePosition, onShow = _a.onShow, onHide = _a.onHide, position = _a.position, style = _a.style;
48
+ var _a = (0, useAbsolutePositioning_1["default"])(props), isComponentExist = _a.isComponentExist, isComponentVisible = _a.isComponentVisible, calculateAbsolutePosition = _a.calculateAbsolutePosition, onShow = _a.onShow, onHide = _a.onHide, position = _a.position, arrowPosition = _a.arrowPosition, style = _a.style;
49
49
  var childRef = (0, react_1.useRef)(null);
50
50
  var isManualControl = props.visible !== undefined;
51
51
  // Outside click -> close
@@ -70,8 +70,8 @@ function DropDown(props) {
70
70
  }, [isComponentExist, isComponentVisible, onHide, props.closeMode]);
71
71
  (0, react_use_1.useEvent)('mousedown', onAnyClick);
72
72
  (0, react_use_1.useEvent)('touchstart', onAnyClick);
73
- var calculatePosition = (0, react_1.useCallback)(function (componentSize) {
74
- calculateAbsolutePosition(position, childRef.current, componentSize);
73
+ var calculatePosition = (0, react_1.useCallback)(function (componentSize, arrowSize) {
74
+ calculateAbsolutePosition(position, childRef.current, componentSize, arrowSize);
75
75
  // eslint-disable-next-line react-hooks/exhaustive-deps
76
76
  }, []);
77
77
  var DropDownView = components.ui.getView(props.view || 'content.DropDownView');
@@ -93,7 +93,7 @@ function DropDown(props) {
93
93
  isComponentExist && (
94
94
  // TODO Change Portal to global
95
95
  React.createElement(TooltipPortalInner_1["default"], null,
96
- React.createElement(DropDownView, __assign({}, props, { className: props.className, forwardedRef: forwardedRef, content: props.content, position: position, style: style, calculatePosition: calculatePosition, isComponentVisible: isComponentVisible, onClose: onHide }))))));
96
+ React.createElement(DropDownView, __assign({}, props, { className: props.className, forwardedRef: forwardedRef, content: props.content, position: position, style: style, arrowPosition: arrowPosition, calculatePosition: calculatePosition, isComponentVisible: isComponentVisible, onClose: onHide }))))));
97
97
  }
98
98
  DropDown.defaultProps = {
99
99
  autoPositioning: true,
@@ -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'> {
@@ -85,6 +85,7 @@ function DateTimeRangeField(props) {
85
85
  inputFrom: props.inputFrom,
86
86
  inputTo: props.inputTo,
87
87
  useSmartFocus: false,
88
+ hasInitialFocus: props.hasInitialFocus,
88
89
  displayFormat: props.displayFormat,
89
90
  valueFormat: props.valueFormat
90
91
  }), focus = _e.focus, onClose = _e.onClose, onClear = _e.onClear, extendedInputPropsFrom = _e.extendedInputPropsFrom, extendedInputPropsTo = _e.extendedInputPropsTo;
@@ -110,6 +111,7 @@ DateTimeRangeField.defaultProps = {
110
111
  displayFormat: 'DD.MM.YYYY' + DATE_TIME_SEPARATOR + 'HH:mm',
111
112
  valueFormat: 'YYYY-MM-DD' + DATE_TIME_SEPARATOR + 'HH:mm',
112
113
  showRemove: true,
114
+ hasInitialFocus: false,
113
115
  useUTC: false,
114
116
  dateInUTC: false,
115
117
  icon: true,
@@ -86,7 +86,11 @@ export interface IDropDownFieldProps extends IFieldWrapperInputProps, Omit<IData
86
86
  groupAttribute?: string;
87
87
  /**
88
88
  * Свойство, которое устанавливает один type и src контента для всех пунктов
89
- * @example {type: 'icon', src: 'user'}
89
+ * @example
90
+ * {
91
+ * type: 'icon',
92
+ * src: 'user'
93
+ * }
90
94
  */
91
95
  itemsContent?: {
92
96
  type: ContentType | string;
@@ -94,7 +98,15 @@ export interface IDropDownFieldProps extends IFieldWrapperInputProps, Omit<IData
94
98
  };
95
99
  /**
96
100
  * Элементы вложенные внутрь DropDownField
97
- * @example [{id: 1, label: 'Ivan Ivanov', type: 'icon', typeSrc: 'user'}]
101
+ * @example
102
+ * [
103
+ * {
104
+ * id: 1,
105
+ * label: 'Ivan Ivanov',
106
+ * type: 'icon',
107
+ * typeSrc: 'user'
108
+ * }
109
+ * ]
98
110
  */
99
111
  items?: IDropDownFieldItem[] | DataProviderItems;
100
112
  /**
@@ -104,7 +116,11 @@ export interface IDropDownFieldProps extends IFieldWrapperInputProps, Omit<IData
104
116
  showEllipses?: boolean;
105
117
  /**
106
118
  * Добавляет кнопку при нажатии на которую выбираются все элементы, работает только при multiple: true
107
- * @example {label: 'All', id: 'all'}
119
+ * @example
120
+ * {
121
+ * label: 'All',
122
+ * id: 'all'
123
+ * }
108
124
  */
109
125
  itemToSelectAll?: boolean | {
110
126
  label: string;
@@ -16,7 +16,15 @@ export interface IFieldProps extends IFieldWrapperInputProps {
16
16
  attribute?: any;
17
17
  /**
18
18
  * Модель с полями формы
19
- * @example {attributes: [{attribute: 'category', field: 'DropDownField'}]}
19
+ * @example
20
+ * {
21
+ * attributes: [
22
+ * {
23
+ * attribute: 'category',
24
+ * field: 'DropDownField'
25
+ * }
26
+ * ]
27
+ * }
20
28
  */
21
29
  model?: Model;
22
30
  /**
@@ -50,7 +50,7 @@ function Field(props) {
50
50
  var fieldModel = (0, react_1.useMemo)(function () {
51
51
  var _a;
52
52
  var model = props.model || context.model;
53
- var modelAttributes = (((_a = components.meta.getModel(model)) === null || _a === void 0 ? void 0 : _a.attributes) || []);
53
+ var modelAttributes = (((_a = components.meta.getModel(model)) === null || _a === void 0 ? void 0 : _a.attributes) || (model === null || model === void 0 ? void 0 : model.attributes) || []);
54
54
  var result = modelAttributes
55
55
  .find(function (field) { return field.attribute === props.attribute; });
56
56
  return result || {};
@@ -16,7 +16,15 @@ export interface IFieldWrapperInputProps {
16
16
  attribute?: string;
17
17
  /**
18
18
  * Модель с полями формы
19
- * @example {attributes: [{attribute: 'category', field: 'DropDownField'}]}
19
+ * @example
20
+ * {
21
+ * attributes: [
22
+ * {
23
+ * attribute: 'category',
24
+ * field: 'DropDownField'
25
+ * }
26
+ * ]
27
+ * }
20
28
  */
21
29
  model?: string | ((...args: any[]) => any) | any;
22
30
  /**
@@ -34,7 +34,11 @@ export interface IFieldListItem extends IFieldWrapperInputProps, IUiComponent {
34
34
  export interface IFieldListProps extends IFieldWrapperInputProps, IUiComponent {
35
35
  /**
36
36
  * Начальные значения в полях
37
- * @example {name: 'Ivan', amount: 5}
37
+ * @example
38
+ * {
39
+ * name: 'Ivan',
40
+ * amount: 5
41
+ * }
38
42
  */
39
43
  initialValues?: {
40
44
  [key: string]: any;
@@ -19,7 +19,15 @@ export interface IFormProps extends IUiComponent {
19
19
  prefix?: string;
20
20
  /**
21
21
  * Модель с полями формы
22
- * @example {attributes: [{attribute: 'category', field: 'DropDownField'}]}
22
+ * @example
23
+ * {
24
+ * attributes: [
25
+ * {
26
+ * attribute: 'category',
27
+ * field: 'DropDownField'
28
+ * }
29
+ * ]
30
+ * }
23
31
  */
24
32
  model?: string | ((...args: any[]) => any) | any;
25
33
  /**
@@ -45,7 +53,11 @@ export interface IFormProps extends IUiComponent {
45
53
  /**
46
54
  * Набор с правилами для проверки соответствия значений полей формы определенному формату.
47
55
  * Проверка запускается в момент отправки формы (в обработчике onSubmit).
48
- * @example [['name', 'required'], ['age', 'integer']]
56
+ * @example
57
+ * [
58
+ * ['name', 'required'],
59
+ * ['age', 'integer']
60
+ * ]
49
61
  */
50
62
  validators?: any[];
51
63
  /**
@@ -97,7 +109,13 @@ export interface IFormProps extends IUiComponent {
97
109
  viewProps?: any;
98
110
  /**
99
111
  * Поля, которые необходимо поместить в форму
100
- * @example [{attribute: 'category', component: 'DropDownField'}]
112
+ * @example
113
+ * [
114
+ * {
115
+ * attribute: 'category',
116
+ * component: 'DropDownField'
117
+ * }
118
+ * ]
101
119
  */
102
120
  fields?: (string | IFieldProps)[];
103
121
  /**
@@ -129,7 +129,7 @@ function Form(props) {
129
129
  }
130
130
  // Init data provider
131
131
  var provider = props.useRedux ? form_1.providers.redux : form_1.providers.reducer;
132
- var _b = provider.useForm(props.formId, initialValues), values = _b.values, submitCounter = _b.submitCounter, isInvalid = _b.isInvalid, isSubmitting = _b.isSubmitting, setErrors = _b.setErrors, reducer = _b.reducer, dispatch = _b.dispatch;
132
+ var _b = provider.useForm(props.formId, initialValues), values = _b.values, submitCounter = _b.submitCounter, isInvalid = _b.isInvalid, isSubmitting = _b.isSubmitting, errors = _b.errors, setErrors = _b.setErrors, reducer = _b.reducer, dispatch = _b.dispatch;
133
133
  // Sync with address bar
134
134
  (0, react_use_1.useUpdateEffect)(function () {
135
135
  updateQuery(values);
@@ -147,6 +147,9 @@ function Form(props) {
147
147
  dispatch((0, form_2.formDestroy)(props.formId));
148
148
  }
149
149
  });
150
+ // Clear Errors
151
+ var prevValues = (0, react_use_1.usePrevious)(values);
152
+ (0, react_use_1.useUpdateEffect)(function () { return (0, form_1.clearErrors)(values, prevValues, errors, setErrors); }, [errors, prevValues, setErrors, values]);
150
153
  // OnChange handler
151
154
  (0, react_use_1.useUpdateEffect)(function () {
152
155
  if (props.onChange) {
@@ -6,7 +6,15 @@ import { IButtonProps } from '../Button/Button';
6
6
  export interface ICropConfig {
7
7
  /**
8
8
  * Изначальные параметры обрезки изображения
9
- * @example {unit: 'px', aspect: 1, x: 0, y: 0, width: 200, height: 200}
9
+ * @example
10
+ * {
11
+ * unit: 'px',
12
+ * aspect: 1,
13
+ * x: 0,
14
+ * y: 0,
15
+ * width: 200,
16
+ * height: 200
17
+ * }
10
18
  */
11
19
  initialValues?: Crop;
12
20
  /**
@@ -15,7 +15,7 @@ export type IElementInputType = 'button' | 'checkbox' | 'color' | 'date' | 'date
15
15
  export interface IBaseFieldProps extends IFieldWrapperInputProps, IUiComponent {
16
16
  /**
17
17
  * Свойства для элемента input
18
- * @example {onKeyDown: ...}
18
+ * @example { onKeyDown: ... }
19
19
  */
20
20
  inputProps?: InputHTMLAttributes<HTMLInputElement>;
21
21
  /**
@@ -25,7 +25,10 @@ export interface IBaseFieldProps extends IFieldWrapperInputProps, IUiComponent {
25
25
  showClear?: boolean;
26
26
  /**
27
27
  * Свойства для компонента отображения
28
- * @example {customHandler: () => {...}}
28
+ * @example
29
+ * {
30
+ * customHandler: () => {...}
31
+ * }
29
32
  */
30
33
  viewProps?: {
31
34
  [key: string]: any;
@@ -10,12 +10,35 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
13
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
38
  };
16
39
  exports.__esModule = true;
17
40
  /* eslint-disable max-len */
18
- var react_1 = require("react");
41
+ var react_1 = __importStar(require("react"));
19
42
  var hooks_1 = require("../../../hooks");
20
43
  var fieldWrapper_1 = __importDefault(require("../Field/fieldWrapper"));
21
44
  var useInputTypeNumber_1 = __importDefault(require("./hooks/useInputTypeNumber"));
@@ -23,6 +46,7 @@ var DEFAULT_STEP = 1;
23
46
  function NumberField(props) {
24
47
  var components = (0, hooks_1.useComponents)();
25
48
  var _a = (0, hooks_1.useSaveCursorPosition)(props.input), currentInputRef = _a.inputRef, onChange = _a.onChange;
49
+ var step = react_1["default"].useMemo(function () { var _a; return (_a = props.step) !== null && _a !== void 0 ? _a : DEFAULT_STEP; }, [props.step]);
26
50
  var onInputChange = (0, useInputTypeNumber_1["default"])(currentInputRef, {
27
51
  max: props.max,
28
52
  min: props.min,
@@ -30,15 +54,18 @@ function NumberField(props) {
30
54
  }, onChange).onInputChange;
31
55
  var onStep = (0, react_1.useCallback)(function (isIncrement) {
32
56
  var _a;
33
- var step = props.step || DEFAULT_STEP;
34
57
  onChange(null, String(Number((_a = currentInputRef === null || currentInputRef === void 0 ? void 0 : currentInputRef.current) === null || _a === void 0 ? void 0 : _a.value) + (isIncrement ? step : -step)));
35
- }, [currentInputRef, onChange, props.step]);
58
+ }, [currentInputRef, onChange, step]);
36
59
  var onStepUp = (0, react_1.useCallback)(function () {
37
- onStep(true);
38
- }, [onStep]);
60
+ if (!(Number(currentInputRef.current.value) + step > props.max)) {
61
+ onStep(true);
62
+ }
63
+ }, [currentInputRef, onStep, props.max, step]);
39
64
  var onStepDown = (0, react_1.useCallback)(function () {
40
- onStep(false);
41
- }, [onStep]);
65
+ if (!(Number(currentInputRef.current.value) - step < props.min)) {
66
+ onStep(false);
67
+ }
68
+ }, [currentInputRef, onStep, props.min, step]);
42
69
  var onKeyDown = (0, react_1.useCallback)(function (event) {
43
70
  if (event.key === 'ArrowUp') {
44
71
  onStepUp();