@bento-core/facet-filter

中文文档
1.0.1-ccdiintegrated.7发布于 2026/08/20ISCCommonJS近 30 天下载 1894

Bento core sidebar design:

原始使用文档
文档目录13 节
  1. Bento core sidebar design:
  2. 1 Redux stores active filters value and configuration
  3. Generate and integrate redux dispatch actions
  4. Check Global redux store for all active filters
  5. 2 Importing Component and Configuration
  6. 3 Dashboard Data
  7. 4 FacetsConfigs
  8. 5 facetSectionConfig
  9. 6 CustomFacetSection
  10. 7 CustomFacetView
  11. 8 FacetFilterThemeProvider
  12. 9. Styling Non Mui Custom Components
  13. 10 CLearAllFilterButton Component

SIDEBAR COMPONENT DESIGN

Bento core sidebar design:

  • Use of local state for all the click events
  • Use of global redux limited to store active filters
  • Limit use of props drilling
  • Core layout defined by Bento Core Sidebar component
  • Use of generator function to create and configure components (generator funtion is not used for configuring all the sidebar components due to local state issue)
  • Simple configuration to maximize the customization of sideBar component
  • Apply SOLID principles in react (https://konstantinlebedev.com/solid-in-react/)

1 Redux stores active filters value and configuration

Generate and integrate redux dispatch actions

import { sideBarReducerGenerator } from 'bento-core';
const { statusReducer } = sideBarReducerGenerator();

const reducers = {  statusReducer, ..., otherReducers };
const loggerMiddleware = createLogger();
const store = createStore( 
  combineReducers(reducers), 
  composeWithDevTools (applyMiddleware(ReduxThunk, loggerMiddleware)),
);

Check Global redux store for all active filters

// active filter json structure
statusReducer:
  filterState:
    pr_status:
     {
       Not Reported: true
     },
     rc_scores: {
       11-15: true,
       21-25: true
     }
     tumor_grades: {}
     tumor_sizes: {(1,2]: true} 

(Note: Bento core sideBar provides method to override the redux filter events/ actions.)

2 Importing Component and Configuration

import FacetFilter from 'bento-core';

<FacetFilterThemeProvider>
  <OtherComponent />
  <FacetFilter
    data={searchData}
    facetSectionConfig={facetSectionVariables}
    facetsConfig={facetsConfig}
    CustomFacetSection={CustomFacetSection}
    CustomFacetView={CustomFacetView}
  />
</FacetFilterThemeProvider>

3 Dashboard Data

searchData Pass Dashboard Data. (DASHBOARD_QUERY response)

 <FacetFilter
    data={searchData}
    ...
 />

4 FacetsConfigs

import { InputTypes } from 'bento-core';

export const facetsConfig = [{ 
  section: CASES,
  label: 'Program', 
  apiForFiltering: 'filterSubjectCountByProgram', 
  datafield: 'programs', 
  field: GROUP, 
  type: InputTypes.CHECKBOX, 
  sort_type: sortType.ALPHABET,
  show: true, 
}, {
   section: CASES,
   label: 'Age',
    apiForFiltering: 'filterSubjectCountByAge',
    datafield: 'age_at_index',
    ApiLowerBoundName: 'lowerBound',    
    ApiUpperBoundName: 'upperBound',
    show: true,    
    slider: true,    
    type: InputTypes.SLIDER,
    sort_type: 'none',   
    minLowerBound: 0,  
    maxUpperBound: 100,   
    quantifier: 'Years',
].
  1. apiForFiltering refers to object key for retrieving name and subjects count from query response (DASHBOARD_QUERY)
  2. dataField field for global redux store to track active filter item
  3. Type indicates the type of input (checkbox or slider)
  4. sort_type attribute used by Bento core sidebar local state to sorting of facet values
  5. section refers to name of the facet section
  6. show attribute must to be true to display facet on the Bento core Side bar component

Configuration varies based on the input types like checkbox or slider

(NOTE - SLIDER requires additional attributes)

5 facetSectionConfig

export const facetSectionVariables = { 
Cases: { 
  isExpanded: true,
},  
Samples: {
  isExpanded: true,
},  
Files: {
  isExpanded: true,
}};

Facet section defines the number of sections that will be displayed on Bento core sidebar component. isExpanded attribute set default state for the section i.e if true then facet section expand if false facet section collapse.

6 CustomFacetSection

Bento Core sidebar component provides view customization to some component like FacetSection and Face component.

const CustomFacetSection = ({ section }) => { 
  return (
    <>
     <CustomExpansionPanelSummary>
       <div className={classes.sectionSummaryTextContainer}>
         {section.name} 
       </div>
      </CustomExpansionPanelSummary>
    </> );
}; 

// provide as props
<FacetFilter
  data={searchData}
  facetSectionConfig={facetSectionVariables}
  facetsConfig={facetsConfig}
  CustomFacetSection={CustomFacetSection}
  CustomFacetView={CustomFacetView}
/>

7 CustomFacetView

const CustomFacetView = ({ facet, facetClasses }) => {   
   return (
     <>        
       <CustomExpansionPanelSummary>          
         <div 
           className={clsx(classes.sectionSummaryText, classes[facetClasses])}
          >            
           {facet.label}
         </div>        
       </CustomExpansionPanelSummary>      
    </>    
)};

// provide as props
<FacetFilter
  data={searchData}
  facetSectionConfig={facetSectionVariables}
  facetsConfig={facetsConfig}
  CustomFacetSection={CustomFacetSection}
  CustomFacetView={CustomFacetView}
/>

8 FacetFilterThemeProvider

Bento Core Sidebar assigns classes dynamically to its components (Mui component) based on local state of the component, FacetsConfigs and facetSectionConfig. Bento Core sidebar uses Mui Components widely so ThemeProvider can be used to override styles for each of the components in Bento Core Sidebar. This approach is similar to react useContext, to prevent props drilling.

const theme = {
overrides: {
 MuiListItem:
root: {        
  '&.casesCheckedEven': {
    //refer to class name table 
    ..//styles 
  }
  '&.casesCheckedOdd' :{
    //refer to class name table 
    ..//styles 
  },
  '&.samplesCheckedEven': { 
    //refer to class name table 
  ..//styles 
  }
  '&.samplesCheckedOdd' :{
  ..//styles 
  },
   MuiSvgIcon: {
  root: {
  '&.casesCheckedIcon': {
    //refer to class name table 
    ..//styles 
  }
  '&.samplesCheckedIcon': {
    ..//styles
  }
}

import FacetFilter from 'bento-core';
<ThemeProvider theme={computedTheme}>
   <FacetFilter />
</ThemeProvider>

NOTE: These are example class name and it is based on the configuration so for different configuration this classes may not apply)

CheckBox Component CLASS NAMES TABLE

Sidebar ComponentChild ComponentMuiClassNameCondition
Facet ValueCheck box ButtonListItem{checkedSection}Checked{indexType}active
Facet ValueCheckbox InputCheckboxIcon{checkedSection}CheckedIconactive
Facet ValueNameTypography{checkedSection}NameUnCheckedinactive
Facet ValueNameTypography{checkedSection}NameCheckedactive
Facet ValueSubjectTypography{checkedSection}SubjectUnCheckedactive
Facet ValueSubjectTypography{checkedSection}SubjectCheckedinactive

Follows in order of parent to child components
bold text indicates variables
active - when input type is checked
{indexType} = 'Even' /'Odd' based on index of the facet values
{checkedSection} = section name (attribute of facetsConfig) (like Cases, Sample, Files)

Slider Component
{type} -min or max (slider input type)

Sidebar ComponentChild ComponentMuiClassNameCondition
Facet ValueInput Min/MaxInputslider_{type}active

9. Styling Non Mui Custom Components

Classes provided by Bento Core Sidebar can be applied to the Custom elements.

className={clsx(classes.sectionSummaryText, classes[facetClasses])}

10 CLearAllFilterButton Component

Bento Core provides 1. function to clear all active filters, 2. disable flag (true incase of no active filters). Client is responsible for defining view (custom html).

import { generateClearAllFilterBtn } from 'bento-core';

const CustomClearAllFiltersBtn = ({ onClearAllFilters, disable }) => {
    //...custom component 1. bind onClearFilters fn
    // 2. disable flag to disable button
}

const ClearAllFiltersButton = () => generateClearAllFilterBtn(CustomClearAllFiltersBtn); 

版本与发布记录

@bento-core/facet-filter 共发布 110 个版本,首次发布于 2023/05/12;过去 12 个月发布了 19 个版本。

版本发布日期距今
1.0.1-ccdiintegrated.7latest2026/08/202 个月前
1.0.1-ccdiintegrated.62026/07/213 个月前
1.0.1-ccdiintegrated.52026/06/274 个月前
1.0.1-ccdiintegrated.42026/06/114 个月前
1.0.1-ccdiintegrated.32026/06/015 个月前
1.0.1-ccdiintegrated.22026/04/087 个月前

其他发布通道:ctdc → 1.0.1-ctdc.3,icdc → 1.0.1-icdc.16,c3dc → 1.0.1-c3dc.5,popsci → 1.0.1-popsci.4,CDS → 1.0.1-CDS.12,ccdihub → 1.0.1-ccdihub.41。

关于 @bento-core/facet-filter 的常见问题

@bento-core/facet-filter 是什么?

Bento core sidebar design:

如何安装 @bento-core/facet-filter?

在项目目录运行 npm install @bento-core/facet-filter,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@material-ui/core(^4.12.4)、@material-ui/icons(^4.9.1)、@material-ui/lab(^4.0.0-alpha.61)、clsx(^1.2.1)、react(^17.0.2)、react-dom(^17.0.0)、react-redux(^7.2.1)、react-router-dom(^5.1.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bento-core/facet-filter 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bento-core__facet-filter 是否存在。

@bento-core/facet-filter 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bento-core/facet-filter 可以商用吗?

@bento-core/facet-filter 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bento-core/facet-filter 的下载量有多少?

根据 npm 官方下载统计,@bento-core/facet-filter 在 2026/10/08 – 2026/11/06 这 30 天内被下载 1,894 次,日均约 63 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bento-core/facet-filter 还在维护吗?

最新版本 1.0.1-ccdiintegrated.7 发布于 2026/08/20(2 个月前);至今共发布 110 个版本,其中过去 12 个月发布了 19 个;首次发布于 2023/05/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。