@chayns-components/core 5.0.0-beta.174 → 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.
@@ -91,40 +91,50 @@ const ComboBox = _ref => {
91
91
  return items;
92
92
  }, [handleSetSelectedItem, list]);
93
93
 
94
+ /**
95
+ * This function resets the placeholder
96
+ */
97
+ const placeholderText = (0, _react.useMemo)(() => {
98
+ let text = placeholder;
99
+ if (!selectedItem) {
100
+ text = placeholder;
101
+ } else if (item !== null && item !== void 0 && item.text) {
102
+ text = item.text;
103
+ }
104
+ return text;
105
+ }, [item === null || item === void 0 ? void 0 : item.text, placeholder, selectedItem]);
106
+
94
107
  /**
95
108
  * This function opens the content of the combobox
96
109
  */
97
110
  const handleHeaderClick = () => {
98
111
  setIsAnimating(prevState => !prevState);
99
112
  };
100
- return (0, _react.useMemo)(() => {
101
- var _item$text;
102
- return /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBox, {
103
- ref: ref
104
- }, /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBoxHeader, {
105
- minWidth: minWidth,
106
- onClick: handleHeaderClick,
107
- isOpen: isAnimating
108
- }, /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBoxPlaceholder, null, (_item$text = item === null || item === void 0 ? void 0 : item.text) !== null && _item$text !== void 0 ? _item$text : placeholder), /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBoxIconWrapper, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
109
- icons: ['fa fa-chevron-down']
110
- }))), /*#__PURE__*/_react.default.createElement(_ComboBox.StyledMotionComboBoxBody, {
111
- height: height,
112
- initial: {
113
- height: 0,
114
- opacity: 0
115
- },
116
- animate: isAnimating ? {
117
- height: 'fit-content',
118
- opacity: 1
119
- } : {
120
- height: 0,
121
- opacity: 0
122
- },
123
- transition: {
124
- duration: 0.2
125
- }
126
- }, content));
127
- }, [content, height, isAnimating, item === null || item === void 0 ? void 0 : item.text, minWidth, placeholder]);
113
+ return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBox, {
114
+ ref: ref
115
+ }, /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBoxHeader, {
116
+ minWidth: minWidth,
117
+ onClick: handleHeaderClick,
118
+ isOpen: isAnimating
119
+ }, /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBoxPlaceholder, null, placeholderText), /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBoxIconWrapper, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
120
+ icons: ['fa fa-chevron-down']
121
+ }))), /*#__PURE__*/_react.default.createElement(_ComboBox.StyledMotionComboBoxBody, {
122
+ height: height,
123
+ initial: {
124
+ height: 0,
125
+ opacity: 0
126
+ },
127
+ animate: isAnimating ? {
128
+ height: 'fit-content',
129
+ opacity: 1
130
+ } : {
131
+ height: 0,
132
+ opacity: 0
133
+ },
134
+ transition: {
135
+ duration: 0.2
136
+ }
137
+ }, content)), [content, height, isAnimating, item === null || item === void 0 ? void 0 : item.text, minWidth, placeholder]);
128
138
  };
129
139
  ComboBox.displayName = 'ComboBox';
130
140
  var _default = ComboBox;
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.js","names":["_react","_interopRequireWildcard","require","_calculate","_Icon","_interopRequireDefault","_ComboBoxItem","_ComboBox","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ComboBox","_ref","placeholder","list","onSelect","selectedItem","item","setItem","useState","isAnimating","setIsAnimating","minWidth","setMinWidth","height","setHeight","ref","useRef","handleClick","useCallback","event","current","contains","target","useEffect","document","addEventListener","removeEventListener","handleSetSelectedItem","itemToSelect","textArray","map","_ref2","text","calculateContentHeight","push","calculateContentWidth","content","useMemo","items","forEach","_ref3","value","createElement","handleHeaderClick","prevState","_item$text","StyledComboBox","StyledComboBoxHeader","onClick","isOpen","StyledComboBoxPlaceholder","StyledComboBoxIconWrapper","icons","StyledMotionComboBoxBody","initial","opacity","animate","transition","duration","displayName","_default","exports"],"sources":["../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { calculateContentHeight, calculateContentWidth } from '../../utils/calculate';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxPlaceholder,\n StyledMotionComboBoxBody,\n} from './ComboBox.styles';\n\nexport interface IComboBoxItem {\n text: string;\n value: string | number;\n}\n\nexport type ComboBoxProps = {\n /**\n * The list of the items that should be displayed.\n */\n list: IComboBoxItem[];\n /**\n * Function that should be executed when an item is selected.\n */\n onSelect?: (comboboxItem: IComboBoxItem) => void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * An item that should be preselected.\n */\n selectedItem?: IComboBoxItem;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({ placeholder, list, onSelect, selectedItem }) => {\n const [item, setItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState(0);\n const [height, setHeight] = useState(0);\n\n const ref = useRef<HTMLDivElement>(null);\n\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n setIsAnimating(false);\n }\n },\n [ref]\n );\n\n useEffect(() => {\n document.addEventListener('click', handleClick);\n\n return () => {\n document.removeEventListener('click', handleClick);\n };\n }, [handleClick, ref]);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect: IComboBoxItem) => {\n setItem(itemToSelect);\n setIsAnimating(false);\n\n if (onSelect) {\n onSelect(itemToSelect);\n }\n },\n [onSelect]\n );\n\n /**\n * This function calculates the greatest width\n */\n useEffect(() => {\n const textArray = list.map(({ text }) => text);\n\n setHeight(calculateContentHeight(textArray));\n\n textArray.push(placeholder);\n\n setMinWidth(calculateContentWidth(textArray) + 45);\n }, [list, placeholder]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n if (selectedItem) {\n handleSetSelectedItem(selectedItem);\n }\n }, [handleSetSelectedItem, selectedItem]);\n\n /**\n * Function that renders the combobox items\n */\n const content = useMemo(() => {\n const items: ReactNode[] = [];\n\n list.forEach(({ text, value }) => {\n items.push(\n <ComboBoxItem\n key={value}\n value={value}\n text={text}\n onSelect={handleSetSelectedItem}\n />\n );\n });\n\n return items;\n }, [handleSetSelectedItem, list]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = () => {\n setIsAnimating((prevState) => !prevState);\n };\n\n return useMemo(\n () => (\n <StyledComboBox ref={ref}>\n <StyledComboBoxHeader\n minWidth={minWidth}\n onClick={handleHeaderClick}\n isOpen={isAnimating}\n >\n <StyledComboBoxPlaceholder>\n {item?.text ?? placeholder}\n </StyledComboBoxPlaceholder>\n <StyledComboBoxIconWrapper>\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n </StyledComboBoxHeader>\n <StyledMotionComboBoxBody\n height={height}\n initial={{ height: 0, opacity: 0 }}\n animate={\n isAnimating\n ? { height: 'fit-content', opacity: 1 }\n : { height: 0, opacity: 0 }\n }\n transition={{\n duration: 0.2,\n }}\n >\n {content}\n </StyledMotionComboBoxBody>\n </StyledComboBox>\n ),\n [content, height, isAnimating, item?.text, minWidth, placeholder]\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAA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,EAAEH,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE0B,IAAI,EAAErB,QAAQ,EAAET,WAAW,CACpE,CAAC;AACL,CAAC;AAEDF,QAAQ,CAAC2D,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAEnB5D,QAAQ;AAAA6D,OAAA,CAAAjF,OAAA,GAAAgF,QAAA"}
1
+ {"version":3,"file":"ComboBox.js","names":["_react","_interopRequireWildcard","require","_calculate","_Icon","_interopRequireDefault","_ComboBoxItem","_ComboBox","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ComboBox","_ref","placeholder","list","onSelect","selectedItem","item","setItem","useState","isAnimating","setIsAnimating","minWidth","setMinWidth","height","setHeight","ref","useRef","handleClick","useCallback","event","current","contains","target","useEffect","document","addEventListener","removeEventListener","handleSetSelectedItem","itemToSelect","textArray","map","_ref2","text","calculateContentHeight","push","calculateContentWidth","content","useMemo","items","forEach","_ref3","value","createElement","placeholderText","handleHeaderClick","prevState","StyledComboBox","StyledComboBoxHeader","onClick","isOpen","StyledComboBoxPlaceholder","StyledComboBoxIconWrapper","icons","StyledMotionComboBoxBody","initial","opacity","animate","transition","duration","displayName","_default","exports"],"sources":["../../../src/components/combobox/ComboBox.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { calculateContentHeight, calculateContentWidth } from '../../utils/calculate';\nimport Icon from '../icon/Icon';\nimport ComboBoxItem from './combobox-item/ComboBoxItem';\nimport {\n StyledComboBox,\n StyledComboBoxHeader,\n StyledComboBoxIconWrapper,\n StyledComboBoxPlaceholder,\n StyledMotionComboBoxBody,\n} from './ComboBox.styles';\n\nexport interface IComboBoxItem {\n text: string;\n value: string | number;\n}\n\nexport type ComboBoxProps = {\n /**\n * The list of the items that should be displayed.\n */\n list: IComboBoxItem[];\n /**\n * Function that should be executed when an item is selected.\n */\n onSelect?: (comboboxItem: IComboBoxItem) => void;\n /**\n * A text that should be displayed when no item is selected.\n */\n placeholder: string;\n /**\n * An item that should be preselected.\n */\n selectedItem?: IComboBoxItem;\n};\n\nconst ComboBox: FC<ComboBoxProps> = ({ placeholder, list, onSelect, selectedItem }) => {\n const [item, setItem] = useState<IComboBoxItem>();\n const [isAnimating, setIsAnimating] = useState(false);\n const [minWidth, setMinWidth] = useState(0);\n const [height, setHeight] = useState(0);\n\n const ref = useRef<HTMLDivElement>(null);\n\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n setIsAnimating(false);\n }\n },\n [ref]\n );\n\n useEffect(() => {\n document.addEventListener('click', handleClick);\n\n return () => {\n document.removeEventListener('click', handleClick);\n };\n }, [handleClick, ref]);\n\n /**\n * This function sets the selected item\n */\n const handleSetSelectedItem = useCallback(\n (itemToSelect: IComboBoxItem) => {\n setItem(itemToSelect);\n setIsAnimating(false);\n\n if (onSelect) {\n onSelect(itemToSelect);\n }\n },\n [onSelect]\n );\n\n /**\n * This function calculates the greatest width\n */\n useEffect(() => {\n const textArray = list.map(({ text }) => text);\n\n setHeight(calculateContentHeight(textArray));\n\n textArray.push(placeholder);\n\n setMinWidth(calculateContentWidth(textArray) + 45);\n }, [list, placeholder]);\n\n /**\n * This function sets the external selected item\n */\n useEffect(() => {\n if (selectedItem) {\n handleSetSelectedItem(selectedItem);\n }\n }, [handleSetSelectedItem, selectedItem]);\n\n /**\n * Function that renders the combobox items\n */\n const content = useMemo(() => {\n const items: ReactNode[] = [];\n\n list.forEach(({ text, value }) => {\n items.push(\n <ComboBoxItem\n key={value}\n value={value}\n text={text}\n onSelect={handleSetSelectedItem}\n />\n );\n });\n\n return items;\n }, [handleSetSelectedItem, list]);\n\n /**\n * This function resets the placeholder\n */\n const placeholderText = useMemo(() => {\n let text = placeholder;\n\n if (!selectedItem) {\n text = placeholder;\n } else if (item?.text) {\n text = item.text;\n }\n\n return text;\n }, [item?.text, placeholder, selectedItem]);\n\n /**\n * This function opens the content of the combobox\n */\n const handleHeaderClick = () => {\n setIsAnimating((prevState) => !prevState);\n };\n\n return useMemo(\n () => (\n <StyledComboBox ref={ref}>\n <StyledComboBoxHeader\n minWidth={minWidth}\n onClick={handleHeaderClick}\n isOpen={isAnimating}\n >\n <StyledComboBoxPlaceholder>{placeholderText}</StyledComboBoxPlaceholder>\n <StyledComboBoxIconWrapper>\n <Icon icons={['fa fa-chevron-down']} />\n </StyledComboBoxIconWrapper>\n </StyledComboBoxHeader>\n <StyledMotionComboBoxBody\n height={height}\n initial={{ height: 0, opacity: 0 }}\n animate={\n isAnimating\n ? { height: 'fit-content', opacity: 1 }\n : { height: 0, opacity: 0 }\n }\n transition={{\n duration: 0.2,\n }}\n >\n {content}\n </StyledMotionComboBoxBody>\n </StyledComboBox>\n ),\n [content, height, isAnimating, item?.text, minWidth, placeholder]\n );\n};\n\nComboBox.displayName = 'ComboBox';\n\nexport default ComboBox;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAM2B,SAAAG,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,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,SAAAX,wBAAAO,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAA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F,QAAQ,CAAC2D,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAEnB5D,QAAQ;AAAA6D,OAAA,CAAAjF,OAAA,GAAAgF,QAAA"}
@@ -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}</StyledPopupPseudo>\n <StyledPopup ref={popupRef} onClick={handleChildrenClick}>\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n});\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAUA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAAgE,SAAAO,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,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O,EAAEA,OAAQ;MACjBV,GAAG,EAAG,WAAU8B,IAAK,EAAE;MACvBR,SAAS,EAAEA,SAAU;MACrBb,GAAG,EAAEuB;IAAgB,CACxB,CAEQ,CAAC,EAClBb,SACJ,CACJ,CAAC;EACL,CAAC,EAAE,CAACG,SAAS,EAAEH,SAAS,EAAET,OAAO,EAAEI,WAAW,EAAEY,MAAM,EAAEI,IAAI,CAAC,CAAC;EAE9D,oBACItD,MAAA,CAAAU,OAAA,CAAAkF,aAAA,CAAA5F,MAAA,CAAAU,OAAA,CAAAqF,QAAA,qBACI/F,MAAA,CAAAU,OAAA,CAAAkF,aAAA,CAACrF,MAAA,CAAAyF,iBAAiB;IAAC/D,GAAG,EAAEyB;EAAsB,GAAExB,OAA2B,CAAC,eAC5ElC,MAAA,CAAAU,OAAA,CAAAkF,aAAA,CAACrF,MAAA,CAAA0F,WAAW;IAAChE,GAAG,EAAE0B,QAAS;IAACuC,OAAO,EAAEvB;EAAoB,GACpDtC,QACQ,CAAC,EACbe,MACH,CAAC;AAEX,CAAC,CAAC;AAEFtB,KAAK,CAACqE,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAEbtE,KAAK;AAAAuE,OAAA,CAAA3F,OAAA,GAAA0F,QAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const StyledPopup: import("styled-components").StyledComponent<"span", any, {}, never>;
2
+ export declare const StyledPopupPseudo: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -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,WAA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,KAAK,CAACE,IAAI;AAAA,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUC,KAAA,IAAkB;EAAA,IAAjB;IAAEC;EAAS,CAAC,GAAAD,KAAA;EACX,QAAQC,QAAQ;IACZ,KAAKC,yBAAc,CAACC,OAAO;MACvB,OAAO,IAAAC,qBAAG,CAAC;AAC/B;AACA;AACA;AACA,qBAAqB;IACL,KAAKF,yBAAc,CAACG,UAAU;MAC1B,OAAO,IAAAD,qBAAG,CAAC;AAC/B;AACA;AACA;AACA,qBAAqB;IACL,KAAKF,yBAAc,CAACI,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"}
@@ -21,7 +21,7 @@ const Slider = _ref => {
21
21
  * This function sets the value
22
22
  */
23
23
  (0, _react.useEffect)(() => {
24
- if (!value) {
24
+ if (typeof value !== 'number') {
25
25
  return;
26
26
  }
27
27
  if (value >= minValue && value <= maxValue) {
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","names":["_react","_interopRequireWildcard","require","_Slider","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Slider","_ref","maxValue","minValue","value","onChange","editedValue","setEditedValue","useState","useEffect","handleInputChange","useCallback","event","Number","target","useMemo","createElement","StyledSlider","StyledSliderInput","type","max","min","displayName","_default","exports"],"sources":["../../../src/components/slider/Slider.tsx"],"sourcesContent":["import React, { ChangeEvent, FC, useCallback, useEffect, useMemo, useState } from 'react';\nimport { StyledSlider, StyledSliderInput } from './Slider.styles';\n\nexport type SliderProps = {\n /**\n * The maximum value of the slider.\n */\n maxValue: number;\n /**\n * The minimum value of the slider.\n */\n minValue: number;\n /**\n * Function that will be executed when the value is changed.\n */\n onChange?: (value: number) => void;\n /**\n * the Value that the slider should have.\n */\n value?: number;\n};\n\nconst Slider: FC<SliderProps> = ({ maxValue, minValue, value, onChange }) => {\n const [editedValue, setEditedValue] = useState(0);\n\n /**\n * This function sets the value\n */\n useEffect(() => {\n if (!value) {\n return;\n }\n\n if (value >= minValue && value <= maxValue) {\n setEditedValue(value);\n }\n }, [maxValue, minValue, value]);\n\n /**\n * This function updates the value\n */\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setEditedValue(Number(event.target.value));\n\n if (onChange) {\n onChange(Number(event.target.value));\n }\n },\n [onChange]\n );\n\n return useMemo(\n () => (\n <StyledSlider>\n <StyledSliderInput\n type=\"range\"\n value={editedValue}\n max={maxValue}\n min={minValue}\n onChange={handleInputChange}\n />\n </StyledSlider>\n ),\n [editedValue, handleInputChange, maxValue, minValue]\n );\n};\n\nSlider.displayName = 'Slider';\n\nexport default Slider;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAkE,SAAAE,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,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,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EC,KAAK,CAAC,CAAC;;EAE/B;AACJ;AACA;EACI,MAAMM,iBAAiB,GAAG,IAAAC,kBAAW,EAChCC,KAAoC,IAAK;IACtCL,cAAc,CAACM,MAAM,CAACD,KAAK,CAACE,MAAM,CAACV,KAAK,CAAC,CAAC;IAE1C,IAAIC,QAAQ,EAAE;MACVA,QAAQ,CAACQ,MAAM,CAACD,KAAK,CAACE,MAAM,CAACV,KAAK,CAAC,CAAC;IACxC;EACJ,CAAC,EACD,CAACC,QAAQ,CACb,CAAC;EAED,OAAO,IAAAU,cAAO,EACV,mBACIzC,MAAA,CAAAW,OAAA,CAAA+B,aAAA,CAACvC,OAAA,CAAAwC,YAAY,qBACT3C,MAAA,CAAAW,OAAA,CAAA+B,aAAA,CAACvC,OAAA,CAAAyC,iBAAiB;IACdC,IAAI,EAAC,OAAO;IACZf,KAAK,EAAEE,WAAY;IACnBc,GAAG,EAAElB,QAAS;IACdmB,GAAG,EAAElB,QAAS;IACdE,QAAQ,EAAEK;EAAkB,CAC/B,CACS,CACjB,EACD,CAACJ,WAAW,EAAEI,iBAAiB,EAAER,QAAQ,EAAEC,QAAQ,CACvD,CAAC;AACL,CAAC;AAEDH,MAAM,CAACsB,WAAW,GAAG,QAAQ;AAAC,IAAAC,QAAA,GAEfvB,MAAM;AAAAwB,OAAA,CAAAvC,OAAA,GAAAsC,QAAA"}
1
+ {"version":3,"file":"Slider.js","names":["_react","_interopRequireWildcard","require","_Slider","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Slider","_ref","maxValue","minValue","value","onChange","editedValue","setEditedValue","useState","useEffect","handleInputChange","useCallback","event","Number","target","useMemo","createElement","StyledSlider","StyledSliderInput","type","max","min","displayName","_default","exports"],"sources":["../../../src/components/slider/Slider.tsx"],"sourcesContent":["import React, { ChangeEvent, FC, useCallback, useEffect, useMemo, useState } from 'react';\nimport { StyledSlider, StyledSliderInput } from './Slider.styles';\n\nexport type SliderProps = {\n /**\n * The maximum value of the slider.\n */\n maxValue: number;\n /**\n * The minimum value of the slider.\n */\n minValue: number;\n /**\n * Function that will be executed when the value is changed.\n */\n onChange?: (value: number) => void;\n /**\n * the Value that the slider should have.\n */\n value?: number;\n};\n\nconst Slider: FC<SliderProps> = ({ maxValue, minValue, value, onChange }) => {\n const [editedValue, setEditedValue] = useState(0);\n\n /**\n * This function sets the value\n */\n useEffect(() => {\n if (typeof value !== 'number') {\n return;\n }\n\n if (value >= minValue && value <= maxValue) {\n setEditedValue(value);\n }\n }, [maxValue, minValue, value]);\n\n /**\n * This function updates the value\n */\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setEditedValue(Number(event.target.value));\n\n if (onChange) {\n onChange(Number(event.target.value));\n }\n },\n [onChange]\n );\n\n return useMemo(\n () => (\n <StyledSlider>\n <StyledSliderInput\n type=\"range\"\n value={editedValue}\n max={maxValue}\n min={minValue}\n onChange={handleInputChange}\n />\n </StyledSlider>\n ),\n [editedValue, handleInputChange, maxValue, minValue]\n );\n};\n\nSlider.displayName = 'Slider';\n\nexport default Slider;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAkE,SAAAE,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,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,U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J;AACA;EACI,MAAMM,iBAAiB,GAAG,IAAAC,kBAAW,EAChCC,KAAoC,IAAK;IACtCL,cAAc,CAACM,MAAM,CAACD,KAAK,CAACE,MAAM,CAACV,KAAK,CAAC,CAAC;IAE1C,IAAIC,QAAQ,EAAE;MACVA,QAAQ,CAACQ,MAAM,CAACD,KAAK,CAACE,MAAM,CAACV,KAAK,CAAC,CAAC;IACxC;EACJ,CAAC,EACD,CAACC,QAAQ,CACb,CAAC;EAED,OAAO,IAAAU,cAAO,EACV,mBACIzC,MAAA,CAAAW,OAAA,CAAA+B,aAAA,CAACvC,OAAA,CAAAwC,YAAY,qBACT3C,MAAA,CAAAW,OAAA,CAAA+B,aAAA,CAACvC,OAAA,CAAAyC,iBAAiB;IACdC,IAAI,EAAC,OAAO;IACZf,KAAK,EAAEE,WAAY;IACnBc,GAAG,EAAElB,QAAS;IACdmB,GAAG,EAAElB,QAAS;IACdE,QAAQ,EAAEK;EAAkB,CAC/B,CACS,CACjB,EACD,CAACJ,WAAW,EAAEI,iBAAiB,EAAER,QAAQ,EAAEC,QAAQ,CACvD,CAAC;AACL,CAAC;AAEDH,MAAM,CAACsB,WAAW,GAAG,QAAQ;AAAC,IAAAC,QAAA,GAEfvB,MAAM;AAAAwB,OAAA,CAAAvC,OAAA,GAAAsC,QAAA"}
@@ -1,2 +1,2 @@
1
1
  export declare const calculateContentWidth: (texts: string[]) => number;
2
- export declare const calculateContentHeight: (texts: string[]) => number;
2
+ export declare const calculateContentHeight: (elements: string[]) => number;
@@ -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 = texts => {
23
+ const calculateContentHeight = elements => {
24
24
  const length = [];
25
- texts.forEach(text => {
26
- const div = document.createElement('p');
27
- div.style.visibility = 'hidden';
28
- div.style.position = 'absolute';
29
- div.style.width = 'auto';
30
- div.style.margin = '5px';
31
- div.style.whiteSpace = 'nowrap';
32
- document.body.appendChild(div);
33
- div.innerText = text;
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 = (texts: string[]) => {\n const length: number[] = [];\n\n texts.forEach((text) => {\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 div.innerText = text;\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,EAAE;EAE3BD,KAAK,CAACE,OAAO,CAAEC,IAAI,IAAK;IACpB,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IACzCF,GAAG,CAACG,KAAK,C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AACwB,MAAM,CAAC,CAACC,UAAU,EAAEC,CAAC,KAAKD,UAAU,GAAGC,CAAC,EAAE,CAAC,CAAC;AAC9D,CAAC;AAACN,OAAA,CAAAC,sBAAA,GAAAA,sBAAA"}
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,EAAE;EAE3BD,KAAK,CAACE,OAAO,CAAEC,IAAI,IAAK;IACpB,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IACzCF,GAAG,CAACG,KAAK,CAACC,UAAU,GAAG,QAAQ;IAC/BJ,GAAG,CAACG,KAAK,CAACE,QAAQ,GAAG,UAAU;IAC/BL,GAAG,CAACG,KAAK,CAACG,KAAK,GAAG,MAAM;IAC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C,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.174",
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": "364604da7330bc187a2f8c49136fd1f46c2b1224"
66
+ "gitHead": "ba18e5c342ffb57fd61a98a8e223a768d0595e5d"
67
67
  }