@box/box-item-type-selector 2.2.1 → 2.2.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as BoxItemTypeSelector}from"./box-item-type-selector.js";import messages from"../esm/lib/messages.js";import{n as boxItemTypeMapping}from"./constants.js";import{Button,FilterChip,Popover,useBlueprintModernization}from"@box/blueprint-web";import
|
|
1
|
+
import{t as BoxItemTypeSelector}from"./box-item-type-selector.js";import messages from"../esm/lib/messages.js";import{n as boxItemTypeMapping}from"./constants.js";import{Button,FilterChip,Popover,useBlueprintModernization}from"@box/blueprint-web";import React from"react";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import{FileDefault}from"@box/blueprint-web-assets/icons/Line";import{File}from"@box/blueprint-web-assets/icons/Medium";import '../styles/box-item-type-selector-quick-filter.css';var box_item_type_selector_quick_filter_module_default={itemTypeSelectorQuickFilterPopoverContainer:`_itemTypeSelectorQuickFilterPopoverContainer_10sjf_1`,popoverMainContent:`_popoverMainContent_10sjf_4`,boxItemTypeSelectorQuickFilter:`_boxItemTypeSelectorQuickFilter_10sjf_8`,popoverFooterInline:`_popoverFooterInline_10sjf_11`},getSelectableItemTypeCount=()=>boxItemTypeMapping.reduce((count,i)=>count+(i.children?i.children.length:1),0),getSelectedFilterChipLabels=selected=>boxItemTypeMapping.map(parentItem=>parentItem.children?parentItem.children.every(c=>selected.includes(c.value))?parentItem.title:parentItem.children.filter(c=>selected.includes(c.value)).map(c=>c.title):selected.includes(parentItem.value)?parentItem.title:[]).flat(),hasSameSelection=(oldSelection,newSelection)=>oldSelection.length===newSelection.length?oldSelection.every(item=>newSelection.includes(item)):!1,selectableItemTypeCount=getSelectableItemTypeCount();function BoxItemTypeSelectorQuickFilter(props){let{allowAllOptionsSelect=!1,applyButtonType=`button`,autoFocus,selected,onApply,onFocus,className}=props,intl=useIntl(),[popoverSelection,setPopoverSelection]=React.useState(selected),{enableModernizedComponents}=useBlueprintModernization();React.useEffect(()=>{setPopoverSelection(selected)},[selected]);let renderFilterChipLabel=()=>{let selectedFilterChipLabels=getSelectedFilterChipLabels(selected),selectedLength=selectedFilterChipLabels.length;return selectedLength?selectedLength===1?intl.formatMessage(selectedFilterChipLabels[0]):intl.formatMessage(messages.multipleFiles,{count:selectedLength-1,fileType:intl.formatMessage(selectedFilterChipLabels[0])}):intl.formatMessage(messages.fileTypeLabelDropdown)},handleApply=()=>{!allowAllOptionsSelect&&popoverSelection.length===selectableItemTypeCount?(setPopoverSelection([]),onApply([])):onApply(popoverSelection)},FileIcon=enableModernizedComponents?File:FileDefault;return jsx(`div`,{className,children:jsxs(Popover.Root,{modal:!1,children:[jsx(Popover.Trigger,{children:jsxs(FilterChip.TriggerChip,{autoFocus,onClick:()=>setPopoverSelection(selected),onFocus,selected:!!selected.length,value:`trigger-chip`,children:[jsx(FilterChip.Icon,{icon:FileIcon}),jsx(FilterChip.Label,{children:renderFilterChipLabel()}),jsx(FilterChip.DropdownIndicator,{})]})}),jsxs(Popover.ContentContainer,{align:`start`,className:box_item_type_selector_quick_filter_module_default.itemTypeSelectorQuickFilterPopoverContainer,children:[jsx(Popover.MainContent,{className:box_item_type_selector_quick_filter_module_default.popoverMainContent,children:jsx(BoxItemTypeSelector,{className:box_item_type_selector_quick_filter_module_default.boxItemTypeSelectorQuickFilter,onSelectionChange:setPopoverSelection,selected:popoverSelection})}),jsxs(Popover.Footer,{className:box_item_type_selector_quick_filter_module_default.popoverFooterInline,children:[jsx(Button,{disabled:!popoverSelection.length,onClick:()=>setPopoverSelection([]),size:`small`,variant:`secondary`,children:intl.formatMessage(messages.clear)}),jsx(Popover.Close,{children:jsx(Button,{disabled:hasSameSelection(popoverSelection,selected),onClick:handleApply,size:`small`,type:applyButtonType,variant:`primary`,children:intl.formatMessage(messages.apply)})})]})]})]})})}export{BoxItemTypeSelectorQuickFilter as t};
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/box-item-type-selector",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@box/blueprint-web": "^16.14.
|
|
6
|
-
"@box/blueprint-web-assets": "^5.6.
|
|
5
|
+
"@box/blueprint-web": "^16.14.2",
|
|
6
|
+
"@box/blueprint-web-assets": "^5.6.2",
|
|
7
7
|
"react": "^17.0.0 || ^18.0.0",
|
|
8
8
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
9
9
|
"react-intl": "^6.4.2"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@box/blueprint-web": "^16.14.
|
|
13
|
-
"@box/blueprint-web-assets": "^5.6.
|
|
14
|
-
"@box/storybook-utils": "^1.2.
|
|
12
|
+
"@box/blueprint-web": "^16.14.2",
|
|
13
|
+
"@box/blueprint-web-assets": "^5.6.2",
|
|
14
|
+
"@box/storybook-utils": "^1.2.2",
|
|
15
15
|
"react": "^18.3.0",
|
|
16
16
|
"react-dom": "^18.3.0",
|
|
17
17
|
"react-intl": "^6.4.2"
|