@chayns-components/core 5.0.0-beta.172 → 5.0.0-beta.174
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/combobox/ComboBox.js +10 -10
- package/lib/components/combobox/ComboBox.js.map +1 -1
- package/lib/components/combobox/ComboBox.styles.d.ts +3 -1
- package/lib/components/combobox/ComboBox.styles.js +12 -6
- package/lib/components/combobox/ComboBox.styles.js.map +1 -1
- package/lib/components/combobox/combobox-item/ComboBoxItem.styles.d.ts +3 -1
- package/lib/components/combobox/combobox-item/ComboBoxItem.styles.js +6 -0
- package/lib/components/combobox/combobox-item/ComboBoxItem.styles.js.map +1 -1
- package/lib/components/filter-button/FilterButton.d.ts +22 -0
- package/lib/components/filter-button/FilterButton.js +89 -0
- package/lib/components/filter-button/FilterButton.js.map +1 -0
- package/lib/components/filter-button/FilterButton.styles.d.ts +1 -0
- package/lib/components/filter-button/FilterButton.styles.js +15 -0
- package/lib/components/filter-button/FilterButton.styles.js.map +1 -0
- package/lib/components/filter-button/filter-button-item/FilterButtonItem.d.ts +14 -0
- package/lib/components/filter-button/filter-button-item/FilterButtonItem.js +48 -0
- package/lib/components/filter-button/filter-button-item/FilterButtonItem.js.map +1 -0
- package/lib/components/filter-button/filter-button-item/FilterButtonItem.styles.d.ts +26 -0
- package/lib/components/filter-button/filter-button-item/FilterButtonItem.styles.js +109 -0
- package/lib/components/filter-button/filter-button-item/FilterButtonItem.styles.js.map +1 -0
- package/lib/components/filter-button/interface.d.ts +15 -0
- package/lib/components/filter-button/interface.js +19 -0
- package/lib/components/filter-button/interface.js.map +1 -0
- package/lib/components/search-box/SearchBox.d.ts +26 -0
- package/lib/components/search-box/SearchBox.js +149 -0
- package/lib/components/search-box/SearchBox.js.map +1 -0
- package/lib/components/search-box/SearchBox.styles.d.ts +6 -0
- package/lib/components/search-box/SearchBox.styles.js +51 -0
- package/lib/components/search-box/SearchBox.styles.js.map +1 -0
- package/lib/components/search-box/interface.d.ts +4 -0
- package/lib/components/search-box/interface.js +6 -0
- package/lib/components/search-box/interface.js.map +1 -0
- package/lib/components/search-box/search-box-item/SearchBoxItem.d.ts +9 -0
- package/lib/components/search-box/search-box-item/SearchBoxItem.js +30 -0
- package/lib/components/search-box/search-box-item/SearchBoxItem.js.map +1 -0
- package/lib/components/search-box/search-box-item/SearchBoxItem.styles.d.ts +6 -0
- package/lib/components/search-box/search-box-item/SearchBoxItem.styles.js +30 -0
- package/lib/components/search-box/search-box-item/SearchBoxItem.styles.js.map +1 -0
- package/lib/components/search-box/utils.d.ts +7 -0
- package/lib/components/search-box/utils.js +23 -0
- package/lib/components/search-box/utils.js.map +1 -0
- package/lib/components/sharing-bar/SharingBar.d.ts +9 -0
- package/lib/components/sharing-bar/SharingBar.js +12 -9
- package/lib/components/sharing-bar/SharingBar.js.map +1 -1
- package/lib/components/sharing-bar/SharingBar.styles.d.ts +3 -1
- package/lib/components/sharing-bar/SharingBar.styles.js +8 -1
- package/lib/components/sharing-bar/SharingBar.styles.js.map +1 -1
- package/lib/components/text-area/TextArea.d.ts +25 -0
- package/lib/components/text-area/TextArea.js +63 -0
- package/lib/components/text-area/TextArea.js.map +1 -0
- package/lib/components/text-area/TextArea.styles.d.ts +8 -0
- package/lib/components/text-area/TextArea.styles.js +46 -0
- package/lib/components/text-area/TextArea.styles.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -1
- package/lib/{components/combobox/utils.js → utils/calculate.js} +1 -1
- package/lib/utils/calculate.js.map +1 -0
- package/package.json +2 -2
- package/lib/components/combobox/utils.js.map +0 -1
- /package/lib/{components/combobox/utils.d.ts → utils/calculate.d.ts} +0 -0
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _calculate = require("../../utils/calculate");
|
|
8
9
|
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
9
10
|
var _ComboBoxItem = _interopRequireDefault(require("./combobox-item/ComboBoxItem"));
|
|
10
11
|
var _ComboBox = require("./ComboBox.styles");
|
|
11
|
-
var _utils = require("./utils");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
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); }
|
|
14
14
|
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; }
|
|
@@ -20,13 +20,13 @@ const ComboBox = _ref => {
|
|
|
20
20
|
selectedItem
|
|
21
21
|
} = _ref;
|
|
22
22
|
const [item, setItem] = (0, _react.useState)();
|
|
23
|
-
const [
|
|
23
|
+
const [isAnimating, setIsAnimating] = (0, _react.useState)(false);
|
|
24
24
|
const [minWidth, setMinWidth] = (0, _react.useState)(0);
|
|
25
25
|
const [height, setHeight] = (0, _react.useState)(0);
|
|
26
26
|
const ref = (0, _react.useRef)(null);
|
|
27
27
|
const handleClick = (0, _react.useCallback)(event => {
|
|
28
28
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
29
|
-
|
|
29
|
+
setIsAnimating(false);
|
|
30
30
|
}
|
|
31
31
|
}, [ref]);
|
|
32
32
|
(0, _react.useEffect)(() => {
|
|
@@ -41,7 +41,7 @@ const ComboBox = _ref => {
|
|
|
41
41
|
*/
|
|
42
42
|
const handleSetSelectedItem = (0, _react.useCallback)(itemToSelect => {
|
|
43
43
|
setItem(itemToSelect);
|
|
44
|
-
|
|
44
|
+
setIsAnimating(false);
|
|
45
45
|
if (onSelect) {
|
|
46
46
|
onSelect(itemToSelect);
|
|
47
47
|
}
|
|
@@ -57,9 +57,9 @@ const ComboBox = _ref => {
|
|
|
57
57
|
} = _ref2;
|
|
58
58
|
return text;
|
|
59
59
|
});
|
|
60
|
-
setHeight((0,
|
|
60
|
+
setHeight((0, _calculate.calculateContentHeight)(textArray));
|
|
61
61
|
textArray.push(placeholder);
|
|
62
|
-
setMinWidth((0,
|
|
62
|
+
setMinWidth((0, _calculate.calculateContentWidth)(textArray) + 45);
|
|
63
63
|
}, [list, placeholder]);
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -95,7 +95,7 @@ const ComboBox = _ref => {
|
|
|
95
95
|
* This function opens the content of the combobox
|
|
96
96
|
*/
|
|
97
97
|
const handleHeaderClick = () => {
|
|
98
|
-
|
|
98
|
+
setIsAnimating(prevState => !prevState);
|
|
99
99
|
};
|
|
100
100
|
return (0, _react.useMemo)(() => {
|
|
101
101
|
var _item$text;
|
|
@@ -104,7 +104,7 @@ const ComboBox = _ref => {
|
|
|
104
104
|
}, /*#__PURE__*/_react.default.createElement(_ComboBox.StyledComboBoxHeader, {
|
|
105
105
|
minWidth: minWidth,
|
|
106
106
|
onClick: handleHeaderClick,
|
|
107
|
-
isOpen:
|
|
107
|
+
isOpen: isAnimating
|
|
108
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
109
|
icons: ['fa fa-chevron-down']
|
|
110
110
|
}))), /*#__PURE__*/_react.default.createElement(_ComboBox.StyledMotionComboBoxBody, {
|
|
@@ -113,7 +113,7 @@ const ComboBox = _ref => {
|
|
|
113
113
|
height: 0,
|
|
114
114
|
opacity: 0
|
|
115
115
|
},
|
|
116
|
-
animate:
|
|
116
|
+
animate: isAnimating ? {
|
|
117
117
|
height: 'fit-content',
|
|
118
118
|
opacity: 1
|
|
119
119
|
} : {
|
|
@@ -124,7 +124,7 @@ const ComboBox = _ref => {
|
|
|
124
124
|
duration: 0.2
|
|
125
125
|
}
|
|
126
126
|
}, content));
|
|
127
|
-
}, [content,
|
|
127
|
+
}, [content, height, isAnimating, item === null || item === void 0 ? void 0 : item.text, minWidth, placeholder]);
|
|
128
128
|
};
|
|
129
129
|
ComboBox.displayName = 'ComboBox';
|
|
130
130
|
var _default = ComboBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.js","names":["_react","_interopRequireWildcard","require","_Icon","_interopRequireDefault","_ComboBoxItem","_ComboBox","_utils","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","isAnimation","setIsAnimation","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 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';\nimport { calculateContentHeight, calculateContentWidth } from './utils';\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 [isAnimation, setIsAnimation] = 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 setIsAnimation(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 setIsAnimation(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 setIsAnimation((prevState) => !prevState);\n };\n\n return useMemo(\n () => (\n <StyledComboBox ref={ref}>\n <StyledComboBoxHeader\n minWidth={minWidth}\n onClick={handleHeaderClick}\n isOpen={isAnimation}\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 isAnimation\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, isAnimation, 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,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAOA,IAAAK,MAAA,GAAAL,OAAA;AAAwE,SAAAE,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,G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AAW,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","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,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,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAT,GAAA,YAAAQ,KAAA,CAAAE,GAAA,CAAAV,GAAA,SAAA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CAAAU,OAAA,CAAA8D,aAAA,CAACpE,KAAA,CAAAM,OAAI;MAACwE,KAAK,EAAE,CAAC,oBAAoB;IAAE,CAAE,CACf,CACT,CAAC,eACvBlF,MAAA,CAAAU,OAAA,CAAA8D,aAAA,CAACjE,SAAA,CAAA4E,wBAAwB;MACrBxC,MAAM,EAAEA,MAAO;MACfyC,OAAO,EAAE;QAAEzC,MAAM,EAAE,CAAC;QAAE0C,OAAO,EAAE;MAAE,CAAE;MACnCC,OAAO,EACH/C,WAAW,GACL;QAAEI,MAAM,EAAE,aAAa;QAAE0C,OAAO,EAAE;MAAE,CAAC,GACrC;QAAE1C,MAAM,EAAE,CAAC;QAAE0C,OAAO,EAAE;MAAE,CACjC;MACDE,UAAU,EAAE;QACRC,QAAQ,EAAE;MACd;IAAE,GAEDtB,OACqB,CACd,CAAC;EAAA,CACpB,EACD,CAACA,OAAO,EAAEvB,MAAM,EAAEJ,WAAW,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"}
|
|
@@ -5,7 +5,9 @@ export declare const StyledComboBoxHeader: import("styled-components").StyledCom
|
|
|
5
5
|
} & {
|
|
6
6
|
theme: import("../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
7
7
|
}, never>;
|
|
8
|
-
export declare const StyledComboBoxPlaceholder: import("styled-components").StyledComponent<"p", any, {
|
|
8
|
+
export declare const StyledComboBoxPlaceholder: import("styled-components").StyledComponent<"p", any, {
|
|
9
|
+
theme: import("../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
10
|
+
}, never>;
|
|
9
11
|
export declare const StyledComboBoxIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
12
|
export declare const StyledMotionComboBoxBody: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {
|
|
11
13
|
height: number;
|
|
@@ -60,6 +60,12 @@ const StyledComboBoxHeader = _styledComponents.default.div`
|
|
|
60
60
|
`;
|
|
61
61
|
exports.StyledComboBoxHeader = StyledComboBoxHeader;
|
|
62
62
|
const StyledComboBoxPlaceholder = _styledComponents.default.p`
|
|
63
|
+
color: ${_ref6 => {
|
|
64
|
+
let {
|
|
65
|
+
theme
|
|
66
|
+
} = _ref6;
|
|
67
|
+
return theme.text;
|
|
68
|
+
}};
|
|
63
69
|
margin: 0;
|
|
64
70
|
`;
|
|
65
71
|
exports.StyledComboBoxPlaceholder = StyledComboBoxPlaceholder;
|
|
@@ -68,10 +74,10 @@ const StyledComboBoxIconWrapper = _styledComponents.default.div`
|
|
|
68
74
|
`;
|
|
69
75
|
exports.StyledComboBoxIconWrapper = StyledComboBoxIconWrapper;
|
|
70
76
|
const StyledMotionComboBoxBody = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
71
|
-
background: ${
|
|
77
|
+
background: ${_ref7 => {
|
|
72
78
|
let {
|
|
73
79
|
theme
|
|
74
|
-
} =
|
|
80
|
+
} = _ref7;
|
|
75
81
|
return theme['001'];
|
|
76
82
|
}};
|
|
77
83
|
display: flex;
|
|
@@ -82,16 +88,16 @@ const StyledMotionComboBoxBody = (0, _styledComponents.default)(_framerMotion.mo
|
|
|
82
88
|
border-top: none;
|
|
83
89
|
cursor: pointer;
|
|
84
90
|
max-height: 300px;
|
|
85
|
-
overflow-y: ${
|
|
91
|
+
overflow-y: ${_ref8 => {
|
|
86
92
|
let {
|
|
87
93
|
height
|
|
88
|
-
} =
|
|
94
|
+
} = _ref8;
|
|
89
95
|
return height <= 300 ? 'hidden' : 'auto';
|
|
90
96
|
}};
|
|
91
|
-
box-shadow: 0 0 0 1px rgba(${
|
|
97
|
+
box-shadow: 0 0 0 1px rgba(${_ref9 => {
|
|
92
98
|
let {
|
|
93
99
|
theme
|
|
94
|
-
} =
|
|
100
|
+
} = _ref9;
|
|
95
101
|
return theme['009-rgb'];
|
|
96
102
|
}}, 0.08)
|
|
97
103
|
inset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StyledComboBox","styled","div","exports","StyledComboBoxHeader","_ref","theme","_ref2","minWidth","_ref3","_ref4","isOpen","css","_ref5","StyledComboBoxPlaceholder","p","StyledComboBoxIconWrapper","StyledMotionComboBoxBody","motion","
|
|
1
|
+
{"version":3,"file":"ComboBox.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","StyledComboBox","styled","div","exports","StyledComboBoxHeader","_ref","theme","_ref2","minWidth","_ref3","_ref4","isOpen","css","_ref5","StyledComboBoxPlaceholder","p","_ref6","text","StyledComboBoxIconWrapper","StyledMotionComboBoxBody","motion","_ref7","_ref8","height","_ref9"],"sources":["../../../src/components/combobox/ComboBox.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledComboBox = styled.div`\n width: fit-content;\n`;\n\ntype StyledComboBoxHeaderProps = WithTheme<{\n isOpen: boolean;\n minWidth: number;\n}>;\n\nexport const StyledComboBoxHeader = styled.div<StyledComboBoxHeaderProps>`\n display: flex;\n justify-content: space-between;\n border: 1px solid rgba(160, 160, 160, 0.3);\n padding: 8px 10px;\n cursor: pointer;\n background: ${({ theme }: StyledComboBoxHeaderProps) => theme['001']};\n min-width: ${({ minWidth }) => minWidth}px;\n max-width: ${({ minWidth }) => minWidth}px;\n\n ${({ isOpen }) =>\n isOpen\n ? css`\n border-top-left-radius: 3px;\n border-top-right-radius: 3px;\n `\n : css`\n border-radius: 3px;\n `}\n\n &:hover {\n background: ${({ theme }: StyledComboBoxHeaderProps) => theme['secondary-103']};\n }\n`;\n\ntype StyledComboBoxPlaceholderProps = WithTheme<unknown>;\n\nexport const StyledComboBoxPlaceholder = styled.p<StyledComboBoxPlaceholderProps>`\n color: ${({ theme }: StyledComboBoxPlaceholderProps) => theme.text};\n margin: 0;\n`;\n\nexport const StyledComboBoxIconWrapper = styled.div`\n margin-left: 5px;\n`;\n\ntype StyledComboBoxBodyProps = WithTheme<{\n height: number;\n}>;\n\nexport const StyledMotionComboBoxBody = styled(motion.div)<StyledComboBoxBodyProps>`\n background: ${({ theme }: StyledComboBoxBodyProps) => theme['001']};\n display: flex;\n flex-direction: column;\n border: 1px solid rgba(160, 160, 160, 0.3);\n border-bottom-left-radius: 3px;\n border-bottom-right-radius: 3px;\n border-top: none;\n cursor: pointer;\n max-height: 300px;\n overflow-y: ${({ height }) => (height <= 300 ? 'hidden' : 'auto')};\n box-shadow: 0 0 0 1px rgba(${({ theme }: StyledComboBoxBodyProps) => theme['009-rgb']}, 0.08)\n inset;\n\n &::-webkit-scrollbar {\n width: 5px;\n }\n\n &::-webkit-scrollbar-thumb {\n background: rgba(160, 160, 160, 1);\n }\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAgD,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,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AAQ,GAAG,MAAM;AAAA,CAAE;AACtE,iCAAiCC,KAAA;EAAA,IAAC;IAAElB;EAA+B,CAAC,GAAAkB,KAAA;EAAA,OAAKlB,KAAK,CAAC,SAAS,CAAC;AAAA,CAAC;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACH,OAAA,CAAAgB,wBAAA,GAAAA,wBAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const StyledComboBoxItem: import("styled-components").StyledComponent<"div", any, {
|
|
2
2
|
theme: import("../../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
3
3
|
}, never>;
|
|
4
|
-
export declare const StyledComboBoxItemText: import("styled-components").StyledComponent<"p", any, {
|
|
4
|
+
export declare const StyledComboBoxItemText: import("styled-components").StyledComponent<"p", any, {
|
|
5
|
+
theme: import("../../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
6
|
+
}, never>;
|
|
@@ -18,6 +18,12 @@ const StyledComboBoxItem = _styledComponents.default.div`
|
|
|
18
18
|
`;
|
|
19
19
|
exports.StyledComboBoxItem = StyledComboBoxItem;
|
|
20
20
|
const StyledComboBoxItemText = _styledComponents.default.p`
|
|
21
|
+
color: ${_ref2 => {
|
|
22
|
+
let {
|
|
23
|
+
theme
|
|
24
|
+
} = _ref2;
|
|
25
|
+
return theme.text;
|
|
26
|
+
}};
|
|
21
27
|
margin: 5px;
|
|
22
28
|
`;
|
|
23
29
|
exports.StyledComboBoxItemText = StyledComboBoxItemText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxItem.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledComboBoxItem","styled","div","_ref","theme","exports","StyledComboBoxItemText","p"],"sources":["../../../../src/components/combobox/combobox-item/ComboBoxItem.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledComboBoxItemProps = WithTheme<unknown>;\n\nexport const StyledComboBoxItem = styled.div<StyledComboBoxItemProps>`\n &:hover {\n background: ${({ theme }: StyledComboBoxItemProps) => theme['secondary-103']};\n }\n`;\n\nexport const StyledComboBoxItemText = styled.p
|
|
1
|
+
{"version":3,"file":"ComboBoxItem.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledComboBoxItem","styled","div","_ref","theme","exports","StyledComboBoxItemText","p","_ref2","text"],"sources":["../../../../src/components/combobox/combobox-item/ComboBoxItem.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledComboBoxItemProps = WithTheme<unknown>;\n\nexport const StyledComboBoxItem = styled.div<StyledComboBoxItemProps>`\n &:hover {\n background: ${({ theme }: StyledComboBoxItemProps) => theme['secondary-103']};\n }\n`;\n\ntype StyledComboBoxItemTextProps = WithTheme<unknown>;\n\nexport const StyledComboBoxItemText = styled.p<StyledComboBoxItemTextProps>`\n color: ${({ theme }: StyledComboBoxItemTextProps) => theme.text};\n margin: 5px;\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;AAKhC,MAAMG,kBAAkB,GAAGC,yBAAM,CAACC,GAA6B;AACtE;AACA,sBAAsBC,IAAA;EAAA,IAAC;IAAEC;EAA+B,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAAC,eAAe,CAAC;AAAA,CAAC;AACrF;AACA,CAAC;AAACC,OAAA,CAAAL,kBAAA,GAAAA,kBAAA;AAIK,MAAMM,sBAAsB,GAAGL,yBAAM,CAACM,CAA+B;AAC5E,aAAaC,KAAA;EAAA,IAAC;IAAEJ;EAAmC,CAAC,GAAAI,KAAA;EAAA,OAAKJ,KAAK,CAACK,IAAI;AAAA,CAAC;AACpE;AACA,CAAC;AAACJ,OAAA,CAAAC,sBAAA,GAAAA,sBAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FilterButtonSize, IFilterButtonItem } from './interface';
|
|
3
|
+
export type FilterButtonProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The items that should be displayed.
|
|
6
|
+
*/
|
|
7
|
+
items: IFilterButtonItem[];
|
|
8
|
+
/**
|
|
9
|
+
* A function that should be executed when an item is selected.
|
|
10
|
+
*/
|
|
11
|
+
onSelect?: (keys: string[]) => void;
|
|
12
|
+
/**
|
|
13
|
+
* The keys of items that should be selected.
|
|
14
|
+
*/
|
|
15
|
+
selectedItemIds?: string[];
|
|
16
|
+
/**
|
|
17
|
+
* The size auf the filter buttons. Use the FilterButtonSize enum.
|
|
18
|
+
*/
|
|
19
|
+
size?: FilterButtonSize;
|
|
20
|
+
};
|
|
21
|
+
declare const FilterButton: FC<FilterButtonProps>;
|
|
22
|
+
export default FilterButton;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _FilterButtonItem = _interopRequireDefault(require("./filter-button-item/FilterButtonItem"));
|
|
9
|
+
var _FilterButton = require("./FilterButton.styles");
|
|
10
|
+
var _interface = require("./interface");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
const FilterButton = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
selectedItemIds,
|
|
17
|
+
onSelect,
|
|
18
|
+
items,
|
|
19
|
+
size = _interface.FilterButtonSize.Normal
|
|
20
|
+
} = _ref;
|
|
21
|
+
const [selectedIds, setSelectedIds] = (0, _react.useState)(['all']);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This function set the selectedItemKey
|
|
25
|
+
*/
|
|
26
|
+
(0, _react.useEffect)(() => {
|
|
27
|
+
if (selectedItemIds) {
|
|
28
|
+
setSelectedIds(selectedItemIds);
|
|
29
|
+
}
|
|
30
|
+
}, [selectedItemIds]);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Function to update the selected items
|
|
34
|
+
*/
|
|
35
|
+
const handleSelect = (0, _react.useCallback)(id => {
|
|
36
|
+
let newIds;
|
|
37
|
+
if (id === 'all') {
|
|
38
|
+
newIds = selectedIds.includes('all') ? [] : ['all'];
|
|
39
|
+
} else {
|
|
40
|
+
newIds = selectedIds.includes(id) ? selectedIds.filter(filteredId => filteredId !== id) : [...selectedIds.filter(filteredId => filteredId !== 'all'), id];
|
|
41
|
+
}
|
|
42
|
+
if (newIds.length === 0) {
|
|
43
|
+
newIds = ['all'];
|
|
44
|
+
}
|
|
45
|
+
setSelectedIds(newIds);
|
|
46
|
+
if (typeof onSelect === 'function') {
|
|
47
|
+
onSelect(newIds);
|
|
48
|
+
}
|
|
49
|
+
}, [onSelect, selectedIds]);
|
|
50
|
+
const reactItems = (0, _react.useMemo)(() => {
|
|
51
|
+
if (items.length === 0) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const array = [/*#__PURE__*/_react.default.createElement(_FilterButtonItem.default, {
|
|
55
|
+
id: "all",
|
|
56
|
+
key: "all",
|
|
57
|
+
onSelect: handleSelect,
|
|
58
|
+
isSelected: selectedIds.includes('all'),
|
|
59
|
+
shape: _interface.FilterButtonItemShape.Rectangular,
|
|
60
|
+
size: size,
|
|
61
|
+
text: "Alle"
|
|
62
|
+
})];
|
|
63
|
+
items.forEach(_ref2 => {
|
|
64
|
+
let {
|
|
65
|
+
icons,
|
|
66
|
+
text,
|
|
67
|
+
color,
|
|
68
|
+
id
|
|
69
|
+
} = _ref2;
|
|
70
|
+
array.push( /*#__PURE__*/_react.default.createElement(_FilterButtonItem.default, {
|
|
71
|
+
color: color,
|
|
72
|
+
icons: icons,
|
|
73
|
+
id: id,
|
|
74
|
+
key: id,
|
|
75
|
+
onSelect: handleSelect,
|
|
76
|
+
isSelected: selectedIds.includes(id),
|
|
77
|
+
shape: _interface.FilterButtonItemShape.Round,
|
|
78
|
+
size: size,
|
|
79
|
+
text: text
|
|
80
|
+
}));
|
|
81
|
+
});
|
|
82
|
+
return array;
|
|
83
|
+
}, [handleSelect, items, selectedIds, size]);
|
|
84
|
+
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_FilterButton.StyledFilterButton, null, reactItems), [reactItems]);
|
|
85
|
+
};
|
|
86
|
+
FilterButton.displayName = 'FilterButton';
|
|
87
|
+
var _default = FilterButton;
|
|
88
|
+
exports.default = _default;
|
|
89
|
+
//# sourceMappingURL=FilterButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterButton.js","names":["_react","_interopRequireWildcard","require","_FilterButtonItem","_interopRequireDefault","_FilterButton","_interface","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","FilterButton","_ref","selectedItemIds","onSelect","items","size","FilterButtonSize","Normal","selectedIds","setSelectedIds","useState","useEffect","handleSelect","useCallback","id","newIds","includes","filter","filteredId","length","reactItems","useMemo","array","createElement","isSelected","shape","FilterButtonItemShape","Rectangular","text","forEach","_ref2","icons","color","push","Round","StyledFilterButton","displayName","_default","exports"],"sources":["../../../src/components/filter-button/FilterButton.tsx"],"sourcesContent":["import React, { FC, ReactElement, useCallback, useEffect, useMemo, useState } from 'react';\nimport FilterButtonItem from './filter-button-item/FilterButtonItem';\nimport { StyledFilterButton } from './FilterButton.styles';\nimport { FilterButtonItemShape, FilterButtonSize, IFilterButtonItem } from './interface';\n\nexport type FilterButtonProps = {\n /**\n * The items that should be displayed.\n */\n items: IFilterButtonItem[];\n /**\n * A function that should be executed when an item is selected.\n */\n onSelect?: (keys: string[]) => void;\n /**\n * The keys of items that should be selected.\n */\n selectedItemIds?: string[];\n /**\n * The size auf the filter buttons. Use the FilterButtonSize enum.\n */\n size?: FilterButtonSize;\n};\n\nconst FilterButton: FC<FilterButtonProps> = ({\n selectedItemIds,\n onSelect,\n items,\n size = FilterButtonSize.Normal,\n}) => {\n const [selectedIds, setSelectedIds] = useState<string[]>(['all']);\n\n /**\n * This function set the selectedItemKey\n */\n useEffect(() => {\n if (selectedItemIds) {\n setSelectedIds(selectedItemIds);\n }\n }, [selectedItemIds]);\n\n /**\n * Function to update the selected items\n */\n const handleSelect = useCallback(\n (id: string) => {\n let newIds: string[];\n\n if (id === 'all') {\n newIds = selectedIds.includes('all') ? [] : ['all'];\n } else {\n newIds = selectedIds.includes(id)\n ? selectedIds.filter((filteredId) => filteredId !== id)\n : [...selectedIds.filter((filteredId) => filteredId !== 'all'), id];\n }\n\n if (newIds.length === 0) {\n newIds = ['all'];\n }\n\n setSelectedIds(newIds);\n\n if (typeof onSelect === 'function') {\n onSelect(newIds);\n }\n },\n [onSelect, selectedIds]\n );\n\n const reactItems = useMemo(() => {\n if (items.length === 0) {\n return null;\n }\n\n const array: ReactElement[] = [\n <FilterButtonItem\n id=\"all\"\n key=\"all\"\n onSelect={handleSelect}\n isSelected={selectedIds.includes('all')}\n shape={FilterButtonItemShape.Rectangular}\n size={size}\n text=\"Alle\"\n />,\n ];\n\n items.forEach(({ icons, text, color, id }) => {\n array.push(\n <FilterButtonItem\n color={color}\n icons={icons}\n id={id}\n key={id}\n onSelect={handleSelect}\n isSelected={selectedIds.includes(id)}\n shape={FilterButtonItemShape.Round}\n size={size}\n text={text}\n />\n );\n });\n\n return array;\n }, [handleSelect, items, selectedIds, size]);\n\n return useMemo(() => <StyledFilterButton>{reactItems}</StyledFilterButton>, [reactItems]);\n};\n\nFilterButton.displayName = 'FilterButton';\n\nexport default FilterButton;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAAyF,SAAAE,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,SAAAV,wBAAAM,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBA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,IAA/B;QAAEC,KAAK;QAAEH,IAAI;QAAEI,KAAK;QAAElB;MAAG,CAAC,GAAAgB,KAAA;MACrCR,KAAK,CAACW,IAAI,eACN9D,MAAA,CAAAS,OAAA,CAAA2C,aAAA,CAACjD,iBAAA,CAAAM,OAAgB;QACboD,KAAK,EAAEA,KAAM;QACbD,KAAK,EAAEA,KAAM;QACbjB,EAAE,EAAEA,EAAG;QACPpB,GAAG,EAAEoB,EAAG;QACRX,QAAQ,EAAES,YAAa;QACvBY,UAAU,EAAEhB,WAAW,CAACQ,QAAQ,CAACF,EAAE,CAAE;QACrCW,KAAK,EAAEC,gCAAqB,CAACQ,KAAM;QACnC7B,IAAI,EAAEA,IAAK;QACXuB,IAAI,EAAEA;MAAK,CACd,CACL,CAAC;IACL,CAAC,CAAC;IAEF,OAAON,KAAK;EAChB,CAAC,EAAE,CAACV,YAAY,EAAER,KAAK,EAAEI,WAAW,EAAEH,IAAI,CAAC,CAAC;EAE5C,OAAO,IAAAgB,cAAO,EAAC,mBAAMlD,MAAA,CAAAS,OAAA,CAAA2C,aAAA,CAAC/C,aAAA,CAAA2D,kBAAkB,QAAEf,UAA+B,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;AAC7F,CAAC;AAEDpB,YAAY,CAACoC,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAE3BrC,YAAY;AAAAsC,OAAA,CAAA1D,OAAA,GAAAyD,QAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledFilterButton: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledFilterButton = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const StyledFilterButton = _styledComponents.default.div`
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
gap: 10px;
|
|
13
|
+
`;
|
|
14
|
+
exports.StyledFilterButton = StyledFilterButton;
|
|
15
|
+
//# sourceMappingURL=FilterButton.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterButton.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledFilterButton","styled","div","exports"],"sources":["../../../src/components/filter-button/FilterButton.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledFilterButton = styled.div`\n display: flex;\n flex-wrap: wrap;\n gap: 10px;\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,kBAAkB,GAAGC,yBAAM,CAACC,GAAI;AAC7C;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAH,kBAAA,GAAAA,kBAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CSSProperties, FC } from 'react';
|
|
2
|
+
import { FilterButtonItemShape, FilterButtonSize } from '../interface';
|
|
3
|
+
export type FilterButtonItemProps = {
|
|
4
|
+
color?: CSSProperties['color'];
|
|
5
|
+
icons?: string[];
|
|
6
|
+
isSelected: boolean;
|
|
7
|
+
shape: FilterButtonItemShape;
|
|
8
|
+
size: FilterButtonSize;
|
|
9
|
+
text: string;
|
|
10
|
+
id: string;
|
|
11
|
+
onSelect: (key: string) => void;
|
|
12
|
+
};
|
|
13
|
+
declare const FilterButtonItem: FC<FilterButtonItemProps>;
|
|
14
|
+
export default FilterButtonItem;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _Icon = _interopRequireDefault(require("../../icon/Icon"));
|
|
9
|
+
var _interface = require("../interface");
|
|
10
|
+
var _FilterButtonItem = require("./FilterButtonItem.styles");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
const FilterButtonItem = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
icons,
|
|
17
|
+
size,
|
|
18
|
+
shape,
|
|
19
|
+
text,
|
|
20
|
+
color,
|
|
21
|
+
isSelected,
|
|
22
|
+
id,
|
|
23
|
+
onSelect
|
|
24
|
+
} = _ref;
|
|
25
|
+
const handleClick = (0, _react.useCallback)(() => {
|
|
26
|
+
onSelect(id);
|
|
27
|
+
}, [id, onSelect]);
|
|
28
|
+
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_FilterButtonItem.StyledFilterButtonItem, {
|
|
29
|
+
isSelected: isSelected,
|
|
30
|
+
size: size,
|
|
31
|
+
onClick: handleClick
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_FilterButtonItem.StyledFilterButtonItemLabel, null, icons && /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
33
|
+
icons: icons,
|
|
34
|
+
size: size === _interface.FilterButtonSize.Normal ? 15 : 10
|
|
35
|
+
}), /*#__PURE__*/_react.default.createElement(_FilterButtonItem.StyledFilterButtonItemLabelText, null, text)), /*#__PURE__*/_react.default.createElement(_FilterButtonItem.StyledFilterButtonItemBorder, {
|
|
36
|
+
isSelected: isSelected,
|
|
37
|
+
shape: shape,
|
|
38
|
+
color: color
|
|
39
|
+
}), /*#__PURE__*/_react.default.createElement(_FilterButtonItem.StyledMotionFilterButtonItemBackground, {
|
|
40
|
+
isSelected: isSelected,
|
|
41
|
+
shape: shape,
|
|
42
|
+
color: color
|
|
43
|
+
})), [color, handleClick, icons, isSelected, shape, size, text]);
|
|
44
|
+
};
|
|
45
|
+
FilterButtonItem.displayName = 'FilterButtonItem';
|
|
46
|
+
var _default = FilterButtonItem;
|
|
47
|
+
exports.default = _default;
|
|
48
|
+
//# sourceMappingURL=FilterButtonItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterButtonItem.js","names":["_react","_interopRequireWildcard","require","_Icon","_interopRequireDefault","_interface","_FilterButtonItem","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","FilterButtonItem","_ref","icons","size","shape","text","color","isSelected","id","onSelect","handleClick","useCallback","useMemo","createElement","StyledFilterButtonItem","onClick","StyledFilterButtonItemLabel","FilterButtonSize","Normal","StyledFilterButtonItemLabelText","StyledFilterButtonItemBorder","StyledMotionFilterButtonItemBackground","displayName","_default","exports"],"sources":["../../../../src/components/filter-button/filter-button-item/FilterButtonItem.tsx"],"sourcesContent":["import React, { CSSProperties, FC, useCallback, useMemo } from 'react';\nimport Icon from '../../icon/Icon';\nimport { FilterButtonItemShape, FilterButtonSize } from '../interface';\nimport {\n StyledFilterButtonItem,\n StyledFilterButtonItemBorder,\n StyledFilterButtonItemLabel,\n StyledFilterButtonItemLabelText,\n StyledMotionFilterButtonItemBackground,\n} from './FilterButtonItem.styles';\n\nexport type FilterButtonItemProps = {\n color?: CSSProperties['color'];\n icons?: string[];\n isSelected: boolean;\n shape: FilterButtonItemShape;\n size: FilterButtonSize;\n text: string;\n id: string;\n onSelect: (key: string) => void;\n};\n\nconst FilterButtonItem: FC<FilterButtonItemProps> = ({\n icons,\n size,\n shape,\n text,\n color,\n isSelected,\n id,\n onSelect,\n}) => {\n const handleClick = useCallback(() => {\n onSelect(id);\n }, [id, onSelect]);\n\n return useMemo(\n () => (\n <StyledFilterButtonItem isSelected={isSelected} size={size} onClick={handleClick}>\n <StyledFilterButtonItemLabel>\n {icons && (\n <Icon icons={icons} size={size === FilterButtonSize.Normal ? 15 : 10} />\n )}\n <StyledFilterButtonItemLabelText>{text}</StyledFilterButtonItemLabelText>\n </StyledFilterButtonItemLabel>\n <StyledFilterButtonItemBorder isSelected={isSelected} shape={shape} color={color} />\n <StyledMotionFilterButtonItemBackground\n isSelected={isSelected}\n shape={shape}\n color={color}\n />\n </StyledFilterButtonItem>\n ),\n [color, handleClick, icons, isSelected, shape, size, text]\n );\n};\n\nFilterButtonItem.displayName = 'FilterButtonItem';\n\nexport default FilterButtonItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAMmC,SAAAE,uBAAAG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I,EAAEE,IAAI,CAC7D,CAAC;AACL,CAAC;AAEDL,gBAAgB,CAACsB,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAEnCvB,gBAAgB;AAAAwB,OAAA,CAAA5C,OAAA,GAAA2C,QAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import { FilterButtonItemShape, FilterButtonSize } from '../interface';
|
|
3
|
+
export declare const StyledFilterButtonItem: import("styled-components").StyledComponent<"div", any, {
|
|
4
|
+
size: FilterButtonSize;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
} & {
|
|
7
|
+
theme: import("../../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
8
|
+
}, never>;
|
|
9
|
+
export declare const StyledFilterButtonItemLabel: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
+
export declare const StyledFilterButtonItemLabelText: import("styled-components").StyledComponent<"p", any, {
|
|
11
|
+
theme: import("../../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
12
|
+
}, never>;
|
|
13
|
+
export declare const StyledFilterButtonItemBorder: import("styled-components").StyledComponent<"div", any, {
|
|
14
|
+
shape: FilterButtonItemShape;
|
|
15
|
+
color: CSSProperties['color'];
|
|
16
|
+
isSelected: boolean;
|
|
17
|
+
} & {
|
|
18
|
+
theme: import("../../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
19
|
+
}, never>;
|
|
20
|
+
export declare const StyledMotionFilterButtonItemBackground: import("styled-components").StyledComponent<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, any, {
|
|
21
|
+
shape: FilterButtonItemShape;
|
|
22
|
+
color: CSSProperties['color'];
|
|
23
|
+
isSelected: boolean;
|
|
24
|
+
} & {
|
|
25
|
+
theme: import("../../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
26
|
+
}, never>;
|