@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.
- package/cjs/components/DatePicker/RangeDate/RangeDate.js +30 -6
- package/cjs/components/DatePicker/RangeDate/RangeDate.js.map +1 -1
- package/cjs/components/DatePicker/SingleDate/SingleDate.js +15 -3
- package/cjs/components/DatePicker/SingleDate/SingleDate.js.map +1 -1
- package/cjs/components/DatePicker/hooks/useDatePicker.js +48 -5
- package/cjs/components/DatePicker/hooks/useDatePicker.js.map +1 -1
- package/cjs/components/DatePicker/utils/dateHelper.js +11 -2
- package/cjs/components/DatePicker/utils/dateHelper.js.map +1 -1
- package/cjs/components/Drawer/Drawer.css +3 -4
- package/cjs/components/Drawer/Drawer.js +1 -1
- package/cjs/components/Drawer/Drawer.styles.js +0 -2
- package/cjs/components/Drawer/Drawer.styles.js.map +1 -1
- package/cjs/components/Drawer/hooks/useDrawer.js +1 -1
- package/cjs/components/Modal/Modal.css +3 -4
- package/cjs/components/Modal/hooks/useModal.js +1 -1
- package/cjs/components/Notification/NotificationsProvider.css +3 -4
- package/cjs/components/Popup/Popup.css +3 -0
- package/cjs/components/Popup/Popup.js +38 -155
- package/cjs/components/Popup/Popup.js.map +1 -1
- package/cjs/components/Popup/Popup.styles.js +9 -21
- package/cjs/components/Popup/Popup.styles.js.map +1 -1
- package/cjs/components/Popup/Popup.styles_141jyqa.css +3 -0
- package/cjs/components/Popup/PopupContext.js +9 -9
- package/cjs/components/Popup/PopupContext.js.map +1 -1
- package/cjs/components/Popup/hooks/usePopup.js +1 -1
- package/cjs/components/Popup/hooks/usePopup.js.map +1 -1
- package/cjs/index.css +3 -4
- package/emotion/cjs/components/DatePicker/DatePicker.template-doc.mdx +13 -10
- package/emotion/cjs/components/DatePicker/RangeDate/RangeDate.js +30 -6
- package/emotion/cjs/components/DatePicker/SingleDate/SingleDate.js +15 -3
- package/emotion/cjs/components/DatePicker/hooks/useDatePicker.js +48 -5
- package/emotion/cjs/components/DatePicker/utils/dateHelper.js +11 -2
- package/emotion/cjs/components/Popup/Popup.js +38 -156
- package/emotion/cjs/components/Popup/Popup.styles.js +5 -25
- package/emotion/cjs/components/Popup/PopupContext.js +9 -10
- package/emotion/cjs/components/Popup/hooks/usePopup.js +1 -1
- package/emotion/cjs/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
- package/emotion/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
- package/emotion/cjs/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
- package/emotion/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
- package/emotion/cjs/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
- package/emotion/es/components/DatePicker/DatePicker.template-doc.mdx +13 -10
- package/emotion/es/components/DatePicker/RangeDate/RangeDate.js +30 -6
- package/emotion/es/components/DatePicker/SingleDate/SingleDate.js +15 -3
- package/emotion/es/components/DatePicker/hooks/useDatePicker.js +48 -5
- package/emotion/es/components/DatePicker/utils/dateHelper.js +11 -2
- package/emotion/es/components/Popup/Popup.js +39 -156
- package/emotion/es/components/Popup/Popup.styles.js +4 -24
- package/emotion/es/components/Popup/PopupContext.js +10 -10
- package/emotion/es/components/Popup/hooks/usePopup.js +1 -1
- package/emotion/es/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
- package/emotion/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
- package/emotion/es/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
- package/emotion/es/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
- package/emotion/es/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
- package/es/components/DatePicker/RangeDate/RangeDate.js +30 -6
- package/es/components/DatePicker/RangeDate/RangeDate.js.map +1 -1
- package/es/components/DatePicker/SingleDate/SingleDate.js +15 -3
- package/es/components/DatePicker/SingleDate/SingleDate.js.map +1 -1
- package/es/components/DatePicker/hooks/useDatePicker.js +48 -5
- package/es/components/DatePicker/hooks/useDatePicker.js.map +1 -1
- package/es/components/DatePicker/utils/dateHelper.js +11 -2
- package/es/components/DatePicker/utils/dateHelper.js.map +1 -1
- package/es/components/Drawer/Drawer.css +3 -4
- package/es/components/Drawer/Drawer.js +1 -1
- package/es/components/Drawer/Drawer.styles.js +0 -2
- package/es/components/Drawer/Drawer.styles.js.map +1 -1
- package/es/components/Drawer/hooks/useDrawer.js +1 -1
- package/es/components/Modal/Modal.css +3 -4
- package/es/components/Modal/hooks/useModal.js +1 -1
- package/es/components/Notification/NotificationsProvider.css +3 -4
- package/es/components/Popup/Popup.css +3 -0
- package/es/components/Popup/Popup.js +40 -157
- package/es/components/Popup/Popup.js.map +1 -1
- package/es/components/Popup/Popup.styles.js +10 -20
- package/es/components/Popup/Popup.styles.js.map +1 -1
- package/es/components/Popup/Popup.styles_141jyqa.css +3 -0
- package/es/components/Popup/PopupContext.js +10 -10
- package/es/components/Popup/PopupContext.js.map +1 -1
- package/es/components/Popup/hooks/usePopup.js +1 -1
- package/es/components/Popup/hooks/usePopup.js.map +1 -1
- package/es/index.css +3 -4
- package/package.json +4 -4
- package/styled-components/cjs/components/DatePicker/DatePicker.template-doc.mdx +13 -10
- package/styled-components/cjs/components/DatePicker/RangeDate/RangeDate.js +30 -6
- package/styled-components/cjs/components/DatePicker/SingleDate/SingleDate.js +15 -3
- package/styled-components/cjs/components/DatePicker/hooks/useDatePicker.js +48 -5
- package/styled-components/cjs/components/DatePicker/utils/dateHelper.js +11 -2
- package/styled-components/cjs/components/Popup/Popup.js +38 -156
- package/styled-components/cjs/components/Popup/Popup.styles.js +4 -7
- package/styled-components/cjs/components/Popup/PopupContext.js +9 -10
- package/styled-components/cjs/components/Popup/hooks/usePopup.js +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
- package/styled-components/es/components/DatePicker/DatePicker.template-doc.mdx +13 -10
- package/styled-components/es/components/DatePicker/RangeDate/RangeDate.js +30 -6
- package/styled-components/es/components/DatePicker/SingleDate/SingleDate.js +15 -3
- package/styled-components/es/components/DatePicker/hooks/useDatePicker.js +48 -5
- package/styled-components/es/components/DatePicker/utils/dateHelper.js +11 -2
- package/styled-components/es/components/Popup/Popup.js +39 -156
- package/styled-components/es/components/Popup/Popup.styles.js +3 -6
- package/styled-components/es/components/Popup/PopupContext.js +10 -10
- package/styled-components/es/components/Popup/hooks/usePopup.js +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
- package/styled-components/es/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
- package/styled-components/es/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
- package/types/components/DatePicker/RangeDate/RangeDate.d.ts.map +1 -1
- package/types/components/DatePicker/hooks/useDatePicker.d.ts.map +1 -1
- package/types/components/DatePicker/utils/dateHelper.d.ts +10 -1
- package/types/components/DatePicker/utils/dateHelper.d.ts.map +1 -1
- package/types/components/Popup/Popup.d.ts +1 -1
- package/types/components/Popup/Popup.d.ts.map +1 -1
- package/types/components/Popup/Popup.styles.d.ts +0 -1
- package/types/components/Popup/Popup.styles.d.ts.map +1 -1
- package/types/components/Popup/PopupContext.d.ts.map +1 -1
- package/cjs/components/Popup/Popup.styles_8h77g1.css +0 -4
- package/cjs/components/Popup/PopupContext.css +0 -4
- package/es/components/Popup/Popup.styles_8h77g1.css +0 -4
- package/es/components/Popup/PopupContext.css +0 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usePopup.js","sources":["../../../../src/components/Popup/hooks/usePopup.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { PopupAnimationInfo, PopupHookArgs } from '../Popup.types';\nimport { usePopupContext } from '../PopupContext';\n\n// Хук для
|
1
|
+
{"version":3,"file":"usePopup.js","sources":["../../../../src/components/Popup/hooks/usePopup.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { PopupAnimationInfo, PopupHookArgs } from '../Popup.types';\nimport { usePopupContext } from '../PopupContext';\n\n// Хук для поключения анимации\nconst usePopupAnimation = (): PopupAnimationInfo => {\n const [endAnimation, setEndAnimation] = useState<boolean>(false);\n const [endTransition, setEndTransition] = useState<boolean>(false);\n\n return { endAnimation, endTransition, setEndTransition, setEndAnimation };\n};\n\n// Хук для внутреннего состояния, необходимого для правильного отображения вложенных окон, а также для анимации\nexport const usePopup = ({ isOpen, id, popupInfo, withAnimation }: PopupHookArgs) => {\n const [isVisible, setVisible] = useState<boolean>(false);\n const popupController = usePopupContext();\n const animationInfo = usePopupAnimation();\n\n // для использования transition в качестве анимации\n useEffect(() => {\n if (withAnimation && animationInfo) {\n animationInfo.setEndTransition(!isVisible || animationInfo?.endAnimation);\n }\n }, [animationInfo, withAnimation, isVisible]);\n\n // сначала добавление/удаление из контекста, и только после этого отображение/скрытие\n useEffect(() => {\n // при первом открытии\n if (isOpen && !isVisible) {\n popupController.register({ id, ...popupInfo });\n setVisible(true);\n animationInfo.setEndAnimation(false);\n return;\n }\n\n if (isOpen || !isVisible) {\n return;\n }\n\n // если есть анимация - закрытие по окончании анимации\n if (withAnimation) {\n animationInfo.setEndAnimation(true);\n return;\n }\n\n // иначе обычное закрытие\n popupController.unregister(id);\n setVisible(false);\n }, [isOpen, isVisible, animationInfo]);\n\n useEffect(() => {\n return () => {\n popupController.unregister(id);\n };\n }, [id]);\n\n return { isVisible, setVisible, animationInfo, withAnimation };\n};\n"],"names":["usePopupAnimation","_useState","useState","_useState2","_slicedToArray","endAnimation","setEndAnimation","_useState3","_useState4","endTransition","setEndTransition","usePopup","_ref","isOpen","id","popupInfo","withAnimation","_useState5","_useState6","isVisible","setVisible","popupController","usePopupContext","animationInfo","useEffect","register","_objectSpread","unregister"],"mappings":"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"}
|
package/es/index.css
CHANGED
@@ -258,10 +258,9 @@
|
|
258
258
|
|
259
259
|
.Subtitle_styles_1plleej_b810c19__d9c54bce{font-family:var(--typo-font-family);font-size:var(--typo-font-size);font-style:var(--typo-font-style);-webkit-letter-spacing:var(--typo-font-letter-spacing);-moz-letter-spacing:var(--typo-font-letter-spacing);-ms-letter-spacing:var(--typo-font-letter-spacing);letter-spacing:var(--typo-font-letter-spacing);line-height:var(--typo-font-line-height);font-weight:var(--typo-font-weight);overflow-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;hyphens:auto;}
|
260
260
|
|
261
|
-
|
262
|
-
.
|
263
|
-
.
|
264
|
-
.Popup_styles_8h77g1_p1f40oul__4eb91f42{position:absolute;z-index:var(--p1f40oul-0);left:var(--p1f40oul-1);right:var(--p1f40oul-2);top:var(--p1f40oul-3);bottom:var(--p1f40oul-4);-webkit-transform:var(--p1f40oul-5);-ms-transform:var(--p1f40oul-5);transform:var(--p1f40oul-5);}
|
261
|
+
|
262
|
+
.Popup_styles_141jyqa_p1cjo3us__ed39c2a3{position:relative;max-width:100%;pointer-events:all;}
|
263
|
+
.Popup_styles_141jyqa_p5u7tqa__ed39c2a3{position:absolute;z-index:var(--p5u7tqa-0);left:var(--p5u7tqa-1);right:var(--p5u7tqa-2);top:var(--p5u7tqa-3);bottom:var(--p5u7tqa-4);-webkit-transform:var(--p5u7tqa-5);-ms-transform:var(--p5u7tqa-5);transform:var(--p5u7tqa-5);}
|
265
264
|
|
266
265
|
.NotificationsPortal_6417q6_s19gbs9t__4166aeb6 > .NotificationsPortal_6417q6_popupBaseRoot__4166aeb6{overflow:hidden;}
|
267
266
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.146.1-canary.
|
3
|
+
"version": "0.146.1-canary.1441.10902378762.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -80,7 +80,7 @@
|
|
80
80
|
"@rollup/plugin-babel": "^6.0.4",
|
81
81
|
"@rollup/plugin-commonjs": "^25.0.4",
|
82
82
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
83
|
-
"@salutejs/plasma-sb-utils": "0.177.1-canary.
|
83
|
+
"@salutejs/plasma-sb-utils": "0.177.1-canary.1441.10902378762.0",
|
84
84
|
"@storybook/addon-docs": "^7.6.17",
|
85
85
|
"@storybook/addon-essentials": "^7.6.17",
|
86
86
|
"@storybook/addons": "^7.6.17",
|
@@ -113,7 +113,7 @@
|
|
113
113
|
"@linaria/core": "5.0.2",
|
114
114
|
"@linaria/react": "5.0.3",
|
115
115
|
"@popperjs/core": "2.11.8",
|
116
|
-
"@salutejs/plasma-core": "1.179.0",
|
116
|
+
"@salutejs/plasma-core": "1.179.1-canary.1441.10902378762.0",
|
117
117
|
"dayjs": "1.11.11",
|
118
118
|
"focus-visible": "5.2.0",
|
119
119
|
"lodash.throttle": "4.1.1",
|
@@ -121,5 +121,5 @@
|
|
121
121
|
"react-popper": "2.3.0",
|
122
122
|
"storeon": "3.1.5"
|
123
123
|
},
|
124
|
-
"gitHead": "
|
124
|
+
"gitHead": "060b8d34a843d7e9a147a385291cde3867a9635c"
|
125
125
|
}
|
@@ -37,17 +37,20 @@ export function App() {
|
|
37
37
|
|
38
38
|
### Формат даты
|
39
39
|
Формат даты задается с помощью свойства `format`.
|
40
|
-
| Обозначение | Отображение
|
41
|
-
|
42
|
-
| DD | 01-31
|
43
|
-
| D | 1-31
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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';
|
@@ -122,7 +122,11 @@ var datePickerRangeRoot = exports.datePickerRangeRoot = function datePickerRange
|
|
122
122
|
_useState8 = _slicedToArray(_useState7, 2),
|
123
123
|
calendarFirstValue = _useState8[0],
|
124
124
|
setCalendarFirstValue = _useState8[1];
|
125
|
-
var _useState9 = (0, _react.useState)((0, _dateHelper.formatInputValue)(
|
125
|
+
var _useState9 = (0, _react.useState)((0, _dateHelper.formatInputValue)({
|
126
|
+
value: defaultFirstDate,
|
127
|
+
format: format,
|
128
|
+
lang: lang
|
129
|
+
})),
|
126
130
|
_useState10 = _slicedToArray(_useState9, 2),
|
127
131
|
inputFirstValue = _useState10[0],
|
128
132
|
setInputFirstValue = _useState10[1];
|
@@ -130,7 +134,11 @@ var datePickerRangeRoot = exports.datePickerRangeRoot = function datePickerRange
|
|
130
134
|
_useState12 = _slicedToArray(_useState11, 2),
|
131
135
|
calendarSecondValue = _useState12[0],
|
132
136
|
setCalendarSecondValue = _useState12[1];
|
133
|
-
var _useState13 = (0, _react.useState)((0, _dateHelper.formatInputValue)(
|
137
|
+
var _useState13 = (0, _react.useState)((0, _dateHelper.formatInputValue)({
|
138
|
+
value: defaultSecondDate,
|
139
|
+
format: format,
|
140
|
+
lang: lang
|
141
|
+
})),
|
134
142
|
_useState14 = _slicedToArray(_useState13, 2),
|
135
143
|
inputSecondValue = _useState14[0],
|
136
144
|
setInputSecondValue = _useState14[1];
|
@@ -249,17 +257,33 @@ var datePickerRangeRoot = exports.datePickerRangeRoot = function datePickerRange
|
|
249
257
|
}, [opened]);
|
250
258
|
(0, _react.useEffect)(function () {
|
251
259
|
setCalendarFirstValue((0, _dateHelper.formatCalendarValue)(defaultFirstDate, format, lang));
|
252
|
-
setInputFirstValue((0, _dateHelper.formatInputValue)(
|
260
|
+
setInputFirstValue((0, _dateHelper.formatInputValue)({
|
261
|
+
value: defaultFirstDate,
|
262
|
+
format: format,
|
263
|
+
lang: lang
|
264
|
+
}));
|
253
265
|
}, [defaultFirstDate]);
|
254
266
|
(0, _react.useEffect)(function () {
|
255
267
|
setCalendarSecondValue((0, _dateHelper.formatCalendarValue)(defaultSecondDate, format, lang));
|
256
|
-
setInputSecondValue((0, _dateHelper.formatInputValue)(
|
268
|
+
setInputSecondValue((0, _dateHelper.formatInputValue)({
|
269
|
+
value: defaultSecondDate,
|
270
|
+
format: format,
|
271
|
+
lang: lang
|
272
|
+
}));
|
257
273
|
}, [defaultSecondDate]);
|
258
274
|
(0, _react.useEffect)(function () {
|
259
275
|
setCalendarFirstValue((0, _dateHelper.formatCalendarValue)(defaultFirstDate, format, lang));
|
260
|
-
setInputFirstValue((0, _dateHelper.formatInputValue)(
|
276
|
+
setInputFirstValue((0, _dateHelper.formatInputValue)({
|
277
|
+
value: defaultFirstDate,
|
278
|
+
format: format,
|
279
|
+
lang: lang
|
280
|
+
}));
|
261
281
|
setCalendarSecondValue((0, _dateHelper.formatCalendarValue)(defaultSecondDate, format, lang));
|
262
|
-
setInputSecondValue((0, _dateHelper.formatInputValue)(
|
282
|
+
setInputSecondValue((0, _dateHelper.formatInputValue)({
|
283
|
+
value: defaultSecondDate,
|
284
|
+
format: format,
|
285
|
+
lang: lang
|
286
|
+
}));
|
263
287
|
}, [format, lang]);
|
264
288
|
return /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
265
289
|
ref: rootRef,
|
@@ -92,7 +92,11 @@ var datePickerRoot = exports.datePickerRoot = function datePickerRoot(Root) {
|
|
92
92
|
_useState4 = _slicedToArray(_useState3, 2),
|
93
93
|
calendarValue = _useState4[0],
|
94
94
|
setCalendarValue = _useState4[1];
|
95
|
-
var _useState5 = (0, _react.useState)((0, _dateHelper.formatInputValue)(
|
95
|
+
var _useState5 = (0, _react.useState)((0, _dateHelper.formatInputValue)({
|
96
|
+
value: defaultDate,
|
97
|
+
format: format,
|
98
|
+
lang: lang
|
99
|
+
})),
|
96
100
|
_useState6 = _slicedToArray(_useState5, 2),
|
97
101
|
inputValue = _useState6[0],
|
98
102
|
setInputValue = _useState6[1];
|
@@ -158,11 +162,19 @@ var datePickerRoot = exports.datePickerRoot = function datePickerRoot(Root) {
|
|
158
162
|
}, [opened]);
|
159
163
|
(0, _react.useEffect)(function () {
|
160
164
|
setCalendarValue((0, _dateHelper.formatCalendarValue)(defaultDate, format, lang));
|
161
|
-
setInputValue((0, _dateHelper.formatInputValue)(
|
165
|
+
setInputValue((0, _dateHelper.formatInputValue)({
|
166
|
+
value: defaultDate,
|
167
|
+
format: format,
|
168
|
+
lang: lang
|
169
|
+
}));
|
162
170
|
}, [defaultDate]);
|
163
171
|
(0, _react.useEffect)(function () {
|
164
172
|
setCalendarValue((0, _dateHelper.formatCalendarValue)(defaultDate, format, lang));
|
165
|
-
setInputValue((0, _dateHelper.formatInputValue)(
|
173
|
+
setInputValue((0, _dateHelper.formatInputValue)({
|
174
|
+
value: defaultDate,
|
175
|
+
format: format,
|
176
|
+
lang: lang
|
177
|
+
}));
|
166
178
|
}, [format, lang]);
|
167
179
|
return /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
168
180
|
view: view,
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.useDatePicker = void 0;
|
7
7
|
var _DatePicker = /*#__PURE__*/require("../DatePicker.tokens");
|
8
8
|
var _dateHelper = /*#__PURE__*/require("../utils/dateHelper");
|
9
|
+
var _datejs = /*#__PURE__*/require("../../../utils/datejs");
|
9
10
|
var useDatePicker = exports.useDatePicker = function useDatePicker(_ref) {
|
10
11
|
var currentValue = _ref.currentValue,
|
11
12
|
setInputValue = _ref.setInputValue,
|
@@ -44,10 +45,43 @@ var useDatePicker = exports.useDatePicker = function useDatePicker(_ref) {
|
|
44
45
|
var newValue = maskWithFormat ? (0, _dateHelper.getMaskedDateOnInput)(value, format, dateFormatDelimiter(), currentValue) : value;
|
45
46
|
if (!format) {
|
46
47
|
setCalendarValue((0, _dateHelper.formatCalendarValue)(newValue));
|
47
|
-
|
48
|
+
setInputValue((0, _dateHelper.formatInputValue)({
|
49
|
+
value: newValue,
|
50
|
+
format: format,
|
51
|
+
lang: lang
|
52
|
+
}));
|
53
|
+
onChangeValue === null || onChangeValue === void 0 || onChangeValue(event, newValue);
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* NOTE: если в формате даты есть месяц в полном названии или сокращенном,
|
59
|
+
* нужно дополнительно проводить валидацию на полноту введенной даты.
|
60
|
+
* Иначе dayjs циклически будет пытаться отформатировать некорректную дату.
|
61
|
+
*/
|
62
|
+
var hasMonthFullName = /M{3,4}/g.test(format);
|
63
|
+
var isValidMonth;
|
64
|
+
var isLengthEqual;
|
65
|
+
if (hasMonthFullName) {
|
66
|
+
_datejs.customDayjs.locale(lang);
|
67
|
+
var firstIndexOfMonth = format.indexOf('M');
|
68
|
+
var lastIndexOfMonth = newValue.indexOf(dateFormatDelimiter(), firstIndexOfMonth);
|
69
|
+
var fullMonthName = !lastIndexOfMonth ? newValue.slice(firstIndexOfMonth) : newValue.slice(firstIndexOfMonth, lastIndexOfMonth);
|
70
|
+
var monthFormatting = format.replace(/[^M]/g, '');
|
71
|
+
isValidMonth = (0, _datejs.customDayjs)("01 ".concat(fullMonthName, " 1970"), "DD ".concat(monthFormatting, " YYYY"), true).isValid();
|
72
|
+
isLengthEqual = format.length - monthFormatting.length === newValue.length - fullMonthName.length;
|
73
|
+
}
|
74
|
+
if (!hasMonthFullName && (newValue === null || newValue === void 0 ? void 0 : newValue.length) === (format === null || format === void 0 ? void 0 : format.length) || isValidMonth && isLengthEqual) {
|
48
75
|
setCalendarValue((0, _dateHelper.formatCalendarValue)(newValue, format, lang));
|
49
76
|
}
|
50
|
-
setInputValue((0, _dateHelper.formatInputValue)(
|
77
|
+
setInputValue((0, _dateHelper.formatInputValue)({
|
78
|
+
value: newValue,
|
79
|
+
format: format,
|
80
|
+
lang: lang,
|
81
|
+
hasMonthFullName: hasMonthFullName,
|
82
|
+
isValidMonth: isValidMonth,
|
83
|
+
isLengthEqual: isLengthEqual
|
84
|
+
}));
|
51
85
|
onChangeValue === null || onChangeValue === void 0 || onChangeValue(event, newValue);
|
52
86
|
};
|
53
87
|
var handleCommitDate = function handleCommitDate(date, applyFormat, isCalendarValue, dateInfo) {
|
@@ -61,8 +95,13 @@ var useDatePicker = exports.useDatePicker = function useDatePicker(_ref) {
|
|
61
95
|
}
|
62
96
|
if (isCalendarValue) {
|
63
97
|
setCalendarValue((0, _dateHelper.formatCalendarValue)(date, format, lang));
|
64
|
-
setInputValue((0, _dateHelper.formatInputValue)(
|
65
|
-
|
98
|
+
setInputValue((0, _dateHelper.formatInputValue)({
|
99
|
+
value: date,
|
100
|
+
format: format,
|
101
|
+
lang: lang
|
102
|
+
}));
|
103
|
+
onCommitDate === null || onCommitDate === void 0 || onCommitDate(date, false, true, dateInfo);
|
104
|
+
return;
|
66
105
|
}
|
67
106
|
var formatString = applyFormat ? format : undefined;
|
68
107
|
var _getDateFromFormat = (0, _dateHelper.getDateFromFormat)(date, formatString, lang),
|
@@ -70,7 +109,11 @@ var useDatePicker = exports.useDatePicker = function useDatePicker(_ref) {
|
|
70
109
|
isError = _getDateFromFormat.isError,
|
71
110
|
isSuccess = _getDateFromFormat.isSuccess;
|
72
111
|
setCalendarValue((0, _dateHelper.formatCalendarValue)(newDate, format, lang));
|
73
|
-
setInputValue((0, _dateHelper.formatInputValue)(
|
112
|
+
setInputValue((0, _dateHelper.formatInputValue)({
|
113
|
+
value: newDate,
|
114
|
+
format: format,
|
115
|
+
lang: lang
|
116
|
+
}));
|
74
117
|
onCommitDate === null || onCommitDate === void 0 || onCommitDate(newDate, isError, isSuccess);
|
75
118
|
};
|
76
119
|
return {
|
@@ -5,10 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.getMaskedDateOnInput = exports.getDateFromFormat = exports.getDateFormatDelimiter = exports.formatInputValue = exports.formatCalendarValue = void 0;
|
7
7
|
var _datejs = /*#__PURE__*/require("../../../utils/datejs");
|
8
|
-
var formatInputValue = exports.formatInputValue = function formatInputValue(
|
8
|
+
var formatInputValue = exports.formatInputValue = function formatInputValue(_ref) {
|
9
|
+
var value = _ref.value,
|
10
|
+
format = _ref.format,
|
11
|
+
lang = _ref.lang,
|
12
|
+
hasMonthFullName = _ref.hasMonthFullName,
|
13
|
+
isValidMonth = _ref.isValidMonth,
|
14
|
+
isLengthEqual = _ref.isLengthEqual;
|
9
15
|
if (!value || !lang) {
|
10
16
|
return '';
|
11
17
|
}
|
18
|
+
if (hasMonthFullName && (!isValidMonth || !isLengthEqual)) {
|
19
|
+
return String(value);
|
20
|
+
}
|
12
21
|
if (format && (0, _datejs.customDayjs)(value, format, true).isValid()) {
|
13
22
|
return (0, _datejs.customDayjs)(value, format).locale(lang).format(format);
|
14
23
|
}
|
@@ -62,7 +71,7 @@ var getMaskedDateOnInput = exports.getMaskedDateOnInput = function getMaskedDate
|
|
62
71
|
if (!value) {
|
63
72
|
return '';
|
64
73
|
}
|
65
|
-
if (!format || !delimiter) {
|
74
|
+
if (!format || !delimiter || /M{3,4}/g.test(format)) {
|
66
75
|
return value;
|
67
76
|
}
|
68
77
|
if (value.length >= format.length) {
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.popupRoot = exports.popupConfig = exports.handlePosition = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var _reactDom = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react-dom"));
|
10
9
|
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
11
10
|
var _utils = /*#__PURE__*/require("../../utils");
|
12
11
|
var _Portal = /*#__PURE__*/require("../Portal");
|
@@ -14,9 +13,7 @@ var _PopupContext = /*#__PURE__*/require("./PopupContext");
|
|
14
13
|
var _PopupRoot = /*#__PURE__*/require("./PopupRoot");
|
15
14
|
var _hooks = /*#__PURE__*/require("./hooks");
|
16
15
|
var _Popup = /*#__PURE__*/require("./Popup.tokens");
|
17
|
-
var _Popup2 = /*#__PURE__*/require("./Popup.styles");
|
18
16
|
var _excluded = ["id", "isOpen", "opened", "placement", "offset", "frame", "children", "overlay", "role", "zIndex", "popupInfo", "withAnimation", "className"];
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
20
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
21
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
22
19
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -51,8 +48,8 @@ var handlePosition = exports.handlePosition = function handlePosition(placement,
|
|
51
48
|
var bottom;
|
52
49
|
var transform;
|
53
50
|
var placements = placement.split('-');
|
54
|
-
placements.forEach(function (
|
55
|
-
switch (
|
51
|
+
placements.forEach(function (placement) {
|
52
|
+
switch (placement) {
|
56
53
|
case 'left':
|
57
54
|
left = x;
|
58
55
|
break;
|
@@ -85,139 +82,9 @@ var handlePosition = exports.handlePosition = function handlePosition(placement,
|
|
85
82
|
transform: transform
|
86
83
|
};
|
87
84
|
};
|
88
|
-
/*
|
89
|
-
const getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {
|
90
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
91
|
-
portalRef.current = frame.current;
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
|
95
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
96
|
-
const element = document.getElementById(frame);
|
97
|
-
if (element) {
|
98
|
-
const portal = document.createElement('div');
|
99
|
-
portal.className = 'frame-portal';
|
100
|
-
portal.style.position = 'relative';
|
101
|
-
portal.style.width = '0';
|
102
|
-
|
103
|
-
element.appendChild(portal);
|
104
|
-
portalRef.current = portal;
|
105
|
-
|
106
|
-
return;
|
107
|
-
//
|
108
|
-
// const portal = document?.querySelector('.frame-portal');
|
109
|
-
// if (!portal) {
|
110
|
-
// portal = document.createElement('div');
|
111
|
-
// document.getElementById(frame)?.appendChild(portal);
|
112
|
-
// }
|
113
|
-
// return portal;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
118
|
-
|
119
|
-
if (!portal) {
|
120
|
-
ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
121
|
-
}
|
122
|
-
|
123
|
-
portalRef.current = portal;
|
124
|
-
|
125
|
-
let portal;
|
126
|
-
|
127
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
128
|
-
if (hasFrame) {
|
129
|
-
portal = frame.current;
|
130
|
-
} else {
|
131
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
132
|
-
|
133
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
134
|
-
|
135
|
-
if (!portal) {
|
136
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
137
|
-
portal = document.createElement('div');
|
138
|
-
document.getElementById(frame)?.appendChild(portal);
|
139
|
-
} else {
|
140
|
-
portal.className('frame-portal');
|
141
|
-
document.body.appendChild(portal);
|
142
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
};
|
148
|
-
|
149
|
-
const usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {
|
150
|
-
const portalRef = useRef<HTMLDivElement | null>(null);
|
151
|
-
|
152
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
153
|
-
return frame.current;
|
154
|
-
}
|
155
|
-
|
156
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
157
|
-
const element = document.getElementById(frame);
|
158
|
-
|
159
|
-
const portal = document?.querySelector('.frame-portal');
|
160
|
-
|
161
|
-
if (portal) {
|
162
|
-
return portal;
|
163
|
-
}
|
164
|
-
|
165
|
-
if (element) {
|
166
|
-
const portal = document.createElement('div');
|
167
|
-
portal.className = 'frame-portal';
|
168
|
-
portal.style.position = 'relative';
|
169
|
-
// portal.style.width = '0';
|
170
|
-
|
171
|
-
element.appendChild(portal);
|
172
|
-
return portal;
|
173
|
-
//
|
174
|
-
// const portal = document?.querySelector('.frame-portal');
|
175
|
-
// if (!portal) {
|
176
|
-
// portal = document.createElement('div');
|
177
|
-
// document.getElementById(frame)?.appendChild(portal);
|
178
|
-
// }
|
179
|
-
// return portal;
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
184
|
-
|
185
|
-
if (!portal) {
|
186
|
-
const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
187
|
-
|
188
|
-
console.log('!!! res', res);
|
189
|
-
}
|
190
|
-
|
191
|
-
console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));
|
192
|
-
return portalRef.current;
|
193
|
-
|
194
|
-
let portal;
|
195
|
-
|
196
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
197
|
-
if (hasFrame) {
|
198
|
-
portal = frame.current;
|
199
|
-
} else {
|
200
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
201
|
-
|
202
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
203
|
-
|
204
|
-
if (!portal) {
|
205
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
206
|
-
portal = document.createElement('div');
|
207
|
-
document.getElementById(frame)?.appendChild(portal);
|
208
|
-
} else {
|
209
|
-
portal.className('frame-portal');
|
210
|
-
document.body.appendChild(portal);
|
211
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
212
|
-
}
|
213
|
-
}
|
214
|
-
}
|
215
|
-
|
216
|
-
};
|
217
|
-
*/
|
218
85
|
|
219
86
|
/**
|
220
|
-
* Базовый
|
87
|
+
* Базовый копмонент Popup.
|
221
88
|
*/
|
222
89
|
var popupRoot = exports.popupRoot = function popupRoot(Root) {
|
223
90
|
return /*#__PURE__*/(0, _react.forwardRef)(function (_ref, outerRootRef) {
|
@@ -256,11 +123,44 @@ var popupRoot = exports.popupRoot = function popupRoot(Root) {
|
|
256
123
|
var portalRef = (0, _react.useRef)(null);
|
257
124
|
var contentRef = (0, _react.useRef)(null);
|
258
125
|
var innerRef = (0, _plasmaCore.useForkRef)(contentRef, outerRootRef);
|
126
|
+
var _useState = (0, _react.useState)(false),
|
127
|
+
_useState2 = _slicedToArray(_useState, 2),
|
128
|
+
forceRender = _useState2[1];
|
129
|
+
(0, _react.useEffect)(function () {
|
130
|
+
var portal = document.getElementById(_PopupContext.POPUP_PORTAL_ID);
|
131
|
+
if (typeof frame !== 'string' && frame && frame.current) {
|
132
|
+
portal = frame.current;
|
133
|
+
}
|
134
|
+
if (!portal) {
|
135
|
+
portal = document.createElement('div');
|
136
|
+
portal.setAttribute('id', _PopupContext.POPUP_PORTAL_ID);
|
137
|
+
/**
|
138
|
+
* Нужно для того, чтобы во фрейме не происходило скачков контента
|
139
|
+
* при анимации через transform, если есть элемент с шириной/высотой в 100% (Overlay)
|
140
|
+
*/
|
141
|
+
portal.style.width = '0';
|
142
|
+
if (typeof frame === 'string' && frame !== 'document') {
|
143
|
+
var _document$getElementB;
|
144
|
+
(_document$getElementB = document.getElementById(frame)) === null || _document$getElementB === void 0 || _document$getElementB.appendChild(portal);
|
145
|
+
} else {
|
146
|
+
document.body.appendChild(portal);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
portalRef.current = portal;
|
150
|
+
|
151
|
+
/**
|
152
|
+
* Изменение стейта нужно для того, чтобы Popup
|
153
|
+
* отобразился после записи DOM элемента в portalRef.current
|
154
|
+
*/
|
155
|
+
forceRender(true);
|
156
|
+
}, []);
|
259
157
|
if (!isVisible && !innerIsOpen) {
|
260
158
|
return null;
|
261
159
|
}
|
262
160
|
var cls = (0, _utils.cx)(className, animationInfo !== null && animationInfo !== void 0 && animationInfo.endAnimation ? _Popup.classes.endAnimation : '', animationInfo !== null && animationInfo !== void 0 && animationInfo.endTransition ? _Popup.classes.endTransition : '');
|
263
|
-
|
161
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, portalRef.current && /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
162
|
+
container: portalRef.current
|
163
|
+
}, /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
264
164
|
className: cls
|
265
165
|
}, rest), overlay, /*#__PURE__*/_react["default"].createElement(_PopupRoot.PopupRoot, {
|
266
166
|
id: innerId,
|
@@ -270,25 +170,7 @@ var popupRoot = exports.popupRoot = function popupRoot(Root) {
|
|
270
170
|
zIndex: zIndex,
|
271
171
|
animationInfo: animationInfo,
|
272
172
|
setVisible: setVisible
|
273
|
-
}, children));
|
274
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
275
|
-
return /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
276
|
-
container: frame.current
|
277
|
-
}, rootNode);
|
278
|
-
}
|
279
|
-
var withFrameId = typeof frame === 'string' && frame !== 'document';
|
280
|
-
var containerElement = withFrameId && document.getElementById(frame);
|
281
|
-
if (containerElement) {
|
282
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_reactDom["default"].createPortal( /*#__PURE__*/_react["default"].createElement(_Popup2.StyledPortalContainer, {
|
283
|
-
ref: portalRef
|
284
|
-
}, portalRef.current && /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
285
|
-
container: portalRef.current
|
286
|
-
}, rootNode)), containerElement));
|
287
|
-
}
|
288
|
-
var globalPortal = typeof document !== 'undefined' && document.getElementById(_PopupContext.POPUP_PORTAL_ID);
|
289
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, globalPortal && /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
290
|
-
container: globalPortal
|
291
|
-
}, rootNode));
|
173
|
+
}, children))));
|
292
174
|
});
|
293
175
|
};
|
294
176
|
var popupConfig = exports.popupConfig = {
|
@@ -3,21 +3,18 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.StyledPortal = exports.PopupView = exports.PopupRootContainer = void 0;
|
7
7
|
var _styledComponents = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("styled-components"));
|
8
8
|
var _utils = /*#__PURE__*/require("./utils");
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
10
10
|
var StyledPortal = exports.StyledPortal = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
11
11
|
componentId: "plasma-new-hope__sc-rkhnjn-0"
|
12
|
-
})(["
|
13
|
-
var StyledPortalContainer = exports.StyledPortalContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
14
|
-
componentId: "plasma-new-hope__sc-rkhnjn-1"
|
15
|
-
})(["width:0;"]);
|
12
|
+
})([""]);
|
16
13
|
var PopupView = exports.PopupView = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
17
|
-
componentId: "plasma-new-hope__sc-rkhnjn-
|
14
|
+
componentId: "plasma-new-hope__sc-rkhnjn-1"
|
18
15
|
})(["position:relative;max-width:100%;pointer-events:all;"]);
|
19
16
|
var PopupRootContainer = exports.PopupRootContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
20
|
-
componentId: "plasma-new-hope__sc-rkhnjn-
|
17
|
+
componentId: "plasma-new-hope__sc-rkhnjn-2"
|
21
18
|
})(["position:absolute;z-index:", ";left:", ";right:", ";top:", ";bottom:", ";transform:", ";"], function (_ref) {
|
22
19
|
var zIndex = _ref.zIndex;
|
23
20
|
return zIndex || _utils.DEFAULT_Z_INDEX;
|
@@ -6,11 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.usePopupContext = exports.PopupProvider = exports.POPUP_PORTAL_ID = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var _reactDom = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react-dom"));
|
10
9
|
var _ModalContext = /*#__PURE__*/require("../Modal/ModalContext");
|
11
|
-
var _Popup = /*#__PURE__*/require("./Popup.styles");
|
12
|
-
var _StyledPortal;
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
14
10
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
15
11
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
16
12
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
@@ -27,11 +23,9 @@ var POPUP_PORTAL_ID = exports.POPUP_PORTAL_ID = 'plasma-popup-root';
|
|
27
23
|
var items = [];
|
28
24
|
var PopupContext = /*#__PURE__*/(0, _react.createContext)({
|
29
25
|
items: items,
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
31
26
|
register: function register(_info) {
|
32
27
|
throw new Error('Function not implemented. Add PopupProvider');
|
33
28
|
},
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
35
29
|
unregister: function unregister(_id) {
|
36
30
|
throw new Error('Function not implemented. Add PopupProvider');
|
37
31
|
}
|
@@ -42,7 +36,6 @@ var usePopupContext = exports.usePopupContext = function usePopupContext() {
|
|
42
36
|
var PopupProvider = exports.PopupProvider = function PopupProvider(_ref) {
|
43
37
|
var children = _ref.children;
|
44
38
|
var prevBodyOverflowY = (0, _react.useRef)(typeof document !== 'undefined' ? document.body.style.overflowY : '');
|
45
|
-
// eslint-disable-next-line no-shadow
|
46
39
|
var _useState = (0, _react.useState)([]),
|
47
40
|
_useState2 = _slicedToArray(_useState, 2),
|
48
41
|
items = _useState2[0],
|
@@ -80,9 +73,15 @@ var PopupProvider = exports.PopupProvider = function PopupProvider(_ref) {
|
|
80
73
|
register: register,
|
81
74
|
unregister: unregister
|
82
75
|
};
|
76
|
+
(0, _react.useEffect)(function () {
|
77
|
+
return function () {
|
78
|
+
var portal = document.createElement('div');
|
79
|
+
if (portal && document.body.contains(portal)) {
|
80
|
+
document.body.removeChild(portal);
|
81
|
+
}
|
82
|
+
};
|
83
|
+
}, []);
|
83
84
|
return /*#__PURE__*/_react["default"].createElement(PopupContext.Provider, {
|
84
85
|
value: context
|
85
|
-
}, children
|
86
|
-
id: POPUP_PORTAL_ID
|
87
|
-
})), document.body));
|
86
|
+
}, children);
|
88
87
|
};
|