@chayns-components/core 5.0.0-beta.175 → 5.0.0-beta.176
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/lib/components/popup/Popup.d.ts +18 -0
- package/lib/components/popup/Popup.js +130 -0
- package/lib/components/popup/Popup.js.map +1 -0
- package/lib/components/popup/Popup.styles.d.ts +2 -0
- package/lib/components/popup/Popup.styles.js +22 -0
- package/lib/components/popup/Popup.styles.js.map +1 -0
- package/lib/components/popup/interface.d.ts +16 -0
- package/lib/components/popup/interface.js +17 -0
- package/lib/components/popup/interface.js.map +1 -0
- package/lib/components/popup/popup-content/PopupContent.d.ts +9 -0
- package/lib/components/popup/popup-content/PopupContent.js +64 -0
- package/lib/components/popup/popup-content/PopupContent.js.map +1 -0
- package/lib/components/popup/popup-content/PopupContent.styles.d.ts +6 -0
- package/lib/components/popup/popup-content/PopupContent.styles.js +90 -0
- package/lib/components/popup/popup-content/PopupContent.styles.js.map +1 -0
- package/lib/utils/calculate.d.ts +1 -1
- package/lib/utils/calculate.js +10 -10
- package/lib/utils/calculate.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { PopupRef } from './interface';
|
|
3
|
+
export type PopupProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The content that should be displayed inside the popup.
|
|
6
|
+
*/
|
|
7
|
+
content: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Function to be executed when the content of the Context menu has been hidden.
|
|
10
|
+
*/
|
|
11
|
+
onHide?: VoidFunction;
|
|
12
|
+
/**
|
|
13
|
+
* Function to be executed when the content of the Context menu has been shown.
|
|
14
|
+
*/
|
|
15
|
+
onShow?: VoidFunction;
|
|
16
|
+
};
|
|
17
|
+
declare const Popup: React.ForwardRefExoticComponent<PopupProps & React.RefAttributes<PopupRef>>;
|
|
18
|
+
export default Popup;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _framerMotion = require("framer-motion");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactDom = require("react-dom");
|
|
10
|
+
var _uuid = require("../../hooks/uuid");
|
|
11
|
+
var _interface = require("./interface");
|
|
12
|
+
var _PopupContent = _interopRequireDefault(require("./popup-content/PopupContent"));
|
|
13
|
+
var _Popup = require("./Popup.styles");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
const Popup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
18
|
+
let {
|
|
19
|
+
content,
|
|
20
|
+
onShow,
|
|
21
|
+
onHide,
|
|
22
|
+
children
|
|
23
|
+
} = _ref;
|
|
24
|
+
const [coordinates, setCoordinates] = (0, _react.useState)({
|
|
25
|
+
x: 0,
|
|
26
|
+
y: 0
|
|
27
|
+
});
|
|
28
|
+
const container = document.body;
|
|
29
|
+
const [alignment, setAlignment] = (0, _react.useState)(_interface.PopupAlignment.TopLeft);
|
|
30
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
31
|
+
const [portal, setPortal] = (0, _react.useState)();
|
|
32
|
+
const uuid = (0, _uuid.useUuid)();
|
|
33
|
+
|
|
34
|
+
// ToDo: Replace with hook if new chayns api is ready
|
|
35
|
+
const popupContentRef = (0, _react.useRef)(null);
|
|
36
|
+
const popupPseudoContentRef = (0, _react.useRef)(null);
|
|
37
|
+
const popupRef = (0, _react.useRef)(null);
|
|
38
|
+
const handleShow = (0, _react.useCallback)(() => {
|
|
39
|
+
if (popupRef.current && popupPseudoContentRef.current) {
|
|
40
|
+
const {
|
|
41
|
+
height: pseudoHeight,
|
|
42
|
+
width: pseudoWidth
|
|
43
|
+
} = popupPseudoContentRef.current.getBoundingClientRect();
|
|
44
|
+
const {
|
|
45
|
+
x: childrenX,
|
|
46
|
+
y: childrenY,
|
|
47
|
+
height: childrenHeight,
|
|
48
|
+
width: childrenWidth
|
|
49
|
+
} = popupRef.current.getBoundingClientRect();
|
|
50
|
+
if (pseudoHeight > childrenY - 25) {
|
|
51
|
+
if (pseudoWidth > childrenX + childrenWidth / 2 - 25) {
|
|
52
|
+
setAlignment(_interface.PopupAlignment.BottomRight);
|
|
53
|
+
} else {
|
|
54
|
+
setAlignment(_interface.PopupAlignment.BottomLeft);
|
|
55
|
+
}
|
|
56
|
+
setCoordinates({
|
|
57
|
+
x: childrenX + childrenWidth / 2,
|
|
58
|
+
y: childrenY + childrenHeight - 15
|
|
59
|
+
});
|
|
60
|
+
} else if (pseudoWidth > childrenX + childrenWidth / 2 - 25) {
|
|
61
|
+
setAlignment(_interface.PopupAlignment.TopRight);
|
|
62
|
+
setCoordinates({
|
|
63
|
+
x: childrenX + childrenWidth / 2,
|
|
64
|
+
y: childrenY
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
setAlignment(_interface.PopupAlignment.TopLeft);
|
|
68
|
+
setCoordinates({
|
|
69
|
+
x: childrenX + childrenWidth / 2,
|
|
70
|
+
y: childrenY + 15
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
setIsOpen(true);
|
|
74
|
+
}
|
|
75
|
+
}, []);
|
|
76
|
+
const handleChildrenClick = () => {
|
|
77
|
+
handleShow();
|
|
78
|
+
};
|
|
79
|
+
const handleHide = (0, _react.useCallback)(() => {
|
|
80
|
+
setIsOpen(false);
|
|
81
|
+
}, []);
|
|
82
|
+
const handleDocumentClick = (0, _react.useCallback)(event => {
|
|
83
|
+
var _popupContentRef$curr;
|
|
84
|
+
if (!((_popupContentRef$curr = popupContentRef.current) !== null && _popupContentRef$curr !== void 0 && _popupContentRef$curr.contains(event.target))) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
}
|
|
88
|
+
handleHide();
|
|
89
|
+
}, [handleHide]);
|
|
90
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
91
|
+
hide: handleHide,
|
|
92
|
+
show: handleShow
|
|
93
|
+
}), [handleHide, handleShow]);
|
|
94
|
+
(0, _react.useEffect)(() => {
|
|
95
|
+
if (isOpen) {
|
|
96
|
+
document.addEventListener('click', handleDocumentClick, true);
|
|
97
|
+
window.addEventListener('blur', handleHide);
|
|
98
|
+
if (typeof onShow === 'function') {
|
|
99
|
+
onShow();
|
|
100
|
+
}
|
|
101
|
+
} else if (typeof onHide === 'function') {
|
|
102
|
+
onHide();
|
|
103
|
+
}
|
|
104
|
+
return () => {
|
|
105
|
+
document.removeEventListener('click', handleDocumentClick, true);
|
|
106
|
+
window.removeEventListener('blur', handleHide);
|
|
107
|
+
};
|
|
108
|
+
}, [handleDocumentClick, handleHide, isOpen, onHide, onShow]);
|
|
109
|
+
(0, _react.useEffect)(() => {
|
|
110
|
+
setPortal(() => /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react.default.createElement(_framerMotion.AnimatePresence, {
|
|
111
|
+
initial: false
|
|
112
|
+
}, isOpen && /*#__PURE__*/_react.default.createElement(_PopupContent.default, {
|
|
113
|
+
coordinates: coordinates,
|
|
114
|
+
content: content,
|
|
115
|
+
key: `tooltip_${uuid}`,
|
|
116
|
+
alignment: alignment,
|
|
117
|
+
ref: popupContentRef
|
|
118
|
+
})), container));
|
|
119
|
+
}, [alignment, container, content, coordinates, isOpen, uuid]);
|
|
120
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Popup.StyledPopupPseudo, {
|
|
121
|
+
ref: popupPseudoContentRef
|
|
122
|
+
}, content), /*#__PURE__*/_react.default.createElement(_Popup.StyledPopup, {
|
|
123
|
+
ref: popupRef,
|
|
124
|
+
onClick: handleChildrenClick
|
|
125
|
+
}, children), portal);
|
|
126
|
+
});
|
|
127
|
+
Popup.displayName = 'Popup';
|
|
128
|
+
var _default = Popup;
|
|
129
|
+
exports.default = _default;
|
|
130
|
+
//# sourceMappingURL=Popup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popup.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_reactDom","_uuid","_interface","_PopupContent","_interopRequireDefault","_Popup","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Popup","forwardRef","_ref","ref","content","onShow","onHide","children","coordinates","setCoordinates","useState","x","y","container","document","body","alignment","setAlignment","PopupAlignment","TopLeft","isOpen","setIsOpen","portal","setPortal","uuid","useUuid","popupContentRef","useRef","popupPseudoContentRef","popupRef","handleShow","useCallback","current","height","pseudoHeight","width","pseudoWidth","getBoundingClientRect","childrenX","childrenY","childrenHeight","childrenWidth","BottomRight","BottomLeft","TopRight","handleChildrenClick","handleHide","handleDocumentClick","event","_popupContentRef$curr","contains","target","preventDefault","stopPropagation","useImperativeHandle","hide","show","useEffect","addEventListener","window","removeEventListener","createPortal","createElement","AnimatePresence","initial","Fragment","StyledPopupPseudo","StyledPopup","onClick","displayName","_default","exports"],"sources":["../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n forwardRef,\n ReactNode,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from './interface';\nimport PopupContent from './popup-content/PopupContent';\nimport { StyledPopup, StyledPopupPseudo } from './Popup.styles';\n\nexport type PopupProps = {\n /**\n * The content that should be displayed inside the popup.\n */\n content: ReactNode;\n /**\n * Function to be executed when the content of the Context menu has been hidden.\n */\n onHide?: VoidFunction;\n /**\n * Function to be executed when the content of the Context menu has been shown.\n */\n onShow?: VoidFunction;\n};\n\nconst Popup = forwardRef<PopupRef, PopupProps>(({ content, onShow, onHide, children }, ref) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n const container = document.body;\n\n const [alignment, setAlignment] = useState<PopupAlignment>(PopupAlignment.TopLeft);\n const [isOpen, setIsOpen] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n\n const uuid = useUuid();\n\n // ToDo: Replace with hook if new chayns api is ready\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupPseudoContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n const handleShow = useCallback(() => {\n if (popupRef.current && popupPseudoContentRef.current) {\n const { height: pseudoHeight, width: pseudoWidth } =\n popupPseudoContentRef.current.getBoundingClientRect();\n\n const {\n x: childrenX,\n y: childrenY,\n height: childrenHeight,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n if (pseudoHeight > childrenY - 25) {\n if (pseudoWidth > childrenX + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.BottomRight);\n } else {\n setAlignment(PopupAlignment.BottomLeft);\n }\n\n setCoordinates({\n x: childrenX + childrenWidth / 2,\n y: childrenY + childrenHeight - 15,\n });\n } else if (pseudoWidth > childrenX + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.TopRight);\n setCoordinates({\n x: childrenX + childrenWidth / 2,\n y: childrenY,\n });\n } else {\n setAlignment(PopupAlignment.TopLeft);\n setCoordinates({\n x: childrenX + childrenWidth / 2,\n y: childrenY + 15,\n });\n }\n\n setIsOpen(true);\n }\n }, []);\n\n const handleChildrenClick = () => {\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n handleHide();\n },\n [handleHide]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow]\n );\n\n useEffect(() => {\n if (isOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n\n if (typeof onShow === 'function') {\n onShow();\n }\n } else if (typeof onHide === 'function') {\n onHide();\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isOpen, onHide, onShow]);\n\n useEffect(() => {\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isOpen && (\n <PopupContent\n coordinates={coordinates}\n content={content}\n key={`tooltip_${uuid}`}\n alignment={alignment}\n ref={popupContentRef}\n />\n )}\n </AnimatePresence>,\n container\n )\n );\n }, [alignment, container, content, coordinates, isOpen, uuid]);\n\n return (\n <>\n <StyledPopupPseudo ref={popupPseudoContentRef}>{content}</StyledPopupPse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A"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledPopupPseudo = exports.StyledPopup = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const StyledPopup = _styledComponents.default.span`
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
position: relative;
|
|
12
|
+
`;
|
|
13
|
+
exports.StyledPopup = StyledPopup;
|
|
14
|
+
const StyledPopupPseudo = _styledComponents.default.div`
|
|
15
|
+
top: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
visibility: hidden;
|
|
19
|
+
position: absolute;
|
|
20
|
+
`;
|
|
21
|
+
exports.StyledPopupPseudo = StyledPopupPseudo;
|
|
22
|
+
//# sourceMappingURL=Popup.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popup.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledPopup","styled","span","exports","StyledPopupPseudo","div"],"sources":["../../../src/components/popup/Popup.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledPopup = styled.span`\n cursor: pointer;\n position: relative;\n`;\n\nexport const StyledPopupPseudo = styled.div`\n top: 0;\n left: 0;\n pointer-events: none;\n visibility: hidden;\n position: absolute;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,WAAW,GAAGC,yBAAM,CAACC,IAAK;AACvC;AACA;AACA,CAAC;AAACC,OAAA,CAAAH,WAAA,GAAAA,WAAA;AAEK,MAAMI,iBAAiB,GAAGH,yBAAM,CAACI,GAAI;AAC5C;AACA;AACA;AACA;AACA;AACA,CAAC;AAACF,OAAA,CAAAC,iBAAA,GAAAA,iBAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare enum PopupAlignment {
|
|
2
|
+
TopLeft = 0,
|
|
3
|
+
TopCenter = 1,
|
|
4
|
+
TopRight = 2,
|
|
5
|
+
BottomLeft = 3,
|
|
6
|
+
BottomCenter = 4,
|
|
7
|
+
BottomRight = 5
|
|
8
|
+
}
|
|
9
|
+
export type PopupCoordinates = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
export type PopupRef = {
|
|
14
|
+
hide: VoidFunction;
|
|
15
|
+
show: VoidFunction;
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PopupAlignment = void 0;
|
|
7
|
+
let PopupAlignment = /*#__PURE__*/function (PopupAlignment) {
|
|
8
|
+
PopupAlignment[PopupAlignment["TopLeft"] = 0] = "TopLeft";
|
|
9
|
+
PopupAlignment[PopupAlignment["TopCenter"] = 1] = "TopCenter";
|
|
10
|
+
PopupAlignment[PopupAlignment["TopRight"] = 2] = "TopRight";
|
|
11
|
+
PopupAlignment[PopupAlignment["BottomLeft"] = 3] = "BottomLeft";
|
|
12
|
+
PopupAlignment[PopupAlignment["BottomCenter"] = 4] = "BottomCenter";
|
|
13
|
+
PopupAlignment[PopupAlignment["BottomRight"] = 5] = "BottomRight";
|
|
14
|
+
return PopupAlignment;
|
|
15
|
+
}({});
|
|
16
|
+
exports.PopupAlignment = PopupAlignment;
|
|
17
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","names":["PopupAlignment","exports"],"sources":["../../../src/components/popup/interface.ts"],"sourcesContent":["export enum PopupAlignment {\n TopLeft,\n TopCenter,\n TopRight,\n BottomLeft,\n BottomCenter,\n BottomRight,\n}\n\nexport type PopupCoordinates = {\n x: number;\n y: number;\n};\n\nexport type PopupRef = {\n hide: VoidFunction;\n show: VoidFunction;\n};\n"],"mappings":";;;;;;IAAYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAAAC,OAAA,CAAAD,cAAA,GAAAA,cAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { PopupAlignment, PopupCoordinates } from '../interface';
|
|
3
|
+
type PopupContentProps = {
|
|
4
|
+
alignment: PopupAlignment;
|
|
5
|
+
coordinates: PopupCoordinates;
|
|
6
|
+
content: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
declare const PopupContent: React.ForwardRefExoticComponent<PopupContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export default PopupContent;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _interface = require("../interface");
|
|
9
|
+
var _PopupContent = require("./PopupContent.styles");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const PopupContent = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
12
|
+
let {
|
|
13
|
+
alignment,
|
|
14
|
+
coordinates,
|
|
15
|
+
content
|
|
16
|
+
} = _ref;
|
|
17
|
+
const isBottomLeftAlignment = alignment === _interface.PopupAlignment.BottomLeft;
|
|
18
|
+
const isTopLeftAlignment = alignment === _interface.PopupAlignment.TopLeft;
|
|
19
|
+
const isTopRightAlignment = alignment === _interface.PopupAlignment.TopRight;
|
|
20
|
+
const percentageOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? -100 : 0;
|
|
21
|
+
const percentageOffsetY = isTopRightAlignment || isTopLeftAlignment ? -100 : 0;
|
|
22
|
+
const anchorOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? 21 : -21;
|
|
23
|
+
const anchorOffsetY = isTopRightAlignment || isTopLeftAlignment ? -21 : 21;
|
|
24
|
+
const exitAndInitialY = isTopLeftAlignment || isTopRightAlignment ? -16 : 16;
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_PopupContent.StyledMotionPopupContent, {
|
|
26
|
+
animate: {
|
|
27
|
+
opacity: 1,
|
|
28
|
+
y: 0
|
|
29
|
+
},
|
|
30
|
+
exit: {
|
|
31
|
+
opacity: 0,
|
|
32
|
+
y: exitAndInitialY
|
|
33
|
+
},
|
|
34
|
+
initial: {
|
|
35
|
+
opacity: 0,
|
|
36
|
+
y: exitAndInitialY
|
|
37
|
+
},
|
|
38
|
+
position: alignment,
|
|
39
|
+
ref: ref,
|
|
40
|
+
style: {
|
|
41
|
+
left: coordinates.x,
|
|
42
|
+
top: coordinates.y
|
|
43
|
+
},
|
|
44
|
+
transition: {
|
|
45
|
+
type: 'tween'
|
|
46
|
+
},
|
|
47
|
+
transformTemplate: _ref2 => {
|
|
48
|
+
let {
|
|
49
|
+
y = '0px'
|
|
50
|
+
} = _ref2;
|
|
51
|
+
return `
|
|
52
|
+
translateX(${percentageOffsetX}%)
|
|
53
|
+
translateY(${percentageOffsetY}%)
|
|
54
|
+
translateX(${anchorOffsetX}px)
|
|
55
|
+
translateY(${anchorOffsetY}px)
|
|
56
|
+
translateY(${y})
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
}, content);
|
|
60
|
+
});
|
|
61
|
+
PopupContent.displayName = 'PopupContent';
|
|
62
|
+
var _default = PopupContent;
|
|
63
|
+
exports.default = _default;
|
|
64
|
+
//# sourceMappingURL=PopupContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopupContent.js","names":["_react","_interopRequireDefault","require","_interface","_PopupContent","obj","__esModule","default","PopupContent","React","forwardRef","_ref","ref","alignment","coordinates","content","isBottomLeftAlignment","PopupAlignment","BottomLeft","isTopLeftAlignment","TopLeft","isTopRightAlignment","TopRight","percentageOffsetX","percentageOffsetY","anchorOffsetX","anchorOffsetY","exitAndInitialY","createElement","StyledMotionPopupContent","animate","opacity","y","exit","initial","position","style","left","x","top","transition","type","transformTemplate","_ref2","displayName","_default","exports"],"sources":["../../../../src/components/popup/popup-content/PopupContent.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { PopupAlignment, PopupCoordinates } from '../interface';\nimport { StyledMotionPopupContent } from './PopupContent.styles';\n\ntype PopupContentProps = {\n alignment: PopupAlignment;\n coordinates: PopupCoordinates;\n content: ReactNode;\n};\n\nconst PopupContent = React.forwardRef<HTMLDivElement, PopupContentProps>(\n ({ alignment, coordinates, content }, ref) => {\n const isBottomLeftAlignment = alignment === PopupAlignment.BottomLeft;\n const isTopLeftAlignment = alignment === PopupAlignment.TopLeft;\n const isTopRightAlignment = alignment === PopupAlignment.TopRight;\n\n const percentageOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? -100 : 0;\n const percentageOffsetY = isTopRightAlignment || isTopLeftAlignment ? -100 : 0;\n\n const anchorOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? 21 : -21;\n const anchorOffsetY = isTopRightAlignment || isTopLeftAlignment ? -21 : 21;\n\n const exitAndInitialY = isTopLeftAlignment || isTopRightAlignment ? -16 : 16;\n\n return (\n <StyledMotionPopupContent\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: exitAndInitialY }}\n initial={{ opacity: 0, y: exitAndInitialY }}\n position={alignment}\n ref={ref}\n style={{ left: coordinates.x, top: coordinates.y }}\n transition={{ type: 'tween' }}\n transformTemplate={({ y = '0px' }) => `\n translateX(${percentageOffsetX}%)\n translateY(${percentageOffsetY}%)\n translateX(${anchorOffsetX}px)\n translateY(${anchorOffsetY}px)\n translateY(${y})\n `}\n >\n {content}\n </StyledMotionPopupContent>\n );\n }\n);\n\nPopupContent.displayName = 'PopupContent';\n\nexport default PopupContent;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAAiE,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAQjE,MAAMG,YAAY,gBAAGC,cAAK,CAACC,UAAU,CACjC,CAAAC,IAAA,EAAsCC,GAAG,KAAK;EAAA,IAA7C;IAAEC,SAAS;IAAEC,WAAW;IAAEC;EAAQ,CAAC,GAAAJ,IAAA;EAChC,MAAMK,qBAAqB,GAAGH,SAAS,KAAKI,yBAAc,CAACC,UAAU;EACrE,MAAMC,kBAAkB,GAAGN,SAAS,KAAKI,yBAAc,CAACG,OAAO;EAC/D,MAAMC,mBAAmB,GAAGR,SAAS,KAAKI,yBAAc,CAACK,QAAQ;EAEjE,MAAMC,iBAAiB,GAAGP,qBAAqB,IAAIG,kBAAkB,GAAG,CAAC,GAAG,GAAG,CAAC;EAChF,MAAMK,iBAAiB,GAAGH,mBAAmB,IAAIF,kBAAkB,GAAG,CAAC,GAAG,GAAG,CAAC;EAE9E,MAAMM,aAAa,GAAGT,qBAAqB,IAAIG,kBAAkB,GAAG,EAAE,GAAG,CAAC,EAAE;EAC5E,MAAMO,aAAa,GAAGL,mBAAmB,IAAIF,kBAAkB,GAAG,CAAC,EAAE,GAAG,EAAE;EAE1E,MAAMQ,eAAe,GAAGR,kBAAkB,IAAIE,mBAAmB,GAAG,CAAC,EAAE,GAAG,EAAE;EAE5E,oBACIrB,MAAA,CAAAO,OAAA,CAAAqB,aAAA,CAACxB,aAAA,CAAAyB,wBAAwB;IACrBC,OAAO,EAAE;MAAEC,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAE;IAAE,CAAE;IAC9BC,IAAI,EAAE;MAAEF,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAEL;IAAgB,CAAE;IACzCO,OAAO,EAAE;MAAEH,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAEL;IAAgB,CAAE;IAC5CQ,QAAQ,EAAEtB,SAAU;IACpBD,GAAG,EAAEA,GAAI;IACTwB,KAAK,EAAE;MAAEC,IAAI,EAAEvB,WAAW,CAACwB,CAAC;MAAEC,GAAG,EAAEzB,WAAW,CAACkB;IAAE,CAAE;IACnDQ,UAAU,EAAE;MAAEC,IAAI,EAAE;IAAQ,CAAE;IAC9BC,iBAAiB,EAAEC,KAAA;MAAA,IAAC;QAAEX,CAAC,GAAG;MAAM,CAAC,GAAAW,KAAA;MAAA,OAAM;AACvD,iCAAiCpB,iBAAkB;AACnD,iCAAiCC,iBAAkB;AACnD,iCAAiCC,aAAc;AAC/C,iCAAiCC,aAAc;AAC/C,iCAAiCM,CAAE;AACnC,iBAAiB;IAAA;EAAC,GAEDjB,OACqB,CAAC;AAEnC,CACJ,CAAC;AAEDP,YAAY,CAACoC,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAE3BrC,YAAY;AAAAsC,OAAA,CAAAvC,OAAA,GAAAsC,QAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PopupAlignment } from '../interface';
|
|
2
|
+
export declare const StyledMotionPopupContent: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {
|
|
3
|
+
position: PopupAlignment;
|
|
4
|
+
} & {
|
|
5
|
+
theme: import("../../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
6
|
+
}, never>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledMotionPopupContent = void 0;
|
|
7
|
+
var _framerMotion = require("framer-motion");
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
var _interface = require("../interface");
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
+
const StyledMotionPopupContent = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
13
|
+
background-color: ${_ref => {
|
|
14
|
+
let {
|
|
15
|
+
theme
|
|
16
|
+
} = _ref;
|
|
17
|
+
return theme['001'];
|
|
18
|
+
}};
|
|
19
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
20
|
+
border-radius: 3px;
|
|
21
|
+
box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);
|
|
22
|
+
color: ${_ref2 => {
|
|
23
|
+
let {
|
|
24
|
+
theme
|
|
25
|
+
} = _ref2;
|
|
26
|
+
return theme.text;
|
|
27
|
+
}};
|
|
28
|
+
position: absolute;
|
|
29
|
+
z-index: 0;
|
|
30
|
+
|
|
31
|
+
::after {
|
|
32
|
+
background-color: inherit;
|
|
33
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
34
|
+
border-bottom-right-radius: 3px;
|
|
35
|
+
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
|
36
|
+
box-shadow: 2px 2px 8px rgb(4 3 4 / 10%);
|
|
37
|
+
content: '';
|
|
38
|
+
height: 14px;
|
|
39
|
+
position: absolute;
|
|
40
|
+
width: 14px;
|
|
41
|
+
z-index: -2;
|
|
42
|
+
|
|
43
|
+
${_ref3 => {
|
|
44
|
+
let {
|
|
45
|
+
position
|
|
46
|
+
} = _ref3;
|
|
47
|
+
switch (position) {
|
|
48
|
+
case _interface.PopupAlignment.TopLeft:
|
|
49
|
+
return (0, _styledComponents.css)`
|
|
50
|
+
bottom: -8px;
|
|
51
|
+
right: 13px;
|
|
52
|
+
transform: rotate(45deg);
|
|
53
|
+
`;
|
|
54
|
+
case _interface.PopupAlignment.BottomLeft:
|
|
55
|
+
return (0, _styledComponents.css)`
|
|
56
|
+
top: -8px;
|
|
57
|
+
right: 13px;
|
|
58
|
+
transform: rotate(225deg);
|
|
59
|
+
`;
|
|
60
|
+
case _interface.PopupAlignment.TopRight:
|
|
61
|
+
return (0, _styledComponents.css)`
|
|
62
|
+
transform: rotate(45deg);
|
|
63
|
+
bottom: -8px;
|
|
64
|
+
left: 13px;
|
|
65
|
+
`;
|
|
66
|
+
case _interface.PopupAlignment.BottomRight:
|
|
67
|
+
return (0, _styledComponents.css)`
|
|
68
|
+
transform: rotate(225deg);
|
|
69
|
+
top: -8px;
|
|
70
|
+
left: 13px;
|
|
71
|
+
`;
|
|
72
|
+
default:
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
::before {
|
|
79
|
+
background-color: inherit;
|
|
80
|
+
bottom: 0;
|
|
81
|
+
content: '';
|
|
82
|
+
left: 0;
|
|
83
|
+
position: absolute;
|
|
84
|
+
right: 0;
|
|
85
|
+
top: 0;
|
|
86
|
+
z-index: -1;
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
exports.StyledMotionPopupContent = StyledMotionPopupContent;
|
|
90
|
+
//# sourceMappingURL=PopupContent.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopupContent.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_interface","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StyledMotionPopupContent","styled","motion","div","_ref","theme","_ref2","text","_ref3","position","PopupAlignment","TopLeft","css","BottomLeft","TopRight","BottomRight","undefined","exports"],"sources":["../../../../src/components/popup/popup-content/PopupContent.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { PopupAlignment } from '../interface';\n\ntype StyledMotionPopupContentProps = WithTheme<{\n position: PopupAlignment;\n}>;\n\nexport const StyledMotionPopupContent = styled(motion.div)<StyledMotionPopupContentProps>`\n background-color: ${({ theme }: StyledMotionPopupContentProps) => theme['001']};\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-radius: 3px;\n box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);\n color: ${({ theme }: StyledMotionPopupContentProps) => theme.text};\n position: absolute;\n z-index: 0;\n\n ::after {\n background-color: inherit;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n border-bottom-right-radius: 3px;\n border-right: 1px solid rgba(0, 0, 0, 0.1);\n box-shadow: 2px 2px 8px rgb(4 3 4 / 10%);\n content: '';\n height: 14px;\n position: absolute;\n width: 14px;\n z-index: -2;\n\n ${({ position }) => {\n switch (position) {\n case PopupAlignment.TopLeft:\n return css`\n bottom: -8px;\n right: 13px;\n transform: rotate(45deg);\n `;\n case PopupAlignment.BottomLeft:\n return css`\n top: -8px;\n right: 13px;\n transform: rotate(225deg);\n `;\n case PopupAlignment.TopRight:\n return css`\n transform: rotate(45deg);\n bottom: -8px;\n left: 13px;\n `;\n case PopupAlignment.BottomRight:\n return css`\n transform: rotate(225deg);\n top: -8px;\n left: 13px;\n `;\n default:\n return undefined;\n }\n }}\n }\n\n ::before {\n background-color: inherit;\n bottom: 0;\n content: '';\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -1;\n }\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AAA8C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,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AACI,QAAQ;MACxB,OAAO,IAAAF,qBAAG,CAAC;AAC/B;AACA;AACA;AACA,qBAAqB;IACL,KAAKF,yBAAc,CAACK,WAAW;MAC3B,OAAO,IAAAH,qBAAG,CAAC;AAC/B;AACA;AACA;AACA,qBAAqB;IACL;MACI,OAAOI,SAAS;EACxB;AACJ,CAAE;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAjB,wBAAA,GAAAA,wBAAA"}
|
package/lib/utils/calculate.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const calculateContentWidth: (texts: string[]) => number;
|
|
2
|
-
export declare const calculateContentHeight: (
|
|
2
|
+
export declare const calculateContentHeight: (elements: string[]) => number;
|
package/lib/utils/calculate.js
CHANGED
|
@@ -20,17 +20,17 @@ const calculateContentWidth = texts => {
|
|
|
20
20
|
return Math.max.apply(null, length);
|
|
21
21
|
};
|
|
22
22
|
exports.calculateContentWidth = calculateContentWidth;
|
|
23
|
-
const calculateContentHeight =
|
|
23
|
+
const calculateContentHeight = elements => {
|
|
24
24
|
const length = [];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
div.innerText =
|
|
25
|
+
const div = document.createElement('p');
|
|
26
|
+
div.style.visibility = 'hidden';
|
|
27
|
+
div.style.position = 'absolute';
|
|
28
|
+
div.style.width = 'auto';
|
|
29
|
+
div.style.margin = '5px';
|
|
30
|
+
div.style.whiteSpace = 'nowrap';
|
|
31
|
+
document.body.appendChild(div);
|
|
32
|
+
elements.forEach(element => {
|
|
33
|
+
div.innerText = element;
|
|
34
34
|
length.push(div.offsetHeight);
|
|
35
35
|
document.body.removeChild(div);
|
|
36
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate.js","names":["calculateContentWidth","texts","length","forEach","text","div","document","createElement","style","visibility","position","width","whiteSpace","body","appendChild","innerText","push","offsetWidth","removeChild","Math","max","apply","exports","calculateContentHeight","margin","offsetHeight","reduce","partialSum","a"],"sources":["../../src/utils/calculate.ts"],"sourcesContent":["export const calculateContentWidth = (texts: string[]) => {\n const length: number[] = [];\n\n texts.forEach((text) => {\n const div = document.createElement('div');\n div.style.visibility = 'hidden';\n div.style.position = 'absolute';\n div.style.width = 'auto';\n div.style.whiteSpace = 'nowrap';\n document.body.appendChild(div);\n\n div.innerText = text;\n\n length.push(div.offsetWidth);\n\n document.body.removeChild(div);\n });\n\n return Math.max.apply(null, length);\n};\n\nexport const calculateContentHeight = (
|
|
1
|
+
{"version":3,"file":"calculate.js","names":["calculateContentWidth","texts","length","forEach","text","div","document","createElement","style","visibility","position","width","whiteSpace","body","appendChild","innerText","push","offsetWidth","removeChild","Math","max","apply","exports","calculateContentHeight","elements","margin","element","offsetHeight","reduce","partialSum","a"],"sources":["../../src/utils/calculate.ts"],"sourcesContent":["export const calculateContentWidth = (texts: string[]) => {\n const length: number[] = [];\n\n texts.forEach((text) => {\n const div = document.createElement('div');\n div.style.visibility = 'hidden';\n div.style.position = 'absolute';\n div.style.width = 'auto';\n div.style.whiteSpace = 'nowrap';\n document.body.appendChild(div);\n\n div.innerText = text;\n\n length.push(div.offsetWidth);\n\n document.body.removeChild(div);\n });\n\n return Math.max.apply(null, length);\n};\n\nexport const calculateContentHeight = (elements: string[]) => {\n const length: number[] = [];\n\n const div = document.createElement('p');\n div.style.visibility = 'hidden';\n div.style.position = 'absolute';\n div.style.width = 'auto';\n div.style.margin = '5px';\n div.style.whiteSpace = 'nowrap';\n document.body.appendChild(div);\n\n elements.forEach((element: string) => {\n div.innerText = element;\n\n length.push(div.offsetHeight);\n\n document.body.removeChild(div);\n });\n\n return length.reduce((partialSum, a) => partialSum + a, 0);\n};\n"],"mappings":";;;;;;AAAO,MAAMA,qBAAqB,GAAIC,KAAe,IAAK;EACtD,MAAMC,MAAgB,GAAG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EvBxB,MAAM,CAACc,IAAI,CAACX,GAAG,CAACsB,YAAY,CAAC;IAE7BrB,QAAQ,CAACO,IAAI,CAACK,WAAW,CAACb,GAAG,CAAC;EAClC,CAAC,CAAC;EAEF,OAAOH,MAAM,CAAC0B,MAAM,CAAC,CAACC,UAAU,EAAEC,CAAC,KAAKD,UAAU,GAAGC,CAAC,EAAE,CAAC,CAAC;AAC9D,CAAC;AAACR,OAAA,CAAAC,sBAAA,GAAAA,sBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.176",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chayns",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "ba18e5c342ffb57fd61a98a8e223a768d0595e5d"
|
|
67
67
|
}
|