@chayns-components/core 5.0.0-beta.949 → 5.0.0-beta.953
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/cjs/components/filter-buttons/FilterButtons.js +8 -1
- package/lib/cjs/components/filter-buttons/FilterButtons.js.map +1 -1
- package/lib/cjs/components/filter-buttons/filter-button/FilterButton.js +1 -1
- package/lib/cjs/components/filter-buttons/filter-button/FilterButton.js.map +1 -1
- package/lib/cjs/utils/calculate.js +10 -2
- package/lib/cjs/utils/calculate.js.map +1 -1
- package/lib/esm/components/filter-buttons/FilterButtons.js +8 -1
- package/lib/esm/components/filter-buttons/FilterButtons.js.map +1 -1
- package/lib/esm/components/filter-buttons/filter-button/FilterButton.js +1 -1
- package/lib/esm/components/filter-buttons/filter-button/FilterButton.js.map +1 -1
- package/lib/esm/utils/calculate.js +10 -2
- package/lib/esm/utils/calculate.js.map +1 -1
- package/lib/types/components/filter-buttons/FilterButtons.d.ts +8 -0
- package/package.json +2 -2
|
@@ -12,9 +12,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
const FilterButtons = ({
|
|
15
|
+
allCount,
|
|
15
16
|
selectedItemIds,
|
|
16
17
|
onSelect,
|
|
17
18
|
items,
|
|
19
|
+
shouldCalcCountForAll = false,
|
|
18
20
|
size = _filterButtons.FilterButtonSize.Normal
|
|
19
21
|
}) => {
|
|
20
22
|
const [selectedIds, setSelectedIds] = (0, _react.useState)(['all']);
|
|
@@ -50,7 +52,12 @@ const FilterButtons = ({
|
|
|
50
52
|
if (items.length === 0) {
|
|
51
53
|
return null;
|
|
52
54
|
}
|
|
55
|
+
let allButtonCount = allCount;
|
|
56
|
+
if (typeof allButtonCount !== 'number' && shouldCalcCountForAll) {
|
|
57
|
+
allButtonCount = items.reduce((acc, item) => acc + (item.count || 0), 0);
|
|
58
|
+
}
|
|
53
59
|
const array = [/*#__PURE__*/_react.default.createElement(_FilterButton.default, {
|
|
60
|
+
count: allButtonCount,
|
|
54
61
|
id: "all",
|
|
55
62
|
key: "all",
|
|
56
63
|
onSelect: handleSelect,
|
|
@@ -80,7 +87,7 @@ const FilterButtons = ({
|
|
|
80
87
|
}));
|
|
81
88
|
});
|
|
82
89
|
return array;
|
|
83
|
-
}, [handleSelect, items, selectedIds, size]);
|
|
90
|
+
}, [allCount, handleSelect, items, selectedIds, shouldCalcCountForAll, size]);
|
|
84
91
|
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_FilterButtons.StyledFilterButton, null, reactItems), [reactItems]);
|
|
85
92
|
};
|
|
86
93
|
FilterButtons.displayName = 'FilterButtons';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterButtons.js","names":["_react","_interopRequireWildcard","require","_filterButtons","_FilterButton","_interopRequireDefault","_FilterButtons","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","FilterButtons","selectedItemIds","onSelect","items","size","FilterButtonSize","Normal","selectedIds","setSelectedIds","useState","useEffect","handleSelect","useCallback","id","newIds","includes","filter","filteredId","length","selectedId","reactItems","useMemo","array","createElement","key","isSelected","Array","isArray","shape","FilterButtonItemShape","Rectangular","text","forEach","icons","color","
|
|
1
|
+
{"version":3,"file":"FilterButtons.js","names":["_react","_interopRequireWildcard","require","_filterButtons","_FilterButton","_interopRequireDefault","_FilterButtons","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","FilterButtons","allCount","selectedItemIds","onSelect","items","shouldCalcCountForAll","size","FilterButtonSize","Normal","selectedIds","setSelectedIds","useState","useEffect","handleSelect","useCallback","id","newIds","includes","filter","filteredId","length","selectedId","reactItems","useMemo","allButtonCount","reduce","acc","item","count","array","createElement","key","isSelected","Array","isArray","shape","FilterButtonItemShape","Rectangular","text","forEach","icons","color","push","Round","StyledFilterButton","displayName","_default","exports"],"sources":["../../../../src/components/filter-buttons/FilterButtons.tsx"],"sourcesContent":["import React, { FC, ReactElement, useCallback, useEffect, useMemo, useState } from 'react';\nimport {\n FilterButtonItemShape,\n FilterButtonSize,\n IFilterButtonItem,\n} from '../../types/filterButtons';\nimport FilterButton from './filter-button/FilterButton';\nimport { StyledFilterButton } from './FilterButtons.styles';\n\nexport type FilterButtonsProps = {\n /**\n * The number that should be displayed as count in the \"all\" button.\n */\n allCount?: number;\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 * If true, the count of all items will be shown in the \"all\" button.\n */\n shouldCalcCountForAll?: boolean;\n /**\n * The size auf the filter buttons. Use the FilterButtonSize enum.\n */\n size?: FilterButtonSize;\n};\n\nconst FilterButtons: FC<FilterButtonsProps> = ({\n allCount,\n selectedItemIds,\n onSelect,\n items,\n shouldCalcCountForAll = false,\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.filter((selectedId) => selectedId !== 'all'));\n }\n },\n [onSelect, selectedIds],\n );\n\n const reactItems = useMemo(() => {\n if (items.length === 0) {\n return null;\n }\n\n let allButtonCount = allCount;\n\n if (typeof allButtonCount !== 'number' && shouldCalcCountForAll) {\n allButtonCount = items.reduce((acc, item) => acc + (item.count || 0), 0);\n }\n\n const array: ReactElement[] = [\n <FilterButton\n count={allButtonCount}\n id=\"all\"\n key=\"all\"\n onSelect={handleSelect}\n isSelected={\n selectedIds.includes('all') ||\n (Array.isArray(selectedIds) && selectedIds.length === 0)\n }\n shape={FilterButtonItemShape.Rectangular}\n size={size}\n text=\"Alle\"\n />,\n ];\n\n items.forEach(({ icons, text, color, count, id }) => {\n array.push(\n <FilterButton\n color={color}\n icons={icons}\n id={id}\n key={id}\n count={count}\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 }, [allCount, handleSelect, items, selectedIds, shouldCalcCountForAll, size]);\n\n return useMemo(() => <StyledFilterButton>{reactItems}</StyledFilterButton>, [reactItems]);\n};\n\nFilterButtons.displayName = 'FilterButtons';\n\nexport default FilterButtons;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAKA,IAAAE,aAAA,GAAAC,sBAAA,CAAA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ACF,EAAE,CAAE;QACrCoB,KAAK,EAAEC,oCAAqB,CAACO,KAAM;QACnCrC,IAAI,EAAEA,IAAK;QACXgC,IAAI,EAAEA;MAAK,CACd,CACL,CAAC;IACL,CAAC,CAAC;IAEF,OAAOT,KAAK;EAChB,CAAC,EAAE,CAAC5B,QAAQ,EAAEY,YAAY,EAAET,KAAK,EAAEK,WAAW,EAAEJ,qBAAqB,EAAEC,IAAI,CAAC,CAAC;EAE7E,OAAO,IAAAiB,cAAO,EAAC,mBAAMlD,MAAA,CAAAS,OAAA,CAAAgD,aAAA,CAACnD,cAAA,CAAAiE,kBAAkB,QAAEtB,UAA+B,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;AAC7F,CAAC;AAEDtB,aAAa,CAAC6C,WAAW,GAAG,eAAe;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjE,OAAA,GAE7BkB,aAAa","ignoreList":[]}
|
|
@@ -31,7 +31,7 @@ const FilterButton = ({
|
|
|
31
31
|
}, /*#__PURE__*/_react.default.createElement(_FilterButton.StyledFilterButtonItemLabel, null, icons && /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
32
32
|
icons: icons,
|
|
33
33
|
size: 15
|
|
34
|
-
}), /*#__PURE__*/_react.default.createElement(_FilterButton.StyledFilterButtonItemLabelText, null, text), count && /*#__PURE__*/_react.default.createElement(_FilterButton.StyledFilterButtonItemLabelCount, null, count)), /*#__PURE__*/_react.default.createElement(_FilterButton.StyledFilterButtonItemBorder, {
|
|
34
|
+
}), /*#__PURE__*/_react.default.createElement(_FilterButton.StyledFilterButtonItemLabelText, null, text), typeof count === 'number' && /*#__PURE__*/_react.default.createElement(_FilterButton.StyledFilterButtonItemLabelCount, null, count.toLocaleString())), /*#__PURE__*/_react.default.createElement(_FilterButton.StyledFilterButtonItemBorder, {
|
|
35
35
|
$isSelected: isSelected,
|
|
36
36
|
$shape: shape,
|
|
37
37
|
$color: color
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterButton.js","names":["_react","_interopRequireWildcard","require","_Icon","_interopRequireDefault","_FilterButton","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","FilterButton","icons","size","shape","text","color","count","isSelected","id","onSelect","handleClick","useCallback","useMemo","createElement","StyledFilterButtonItem","$isSelected","$size","onClick","StyledFilterButtonItemLabel","StyledFilterButtonItemLabelText","StyledFilterButtonItemLabelCount","StyledFilterButtonItemBorder","$shape","$color","StyledMotionFilterButtonItemBackground","displayName","_default","exports"],"sources":["../../../../../src/components/filter-buttons/filter-button/FilterButton.tsx"],"sourcesContent":["import React, { CSSProperties, FC, useCallback, useMemo } from 'react';\nimport type { FilterButtonItemShape, FilterButtonSize } from '../../../types/filterButtons';\nimport Icon from '../../icon/Icon';\nimport {\n StyledFilterButtonItem,\n StyledFilterButtonItemBorder,\n StyledFilterButtonItemLabel,\n StyledFilterButtonItemLabelCount,\n StyledFilterButtonItemLabelText,\n StyledMotionFilterButtonItemBackground,\n} from './FilterButton.styles';\n\nexport type FilterButtonProps = {\n color?: CSSProperties['color'];\n icons?: string[];\n isSelected: boolean;\n shape: FilterButtonItemShape;\n size: FilterButtonSize;\n count?: number;\n text: string;\n id: string;\n onSelect: (key: string) => void;\n};\n\nconst FilterButton: FC<FilterButtonProps> = ({\n icons,\n size,\n shape,\n text,\n color,\n count,\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 && <Icon icons={icons} size={15} />}\n <StyledFilterButtonItemLabelText>{text}</StyledFilterButtonItemLabelText>\n {count && (\n <StyledFilterButtonItemLabelCount
|
|
1
|
+
{"version":3,"file":"FilterButton.js","names":["_react","_interopRequireWildcard","require","_Icon","_interopRequireDefault","_FilterButton","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","FilterButton","icons","size","shape","text","color","count","isSelected","id","onSelect","handleClick","useCallback","useMemo","createElement","StyledFilterButtonItem","$isSelected","$size","onClick","StyledFilterButtonItemLabel","StyledFilterButtonItemLabelText","StyledFilterButtonItemLabelCount","toLocaleString","StyledFilterButtonItemBorder","$shape","$color","StyledMotionFilterButtonItemBackground","displayName","_default","exports"],"sources":["../../../../../src/components/filter-buttons/filter-button/FilterButton.tsx"],"sourcesContent":["import React, { CSSProperties, FC, useCallback, useMemo } from 'react';\nimport type { FilterButtonItemShape, FilterButtonSize } from '../../../types/filterButtons';\nimport Icon from '../../icon/Icon';\nimport {\n StyledFilterButtonItem,\n StyledFilterButtonItemBorder,\n StyledFilterButtonItemLabel,\n StyledFilterButtonItemLabelCount,\n StyledFilterButtonItemLabelText,\n StyledMotionFilterButtonItemBackground,\n} from './FilterButton.styles';\n\nexport type FilterButtonProps = {\n color?: CSSProperties['color'];\n icons?: string[];\n isSelected: boolean;\n shape: FilterButtonItemShape;\n size: FilterButtonSize;\n count?: number;\n text: string;\n id: string;\n onSelect: (key: string) => void;\n};\n\nconst FilterButton: FC<FilterButtonProps> = ({\n icons,\n size,\n shape,\n text,\n color,\n count,\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 && <Icon icons={icons} size={15} />}\n <StyledFilterButtonItemLabelText>{text}</StyledFilterButtonItemLabelText>\n {typeof count === 'number' && (\n <StyledFilterButtonItemLabelCount>\n {count.toLocaleString()}\n </StyledFilterButtonItemLabelCount>\n )}\n </StyledFilterButtonItemLabel>\n <StyledFilterButtonItemBorder\n $isSelected={isSelected}\n $shape={shape}\n $color={color}\n />\n <StyledMotionFilterButtonItemBackground\n $isSelected={isSelected}\n $shape={shape}\n $color={color}\n />\n </StyledFilterButtonItem>\n ),\n [color, count, handleClick, icons, isSelected, shape, size, text],\n );\n};\n\nFilterButton.displayName = 'FilterButton';\n\nexport default FilterButton;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAO+B,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAe,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAd,CAAA,EAAAe,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAA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AA,CAAAQ,OAAA,CAAA+B,aAAA,CAAClC,aAAA,CAAA2C,4BAA4B;IACzBP,WAAW,EAAER,UAAW;IACxBgB,MAAM,EAAEpB,KAAM;IACdqB,MAAM,EAAEnB;EAAM,CACjB,CAAC,eACF/B,MAAA,CAAAQ,OAAA,CAAA+B,aAAA,CAAClC,aAAA,CAAA8C,sCAAsC;IACnCV,WAAW,EAAER,UAAW;IACxBgB,MAAM,EAAEpB,KAAM;IACdqB,MAAM,EAAEnB;EAAM,CACjB,CACmB,CAC3B,EACD,CAACA,KAAK,EAAEC,KAAK,EAAEI,WAAW,EAAET,KAAK,EAAEM,UAAU,EAAEJ,KAAK,EAAED,IAAI,EAAEE,IAAI,CACpE,CAAC;AACL,CAAC;AAEDJ,YAAY,CAAC0B,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA9C,OAAA,GAE3BkB,YAAY","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getMaxHeightInPixels = exports.getHeightOfSingleTextLine = exports.calculateContentWidth = exports.calculateContentHeight = exports.calculateBiggestWidth = void 0;
|
|
7
|
+
var _chaynsApi = require("chayns-api");
|
|
7
8
|
var _react = _interopRequireDefault(require("react"));
|
|
8
9
|
var _server = require("react-dom/server");
|
|
9
10
|
var _ColorSchemeProvider = _interopRequireDefault(require("../components/color-scheme-provider/ColorSchemeProvider"));
|
|
@@ -32,10 +33,17 @@ const calculateContentWidth = list => {
|
|
|
32
33
|
if (suffixElement) {
|
|
33
34
|
// ColorSchemeProvider is used to prevent missing scheme context error.
|
|
34
35
|
// Due to the fact that the element is never rendered visible, the values are irrelevant.
|
|
35
|
-
div.innerHTML += (0, _server.renderToString)(
|
|
36
|
+
div.innerHTML += (0, _server.renderToString)(
|
|
37
|
+
/*#__PURE__*/
|
|
38
|
+
// @ts-expect-error: It's a fake chayns provider because it's not necessary here to have the correct data
|
|
39
|
+
_react.default.createElement(_chaynsApi.ChaynsProvider, {
|
|
40
|
+
data: {},
|
|
41
|
+
functions: {},
|
|
42
|
+
isModule: true
|
|
43
|
+
}, /*#__PURE__*/_react.default.createElement(_ColorSchemeProvider.default, {
|
|
36
44
|
color: "#005EB8",
|
|
37
45
|
colorMode: 0
|
|
38
|
-
}, suffixElement));
|
|
46
|
+
}, suffixElement)));
|
|
39
47
|
}
|
|
40
48
|
length.push(div.offsetWidth);
|
|
41
49
|
document.body.removeChild(div);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate.js","names":["
|
|
1
|
+
{"version":3,"file":"calculate.js","names":["_chaynsApi","require","_react","_interopRequireDefault","_server","_ColorSchemeProvider","e","__esModule","default","calculateContentWidth","list","length","forEach","suffixElement","text","textStyles","tagName","styles","div","document","createElement","Object","assign","style","display","gap","position","visibility","whiteSpace","width","body","appendChild","innerText","innerHTML","renderToString","ChaynsProvider","data","functions","isModule","color","colorMode","push","offsetWidth","removeChild","Math","max","apply","exports","calculateBiggestWidth","elements","container","padding","id","element","accessKey","calculateContentHeight","heights","offsetHeight","reduce","partialSum","a","getHeightOfSingleTextLine","span","height","getMaxHeightInPixels","maxHeight","rootElement","tempElement","getBoundingClientRect"],"sources":["../../../src/utils/calculate.tsx"],"sourcesContent":["import { ChaynsProvider } from 'chayns-api';\nimport React, { type CSSProperties } from 'react';\nimport { renderToString } from 'react-dom/server';\nimport ColorSchemeProvider from '../components/color-scheme-provider/ColorSchemeProvider';\nimport type { IComboBoxItem } from '../components/combobox/ComboBox';\nimport type { SliderButtonItem } from '../types/slider-button';\n\nexport const calculateContentWidth = (list: IComboBoxItem[]) => {\n const length: number[] = [];\n\n list.forEach(({ suffixElement, text, textStyles }) => {\n const tagName = textStyles?.tagName ?? 'div';\n const styles = textStyles?.styles;\n\n const div = document.createElement(tagName);\n\n if (styles) {\n Object.assign(div.style, styles);\n }\n\n div.style.display = 'flex';\n div.style.gap = '10px';\n div.style.position = 'absolute';\n div.style.visibility = 'hidden';\n div.style.whiteSpace = 'nowrap';\n div.style.width = 'auto';\n\n document.body.appendChild(div);\n\n div.innerText = text;\n\n if (suffixElement) {\n // ColorSchemeProvider is used to prevent missing scheme context error.\n // Due to the fact that the element is never rendered visible, the values are irrelevant.\n div.innerHTML += renderToString(\n // @ts-expect-error: It's a fake chayns provider because it's not necessary here to have the correct data\n <ChaynsProvider data={{}} functions={{}} isModule>\n <ColorSchemeProvider color=\"#005EB8\" colorMode={0}>\n {suffixElement}\n </ColorSchemeProvider>\n </ChaynsProvider>,\n );\n }\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 calculateBiggestWidth = (elements: SliderButtonItem[]) => {\n const container = document.createElement('div');\n\n container.style.visibility = 'hidden';\n container.style.position = 'absolute';\n container.style.width = 'auto';\n container.style.whiteSpace = 'nowrap';\n container.style.padding = '7px 12px';\n container.style.display = 'block';\n\n elements.forEach(({ text, id }) => {\n const element = document.createElement('div');\n\n element.accessKey = `slider-button-pseudo--${id}`;\n element.innerText = text;\n\n container.appendChild(element);\n });\n\n document.body.appendChild(container);\n\n const width = container.offsetWidth;\n\n document.body.removeChild(container);\n\n return width;\n};\n\nexport const calculateContentHeight = (elements: string[]) => {\n const heights: number[] = [];\n\n elements.forEach((element: string) => {\n const div = document.createElement('div');\n\n div.style.visibility = 'hidden';\n div.style.position = 'absolute';\n div.style.width = 'auto';\n div.style.padding = '4px 10px';\n div.style.whiteSpace = 'nowrap';\n\n document.body.appendChild(div);\n\n div.innerText = element;\n\n heights.push(div.offsetHeight);\n\n document.body.removeChild(div);\n });\n\n return heights.reduce((partialSum, a) => partialSum + a, 0);\n};\n\nexport const getHeightOfSingleTextLine = () => {\n const span = document.createElement('span');\n\n span.innerText = 'A';\n\n document.body.appendChild(span);\n\n const height = span.offsetHeight;\n\n document.body.removeChild(span);\n\n return height;\n};\n\nexport const getMaxHeightInPixels = (\n maxHeight: CSSProperties['maxHeight'],\n rootElement: HTMLElement,\n): number => {\n const tempElement = document.createElement('div');\n\n tempElement.style.position = 'absolute';\n tempElement.style.visibility = 'hidden';\n tempElement.style.height = '100vh';\n tempElement.style.maxHeight = maxHeight as string;\n\n rootElement.appendChild(tempElement);\n\n const { height } = tempElement.getBoundingClientRect();\n\n rootElement.removeChild(tempElement);\n\n return height;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAA0F,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAInF,MAAMG,qBAAqB,GAAIC,IAAqB,IAAK;EAC5D,MAAMC,MAAgB,GAAG,EAAE;EAE3BD,IAAI,CAACE,OAAO,CAAC,CAAC;IAAEC,aAAa;IAAEC,IAAI;IAAEC;EAAW,CAAC,KAAK;IAClD,MAAMC,OAAO,GAAG,CAAAD,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEC,OAAO,KAAI,KAAK;IAC5C,MAAMC,MAAM,GAAGF,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEE,MAAM;IAEjC,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAACJ,OAAO,CAAC;IAE3C,IAAIC,MAAM,EAAE;MACRI,MAAM,CAACC,MAAM,CAACJ,GAAG,CAACK,KAAK,EAAEN,MAAM,CAAC;IACpC;IAEAC,GAAG,CAACK,KAAK,CAACC,OAAO,GAAG,MAAM;IAC1BN,GAAG,CAACK,KAAK,CAACE,GAAG,GAAG,MAAM;IACtBP,GAAG,CAACK,KAAK,CAACG,QAAQ,GAAG,UAAU;IAC/BR,GAAG,CAACK,KAAK,CAACI,UAAU,GAAG,QAAQ;I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
@@ -4,9 +4,11 @@ import FilterButton from './filter-button/FilterButton';
|
|
|
4
4
|
import { StyledFilterButton } from './FilterButtons.styles';
|
|
5
5
|
const FilterButtons = _ref => {
|
|
6
6
|
let {
|
|
7
|
+
allCount,
|
|
7
8
|
selectedItemIds,
|
|
8
9
|
onSelect,
|
|
9
10
|
items,
|
|
11
|
+
shouldCalcCountForAll = false,
|
|
10
12
|
size = FilterButtonSize.Normal
|
|
11
13
|
} = _ref;
|
|
12
14
|
const [selectedIds, setSelectedIds] = useState(['all']);
|
|
@@ -42,7 +44,12 @@ const FilterButtons = _ref => {
|
|
|
42
44
|
if (items.length === 0) {
|
|
43
45
|
return null;
|
|
44
46
|
}
|
|
47
|
+
let allButtonCount = allCount;
|
|
48
|
+
if (typeof allButtonCount !== 'number' && shouldCalcCountForAll) {
|
|
49
|
+
allButtonCount = items.reduce((acc, item) => acc + (item.count || 0), 0);
|
|
50
|
+
}
|
|
45
51
|
const array = [/*#__PURE__*/React.createElement(FilterButton, {
|
|
52
|
+
count: allButtonCount,
|
|
46
53
|
id: "all",
|
|
47
54
|
key: "all",
|
|
48
55
|
onSelect: handleSelect,
|
|
@@ -73,7 +80,7 @@ const FilterButtons = _ref => {
|
|
|
73
80
|
}));
|
|
74
81
|
});
|
|
75
82
|
return array;
|
|
76
|
-
}, [handleSelect, items, selectedIds, size]);
|
|
83
|
+
}, [allCount, handleSelect, items, selectedIds, shouldCalcCountForAll, size]);
|
|
77
84
|
return useMemo(() => /*#__PURE__*/React.createElement(StyledFilterButton, null, reactItems), [reactItems]);
|
|
78
85
|
};
|
|
79
86
|
FilterButtons.displayName = 'FilterButtons';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterButtons.js","names":["React","useCallback","useEffect","useMemo","useState","FilterButtonItemShape","FilterButtonSize","FilterButton","StyledFilterButton","FilterButtons","_ref","selectedItemIds","onSelect","items","size","Normal","selectedIds","setSelectedIds","handleSelect","id","newIds","includes","filter","filteredId","length","selectedId","reactItems","array","createElement","key","isSelected","Array","isArray","shape","Rectangular","text","forEach","_ref2","icons","color","
|
|
1
|
+
{"version":3,"file":"FilterButtons.js","names":["React","useCallback","useEffect","useMemo","useState","FilterButtonItemShape","FilterButtonSize","FilterButton","StyledFilterButton","FilterButtons","_ref","allCount","selectedItemIds","onSelect","items","shouldCalcCountForAll","size","Normal","selectedIds","setSelectedIds","handleSelect","id","newIds","includes","filter","filteredId","length","selectedId","reactItems","allButtonCount","reduce","acc","item","count","array","createElement","key","isSelected","Array","isArray","shape","Rectangular","text","forEach","_ref2","icons","color","push","Round","displayName"],"sources":["../../../../src/components/filter-buttons/FilterButtons.tsx"],"sourcesContent":["import React, { FC, ReactElement, useCallback, useEffect, useMemo, useState } from 'react';\nimport {\n FilterButtonItemShape,\n FilterButtonSize,\n IFilterButtonItem,\n} from '../../types/filterButtons';\nimport FilterButton from './filter-button/FilterButton';\nimport { StyledFilterButton } from './FilterButtons.styles';\n\nexport type FilterButtonsProps = {\n /**\n * The number that should be displayed as count in the \"all\" button.\n */\n allCount?: number;\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 * If true, the count of all items will be shown in the \"all\" button.\n */\n shouldCalcCountForAll?: boolean;\n /**\n * The size auf the filter buttons. Use the FilterButtonSize enum.\n */\n size?: FilterButtonSize;\n};\n\nconst FilterButtons: FC<FilterButtonsProps> = ({\n allCount,\n selectedItemIds,\n onSelect,\n items,\n shouldCalcCountForAll = false,\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.filter((selectedId) => selectedId !== 'all'));\n }\n },\n [onSelect, selectedIds],\n );\n\n const reactItems = useMemo(() => {\n if (items.length === 0) {\n return null;\n }\n\n let allButtonCount = allCount;\n\n if (typeof allButtonCount !== 'number' && shouldCalcCountForAll) {\n allButtonCount = items.reduce((acc, item) => acc + (item.count || 0), 0);\n }\n\n const array: ReactElement[] = [\n <FilterButton\n count={allButtonCount}\n id=\"all\"\n key=\"all\"\n onSelect={handleSelect}\n isSelected={\n selectedIds.includes('all') ||\n (Array.isArray(selectedIds) && selectedIds.length === 0)\n }\n shape={FilterButtonItemShape.Rectangular}\n size={size}\n text=\"Alle\"\n />,\n ];\n\n items.forEach(({ icons, text, color, count, id }) => {\n array.push(\n <FilterButton\n color={color}\n icons={icons}\n id={id}\n key={id}\n count={count}\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 }, [allCount, handleSelect, items, selectedIds, shouldCalcCountForAll, size]);\n\n return useMemo(() => <StyledFilterButton>{reactItems}</StyledFilterButton>, [reactItems]);\n};\n\nFilterButtons.displayName = 'FilterButtons';\n\nexport default FilterButtons;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAsBC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC1F,SACIC,qBAAqB,EACrBC,gBAAgB,QAEb,2BAA2B;AAClC,OAAOC,YAAY,MAAM,8BAA8B;AACvD,SAASC,kBAAkB,QAAQ,wBAAwB;AA6B3D,MAAMC,aAAqC,GAAGC,IAAA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AqB,CAAC2C,KAAM;QACnChC,IAAI,EAAEA,IAAK;QACX0B,IAAI,EAAEA;MAAK,CACd,CACL,CAAC;IACL,CAAC,CAAC;IAEF,OAAOR,KAAK;EAChB,CAAC,EAAE,CAACvB,QAAQ,EAAES,YAAY,EAAEN,KAAK,EAAEI,WAAW,EAAEH,qBAAqB,EAAEC,IAAI,CAAC,CAAC;EAE7E,OAAOb,OAAO,CAAC,mBAAMH,KAAA,CAAAmC,aAAA,CAAC3B,kBAAkB,QAAEoB,UAA+B,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;AAC7F,CAAC;AAEDnB,aAAa,CAACwC,WAAW,GAAG,eAAe;AAE3C,eAAexC,aAAa","ignoreList":[]}
|
|
@@ -23,7 +23,7 @@ const FilterButton = _ref => {
|
|
|
23
23
|
}, /*#__PURE__*/React.createElement(StyledFilterButtonItemLabel, null, icons && /*#__PURE__*/React.createElement(Icon, {
|
|
24
24
|
icons: icons,
|
|
25
25
|
size: 15
|
|
26
|
-
}), /*#__PURE__*/React.createElement(StyledFilterButtonItemLabelText, null, text), count && /*#__PURE__*/React.createElement(StyledFilterButtonItemLabelCount, null, count)), /*#__PURE__*/React.createElement(StyledFilterButtonItemBorder, {
|
|
26
|
+
}), /*#__PURE__*/React.createElement(StyledFilterButtonItemLabelText, null, text), typeof count === 'number' && /*#__PURE__*/React.createElement(StyledFilterButtonItemLabelCount, null, count.toLocaleString())), /*#__PURE__*/React.createElement(StyledFilterButtonItemBorder, {
|
|
27
27
|
$isSelected: isSelected,
|
|
28
28
|
$shape: shape,
|
|
29
29
|
$color: color
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterButton.js","names":["React","useCallback","useMemo","Icon","StyledFilterButtonItem","StyledFilterButtonItemBorder","StyledFilterButtonItemLabel","StyledFilterButtonItemLabelCount","StyledFilterButtonItemLabelText","StyledMotionFilterButtonItemBackground","FilterButton","_ref","icons","size","shape","text","color","count","isSelected","id","onSelect","handleClick","createElement","$isSelected","$size","onClick","$shape","$color","displayName"],"sources":["../../../../../src/components/filter-buttons/filter-button/FilterButton.tsx"],"sourcesContent":["import React, { CSSProperties, FC, useCallback, useMemo } from 'react';\nimport type { FilterButtonItemShape, FilterButtonSize } from '../../../types/filterButtons';\nimport Icon from '../../icon/Icon';\nimport {\n StyledFilterButtonItem,\n StyledFilterButtonItemBorder,\n StyledFilterButtonItemLabel,\n StyledFilterButtonItemLabelCount,\n StyledFilterButtonItemLabelText,\n StyledMotionFilterButtonItemBackground,\n} from './FilterButton.styles';\n\nexport type FilterButtonProps = {\n color?: CSSProperties['color'];\n icons?: string[];\n isSelected: boolean;\n shape: FilterButtonItemShape;\n size: FilterButtonSize;\n count?: number;\n text: string;\n id: string;\n onSelect: (key: string) => void;\n};\n\nconst FilterButton: FC<FilterButtonProps> = ({\n icons,\n size,\n shape,\n text,\n color,\n count,\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 && <Icon icons={icons} size={15} />}\n <StyledFilterButtonItemLabelText>{text}</StyledFilterButtonItemLabelText>\n {count && (\n <StyledFilterButtonItemLabelCount
|
|
1
|
+
{"version":3,"file":"FilterButton.js","names":["React","useCallback","useMemo","Icon","StyledFilterButtonItem","StyledFilterButtonItemBorder","StyledFilterButtonItemLabel","StyledFilterButtonItemLabelCount","StyledFilterButtonItemLabelText","StyledMotionFilterButtonItemBackground","FilterButton","_ref","icons","size","shape","text","color","count","isSelected","id","onSelect","handleClick","createElement","$isSelected","$size","onClick","toLocaleString","$shape","$color","displayName"],"sources":["../../../../../src/components/filter-buttons/filter-button/FilterButton.tsx"],"sourcesContent":["import React, { CSSProperties, FC, useCallback, useMemo } from 'react';\nimport type { FilterButtonItemShape, FilterButtonSize } from '../../../types/filterButtons';\nimport Icon from '../../icon/Icon';\nimport {\n StyledFilterButtonItem,\n StyledFilterButtonItemBorder,\n StyledFilterButtonItemLabel,\n StyledFilterButtonItemLabelCount,\n StyledFilterButtonItemLabelText,\n StyledMotionFilterButtonItemBackground,\n} from './FilterButton.styles';\n\nexport type FilterButtonProps = {\n color?: CSSProperties['color'];\n icons?: string[];\n isSelected: boolean;\n shape: FilterButtonItemShape;\n size: FilterButtonSize;\n count?: number;\n text: string;\n id: string;\n onSelect: (key: string) => void;\n};\n\nconst FilterButton: FC<FilterButtonProps> = ({\n icons,\n size,\n shape,\n text,\n color,\n count,\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 && <Icon icons={icons} size={15} />}\n <StyledFilterButtonItemLabelText>{text}</StyledFilterButtonItemLabelText>\n {typeof count === 'number' && (\n <StyledFilterButtonItemLabelCount>\n {count.toLocaleString()}\n </StyledFilterButtonItemLabelCount>\n )}\n </StyledFilterButtonItemLabel>\n <StyledFilterButtonItemBorder\n $isSelected={isSelected}\n $shape={shape}\n $color={color}\n />\n <StyledMotionFilterButtonItemBackground\n $isSelected={isSelected}\n $shape={shape}\n $color={color}\n />\n </StyledFilterButtonItem>\n ),\n [color, count, handleClick, icons, isSelected, shape, size, text],\n );\n};\n\nFilterButton.displayName = 'FilterButton';\n\nexport default FilterButton;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAuBC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAEtE,OAAOC,IAAI,MAAM,iBAAiB;AAClC,SACIC,sBAAsB,EACtBC,4BAA4B,EAC5BC,2BAA2B,EAC3BC,gCAAgC,EAChCC,+BAA+B,EAC/BC,sCAAsC,QACnC,uBAAuB;AAc9B,MAAMC,YAAmC,GAAGC,IAAA,IAUtC;EAAA,IAVuC;IACzCC,KAAK;IACLC,IAAI;IACJC,K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1,4 @@
|
|
|
1
|
+
import { ChaynsProvider } from 'chayns-api';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { renderToString } from 'react-dom/server';
|
|
3
4
|
import ColorSchemeProvider from '../components/color-scheme-provider/ColorSchemeProvider';
|
|
@@ -26,10 +27,17 @@ export const calculateContentWidth = list => {
|
|
|
26
27
|
if (suffixElement) {
|
|
27
28
|
// ColorSchemeProvider is used to prevent missing scheme context error.
|
|
28
29
|
// Due to the fact that the element is never rendered visible, the values are irrelevant.
|
|
29
|
-
div.innerHTML += renderToString(
|
|
30
|
+
div.innerHTML += renderToString(
|
|
31
|
+
/*#__PURE__*/
|
|
32
|
+
// @ts-expect-error: It's a fake chayns provider because it's not necessary here to have the correct data
|
|
33
|
+
React.createElement(ChaynsProvider, {
|
|
34
|
+
data: {},
|
|
35
|
+
functions: {},
|
|
36
|
+
isModule: true
|
|
37
|
+
}, /*#__PURE__*/React.createElement(ColorSchemeProvider, {
|
|
30
38
|
color: "#005EB8",
|
|
31
39
|
colorMode: 0
|
|
32
|
-
}, suffixElement));
|
|
40
|
+
}, suffixElement)));
|
|
33
41
|
}
|
|
34
42
|
length.push(div.offsetWidth);
|
|
35
43
|
document.body.removeChild(div);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate.js","names":["React","renderToString","ColorSchemeProvider","calculateContentWidth","list","length","forEach","_ref","suffixElement","text","textStyles","tagName","styles","div","document","createElement","Object","assign","style","display","gap","position","visibility","whiteSpace","width","body","appendChild","innerText","innerHTML","color","colorMode","push","offsetWidth","removeChild","Math","max","apply","calculateBiggestWidth","elements","container","padding","_ref2","id","element","accessKey","calculateContentHeight","heights","offsetHeight","reduce","partialSum","a","getHeightOfSingleTextLine","span","height","getMaxHeightInPixels","maxHeight","rootElement","tempElement","getBoundingClientRect"],"sources":["../../../src/utils/calculate.tsx"],"sourcesContent":["import React, { type CSSProperties } from 'react';\nimport { renderToString } from 'react-dom/server';\nimport ColorSchemeProvider from '../components/color-scheme-provider/ColorSchemeProvider';\nimport type { IComboBoxItem } from '../components/combobox/ComboBox';\nimport type { SliderButtonItem } from '../types/slider-button';\n\nexport const calculateContentWidth = (list: IComboBoxItem[]) => {\n const length: number[] = [];\n\n list.forEach(({ suffixElement, text, textStyles }) => {\n const tagName = textStyles?.tagName ?? 'div';\n const styles = textStyles?.styles;\n\n const div = document.createElement(tagName);\n\n if (styles) {\n Object.assign(div.style, styles);\n }\n\n div.style.display = 'flex';\n div.style.gap = '10px';\n div.style.position = 'absolute';\n div.style.visibility = 'hidden';\n div.style.whiteSpace = 'nowrap';\n div.style.width = 'auto';\n\n document.body.appendChild(div);\n\n div.innerText = text;\n\n if (suffixElement) {\n // ColorSchemeProvider is used to prevent missing scheme context error.\n // Due to the fact that the element is never rendered visible, the values are irrelevant.\n div.innerHTML += renderToString(\n <ColorSchemeProvider color=\"#005EB8\" colorMode={0}>\n
|
|
1
|
+
{"version":3,"file":"calculate.js","names":["ChaynsProvider","React","renderToString","ColorSchemeProvider","calculateContentWidth","list","length","forEach","_ref","suffixElement","text","textStyles","tagName","styles","div","document","createElement","Object","assign","style","display","gap","position","visibility","whiteSpace","width","body","appendChild","innerText","innerHTML","data","functions","isModule","color","colorMode","push","offsetWidth","removeChild","Math","max","apply","calculateBiggestWidth","elements","container","padding","_ref2","id","element","accessKey","calculateContentHeight","heights","offsetHeight","reduce","partialSum","a","getHeightOfSingleTextLine","span","height","getMaxHeightInPixels","maxHeight","rootElement","tempElement","getBoundingClientRect"],"sources":["../../../src/utils/calculate.tsx"],"sourcesContent":["import { ChaynsProvider } from 'chayns-api';\nimport React, { type CSSProperties } from 'react';\nimport { renderToString } from 'react-dom/server';\nimport ColorSchemeProvider from '../components/color-scheme-provider/ColorSchemeProvider';\nimport type { IComboBoxItem } from '../components/combobox/ComboBox';\nimport type { SliderButtonItem } from '../types/slider-button';\n\nexport const calculateContentWidth = (list: IComboBoxItem[]) => {\n const length: number[] = [];\n\n list.forEach(({ suffixElement, text, textStyles }) => {\n const tagName = textStyles?.tagName ?? 'div';\n const styles = textStyles?.styles;\n\n const div = document.createElement(tagName);\n\n if (styles) {\n Object.assign(div.style, styles);\n }\n\n div.style.display = 'flex';\n div.style.gap = '10px';\n div.style.position = 'absolute';\n div.style.visibility = 'hidden';\n div.style.whiteSpace = 'nowrap';\n div.style.width = 'auto';\n\n document.body.appendChild(div);\n\n div.innerText = text;\n\n if (suffixElement) {\n // ColorSchemeProvider is used to prevent missing scheme context error.\n // Due to the fact that the element is never rendered visible, the values are irrelevant.\n div.innerHTML += renderToString(\n // @ts-expect-error: It's a fake chayns provider because it's not necessary here to have the correct data\n <ChaynsProvider data={{}} functions={{}} isModule>\n <ColorSchemeProvider color=\"#005EB8\" colorMode={0}>\n {suffixElement}\n </ColorSchemeProvider>\n </ChaynsProvider>,\n );\n }\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 calculateBiggestWidth = (elements: SliderButtonItem[]) => {\n const container = document.createElement('div');\n\n container.style.visibility = 'hidden';\n container.style.position = 'absolute';\n container.style.width = 'auto';\n container.style.whiteSpace = 'nowrap';\n container.style.padding = '7px 12px';\n container.style.display = 'block';\n\n elements.forEach(({ text, id }) => {\n const element = document.createElement('div');\n\n element.accessKey = `slider-button-pseudo--${id}`;\n element.innerText = text;\n\n container.appendChild(element);\n });\n\n document.body.appendChild(container);\n\n const width = container.offsetWidth;\n\n document.body.removeChild(container);\n\n return width;\n};\n\nexport const calculateContentHeight = (elements: string[]) => {\n const heights: number[] = [];\n\n elements.forEach((element: string) => {\n const div = document.createElement('div');\n\n div.style.visibility = 'hidden';\n div.style.position = 'absolute';\n div.style.width = 'auto';\n div.style.padding = '4px 10px';\n div.style.whiteSpace = 'nowrap';\n\n document.body.appendChild(div);\n\n div.innerText = element;\n\n heights.push(div.offsetHeight);\n\n document.body.removeChild(div);\n });\n\n return heights.reduce((partialSum, a) => partialSum + a, 0);\n};\n\nexport const getHeightOfSingleTextLine = () => {\n const span = document.createElement('span');\n\n span.innerText = 'A';\n\n document.body.appendChild(span);\n\n const height = span.offsetHeight;\n\n document.body.removeChild(span);\n\n return height;\n};\n\nexport const getMaxHeightInPixels = (\n maxHeight: CSSProperties['maxHeight'],\n rootElement: HTMLElement,\n): number => {\n const tempElement = document.createElement('div');\n\n tempElement.style.position = 'absolute';\n tempElement.style.visibility = 'hidden';\n tempElement.style.height = '100vh';\n tempElement.style.maxHeight = maxHeight as string;\n\n rootElement.appendChild(tempElement);\n\n const { height } = tempElement.getBoundingClientRect();\n\n rootElement.removeChild(tempElement);\n\n return height;\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,YAAY;AAC3C,OAAOC,KAAK,MAA8B,OAAO;AACjD,SAASC,cAAc,QAAQ,kBAAkB;AACjD,OAAOC,mBAAmB,MAAM,yDAAyD;AAIzF,OAAO,MAAMC,qBAAqB,GAAIC,IAAqB,IAAK;EAC5D,MAAMC,MAAgB,GAAG,EAAE;EAE3BD,IAAI,CAACE,OAAO,CAACC,IAAA,IAAyC;IAAA,IAAxC;MAAEC,aAAa;MAAEC,IAAI;MAAEC;IAAW,CAAC,GAAAH,IAAA;IAC7C,MAAMI,OAAO,GAAGD,UAAU,EAAEC,OAAO,IAAI,KAAK;IAC5C,MAAMC,MAAM,GAAGF,UAAU,EAAEE,MAAM;IAEjC,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAACJ,OAAO,CAAC;IAE3C,IAAIC,MAAM,EAAE;MACRI,MAAM,CAACC,MAAM,CAACJ,GAAG,CAACK,KAAK,EAAEN,MAAM,CAAC;IACpC;IAEAC,GAAG,CAACK,KAAK,CAACC,OAAO,GAAG,MAAM;IAC1BN,GAAG,CAACK,KAAK,CAACE,GAAG,GAAG,MAAM;IACtBP,GAAG,CAACK,KAAK,CAACG,QAAQ,GAAG,UAAU;IAC/BR,GAAG,CAACK,KAAK,CAACI,UAAU,GAAG,QAAQ;IAC/BT,GAAG,CAACK,KAAK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AKD,UAAU,GAAGC,CAAC,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,IAAI,GAAGzC,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAC;EAE3CwC,IAAI,CAAC5B,SAAS,GAAG,GAAG;EAEpBb,QAAQ,CAACW,IAAI,CAACC,WAAW,CAAC6B,IAAI,CAAC;EAE/B,MAAMC,MAAM,GAAGD,IAAI,CAACL,YAAY;EAEhCpC,QAAQ,CAACW,IAAI,CAACW,WAAW,CAACmB,IAAI,CAAC;EAE/B,OAAOC,MAAM;AACjB,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAGA,CAChCC,SAAqC,EACrCC,WAAwB,KACf;EACT,MAAMC,WAAW,GAAG9C,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAEjD6C,WAAW,CAAC1C,KAAK,CAACG,QAAQ,GAAG,UAAU;EACvCuC,WAAW,CAAC1C,KAAK,CAACI,UAAU,GAAG,QAAQ;EACvCsC,WAAW,CAAC1C,KAAK,CAACsC,MAAM,GAAG,OAAO;EAClCI,WAAW,CAAC1C,KAAK,CAACwC,SAAS,GAAGA,SAAmB;EAEjDC,WAAW,CAACjC,WAAW,CAACkC,WAAW,CAAC;EAEpC,MAAM;IAAEJ;EAAO,CAAC,GAAGI,WAAW,CAACC,qBAAqB,CAAC,CAAC;EAEtDF,WAAW,CAACvB,WAAW,CAACwB,WAAW,CAAC;EAEpC,OAAOJ,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { FilterButtonSize, IFilterButtonItem } from '../../types/filterButtons';
|
|
3
3
|
export type FilterButtonsProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The number that should be displayed as count in the "all" button.
|
|
6
|
+
*/
|
|
7
|
+
allCount?: number;
|
|
4
8
|
/**
|
|
5
9
|
* The items that should be displayed.
|
|
6
10
|
*/
|
|
@@ -13,6 +17,10 @@ export type FilterButtonsProps = {
|
|
|
13
17
|
* The keys of items that should be selected.
|
|
14
18
|
*/
|
|
15
19
|
selectedItemIds?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* If true, the count of all items will be shown in the "all" button.
|
|
22
|
+
*/
|
|
23
|
+
shouldCalcCountForAll?: boolean;
|
|
16
24
|
/**
|
|
17
25
|
* The size auf the filter buttons. Use the FilterButtonSize enum.
|
|
18
26
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.953",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "3bfce8ead50d1103c1226648980618fdf3d3724d"
|
|
91
91
|
}
|