@steroidsjs/bootstrap 3.0.29 → 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 (55) 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 -10
  6. package/form/AutoCompleteField/AutoCompleteFieldView.scss +10 -4
  7. package/form/Button/ButtonView.scss +4 -3
  8. package/form/DateField/DateFieldView.js +1 -1
  9. package/form/DateRangeField/DateRangeFieldView.js +11 -2
  10. package/form/DateRangeField/DateRangeFieldView.scss +54 -0
  11. package/form/DateRangeField/views/RangeButtons/RangeButtons.d.ts +11 -0
  12. package/form/DateRangeField/views/RangeButtons/RangeButtons.js +60 -0
  13. package/form/DateRangeField/views/RangeButtons/RangeButtons.scss +126 -0
  14. package/form/DateRangeField/views/RangeButtons/consts.d.ts +34 -0
  15. package/form/DateRangeField/views/RangeButtons/consts.js +71 -0
  16. package/form/DateRangeField/views/RangeButtons/index.d.ts +2 -0
  17. package/form/DateRangeField/views/RangeButtons/index.js +7 -0
  18. package/form/DateRangeField/views/RangeButtons/utils.d.ts +14 -0
  19. package/form/DateRangeField/views/RangeButtons/utils.js +36 -0
  20. package/form/DateTimeField/DateTimeFieldView.js +1 -1
  21. package/form/DateTimeRangeField/DateTimeRangeFieldView.js +13 -4
  22. package/form/DateTimeRangeField/DateTimeRangeFieldView.scss +54 -0
  23. package/form/DropDownField/DropDownFieldView.js +3 -2
  24. package/form/DropDownField/DropDownFieldView.scss +12 -0
  25. package/form/InputField/InputFieldView.js +4 -4
  26. package/form/InputField/InputFieldView.scss +128 -174
  27. package/form/PasswordField/PasswordFieldView.scss +12 -3
  28. package/form/TimeField/TimeFieldView.js +1 -1
  29. package/form/TimeField/TimeFieldView.scss +19 -1
  30. package/form/TimeField/TimePanelView.d.ts +5 -0
  31. package/form/TimeField/TimePanelView.js +20 -22
  32. package/form/TimeField/TimePanelView.scss +0 -23
  33. package/form/TimeField/views/TimePanelColumn/TimePanelColumn.d.ts +8 -0
  34. package/form/TimeField/views/TimePanelColumn/TimePanelColumn.js +20 -0
  35. package/form/TimeField/views/TimePanelColumn/TimePanelColumn.scss +53 -0
  36. package/form/TimeField/views/TimePanelColumn/index.d.ts +2 -0
  37. package/form/TimeField/views/TimePanelColumn/index.js +7 -0
  38. package/form/TimeRangeField/TimeRangeFieldView.js +1 -1
  39. package/form/TimeRangeField/TimeRangeFieldView.scss +6 -0
  40. package/hooks/index.d.ts +2 -0
  41. package/hooks/index.js +8 -0
  42. package/hooks/useHideScroll.d.ts +1 -0
  43. package/hooks/useHideScroll.js +37 -0
  44. package/icons/index.js +2 -0
  45. package/icons/svgs/long-arrow-alt-down.svg +3 -0
  46. package/icons/svgs/long-arrow-alt-up.svg +3 -0
  47. package/list/Grid/GridView.js +2 -3
  48. package/list/Grid/GridView.scss +46 -0
  49. package/list/Grid/views/DiagramColumnView/DiagramColumnView.scss +6 -5
  50. package/modal/Modal/ModalView.js +3 -1
  51. package/modal/Modal/ModalView.scss +0 -5
  52. package/package.json +2 -2
  53. package/scss/mixins/button.scss +5 -5
  54. package/scss/mixins/date.scss +2 -2
  55. 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;
@@ -212,14 +212,6 @@ $calendar-border-color: var(--calendar-border-color);
212
212
  background-color: $day-background-color-hover;
213
213
  }
214
214
 
215
- .DayPicker-Day--today:hover {
216
- background-color: transparent;
217
-
218
- .CalendarView__day {
219
- transition: background-color 150ms ease-in-out;
220
- }
221
- }
222
-
223
215
  &__day {
224
216
  position: relative;
225
217
  z-index: 1;
@@ -293,6 +285,6 @@ $calendar-border-color: var(--calendar-border-color);
293
285
  }
294
286
 
295
287
  // Class to allow body scroll, when Calendar is open in a Modal window
296
- .ModalView_body-hide-scroll:has(.CalendarView) {
288
+ .body-hide-scroll:has(.CalendarView) {
297
289
  overflow-y: auto;
298
290
  }
@@ -45,24 +45,30 @@ $autocomplete-icon-color: var(--autocomplete-icon-color);
45
45
  &__input {
46
46
  width: 100%;
47
47
  padding: 0 8px;
48
- border: 1px solid variables.$element-border-color;
48
+ outline: 1px solid variables.$element-border-color;
49
+ border: none;
49
50
  background-color: variables.$element-field-background-color;
50
51
  color: variables.$text-color;
51
- transition: border-color 150ms ease-in-out;
52
+ transition: outline 150ms ease-in-out;
52
53
  font-size: inherit;
53
54
  line-height: inherit;
55
+
56
+ &:active {
57
+ outline-color: variables.$primary;
58
+ }
54
59
  }
55
60
 
56
61
  &_opened {
57
62
  #{$root}__input {
58
- border-color: variables.$primary;
63
+ outline-width: 4px;
64
+ outline-color: variables.$primary-light;
59
65
  }
60
66
  }
61
67
 
62
68
  &_disabled {
63
69
  #{$root}__input {
64
70
  background-color: variables.$element-background-color-disabled;
65
- border-color: transparent;
71
+ outline-color: transparent;
66
72
  cursor: not-allowed;
67
73
  }
68
74
  }
@@ -9,7 +9,7 @@ $btn-letter-spacing: 0.1em;
9
9
  .ButtonView {
10
10
  $root: &;
11
11
 
12
- transition-property: color, background-color, border-color, box-shadow;
12
+ transition-property: color, background-color, outline-color, box-shadow;
13
13
  transition-duration: variables.$transition-duration;
14
14
  transition-timing-function: ease-in-out;
15
15
 
@@ -22,8 +22,9 @@ $btn-letter-spacing: 0.1em;
22
22
  &_button {
23
23
  position: relative;
24
24
  border-radius: variables.$radius-small;
25
+ border: none;
25
26
  user-select: none;
26
- border: 3px solid transparent;
27
+ outline: 3px solid transparent;
27
28
 
28
29
  padding: 0 20px;
29
30
  display: flex;
@@ -140,7 +141,7 @@ $btn-letter-spacing: 0.1em;
140
141
  &_failed {
141
142
  &,
142
143
  &:hover {
143
- border-color: variables.$danger;
144
+ outline-color: variables.$danger;
144
145
  box-shadow: 0 0 1rem rgba(variables.$danger, 0.2);
145
146
  }
146
147
  }
@@ -53,7 +53,7 @@ function DateFieldView(props) {
53
53
  'is-invalid': !!props.errors
54
54
  }), props.className), style: props.style },
55
55
  React.createElement("div", { className: bem.element('body') },
56
- React.createElement("input", __assign({}, props.inputProps, { ref: props.maskInputRef, onInput: function (e) {
56
+ React.createElement("input", __assign({}, props.inputProps, { id: props.id, ref: props.maskInputRef, onInput: function (e) {
57
57
  props.inputProps.onChange(e.currentTarget.value);
58
58
  }, className: bem(bem.element('input'), props.inputProps.className) })),
59
59
  React.createElement("div", { className: bem.element('icon-container') },
@@ -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,
@@ -54,7 +63,7 @@ function DateRangeFieldView(props) {
54
63
  'is-invalid': !!props.errors
55
64
  }), props.className), style: props.style },
56
65
  React.createElement("div", { className: bem.element('body') },
57
- React.createElement("input", __assign({}, props.inputPropsFrom, { className: bem(bem.element('input', {})), onInput: function (e) { return props.inputPropsFrom.onChange(e.currentTarget.value); } })),
66
+ React.createElement("input", __assign({}, props.inputPropsFrom, { id: props.id, className: bem(bem.element('input', {})), onInput: function (e) { return props.inputPropsFrom.onChange(e.currentTarget.value); } })),
58
67
  React.createElement("input", __assign({}, props.inputPropsTo, { className: bem.element('input'), onInput: function (e) { return props.inputPropsTo.onChange(e.currentTarget.value); } })),
59
68
  React.createElement("div", { className: bem.element('icon-container') },
60
69
  props.icon && !hasValue && (React.createElement(Icon_1["default"], { className: bem.element('date-icon'), name: typeof props.icon === 'string' ? props.icon : 'calendar_range', tabIndex: -1 })),
@@ -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;