@salutejs/plasma-new-hope 0.324.1-canary.1990.15248420614.0 → 0.325.0-canary.1715.15255555914.0

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 (58) hide show
  1. package/cjs/components/Calendar/hooks/useMonths.js +3 -1
  2. package/cjs/components/Calendar/hooks/useMonths.js.map +1 -1
  3. package/cjs/components/Calendar/hooks/useQuarters.js +3 -1
  4. package/cjs/components/Calendar/hooks/useQuarters.js.map +1 -1
  5. package/cjs/components/Calendar/hooks/useYears.js +3 -1
  6. package/cjs/components/Calendar/hooks/useYears.js.map +1 -1
  7. package/cjs/components/Calendar/utils/getDateWithModification.js +28 -24
  8. package/cjs/components/Calendar/utils/getDateWithModification.js.map +1 -1
  9. package/emotion/cjs/components/Calendar/hooks/useMonths.js +3 -1
  10. package/emotion/cjs/components/Calendar/hooks/useQuarters.js +3 -1
  11. package/emotion/cjs/components/Calendar/hooks/useYears.js +3 -1
  12. package/emotion/cjs/components/Calendar/utils/getDateWithModification.js +28 -24
  13. package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.config.js +23 -22
  14. package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +4 -3
  15. package/emotion/cjs/examples/plasma_web/components/TextField/TextField.config.js +23 -22
  16. package/emotion/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +5 -4
  17. package/emotion/es/components/Calendar/hooks/useMonths.js +3 -1
  18. package/emotion/es/components/Calendar/hooks/useQuarters.js +3 -1
  19. package/emotion/es/components/Calendar/hooks/useYears.js +3 -1
  20. package/emotion/es/components/Calendar/utils/getDateWithModification.js +28 -24
  21. package/emotion/es/examples/plasma_b2c/components/TextField/TextField.config.js +23 -22
  22. package/emotion/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +4 -3
  23. package/emotion/es/examples/plasma_web/components/TextField/TextField.config.js +23 -22
  24. package/emotion/es/examples/plasma_web/components/TextField/TextField.stories.tsx +5 -4
  25. package/es/components/Calendar/hooks/useMonths.js +3 -1
  26. package/es/components/Calendar/hooks/useMonths.js.map +1 -1
  27. package/es/components/Calendar/hooks/useQuarters.js +3 -1
  28. package/es/components/Calendar/hooks/useQuarters.js.map +1 -1
  29. package/es/components/Calendar/hooks/useYears.js +3 -1
  30. package/es/components/Calendar/hooks/useYears.js.map +1 -1
  31. package/es/components/Calendar/utils/getDateWithModification.js +28 -24
  32. package/es/components/Calendar/utils/getDateWithModification.js.map +1 -1
  33. package/package.json +2 -2
  34. package/styled-components/cjs/components/Calendar/hooks/useMonths.js +3 -1
  35. package/styled-components/cjs/components/Calendar/hooks/useQuarters.js +3 -1
  36. package/styled-components/cjs/components/Calendar/hooks/useYears.js +3 -1
  37. package/styled-components/cjs/components/Calendar/utils/getDateWithModification.js +28 -24
  38. package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.config.js +2 -1
  39. package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +4 -3
  40. package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.config.js +7 -6
  41. package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +5 -4
  42. package/styled-components/es/components/Calendar/hooks/useMonths.js +3 -1
  43. package/styled-components/es/components/Calendar/hooks/useQuarters.js +3 -1
  44. package/styled-components/es/components/Calendar/hooks/useYears.js +3 -1
  45. package/styled-components/es/components/Calendar/utils/getDateWithModification.js +28 -24
  46. package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.config.js +2 -1
  47. package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +4 -3
  48. package/styled-components/es/examples/plasma_web/components/TextField/TextField.config.js +7 -6
  49. package/styled-components/es/examples/plasma_web/components/TextField/TextField.stories.tsx +5 -4
  50. package/types/components/Calendar/hooks/types.d.ts +7 -2
  51. package/types/components/Calendar/hooks/types.d.ts.map +1 -1
  52. package/types/components/Calendar/hooks/useMonths.d.ts +1 -1
  53. package/types/components/Calendar/hooks/useMonths.d.ts.map +1 -1
  54. package/types/components/Calendar/hooks/useQuarters.d.ts +1 -1
  55. package/types/components/Calendar/hooks/useQuarters.d.ts.map +1 -1
  56. package/types/components/Calendar/hooks/useYears.d.ts +1 -1
  57. package/types/components/Calendar/hooks/useYears.d.ts.map +1 -1
  58. package/types/components/Calendar/utils/getDateWithModification.d.ts.map +1 -1
@@ -1,13 +1,14 @@
1
1
  import React, { ComponentProps, useState } from 'react';
2
2
  import type { StoryObj, Meta } from '@storybook/react';
3
3
  import { action } from '@storybook/addon-actions';
4
- import { IconPlaceholder } from '@salutejs/plasma-sb-utils';
4
+ import { IconPlaceholder, getConfigVariations } from '@salutejs/plasma-sb-utils';
5
5
 
6
6
  import { WithTheme } from '../../../_helpers';
7
7
  import { IconCross, IconLock } from '../../../../components/_Icon';
8
8
  import type { PopoverPlacement } from '../Popover/Popover';
9
9
 
10
10
  import { TextField } from './TextField';
11
+ import { config } from './TextField.config';
11
12
 
12
13
  const onChange = action('onChange');
13
14
  const onFocus = action('onFocus');
@@ -15,14 +16,14 @@ const onBlur = action('onBlur');
15
16
  const onSearch = action('onSearch');
16
17
  const onChipsChange = action('onChipsChange');
17
18
 
18
- const sizes = ['l', 'm', 's', 'xs'];
19
- const views = ['default', 'positive', 'warning', 'negative'];
19
+ const { views, sizes } = getConfigVariations(config);
20
+
20
21
  const chipViews = ['default', 'secondary', 'accent', 'positive', 'warning', 'negative'];
21
22
  const hintViews = ['default'];
22
23
  const hintSizes = ['m', 's'];
23
24
  const hintTriggers = ['hover', 'click'];
24
- const hintTargetPlacements = ['outer', 'inner'];
25
25
  const labelPlacements = ['outer', 'inner'];
26
+ const hintTargetPlacements = ['outer', 'inner'];
26
27
  const placements: Array<PopoverPlacement> = [
27
28
  'top',
28
29
  'top-start',
@@ -12,7 +12,8 @@ export var useMonths = function useMonths(_ref) {
12
12
  min = _ref.min,
13
13
  max = _ref.max,
14
14
  _ref$locale = _ref.locale,
15
- locale = _ref$locale === void 0 ? 'ru' : _ref$locale;
15
+ locale = _ref$locale === void 0 ? 'ru' : _ref$locale,
16
+ includeEdgeDates = _ref.includeEdgeDates;
16
17
  return useMemo(function () {
17
18
  var months = SHORT_MONTH_NAME[locale].map(function (monthName, monthIndex) {
18
19
  return {
@@ -37,6 +38,7 @@ export var useMonths = function useMonths(_ref) {
37
38
  type: CalendarState.Months,
38
39
  min: min,
39
40
  max: max,
41
+ includeEdgeDates: includeEdgeDates,
40
42
  eventList: eventList,
41
43
  disabledList: disabledList
42
44
  });
@@ -10,7 +10,8 @@ export var useQuarters = function useQuarters(_ref) {
10
10
  eventList = _ref.eventList,
11
11
  disabledList = _ref.disabledList,
12
12
  min = _ref.min,
13
- max = _ref.max;
13
+ max = _ref.max,
14
+ includeEdgeDates = _ref.includeEdgeDates;
14
15
  return useMemo(function () {
15
16
  var quarters = QUARTER_NAMES.map(function (quarterName) {
16
17
  var _quarterDates$quarter = quarterDates[quarterName],
@@ -36,6 +37,7 @@ export var useQuarters = function useQuarters(_ref) {
36
37
  type: CalendarState.Quarters,
37
38
  min: min,
38
39
  max: max,
40
+ includeEdgeDates: includeEdgeDates,
39
41
  eventList: eventList,
40
42
  disabledList: disabledList
41
43
  });
@@ -11,7 +11,8 @@ export var useYears = function useYears(_ref) {
11
11
  eventList = _ref.eventList,
12
12
  disabledList = _ref.disabledList,
13
13
  min = _ref.min,
14
- max = _ref.max;
14
+ max = _ref.max,
15
+ includeEdgeDates = _ref.includeEdgeDates;
15
16
  return useMemo(function () {
16
17
  // type-coverage:ignore-next-line
17
18
  var years = Array.from(Array(YEAR_RENDER_COUNT), function (_, i) {
@@ -36,6 +37,7 @@ export var useYears = function useYears(_ref) {
36
37
  type: CalendarState.Years,
37
38
  min: min,
38
39
  max: max,
40
+ includeEdgeDates: includeEdgeDates,
39
41
  eventList: eventList,
40
42
  disabledList: disabledList
41
43
  });
@@ -42,7 +42,7 @@ var normalizeDate = function normalizeDate(date, type) {
42
42
  date.setMonth(0);
43
43
  }
44
44
  };
45
- var isDisabledNextDate = function isDisabledNextDate(_ref, type, max) {
45
+ var isDisabledNextDate = function isDisabledNextDate(_ref, type, max, includeEdgeDates) {
46
46
  var year = _ref.year,
47
47
  monthIndex = _ref.monthIndex,
48
48
  day = _ref.day;
@@ -54,13 +54,13 @@ var isDisabledNextDate = function isDisabledNextDate(_ref, type, max) {
54
54
  var currentDate = new Date(year, monthIndex, day);
55
55
  dateOperationHandler[type].add(currentDate);
56
56
  var isOut = true;
57
- while (isOut && currentDate <= maxDate) {
58
- isOut = maxDate <= currentDate;
57
+ while (isOut && includeEdgeDates ? currentDate < maxDate : currentDate <= maxDate) {
58
+ isOut = includeEdgeDates ? maxDate < currentDate : maxDate <= currentDate;
59
59
  dateOperationHandler[type].add(currentDate);
60
60
  }
61
61
  return isOut;
62
62
  };
63
- var isDisabledPreviousDate = function isDisabledPreviousDate(_ref2, type, min) {
63
+ var isDisabledPreviousDate = function isDisabledPreviousDate(_ref2, type, min, includeEdgeDates) {
64
64
  var year = _ref2.year,
65
65
  monthIndex = _ref2.monthIndex,
66
66
  day = _ref2.day;
@@ -72,54 +72,58 @@ var isDisabledPreviousDate = function isDisabledPreviousDate(_ref2, type, min) {
72
72
  var currentDate = new Date(year, monthIndex, day);
73
73
  dateOperationHandler[type].subtract(currentDate);
74
74
  var isOut = true;
75
- while (isOut && currentDate >= minDate) {
76
- isOut = minDate >= currentDate;
75
+ while (isOut && includeEdgeDates ? currentDate > minDate : currentDate >= minDate) {
76
+ isOut = includeEdgeDates ? minDate > currentDate : minDate >= currentDate;
77
77
  dateOperationHandler[type].subtract(currentDate);
78
78
  }
79
79
  return isOut;
80
80
  };
81
- var getDisabledDates = function getDisabledDates(list, type, min, max) {
81
+ var getDisabledDates = function getDisabledDates(list, type, min, max, includeEdgeDates) {
82
82
  var disabledDate = [];
83
- if (isDisabledPreviousDate(list[0], type, min)) {
83
+ if (isDisabledPreviousDate(list[0], type, min, includeEdgeDates)) {
84
84
  disabledDate.push('previous');
85
85
  }
86
- if (isDisabledNextDate(list[list.length - 1], type, max)) {
86
+ if (isDisabledNextDate(list[list.length - 1], type, max, includeEdgeDates)) {
87
87
  disabledDate.push('next');
88
88
  }
89
89
  return disabledDate.join(',');
90
90
  };
91
- var isDisabledArrowLeft = function isDisabledArrowLeft(date, min) {
91
+ var isDisabledArrowLeft = function isDisabledArrowLeft(date, min, includeEdgeDates) {
92
92
  var currentDate = new Date(date);
93
93
  currentDate.setDate(currentDate.getDate() - 1);
94
- return min && min >= currentDate || min && min >= date;
94
+ var disableCondition = min && (includeEdgeDates ? min > currentDate : min >= currentDate);
95
+ return disableCondition;
95
96
  };
96
- var isDisabledArrowRight = function isDisabledArrowRight(date, max) {
97
+ var isDisabledArrowRight = function isDisabledArrowRight(date, max, includeEdgeDates) {
97
98
  var currentDate = new Date(date);
98
99
  currentDate.setDate(currentDate.getDate() + 1);
99
- return max && max <= currentDate || max && max <= date;
100
+ var disableCondition = max && (includeEdgeDates ? max < currentDate : max <= currentDate);
101
+ return disableCondition;
100
102
  };
101
- var isDisabledArrowUp = function isDisabledArrowUp(date, min) {
103
+ var isDisabledArrowUp = function isDisabledArrowUp(date, min, includeEdgeDates) {
102
104
  var currentDate = new Date(date);
103
105
  currentDate.setDate(date.getDate() - 7);
104
- return min && min >= currentDate;
106
+ var disableCondition = min && (includeEdgeDates ? min > currentDate : min >= currentDate);
107
+ return disableCondition;
105
108
  };
106
- var isDisabledArrowDown = function isDisabledArrowDown(date, max) {
109
+ var isDisabledArrowDown = function isDisabledArrowDown(date, max, includeEdgeDates) {
107
110
  var currentDate = new Date(date);
108
111
  currentDate.setDate(date.getDate() + 7);
109
- return max && max <= currentDate;
112
+ var disableCondition = max && (includeEdgeDates ? max < currentDate : max <= currentDate);
113
+ return disableCondition;
110
114
  };
111
- var getDisabledArrowKey = function getDisabledArrowKey(currentDate, min, max) {
115
+ var getDisabledArrowKey = function getDisabledArrowKey(currentDate, min, max, includeEdgeDates) {
112
116
  var disabledArrowKey = [];
113
- if (isDisabledArrowLeft(currentDate, min)) {
117
+ if (isDisabledArrowLeft(currentDate, min, includeEdgeDates)) {
114
118
  disabledArrowKey.push('left');
115
119
  }
116
- if (isDisabledArrowRight(currentDate, max)) {
120
+ if (isDisabledArrowRight(currentDate, max, includeEdgeDates)) {
117
121
  disabledArrowKey.push('right');
118
122
  }
119
- if (isDisabledArrowDown(currentDate, max)) {
123
+ if (isDisabledArrowDown(currentDate, max, includeEdgeDates)) {
120
124
  disabledArrowKey.push('down');
121
125
  }
122
- if (isDisabledArrowUp(currentDate, min)) {
126
+ if (isDisabledArrowUp(currentDate, min, includeEdgeDates)) {
123
127
  disabledArrowKey.push('up');
124
128
  }
125
129
  return disabledArrowKey.join(',');
@@ -148,7 +152,7 @@ export var getDatesWithModifications = function getDatesWithModifications(_ref3)
148
152
  var date = _ref5.date;
149
153
  return date;
150
154
  });
151
- var disabledDates = getDisabledDates(datesList, type, min, max);
155
+ var disabledDates = getDisabledDates(datesList, type, min, max, includeEdgeDates);
152
156
  return dates.map(function (dateItem) {
153
157
  var date = dateItem.date;
154
158
  var year = date.year,
@@ -173,7 +177,7 @@ export var getDatesWithModifications = function getDatesWithModifications(_ref3)
173
177
  dateItem.events = eventsMap.get(keyDate);
174
178
  dateItem.disabled = disabledDatesMap.has(keyDate) || isOutOfMinMaxRange;
175
179
  dateItem.isOutOfMinMaxRange = isOutOfMinMaxRange;
176
- dateItem.disabledArrowKey = getDisabledArrowKey(currentDate, min, max);
180
+ dateItem.disabledArrowKey = getDisabledArrowKey(currentDate, min, max, includeEdgeDates);
177
181
  dateItem.disabledDates = disabledDates;
178
182
  return dateItem;
179
183
  });