@steroidsjs/core 3.0.14 → 3.0.16

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 (40) hide show
  1. package/docs-autogen-result.json +464 -38
  2. package/en.json +7 -0
  3. package/hooks/useTree.d.ts +3 -2
  4. package/hooks/useTree.js +20 -1
  5. package/package.json +4 -4
  6. package/ui/content/CalendarSystem/CalendarSystem.d.ts +46 -15
  7. package/ui/content/CalendarSystem/CalendarSystem.js +32 -68
  8. package/ui/content/CalendarSystem/enums/CalendarType.d.ts +1 -0
  9. package/ui/content/CalendarSystem/enums/CalendarType.js +2 -0
  10. package/ui/content/CalendarSystem/enums/DisplayDateFormatType.d.ts +6 -0
  11. package/ui/content/CalendarSystem/enums/DisplayDateFormatType.js +38 -0
  12. package/ui/content/CalendarSystem/hooks/useCalendarControls.d.ts +4 -4
  13. package/ui/content/CalendarSystem/hooks/useCalendarControls.js +125 -21
  14. package/ui/content/CalendarSystem/hooks/useCalendarSystem.d.ts +29 -0
  15. package/ui/content/CalendarSystem/hooks/useCalendarSystem.js +96 -0
  16. package/ui/content/CalendarSystem/hooks/useCalendarSystemModals.d.ts +2 -2
  17. package/ui/content/CalendarSystem/hooks/useCalendarSystemModals.js +29 -10
  18. package/ui/content/CalendarSystem/hooks/useCustomViews.d.ts +24 -0
  19. package/ui/content/CalendarSystem/hooks/useCustomViews.js +45 -0
  20. package/ui/content/CalendarSystem/hooks/useDayGrid.d.ts +5 -0
  21. package/ui/content/CalendarSystem/hooks/useDayGrid.js +9 -0
  22. package/ui/content/CalendarSystem/hooks/useDisplayDate.d.ts +4 -3
  23. package/ui/content/CalendarSystem/hooks/useDisplayDate.js +10 -14
  24. package/ui/content/CalendarSystem/hooks/useEventsFromDate.js +9 -1
  25. package/ui/content/CalendarSystem/hooks/useMonthGrid.d.ts +1 -10
  26. package/ui/content/CalendarSystem/hooks/useMonthGrid.js +28 -44
  27. package/ui/content/CalendarSystem/hooks/useWeekGrid.d.ts +3 -7
  28. package/ui/content/CalendarSystem/hooks/useWeekGrid.js +8 -65
  29. package/ui/content/CalendarSystem/utils/utils.d.ts +7 -0
  30. package/ui/content/CalendarSystem/utils/utils.js +57 -3
  31. package/ui/content/Icon/Icon.d.ts +4 -0
  32. package/ui/content/Icon/Icon.js +3 -2
  33. package/ui/form/DateField/useDateInputState.js +1 -1
  34. package/ui/form/DateTimeField/DateTimeField.js +2 -1
  35. package/ui/form/PasswordField/PasswordField.js +14 -7
  36. package/ui/form/RadioListField/RadioListField.js +1 -1
  37. package/ui/form/SliderField/SliderField.d.ts +8 -0
  38. package/ui/form/SliderField/SliderField.js +17 -7
  39. package/ui/nav/Tree/Tree.d.ts +7 -0
  40. package/ui/nav/Tree/Tree.js +14 -10
@@ -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
  }
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { IPreparedTreeItem, ITreeConfig, ITreeItem } from '../../../hooks/useTree';
3
3
  export interface ITreeViewProps extends ITreeProps {
4
4
  items: IPreparedTreeItem[];
5
+ onItemFocus?: () => void;
5
6
  }
6
7
  export interface ITreeItemViewProps extends ITreeProps {
7
8
  item: IPreparedTreeItem;
@@ -11,6 +12,12 @@ export interface ITreeItemViewProps extends ITreeProps {
11
12
  /**
12
13
  * Tree
13
14
  * Компонент, который представляет в виде дерева список с иерархической структурой данных
15
+ *
16
+ * Дополнительный функционал: в кастомном view компонента есть возможность реализовать кнопку, по клику на которую
17
+ * будет вызываться функция props.onItemFocus. Данная функция "находит" текущий роут в дереве -
18
+ * раскрывает родительские уровни, делает элемент активным.
19
+ * Данная функция не включает скролл к активному компоненту внутри дерева, это также необходимо
20
+ * реализовать в кастомном view локально в проекте.
14
21
  */
15
22
  export interface ITreeProps extends Omit<ITreeConfig, 'currentPage' | 'itemsOnPage'> {
16
23
  /**
@@ -1,10 +1,21 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  exports.__esModule = true;
3
14
  var react_1 = require("react");
4
15
  var hooks_1 = require("../../../hooks");
5
16
  function Tree(props) {
6
17
  var components = (0, hooks_1.useComponents)();
7
- var treeItems = (0, hooks_1.useTree)({
18
+ var _a = (0, hooks_1.useTree)({
8
19
  items: props.items,
9
20
  selectedItemId: props.selectedItemId,
10
21
  routerParams: props.routerParams,
@@ -17,15 +28,8 @@ function Tree(props) {
17
28
  collapseChildItems: props.collapseChildItems,
18
29
  saveInClientStorage: props.autoSave,
19
30
  clientStorageId: props.id
20
- }).treeItems;
21
- var viewProps = (0, react_1.useMemo)(function () { return ({
22
- items: treeItems,
23
- levelPadding: props.levelPadding,
24
- className: props.className,
25
- hideIcon: props.hideIcon,
26
- customIcon: props.customIcon,
27
- hasIconExpandOnly: props.hasIconExpandOnly
28
- }); }, [props.className, props.customIcon, props.hasIconExpandOnly, props.hideIcon, props.levelPadding, treeItems]);
31
+ }), treeItems = _a.treeItems, onItemFocus = _a.onItemFocus;
32
+ var viewProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props), { onItemFocus: onItemFocus, items: treeItems, levelPadding: props.levelPadding, className: props.className, hideIcon: props.hideIcon, customIcon: props.customIcon, hasIconExpandOnly: props.hasIconExpandOnly })); }, [props, treeItems, onItemFocus]);
29
33
  return components.ui.renderView(props.view || 'nav.TreeView', viewProps);
30
34
  }
31
35
  exports["default"] = Tree;