magneto365.ui 2.67.0 → 2.68.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/dist/cjs/index.js +46 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/context/container/container.context.d.ts +4 -0
- package/dist/cjs/types/components/context/container/container.interface.d.ts +6 -0
- package/dist/cjs/types/components/context/context.interface.d.ts +1 -0
- package/dist/cjs/types/constants/env.constants.d.ts +2 -0
- package/dist/esm/index.js +46 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/context/container/container.context.d.ts +4 -0
- package/dist/esm/types/components/context/container/container.interface.d.ts +6 -0
- package/dist/esm/types/components/context/context.interface.d.ts +1 -0
- package/dist/esm/types/constants/env.constants.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IContainerContext, IContainerContextProvider } from './container.interface';
|
|
3
|
+
export declare const ContainerContext: React.Context<IContainerContext>;
|
|
4
|
+
export declare const ContainerContextProvider: FC<IContainerContextProvider>;
|
package/dist/esm/index.js
CHANGED
|
@@ -212,10 +212,31 @@ var ResponsiveContextProvider = function (_a) {
|
|
|
212
212
|
return React.createElement(ResponsiveContext.Provider, { value: { dim: dim } }, children);
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
+
var isClient = typeof window !== 'undefined';
|
|
216
|
+
var isServer = !isClient;
|
|
217
|
+
|
|
218
|
+
var ContainerContext = createContext({
|
|
219
|
+
container: isClient ? window.document.body : null
|
|
220
|
+
});
|
|
221
|
+
var ContainerContextProvider = function (_a) {
|
|
222
|
+
var children = _a.children, _b = _a.container, container = _b === void 0 ? null : _b;
|
|
223
|
+
var ctx = useMemo(function () {
|
|
224
|
+
var element = container;
|
|
225
|
+
if (!element && isClient) {
|
|
226
|
+
element = document.body;
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
container: element
|
|
230
|
+
};
|
|
231
|
+
}, [container]);
|
|
232
|
+
return React.createElement(ContainerContext.Provider, { value: ctx }, children);
|
|
233
|
+
};
|
|
234
|
+
|
|
215
235
|
var ContextAppProvider = function (_a) {
|
|
216
|
-
var children = _a.children, device = _a.device;
|
|
236
|
+
var children = _a.children, device = _a.device, container = _a.container;
|
|
217
237
|
return (React.createElement(EventDispatcherContextProvider, null,
|
|
218
|
-
React.createElement(
|
|
238
|
+
React.createElement(ContainerContextProvider, { container: container },
|
|
239
|
+
React.createElement(ResponsiveContextProvider, { device: device }, children))));
|
|
219
240
|
};
|
|
220
241
|
|
|
221
242
|
var screenList = Object.entries(screenSize).sort(function (a, b) { return a[1] - b[1]; });
|
|
@@ -3023,20 +3044,21 @@ var AlertJobModalButton = function (_a) {
|
|
|
3023
3044
|
var DrawerPortal = function (_a) {
|
|
3024
3045
|
var children = _a.children;
|
|
3025
3046
|
var portalNode = useRef(null);
|
|
3047
|
+
var container = useContext(ContainerContext).container;
|
|
3026
3048
|
var _b = useState(false), mounted = _b[0], setMounted = _b[1];
|
|
3027
3049
|
useEffect(function () {
|
|
3028
|
-
if (!
|
|
3050
|
+
if (isServer || !container)
|
|
3029
3051
|
return;
|
|
3030
3052
|
portalNode.current = document.createElement('div');
|
|
3031
3053
|
portalNode.current.classList.add('magneto-ui-drawer');
|
|
3032
|
-
|
|
3054
|
+
container.appendChild(portalNode.current);
|
|
3033
3055
|
setMounted(true);
|
|
3034
3056
|
return function () {
|
|
3035
3057
|
if (portalNode.current) {
|
|
3036
|
-
|
|
3058
|
+
container.removeChild(portalNode.current);
|
|
3037
3059
|
}
|
|
3038
3060
|
};
|
|
3039
|
-
}, []);
|
|
3061
|
+
}, [container]);
|
|
3040
3062
|
return mounted && portalNode.current ? ReactDOM.createPortal(children, portalNode.current) : null;
|
|
3041
3063
|
};
|
|
3042
3064
|
|
|
@@ -3085,21 +3107,22 @@ var styles$2i = {"magneto-ui-modal":"mg_modal_magneto-ui-modal_1ffsw","magneto-u
|
|
|
3085
3107
|
|
|
3086
3108
|
var ModalPortal = function (_a) {
|
|
3087
3109
|
var children = _a.children;
|
|
3110
|
+
var container = useContext(ContainerContext).container;
|
|
3088
3111
|
var portalNode = useRef(null);
|
|
3089
3112
|
var _b = useState(false), mounted = _b[0], setMounted = _b[1];
|
|
3090
3113
|
useEffect(function () {
|
|
3091
|
-
if (!
|
|
3114
|
+
if (isServer || !container)
|
|
3092
3115
|
return;
|
|
3093
3116
|
portalNode.current = document.createElement('div');
|
|
3094
3117
|
portalNode.current.classList.add('modal-ui-drawer');
|
|
3095
|
-
|
|
3118
|
+
container.appendChild(portalNode.current);
|
|
3096
3119
|
setMounted(true);
|
|
3097
3120
|
return function () {
|
|
3098
3121
|
if (portalNode.current) {
|
|
3099
|
-
|
|
3122
|
+
container.removeChild(portalNode.current);
|
|
3100
3123
|
}
|
|
3101
3124
|
};
|
|
3102
|
-
}, []);
|
|
3125
|
+
}, [container]);
|
|
3103
3126
|
return mounted && portalNode.current ? ReactDOM.createPortal(children, portalNode.current) : null;
|
|
3104
3127
|
};
|
|
3105
3128
|
|
|
@@ -3281,6 +3304,7 @@ var BrandsMenuMobile = function (_a) {
|
|
|
3281
3304
|
|
|
3282
3305
|
var withClickOut = function (WrappedComponent) {
|
|
3283
3306
|
var Component = function (props) {
|
|
3307
|
+
var container = useContext(ContainerContext).container;
|
|
3284
3308
|
var _a = useState(false), clickOut = _a[0], setClickOut = _a[1];
|
|
3285
3309
|
var ref = useRef(null);
|
|
3286
3310
|
var handleClick = useCallback(function (e) {
|
|
@@ -3291,11 +3315,11 @@ var withClickOut = function (WrappedComponent) {
|
|
|
3291
3315
|
}
|
|
3292
3316
|
}, [clickOut]);
|
|
3293
3317
|
useEffect(function () {
|
|
3294
|
-
|
|
3318
|
+
container === null || container === void 0 ? void 0 : container.addEventListener('click', handleClick);
|
|
3295
3319
|
return function () {
|
|
3296
|
-
|
|
3320
|
+
container === null || container === void 0 ? void 0 : container.removeEventListener('click', handleClick);
|
|
3297
3321
|
};
|
|
3298
|
-
}, [handleClick]);
|
|
3322
|
+
}, [handleClick, container]);
|
|
3299
3323
|
return (React.createElement("div", { ref: ref },
|
|
3300
3324
|
React.createElement(WrappedComponent, __assign({ clickOut: clickOut, setClickOut: setClickOut }, props))));
|
|
3301
3325
|
};
|
|
@@ -5205,6 +5229,7 @@ var Component$1B = function (_a) {
|
|
|
5205
5229
|
var _g = useState(false), isAnimating = _g[0], setIsAnimating = _g[1];
|
|
5206
5230
|
var removeTimeoutRef = useRef(null);
|
|
5207
5231
|
var hideTimeoutRef = useRef(null);
|
|
5232
|
+
var container = useContext(ContainerContext).container;
|
|
5208
5233
|
var containerVar = useMemo(function () { return ({
|
|
5209
5234
|
'--transition-duration': "".concat(transitionDuration / 1000, "s")
|
|
5210
5235
|
}); }, []);
|
|
@@ -5249,13 +5274,13 @@ var Component$1B = function (_a) {
|
|
|
5249
5274
|
setLocalVisible(visible);
|
|
5250
5275
|
setIsAnimating(visible);
|
|
5251
5276
|
}, [isAnimating, visible]);
|
|
5252
|
-
return localVisible
|
|
5277
|
+
return localVisible && container
|
|
5253
5278
|
? ReactDOM.createPortal(React.createElement("div", { style: containerVar, className: CNM.get({ styles: styles$1r, cls: [className] }) },
|
|
5254
5279
|
React.createElement("div", { className: containerStyles },
|
|
5255
5280
|
React.createElement(IconItem, __assign({ alt: type, className: CNM.get({ styles: styles$1r, cls: ['message__icon'] }), icon: iconByType[type], showDefaultFallback: false, size: 20 }, iconProps)),
|
|
5256
5281
|
React.createElement("div", null,
|
|
5257
5282
|
text && React.createElement("span", { className: textStyles(!!description) }, text),
|
|
5258
|
-
description && React.createElement("span", { className: textStyles() }, description)))),
|
|
5283
|
+
description && React.createElement("span", { className: textStyles() }, description)))), container)
|
|
5259
5284
|
: null;
|
|
5260
5285
|
};
|
|
5261
5286
|
/**
|
|
@@ -7499,6 +7524,7 @@ var useContainerDesktop$1 = function (_a) {
|
|
|
7499
7524
|
var ContainerDesktop$3 = function (_a) {
|
|
7500
7525
|
var inputSearchProps = _a.inputSearchProps, selectedValues = _a.selectedValues, listOptions = _a.listOptions, removeValueToArray = _a.removeValueToArray, addValueToArray = _a.addValueToArray, numberOfSelectable = _a.numberOfSelectable, dropDownTitle = _a.dropDownTitle;
|
|
7501
7526
|
var _b = useContainerDesktop$1({ numberOfSelectable: numberOfSelectable, selectedValues: selectedValues }), containerOptions = _b.containerOptions, menuPosition = _b.menuPosition, toggleDropdown = _b.toggleDropdown, limitOfSelectable = _b.limitOfSelectable, inputRef = _b.inputRef, isOpen = _b.isOpen, dropdownRef = _b.dropdownRef;
|
|
7527
|
+
var container = useContext(ContainerContext).container;
|
|
7502
7528
|
var hideComponent = useMemo(function () {
|
|
7503
7529
|
return isOpen ? style$f['hide'] : '';
|
|
7504
7530
|
}, [isOpen]);
|
|
@@ -7507,6 +7533,7 @@ var ContainerDesktop$3 = function (_a) {
|
|
|
7507
7533
|
React.createElement(DropDownButton$1, { title: dropDownTitle, onClick: toggleDropdown }))),
|
|
7508
7534
|
React.createElement("div", { className: "".concat(style$f["".concat(classMUI, "-container-options-tags-container")], " ").concat(hideComponent) }, selectedValues.map(function (itemSelected) { return (React.createElement(Tags, { key: itemSelected.id, text: itemSelected.name, icon: Close, bgColor: "#FFF", onClick: function () { return removeValueToArray(itemSelected); } })); })),
|
|
7509
7535
|
React.createElement("div", { ref: containerOptions, className: "".concat(style$f["".concat(classMUI, "-container-options")]) }, isOpen &&
|
|
7536
|
+
container &&
|
|
7510
7537
|
ReactDOM.createPortal(React.createElement("div", { style: {
|
|
7511
7538
|
position: 'absolute',
|
|
7512
7539
|
top: "".concat(menuPosition.top - 60, "px "),
|
|
@@ -7516,7 +7543,7 @@ var ContainerDesktop$3 = function (_a) {
|
|
|
7516
7543
|
}, ref: dropdownRef, className: "".concat(style$f["".concat(classMUI, "-container-options__menu")]) },
|
|
7517
7544
|
inputSearchProps && React.createElement(InputSearch, __assign({}, inputSearchProps)),
|
|
7518
7545
|
React.createElement("div", { className: "".concat(style$f["".concat(classMUI, "-container-options__menu--tags")]) }, selectedValues.map(function (itemSelected) { return (React.createElement(Tags, { key: itemSelected.id, text: itemSelected.name, icon: Close, bgColor: "#F4F4FA", onClick: function () { return removeValueToArray(itemSelected); } })); })),
|
|
7519
|
-
React.createElement("div", { className: "".concat(style$f["".concat(classMUI, "-container-options__menu--list")]) }, listOptions.map(function (value) { return (React.createElement(SelectItem$1, { disable: !limitOfSelectable || selectedValues.includes(value), key: value.id, onClick: function () { return addValueToArray(value); }, text: value.name })); }))),
|
|
7546
|
+
React.createElement("div", { className: "".concat(style$f["".concat(classMUI, "-container-options__menu--list")]) }, listOptions.map(function (value) { return (React.createElement(SelectItem$1, { disable: !limitOfSelectable || selectedValues.includes(value), key: value.id, onClick: function () { return addValueToArray(value); }, text: value.name })); }))), container))));
|
|
7520
7547
|
};
|
|
7521
7548
|
|
|
7522
7549
|
var style$e = {"magneto-ui-container-options":"mg_container_mobile_magneto-ui-container-options_1caxk","magneto-ui-container-options-tags-container":"mg_container_mobile_magneto-ui-container-options-tags-container_1caxk","magneto-ui-container-options__menu":"mg_container_mobile_magneto-ui-container-options_menu_1caxk","magneto-ui-container-options__menu--tags":"mg_container_mobile_magneto-ui-container-options_menu--tags_1caxk","magneto-ui-container-options__menu--list":"mg_container_mobile_magneto-ui-container-options_menu--list_1caxk"};
|
|
@@ -8088,10 +8115,12 @@ var useContainerDesktop = function (_a) {
|
|
|
8088
8115
|
var ContainerDesktop$1 = function (_a) {
|
|
8089
8116
|
var listOptions = _a.listOptions, addValue = _a.addValue, dropDownTitle = _a.dropDownTitle, selectedValue = _a.selectedValue;
|
|
8090
8117
|
var _b = useContainerDesktop({ addValue: addValue }), containerOptions = _b.containerOptions, menuPosition = _b.menuPosition, toggleDropdown = _b.toggleDropdown, isOpen = _b.isOpen, dropdownRef = _b.dropdownRef, inputRef = _b.inputRef, selectValue = _b.selectValue;
|
|
8118
|
+
var container = useContext(ContainerContext).container;
|
|
8091
8119
|
return (React.createElement("div", { style: { zIndex: 999999 } },
|
|
8092
8120
|
React.createElement("div", { ref: inputRef },
|
|
8093
8121
|
React.createElement(DropDownButton, { title: dropDownTitle, onClick: toggleDropdown })),
|
|
8094
8122
|
React.createElement("div", { ref: containerOptions, className: "".concat(style$b["".concat(classMUI, "-container-options")]) }, isOpen &&
|
|
8123
|
+
container &&
|
|
8095
8124
|
ReactDOM.createPortal(React.createElement("div", { style: {
|
|
8096
8125
|
position: 'absolute',
|
|
8097
8126
|
top: "".concat(menuPosition.top - 8, "px "),
|
|
@@ -8099,7 +8128,7 @@ var ContainerDesktop$1 = function (_a) {
|
|
|
8099
8128
|
width: "".concat(menuPosition.width, "px"),
|
|
8100
8129
|
zIndex: 999999
|
|
8101
8130
|
}, ref: dropdownRef, className: "".concat(style$b["".concat(classMUI, "-container-options__menu")]) },
|
|
8102
|
-
React.createElement("div", { className: "".concat(style$b["".concat(classMUI, "-container-options__menu--list")]) }, listOptions.map(function (value) { return (React.createElement(SelectItem, { selected: (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.id) === value.id, disable: (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.id) === value.id, key: value.id, onClick: function () { return selectValue(value.id); }, text: value.label })); }))),
|
|
8131
|
+
React.createElement("div", { className: "".concat(style$b["".concat(classMUI, "-container-options__menu--list")]) }, listOptions.map(function (value) { return (React.createElement(SelectItem, { selected: (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.id) === value.id, disable: (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.id) === value.id, key: value.id, onClick: function () { return selectValue(value.id); }, text: value.label })); }))), container))));
|
|
8103
8132
|
};
|
|
8104
8133
|
|
|
8105
8134
|
var style$a = {"magneto-ui-container-options":"mg_container_mobile_magneto-ui-container-options_16tb3","magneto-ui-container-options__menu":"mg_container_mobile_magneto-ui-container-options_menu_16tb3","magneto-ui-container-options__menu--list":"mg_container_mobile_magneto-ui-container-options_menu--list_16tb3"};
|