@salutejs/plasma-new-hope 0.146.1-canary.1412.10900761739.0 → 0.146.1-canary.1441.10902378762.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. package/cjs/components/DatePicker/RangeDate/RangeDate.js +30 -6
  2. package/cjs/components/DatePicker/RangeDate/RangeDate.js.map +1 -1
  3. package/cjs/components/DatePicker/SingleDate/SingleDate.js +15 -3
  4. package/cjs/components/DatePicker/SingleDate/SingleDate.js.map +1 -1
  5. package/cjs/components/DatePicker/hooks/useDatePicker.js +48 -5
  6. package/cjs/components/DatePicker/hooks/useDatePicker.js.map +1 -1
  7. package/cjs/components/DatePicker/utils/dateHelper.js +11 -2
  8. package/cjs/components/DatePicker/utils/dateHelper.js.map +1 -1
  9. package/cjs/components/Drawer/Drawer.css +3 -4
  10. package/cjs/components/Drawer/Drawer.js +1 -1
  11. package/cjs/components/Drawer/Drawer.styles.js +0 -2
  12. package/cjs/components/Drawer/Drawer.styles.js.map +1 -1
  13. package/cjs/components/Drawer/hooks/useDrawer.js +1 -1
  14. package/cjs/components/Modal/Modal.css +3 -4
  15. package/cjs/components/Modal/hooks/useModal.js +1 -1
  16. package/cjs/components/Notification/NotificationsProvider.css +3 -4
  17. package/cjs/components/Popup/Popup.css +3 -0
  18. package/cjs/components/Popup/Popup.js +38 -155
  19. package/cjs/components/Popup/Popup.js.map +1 -1
  20. package/cjs/components/Popup/Popup.styles.js +9 -21
  21. package/cjs/components/Popup/Popup.styles.js.map +1 -1
  22. package/cjs/components/Popup/Popup.styles_141jyqa.css +3 -0
  23. package/cjs/components/Popup/PopupContext.js +9 -9
  24. package/cjs/components/Popup/PopupContext.js.map +1 -1
  25. package/cjs/components/Popup/hooks/usePopup.js +1 -1
  26. package/cjs/components/Popup/hooks/usePopup.js.map +1 -1
  27. package/cjs/index.css +3 -4
  28. package/emotion/cjs/components/DatePicker/DatePicker.template-doc.mdx +13 -10
  29. package/emotion/cjs/components/DatePicker/RangeDate/RangeDate.js +30 -6
  30. package/emotion/cjs/components/DatePicker/SingleDate/SingleDate.js +15 -3
  31. package/emotion/cjs/components/DatePicker/hooks/useDatePicker.js +48 -5
  32. package/emotion/cjs/components/DatePicker/utils/dateHelper.js +11 -2
  33. package/emotion/cjs/components/Popup/Popup.js +38 -156
  34. package/emotion/cjs/components/Popup/Popup.styles.js +5 -25
  35. package/emotion/cjs/components/Popup/PopupContext.js +9 -10
  36. package/emotion/cjs/components/Popup/hooks/usePopup.js +1 -1
  37. package/emotion/cjs/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
  38. package/emotion/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
  39. package/emotion/cjs/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
  40. package/emotion/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
  41. package/emotion/cjs/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
  42. package/emotion/es/components/DatePicker/DatePicker.template-doc.mdx +13 -10
  43. package/emotion/es/components/DatePicker/RangeDate/RangeDate.js +30 -6
  44. package/emotion/es/components/DatePicker/SingleDate/SingleDate.js +15 -3
  45. package/emotion/es/components/DatePicker/hooks/useDatePicker.js +48 -5
  46. package/emotion/es/components/DatePicker/utils/dateHelper.js +11 -2
  47. package/emotion/es/components/Popup/Popup.js +39 -156
  48. package/emotion/es/components/Popup/Popup.styles.js +4 -24
  49. package/emotion/es/components/Popup/PopupContext.js +10 -10
  50. package/emotion/es/components/Popup/hooks/usePopup.js +1 -1
  51. package/emotion/es/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
  52. package/emotion/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
  53. package/emotion/es/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
  54. package/emotion/es/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
  55. package/emotion/es/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
  56. package/es/components/DatePicker/RangeDate/RangeDate.js +30 -6
  57. package/es/components/DatePicker/RangeDate/RangeDate.js.map +1 -1
  58. package/es/components/DatePicker/SingleDate/SingleDate.js +15 -3
  59. package/es/components/DatePicker/SingleDate/SingleDate.js.map +1 -1
  60. package/es/components/DatePicker/hooks/useDatePicker.js +48 -5
  61. package/es/components/DatePicker/hooks/useDatePicker.js.map +1 -1
  62. package/es/components/DatePicker/utils/dateHelper.js +11 -2
  63. package/es/components/DatePicker/utils/dateHelper.js.map +1 -1
  64. package/es/components/Drawer/Drawer.css +3 -4
  65. package/es/components/Drawer/Drawer.js +1 -1
  66. package/es/components/Drawer/Drawer.styles.js +0 -2
  67. package/es/components/Drawer/Drawer.styles.js.map +1 -1
  68. package/es/components/Drawer/hooks/useDrawer.js +1 -1
  69. package/es/components/Modal/Modal.css +3 -4
  70. package/es/components/Modal/hooks/useModal.js +1 -1
  71. package/es/components/Notification/NotificationsProvider.css +3 -4
  72. package/es/components/Popup/Popup.css +3 -0
  73. package/es/components/Popup/Popup.js +40 -157
  74. package/es/components/Popup/Popup.js.map +1 -1
  75. package/es/components/Popup/Popup.styles.js +10 -20
  76. package/es/components/Popup/Popup.styles.js.map +1 -1
  77. package/es/components/Popup/Popup.styles_141jyqa.css +3 -0
  78. package/es/components/Popup/PopupContext.js +10 -10
  79. package/es/components/Popup/PopupContext.js.map +1 -1
  80. package/es/components/Popup/hooks/usePopup.js +1 -1
  81. package/es/components/Popup/hooks/usePopup.js.map +1 -1
  82. package/es/index.css +3 -4
  83. package/package.json +4 -4
  84. package/styled-components/cjs/components/DatePicker/DatePicker.template-doc.mdx +13 -10
  85. package/styled-components/cjs/components/DatePicker/RangeDate/RangeDate.js +30 -6
  86. package/styled-components/cjs/components/DatePicker/SingleDate/SingleDate.js +15 -3
  87. package/styled-components/cjs/components/DatePicker/hooks/useDatePicker.js +48 -5
  88. package/styled-components/cjs/components/DatePicker/utils/dateHelper.js +11 -2
  89. package/styled-components/cjs/components/Popup/Popup.js +38 -156
  90. package/styled-components/cjs/components/Popup/Popup.styles.js +4 -7
  91. package/styled-components/cjs/components/Popup/PopupContext.js +9 -10
  92. package/styled-components/cjs/components/Popup/hooks/usePopup.js +1 -1
  93. package/styled-components/cjs/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
  94. package/styled-components/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
  95. package/styled-components/cjs/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
  96. package/styled-components/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
  97. package/styled-components/cjs/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
  98. package/styled-components/es/components/DatePicker/DatePicker.template-doc.mdx +13 -10
  99. package/styled-components/es/components/DatePicker/RangeDate/RangeDate.js +30 -6
  100. package/styled-components/es/components/DatePicker/SingleDate/SingleDate.js +15 -3
  101. package/styled-components/es/components/DatePicker/hooks/useDatePicker.js +48 -5
  102. package/styled-components/es/components/DatePicker/utils/dateHelper.js +11 -2
  103. package/styled-components/es/components/Popup/Popup.js +39 -156
  104. package/styled-components/es/components/Popup/Popup.styles.js +3 -6
  105. package/styled-components/es/components/Popup/PopupContext.js +10 -10
  106. package/styled-components/es/components/Popup/hooks/usePopup.js +1 -1
  107. package/styled-components/es/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
  108. package/styled-components/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
  109. package/styled-components/es/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
  110. package/styled-components/es/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
  111. package/styled-components/es/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
  112. package/types/components/DatePicker/RangeDate/RangeDate.d.ts.map +1 -1
  113. package/types/components/DatePicker/hooks/useDatePicker.d.ts.map +1 -1
  114. package/types/components/DatePicker/utils/dateHelper.d.ts +10 -1
  115. package/types/components/DatePicker/utils/dateHelper.d.ts.map +1 -1
  116. package/types/components/Popup/Popup.d.ts +1 -1
  117. package/types/components/Popup/Popup.d.ts.map +1 -1
  118. package/types/components/Popup/Popup.styles.d.ts +0 -1
  119. package/types/components/Popup/Popup.styles.d.ts.map +1 -1
  120. package/types/components/Popup/PopupContext.d.ts.map +1 -1
  121. package/cjs/components/Popup/Popup.styles_8h77g1.css +0 -4
  122. package/cjs/components/Popup/PopupContext.css +0 -4
  123. package/es/components/Popup/Popup.styles_8h77g1.css +0 -4
  124. package/es/components/Popup/PopupContext.css +0 -4
@@ -18,7 +18,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
18
18
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
19
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
20
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
- // Хук для подключения анимации
21
+ // Хук для поключения анимации
22
22
  var usePopupAnimation = function usePopupAnimation() {
23
23
  var _useState = (0, _react.useState)(false),
24
24
  _useState2 = _slicedToArray(_useState, 2),
@@ -211,7 +211,7 @@ export const DrawerDemo: StoryObj<StoryDrawerProps> = {
211
211
  asModal: true,
212
212
  closePlacement: 'right',
213
213
  width: '25vw',
214
- height: '100vh',
214
+ height: '100dvh',
215
215
  borderRadius: 'none',
216
216
  },
217
217
  render: (args) => <StoryDrawerDemo {...args} />,
@@ -80,7 +80,7 @@ const StyledButton = styled(Button)`
80
80
  `;
81
81
 
82
82
  const StyledWrapper = styled.div`
83
- height: 300px;
83
+ height: 1200px;
84
84
  `;
85
85
 
86
86
  const Content = styled.div`
@@ -55,7 +55,7 @@ const StyledButton = styled(Button)`
55
55
  `;
56
56
 
57
57
  const StyledWrapper = styled.div`
58
- height: 600px;
58
+ height: 1200px;
59
59
  `;
60
60
 
61
61
  const OtherContent = styled.div`
@@ -80,7 +80,7 @@ const StyledButton = styled(Button)`
80
80
  `;
81
81
 
82
82
  const StyledWrapper = styled.div`
83
- height: 300px;
83
+ height: 1200px;
84
84
  `;
85
85
 
86
86
  const Content = styled.div`
@@ -55,7 +55,7 @@ const StyledButton = styled(Button)`
55
55
  `;
56
56
 
57
57
  const StyledWrapper = styled.div`
58
- height: 600px;
58
+ height: 1200px;
59
59
  `;
60
60
 
61
61
  const OtherContent = styled.div`
@@ -37,17 +37,20 @@ export function App() {
37
37
 
38
38
  ### Формат даты
39
39
  Формат даты задается с помощью свойства `format`.
40
- | Обозначение | Отображение | Описание |
41
- |-------------|-------------|---------------------|
42
- | DD | 01-31 | Дни месяца, 2 цифры |
43
- | D | 1-31 | Дни месяца |
44
- | MM | 01-12 | Месяц года, 2 цифры |
45
- | M | 1-12 | Месяц года |
46
- | YYYY | 2024 | Год из 4 цифр |
47
- | YY | 24 | Год из 2 цифр |
48
- | Q | 1-4 | Квартал |
40
+ | Обозначение | Отображение | Описание |
41
+ |-------------|---------------------------------------|----------------------------------|
42
+ | DD | 01-31 | Дни месяца, 2 цифры |
43
+ | D | 1-31 | Дни месяца |
44
+ | MMMM | January...December / январь...декабрь | Месяц года, полное название |
45
+ | MMM | Jan...Dec / янв.-дек. | Месяц года, сокращенное название |
46
+ | MM | 01-12 | Месяц года, 2 цифры |
47
+ | M | 1-12 | Месяц года |
48
+ | YYYY | 2024 | Год из 4 цифр |
49
+ | YY | 24 | Год из 2 цифр |
50
+ | Q | 1-4 | Квартал |
51
+
49
52
  При выборе даты в календаре или вводе даты через поле ввода, дата будет приводиться к заданному формату.
50
- Свойство `maskWithFormat` позволяет маскировать ввод:
53
+ Свойство `maskWithFormat` позволяет маскировать ввод, кроме случаев когда месяц имеет формат полной записи MMMM:
51
54
 
52
55
  ```tsx live
53
56
  import React from 'react';
@@ -113,7 +113,11 @@ export var datePickerRangeRoot = function datePickerRangeRoot(Root) {
113
113
  _useState8 = _slicedToArray(_useState7, 2),
114
114
  calendarFirstValue = _useState8[0],
115
115
  setCalendarFirstValue = _useState8[1];
116
- var _useState9 = useState(formatInputValue(defaultFirstDate, format, lang)),
116
+ var _useState9 = useState(formatInputValue({
117
+ value: defaultFirstDate,
118
+ format: format,
119
+ lang: lang
120
+ })),
117
121
  _useState10 = _slicedToArray(_useState9, 2),
118
122
  inputFirstValue = _useState10[0],
119
123
  setInputFirstValue = _useState10[1];
@@ -121,7 +125,11 @@ export var datePickerRangeRoot = function datePickerRangeRoot(Root) {
121
125
  _useState12 = _slicedToArray(_useState11, 2),
122
126
  calendarSecondValue = _useState12[0],
123
127
  setCalendarSecondValue = _useState12[1];
124
- var _useState13 = useState(formatInputValue(defaultSecondDate, format, lang)),
128
+ var _useState13 = useState(formatInputValue({
129
+ value: defaultSecondDate,
130
+ format: format,
131
+ lang: lang
132
+ })),
125
133
  _useState14 = _slicedToArray(_useState13, 2),
126
134
  inputSecondValue = _useState14[0],
127
135
  setInputSecondValue = _useState14[1];
@@ -240,17 +248,33 @@ export var datePickerRangeRoot = function datePickerRangeRoot(Root) {
240
248
  }, [opened]);
241
249
  useEffect(function () {
242
250
  setCalendarFirstValue(formatCalendarValue(defaultFirstDate, format, lang));
243
- setInputFirstValue(formatInputValue(defaultFirstDate, format, lang));
251
+ setInputFirstValue(formatInputValue({
252
+ value: defaultFirstDate,
253
+ format: format,
254
+ lang: lang
255
+ }));
244
256
  }, [defaultFirstDate]);
245
257
  useEffect(function () {
246
258
  setCalendarSecondValue(formatCalendarValue(defaultSecondDate, format, lang));
247
- setInputSecondValue(formatInputValue(defaultSecondDate, format, lang));
259
+ setInputSecondValue(formatInputValue({
260
+ value: defaultSecondDate,
261
+ format: format,
262
+ lang: lang
263
+ }));
248
264
  }, [defaultSecondDate]);
249
265
  useEffect(function () {
250
266
  setCalendarFirstValue(formatCalendarValue(defaultFirstDate, format, lang));
251
- setInputFirstValue(formatInputValue(defaultFirstDate, format, lang));
267
+ setInputFirstValue(formatInputValue({
268
+ value: defaultFirstDate,
269
+ format: format,
270
+ lang: lang
271
+ }));
252
272
  setCalendarSecondValue(formatCalendarValue(defaultSecondDate, format, lang));
253
- setInputSecondValue(formatInputValue(defaultSecondDate, format, lang));
273
+ setInputSecondValue(formatInputValue({
274
+ value: defaultSecondDate,
275
+ format: format,
276
+ lang: lang
277
+ }));
254
278
  }, [format, lang]);
255
279
  return /*#__PURE__*/React.createElement(Root, _extends({
256
280
  ref: rootRef,
@@ -83,7 +83,11 @@ export var datePickerRoot = function datePickerRoot(Root) {
83
83
  _useState4 = _slicedToArray(_useState3, 2),
84
84
  calendarValue = _useState4[0],
85
85
  setCalendarValue = _useState4[1];
86
- var _useState5 = useState(formatInputValue(defaultDate, format, lang)),
86
+ var _useState5 = useState(formatInputValue({
87
+ value: defaultDate,
88
+ format: format,
89
+ lang: lang
90
+ })),
87
91
  _useState6 = _slicedToArray(_useState5, 2),
88
92
  inputValue = _useState6[0],
89
93
  setInputValue = _useState6[1];
@@ -149,11 +153,19 @@ export var datePickerRoot = function datePickerRoot(Root) {
149
153
  }, [opened]);
150
154
  useEffect(function () {
151
155
  setCalendarValue(formatCalendarValue(defaultDate, format, lang));
152
- setInputValue(formatInputValue(defaultDate, format, lang));
156
+ setInputValue(formatInputValue({
157
+ value: defaultDate,
158
+ format: format,
159
+ lang: lang
160
+ }));
153
161
  }, [defaultDate]);
154
162
  useEffect(function () {
155
163
  setCalendarValue(formatCalendarValue(defaultDate, format, lang));
156
- setInputValue(formatInputValue(defaultDate, format, lang));
164
+ setInputValue(formatInputValue({
165
+ value: defaultDate,
166
+ format: format,
167
+ lang: lang
168
+ }));
157
169
  }, [format, lang]);
158
170
  return /*#__PURE__*/React.createElement(Root, _extends({
159
171
  view: view,
@@ -1,5 +1,6 @@
1
1
  import { classes } from '../DatePicker.tokens';
2
2
  import { formatCalendarValue, formatInputValue, getDateFromFormat, getMaskedDateOnInput } from '../utils/dateHelper';
3
+ import { customDayjs } from '../../../utils/datejs';
3
4
  export var useDatePicker = function useDatePicker(_ref) {
4
5
  var currentValue = _ref.currentValue,
5
6
  setInputValue = _ref.setInputValue,
@@ -38,10 +39,43 @@ export var useDatePicker = function useDatePicker(_ref) {
38
39
  var newValue = maskWithFormat ? getMaskedDateOnInput(value, format, dateFormatDelimiter(), currentValue) : value;
39
40
  if (!format) {
40
41
  setCalendarValue(formatCalendarValue(newValue));
41
- } else if ((newValue === null || newValue === void 0 ? void 0 : newValue.length) === format.length) {
42
+ setInputValue(formatInputValue({
43
+ value: newValue,
44
+ format: format,
45
+ lang: lang
46
+ }));
47
+ onChangeValue === null || onChangeValue === void 0 || onChangeValue(event, newValue);
48
+ return;
49
+ }
50
+
51
+ /**
52
+ * NOTE: если в формате даты есть месяц в полном названии или сокращенном,
53
+ * нужно дополнительно проводить валидацию на полноту введенной даты.
54
+ * Иначе dayjs циклически будет пытаться отформатировать некорректную дату.
55
+ */
56
+ var hasMonthFullName = /M{3,4}/g.test(format);
57
+ var isValidMonth;
58
+ var isLengthEqual;
59
+ if (hasMonthFullName) {
60
+ customDayjs.locale(lang);
61
+ var firstIndexOfMonth = format.indexOf('M');
62
+ var lastIndexOfMonth = newValue.indexOf(dateFormatDelimiter(), firstIndexOfMonth);
63
+ var fullMonthName = !lastIndexOfMonth ? newValue.slice(firstIndexOfMonth) : newValue.slice(firstIndexOfMonth, lastIndexOfMonth);
64
+ var monthFormatting = format.replace(/[^M]/g, '');
65
+ isValidMonth = customDayjs("01 ".concat(fullMonthName, " 1970"), "DD ".concat(monthFormatting, " YYYY"), true).isValid();
66
+ isLengthEqual = format.length - monthFormatting.length === newValue.length - fullMonthName.length;
67
+ }
68
+ if (!hasMonthFullName && (newValue === null || newValue === void 0 ? void 0 : newValue.length) === (format === null || format === void 0 ? void 0 : format.length) || isValidMonth && isLengthEqual) {
42
69
  setCalendarValue(formatCalendarValue(newValue, format, lang));
43
70
  }
44
- setInputValue(formatInputValue(newValue, format, lang));
71
+ setInputValue(formatInputValue({
72
+ value: newValue,
73
+ format: format,
74
+ lang: lang,
75
+ hasMonthFullName: hasMonthFullName,
76
+ isValidMonth: isValidMonth,
77
+ isLengthEqual: isLengthEqual
78
+ }));
45
79
  onChangeValue === null || onChangeValue === void 0 || onChangeValue(event, newValue);
46
80
  };
47
81
  var handleCommitDate = function handleCommitDate(date, applyFormat, isCalendarValue, dateInfo) {
@@ -55,8 +89,13 @@ export var useDatePicker = function useDatePicker(_ref) {
55
89
  }
56
90
  if (isCalendarValue) {
57
91
  setCalendarValue(formatCalendarValue(date, format, lang));
58
- setInputValue(formatInputValue(date, format, lang));
59
- return onCommitDate === null || onCommitDate === void 0 ? void 0 : onCommitDate(date, false, true, dateInfo);
92
+ setInputValue(formatInputValue({
93
+ value: date,
94
+ format: format,
95
+ lang: lang
96
+ }));
97
+ onCommitDate === null || onCommitDate === void 0 || onCommitDate(date, false, true, dateInfo);
98
+ return;
60
99
  }
61
100
  var formatString = applyFormat ? format : undefined;
62
101
  var _getDateFromFormat = getDateFromFormat(date, formatString, lang),
@@ -64,7 +103,11 @@ export var useDatePicker = function useDatePicker(_ref) {
64
103
  isError = _getDateFromFormat.isError,
65
104
  isSuccess = _getDateFromFormat.isSuccess;
66
105
  setCalendarValue(formatCalendarValue(newDate, format, lang));
67
- setInputValue(formatInputValue(newDate, format, lang));
106
+ setInputValue(formatInputValue({
107
+ value: newDate,
108
+ format: format,
109
+ lang: lang
110
+ }));
68
111
  onCommitDate === null || onCommitDate === void 0 || onCommitDate(newDate, isError, isSuccess);
69
112
  };
70
113
  return {
@@ -1,8 +1,17 @@
1
1
  import { customDayjs } from '../../../utils/datejs';
2
- export var formatInputValue = function formatInputValue(value, format, lang) {
2
+ export var formatInputValue = function formatInputValue(_ref) {
3
+ var value = _ref.value,
4
+ format = _ref.format,
5
+ lang = _ref.lang,
6
+ hasMonthFullName = _ref.hasMonthFullName,
7
+ isValidMonth = _ref.isValidMonth,
8
+ isLengthEqual = _ref.isLengthEqual;
3
9
  if (!value || !lang) {
4
10
  return '';
5
11
  }
12
+ if (hasMonthFullName && (!isValidMonth || !isLengthEqual)) {
13
+ return String(value);
14
+ }
6
15
  if (format && customDayjs(value, format, true).isValid()) {
7
16
  return customDayjs(value, format).locale(lang).format(format);
8
17
  }
@@ -56,7 +65,7 @@ export var getMaskedDateOnInput = function getMaskedDateOnInput(value, format, d
56
65
  if (!value) {
57
66
  return '';
58
67
  }
59
- if (!format || !delimiter) {
68
+ if (!format || !delimiter || /M{3,4}/g.test(format)) {
60
69
  return value;
61
70
  }
62
71
  if (value.length >= format.length) {
@@ -8,8 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
- import React, { forwardRef, useRef } from 'react';
12
- import ReactDOM from 'react-dom';
11
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
13
12
  import { useForkRef, safeUseId } from '@salutejs/plasma-core';
14
13
  import { cx } from '../../utils';
15
14
  import { Portal } from '../Portal';
@@ -17,7 +16,6 @@ import { POPUP_PORTAL_ID } from './PopupContext';
17
16
  import { PopupRoot } from './PopupRoot';
18
17
  import { usePopup } from './hooks';
19
18
  import { classes } from './Popup.tokens';
20
- import { StyledPortalContainer } from './Popup.styles';
21
19
  export var handlePosition = function handlePosition(placement, offset) {
22
20
  var x = '0rem';
23
21
  var y = '0rem';
@@ -41,8 +39,8 @@ export var handlePosition = function handlePosition(placement, offset) {
41
39
  var bottom;
42
40
  var transform;
43
41
  var placements = placement.split('-');
44
- placements.forEach(function (placementValue) {
45
- switch (placementValue) {
42
+ placements.forEach(function (placement) {
43
+ switch (placement) {
46
44
  case 'left':
47
45
  left = x;
48
46
  break;
@@ -75,139 +73,9 @@ export var handlePosition = function handlePosition(placement, offset) {
75
73
  transform: transform
76
74
  };
77
75
  };
78
- /*
79
- const getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {
80
- if (typeof frame !== 'string' && frame && frame.current) {
81
- portalRef.current = frame.current;
82
- return;
83
- }
84
-
85
- if (typeof frame === 'string' && frame !== 'document') {
86
- const element = document.getElementById(frame);
87
- if (element) {
88
- const portal = document.createElement('div');
89
- portal.className = 'frame-portal';
90
- portal.style.position = 'relative';
91
- portal.style.width = '0';
92
-
93
- element.appendChild(portal);
94
- portalRef.current = portal;
95
-
96
- return;
97
- //
98
- // const portal = document?.querySelector('.frame-portal');
99
- // if (!portal) {
100
- // portal = document.createElement('div');
101
- // document.getElementById(frame)?.appendChild(portal);
102
- // }
103
- // return portal;
104
- }
105
- }
106
-
107
- const portal = document.getElementById(POPUP_PORTAL_ID);
108
-
109
- if (!portal) {
110
- ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
111
- }
112
-
113
- portalRef.current = portal;
114
-
115
- let portal;
116
-
117
- const hasFrame = typeof frame !== 'string' && frame && frame.current;
118
- if (hasFrame) {
119
- portal = frame.current;
120
- } else {
121
- // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
122
-
123
- portal = document.getElementById(POPUP_PORTAL_ID);
124
-
125
- if (!portal) {
126
- if (typeof frame === 'string' && frame !== 'document') {
127
- portal = document.createElement('div');
128
- document.getElementById(frame)?.appendChild(portal);
129
- } else {
130
- portal.className('frame-portal');
131
- document.body.appendChild(portal);
132
- // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
133
- }
134
- }
135
- }
136
-
137
- };
138
-
139
- const usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {
140
- const portalRef = useRef<HTMLDivElement | null>(null);
141
-
142
- if (typeof frame !== 'string' && frame && frame.current) {
143
- return frame.current;
144
- }
145
-
146
- if (typeof frame === 'string' && frame !== 'document') {
147
- const element = document.getElementById(frame);
148
-
149
- const portal = document?.querySelector('.frame-portal');
150
-
151
- if (portal) {
152
- return portal;
153
- }
154
-
155
- if (element) {
156
- const portal = document.createElement('div');
157
- portal.className = 'frame-portal';
158
- portal.style.position = 'relative';
159
- // portal.style.width = '0';
160
-
161
- element.appendChild(portal);
162
- return portal;
163
- //
164
- // const portal = document?.querySelector('.frame-portal');
165
- // if (!portal) {
166
- // portal = document.createElement('div');
167
- // document.getElementById(frame)?.appendChild(portal);
168
- // }
169
- // return portal;
170
- }
171
- }
172
-
173
- const portal = document.getElementById(POPUP_PORTAL_ID);
174
-
175
- if (!portal) {
176
- const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
177
-
178
- console.log('!!! res', res);
179
- }
180
-
181
- console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));
182
- return portalRef.current;
183
-
184
- let portal;
185
-
186
- const hasFrame = typeof frame !== 'string' && frame && frame.current;
187
- if (hasFrame) {
188
- portal = frame.current;
189
- } else {
190
- // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
191
-
192
- portal = document.getElementById(POPUP_PORTAL_ID);
193
-
194
- if (!portal) {
195
- if (typeof frame === 'string' && frame !== 'document') {
196
- portal = document.createElement('div');
197
- document.getElementById(frame)?.appendChild(portal);
198
- } else {
199
- portal.className('frame-portal');
200
- document.body.appendChild(portal);
201
- // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
202
- }
203
- }
204
- }
205
-
206
- };
207
- */
208
76
 
209
77
  /**
210
- * Базовый компонент Popup.
78
+ * Базовый копмонент Popup.
211
79
  */
212
80
  export var popupRoot = function popupRoot(Root) {
213
81
  return /*#__PURE__*/forwardRef(function (_ref, outerRootRef) {
@@ -246,11 +114,44 @@ export var popupRoot = function popupRoot(Root) {
246
114
  var portalRef = useRef(null);
247
115
  var contentRef = useRef(null);
248
116
  var innerRef = useForkRef(contentRef, outerRootRef);
117
+ var _useState = useState(false),
118
+ _useState2 = _slicedToArray(_useState, 2),
119
+ forceRender = _useState2[1];
120
+ useEffect(function () {
121
+ var portal = document.getElementById(POPUP_PORTAL_ID);
122
+ if (typeof frame !== 'string' && frame && frame.current) {
123
+ portal = frame.current;
124
+ }
125
+ if (!portal) {
126
+ portal = document.createElement('div');
127
+ portal.setAttribute('id', POPUP_PORTAL_ID);
128
+ /**
129
+ * Нужно для того, чтобы во фрейме не происходило скачков контента
130
+ * при анимации через transform, если есть элемент с шириной/высотой в 100% (Overlay)
131
+ */
132
+ portal.style.width = '0';
133
+ if (typeof frame === 'string' && frame !== 'document') {
134
+ var _document$getElementB;
135
+ (_document$getElementB = document.getElementById(frame)) === null || _document$getElementB === void 0 || _document$getElementB.appendChild(portal);
136
+ } else {
137
+ document.body.appendChild(portal);
138
+ }
139
+ }
140
+ portalRef.current = portal;
141
+
142
+ /**
143
+ * Изменение стейта нужно для того, чтобы Popup
144
+ * отобразился после записи DOM элемента в portalRef.current
145
+ */
146
+ forceRender(true);
147
+ }, []);
249
148
  if (!isVisible && !innerIsOpen) {
250
149
  return null;
251
150
  }
252
151
  var cls = cx(className, animationInfo !== null && animationInfo !== void 0 && animationInfo.endAnimation ? classes.endAnimation : '', animationInfo !== null && animationInfo !== void 0 && animationInfo.endTransition ? classes.endTransition : '');
253
- var rootNode = /*#__PURE__*/React.createElement(Root, _extends({
152
+ return /*#__PURE__*/React.createElement(React.Fragment, null, portalRef.current && /*#__PURE__*/React.createElement(Portal, {
153
+ container: portalRef.current
154
+ }, /*#__PURE__*/React.createElement(Root, _extends({
254
155
  className: cls
255
156
  }, rest), overlay, /*#__PURE__*/React.createElement(PopupRoot, {
256
157
  id: innerId,
@@ -260,25 +161,7 @@ export var popupRoot = function popupRoot(Root) {
260
161
  zIndex: zIndex,
261
162
  animationInfo: animationInfo,
262
163
  setVisible: setVisible
263
- }, children));
264
- if (typeof frame !== 'string' && frame && frame.current) {
265
- return /*#__PURE__*/React.createElement(Portal, {
266
- container: frame.current
267
- }, rootNode);
268
- }
269
- var withFrameId = typeof frame === 'string' && frame !== 'document';
270
- var containerElement = withFrameId && document.getElementById(frame);
271
- if (containerElement) {
272
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(StyledPortalContainer, {
273
- ref: portalRef
274
- }, portalRef.current && /*#__PURE__*/React.createElement(Portal, {
275
- container: portalRef.current
276
- }, rootNode)), containerElement));
277
- }
278
- var globalPortal = typeof document !== 'undefined' && document.getElementById(POPUP_PORTAL_ID);
279
- return /*#__PURE__*/React.createElement(React.Fragment, null, globalPortal && /*#__PURE__*/React.createElement(Portal, {
280
- container: globalPortal
281
- }, rootNode));
164
+ }, children))));
282
165
  });
283
166
  };
284
167
  export var popupConfig = {
@@ -2,15 +2,12 @@ import styled from 'styled-components';
2
2
  import { DEFAULT_Z_INDEX } from './utils';
3
3
  export var StyledPortal = /*#__PURE__*/styled.div.withConfig({
4
4
  componentId: "plasma-new-hope__sc-rkhnjn-0"
5
- })(["position:fixed;top:0;left:0;right:0;bottom:0;:empty{width:0;pointer-events:none;}:not(:empty){width:auto;pointer-events:auto;}"]);
6
- export var StyledPortalContainer = /*#__PURE__*/styled.div.withConfig({
7
- componentId: "plasma-new-hope__sc-rkhnjn-1"
8
- })(["width:0;"]);
5
+ })([""]);
9
6
  export var PopupView = /*#__PURE__*/styled.div.withConfig({
10
- componentId: "plasma-new-hope__sc-rkhnjn-2"
7
+ componentId: "plasma-new-hope__sc-rkhnjn-1"
11
8
  })(["position:relative;max-width:100%;pointer-events:all;"]);
12
9
  export var PopupRootContainer = /*#__PURE__*/styled.div.withConfig({
13
- componentId: "plasma-new-hope__sc-rkhnjn-3"
10
+ componentId: "plasma-new-hope__sc-rkhnjn-2"
14
11
  })(["position:absolute;z-index:", ";left:", ";right:", ";top:", ";bottom:", ";transform:", ";"], function (_ref) {
15
12
  var zIndex = _ref.zIndex;
16
13
  return zIndex || DEFAULT_Z_INDEX;
@@ -1,4 +1,3 @@
1
- var _StyledPortal;
2
1
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
2
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
3
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -9,19 +8,15 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
9
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
- import React, { createContext, useState, useContext, useRef } from 'react';
13
- import ReactDOM from 'react-dom';
11
+ import React, { createContext, useEffect, useState, useContext, useRef } from 'react';
14
12
  import { hasModals } from '../Modal/ModalContext';
15
- import { StyledPortal } from './Popup.styles';
16
13
  export var POPUP_PORTAL_ID = 'plasma-popup-root';
17
14
  var items = [];
18
15
  var PopupContext = /*#__PURE__*/createContext({
19
16
  items: items,
20
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
17
  register: function register(_info) {
22
18
  throw new Error('Function not implemented. Add PopupProvider');
23
19
  },
24
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
20
  unregister: function unregister(_id) {
26
21
  throw new Error('Function not implemented. Add PopupProvider');
27
22
  }
@@ -32,7 +27,6 @@ export var usePopupContext = function usePopupContext() {
32
27
  export var PopupProvider = function PopupProvider(_ref) {
33
28
  var children = _ref.children;
34
29
  var prevBodyOverflowY = useRef(typeof document !== 'undefined' ? document.body.style.overflowY : '');
35
- // eslint-disable-next-line no-shadow
36
30
  var _useState = useState([]),
37
31
  _useState2 = _slicedToArray(_useState, 2),
38
32
  items = _useState2[0],
@@ -70,9 +64,15 @@ export var PopupProvider = function PopupProvider(_ref) {
70
64
  register: register,
71
65
  unregister: unregister
72
66
  };
67
+ useEffect(function () {
68
+ return function () {
69
+ var portal = document.createElement('div');
70
+ if (portal && document.body.contains(portal)) {
71
+ document.body.removeChild(portal);
72
+ }
73
+ };
74
+ }, []);
73
75
  return /*#__PURE__*/React.createElement(PopupContext.Provider, {
74
76
  value: context
75
- }, children, /*#__PURE__*/ReactDOM.createPortal(_StyledPortal || (_StyledPortal = /*#__PURE__*/React.createElement(StyledPortal, {
76
- id: POPUP_PORTAL_ID
77
- })), document.body));
77
+ }, children);
78
78
  };
@@ -13,7 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { useEffect, useState } from 'react';
14
14
  import { usePopupContext } from '../PopupContext';
15
15
 
16
- // Хук для подключения анимации
16
+ // Хук для поключения анимации
17
17
  var usePopupAnimation = function usePopupAnimation() {
18
18
  var _useState = useState(false),
19
19
  _useState2 = _slicedToArray(_useState, 2),
@@ -211,7 +211,7 @@ export const DrawerDemo: StoryObj<StoryDrawerProps> = {
211
211
  asModal: true,
212
212
  closePlacement: 'right',
213
213
  width: '25vw',
214
- height: '100vh',
214
+ height: '100dvh',
215
215
  borderRadius: 'none',
216
216
  },
217
217
  render: (args) => <StoryDrawerDemo {...args} />,
@@ -80,7 +80,7 @@ const StyledButton = styled(Button)`
80
80
  `;
81
81
 
82
82
  const StyledWrapper = styled.div`
83
- height: 300px;
83
+ height: 1200px;
84
84
  `;
85
85
 
86
86
  const Content = styled.div`
@@ -55,7 +55,7 @@ const StyledButton = styled(Button)`
55
55
  `;
56
56
 
57
57
  const StyledWrapper = styled.div`
58
- height: 600px;
58
+ height: 1200px;
59
59
  `;
60
60
 
61
61
  const OtherContent = styled.div`