@steroidsjs/bootstrap 3.0.30 → 3.0.32

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 (35) hide show
  1. package/content/Accordion/AccordionItemView.js +0 -1
  2. package/content/Accordion/AccordionItemView.scss +56 -7
  3. package/content/Accordion/AccordionView.scss +2 -0
  4. package/content/Calendar/CalendarView.js +8 -3
  5. package/content/Calendar/CalendarView.scss +2 -2
  6. package/form/DateRangeField/DateRangeFieldView.js +10 -1
  7. package/form/DateRangeField/DateRangeFieldView.scss +54 -0
  8. package/form/DateRangeField/views/RangeButtons/RangeButtons.d.ts +11 -0
  9. package/form/DateRangeField/views/RangeButtons/RangeButtons.js +60 -0
  10. package/form/DateRangeField/views/RangeButtons/RangeButtons.scss +126 -0
  11. package/form/DateRangeField/views/RangeButtons/consts.d.ts +34 -0
  12. package/form/DateRangeField/views/RangeButtons/consts.js +71 -0
  13. package/form/DateRangeField/views/RangeButtons/index.d.ts +2 -0
  14. package/form/DateRangeField/views/RangeButtons/index.js +7 -0
  15. package/form/DateRangeField/views/RangeButtons/utils.d.ts +14 -0
  16. package/form/DateRangeField/views/RangeButtons/utils.js +36 -0
  17. package/form/DateTimeRangeField/DateTimeRangeFieldView.js +12 -3
  18. package/form/DateTimeRangeField/DateTimeRangeFieldView.scss +54 -0
  19. package/form/DropDownField/DropDownFieldView.js +3 -2
  20. package/form/DropDownField/DropDownFieldView.scss +12 -0
  21. package/form/InputField/InputFieldView.js +4 -4
  22. package/form/InputField/InputFieldView.scss +128 -174
  23. package/hooks/index.d.ts +2 -0
  24. package/hooks/index.js +8 -0
  25. package/hooks/useHideScroll.d.ts +1 -0
  26. package/hooks/useHideScroll.js +37 -0
  27. package/icons/index.js +2 -0
  28. package/icons/svgs/long-arrow-alt-down.svg +3 -0
  29. package/icons/svgs/long-arrow-alt-up.svg +3 -0
  30. package/list/Grid/GridView.js +2 -3
  31. package/list/Grid/GridView.scss +46 -0
  32. package/modal/Modal/ModalView.js +3 -1
  33. package/modal/Modal/ModalView.scss +0 -5
  34. package/package.json +2 -2
  35. package/scss/normalize.scss +5 -0
@@ -30,7 +30,6 @@ var React = __importStar(require("react"));
30
30
  var Icon_1 = __importDefault(require("@steroidsjs/core/ui/content/Icon"));
31
31
  var hooks_1 = require("@steroidsjs/core/hooks");
32
32
  var renderIcon_1 = __importDefault(require("../../utils/renderIcon"));
33
- var ICON_SIZE = '_24x24';
34
33
  function AccordionItemView(props) {
35
34
  var _a;
36
35
  var bem = (0, hooks_1.useBem)('AccordionItemView');
@@ -100,7 +100,6 @@ $accordion-chevron-color: var(--accordion-chevron-color);
100
100
  overflow: hidden;
101
101
 
102
102
  background-color: $accordion-content-background;
103
- height: 56px;
104
103
  width: 100%;
105
104
  height: fit-content;
106
105
 
@@ -123,18 +122,67 @@ $accordion-chevron-color: var(--accordion-chevron-color);
123
122
  }
124
123
  }
125
124
 
125
+ &:first-child {
126
+ .AccordionItemView__header-container {
127
+ border-top-left-radius: variables.$radius-large;
128
+ border-top-right-radius: variables.$radius-large;
129
+ transition: 200ms ease border-radius;
130
+ transition-delay: 200ms;
131
+ }
132
+ }
133
+ &:last-child {
134
+ .AccordionItemView__header-container {
135
+ border-bottom-left-radius: variables.$radius-large;
136
+ border-bottom-right-radius: variables.$radius-large;
137
+ transition: 200ms ease border-radius;
138
+ transition-delay: 200ms;
139
+ }
140
+ .AccordionItemView__content {
141
+ border-bottom-left-radius: variables.$radius-large;
142
+ border-bottom-right-radius: variables.$radius-large;
143
+ }
144
+ }
145
+ &_position_bottom.AccordionItemView_opened.AccordionItemView {
146
+ &:first-child {
147
+ .AccordionItemView__header-container {
148
+ border-top-left-radius: 0;
149
+ border-top-right-radius: 0;
150
+ transition: 0ms ease border-radius;
151
+ }
152
+ .AccordionItemView__content {
153
+ border-top-left-radius: variables.$radius-large;
154
+ border-top-right-radius: variables.$radius-large;
155
+ }
156
+ }
157
+ &:last-child {
158
+ .AccordionItemView__header-container {
159
+ border-bottom-left-radius: variables.$radius-large;
160
+ border-bottom-right-radius: variables.$radius-large;
161
+ transition: 200ms ease border-radius;
162
+ transition-delay: 200ms;
163
+ }
164
+ .AccordionItemView__content {
165
+ border-bottom-left-radius: 0;
166
+ border-bottom-right-radius: 0;
167
+ }
168
+ }
169
+ }
170
+ &_opened.AccordionItemView {
171
+ &:last-child .AccordionItemView__header-container {
172
+ border-bottom-left-radius: 0;
173
+ border-bottom-right-radius: 0;
174
+ transition: 0s ease border-radius;
175
+ }
176
+ }
177
+
126
178
  &_position {
127
179
  &_top {
128
- border-radius: variables.$radius-large variables.$radius-large 0 0;
129
180
  }
130
181
 
131
182
  &_middle {
132
- border-radius: 0px;
133
183
  }
134
184
 
135
185
  &_bottom {
136
- border-radius: 0 0 variables.$radius-large variables.$radius-large;
137
-
138
186
  #{$root}__content {
139
187
  grid-row-start: 1;
140
188
  grid-row-end: 1;
@@ -174,7 +222,7 @@ $accordion-chevron-color: var(--accordion-chevron-color);
174
222
  &__icon-chevron {
175
223
  width: 24px;
176
224
  height: 24px;
177
- box-shadow: 0px 1px 20px rgba(0, 0, 0, 0.1);
225
+ box-shadow: 0 1px 20px rgba(0, 0, 0, 0.1);
178
226
  border-radius: variables.$radius-small;
179
227
 
180
228
  transform: rotate(0deg);
@@ -225,11 +273,12 @@ $accordion-chevron-color: var(--accordion-chevron-color);
225
273
  max-height: 0;
226
274
  padding: 0 16px;
227
275
  color: variables.$text-color;
276
+ background-color: $accordion-content-background;
228
277
 
229
278
  &_visible {
230
279
  max-height: 1024px;
231
280
  padding: 18px 32px 18px 16px;
232
- border: 1px solid $accordion-content-border;
281
+ box-shadow: inset 0 0 0 1px $accordion-content-border;
233
282
  }
234
283
  }
235
284
 
@@ -1,3 +1,5 @@
1
+ @use "../../scss/variables";
2
+
1
3
  :root {
2
4
  --accordion-content-border: rgba(0, 0, 0, 0.1);
3
5
  }
@@ -48,7 +48,7 @@ function CalendarView(props) {
48
48
  var localeComponent = (0, hooks_1.useComponents)().locale;
49
49
  //TODO Исправить тип, связано с yarn tsc в action publish.yml
50
50
  var DayPicker = react_day_picker_1["default"];
51
- var month = props.month, toYear = props.toYear, fromYear = props.fromYear, showFooter = props.showFooter, onDaySelect = props.onDaySelect, selectedDates = props.selectedDates, onMonthSelect = props.onMonthSelect, numberOfMonths = props.numberOfMonths, toggleCaptionPanel = props.toggleCaptionPanel, isCaptionPanelVisible = props.isCaptionPanelVisible;
51
+ var month = props.month, toYear = props.toYear, fromYear = props.fromYear, showFooter = props.showFooter, showTodayButton = props.showTodayButton, onDaySelect = props.onDaySelect, selectedDates = props.selectedDates, onMonthSelect = props.onMonthSelect, numberOfMonths = props.numberOfMonths, toggleCaptionPanel = props.toggleCaptionPanel, isCaptionPanelVisible = props.isCaptionPanelVisible;
52
52
  var isRange = !!selectedDates[0] && !!selectedDates[1];
53
53
  var _a = (0, react_1.useMemo)(function () {
54
54
  var from = selectedDates[0];
@@ -71,13 +71,18 @@ function CalendarView(props) {
71
71
  : undefined
72
72
  };
73
73
  }, [isRange, selectedDates]), selectedDays = _a.selectedDays, modifiers = _a.modifiers;
74
- return (React.createElement(DayPicker, __assign({}, props, { className: bem(bem.block({ ranged: isRange }), props.className), captionElement: (0, react_1.useCallback)(function (_a) {
74
+ var shouldShowFooter = (0, react_1.useMemo)(function () { return (
75
+ // Показывать кнопку "закрыть", если открыто меню с выбором месяца, независимо от showTodayButton
76
+ (showFooter && isCaptionPanelVisible)
77
+ // Показывать кнопку "Сегодня"
78
+ || (showFooter && showTodayButton)); }, [isCaptionPanelVisible, showFooter, showTodayButton]);
79
+ return (React.createElement(DayPicker, __assign({}, props, props.pickerProps, { className: bem(bem.block({ ranged: isRange }), props.className), captionElement: (0, react_1.useCallback)(function (_a) {
75
80
  var classNames = _a.classNames, date = _a.date, localeUtils = _a.localeUtils, locale = _a.locale;
76
81
  return (React.createElement(CaptionElement_1["default"], { date: date, locale: locale, toYear: toYear, fromYear: fromYear, classNames: classNames, onChange: onMonthSelect, localeUtils: localeUtils, showCalendarFooter: showFooter, toggleCaptionPanel: toggleCaptionPanel, isCaptionPanelVisible: isCaptionPanelVisible }));
77
82
  }, [fromYear, isCaptionPanelVisible, onMonthSelect, showFooter, toYear, toggleCaptionPanel]), renderDay: function (day) {
78
83
  var date = day.getDate();
79
84
  return (React.createElement("div", { className: bem.element('day') }, date));
80
- }, todayButton: showFooter && (isCaptionPanelVisible ? __('Закрыть') : __('Сегодня')), onTodayButtonClick: function (day) {
85
+ }, todayButton: shouldShowFooter && (isCaptionPanelVisible ? __('Закрыть') : __('Сегодня')), onTodayButtonClick: function (day) {
81
86
  if (isCaptionPanelVisible) {
82
87
  toggleCaptionPanel();
83
88
  }
@@ -183,7 +183,7 @@ $calendar-border-color: var(--calendar-border-color);
183
183
 
184
184
  // Footer
185
185
  .DayPicker-Footer {
186
- margin-top: 8px;
186
+ margin-top: 6px;
187
187
  display: flex;
188
188
  flex-flow: row nowrap;
189
189
  align-items: center;
@@ -285,6 +285,6 @@ $calendar-border-color: var(--calendar-border-color);
285
285
  }
286
286
 
287
287
  // Class to allow body scroll, when Calendar is open in a Modal window
288
- .ModalView_body-hide-scroll:has(.CalendarView) {
288
+ .body-hide-scroll:has(.CalendarView) {
289
289
  overflow-y: auto;
290
290
  }
@@ -43,10 +43,19 @@ var hooks_1 = require("@steroidsjs/core/hooks");
43
43
  var Icon_1 = __importDefault(require("@steroidsjs/core/ui/content/Icon"));
44
44
  var DropDown_1 = __importDefault(require("@steroidsjs/core/ui/content/DropDown"));
45
45
  var Calendar_1 = __importDefault(require("@steroidsjs/core/ui/content/Calendar"));
46
+ var RangeButtons_1 = __importDefault(require("./views/RangeButtons"));
46
47
  function DateRangeFieldView(props) {
47
48
  var bem = (0, hooks_1.useBem)('DateRangeFieldView');
48
49
  var hasValue = props.inputPropsFrom.value || props.inputPropsTo.value;
49
- var renderCalendar = (0, react_1.useCallback)(function () { return (React.createElement(Calendar_1["default"], __assign({}, props.calendarProps))); }, [props.calendarProps]);
50
+ var renderCalendar = (0, react_1.useCallback)(function () { return (props.withRangeButtons ? (React.createElement("div", { className: bem.element('calendar-wrapper', {
51
+ position: props.rangeButtonsPosition
52
+ }) },
53
+ React.createElement("div", { className: bem.element('additional-buttons') },
54
+ React.createElement(RangeButtons_1["default"], { config: props.withRangeButtons, changeTo: props.inputPropsTo.onChange, changeFrom: props.inputPropsFrom.onChange, position: props.rangeButtonsPosition, format: props.displayFormat })),
55
+ React.createElement("div", { className: bem.element('calendar') },
56
+ React.createElement(Calendar_1["default"], __assign({}, props.calendarProps)))))
57
+ : (React.createElement(Calendar_1["default"], __assign({}, props.calendarProps)))); }, [bem, props.calendarProps, props.displayFormat, props.inputPropsFrom.onChange,
58
+ props.inputPropsTo.onChange, props.rangeButtonsPosition, props.withRangeButtons]);
50
59
  return (React.createElement(DropDown_1["default"], { content: renderCalendar, position: 'bottomLeft', visible: props.isOpened, onClose: props.onClose, className: bem.element('split'), hasArrow: false },
51
60
  React.createElement("div", { className: bem(bem.block({
52
61
  disabled: props.disabled,
@@ -1,5 +1,6 @@
1
1
  @use "../../scss/variables";
2
2
  @use '../../scss/mixins';
3
+ @forward './views/RangeButtons/RangeButtons.scss';
3
4
 
4
5
  :root {
5
6
  --date-range-separator-color: rgba(0, 0, 0, 0.1);
@@ -11,6 +12,26 @@ html[data-theme="dark"] {
11
12
 
12
13
  $date-range-separator-color: var(--date-range-separator-color);
13
14
 
15
+ $positions: (
16
+ top: (
17
+ direction: column,
18
+ responsive: top
19
+ ),
20
+ bottom: (
21
+ direction: column-reverse,
22
+ responsive: bottom
23
+ ),
24
+ left: (
25
+ direction: row,
26
+ responsive: left
27
+ ),
28
+ right: (
29
+ direction: row-reverse,
30
+ responsive: right
31
+ )
32
+ );
33
+
34
+ $all-directions: top, bottom, left, right;
14
35
 
15
36
  .DateRangeFieldView {
16
37
  $root: &;
@@ -47,4 +68,37 @@ $date-range-separator-color: var(--date-range-separator-color);
47
68
 
48
69
  @include mixins.date-range-effects($root);
49
70
 
71
+ &__calendar-wrapper {
72
+ display: flex;
73
+ width: min-content;
74
+
75
+ &_position {
76
+ @each $pos, $config in $positions {
77
+ &_#{$pos} {
78
+ flex-direction: map-get($config, direction);
79
+ align-items: center;
80
+
81
+ @media (max-width: variables.$tablet-width) {
82
+ flex-direction: map-get($config, responsive);
83
+ align-items: center;
84
+ }
85
+ }
86
+ }
87
+ @each $dir1 in $all-directions {
88
+ @each $dir2 in $all-directions {
89
+ @if $dir1 != $dir2 {
90
+ &_#{$dir1}-#{$dir2} {
91
+ flex-direction: map-get(map-get($positions, $dir1), direction);
92
+ align-items: center;
93
+
94
+ @media (max-width: variables.$tablet-width) {
95
+ flex-direction: map-get(map-get($positions, $dir2), direction);
96
+ align-items: center;
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
50
104
  }
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { IDateRangeFieldViewProps } from '@steroidsjs/core/ui/form/DateRangeField/DateRangeField';
3
+ interface IRangeButtonsProps {
4
+ config: IDateRangeFieldViewProps['withRangeButtons'];
5
+ changeFrom: (value: string) => void;
6
+ changeTo: (value: string) => void;
7
+ position?: IDateRangeFieldViewProps['rangeButtonsPosition'];
8
+ format?: string;
9
+ }
10
+ export default function RangeButtons(props: IRangeButtonsProps): JSX.Element;
11
+ export {};
@@ -0,0 +1,60 @@
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
+ };
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
+ };
36
+ exports.__esModule = true;
37
+ var react_1 = __importStar(require("react"));
38
+ var hooks_1 = require("@steroidsjs/core/hooks");
39
+ var form_1 = require("@steroidsjs/core/ui/form");
40
+ var consts_1 = require("./consts");
41
+ var DEFAULT_BUTTONS = [
42
+ consts_1.RANGE_BUTTONS.today,
43
+ consts_1.RANGE_BUTTONS.yesterday,
44
+ consts_1.RANGE_BUTTONS.thisWeek,
45
+ consts_1.RANGE_BUTTONS.lastWeek,
46
+ consts_1.RANGE_BUTTONS.thisMonth,
47
+ consts_1.RANGE_BUTTONS.lastMonth,
48
+ consts_1.RANGE_BUTTONS.thisYear,
49
+ consts_1.RANGE_BUTTONS.lastYear,
50
+ ];
51
+ var DEFAULT_VALUE_FORMAT = 'DD.MM.YYYY';
52
+ function RangeButtons(props) {
53
+ var bem = (0, hooks_1.useBem)('RangeButtons');
54
+ var locale = (0, hooks_1.useComponents)().locale;
55
+ var changeFrom = props.changeFrom, changeTo = props.changeTo;
56
+ var buttons = (0, react_1.useMemo)(function () { return (Array.isArray(props.config) ? props.config : DEFAULT_BUTTONS)
57
+ .map(function (button) { return (__assign(__assign({}, button), { onClick: button.onClick.bind(null, locale, changeFrom, changeTo, props.format || DEFAULT_VALUE_FORMAT) })); }); }, [changeFrom, changeTo, locale, props.config, props.format]);
58
+ return (react_1["default"].createElement("div", { className: bem.block({ position: props.position }) }, buttons.map(function (button, index) { return (react_1["default"].createElement(form_1.Button, { key: index, onClick: button.onClick, label: button.label, outline: true, size: 'sm', color: 'basic' })); })));
59
+ }
60
+ exports["default"] = RangeButtons;
@@ -0,0 +1,126 @@
1
+ @use '../../../../scss/variables';
2
+
3
+ $all-directions: top, bottom, left, right;
4
+
5
+ $positions: (
6
+ top: (
7
+ flex-direction: row,
8
+ justify-content: center,
9
+ padding: (padding-bottom: 16px, padding-top: unset),
10
+ before: (top: unset, bottom: 0),
11
+ size: (width: 100%, height: 1px)
12
+ ),
13
+ bottom: (
14
+ flex-direction: row,
15
+ justify-content: center,
16
+ padding: (padding-top: 16px, padding-bottom: unset),
17
+ before: (top: 0, bottom: unset),
18
+ size: (width: 100%, height: 1px)
19
+ ),
20
+ left: (
21
+ flex-direction: column,
22
+ justify-content: center,
23
+ padding: (padding-top: unset, padding-right: 16px),
24
+ before: (left: unset, right: 1px),
25
+ size: (width: 1px, height: 100%)
26
+ ),
27
+ right: (
28
+ flex-direction: column,
29
+ justify-content: center,
30
+ padding: (padding-top: unset, padding-left: 16px),
31
+ before: (left: 1px, right: unset),
32
+ size: (width: 1px, height: 100%)
33
+ )
34
+ );
35
+
36
+ .RangeButtons {
37
+ position: relative;
38
+ display: flex;
39
+
40
+ flex-wrap: wrap;
41
+ width: fit-content;
42
+ gap: 8px;
43
+
44
+ padding-top: 16px;
45
+
46
+ &::before {
47
+ content: '';
48
+ position: absolute;
49
+ top: 0;
50
+ left: 0;
51
+ width: 100%;
52
+ height: 1px;
53
+ background-color: var(--date-range-separator-color);
54
+ }
55
+
56
+ &_position {
57
+ @each $dir, $config in $positions {
58
+ &_#{$dir} {
59
+ flex-direction: map-get($config, flex-direction);
60
+ justify-content: map-get($config, justify-content);
61
+
62
+ @each $pad, $val in map-get($config, padding) {
63
+ #{$pad}: #{$val};
64
+ }
65
+
66
+ &::before {
67
+ @each $prop, $val in map-get($config, before) {
68
+ #{$prop}: #{$val};
69
+ }
70
+ @each $size, $val in map-get($config, size) {
71
+ #{$size}: #{$val};
72
+ }
73
+ }
74
+ }
75
+ }
76
+ @each $dir1 in $all-directions {
77
+ @each $dir2 in $all-directions {
78
+ @if $dir1 != $dir2 {
79
+ &_#{$dir1}-#{$dir2} {
80
+ flex-direction: map-get(map-get($positions, $dir1), flex-direction);
81
+ justify-content: map-get(map-get($positions, $dir1), justify-content);
82
+
83
+ // padding из первого направления
84
+ @each $pad, $val in map-get(map-get($positions, $dir1), padding) {
85
+ #{$pad}: #{$val};
86
+ }
87
+
88
+ &::before {
89
+ // before из первого направления
90
+ @each $prop, $val in map-get(map-get($positions, $dir1), before) {
91
+ #{$prop}: #{$val};
92
+ }
93
+ // size из первого направления
94
+ @each $size, $val in map-get(map-get($positions, $dir1), size) {
95
+ #{$size}: #{$val};
96
+ }
97
+ }
98
+
99
+ @media (max-width: variables.$tablet-width) {
100
+ // при адаптиве — использовать второй как fallback
101
+ flex-direction: map-get(map-get($positions, $dir2), flex-direction);
102
+ justify-content: map-get(map-get($positions, $dir2), justify-content);
103
+
104
+ @each $pad, $val in map-get(map-get($positions, $dir2), padding) {
105
+ #{$pad}: #{$val};
106
+ }
107
+
108
+ &::before {
109
+ @each $prop, $val in map-get(map-get($positions, $dir2), before) {
110
+ #{$prop}: #{$val};
111
+ }
112
+ @each $size, $val in map-get(map-get($positions, $dir2), size) {
113
+ #{$size}: #{$val};
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ .ButtonView__text {
124
+ text-wrap: nowrap;
125
+ }
126
+ }
@@ -0,0 +1,34 @@
1
+ export declare const RANGE_BUTTONS: {
2
+ today: {
3
+ label: string;
4
+ onClick: (locale: any, changeFrom: any, changeTo: any, format: any) => void;
5
+ };
6
+ yesterday: {
7
+ label: string;
8
+ onClick: (locale: any, changeFrom: any, changeTo: any, format: any) => void;
9
+ };
10
+ thisWeek: {
11
+ label: string;
12
+ onClick: (locale: any, changeFrom: any, changeTo: any, format: any) => void;
13
+ };
14
+ lastWeek: {
15
+ label: string;
16
+ onClick: (locale: any, changeFrom: any, changeTo: any, format: any) => void;
17
+ };
18
+ thisMonth: {
19
+ label: string;
20
+ onClick: (locale: any, changeFrom: any, changeTo: any, format: any) => void;
21
+ };
22
+ lastMonth: {
23
+ label: string;
24
+ onClick: (locale: any, changeFrom: any, changeTo: any, format: any) => void;
25
+ };
26
+ thisYear: {
27
+ label: string;
28
+ onClick: (locale: any, changeFrom: any, changeTo: any, format: any) => void;
29
+ };
30
+ lastYear: {
31
+ label: string;
32
+ onClick: (locale: any, changeFrom: any, changeTo: any, format: any) => void;
33
+ };
34
+ };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.RANGE_BUTTONS = void 0;
4
+ var utils_1 = require("./utils");
5
+ exports.RANGE_BUTTONS = {
6
+ today: {
7
+ label: __('Сегодня'),
8
+ onClick: function (locale, changeFrom, changeTo, format) {
9
+ var today = locale.dayjs(new Date().toDateString());
10
+ changeFrom(today.format(format));
11
+ changeTo((0, utils_1.getEndOfDay)(today).format(format));
12
+ }
13
+ },
14
+ yesterday: {
15
+ label: __('Вчера'),
16
+ onClick: function (locale, changeFrom, changeTo, format) {
17
+ var today = locale.dayjs(new Date().toDateString());
18
+ var yesterday = today.subtract(1, 'day');
19
+ changeFrom(yesterday.format(format));
20
+ changeTo(yesterday.hour(23).minute(59).second(59).format(format));
21
+ }
22
+ },
23
+ thisWeek: {
24
+ label: __('Эта неделя'),
25
+ onClick: function (locale, changeFrom, changeTo, format) {
26
+ var _a = (0, utils_1.getCurrentWeek)(locale), start = _a.start, finish = _a.finish;
27
+ changeFrom(start.format(format));
28
+ changeTo(finish.format(format));
29
+ }
30
+ },
31
+ lastWeek: {
32
+ label: __('Прошлая неделя'),
33
+ onClick: function (locale, changeFrom, changeTo, format) {
34
+ var _a = (0, utils_1.getCurrentWeek)(locale), start = _a.start, finish = _a.finish;
35
+ changeFrom(start.subtract(1, 'week').format(format));
36
+ changeTo(finish.subtract(1, 'week').format(format));
37
+ }
38
+ },
39
+ thisMonth: {
40
+ label: __('Этот месяц'),
41
+ onClick: function (locale, changeFrom, changeTo, format) {
42
+ var _a = (0, utils_1.getCurrentMonth)(locale), start = _a.start, finish = _a.finish;
43
+ changeFrom(start.format(format));
44
+ changeTo(finish.format(format));
45
+ }
46
+ },
47
+ lastMonth: {
48
+ label: __('Прошлый месяц'),
49
+ onClick: function (locale, changeFrom, changeTo, format) {
50
+ var _a = (0, utils_1.getCurrentMonth)(locale), start = _a.start, finish = _a.finish;
51
+ changeFrom(start.subtract(1, 'month').format(format));
52
+ changeTo(finish.subtract(1, 'month').format(format));
53
+ }
54
+ },
55
+ thisYear: {
56
+ label: __('Этот год'),
57
+ onClick: function (locale, changeFrom, changeTo, format) {
58
+ var _a = (0, utils_1.getCurrentYear)(locale), start = _a.start, finish = _a.finish;
59
+ changeFrom(start.format(format));
60
+ changeTo(finish.format(format));
61
+ }
62
+ },
63
+ lastYear: {
64
+ label: __('Прошлый год'),
65
+ onClick: function (locale, changeFrom, changeTo, format) {
66
+ var _a = (0, utils_1.getCurrentYear)(locale), start = _a.start, finish = _a.finish;
67
+ changeFrom(start.subtract(1, 'year').format(format));
68
+ changeTo(finish.subtract(1, 'year').format(format));
69
+ }
70
+ }
71
+ };
@@ -0,0 +1,2 @@
1
+ import RangeButtons from './RangeButtons';
2
+ export default RangeButtons;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ var RangeButtons_1 = __importDefault(require("./RangeButtons"));
7
+ exports["default"] = RangeButtons_1["default"];
@@ -0,0 +1,14 @@
1
+ import { ILocaleComponent } from '@steroidsjs/core/components/LocaleComponent';
2
+ export declare const getEndOfDay: (date: ReturnType<ILocaleComponent['dayjs']>) => import("dayjs").Dayjs;
3
+ export declare const getCurrentWeek: (locale: ILocaleComponent) => {
4
+ start: import("dayjs").Dayjs;
5
+ finish: import("dayjs").Dayjs;
6
+ };
7
+ export declare const getCurrentMonth: (locale: ILocaleComponent) => {
8
+ start: import("dayjs").Dayjs;
9
+ finish: import("dayjs").Dayjs;
10
+ };
11
+ export declare const getCurrentYear: (locale: ILocaleComponent) => {
12
+ start: import("dayjs").Dayjs;
13
+ finish: import("dayjs").Dayjs;
14
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.getCurrentYear = exports.getCurrentMonth = exports.getCurrentWeek = exports.getEndOfDay = void 0;
4
+ var getEndOfDay = function (date) { return date.hour(23).minute(59).second(59); };
5
+ exports.getEndOfDay = getEndOfDay;
6
+ var getCurrentWeek = function (locale) {
7
+ var today = locale.dayjs(new Date().toDateString());
8
+ var dayOfWeek = today.day();
9
+ var startDate = today.subtract(dayOfWeek === 0 ? 6 : dayOfWeek - 1, 'day');
10
+ var finishDate = startDate.add(6, 'day');
11
+ return {
12
+ start: startDate,
13
+ finish: (0, exports.getEndOfDay)(finishDate)
14
+ };
15
+ };
16
+ exports.getCurrentWeek = getCurrentWeek;
17
+ var getCurrentMonth = function (locale) {
18
+ var today = locale.dayjs(new Date().toDateString());
19
+ var startDate = today.startOf('month');
20
+ var finishDate = today.endOf('month');
21
+ return {
22
+ start: startDate,
23
+ finish: (0, exports.getEndOfDay)(finishDate)
24
+ };
25
+ };
26
+ exports.getCurrentMonth = getCurrentMonth;
27
+ var getCurrentYear = function (locale) {
28
+ var today = locale.dayjs(new Date().toDateString());
29
+ var startDate = today.startOf('year');
30
+ var finishDate = today.endOf('year');
31
+ return {
32
+ start: startDate,
33
+ finish: (0, exports.getEndOfDay)(finishDate)
34
+ };
35
+ };
36
+ exports.getCurrentYear = getCurrentYear;
@@ -44,13 +44,22 @@ var Icon_1 = __importDefault(require("@steroidsjs/core/ui/content/Icon"));
44
44
  var DropDown_1 = __importDefault(require("@steroidsjs/core/ui/content/DropDown"));
45
45
  var Calendar_1 = __importDefault(require("@steroidsjs/core/ui/content/Calendar"));
46
46
  var TimePanelView_1 = __importDefault(require("../TimeField/TimePanelView"));
47
+ var RangeButtons_1 = __importDefault(require("../DateRangeField/views/RangeButtons"));
47
48
  function DateTimeRangeFieldView(props) {
48
49
  var bem = (0, hooks_1.useBem)('DateTimeRangeFieldView');
49
50
  var hasValue = props.inputPropsFrom.value || props.inputPropsTo.value;
50
- var renderCalendar = (0, react_1.useCallback)(function () { return (React.createElement("div", { className: bem.element('panel-container') },
51
- React.createElement(Calendar_1["default"], __assign({}, props.calendarProps, { className: bem.element('calendar') })),
51
+ var calendarComponent = React.useMemo(function () { return (React.createElement("div", { className: bem.element('panel-container') },
52
+ React.createElement(Calendar_1["default"], __assign({}, props.calendarProps, { className: bem.element('calendar'), showTodayButton: !props.withRangeButtons })),
52
53
  React.createElement("div", { className: bem.element('separator') }),
53
- React.createElement(TimePanelView_1["default"], __assign({}, props.timePanelViewProps, { className: bem.element('time-panel') })))); }, [bem, props.calendarProps, props.timePanelViewProps]);
54
+ React.createElement(TimePanelView_1["default"], __assign({}, props.timePanelViewProps, { className: bem.element('time-panel') })))); }, [bem, props.calendarProps, props.timePanelViewProps, props.withRangeButtons]);
55
+ var renderCalendar = (0, react_1.useCallback)(function () { return (props.withRangeButtons ? (React.createElement("div", { className: bem.element('calendar-wrapper', {
56
+ position: props.rangeButtonsPosition
57
+ }) },
58
+ React.createElement("div", { className: bem.element('additional-buttons') },
59
+ React.createElement(RangeButtons_1["default"], { config: props.withRangeButtons, changeTo: props.inputPropsTo.onChange, changeFrom: props.inputPropsFrom.onChange, position: props.rangeButtonsPosition, format: props.displayFormat })),
60
+ React.createElement("div", { className: bem.element('calendar') }, calendarComponent)))
61
+ : calendarComponent); }, [bem, calendarComponent, props.inputPropsFrom.onChange, props.inputPropsTo.onChange,
62
+ props.rangeButtonsPosition, props.displayFormat, props.withRangeButtons]);
54
63
  return (React.createElement(DropDown_1["default"], { content: renderCalendar, position: 'bottomLeft', visible: props.isOpened, onClose: props.onClose, hasArrow: false, className: bem.element('dropdown') },
55
64
  React.createElement("div", { className: bem(bem.block({
56
65
  disabled: props.disabled,