@coveord/plasma-mantine 59.4.0 → 59.4.1
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/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-test.log +91 -93
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/Facet/Facet.d.ts +11 -1
- package/dist/cjs/components/Facet/Facet.d.ts.map +1 -1
- package/dist/cjs/components/Facet/Facet.js +25 -14
- package/dist/cjs/components/Facet/Facet.js.map +1 -1
- package/dist/cjs/components/Facet/Facet.module.css +13 -0
- package/dist/esm/components/Facet/Facet.d.ts +11 -1
- package/dist/esm/components/Facet/Facet.d.ts.map +1 -1
- package/dist/esm/components/Facet/Facet.js +25 -16
- package/dist/esm/components/Facet/Facet.js.map +1 -1
- package/dist/esm/components/Facet/Facet.module.css +13 -0
- package/package.json +7 -7
- package/src/components/Facet/Facet.module.css +13 -0
- package/src/components/Facet/Facet.tsx +35 -9
- package/src/components/Facet/__tests__/Facet.component.spec.tsx +20 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BoxProps, Factory, StylesApiProps } from '@mantine/core';
|
|
2
2
|
import { FunctionComponent, ReactNode } from 'react';
|
|
3
3
|
import { FacetData, FacetItem, FacetItemComponent } from './FacetTypes.js';
|
|
4
|
-
export type FacetStylesNames = 'facet' | 'facetItem' | 'facetItems' | 'facetHeader' | 'searchInput' | 'hiddenSearch' | 'facetBody' | 'facetTitle' | 'facetSearch' | 'facetControl' | 'separator' | 'separatorLabel';
|
|
4
|
+
export type FacetStylesNames = 'facet' | 'facetItem' | 'facetItems' | 'facetHeader' | 'searchInput' | 'hiddenSearch' | 'facetBody' | 'facetTitleRow' | 'facetTitle' | 'facetRemoveButton' | 'facetSearch' | 'facetControl' | 'separator' | 'separatorLabel';
|
|
5
5
|
export interface FacetProps extends BoxProps, StylesApiProps<FacetFactory> {
|
|
6
6
|
className?: string;
|
|
7
7
|
/**
|
|
@@ -14,12 +14,22 @@ export interface FacetProps extends BoxProps, StylesApiProps<FacetFactory> {
|
|
|
14
14
|
* @param values the selected items
|
|
15
15
|
*/
|
|
16
16
|
onChange?: (values: string[]) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Function called when the remove icon is clicked.
|
|
19
|
+
*/
|
|
20
|
+
onRemove?: () => void;
|
|
17
21
|
/**
|
|
18
22
|
* Initial items selection
|
|
19
23
|
*
|
|
20
24
|
* @default []
|
|
21
25
|
*/
|
|
22
26
|
initialSelection?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Determines if the facet is removable
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
removable?: boolean;
|
|
23
33
|
/**
|
|
24
34
|
* Determined items selection
|
|
25
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Facet.d.ts","sourceRoot":"","sources":["../../../../src/components/Facet/Facet.tsx"],"names":[],"mappings":"AACA,OAAO,EAEH,QAAQ,
|
|
1
|
+
{"version":3,"file":"Facet.d.ts","sourceRoot":"","sources":["../../../../src/components/Facet/Facet.tsx"],"names":[],"mappings":"AACA,OAAO,EAEH,QAAQ,EAKR,OAAO,EAEP,cAAc,EAMjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,iBAAiB,EAAgB,SAAS,EAAY,MAAM,OAAO,CAAC;AAK5E,OAAO,EAAC,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAEzE,MAAM,MAAM,gBAAgB,GACtB,OAAO,GACP,WAAW,GACX,YAAY,GACZ,aAAa,GACb,aAAa,GACb,cAAc,GACd,WAAW,GACX,eAAe,GACf,YAAY,GACZ,mBAAmB,GACnB,aAAa,GACb,cAAc,GACd,WAAW,GACX,gBAAgB,CAAC;AAEvB,MAAM,WAAW,UAAW,SAAQ,QAAQ,EAAE,cAAc,CAAC,YAAY,CAAC;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;I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gB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,GAAG,EAAE,cAAc,CAAC;IACpB,WAAW,EAAE,gBAAgB,CAAC;CACjC,CAAC,CAAC;AAaH,eAAO,MAAM,KAAK,EAAE,iBAAiB,CAAC,UAAU,CA2K9C,CAAC"}
|
|
@@ -22,7 +22,6 @@ var _hooks = require("@mantine/hooks");
|
|
|
22
22
|
var _clsx = require("clsx");
|
|
23
23
|
var _react = require("react");
|
|
24
24
|
var _groupOptions = require("../../utils/groupOptions.js");
|
|
25
|
-
var _ActionIcon = require("../ActionIcon/ActionIcon.js");
|
|
26
25
|
var _DefaultFacetItem = require("./DefaultFacetItem.js");
|
|
27
26
|
var _Facetmodulecss = /*#__PURE__*/ _interop_require_default._(require("./Facet.module.css"));
|
|
28
27
|
var _FacetScrollArea = require("./FacetScrollArea.js");
|
|
@@ -33,15 +32,18 @@ var defaultProps = {
|
|
|
33
32
|
height: 200,
|
|
34
33
|
limit: Infinity,
|
|
35
34
|
itemComponent: _DefaultFacetItem.DefaultFacetItem,
|
|
36
|
-
listComponent: _FacetScrollArea.FacetScrollArea
|
|
35
|
+
listComponent: _FacetScrollArea.FacetScrollArea,
|
|
36
|
+
removable: false
|
|
37
37
|
};
|
|
38
38
|
var Facet = (0, _core.factory)(function(_props, ref) {
|
|
39
39
|
var props = (0, _core.useProps)('Facet', defaultProps, _props);
|
|
40
|
-
var className = props.className, data = props.data, onChange = props.onChange, _props_initialSelection = props.initialSelection, initialSelection = _props_initialSelection === void 0 ? [] : _props_initialSelection, selection = props.selection, ItemComponent = props.itemComponent, ListComponent = props.listComponent, itemCountFormatter = props.itemCountFormatter, searchPlaceholder = props.searchPlaceholder, query = props.query, _props_hideSearch = props.hideSearch, hideSearch = _props_hideSearch === void 0 ? data.length <= 7 : _props_hideSearch, onSearch = props.onSearch, _props_filter = props.filter, filter = _props_filter === void 0 ? defaultFilter : _props_filter, nothingFound = props.nothingFound, placeholder = props.placeholder, title = props.title, height = props.height, radius = props.radius, __staticSelector = props.__staticSelector, classNames = props.classNames, styles = props.styles, limit = props.limit, unstyled = props.unstyled, others = _object_without_properties._(props, [
|
|
40
|
+
var className = props.className, data = props.data, onChange = props.onChange, onRemove = props.onRemove, _props_initialSelection = props.initialSelection, initialSelection = _props_initialSelection === void 0 ? [] : _props_initialSelection, removable = props.removable, selection = props.selection, ItemComponent = props.itemComponent, ListComponent = props.listComponent, itemCountFormatter = props.itemCountFormatter, searchPlaceholder = props.searchPlaceholder, query = props.query, _props_hideSearch = props.hideSearch, hideSearch = _props_hideSearch === void 0 ? data.length <= 7 : _props_hideSearch, onSearch = props.onSearch, _props_filter = props.filter, filter = _props_filter === void 0 ? defaultFilter : _props_filter, nothingFound = props.nothingFound, placeholder = props.placeholder, title = props.title, height = props.height, radius = props.radius, __staticSelector = props.__staticSelector, classNames = props.classNames, styles = props.styles, limit = props.limit, unstyled = props.unstyled, others = _object_without_properties._(props, [
|
|
41
41
|
"className",
|
|
42
42
|
"data",
|
|
43
43
|
"onChange",
|
|
44
|
+
"onRemove",
|
|
44
45
|
"initialSelection",
|
|
46
|
+
"removable",
|
|
45
47
|
"selection",
|
|
46
48
|
"itemComponent",
|
|
47
49
|
"listComponent",
|
|
@@ -150,10 +152,23 @@ var Facet = (0, _core.factory)(function(_props, ref) {
|
|
|
150
152
|
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_core.Box, {
|
|
151
153
|
className: _Facetmodulecss.default.facetHeader,
|
|
152
154
|
children: [
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_core.Group, {
|
|
156
|
+
wrap: "nowrap",
|
|
157
|
+
justify: "space-between",
|
|
158
|
+
className: _Facetmodulecss.default.facetTitleRow,
|
|
159
|
+
children: [
|
|
160
|
+
title ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.Title, {
|
|
161
|
+
order: 5,
|
|
162
|
+
className: _Facetmodulecss.default.facetTitle,
|
|
163
|
+
children: title
|
|
164
|
+
}) : null,
|
|
165
|
+
removable ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.CloseButton, {
|
|
166
|
+
onClick: onRemove,
|
|
167
|
+
className: _Facetmodulecss.default.facetRemoveButton,
|
|
168
|
+
"aria-label": "remove facet"
|
|
169
|
+
}) : null
|
|
170
|
+
]
|
|
171
|
+
}),
|
|
157
172
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_core.TextInput, {
|
|
158
173
|
unstyled: unstyled,
|
|
159
174
|
value: search,
|
|
@@ -165,16 +180,12 @@ var Facet = (0, _core.factory)(function(_props, ref) {
|
|
|
165
180
|
"aria-hidden": hideSearch,
|
|
166
181
|
tabIndex: hideSearch ? -1 : undefined,
|
|
167
182
|
className: (0, _clsx.clsx)(_Facetmodulecss.default.facetSearch, _define_property._({}, _Facetmodulecss.default.hiddenSearch, hideSearch)),
|
|
168
|
-
rightSection: search ? /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
183
|
+
rightSection: search ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.CloseButton, {
|
|
169
184
|
"aria-label": "clear search",
|
|
170
|
-
color: "gray",
|
|
171
185
|
onClick: function onClick() {
|
|
172
186
|
handleSearch('');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
height: 16
|
|
176
|
-
})
|
|
177
|
-
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_plasmareacticons.FilterSize16Px, {
|
|
187
|
+
}
|
|
188
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_plasmareacticons.IconSearch, {
|
|
178
189
|
height: 16
|
|
179
190
|
})
|
|
180
191
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Facet/Facet.tsx"],"sourcesContent":["import {CrossSize16Px, FilterSize16Px} from '@coveord/plasma-react-icons';\nimport {\n Box,\n BoxProps,\n Combobox,\n Divider,\n factory,\n Factory,\n StylesApiProps,\n Text,\n TextInput,\n Title,\n useCombobox,\n useProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport {clsx} from 'clsx';\nimport {FunctionComponent, ReactElement, ReactNode, useEffect} from 'react';\nimport {groupOptions} from '../../utils/groupOptions.js';\nimport {ActionIcon} from '../ActionIcon/ActionIcon.js';\nimport {DefaultFacetItem} from './DefaultFacetItem.js';\nimport classes from './Facet.module.css';\nimport {FacetScrollArea} from './FacetScrollArea.js';\nimport {FacetData, FacetItem, FacetItemComponent} from './FacetTypes.js';\n\nexport type FacetStylesNames =\n | 'facet'\n | 'facetItem'\n | 'facetItems'\n | 'facetHeader'\n | 'searchInput'\n | 'hiddenSearch'\n | 'facetBody'\n | 'facetTitle'\n | 'facetSearch'\n | 'facetControl'\n | 'separator'\n | 'separatorLabel';\n\nexport interface FacetProps extends BoxProps, StylesApiProps<FacetFactory> {\n className?: string;\n /**\n * The data to render in the component\n */\n data: FacetData;\n /**\n * Function called when an item is selected or unselected\n *\n * @param values the selected items\n */\n onChange?: (values: string[]) => void;\n /**\n * Initial items selection\n *\n * @default []\n */\n initialSelection?: string[];\n /**\n * Determined items selection\n *\n * @default []\n */\n selection?: string[];\n /**\n * Custom item component\n *\n * @default a checkbox with the label of the item\n */\n itemComponent?: FacetItemComponent;\n /**\n * Function to format the facet item count\n *\n * @param count\n * @default (count) => count.toString()\n */\n itemCountFormatter?: (value: number) => string;\n /**\n * Search input placeholder\n */\n searchPlaceholder?: string;\n /**\n * Called when the search query changes\n *\n * @param value the search query\n */\n onSearch?: (value: string) => void;\n /**\n * Function to filter search results\n *\n * @param query value of the search input\n * @param item the current item\n *\n * @default function that compare the query with the label and value, case-insensitive\n */\n filter?: (query: string, item: FacetItem) => boolean;\n /**\n * Value of the search input\n */\n query?: string;\n /**\n * Nothing found message\n *\n * @default No matching items\n */\n nothingFound?: ReactNode;\n /**\n * Displayed when a list is empty and there is no search query\n *\n * @default No items\n */\n placeholder?: ReactNode;\n /**\n * Facet title\n */\n title?: ReactNode;\n /**\n * Maximum height, only used when there is more than 7 values\n *\n * @default 200\n */\n height?: number | 'auto';\n /**\n * Predefined border-radius value from theme.radius or number for border-radius in px\n *\n * @default md\n */\n radius?: number | string;\n /**\n * Change list component, can be used to add custom scrollbars\n */\n listComponent?: FunctionComponent<any>;\n /**\n * Limit amount of items showed at a time\n *\n * @default Infinity\n */\n limit?: number;\n /**\n * Control the displaying of the search input.\n *\n * @default data.length <= 7\n */\n hideSearch?: boolean;\n __staticSelector?: string;\n}\n\nexport type FacetFactory = Factory<{\n props: FacetProps;\n ref: HTMLDivElement;\n stylesNames: FacetStylesNames;\n}>;\n\nconst defaultProps: Partial<FacetProps> = {\n searchPlaceholder: 'Search',\n nothingFound: 'No matching items',\n placeholder: 'No items',\n height: 200,\n limit: Infinity,\n itemComponent: DefaultFacetItem,\n listComponent: FacetScrollArea,\n};\n\nexport const Facet: FunctionComponent<FacetProps> = factory<FacetFactory>((_props, ref) => {\n const props = useProps('Facet', defaultProps, _props);\n const {\n className,\n data,\n onChange,\n initialSelection = [],\n selection,\n itemComponent: ItemComponent,\n listComponent: ListComponent,\n itemCountFormatter,\n searchPlaceholder,\n query,\n hideSearch = data.length <= 7,\n onSearch,\n filter = defaultFilter,\n nothingFound,\n placeholder,\n title,\n height,\n radius,\n __staticSelector,\n classNames,\n styles,\n limit,\n unstyled,\n ...others\n } = props;\n const combobox = useCombobox();\n const [search, handleSearch] = useUncontrolled({\n value: query,\n defaultValue: '',\n finalValue: '',\n onChange: onSearch,\n });\n\n const [_selection, handleSelection] = useUncontrolled({\n value: selection,\n defaultValue: initialSelection,\n finalValue: [],\n onChange,\n });\n\n const unGroupedItems: ReactElement[] = [];\n const groupedItems: ReactElement[] = [];\n const filteredData = data.filter((item) => filter(search, item)).slice(0, limit);\n\n const sortedData: FacetData = groupOptions({data: filteredData});\n\n const handleValueSelect = (val: string) =>\n handleSelection(_selection.includes(val) ? _selection.filter((v) => v !== val) : [..._selection, val]);\n\n let groupName: string = null;\n\n useEffect(() => {\n combobox.openDropdown();\n }, []);\n\n sortedData.forEach((item) => {\n const isSelected = _selection.includes(item.value);\n const itemComponent = (\n <Combobox.Option\n aria-selected={isSelected ? true : false}\n value={item.value}\n key={item.value}\n onMouseEnter={() => combobox.resetSelectedOption()}\n className={clsx(classes.facetItem)}\n >\n <ItemComponent data={item} selected={isSelected} countFormatter={itemCountFormatter} />\n </Combobox.Option>\n );\n\n if (!item.group) {\n unGroupedItems.push(itemComponent);\n } else {\n if (groupName !== item.group) {\n groupName = item.group;\n groupedItems.push(\n <div className={classes.separator} key={groupName}>\n <Divider classNames={{label: classes.separatorLabel}} label={groupName} />\n </div>,\n );\n }\n groupedItems.push(itemComponent);\n }\n });\n\n if (groupedItems.length > 0 && unGroupedItems.length > 0) {\n unGroupedItems.unshift(\n <div className={classes.separator} key=\"ungrouped-separator\">\n <Divider unstyled={unstyled} classNames={{label: classes.separatorLabel}} />\n </div>,\n );\n }\n\n return (\n <Box className={clsx(classes.facet, className)} {...others} ref={ref}>\n <Combobox store={combobox} onOptionSubmit={handleValueSelect}>\n <Combobox.EventsTarget>\n <Box className={classes.facetHeader}>\n {title ? <Title order={5}>{title}</Title> : null}\n\n <TextInput\n unstyled={unstyled}\n value={search}\n onChange={(event) => {\n handleSearch(event.currentTarget.value);\n combobox.updateSelectedOptionIndex();\n }}\n placeholder={searchPlaceholder}\n aria-hidden={hideSearch}\n tabIndex={hideSearch ? -1 : undefined}\n className={clsx(classes.facetSearch, {[classes.hiddenSearch]: hideSearch})}\n rightSection={\n search ? (\n <ActionIcon.Quaternary\n aria-label=\"clear search\"\n color=\"gray\"\n onClick={() => {\n handleSearch('');\n }}\n >\n <CrossSize16Px height={16} />\n </ActionIcon.Quaternary>\n ) : (\n <FilterSize16Px height={16} />\n )\n }\n />\n </Box>\n </Combobox.EventsTarget>\n <div className={classes.facetBody}>\n <Combobox.EventsTarget>\n <ListComponent\n className={classes.facetItems}\n mah={height}\n style={{overflow: 'auto', position: 'relative'}}\n tabIndex={hideSearch ? 0 : undefined}\n >\n <Combobox.Options aria-multiselectable=\"true\">\n {groupedItems.length > 0 || unGroupedItems.length > 0 ? (\n <>\n {groupedItems}\n {unGroupedItems}\n </>\n ) : (\n <Combobox.Empty>\n <Text c=\"dimmed\" unstyled={unstyled} size=\"sm\" ta=\"center\" my=\"sm\">\n {!search && placeholder ? placeholder : nothingFound}\n </Text>\n </Combobox.Empty>\n )}\n </Combobox.Options>\n </ListComponent>\n </Combobox.EventsTarget>\n </div>\n </Combobox>\n </Box>\n );\n});\n\nFacet.displayName = 'Facet';\n\nconst defaultFilter = (query: string, item: FacetItem) =>\n item.label.toLowerCase().trim().includes(query.toLowerCase().trim()) ||\n item.value.toLowerCase().trim().includes(query.toLowerCase().trim());\n"],"names":["Facet","defaultProps","searchPlaceholder","nothingFound","placeholder","height","limit","Infinity","itemComponent","DefaultFacetItem","listComponent","FacetScrollArea","factory","_props","ref","props","useProps","className","data","onChange","initialSelection","selection","ItemComponent","ListComponent","itemCountFormatter","query","hideSearch","length","onSearch","filter","defaultFilter","title","radius","__staticSelector","classNames","styles","unstyled","others","combobox","useCombobox","useUncontrolled","value","defaultValue","finalValue","search","handleSearch","_selection","handleSelection","unGroupedItems","groupedItems","filteredData","item","slice","sortedData","groupOptions","handleValueSelect","val","includes","v","groupName","useEffect","openDropdown","forEach","isSelected","Combobox","Option","aria-selected","onMouseEnter","resetSelectedOption","clsx","classes","facetItem","selected","countFormatter","group","push","div","separator","Divider","label","separatorLabel","unshift","Box","facet","store","onOptionSubmit","EventsTarget","facetHeader","Title","order","TextInput","event","currentTarget","updateSelectedOptionIndex","aria-hidden","tabIndex","undefined","facetSearch","hiddenSearch","rightSection","ActionIcon","Quaternary","aria-label","color","onClick","CrossSize16Px","FilterSize16Px","facetBody","facetItems","mah","style","overflow","position","Options","aria-multiselectable","Empty","Text","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a;wCAACpG,QAAQ;;mDAG3B,qBAACqG,gCAAc;oCAACrG,QAAQ;;;;;;8BAM5C,qBAACuE;oBAAI3D,WAAWqD,uBAAO,CAACqC,SAAS;8BAC7B,cAAA,qBAAC3C,cAAQ,CAACsB,YAAY;kCAClB,cAAA,qBAAC/D;4BACGN,WAAWqD,uBAAO,CAACsC,UAAU;4BAC7BC,KAAKxG;4BACLyG,OAAO;gCAACC,UAAU;gCAAQC,UAAU;4BAAU;4BAC9CjB,UAAUrE,aAAa,IAAIsE;sCAE3B,cAAA,qBAAChC,cAAQ,CAACiD,OAAO;gCAACC,wBAAqB;0CAClCjE,aAAatB,MAAM,GAAG,KAAKqB,eAAerB,MAAM,GAAG,kBAChD;;wCACKsB;wCACAD;;mDAGL,qBAACgB,cAAQ,CAACmD,KAAK;8CACX,cAAA,qBAACC,UAAI;wCAACC,GAAE;wCAASjF,UAAUA;wCAAUkF,MAAK;wCAAKC,IAAG;wCAASC,IAAG;kDACzD,CAAC5E,UAAUxC,cAAcA,cAAcD;;;;;;;;;;AAWpF;AAEAH,MAAMyH,WAAW,GAAG;AAEpB,IAAM3F,gBAAgB,uBAACL,OAAe0B;WAClCA,KAAK4B,KAAK,CAAC2C,WAAW,GAAGC,IAAI,GAAGlE,QAAQ,CAAChC,MAAMiG,WAAW,GAAGC,IAAI,OACjExE,KAAKV,KAAK,CAACiF,WAAW,GAAGC,IAAI,GAAGlE,QAAQ,CAAChC,MAAMiG,WAAW,GAAGC,IAAI"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Facet/Facet.tsx"],"sourcesContent":["import {IconSearch} from '@coveord/plasma-react-icons';\nimport {\n Box,\n BoxProps,\n CloseButton,\n Combobox,\n Divider,\n factory,\n Factory,\n Group,\n StylesApiProps,\n Text,\n TextInput,\n Title,\n useCombobox,\n useProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport {clsx} from 'clsx';\nimport {FunctionComponent, ReactElement, ReactNode, useEffect} from 'react';\nimport {groupOptions} from '../../utils/groupOptions.js';\nimport {DefaultFacetItem} from './DefaultFacetItem.js';\nimport classes from './Facet.module.css';\nimport {FacetScrollArea} from './FacetScrollArea.js';\nimport {FacetData, FacetItem, FacetItemComponent} from './FacetTypes.js';\n\nexport type FacetStylesNames =\n | 'facet'\n | 'facetItem'\n | 'facetItems'\n | 'facetHeader'\n | 'searchInput'\n | 'hiddenSearch'\n | 'facetBody'\n | 'facetTitleRow'\n | 'facetTitle'\n | 'facetRemoveButton'\n | 'facetSearch'\n | 'facetControl'\n | 'separator'\n | 'separatorLabel';\n\nexport interface FacetProps extends BoxProps, StylesApiProps<FacetFactory> {\n className?: string;\n /**\n * The data to render in the component\n */\n data: FacetData;\n /**\n * Function called when an item is selected or unselected\n *\n * @param values the selected items\n */\n onChange?: (values: string[]) => void;\n /**\n * Function called when the remove icon is clicked.\n */\n onRemove?: () => void;\n /**\n * Initial items selection\n *\n * @default []\n */\n initialSelection?: string[];\n /**\n * Determines if the facet is removable\n *\n * @default false\n */\n removable?: boolean;\n /**\n * Determined items selection\n *\n * @default []\n */\n selection?: string[];\n /**\n * Custom item component\n *\n * @default a checkbox with the label of the item\n */\n itemComponent?: FacetItemComponent;\n /**\n * Function to format the facet item count\n *\n * @param count\n * @default (count) => count.toString()\n */\n itemCountFormatter?: (value: number) => string;\n /**\n * Search input placeholder\n */\n searchPlaceholder?: string;\n /**\n * Called when the search query changes\n *\n * @param value the search query\n */\n onSearch?: (value: string) => void;\n /**\n * Function to filter search results\n *\n * @param query value of the search input\n * @param item the current item\n *\n * @default function that compare the query with the label and value, case-insensitive\n */\n filter?: (query: string, item: FacetItem) => boolean;\n /**\n * Value of the search input\n */\n query?: string;\n /**\n * Nothing found message\n *\n * @default No matching items\n */\n nothingFound?: ReactNode;\n /**\n * Displayed when a list is empty and there is no search query\n *\n * @default No items\n */\n placeholder?: ReactNode;\n /**\n * Facet title\n */\n title?: ReactNode;\n /**\n * Maximum height, only used when there is more than 7 values\n *\n * @default 200\n */\n height?: number | 'auto';\n /**\n * Predefined border-radius value from theme.radius or number for border-radius in px\n *\n * @default md\n */\n radius?: number | string;\n /**\n * Change list component, can be used to add custom scrollbars\n */\n listComponent?: FunctionComponent<any>;\n /**\n * Limit amount of items showed at a time\n *\n * @default Infinity\n */\n limit?: number;\n /**\n * Control the displaying of the search input.\n *\n * @default data.length <= 7\n */\n hideSearch?: boolean;\n __staticSelector?: string;\n}\n\nexport type FacetFactory = Factory<{\n props: FacetProps;\n ref: HTMLDivElement;\n stylesNames: FacetStylesNames;\n}>;\n\nconst defaultProps: Partial<FacetProps> = {\n searchPlaceholder: 'Search',\n nothingFound: 'No matching items',\n placeholder: 'No items',\n height: 200,\n limit: Infinity,\n itemComponent: DefaultFacetItem,\n listComponent: FacetScrollArea,\n removable: false,\n};\n\nexport const Facet: FunctionComponent<FacetProps> = factory<FacetFactory>((_props, ref) => {\n const props = useProps('Facet', defaultProps, _props);\n const {\n className,\n data,\n onChange,\n onRemove,\n initialSelection = [],\n removable,\n selection,\n itemComponent: ItemComponent,\n listComponent: ListComponent,\n itemCountFormatter,\n searchPlaceholder,\n query,\n hideSearch = data.length <= 7,\n onSearch,\n filter = defaultFilter,\n nothingFound,\n placeholder,\n title,\n height,\n radius,\n __staticSelector,\n classNames,\n styles,\n limit,\n unstyled,\n ...others\n } = props;\n const combobox = useCombobox();\n const [search, handleSearch] = useUncontrolled({\n value: query,\n defaultValue: '',\n finalValue: '',\n onChange: onSearch,\n });\n\n const [_selection, handleSelection] = useUncontrolled({\n value: selection,\n defaultValue: initialSelection,\n finalValue: [],\n onChange,\n });\n\n const unGroupedItems: ReactElement[] = [];\n const groupedItems: ReactElement[] = [];\n const filteredData = data.filter((item) => filter(search, item)).slice(0, limit);\n\n const sortedData: FacetData = groupOptions({data: filteredData});\n\n const handleValueSelect = (val: string) =>\n handleSelection(_selection.includes(val) ? _selection.filter((v) => v !== val) : [..._selection, val]);\n\n let groupName: string = null;\n\n useEffect(() => {\n combobox.openDropdown();\n }, []);\n\n sortedData.forEach((item) => {\n const isSelected = _selection.includes(item.value);\n const itemComponent = (\n <Combobox.Option\n aria-selected={isSelected ? true : false}\n value={item.value}\n key={item.value}\n onMouseEnter={() => combobox.resetSelectedOption()}\n className={clsx(classes.facetItem)}\n >\n <ItemComponent data={item} selected={isSelected} countFormatter={itemCountFormatter} />\n </Combobox.Option>\n );\n\n if (!item.group) {\n unGroupedItems.push(itemComponent);\n } else {\n if (groupName !== item.group) {\n groupName = item.group;\n groupedItems.push(\n <div className={classes.separator} key={groupName}>\n <Divider classNames={{label: classes.separatorLabel}} label={groupName} />\n </div>,\n );\n }\n groupedItems.push(itemComponent);\n }\n });\n\n if (groupedItems.length > 0 && unGroupedItems.length > 0) {\n unGroupedItems.unshift(\n <div className={classes.separator} key=\"ungrouped-separator\">\n <Divider unstyled={unstyled} classNames={{label: classes.separatorLabel}} />\n </div>,\n );\n }\n\n return (\n <Box className={clsx(classes.facet, className)} {...others} ref={ref}>\n <Combobox store={combobox} onOptionSubmit={handleValueSelect}>\n <Combobox.EventsTarget>\n <Box className={classes.facetHeader}>\n <Group wrap=\"nowrap\" justify=\"space-between\" className={classes.facetTitleRow}>\n {title ? (\n <Title order={5} className={classes.facetTitle}>\n {title}\n </Title>\n ) : null}\n {removable ? (\n <CloseButton\n onClick={onRemove}\n className={classes.facetRemoveButton}\n aria-label=\"remove facet\"\n />\n ) : null}\n </Group>\n\n <TextInput\n unstyled={unstyled}\n value={search}\n onChange={(event) => {\n handleSearch(event.currentTarget.value);\n combobox.updateSelectedOptionIndex();\n }}\n placeholder={searchPlaceholder}\n aria-hidden={hideSearch}\n tabIndex={hideSearch ? -1 : undefined}\n className={clsx(classes.facetSearch, {[classes.hiddenSearch]: hideSearch})}\n rightSection={\n search ? (\n <CloseButton\n aria-label=\"clear search\"\n onClick={() => {\n handleSearch('');\n }}\n />\n ) : (\n <IconSearch height={16} />\n )\n }\n />\n </Box>\n </Combobox.EventsTarget>\n <div className={classes.facetBody}>\n <Combobox.EventsTarget>\n <ListComponent\n className={classes.facetItems}\n mah={height}\n style={{overflow: 'auto', position: 'relative'}}\n tabIndex={hideSearch ? 0 : undefined}\n >\n <Combobox.Options aria-multiselectable=\"true\">\n {groupedItems.length > 0 || unGroupedItems.length > 0 ? (\n <>\n {groupedItems}\n {unGroupedItems}\n </>\n ) : (\n <Combobox.Empty>\n <Text c=\"dimmed\" unstyled={unstyled} size=\"sm\" ta=\"center\" my=\"sm\">\n {!search && placeholder ? placeholder : nothingFound}\n </Text>\n </Combobox.Empty>\n )}\n </Combobox.Options>\n </ListComponent>\n </Combobox.EventsTarget>\n </div>\n </Combobox>\n </Box>\n );\n});\n\nFacet.displayName = 'Facet';\n\nconst defaultFilter = (query: string, item: FacetItem) =>\n item.label.toLowerCase().trim().includes(query.toLowerCase().trim()) ||\n item.value.toLowerCase().trim().includes(query.toLowerCase().trim());\n"],"names":["Facet","defaultProps","searchPlaceholder","nothingFound","placeholder","height","limit","Infinity","itemComponent","DefaultFacetItem","listComponent","FacetScrollArea","removable","factory","_props","ref","props","useProps","className","data","onChange","onRemove","initialSelection","selection","ItemComponent","ListComponent","itemCountFormatter","query","hideSearch","length","onSearch","filter","defaultFilter","title","radius","__staticSelector","classNames","styles","unstyled","others","combobox","useCombobox","useUncontrolled","value","defaultValue","finalValue","search","handleSearch","_selection","handleSelection","unGroupedItems","groupedItems","filteredData","item","slice","sortedData","groupOptions","handleValueSelect","val","includes","v","groupName","useEffect","openDropdown","forEach","isSelected","Combobox","Option","aria-selected","onMouseEnter","resetSelectedOption","clsx","classes","facetItem","selected","countFormatter","group","push","div","separator","Divider","label","separatorLabel","unshift","Box","facet","store","onOptionSubmit","EventsTarget","facetHeader","Group","wrap","justify","facetTitleRow","Title","order","facetTitle","CloseButton","onClick","facetRemoveButton","aria-label","TextInput","event","currentTarget","updateSelectedOptionIndex","aria-hidden","tabIndex","undefined","facetSearch","hiddenSearch","rightSection","IconSearch","facetBody","facetItems","mah","style","overflow","position","Options","aria-multiselectable","Empty","Text","c","size","ta","my","displayName","toLowerCase","trim"],"mappings":";;;;+BAgLaA;;;eAAAA;;;;;;;;;;;gCAhLY;oBAgBlB;qBACuB;oBACX;qBACiD;4BACzC;gCACI;uEACX;+BACU;AA8I9B,IAAMC,eAAoC;IACtCC,mBAAmB;IACnBC,cAAc;IACdC,aAAa;IACbC,QAAQ;IACRC,OAAOC;IACPC,eAAeC,kCAAgB;IAC/BC,eAAeC,gCAAe;IAC9BC,WAAW;AACf;AAEO,IAAMZ,QAAuCa,IAAAA,aAAO,EAAe,SAACC,QAAQC;IAC/E,IAAMC,QAAQC,IAAAA,cAAQ,EAAC,SAAShB,cAAca;IAC9C,IACII,YA0BAF,MA1BAE,WACAC,OAyBAH,MAzBAG,MACAC,WAwBAJ,MAxBAI,UACAC,WAuBAL,MAvBAK,oCAuBAL,MAtBAM,kBAAAA,wDAAmB,EAAE,4BACrBV,YAqBAI,MArBAJ,WACAW,YAoBAP,MApBAO,WACAf,AAAegB,gBAmBfR,MAnBAR,eACAE,AAAee,gBAkBfT,MAlBAN,eACAgB,qBAiBAV,MAjBAU,oBACAxB,oBAgBAc,MAhBAd,mBACAyB,QAeAX,MAfAW,2BAeAX,MAdAY,YAAAA,4CAAaT,KAAKU,MAAM,IAAI,uBAC5BC,WAaAd,MAbAc,0BAaAd,MAZAe,QAAAA,oCAASC,+BACT7B,eAWAa,MAXAb,cACAC,cAUAY,MAVAZ,aACA6B,QASAjB,MATAiB,OACA5B,SAQAW,MARAX,QACA6B,SAOAlB,MAPAkB,QACAC,mBAMAnB,MANAmB,kBACAC,aAKApB,MALAoB,YACAC,SAIArB,MAJAqB,QACA/B,QAGAU,MAHAV,OACAgC,WAEAtB,MAFAsB,UACGC,sCACHvB;;;;;;;;;;;;;;;;;;;;;;;;;;;IACJ,IAAMwB,WAAWC,IAAAA,iBAAW;IAC5B,IAA+BC,sCAAAA,IAAAA,sBAAe,EAAC;QAC3CC,OAAOhB;QACPiB,cAAc;QACdC,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|
|
59
|
+
.facetTitleRow {
|
|
60
|
+
width: 100%;
|
|
61
|
+
min-width: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
.facetTitle {
|
|
65
|
+
flex: 1;
|
|
66
|
+
min-width: 0;
|
|
60
67
|
margin-bottom: 0;
|
|
68
|
+
overflow-wrap: anywhere;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.facetRemoveButton {
|
|
72
|
+
flex-shrink: 0;
|
|
73
|
+
margin-left: auto;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
.facetSearch {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BoxProps, Factory, StylesApiProps } from '@mantine/core';
|
|
2
2
|
import { FunctionComponent, ReactNode } from 'react';
|
|
3
3
|
import { FacetData, FacetItem, FacetItemComponent } from './FacetTypes.js';
|
|
4
|
-
export type FacetStylesNames = 'facet' | 'facetItem' | 'facetItems' | 'facetHeader' | 'searchInput' | 'hiddenSearch' | 'facetBody' | 'facetTitle' | 'facetSearch' | 'facetControl' | 'separator' | 'separatorLabel';
|
|
4
|
+
export type FacetStylesNames = 'facet' | 'facetItem' | 'facetItems' | 'facetHeader' | 'searchInput' | 'hiddenSearch' | 'facetBody' | 'facetTitleRow' | 'facetTitle' | 'facetRemoveButton' | 'facetSearch' | 'facetControl' | 'separator' | 'separatorLabel';
|
|
5
5
|
export interface FacetProps extends BoxProps, StylesApiProps<FacetFactory> {
|
|
6
6
|
className?: string;
|
|
7
7
|
/**
|
|
@@ -14,12 +14,22 @@ export interface FacetProps extends BoxProps, StylesApiProps<FacetFactory> {
|
|
|
14
14
|
* @param values the selected items
|
|
15
15
|
*/
|
|
16
16
|
onChange?: (values: string[]) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Function called when the remove icon is clicked.
|
|
19
|
+
*/
|
|
20
|
+
onRemove?: () => void;
|
|
17
21
|
/**
|
|
18
22
|
* Initial items selection
|
|
19
23
|
*
|
|
20
24
|
* @default []
|
|
21
25
|
*/
|
|
22
26
|
initialSelection?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Determines if the facet is removable
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
removable?: boolean;
|
|
23
33
|
/**
|
|
24
34
|
* Determined items selection
|
|
25
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Facet.d.ts","sourceRoot":"","sources":["../../../../src/components/Facet/Facet.tsx"],"names":[],"mappings":"AACA,OAAO,EAEH,QAAQ,
|
|
1
|
+
{"version":3,"file":"Facet.d.ts","sourceRoot":"","sources":["../../../../src/components/Facet/Facet.tsx"],"names":[],"mappings":"AACA,OAAO,EAEH,QAAQ,EAKR,OAAO,EAEP,cAAc,EAMjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,iBAAiB,EAAgB,SAAS,EAAY,MAAM,OAAO,CAAC;AAK5E,OAAO,EAAC,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAEzE,MAAM,MAAM,gBAAgB,GACtB,OAAO,GACP,WAAW,GACX,YAAY,GACZ,aAAa,GACb,aAAa,GACb,cAAc,GACd,WAAW,GACX,eAAe,GACf,YAAY,GACZ,mBAAmB,GACnB,aAAa,GACb,cAAc,GACd,WAAW,GACX,gBAAgB,CAAC;AAEvB,MAAM,WAAW,UAAW,SAAQ,QAAQ,EAAE,cAAc,CAAC,YAAY,CAAC;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;IAChB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CA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|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { Box, Combobox, Divider, factory, Text, TextInput, Title, useCombobox, useProps } from '@mantine/core';
|
|
2
|
+
import { IconSearch } from '@coveord/plasma-react-icons';
|
|
3
|
+
import { Box, CloseButton, Combobox, Divider, factory, Group, Text, TextInput, Title, useCombobox, useProps } from '@mantine/core';
|
|
4
4
|
import { useUncontrolled } from '@mantine/hooks';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { useEffect } from 'react';
|
|
7
7
|
import { groupOptions } from '../../utils/groupOptions.js';
|
|
8
|
-
import { ActionIcon } from '../ActionIcon/ActionIcon.js';
|
|
9
8
|
import { DefaultFacetItem } from './DefaultFacetItem.js';
|
|
10
9
|
import classes from './Facet.module.css';
|
|
11
10
|
import { FacetScrollArea } from './FacetScrollArea.js';
|
|
@@ -16,11 +15,12 @@ const defaultProps = {
|
|
|
16
15
|
height: 200,
|
|
17
16
|
limit: Infinity,
|
|
18
17
|
itemComponent: DefaultFacetItem,
|
|
19
|
-
listComponent: FacetScrollArea
|
|
18
|
+
listComponent: FacetScrollArea,
|
|
19
|
+
removable: false
|
|
20
20
|
};
|
|
21
21
|
export const Facet = factory((_props, ref)=>{
|
|
22
22
|
const props = useProps('Facet', defaultProps, _props);
|
|
23
|
-
const { className, data, onChange, initialSelection = [], selection, itemComponent: ItemComponent, listComponent: ListComponent, itemCountFormatter, searchPlaceholder, query, hideSearch = data.length <= 7, onSearch, filter = defaultFilter, nothingFound, placeholder, title, height, radius, __staticSelector, classNames, styles, limit, unstyled, ...others } = props;
|
|
23
|
+
const { className, data, onChange, onRemove, initialSelection = [], removable, selection, itemComponent: ItemComponent, listComponent: ListComponent, itemCountFormatter, searchPlaceholder, query, hideSearch = data.length <= 7, onSearch, filter = defaultFilter, nothingFound, placeholder, title, height, radius, __staticSelector, classNames, styles, limit, unstyled, ...others } = props;
|
|
24
24
|
const combobox = useCombobox();
|
|
25
25
|
const [search, handleSearch] = useUncontrolled({
|
|
26
26
|
value: query,
|
|
@@ -102,10 +102,23 @@ export const Facet = factory((_props, ref)=>{
|
|
|
102
102
|
children: /*#__PURE__*/ _jsxs(Box, {
|
|
103
103
|
className: classes.facetHeader,
|
|
104
104
|
children: [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
/*#__PURE__*/ _jsxs(Group, {
|
|
106
|
+
wrap: "nowrap",
|
|
107
|
+
justify: "space-between",
|
|
108
|
+
className: classes.facetTitleRow,
|
|
109
|
+
children: [
|
|
110
|
+
title ? /*#__PURE__*/ _jsx(Title, {
|
|
111
|
+
order: 5,
|
|
112
|
+
className: classes.facetTitle,
|
|
113
|
+
children: title
|
|
114
|
+
}) : null,
|
|
115
|
+
removable ? /*#__PURE__*/ _jsx(CloseButton, {
|
|
116
|
+
onClick: onRemove,
|
|
117
|
+
className: classes.facetRemoveButton,
|
|
118
|
+
"aria-label": "remove facet"
|
|
119
|
+
}) : null
|
|
120
|
+
]
|
|
121
|
+
}),
|
|
109
122
|
/*#__PURE__*/ _jsx(TextInput, {
|
|
110
123
|
unstyled: unstyled,
|
|
111
124
|
value: search,
|
|
@@ -119,16 +132,12 @@ export const Facet = factory((_props, ref)=>{
|
|
|
119
132
|
className: clsx(classes.facetSearch, {
|
|
120
133
|
[classes.hiddenSearch]: hideSearch
|
|
121
134
|
}),
|
|
122
|
-
rightSection: search ? /*#__PURE__*/ _jsx(
|
|
135
|
+
rightSection: search ? /*#__PURE__*/ _jsx(CloseButton, {
|
|
123
136
|
"aria-label": "clear search",
|
|
124
|
-
color: "gray",
|
|
125
137
|
onClick: ()=>{
|
|
126
138
|
handleSearch('');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
height: 16
|
|
130
|
-
})
|
|
131
|
-
}) : /*#__PURE__*/ _jsx(FilterSize16Px, {
|
|
139
|
+
}
|
|
140
|
+
}) : /*#__PURE__*/ _jsx(IconSearch, {
|
|
132
141
|
height: 16
|
|
133
142
|
})
|
|
134
143
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Facet/Facet.tsx"],"sourcesContent":["import {CrossSize16Px, FilterSize16Px} from '@coveord/plasma-react-icons';\nimport {\n Box,\n BoxProps,\n Combobox,\n Divider,\n factory,\n Factory,\n StylesApiProps,\n Text,\n TextInput,\n Title,\n useCombobox,\n useProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport {clsx} from 'clsx';\nimport {FunctionComponent, ReactElement, ReactNode, useEffect} from 'react';\nimport {groupOptions} from '../../utils/groupOptions.js';\nimport {ActionIcon} from '../ActionIcon/ActionIcon.js';\nimport {DefaultFacetItem} from './DefaultFacetItem.js';\nimport classes from './Facet.module.css';\nimport {FacetScrollArea} from './FacetScrollArea.js';\nimport {FacetData, FacetItem, FacetItemComponent} from './FacetTypes.js';\n\nexport type FacetStylesNames =\n | 'facet'\n | 'facetItem'\n | 'facetItems'\n | 'facetHeader'\n | 'searchInput'\n | 'hiddenSearch'\n | 'facetBody'\n | 'facetTitle'\n | 'facetSearch'\n | 'facetControl'\n | 'separator'\n | 'separatorLabel';\n\nexport interface FacetProps extends BoxProps, StylesApiProps<FacetFactory> {\n className?: string;\n /**\n * The data to render in the component\n */\n data: FacetData;\n /**\n * Function called when an item is selected or unselected\n *\n * @param values the selected items\n */\n onChange?: (values: string[]) => void;\n /**\n * Initial items selection\n *\n * @default []\n */\n initialSelection?: string[];\n /**\n * Determined items selection\n *\n * @default []\n */\n selection?: string[];\n /**\n * Custom item component\n *\n * @default a checkbox with the label of the item\n */\n itemComponent?: FacetItemComponent;\n /**\n * Function to format the facet item count\n *\n * @param count\n * @default (count) => count.toString()\n */\n itemCountFormatter?: (value: number) => string;\n /**\n * Search input placeholder\n */\n searchPlaceholder?: string;\n /**\n * Called when the search query changes\n *\n * @param value the search query\n */\n onSearch?: (value: string) => void;\n /**\n * Function to filter search results\n *\n * @param query value of the search input\n * @param item the current item\n *\n * @default function that compare the query with the label and value, case-insensitive\n */\n filter?: (query: string, item: FacetItem) => boolean;\n /**\n * Value of the search input\n */\n query?: string;\n /**\n * Nothing found message\n *\n * @default No matching items\n */\n nothingFound?: ReactNode;\n /**\n * Displayed when a list is empty and there is no search query\n *\n * @default No items\n */\n placeholder?: ReactNode;\n /**\n * Facet title\n */\n title?: ReactNode;\n /**\n * Maximum height, only used when there is more than 7 values\n *\n * @default 200\n */\n height?: number | 'auto';\n /**\n * Predefined border-radius value from theme.radius or number for border-radius in px\n *\n * @default md\n */\n radius?: number | string;\n /**\n * Change list component, can be used to add custom scrollbars\n */\n listComponent?: FunctionComponent<any>;\n /**\n * Limit amount of items showed at a time\n *\n * @default Infinity\n */\n limit?: number;\n /**\n * Control the displaying of the search input.\n *\n * @default data.length <= 7\n */\n hideSearch?: boolean;\n __staticSelector?: string;\n}\n\nexport type FacetFactory = Factory<{\n props: FacetProps;\n ref: HTMLDivElement;\n stylesNames: FacetStylesNames;\n}>;\n\nconst defaultProps: Partial<FacetProps> = {\n searchPlaceholder: 'Search',\n nothingFound: 'No matching items',\n placeholder: 'No items',\n height: 200,\n limit: Infinity,\n itemComponent: DefaultFacetItem,\n listComponent: FacetScrollArea,\n};\n\nexport const Facet: FunctionComponent<FacetProps> = factory<FacetFactory>((_props, ref) => {\n const props = useProps('Facet', defaultProps, _props);\n const {\n className,\n data,\n onChange,\n initialSelection = [],\n selection,\n itemComponent: ItemComponent,\n listComponent: ListComponent,\n itemCountFormatter,\n searchPlaceholder,\n query,\n hideSearch = data.length <= 7,\n onSearch,\n filter = defaultFilter,\n nothingFound,\n placeholder,\n title,\n height,\n radius,\n __staticSelector,\n classNames,\n styles,\n limit,\n unstyled,\n ...others\n } = props;\n const combobox = useCombobox();\n const [search, handleSearch] = useUncontrolled({\n value: query,\n defaultValue: '',\n finalValue: '',\n onChange: onSearch,\n });\n\n const [_selection, handleSelection] = useUncontrolled({\n value: selection,\n defaultValue: initialSelection,\n finalValue: [],\n onChange,\n });\n\n const unGroupedItems: ReactElement[] = [];\n const groupedItems: ReactElement[] = [];\n const filteredData = data.filter((item) => filter(search, item)).slice(0, limit);\n\n const sortedData: FacetData = groupOptions({data: filteredData});\n\n const handleValueSelect = (val: string) =>\n handleSelection(_selection.includes(val) ? _selection.filter((v) => v !== val) : [..._selection, val]);\n\n let groupName: string = null;\n\n useEffect(() => {\n combobox.openDropdown();\n }, []);\n\n sortedData.forEach((item) => {\n const isSelected = _selection.includes(item.value);\n const itemComponent = (\n <Combobox.Option\n aria-selected={isSelected ? true : false}\n value={item.value}\n key={item.value}\n onMouseEnter={() => combobox.resetSelectedOption()}\n className={clsx(classes.facetItem)}\n >\n <ItemComponent data={item} selected={isSelected} countFormatter={itemCountFormatter} />\n </Combobox.Option>\n );\n\n if (!item.group) {\n unGroupedItems.push(itemComponent);\n } else {\n if (groupName !== item.group) {\n groupName = item.group;\n groupedItems.push(\n <div className={classes.separator} key={groupName}>\n <Divider classNames={{label: classes.separatorLabel}} label={groupName} />\n </div>,\n );\n }\n groupedItems.push(itemComponent);\n }\n });\n\n if (groupedItems.length > 0 && unGroupedItems.length > 0) {\n unGroupedItems.unshift(\n <div className={classes.separator} key=\"ungrouped-separator\">\n <Divider unstyled={unstyled} classNames={{label: classes.separatorLabel}} />\n </div>,\n );\n }\n\n return (\n <Box className={clsx(classes.facet, className)} {...others} ref={ref}>\n <Combobox store={combobox} onOptionSubmit={handleValueSelect}>\n <Combobox.EventsTarget>\n <Box className={classes.facetHeader}>\n {title ? <Title order={5}>{title}</Title> : null}\n\n <TextInput\n unstyled={unstyled}\n value={search}\n onChange={(event) => {\n handleSearch(event.currentTarget.value);\n combobox.updateSelectedOptionIndex();\n }}\n placeholder={searchPlaceholder}\n aria-hidden={hideSearch}\n tabIndex={hideSearch ? -1 : undefined}\n className={clsx(classes.facetSearch, {[classes.hiddenSearch]: hideSearch})}\n rightSection={\n search ? (\n <ActionIcon.Quaternary\n aria-label=\"clear search\"\n color=\"gray\"\n onClick={() => {\n handleSearch('');\n }}\n >\n <CrossSize16Px height={16} />\n </ActionIcon.Quaternary>\n ) : (\n <FilterSize16Px height={16} />\n )\n }\n />\n </Box>\n </Combobox.EventsTarget>\n <div className={classes.facetBody}>\n <Combobox.EventsTarget>\n <ListComponent\n className={classes.facetItems}\n mah={height}\n style={{overflow: 'auto', position: 'relative'}}\n tabIndex={hideSearch ? 0 : undefined}\n >\n <Combobox.Options aria-multiselectable=\"true\">\n {groupedItems.length > 0 || unGroupedItems.length > 0 ? (\n <>\n {groupedItems}\n {unGroupedItems}\n </>\n ) : (\n <Combobox.Empty>\n <Text c=\"dimmed\" unstyled={unstyled} size=\"sm\" ta=\"center\" my=\"sm\">\n {!search && placeholder ? placeholder : nothingFound}\n </Text>\n </Combobox.Empty>\n )}\n </Combobox.Options>\n </ListComponent>\n </Combobox.EventsTarget>\n </div>\n </Combobox>\n </Box>\n );\n});\n\nFacet.displayName = 'Facet';\n\nconst defaultFilter = (query: string, item: FacetItem) =>\n item.label.toLowerCase().trim().includes(query.toLowerCase().trim()) ||\n item.value.toLowerCase().trim().includes(query.toLowerCase().trim());\n"],"names":["CrossSize16Px","FilterSize16Px","Box","Combobox","Divider","factory","Text","TextInput","Title","useCombobox","useProps","useUncontrolled","clsx","useEffect","groupOptions","ActionIcon","DefaultFacetItem","classes","FacetScrollArea","defaultProps","searchPlaceholder","nothingFound","placeholder","height","limit","Infinity","itemComponent","listComponent","Facet","_props","ref","props","className","data","onChange","initialSelection","selection","ItemComponent","ListComponent","itemCountFormatter","query","hideSearch","length","onSearch","filter","defaultFilter","title","radius","__staticSelector","classNames","styles","unstyled","others","combobox","search","handleSearch","value","defaultValue","finalValue","_selection","handleSelection","unGroupedItems","groupedItems","filteredData","item","slice","sortedData","handleValueSelect","val","includes","v","groupName","openDropdown","forEach","isSelected","Option","aria-selected","onMouseEnter","resetSelectedOption","facetItem","selected","countFormatter","group","push","div","separator","label","separatorLabel","unshift","facet","store","onOptionSubmit","EventsTarget","facetHeader","order","event","currentTarget","updateSelectedOptionIndex","aria-hidden","tabIndex","undefined","facetSearch","hiddenSearch","rightSection","Quaternary","aria-label","color","onClick","facetBody","facetItems","mah","style","overflow","position","Options","aria-multiselectable","Empty","c","size","ta","my","displayName","toLowerCase","trim"],"mappings":";AAAA,SAAQA,aAAa,EAAEC,cAAc,QAAO,8BAA8B;AAC1E,SACIC,GAAG,EAEHC,QAAQ,EACRC,OAAO,EACPC,OAAO,EAGPC,IAAI,EACJC,SAAS,EACTC,KAAK,EACLC,WAAW,EACXC,QAAQ,QACL,gBAAgB;AACvB,SAAQC,eAAe,QAAO,iBAAiB;AAC/C,SAAQC,IAAI,QAAO,OAAO;AAC1B,SAAoDC,SAAS,QAAO,QAAQ;AAC5E,SAAQC,YAAY,QAAO,8BAA8B;AACzD,SAAQC,UAAU,QAAO,8BAA8B;AACvD,SAAQC,gBAAgB,QAAO,wBAAwB;AACvD,OAAOC,aAAa,qBAAqB;AACzC,SAAQC,eAAe,QAAO,uBAAuB;AAkIrD,MAAMC,eAAoC;IACtCC,mBAAmB;IACnBC,cAAc;IACdC,aAAa;IACbC,QAAQ;IACRC,OAAOC;IACPC,eAAeV;IACfW,eAAeT;AACnB;AAEA,OAAO,MAAMU,QAAuCvB,QAAsB,CAACwB,QAAQC;IAC/E,MAAMC,QAAQrB,SAAS,SAASS,cAAcU;IAC9C,MAAM,EACFG,SAAS,EACTC,IAAI,EACJC,QAAQ,EACRC,mBAAmB,EAAE,EACrBC,SAAS,EACTV,eAAeW,aAAa,EAC5BV,eAAeW,aAAa,EAC5BC,kBAAkB,EAClBnB,iBAAiB,EACjBoB,KAAK,EACLC,aAAaR,KAAKS,MAAM,IAAI,CAAC,EAC7BC,QAAQ,EACRC,SAASC,aAAa,EACtBxB,YAAY,EACZC,WAAW,EACXwB,KAAK,EACLvB,MAAM,EACNwB,MAAM,EACNC,gBAAgB,EAChBC,UAAU,EACVC,MAAM,EACN1B,K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CAAesB,QAAQ;;;;;;8BAM5C,KAAC6D;oBAAIpD,WAAWf,QAAQ2F,SAAS;8BAC7B,cAAA,KAACzG,SAASyF,YAAY;kCAClB,cAAA,KAACtD;4BACGN,WAAWf,QAAQ4F,UAAU;4BAC7BC,KAAKvF;4BACLwF,OAAO;gCAACC,UAAU;gCAAQC,UAAU;4BAAU;4BAC9Cd,UAAU1D,aAAa,IAAI2D;sCAE3B,cAAA,KAACjG,SAAS+G,OAAO;gCAACC,wBAAqB;0CAClCrD,aAAapB,MAAM,GAAG,KAAKmB,eAAenB,MAAM,GAAG,kBAChD;;wCACKoB;wCACAD;;mDAGL,KAAC1D,SAASiH,KAAK;8CACX,cAAA,KAAC9G;wCAAK+G,GAAE;wCAASlE,UAAUA;wCAAUmE,MAAK;wCAAKC,IAAG;wCAASC,IAAG;kDACzD,CAAClE,UAAUhC,cAAcA,cAAcD;;;;;;;;;;AAWpF,GAAG;AAEHO,MAAM6F,WAAW,GAAG;AAEpB,MAAM5E,gBAAgB,CAACL,OAAewB,OAClCA,KAAKsB,KAAK,CAACoC,WAAW,GAAGC,IAAI,GAAGtD,QAAQ,CAAC7B,MAAMkF,WAAW,GAAGC,IAAI,OACjE3D,KAAKR,KAAK,CAACkE,WAAW,GAAGC,IAAI,GAAGtD,QAAQ,CAAC7B,MAAMkF,WAAW,GAAGC,IAAI"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Facet/Facet.tsx"],"sourcesContent":["import {IconSearch} from '@coveord/plasma-react-icons';\nimport {\n Box,\n BoxProps,\n CloseButton,\n Combobox,\n Divider,\n factory,\n Factory,\n Group,\n StylesApiProps,\n Text,\n TextInput,\n Title,\n useCombobox,\n useProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport {clsx} from 'clsx';\nimport {FunctionComponent, ReactElement, ReactNode, useEffect} from 'react';\nimport {groupOptions} from '../../utils/groupOptions.js';\nimport {DefaultFacetItem} from './DefaultFacetItem.js';\nimport classes from './Facet.module.css';\nimport {FacetScrollArea} from './FacetScrollArea.js';\nimport {FacetData, FacetItem, FacetItemComponent} from './FacetTypes.js';\n\nexport type FacetStylesNames =\n | 'facet'\n | 'facetItem'\n | 'facetItems'\n | 'facetHeader'\n | 'searchInput'\n | 'hiddenSearch'\n | 'facetBody'\n | 'facetTitleRow'\n | 'facetTitle'\n | 'facetRemoveButton'\n | 'facetSearch'\n | 'facetControl'\n | 'separator'\n | 'separatorLabel';\n\nexport interface FacetProps extends BoxProps, StylesApiProps<FacetFactory> {\n className?: string;\n /**\n * The data to render in the component\n */\n data: FacetData;\n /**\n * Function called when an item is selected or unselected\n *\n * @param values the selected items\n */\n onChange?: (values: string[]) => void;\n /**\n * Function called when the remove icon is clicked.\n */\n onRemove?: () => void;\n /**\n * Initial items selection\n *\n * @default []\n */\n initialSelection?: string[];\n /**\n * Determines if the facet is removable\n *\n * @default false\n */\n removable?: boolean;\n /**\n * Determined items selection\n *\n * @default []\n */\n selection?: string[];\n /**\n * Custom item component\n *\n * @default a checkbox with the label of the item\n */\n itemComponent?: FacetItemComponent;\n /**\n * Function to format the facet item count\n *\n * @param count\n * @default (count) => count.toString()\n */\n itemCountFormatter?: (value: number) => string;\n /**\n * Search input placeholder\n */\n searchPlaceholder?: string;\n /**\n * Called when the search query changes\n *\n * @param value the search query\n */\n onSearch?: (value: string) => void;\n /**\n * Function to filter search results\n *\n * @param query value of the search input\n * @param item the current item\n *\n * @default function that compare the query with the label and value, case-insensitive\n */\n filter?: (query: string, item: FacetItem) => boolean;\n /**\n * Value of the search input\n */\n query?: string;\n /**\n * Nothing found message\n *\n * @default No matching items\n */\n nothingFound?: ReactNode;\n /**\n * Displayed when a list is empty and there is no search query\n *\n * @default No items\n */\n placeholder?: ReactNode;\n /**\n * Facet title\n */\n title?: ReactNode;\n /**\n * Maximum height, only used when there is more than 7 values\n *\n * @default 200\n */\n height?: number | 'auto';\n /**\n * Predefined border-radius value from theme.radius or number for border-radius in px\n *\n * @default md\n */\n radius?: number | string;\n /**\n * Change list component, can be used to add custom scrollbars\n */\n listComponent?: FunctionComponent<any>;\n /**\n * Limit amount of items showed at a time\n *\n * @default Infinity\n */\n limit?: number;\n /**\n * Control the displaying of the search input.\n *\n * @default data.length <= 7\n */\n hideSearch?: boolean;\n __staticSelector?: string;\n}\n\nexport type FacetFactory = Factory<{\n props: FacetProps;\n ref: HTMLDivElement;\n stylesNames: FacetStylesNames;\n}>;\n\nconst defaultProps: Partial<FacetProps> = {\n searchPlaceholder: 'Search',\n nothingFound: 'No matching items',\n placeholder: 'No items',\n height: 200,\n limit: Infinity,\n itemComponent: DefaultFacetItem,\n listComponent: FacetScrollArea,\n removable: false,\n};\n\nexport const Facet: FunctionComponent<FacetProps> = factory<FacetFactory>((_props, ref) => {\n const props = useProps('Facet', defaultProps, _props);\n const {\n className,\n data,\n onChange,\n onRemove,\n initialSelection = [],\n removable,\n selection,\n itemComponent: ItemComponent,\n listComponent: ListComponent,\n itemCountFormatter,\n searchPlaceholder,\n query,\n hideSearch = data.length <= 7,\n onSearch,\n filter = defaultFilter,\n nothingFound,\n placeholder,\n title,\n height,\n radius,\n __staticSelector,\n classNames,\n styles,\n limit,\n unstyled,\n ...others\n } = props;\n const combobox = useCombobox();\n const [search, handleSearch] = useUncontrolled({\n value: query,\n defaultValue: '',\n finalValue: '',\n onChange: onSearch,\n });\n\n const [_selection, handleSelection] = useUncontrolled({\n value: selection,\n defaultValue: initialSelection,\n finalValue: [],\n onChange,\n });\n\n const unGroupedItems: ReactElement[] = [];\n const groupedItems: ReactElement[] = [];\n const filteredData = data.filter((item) => filter(search, item)).slice(0, limit);\n\n const sortedData: FacetData = groupOptions({data: filteredData});\n\n const handleValueSelect = (val: string) =>\n handleSelection(_selection.includes(val) ? _selection.filter((v) => v !== val) : [..._selection, val]);\n\n let groupName: string = null;\n\n useEffect(() => {\n combobox.openDropdown();\n }, []);\n\n sortedData.forEach((item) => {\n const isSelected = _selection.includes(item.value);\n const itemComponent = (\n <Combobox.Option\n aria-selected={isSelected ? true : false}\n value={item.value}\n key={item.value}\n onMouseEnter={() => combobox.resetSelectedOption()}\n className={clsx(classes.facetItem)}\n >\n <ItemComponent data={item} selected={isSelected} countFormatter={itemCountFormatter} />\n </Combobox.Option>\n );\n\n if (!item.group) {\n unGroupedItems.push(itemComponent);\n } else {\n if (groupName !== item.group) {\n groupName = item.group;\n groupedItems.push(\n <div className={classes.separator} key={groupName}>\n <Divider classNames={{label: classes.separatorLabel}} label={groupName} />\n </div>,\n );\n }\n groupedItems.push(itemComponent);\n }\n });\n\n if (groupedItems.length > 0 && unGroupedItems.length > 0) {\n unGroupedItems.unshift(\n <div className={classes.separator} key=\"ungrouped-separator\">\n <Divider unstyled={unstyled} classNames={{label: classes.separatorLabel}} />\n </div>,\n );\n }\n\n return (\n <Box className={clsx(classes.facet, className)} {...others} ref={ref}>\n <Combobox store={combobox} onOptionSubmit={handleValueSelect}>\n <Combobox.EventsTarget>\n <Box className={classes.facetHeader}>\n <Group wrap=\"nowrap\" justify=\"space-between\" className={classes.facetTitleRow}>\n {title ? (\n <Title order={5} className={classes.facetTitle}>\n {title}\n </Title>\n ) : null}\n {removable ? (\n <CloseButton\n onClick={onRemove}\n className={classes.facetRemoveButton}\n aria-label=\"remove facet\"\n />\n ) : null}\n </Group>\n\n <TextInput\n unstyled={unstyled}\n value={search}\n onChange={(event) => {\n handleSearch(event.currentTarget.value);\n combobox.updateSelectedOptionIndex();\n }}\n placeholder={searchPlaceholder}\n aria-hidden={hideSearch}\n tabIndex={hideSearch ? -1 : undefined}\n className={clsx(classes.facetSearch, {[classes.hiddenSearch]: hideSearch})}\n rightSection={\n search ? (\n <CloseButton\n aria-label=\"clear search\"\n onClick={() => {\n handleSearch('');\n }}\n />\n ) : (\n <IconSearch height={16} />\n )\n }\n />\n </Box>\n </Combobox.EventsTarget>\n <div className={classes.facetBody}>\n <Combobox.EventsTarget>\n <ListComponent\n className={classes.facetItems}\n mah={height}\n style={{overflow: 'auto', position: 'relative'}}\n tabIndex={hideSearch ? 0 : undefined}\n >\n <Combobox.Options aria-multiselectable=\"true\">\n {groupedItems.length > 0 || unGroupedItems.length > 0 ? (\n <>\n {groupedItems}\n {unGroupedItems}\n </>\n ) : (\n <Combobox.Empty>\n <Text c=\"dimmed\" unstyled={unstyled} size=\"sm\" ta=\"center\" my=\"sm\">\n {!search && placeholder ? placeholder : nothingFound}\n </Text>\n </Combobox.Empty>\n )}\n </Combobox.Options>\n </ListComponent>\n </Combobox.EventsTarget>\n </div>\n </Combobox>\n </Box>\n );\n});\n\nFacet.displayName = 'Facet';\n\nconst defaultFilter = (query: string, item: FacetItem) =>\n item.label.toLowerCase().trim().includes(query.toLowerCase().trim()) ||\n item.value.toLowerCase().trim().includes(query.toLowerCase().trim());\n"],"names":["IconSearch","Box","CloseButton","Combobox","Divider","factory","Group","Text","TextInput","Title","useCombobox","useProps","useUncontrolled","clsx","useEffect","groupOptions","DefaultFacetItem","classes","FacetScrollArea","defaultProps","searchPlaceholder","nothingFound","placeholder","height","limit","Infinity","itemComponent","listComponent","removable","Facet","_props","ref","props","className","data","onChange","onRemove","initialSelection","selection","ItemComponent","ListComponent","itemCountFormatter","query","hideSearch","length","onSearch","filter","defaultFilter","title","radius","__staticSelector","classNames","styles","unstyled","others","combobox","search","handleSearch","value","defaultValue","finalValue","_selection","handleSelection","unGroupedItems","groupedItems","filteredData","item","slice","sortedData","handleValueSelect","val","includes","v","groupName","openDropdown","forEach","isSelected","Option","aria-selected","onMouseEnter","resetSelectedOption","facetItem","selected","countFormatter","group","push","div","separator","label","separatorLabel","unshift","facet","store","onOptionSubmit","EventsTarget","facetHeader","wrap","justify","facetTitleRow","order","facetTitle","onClick","facetRemoveButton","aria-label","event","currentTarget","updateSelectedOptionIndex","aria-hidden","tabIndex","undefined","facetSearch","hiddenSearch","rightSection","facetBody","facetItems","mah","style","overflow","position","Options","aria-multiselectable","Empty","c","size","ta","my","displayName","toLowerCase","trim"],"mappings":";AAAA,SAAQA,UAAU,QAAO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7B,cAAA,KAAC9G,SAAS2F,YAAY;kCAClB,cAAA,KAACtD;4BACGP,WAAWhB,QAAQiG,UAAU;4BAC7BC,KAAK5F;4BACL6F,OAAO;gCAACC,UAAU;gCAAQC,UAAU;4BAAU;4BAC9CV,UAAUjE,aAAa,IAAIkE;sCAE3B,cAAA,KAAC1G,SAASoH,OAAO;gCAACC,wBAAqB;0CAClCxD,aAAapB,MAAM,GAAG,KAAKmB,eAAenB,MAAM,GAAG,kBAChD;;wCACKoB;wCACAD;;mDAGL,KAAC5D,SAASsH,KAAK;8CACX,cAAA,KAAClH;wCAAKmH,GAAE;wCAASrE,UAAUA;wCAAUsE,MAAK;wCAAKC,IAAG;wCAASC,IAAG;kDACzD,CAACrE,UAAUlC,cAAcA,cAAcD;;;;;;;;;;AAWpF,GAAG;AAEHQ,MAAMiG,WAAW,GAAG;AAEpB,MAAM/E,gBAAgB,CAACL,OAAewB,OAClCA,KAAKsB,KAAK,CAACuC,WAAW,GAAGC,IAAI,GAAGzD,QAAQ,CAAC7B,MAAMqF,WAAW,GAAGC,IAAI,OACjE9D,KAAKR,KAAK,CAACqE,WAAW,GAAGC,IAAI,GAAGzD,QAAQ,CAAC7B,MAAMqF,WAAW,GAAGC,IAAI"}
|
|
@@ -56,8 +56,21 @@
|
|
|
56
56
|
flex: 1;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
.facetTitleRow {
|
|
60
|
+
width: 100%;
|
|
61
|
+
min-width: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
.facetTitle {
|
|
65
|
+
flex: 1;
|
|
66
|
+
min-width: 0;
|
|
60
67
|
margin-bottom: 0;
|
|
68
|
+
overflow-wrap: anywhere;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.facetRemoveButton {
|
|
72
|
+
flex-shrink: 0;
|
|
73
|
+
margin-left: auto;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
.facetSearch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coveord/plasma-mantine",
|
|
3
|
-
"version": "59.4.
|
|
3
|
+
"version": "59.4.1",
|
|
4
4
|
"description": "A Plasma flavoured Mantine theme",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plasma",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"fast-deep-equal": "3.1.3",
|
|
82
82
|
"lodash.defaultsdeep": "4.6.1",
|
|
83
83
|
"monaco-editor": "0.55.1",
|
|
84
|
-
"@coveord/plasma-
|
|
85
|
-
"@coveord/plasma-
|
|
84
|
+
"@coveord/plasma-tokens": "59.4.1",
|
|
85
|
+
"@coveord/plasma-react-icons": "59.4.1"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@mantine/carousel": "8.3.18",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@mantine/modals": "8.3.18",
|
|
95
95
|
"@mantine/notifications": "8.3.18",
|
|
96
96
|
"@swc/cli": "0.8.1",
|
|
97
|
-
"@swc/core": "1.15.
|
|
97
|
+
"@swc/core": "1.15.32",
|
|
98
98
|
"@testing-library/dom": "10.4.1",
|
|
99
99
|
"@testing-library/jest-dom": "6.9.1",
|
|
100
100
|
"@testing-library/react": "16.3.2",
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
"embla-carousel-react": "8.6.0",
|
|
109
109
|
"eslint-plugin-testing-library": "7.16.2",
|
|
110
110
|
"eslint-plugin-vitest-globals": "1.6.1",
|
|
111
|
-
"jsdom": "29.0
|
|
112
|
-
"postcss": "8.5.
|
|
111
|
+
"jsdom": "29.1.0",
|
|
112
|
+
"postcss": "8.5.12",
|
|
113
113
|
"postcss-preset-mantine": "^1.11.0",
|
|
114
114
|
"postcss-simple-vars": "^7.0.1",
|
|
115
115
|
"publint": "0.3.18",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"rimraf": "6.1.3",
|
|
119
119
|
"tslib": "2.8.1",
|
|
120
120
|
"typescript": "5.9.3",
|
|
121
|
-
"vitest": "4.1.
|
|
121
|
+
"vitest": "4.1.5"
|
|
122
122
|
},
|
|
123
123
|
"peerDependencies": {
|
|
124
124
|
"@mantine/carousel": "^8.0.2",
|
|
@@ -56,8 +56,21 @@
|
|
|
56
56
|
flex: 1;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
.facetTitleRow {
|
|
60
|
+
width: 100%;
|
|
61
|
+
min-width: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
.facetTitle {
|
|
65
|
+
flex: 1;
|
|
66
|
+
min-width: 0;
|
|
60
67
|
margin-bottom: 0;
|
|
68
|
+
overflow-wrap: anywhere;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.facetRemoveButton {
|
|
72
|
+
flex-shrink: 0;
|
|
73
|
+
margin-left: auto;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
.facetSearch {
|