@salutejs/plasma-core 1.226.1-next-sbcom.0 → 1.227.0-dev.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.
- package/__helpers/IconPlaceholder.js +6 -9
- package/__helpers/index.js +1 -1
- package/collectPackageInfo.js +4 -4
- package/components/Badge/Badge.js +30 -103
- package/components/Badge/index.js +1 -1
- package/components/Basebox/Basebox.js +33 -42
- package/components/Basebox/index.js +1 -1
- package/components/Button/Button.js +28 -67
- package/components/Button/Button.mixins.js +22 -76
- package/components/Button/Button.props.js +5 -5
- package/components/Button/createButton.js +14 -145
- package/components/Button/index.js +4 -4
- package/components/Card/Card.js +34 -162
- package/components/Card/CardBody.js +4 -4
- package/components/Card/CardContent.js +14 -23
- package/components/Card/CardMedia.js +20 -91
- package/components/Card/CardPrice.js +18 -60
- package/components/Card/CardTypography.js +43 -52
- package/components/Card/index.js +5 -5
- package/components/Carousel/Carousel.js +46 -64
- package/components/Carousel/CarouselItem.js +21 -93
- package/components/Carousel/hooks.js +62 -121
- package/components/Carousel/index.js +3 -3
- package/components/Carousel/utils.js +59 -73
- package/components/Fade/Fade.js +6 -9
- package/components/Fade/index.js +1 -1
- package/components/Field/Field.js +48 -63
- package/components/Field/Field.statuses.js +3 -3
- package/components/Field/index.js +2 -2
- package/components/Image/Image.js +34 -115
- package/components/Image/index.js +1 -1
- package/components/Input/Input.js +7 -7
- package/components/Input/Input.mixins.js +9 -12
- package/components/Input/index.js +1 -1
- package/components/ModalBase/ModalBase.js +22 -100
- package/components/ModalBase/ModalBaseContext.js +6 -9
- package/components/ModalBase/ModalOverlay.js +28 -111
- package/components/ModalBase/hooks.js +15 -43
- package/components/ModalBase/index.js +2 -2
- package/components/PaginationDots/PaginationDot.js +11 -17
- package/components/PaginationDots/PaginationDots.js +4 -7
- package/components/PaginationDots/index.js +3 -3
- package/components/PaginationDots/usePaginationDots.js +10 -11
- package/components/Popup/Popup.js +52 -205
- package/components/Popup/index.js +1 -1
- package/components/PopupBase/PopupBase.js +35 -169
- package/components/PopupBase/PopupBaseContext.js +26 -86
- package/components/PopupBase/PopupBaseRoot.js +31 -169
- package/components/PopupBase/hooks.js +23 -97
- package/components/PopupBase/index.js +3 -3
- package/components/PopupBase/utils.js +32 -78
- package/components/Price/Price.js +15 -90
- package/components/Price/index.js +1 -1
- package/components/RadioGroup/RadioGroup.js +6 -127
- package/components/RadioGroup/index.js +1 -1
- package/components/SSRProvider/SSRProvider.js +4 -5
- package/components/SSRProvider/index.js +1 -1
- package/components/Skeleton/LineSkeleton.js +23 -95
- package/components/Skeleton/RectSkeleton.js +20 -93
- package/components/Skeleton/Skeleton.js +2 -2
- package/components/Skeleton/TextSkeleton.js +11 -55
- package/components/Skeleton/index.js +3 -3
- package/components/Slider/Double.js +52 -203
- package/components/Slider/Handle.js +28 -158
- package/components/Slider/Single.js +29 -177
- package/components/Slider/Slider.js +5 -7
- package/components/Slider/SliderBase.js +39 -48
- package/components/Slider/ThumbBase.js +19 -95
- package/components/Slider/index.js +3 -3
- package/components/Slider/utils.js +2 -2
- package/components/Spinner/Spinner.js +28 -100
- package/components/Spinner/SpinnerSvg.js +9 -78
- package/components/Spinner/index.js +1 -1
- package/components/Switch/Switch.js +49 -220
- package/components/Switch/index.js +1 -1
- package/components/Tabs/TabItem.js +33 -168
- package/components/Tabs/Tabs.js +32 -170
- package/components/Tabs/TabsContext.js +12 -42
- package/components/Tabs/createTabsController.js +33 -168
- package/components/Tabs/index.js +4 -4
- package/components/TextArea/TextArea.js +20 -30
- package/components/TextArea/index.js +1 -1
- package/components/TextField/index.js +3 -3
- package/components/Toast/Toast.js +15 -16
- package/components/Toast/ToastContext.js +4 -8
- package/components/Toast/ToastController.js +44 -101
- package/components/Toast/ToastProvider.js +37 -142
- package/components/Toast/index.js +3 -3
- package/components/Toast/useToast.js +6 -6
- package/components/Typography/Body.js +18 -18
- package/components/Typography/Button.js +13 -13
- package/components/Typography/Caption.js +8 -8
- package/components/Typography/Display.js +18 -18
- package/components/Typography/Footnote.js +13 -13
- package/components/Typography/Headline.js +43 -43
- package/components/Typography/Paragraph.js +24 -24
- package/components/Typography/Underline.js +8 -8
- package/es/__helpers/IconPlaceholder.js +5 -8
- package/es/collectPackageInfo.js +3 -3
- package/es/components/Badge/Badge.js +27 -100
- package/es/components/Basebox/Basebox.js +28 -37
- package/es/components/Button/Button.js +24 -63
- package/es/components/Button/Button.mixins.js +19 -73
- package/es/components/Button/Button.props.js +3 -3
- package/es/components/Button/createButton.js +12 -143
- package/es/components/Card/Card.js +29 -157
- package/es/components/Card/CardBody.js +2 -2
- package/es/components/Card/CardContent.js +12 -21
- package/es/components/Card/CardMedia.js +17 -88
- package/es/components/Card/CardPrice.js +13 -55
- package/es/components/Card/CardTypography.js +43 -52
- package/es/components/Carousel/Carousel.js +45 -63
- package/es/components/Carousel/CarouselItem.js +18 -90
- package/es/components/Carousel/hooks.js +58 -117
- package/es/components/Carousel/utils.js +58 -72
- package/es/components/Fade/Fade.js +5 -8
- package/es/components/Field/Field.js +44 -59
- package/es/components/Field/Field.statuses.js +4 -4
- package/es/components/Image/Image.js +31 -112
- package/es/components/Input/Input.js +4 -4
- package/es/components/Input/Input.mixins.js +6 -9
- package/es/components/ModalBase/ModalBase.js +16 -94
- package/es/components/ModalBase/ModalBaseContext.js +6 -9
- package/es/components/ModalBase/ModalOverlay.js +23 -106
- package/es/components/ModalBase/hooks.js +12 -40
- package/es/components/PaginationDots/PaginationDot.js +9 -15
- package/es/components/PaginationDots/PaginationDots.js +3 -6
- package/es/components/PaginationDots/usePaginationDots.js +9 -10
- package/es/components/Popup/Popup.js +48 -201
- package/es/components/PopupBase/PopupBase.js +27 -161
- package/es/components/PopupBase/PopupBaseContext.js +25 -85
- package/es/components/PopupBase/PopupBaseRoot.js +26 -164
- package/es/components/PopupBase/hooks.js +21 -95
- package/es/components/PopupBase/utils.js +31 -77
- package/es/components/Price/Price.js +12 -87
- package/es/components/RadioGroup/RadioGroup.js +5 -126
- package/es/components/SSRProvider/SSRProvider.js +3 -4
- package/es/components/Skeleton/LineSkeleton.js +18 -90
- package/es/components/Skeleton/RectSkeleton.js +16 -89
- package/es/components/Skeleton/Skeleton.js +2 -2
- package/es/components/Skeleton/TextSkeleton.js +7 -51
- package/es/components/Slider/Double.js +49 -200
- package/es/components/Slider/Handle.js +23 -153
- package/es/components/Slider/Single.js +26 -174
- package/es/components/Slider/Slider.js +2 -4
- package/es/components/Slider/SliderBase.js +36 -45
- package/es/components/Slider/ThumbBase.js +16 -92
- package/es/components/Slider/index.js +1 -1
- package/es/components/Slider/utils.js +2 -2
- package/es/components/Spinner/Spinner.js +23 -95
- package/es/components/Spinner/SpinnerSvg.js +8 -77
- package/es/components/Switch/Switch.js +45 -216
- package/es/components/Tabs/TabItem.js +28 -163
- package/es/components/Tabs/Tabs.js +28 -166
- package/es/components/Tabs/TabsContext.js +11 -41
- package/es/components/Tabs/createTabsController.js +28 -163
- package/es/components/TextArea/TextArea.js +18 -28
- package/es/components/Toast/Toast.js +10 -11
- package/es/components/Toast/ToastContext.js +3 -7
- package/es/components/Toast/ToastController.js +38 -95
- package/es/components/Toast/ToastProvider.js +34 -139
- package/es/components/Toast/useToast.js +4 -4
- package/es/components/Typography/Body.js +15 -15
- package/es/components/Typography/Button.js +10 -10
- package/es/components/Typography/Caption.js +5 -5
- package/es/components/Typography/Display.js +15 -15
- package/es/components/Typography/Footnote.js +10 -10
- package/es/components/Typography/Headline.js +40 -40
- package/es/components/Typography/Paragraph.js +21 -21
- package/es/components/Typography/Underline.js +5 -5
- package/es/hocs/withAutoFocus.js +8 -78
- package/es/hocs/withSkeleton.js +5 -10
- package/es/hooks/useDebouncedFunction.js +4 -36
- package/es/hooks/useFocusTrap.js +18 -21
- package/es/hooks/useForkRef.js +3 -3
- package/es/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/es/hooks/useResizeObserver.js +8 -8
- package/es/hooks/useUniqId.js +6 -52
- package/es/mixins/addFocus.js +17 -22
- package/es/mixins/applyDisabled.js +6 -9
- package/es/mixins/applyEllipsis.js +2 -4
- package/es/mixins/applyMaxLines.js +3 -6
- package/es/mixins/applyNoSelect.js +2 -4
- package/es/mixins/applyOutline.js +2 -4
- package/es/mixins/applyRoundness.js +4 -7
- package/es/mixins/applyScrollSnap.js +4 -7
- package/es/mixins/applySkeletonGradient.js +6 -9
- package/es/mixins/applyView.js +2 -5
- package/es/mixins/blur.js +2 -5
- package/es/mixins/shadows.js +1 -1
- package/es/tokens/colors.js +48 -48
- package/es/tokens/typography.js +18 -18
- package/es/utils/__tests__/formatters.test.js +2 -2
- package/es/utils/animatedScrollTo.js +24 -34
- package/es/utils/canUseDOM.js +1 -1
- package/es/utils/extractTextFrom.js +3 -7
- package/es/utils/focusManager.js +40 -47
- package/es/utils/formatCurrency.js +4 -4
- package/es/utils/formatters.js +6 -14
- package/es/utils/react.js +4 -4
- package/es/utils/roundness.js +2 -4
- package/es/utils/scopeTab.js +5 -5
- package/es/utils/setRef.js +1 -1
- package/es/utils/tabbable.js +16 -25
- package/es/utils/toCssSize.js +1 -3
- package/es/utils/transformStyles.js +5 -60
- package/hocs/index.js +2 -2
- package/hocs/withAutoFocus.js +9 -79
- package/hocs/withSkeleton.js +8 -13
- package/hooks/index.js +6 -6
- package/hooks/useDebouncedFunction.js +5 -37
- package/hooks/useFocusTrap.js +22 -25
- package/hooks/useForkRef.js +5 -5
- package/hooks/useIsomorphicLayoutEffect.js +3 -3
- package/hooks/useResizeObserver.js +9 -9
- package/hooks/useUniqId.js +8 -54
- package/mixins/addFocus.js +19 -24
- package/mixins/applyDisabled.js +7 -10
- package/mixins/applyEllipsis.js +3 -5
- package/mixins/applyMaxLines.js +4 -7
- package/mixins/applyNoSelect.js +3 -5
- package/mixins/applyOutline.js +3 -5
- package/mixins/applyRoundness.js +5 -8
- package/mixins/applyScrollSnap.js +5 -8
- package/mixins/applySkeletonGradient.js +8 -11
- package/mixins/applyView.js +3 -6
- package/mixins/blur.js +2 -5
- package/mixins/index.js +11 -11
- package/mixins/shadows.js +1 -1
- package/package.json +13 -18
- package/tokens/colors.js +48 -48
- package/tokens/typography.js +18 -18
- package/utils/__tests__/formatters.test.js +3 -3
- package/utils/animatedScrollTo.js +24 -34
- package/utils/canUseDOM.js +1 -1
- package/utils/extractTextFrom.js +4 -8
- package/utils/focusManager.js +41 -48
- package/utils/formatCurrency.js +4 -4
- package/utils/formatters.js +6 -14
- package/utils/index.js +10 -10
- package/utils/react.js +7 -7
- package/utils/roundness.js +2 -4
- package/utils/scopeTab.js +6 -6
- package/utils/setRef.js +1 -1
- package/utils/tabbable.js +16 -25
- package/utils/toCssSize.js +1 -3
- package/utils/transformStyles.js +5 -60
|
@@ -16,31 +16,10 @@ _export(exports, {
|
|
|
16
16
|
return getPlacement;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function _array_like_to_array(arr, len) {
|
|
24
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
25
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
26
|
-
return arr2;
|
|
27
|
-
}
|
|
28
|
-
function _array_with_holes(arr) {
|
|
29
|
-
if (Array.isArray(arr)) return arr;
|
|
30
|
-
}
|
|
31
|
-
function _define_property(obj, key, value) {
|
|
32
|
-
if (key in obj) {
|
|
33
|
-
Object.defineProperty(obj, key, {
|
|
34
|
-
value: value,
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
obj[key] = value;
|
|
41
|
-
}
|
|
42
|
-
return obj;
|
|
43
|
-
}
|
|
19
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
20
|
+
const _styledcomponents = /*#__PURE__*/ _interop_require_default(require("styled-components"));
|
|
21
|
+
const _reactpopper = require("react-popper");
|
|
22
|
+
const _hooks = require("../../hooks");
|
|
44
23
|
function _interop_require_default(obj) {
|
|
45
24
|
return obj && obj.__esModule ? obj : {
|
|
46
25
|
default: obj
|
|
@@ -87,165 +66,32 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
87
66
|
}
|
|
88
67
|
return newObj;
|
|
89
68
|
}
|
|
90
|
-
|
|
91
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
92
|
-
}
|
|
93
|
-
function _iterable_to_array_limit(arr, i) {
|
|
94
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
95
|
-
if (_i == null) return;
|
|
96
|
-
var _arr = [];
|
|
97
|
-
var _n = true;
|
|
98
|
-
var _d = false;
|
|
99
|
-
var _s, _e;
|
|
100
|
-
try {
|
|
101
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
102
|
-
_arr.push(_s.value);
|
|
103
|
-
if (i && _arr.length === i) break;
|
|
104
|
-
}
|
|
105
|
-
} catch (err) {
|
|
106
|
-
_d = true;
|
|
107
|
-
_e = err;
|
|
108
|
-
} finally{
|
|
109
|
-
try {
|
|
110
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
111
|
-
} finally{
|
|
112
|
-
if (_d) throw _e;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return _arr;
|
|
116
|
-
}
|
|
117
|
-
function _non_iterable_rest() {
|
|
118
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
119
|
-
}
|
|
120
|
-
function _object_spread(target) {
|
|
121
|
-
for(var i = 1; i < arguments.length; i++){
|
|
122
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
123
|
-
var ownKeys = Object.keys(source);
|
|
124
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
125
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
126
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
ownKeys.forEach(function(key) {
|
|
130
|
-
_define_property(target, key, source[key]);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
return target;
|
|
134
|
-
}
|
|
135
|
-
function ownKeys(object, enumerableOnly) {
|
|
136
|
-
var keys = Object.keys(object);
|
|
137
|
-
if (Object.getOwnPropertySymbols) {
|
|
138
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
139
|
-
if (enumerableOnly) {
|
|
140
|
-
symbols = symbols.filter(function(sym) {
|
|
141
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
keys.push.apply(keys, symbols);
|
|
145
|
-
}
|
|
146
|
-
return keys;
|
|
147
|
-
}
|
|
148
|
-
function _object_spread_props(target, source) {
|
|
149
|
-
source = source != null ? source : {};
|
|
150
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
151
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
152
|
-
} else {
|
|
153
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
154
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
return target;
|
|
158
|
-
}
|
|
159
|
-
function _object_without_properties(source, excluded) {
|
|
160
|
-
if (source == null) return {};
|
|
161
|
-
var target = {}, sourceKeys, key, i;
|
|
162
|
-
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
163
|
-
sourceKeys = Reflect.ownKeys(source);
|
|
164
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
165
|
-
key = sourceKeys[i];
|
|
166
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
167
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
168
|
-
target[key] = source[key];
|
|
169
|
-
}
|
|
170
|
-
return target;
|
|
171
|
-
}
|
|
172
|
-
target = _object_without_properties_loose(source, excluded);
|
|
173
|
-
if (Object.getOwnPropertySymbols) {
|
|
174
|
-
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
175
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
176
|
-
key = sourceKeys[i];
|
|
177
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
178
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
179
|
-
target[key] = source[key];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return target;
|
|
183
|
-
}
|
|
184
|
-
function _object_without_properties_loose(source, excluded) {
|
|
185
|
-
if (source == null) return {};
|
|
186
|
-
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
187
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
188
|
-
key = sourceKeys[i];
|
|
189
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
190
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
191
|
-
target[key] = source[key];
|
|
192
|
-
}
|
|
193
|
-
return target;
|
|
194
|
-
}
|
|
195
|
-
function _sliced_to_array(arr, i) {
|
|
196
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
197
|
-
}
|
|
198
|
-
function _to_array(arr) {
|
|
199
|
-
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
|
200
|
-
}
|
|
201
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
202
|
-
if (!o) return;
|
|
203
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
204
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
205
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
206
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
207
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
208
|
-
}
|
|
209
|
-
var StyledRoot = _styledcomponents.default.div.withConfig({
|
|
69
|
+
const StyledRoot = _styledcomponents.default.div.withConfig({
|
|
210
70
|
displayName: "Popup__StyledRoot",
|
|
211
71
|
componentId: "sc-7a6b6e85-0"
|
|
212
72
|
})([
|
|
213
|
-
|
|
73
|
+
`position:relative;box-sizing:border-box;display:inline-flex;`
|
|
214
74
|
]);
|
|
215
|
-
|
|
75
|
+
const StyledPopup = _styledcomponents.default.div.withConfig({
|
|
216
76
|
displayName: "Popup__StyledPopup",
|
|
217
77
|
componentId: "sc-7a6b6e85-1"
|
|
218
78
|
})([
|
|
219
|
-
|
|
79
|
+
`position:absolute;z-index:1;padding:var(--plasma-popup-padding);margin:var(--plasma-popup-margin);width:var(--plasma-popup-width);`
|
|
220
80
|
]);
|
|
221
|
-
|
|
222
|
-
return
|
|
81
|
+
const getPlacement = (placement)=>{
|
|
82
|
+
return `${placement}-start`;
|
|
223
83
|
};
|
|
224
|
-
|
|
225
|
-
return (placements || []).map(
|
|
226
|
-
return getPlacement(placement);
|
|
227
|
-
});
|
|
84
|
+
const getAutoPlacements = (placements)=>{
|
|
85
|
+
return (placements || []).map((placement)=>getPlacement(placement));
|
|
228
86
|
};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
"opened",
|
|
238
|
-
"trigger",
|
|
239
|
-
"placement",
|
|
240
|
-
"onToggle"
|
|
241
|
-
]), _rest1 = _sliced_to_array(_rest, 1), outerRootRef = _rest1[0];
|
|
242
|
-
var innerIsOpen = Boolean(isOpen || opened);
|
|
243
|
-
var rootRef = (0, _react.useRef)(null);
|
|
244
|
-
var popupRef = (0, _react.useRef)(null);
|
|
245
|
-
var handleRef = (0, _hooks.useForkRef)(rootRef, outerRootRef);
|
|
246
|
-
var isAutoArray = Array.isArray(placement);
|
|
247
|
-
var isAuto = isAutoArray || placement === 'auto';
|
|
248
|
-
var _usePopper = (0, _reactpopper.usePopper)(rootRef.current, popupRef.current, {
|
|
87
|
+
const Popup = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ _react.default.forwardRef(({ disclosure, children, isOpen, opened, trigger, placement = 'auto', onToggle, ...rest }, outerRootRef)=>{
|
|
88
|
+
const innerIsOpen = Boolean(isOpen || opened);
|
|
89
|
+
const rootRef = (0, _react.useRef)(null);
|
|
90
|
+
const popupRef = (0, _react.useRef)(null);
|
|
91
|
+
const handleRef = (0, _hooks.useForkRef)(rootRef, outerRootRef);
|
|
92
|
+
const isAutoArray = Array.isArray(placement);
|
|
93
|
+
const isAuto = isAutoArray || placement === 'auto';
|
|
94
|
+
const { styles, attributes, forceUpdate } = (0, _reactpopper.usePopper)(rootRef.current, popupRef.current, {
|
|
249
95
|
placement: getPlacement(isAutoArray ? 'auto' : placement),
|
|
250
96
|
modifiers: [
|
|
251
97
|
{
|
|
@@ -256,24 +102,22 @@ var Popup = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ _react.default.forwardR
|
|
|
256
102
|
}
|
|
257
103
|
}
|
|
258
104
|
]
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
var rootHasTarget = (_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.contains(event.target);
|
|
105
|
+
});
|
|
106
|
+
const onDocumentClick = (0, _react.useCallback)((event)=>{
|
|
107
|
+
const targetIsRoot = event.target === rootRef.current;
|
|
108
|
+
const rootHasTarget = rootRef.current?.contains(event.target);
|
|
264
109
|
if (!targetIsRoot && !rootHasTarget) {
|
|
265
|
-
onToggle
|
|
110
|
+
onToggle?.(false, event);
|
|
266
111
|
}
|
|
267
112
|
}, [
|
|
268
113
|
onToggle
|
|
269
114
|
]);
|
|
270
|
-
|
|
115
|
+
const onClick = (0, _react.useCallback)((event)=>{
|
|
271
116
|
if (trigger === 'click') {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
var rootHasTarget = (_popupRef_current = popupRef.current) === null || _popupRef_current === void 0 ? void 0 : _popupRef_current.contains(event.target);
|
|
117
|
+
const targetIsPopup = event.target === popupRef.current;
|
|
118
|
+
const rootHasTarget = popupRef.current?.contains(event.target);
|
|
275
119
|
if (!targetIsPopup && !rootHasTarget) {
|
|
276
|
-
onToggle
|
|
120
|
+
onToggle?.(!innerIsOpen, event);
|
|
277
121
|
}
|
|
278
122
|
}
|
|
279
123
|
}, [
|
|
@@ -281,45 +125,43 @@ var Popup = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ _react.default.forwardR
|
|
|
281
125
|
innerIsOpen,
|
|
282
126
|
onToggle
|
|
283
127
|
]);
|
|
284
|
-
|
|
128
|
+
const onMouseEnter = (0, _react.useCallback)((event)=>{
|
|
285
129
|
if (trigger === 'hover') {
|
|
286
|
-
onToggle
|
|
130
|
+
onToggle?.(true, event);
|
|
287
131
|
}
|
|
288
132
|
}, [
|
|
289
133
|
trigger,
|
|
290
134
|
onToggle
|
|
291
135
|
]);
|
|
292
|
-
|
|
136
|
+
const onMouseLeave = (0, _react.useCallback)((event)=>{
|
|
293
137
|
if (trigger === 'hover') {
|
|
294
|
-
onToggle
|
|
138
|
+
onToggle?.(false, event);
|
|
295
139
|
}
|
|
296
140
|
}, [
|
|
297
141
|
trigger,
|
|
298
142
|
onToggle
|
|
299
143
|
]);
|
|
300
|
-
|
|
144
|
+
const onFocus = (0, _react.useCallback)((event)=>{
|
|
301
145
|
if (trigger === 'hover') {
|
|
302
|
-
onToggle
|
|
146
|
+
onToggle?.(true, event);
|
|
303
147
|
}
|
|
304
148
|
}, [
|
|
305
149
|
trigger,
|
|
306
150
|
onToggle
|
|
307
151
|
]);
|
|
308
|
-
|
|
152
|
+
const onBlur = (0, _react.useCallback)((event)=>{
|
|
309
153
|
if (trigger === 'hover') {
|
|
310
|
-
onToggle
|
|
154
|
+
onToggle?.(false, event);
|
|
311
155
|
}
|
|
312
156
|
}, [
|
|
313
157
|
trigger,
|
|
314
158
|
onToggle
|
|
315
159
|
]);
|
|
316
|
-
(0, _react.useEffect)(
|
|
160
|
+
(0, _react.useEffect)(()=>{
|
|
317
161
|
document.addEventListener('click', onDocumentClick);
|
|
318
|
-
return
|
|
319
|
-
return document.removeEventListener('click', onDocumentClick);
|
|
320
|
-
};
|
|
162
|
+
return ()=>document.removeEventListener('click', onDocumentClick);
|
|
321
163
|
}, []);
|
|
322
|
-
(0, _react.useEffect)(
|
|
164
|
+
(0, _react.useEffect)(()=>{
|
|
323
165
|
if (!innerIsOpen || !forceUpdate) {
|
|
324
166
|
return;
|
|
325
167
|
}
|
|
@@ -333,17 +175,22 @@ var Popup = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ _react.default.forwardR
|
|
|
333
175
|
innerIsOpen,
|
|
334
176
|
forceUpdate
|
|
335
177
|
]);
|
|
336
|
-
return /*#__PURE__*/ _react.default.createElement(StyledRoot,
|
|
178
|
+
return /*#__PURE__*/ _react.default.createElement(StyledRoot, {
|
|
337
179
|
ref: handleRef,
|
|
338
180
|
onClick: onClick,
|
|
339
181
|
onMouseEnter: onMouseEnter,
|
|
340
182
|
onMouseLeave: onMouseLeave,
|
|
341
183
|
onFocus: onFocus,
|
|
342
|
-
onBlur: onBlur
|
|
343
|
-
|
|
184
|
+
onBlur: onBlur,
|
|
185
|
+
...rest
|
|
186
|
+
}, disclosure, children && /*#__PURE__*/ _react.default.createElement(StyledPopup, {
|
|
187
|
+
...attributes.popper,
|
|
344
188
|
ref: popupRef,
|
|
345
|
-
style:
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
189
|
+
style: {
|
|
190
|
+
...styles.popper,
|
|
191
|
+
...{
|
|
192
|
+
display: innerIsOpen ? 'block' : 'none'
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}, children));
|
|
349
196
|
}));
|
|
@@ -16,35 +16,14 @@ _export(exports, {
|
|
|
16
16
|
return getClassName;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function _array_like_to_array(arr, len) {
|
|
28
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
29
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
30
|
-
return arr2;
|
|
31
|
-
}
|
|
32
|
-
function _array_with_holes(arr) {
|
|
33
|
-
if (Array.isArray(arr)) return arr;
|
|
34
|
-
}
|
|
35
|
-
function _define_property(obj, key, value) {
|
|
36
|
-
if (key in obj) {
|
|
37
|
-
Object.defineProperty(obj, key, {
|
|
38
|
-
value: value,
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true
|
|
42
|
-
});
|
|
43
|
-
} else {
|
|
44
|
-
obj[key] = value;
|
|
45
|
-
}
|
|
46
|
-
return obj;
|
|
47
|
-
}
|
|
19
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
20
|
+
const _reactdom = /*#__PURE__*/ _interop_require_default(require("react-dom"));
|
|
21
|
+
const _styledcomponents = /*#__PURE__*/ _interop_require_default(require("styled-components"));
|
|
22
|
+
const _hooks = require("../../hooks");
|
|
23
|
+
const _PopupBaseContext = require("./PopupBaseContext");
|
|
24
|
+
const _PopupBaseRoot = require("./PopupBaseRoot");
|
|
25
|
+
const _hooks1 = require("./hooks");
|
|
26
|
+
const _utils = require("./utils");
|
|
48
27
|
function _interop_require_default(obj) {
|
|
49
28
|
return obj && obj.__esModule ? obj : {
|
|
50
29
|
default: obj
|
|
@@ -91,153 +70,40 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
91
70
|
}
|
|
92
71
|
return newObj;
|
|
93
72
|
}
|
|
94
|
-
|
|
95
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
96
|
-
}
|
|
97
|
-
function _iterable_to_array_limit(arr, i) {
|
|
98
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
99
|
-
if (_i == null) return;
|
|
100
|
-
var _arr = [];
|
|
101
|
-
var _n = true;
|
|
102
|
-
var _d = false;
|
|
103
|
-
var _s, _e;
|
|
104
|
-
try {
|
|
105
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
106
|
-
_arr.push(_s.value);
|
|
107
|
-
if (i && _arr.length === i) break;
|
|
108
|
-
}
|
|
109
|
-
} catch (err) {
|
|
110
|
-
_d = true;
|
|
111
|
-
_e = err;
|
|
112
|
-
} finally{
|
|
113
|
-
try {
|
|
114
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
115
|
-
} finally{
|
|
116
|
-
if (_d) throw _e;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return _arr;
|
|
120
|
-
}
|
|
121
|
-
function _non_iterable_rest() {
|
|
122
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
123
|
-
}
|
|
124
|
-
function _object_spread(target) {
|
|
125
|
-
for(var i = 1; i < arguments.length; i++){
|
|
126
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
127
|
-
var ownKeys = Object.keys(source);
|
|
128
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
129
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
130
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
ownKeys.forEach(function(key) {
|
|
134
|
-
_define_property(target, key, source[key]);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
return target;
|
|
138
|
-
}
|
|
139
|
-
function _object_without_properties(source, excluded) {
|
|
140
|
-
if (source == null) return {};
|
|
141
|
-
var target = {}, sourceKeys, key, i;
|
|
142
|
-
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
143
|
-
sourceKeys = Reflect.ownKeys(source);
|
|
144
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
145
|
-
key = sourceKeys[i];
|
|
146
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
147
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
148
|
-
target[key] = source[key];
|
|
149
|
-
}
|
|
150
|
-
return target;
|
|
151
|
-
}
|
|
152
|
-
target = _object_without_properties_loose(source, excluded);
|
|
153
|
-
if (Object.getOwnPropertySymbols) {
|
|
154
|
-
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
155
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
156
|
-
key = sourceKeys[i];
|
|
157
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
158
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
159
|
-
target[key] = source[key];
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return target;
|
|
163
|
-
}
|
|
164
|
-
function _object_without_properties_loose(source, excluded) {
|
|
165
|
-
if (source == null) return {};
|
|
166
|
-
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
167
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
168
|
-
key = sourceKeys[i];
|
|
169
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
170
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
171
|
-
target[key] = source[key];
|
|
172
|
-
}
|
|
173
|
-
return target;
|
|
174
|
-
}
|
|
175
|
-
function _sliced_to_array(arr, i) {
|
|
176
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
177
|
-
}
|
|
178
|
-
function _to_array(arr) {
|
|
179
|
-
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
|
180
|
-
}
|
|
181
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
182
|
-
if (!o) return;
|
|
183
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
184
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
185
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
186
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
187
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
188
|
-
}
|
|
189
|
-
var StyledPortal = _styledcomponents.default.div.withConfig({
|
|
73
|
+
const StyledPortal = _styledcomponents.default.div.withConfig({
|
|
190
74
|
displayName: "PopupBase__StyledPortal",
|
|
191
75
|
componentId: "sc-548d9538-0"
|
|
192
76
|
})([
|
|
193
|
-
|
|
77
|
+
``
|
|
194
78
|
]);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
79
|
+
const getClassName = (animationInfo, className)=>{
|
|
80
|
+
const endAnimation = animationInfo?.endAnimation ? _utils.endAnimationClass : '';
|
|
81
|
+
const endTransition = animationInfo?.endTransition ? _utils.endTransitionClass : '';
|
|
198
82
|
return [
|
|
199
83
|
className,
|
|
200
84
|
endAnimation,
|
|
201
85
|
endTransition
|
|
202
86
|
].filter(Boolean).join(' ');
|
|
203
87
|
};
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
"id",
|
|
213
|
-
"isOpen",
|
|
214
|
-
"opened",
|
|
215
|
-
"placement",
|
|
216
|
-
"offset",
|
|
217
|
-
"frame",
|
|
218
|
-
"children",
|
|
219
|
-
"overlay",
|
|
220
|
-
"role",
|
|
221
|
-
"zIndex",
|
|
222
|
-
"popupInfo",
|
|
223
|
-
"withAnimation",
|
|
224
|
-
"className"
|
|
225
|
-
]), _rest1 = _sliced_to_array(_rest, 1), ref = _rest1[0];
|
|
226
|
-
var innerIsOpen = Boolean(isOpen || opened);
|
|
227
|
-
var uniqId = (0, _hooks.useUniqId)();
|
|
228
|
-
var innerId = id || uniqId;
|
|
229
|
-
var _usePopup = (0, _hooks1.usePopup)({
|
|
88
|
+
const PopupBase = /*#__PURE__*/ (0, _react.forwardRef)(({ id, isOpen, opened, placement = 'center', offset = [
|
|
89
|
+
0,
|
|
90
|
+
0
|
|
91
|
+
], frame = 'document', children, overlay, role, zIndex, popupInfo, withAnimation = false, className, ...rest }, ref)=>{
|
|
92
|
+
const innerIsOpen = Boolean(isOpen || opened);
|
|
93
|
+
const uniqId = (0, _hooks.useUniqId)();
|
|
94
|
+
const innerId = id || uniqId;
|
|
95
|
+
const { isVisible, animationInfo, setVisible } = (0, _hooks1.usePopup)({
|
|
230
96
|
isOpen: innerIsOpen,
|
|
231
97
|
id: innerId,
|
|
232
|
-
popupInfo
|
|
233
|
-
withAnimation
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
(0, _react.useEffect)(
|
|
240
|
-
|
|
98
|
+
popupInfo,
|
|
99
|
+
withAnimation
|
|
100
|
+
});
|
|
101
|
+
const portalRef = (0, _react.useRef)(null);
|
|
102
|
+
const contentRef = (0, _react.useRef)(null);
|
|
103
|
+
const innerRef = (0, _hooks.useForkRef)(contentRef, ref);
|
|
104
|
+
const [, forceRender] = (0, _react.useState)(false);
|
|
105
|
+
(0, _react.useEffect)(()=>{
|
|
106
|
+
let portal = document.getElementById(_PopupBaseContext.POPOVER_PORTAL_ID);
|
|
241
107
|
if (typeof frame !== 'string' && frame && frame.current) {
|
|
242
108
|
portal = frame.current;
|
|
243
109
|
}
|
|
@@ -245,8 +111,7 @@ var PopupBase = /*#__PURE__*/ (0, _react.forwardRef)(function(_0, _1) {
|
|
|
245
111
|
portal = document.createElement('div');
|
|
246
112
|
portal.setAttribute('id', _PopupBaseContext.POPOVER_PORTAL_ID);
|
|
247
113
|
if (typeof frame === 'string' && frame !== 'document') {
|
|
248
|
-
|
|
249
|
-
(_document_getElementById = document.getElementById(frame)) === null || _document_getElementById === void 0 ? void 0 : _document_getElementById.appendChild(portal);
|
|
114
|
+
document.getElementById(frame)?.appendChild(portal);
|
|
250
115
|
} else {
|
|
251
116
|
document.body.appendChild(portal);
|
|
252
117
|
}
|
|
@@ -260,9 +125,10 @@ var PopupBase = /*#__PURE__*/ (0, _react.forwardRef)(function(_0, _1) {
|
|
|
260
125
|
if (!isVisible && !innerIsOpen) {
|
|
261
126
|
return null;
|
|
262
127
|
}
|
|
263
|
-
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, portalRef.current && /*#__PURE__*/ _reactdom.default.createPortal(/*#__PURE__*/ _react.default.createElement(StyledPortal,
|
|
264
|
-
className: getClassName(animationInfo, className)
|
|
265
|
-
|
|
128
|
+
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, portalRef.current && /*#__PURE__*/ _reactdom.default.createPortal(/*#__PURE__*/ _react.default.createElement(StyledPortal, {
|
|
129
|
+
className: getClassName(animationInfo, className),
|
|
130
|
+
...rest
|
|
131
|
+
}, overlay, /*#__PURE__*/ _react.default.createElement(_PopupBaseRoot.PopupBaseRoot, {
|
|
266
132
|
id: innerId,
|
|
267
133
|
ref: innerRef,
|
|
268
134
|
placement: placement,
|