@steroidsjs/core 3.0.15 → 3.0.17

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 (43) hide show
  1. package/docs-autogen-result.json +515 -37
  2. package/en.json +7 -0
  3. package/hooks/useList.d.ts +1 -0
  4. package/hooks/useList.js +9 -3
  5. package/package.json +4 -4
  6. package/ui/content/Calendar/Calendar.d.ts +5 -0
  7. package/ui/content/Calendar/Calendar.js +5 -1
  8. package/ui/content/CalendarSystem/CalendarSystem.d.ts +52 -16
  9. package/ui/content/CalendarSystem/CalendarSystem.js +33 -68
  10. package/ui/content/CalendarSystem/enums/CalendarType.d.ts +1 -0
  11. package/ui/content/CalendarSystem/enums/CalendarType.js +2 -0
  12. package/ui/content/CalendarSystem/enums/DisplayDateFormatType.d.ts +6 -0
  13. package/ui/content/CalendarSystem/enums/DisplayDateFormatType.js +38 -0
  14. package/ui/content/CalendarSystem/hooks/useCalendarControls.d.ts +4 -4
  15. package/ui/content/CalendarSystem/hooks/useCalendarControls.js +125 -21
  16. package/ui/content/CalendarSystem/hooks/useCalendarSystem.d.ts +29 -0
  17. package/ui/content/CalendarSystem/hooks/useCalendarSystem.js +96 -0
  18. package/ui/content/CalendarSystem/hooks/useCalendarSystemModals.d.ts +2 -2
  19. package/ui/content/CalendarSystem/hooks/useCalendarSystemModals.js +29 -10
  20. package/ui/content/CalendarSystem/hooks/useCustomViews.d.ts +24 -0
  21. package/ui/content/CalendarSystem/hooks/useCustomViews.js +45 -0
  22. package/ui/content/CalendarSystem/hooks/useDayGrid.d.ts +5 -0
  23. package/ui/content/CalendarSystem/hooks/useDayGrid.js +9 -0
  24. package/ui/content/CalendarSystem/hooks/useDisplayDate.d.ts +4 -3
  25. package/ui/content/CalendarSystem/hooks/useDisplayDate.js +10 -14
  26. package/ui/content/CalendarSystem/hooks/useEventsFromDate.js +9 -1
  27. package/ui/content/CalendarSystem/hooks/useMonthGrid.d.ts +1 -10
  28. package/ui/content/CalendarSystem/hooks/useMonthGrid.js +28 -44
  29. package/ui/content/CalendarSystem/hooks/useWeekGrid.d.ts +3 -7
  30. package/ui/content/CalendarSystem/hooks/useWeekGrid.js +8 -65
  31. package/ui/content/CalendarSystem/utils/utils.d.ts +7 -0
  32. package/ui/content/CalendarSystem/utils/utils.js +57 -3
  33. package/ui/content/Icon/Icon.d.ts +4 -0
  34. package/ui/content/Icon/Icon.js +3 -2
  35. package/ui/form/DateField/useDateInputState.js +1 -1
  36. package/ui/form/DateTimeField/DateTimeField.js +2 -1
  37. package/ui/form/PasswordField/PasswordField.js +14 -7
  38. package/ui/form/RadioListField/RadioListField.js +1 -1
  39. package/ui/form/SliderField/SliderField.d.ts +8 -0
  40. package/ui/form/SliderField/SliderField.js +17 -7
  41. package/ui/list/Grid/Grid.d.ts +1 -0
  42. package/ui/list/Grid/Grid.js +3 -2
  43. package/ui/list/List/List.js +3 -2
@@ -1,9 +1,11 @@
1
+ import { CSSProperties } from 'react';
1
2
  import { IDay, IEvent, IEventGroup } from '../CalendarSystem';
2
3
  export declare const getWeekDaysFromDate: (date: Date) => IDay[];
3
4
  export declare const isDateIsToday: (date: Date) => boolean;
4
5
  export declare const getOmittedEvent: (event: IEvent | Omit<IEvent, 'color'>) => any;
5
6
  export declare const sortEventsInGroup: (group: IEventGroup) => Omit<IEvent, "color">[];
6
7
  export declare const getSourceCalendarControl: (control: string) => HTMLElement;
8
+ export declare const getFormattedDay: (date?: Date) => IDay;
7
9
  export declare const getFormattedWeekFromDate: (fromDate?: Date) => {
8
10
  dayNumber: number;
9
11
  date: Date;
@@ -11,3 +13,8 @@ export declare const getFormattedWeekFromDate: (fromDate?: Date) => {
11
13
  isToday?: boolean;
12
14
  formattedDisplay?: string;
13
15
  }[];
16
+ export declare const getTwentyFourHoursArray: () => string[];
17
+ export declare const getWeekDays: () => any;
18
+ export declare const getProportionFromEvent: (event: IEvent) => number;
19
+ export declare const getTopMarginFromEvent: (event: IEvent) => CSSProperties;
20
+ export declare const formatEventTime: (date: Date) => any;
@@ -14,10 +14,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  exports.__esModule = true;
17
- exports.getFormattedWeekFromDate = exports.getSourceCalendarControl = exports.sortEventsInGroup = exports.getOmittedEvent = exports.isDateIsToday = exports.getWeekDaysFromDate = void 0;
17
+ exports.formatEventTime = exports.getTopMarginFromEvent = exports.getProportionFromEvent = exports.getWeekDays = exports.getTwentyFourHoursArray = exports.getFormattedWeekFromDate = exports.getFormattedDay = exports.getSourceCalendarControl = exports.sortEventsInGroup = exports.getOmittedEvent = exports.isDateIsToday = exports.getWeekDaysFromDate = void 0;
18
18
  /* eslint-disable no-plusplus */
19
19
  var dayjs_1 = __importDefault(require("dayjs"));
20
20
  var omit_1 = __importDefault(require("lodash-es/omit"));
21
+ var concat_1 = __importDefault(require("lodash-es/concat"));
22
+ var slice_1 = __importDefault(require("lodash-es/slice"));
23
+ var upperFirst_1 = __importDefault(require("lodash-es/upperFirst"));
24
+ var ceil_1 = __importDefault(require("lodash-es/ceil"));
21
25
  var calendar_1 = require("../../../../utils/calendar");
22
26
  var SIX_DAYS_DIFF = 6;
23
27
  var MAX_DAYS_DIFF_IN_WEEK = 7;
@@ -43,10 +47,27 @@ var isDateIsToday = function (date) { return (0, dayjs_1["default"])(date).isTod
43
47
  exports.isDateIsToday = isDateIsToday;
44
48
  var getOmittedEvent = function (event) { return (0, omit_1["default"])(event, ['color', 'eventGroupId']); };
45
49
  exports.getOmittedEvent = getOmittedEvent;
46
- var sortEventsInGroup = function (group) { return group.events.sort(function (eventA, eventB) { return eventA.date.getTime() - eventB.date.getTime(); }); };
50
+ var sortEventsInGroup = function (group) { return group.events
51
+ .sort(function (eventA, eventB) {
52
+ var durationAInMinutest = (0, dayjs_1["default"])(eventA.startDate).diff((0, dayjs_1["default"])(eventA.endDate), 'minutes');
53
+ var durationBInMinutest = (0, dayjs_1["default"])(eventB.startDate).diff((0, dayjs_1["default"])(eventB.endDate), 'minutes');
54
+ return durationBInMinutest - durationAInMinutest;
55
+ }); };
47
56
  exports.sortEventsInGroup = sortEventsInGroup;
48
- var getSourceCalendarControl = function (control) { return document.querySelector("[data-sourcecontrol=\"".concat(control, "\"]")); };
57
+ var getSourceCalendarControl = function (control) { return document.querySelector("[data-icon=\"control-".concat(control, "\"]")); };
49
58
  exports.getSourceCalendarControl = getSourceCalendarControl;
59
+ var getFormattedDay = function (date) {
60
+ if (date === void 0) { date = null; }
61
+ var dateToFormat = date || new Date();
62
+ return {
63
+ dayNumber: dateToFormat.getDate(),
64
+ date: new Date(dateToFormat),
65
+ formattedDisplay: (0, calendar_1.convertDate)(dateToFormat, null, WEEK_DAY_FORMAT),
66
+ isToday: (0, exports.isDateIsToday)(dateToFormat)
67
+ };
68
+ };
69
+ exports.getFormattedDay = getFormattedDay;
70
+ //TODO использовать существующие функции а не дублировать функционал
50
71
  var getFormattedWeekFromDate = function (fromDate) {
51
72
  if (fromDate === void 0) { fromDate = null; }
52
73
  var currentWeek = (0, exports.getWeekDaysFromDate)(fromDate || new Date());
@@ -58,3 +79,36 @@ var getFormattedWeekFromDate = function (fromDate) {
58
79
  });
59
80
  };
60
81
  exports.getFormattedWeekFromDate = getFormattedWeekFromDate;
82
+ var getTwentyFourHoursArray = function () {
83
+ var hoursArray = [];
84
+ for (var i = 0; i < 24; i++) {
85
+ var formattedHour = (0, dayjs_1["default"])().startOf('day').add(i, 'hour').format('HH:00');
86
+ hoursArray.push(formattedHour);
87
+ }
88
+ return hoursArray;
89
+ };
90
+ exports.getTwentyFourHoursArray = getTwentyFourHoursArray;
91
+ var getWeekDays = function () {
92
+ var unformattedDaysOfWeek = dayjs_1["default"].weekdaysMin();
93
+ return (0, concat_1["default"])((0, slice_1["default"])(unformattedDaysOfWeek, 1), unformattedDaysOfWeek[0]).map(function (weekDay) { return __("".concat((0, upperFirst_1["default"])(weekDay))); });
94
+ };
95
+ exports.getWeekDays = getWeekDays;
96
+ var getProportionFromEvent = function (event) {
97
+ var startDate = (0, dayjs_1["default"])(event.startDate);
98
+ var endDate = (0, dayjs_1["default"])(event.endDate);
99
+ var durationInMinutest = endDate.diff(startDate, 'minutes');
100
+ return 100 * (0, ceil_1["default"])(durationInMinutest / 60, 1);
101
+ };
102
+ exports.getProportionFromEvent = getProportionFromEvent;
103
+ var getTopMarginFromEvent = function (event) {
104
+ var startDate = (0, dayjs_1["default"])(event.startDate);
105
+ var startDateHour = startDate.set('minutes', 0);
106
+ var durationInMinutest = startDate.diff(startDateHour, 'minutes');
107
+ var topMargin = (0, ceil_1["default"])(durationInMinutest / 60, 1) * 100;
108
+ return {
109
+ top: "".concat(topMargin, "%")
110
+ };
111
+ };
112
+ exports.getTopMarginFromEvent = getTopMarginFromEvent;
113
+ var formatEventTime = function (date) { return (0, calendar_1.convertDate)(date, null, 'HH:mm'); };
114
+ exports.formatEventTime = formatEventTime;
@@ -41,6 +41,10 @@ export interface IIconProps extends Omit<IUiComponent, 'className' | 'style'>, P
41
41
  * Функция которая вызывается при клике по иконке
42
42
  */
43
43
  onClick?: any;
44
+ /**
45
+ * Дополнительные данные которые попадут в дата аттрибут data-icon
46
+ */
47
+ dataIcon?: any;
44
48
  [key: string]: any;
45
49
  }
46
50
  export interface IIconViewProps extends IIconProps {
@@ -41,8 +41,9 @@ function Icon(props) {
41
41
  title: props.title,
42
42
  className: props.className,
43
43
  style: props.style,
44
- icon: icon
45
- }); }, [props.onClick, props.tabIndex, props.title, props.className, props.style, icon]);
44
+ icon: icon,
45
+ dataIcon: props.dataIcon
46
+ }); }, [props.onClick, props.tabIndex, props.title, props.className, props.style, props.dataIcon, icon]);
46
47
  if (!(0, isString_1["default"])(name)) {
47
48
  return null;
48
49
  }
@@ -42,7 +42,7 @@ function useDateInputState(props) {
42
42
  }, [propsDisplayValue]);
43
43
  // Display input change handler
44
44
  var onDisplayValueChange = (0, react_1.useCallback)(function (value) {
45
- value = value.replace(/[^0-9:. ]/g, '');
45
+ value = value.replace(/[^0-9:., ]/g, '');
46
46
  setDisplayValue(value);
47
47
  var newValue = value;
48
48
  if (value !== null) {
@@ -91,7 +91,8 @@ DateTimeField.defaultProps = {
91
91
  maskOptions: (0, kit_1.maskitoDateTimeOptionsGenerator)({
92
92
  dateMode: 'dd/mm/yyyy',
93
93
  timeMode: 'HH:MM',
94
- dateSeparator: '.'
94
+ dateSeparator: '.',
95
+ dateTimeSeparator: DATE_TIME_SEPARATOR
95
96
  })
96
97
  };
97
98
  exports["default"] = (0, fieldWrapper_1["default"])('DateTimeField', DateTimeField);
@@ -62,21 +62,28 @@ function PasswordField(props) {
62
62
  }, [type]);
63
63
  var inputProps = (0, react_1.useMemo)(function () {
64
64
  var _a;
65
- return (__assign({ name: props.input.name, defaultValue: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', placeholder: props.placeholder, disabled: props.disabled, ref: inputRef, onChange: onChange, type: type }, props.inputProps));
66
- }, [inputRef, onChange, props.disabled, props.input.name, props.input.value, props.inputProps, props.placeholder, type]);
65
+ return (__assign({ name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', placeholder: props.placeholder, ref: inputRef, onChange: onChange, type: type }, props.inputProps));
66
+ }, [inputRef, onChange, props.input.name, props.input.value, props.inputProps, props.placeholder, type]);
67
67
  var viewProps = (0, react_1.useMemo)(function () { return ({
68
- viewProps: props.viewProps,
68
+ inputRef: inputRef,
69
69
  inputProps: inputProps,
70
- securityLevel: props.showSecurityBar ? (0, exports.checkPassword)(props.input.value) : null,
71
70
  onClear: onClear,
72
71
  onShowButtonClick: onShowButtonClick,
72
+ securityLevel: props.showSecurityBar ? (0, exports.checkPassword)(props.input.value) : null,
73
73
  size: props.size,
74
74
  input: props.input,
75
75
  className: props.className,
76
76
  showSecurityIcon: props.showSecurityIcon,
77
- showSecurityBar: props.showSecurityBar
78
- }); }, [inputProps, onClear, onShowButtonClick, props.className, props.input, props.showSecurityBar, props.showSecurityIcon,
79
- props.size, props.viewProps]);
77
+ showSecurityBar: props.showSecurityBar,
78
+ errors: props.errors,
79
+ style: props.style,
80
+ placeholder: props.placeholder,
81
+ required: props.required,
82
+ id: props.id,
83
+ viewProps: props.viewProps,
84
+ disabled: props.disabled
85
+ }); }, [inputProps, inputRef, onClear, onShowButtonClick, props.className, props.disabled, props.errors, props.id,
86
+ props.input, props.placeholder, props.required, props.showSecurityBar, props.showSecurityIcon, props.size, props.style, props.viewProps]);
80
87
  return components.ui.renderView(props.view || 'form.PasswordFieldView' || 'form.InputFieldView', viewProps);
81
88
  }
82
89
  PasswordField.defaultProps = {
@@ -92,7 +92,7 @@ RadioListField.defaultProps = {
92
92
  disabled: false,
93
93
  required: false,
94
94
  className: '',
95
- multiple: true,
95
+ multiple: false,
96
96
  errors: null,
97
97
  orientation: 'vertical'
98
98
  };
@@ -56,6 +56,14 @@ export interface ISliderFieldProps extends IFieldWrapperInputProps, IUiComponent
56
56
  };
57
57
  label: any;
58
58
  } | React.ReactNode | string>;
59
+ /**
60
+ * Функция, вызываемая в момент перетаскивания tip'а у слайдера
61
+ * @example
62
+ * {
63
+ * () => console.log('Slider is moving')
64
+ * }
65
+ */
66
+ onChange?: (value: any) => void;
59
67
  /**
60
68
  * Функция, вызываемая после отпускания tip'а у слайдера (при событии onmouseup)
61
69
  * @see https://github.com/schrodinger/rc-slider
@@ -21,6 +21,19 @@ var fieldWrapper_1 = __importDefault(require("../Field/fieldWrapper"));
21
21
  var normalizeValue = function (value) { return (0, toInteger_1["default"])(String(value).replace(/[0-9]g/, '')) || 0; };
22
22
  function SliderField(props) {
23
23
  var components = (0, hooks_1.useComponents)();
24
+ var onChange = (0, react_1.useCallback)(function (value) {
25
+ if (props.onChange) {
26
+ props.onChange(value);
27
+ }
28
+ props.input.onChange(value);
29
+ }, [props]);
30
+ var onAfterChange = (0, react_1.useCallback)(function (value) {
31
+ var normalizedValue = normalizeValue(value);
32
+ if (props.onAfterChange) {
33
+ props.onAfterChange(normalizedValue);
34
+ }
35
+ props.input.onChange(normalizedValue);
36
+ }, [props]);
24
37
  var sliderProps = (0, react_1.useMemo)(function () { return ({
25
38
  min: props.min,
26
39
  max: props.max,
@@ -33,13 +46,10 @@ function SliderField(props) {
33
46
  valuePostfix: props.valuePostfix,
34
47
  defaultValue: props.defaultValue,
35
48
  tooltipIsVisible: props.tooltipIsVisible,
36
- onChange: function (range) { return props.input.onChange.call(null, range); },
37
- onAfterChange: function (value) {
38
- value = normalizeValue(value);
39
- props.input.onChange.call(null, value);
40
- }
41
- }); }, [props.min, props.max, props.step, props.marks, props.isRange, props.disabled, props.isVertical, props.input.value,
42
- props.input.onChange, props.valuePostfix, props.defaultValue, props.tooltipIsVisible]);
49
+ onChange: onChange,
50
+ onAfterChange: onAfterChange
51
+ }); }, [onAfterChange, onChange, props.defaultValue, props.disabled, props.input.value, props.isRange,
52
+ props.isVertical, props.marks, props.max, props.min, props.step, props.tooltipIsVisible, props.valuePostfix]);
43
53
  var viewProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, sliderProps), { slider: props.slider, className: props.className, rangeDefaultValue: props.rangeDefaultValue, sliderDefaultValue: props.sliderDefaultValue, style: props.style })); }, [props.className, props.rangeDefaultValue, props.slider, props.sliderDefaultValue, props.style, sliderProps]);
44
54
  return components.ui.renderView(props.view || 'form.SliderFieldView', viewProps);
45
55
  }
@@ -192,6 +192,7 @@ export interface IGridViewProps extends Omit<IGridProps, 'onFetch'> {
192
192
  layoutNamesPosition: ListControlPosition;
193
193
  renderList: (children: any) => any;
194
194
  renderEmpty: () => any;
195
+ renderLoading: () => any;
195
196
  renderPagination: () => any;
196
197
  renderPaginationSize: () => any;
197
198
  renderLayoutNames: () => any;
@@ -69,7 +69,7 @@ function Grid(props) {
69
69
  initialItems: props.initialItems,
70
70
  initialTotal: props.initialTotal,
71
71
  autoFetchOnFormChanges: props.autoFetchOnFormChanges
72
- }), list = _a.list, model = _a.model, searchModel = _a.searchModel, paginationPosition = _a.paginationPosition, paginationSizePosition = _a.paginationSizePosition, layoutNamesPosition = _a.layoutNamesPosition, renderList = _a.renderList, renderEmpty = _a.renderEmpty, renderPagination = _a.renderPagination, renderPaginationSize = _a.renderPaginationSize, renderLayoutNames = _a.renderLayoutNames, renderSearchForm = _a.renderSearchForm, onFetch = _a.onFetch, onSort = _a.onSort;
72
+ }), list = _a.list, model = _a.model, searchModel = _a.searchModel, paginationPosition = _a.paginationPosition, paginationSizePosition = _a.paginationSizePosition, layoutNamesPosition = _a.layoutNamesPosition, renderList = _a.renderList, renderLoading = _a.renderLoading, renderEmpty = _a.renderEmpty, renderPagination = _a.renderPagination, renderPaginationSize = _a.renderPaginationSize, renderLayoutNames = _a.renderLayoutNames, renderSearchForm = _a.renderSearchForm, onFetch = _a.onFetch, onSort = _a.onSort;
73
73
  var renderLabel = (0, react_1.useCallback)(function (column) {
74
74
  if (column.headerView) {
75
75
  var HeaderView = column.headerView;
@@ -124,6 +124,7 @@ function Grid(props) {
124
124
  paginationSizePosition: paginationSizePosition,
125
125
  layoutNamesPosition: layoutNamesPosition,
126
126
  renderList: renderList,
127
+ renderLoading: renderLoading,
127
128
  renderEmpty: renderEmpty,
128
129
  renderPagination: renderPagination,
129
130
  renderPaginationSize: renderPaginationSize,
@@ -143,7 +144,7 @@ function Grid(props) {
143
144
  primaryKey: props.primaryKey
144
145
  }); }, [columns, layoutNamesPosition, list, onFetch, onSort, paginationPosition, paginationSizePosition, props.className,
145
146
  props.hasAlternatingColors, props.isLoading, props.listId, props.primaryKey, props.searchForm, props.size, renderEmpty,
146
- renderLayoutNames, renderList, renderPagination, renderPaginationSize, renderSearchForm, renderValue]);
147
+ renderLayoutNames, renderList, renderPagination, renderPaginationSize, renderSearchForm, renderValue, renderLoading]);
147
148
  return components.ui.renderView(props.view || 'list.GridView', viewProps);
148
149
  }
149
150
  exports["default"] = Grid;
@@ -67,7 +67,7 @@ function List(props) {
67
67
  initialItems: props.initialItems,
68
68
  initialTotal: props.initialTotal,
69
69
  autoFetchOnFormChanges: props.autoFetchOnFormChanges
70
- }), list = _a.list, paginationPosition = _a.paginationPosition, paginationSizePosition = _a.paginationSizePosition, layoutNamesPosition = _a.layoutNamesPosition, renderList = _a.renderList, renderEmpty = _a.renderEmpty, renderPagination = _a.renderPagination, renderPaginationSize = _a.renderPaginationSize, renderLayoutNames = _a.renderLayoutNames, renderSearchForm = _a.renderSearchForm;
70
+ }), list = _a.list, paginationPosition = _a.paginationPosition, paginationSizePosition = _a.paginationSizePosition, layoutNamesPosition = _a.layoutNamesPosition, renderList = _a.renderList, renderLoading = _a.renderLoading, renderEmpty = _a.renderEmpty, renderPagination = _a.renderPagination, renderPaginationSize = _a.renderPaginationSize, renderLayoutNames = _a.renderLayoutNames, renderSearchForm = _a.renderSearchForm;
71
71
  var ItemView = props.itemView || components.ui.getView('list.ListItemView');
72
72
  var content = ((list === null || list === void 0 ? void 0 : list.items) || []).map(function (item, index) { return (React.createElement(ItemView, __assign({}, props.itemProps, { key: item[props.primaryKey] || index, primaryKey: props.primaryKey, item: item, index: index, layoutSelected: list.layoutName }))); });
73
73
  var viewProps = (0, react_1.useMemo)(function () { return ({
@@ -76,6 +76,7 @@ function List(props) {
76
76
  paginationSizePosition: paginationSizePosition,
77
77
  layoutNamesPosition: layoutNamesPosition,
78
78
  renderList: renderList,
79
+ renderLoading: renderLoading,
79
80
  renderEmpty: renderEmpty,
80
81
  renderPagination: renderPagination,
81
82
  renderPaginationSize: renderPaginationSize,
@@ -86,7 +87,7 @@ function List(props) {
86
87
  className: props.className,
87
88
  contentClassName: props.contentClassName
88
89
  }); }, [content, layoutNamesPosition, list, paginationPosition, paginationSizePosition, props.className, props.contentClassName,
89
- props.isLoading, renderEmpty, renderLayoutNames, renderList, renderPagination, renderPaginationSize, renderSearchForm]);
90
+ props.isLoading, renderEmpty, renderLayoutNames, renderList, renderPagination, renderPaginationSize, renderSearchForm, renderLoading]);
90
91
  return components.ui.renderView(props.view || 'list.ListView', viewProps);
91
92
  }
92
93
  exports["default"] = List;