@box/metadata-template-browser 3.0.30 → 3.1.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/dist/chunks/metadata-template-browser-container.js +1 -1
- package/dist/chunks/metadata-template-browser-controller.js +1 -1
- package/dist/esm/lib/components/browse-list/browse-list.js +1 -1
- package/dist/esm/lib/components/template-row/template-row.js +1 -1
- package/dist/esm/lib/contexts/contexts.js +1 -1
- package/dist/esm/lib/hooks/use-can-create-in-current-namespace.js +1 -0
- package/dist/esm/lib/metadata-template-browser.js +1 -1
- package/dist/types/lib/components/metadata-template-browser-container.d.ts +2 -2
- package/dist/types/lib/contexts/contexts.d.ts +3 -1
- package/dist/types/lib/hooks/use-can-create-in-current-namespace.d.ts +5 -0
- package/dist/types/lib/metadata-template-browser.d.ts +2 -2
- package/dist/types/lib/stories/shared/create-mock-items-service.d.ts +2 -2
- package/dist/types/lib/types.d.ts +7 -4
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useBrowseNode,useBrowseState,useBrowserActions,useConsumerState,useNavigationState,useSearchState}from"../esm/lib/contexts/hooks.js";import{t as BreadcrumbNavigation}from"./breadcrumb-navigation.js";import{messages}from"../esm/lib/components/messages.js";import{useIsInitialBrowseLoading}from"../esm/lib/hooks/use-is-initial-browse-loading.js";import{t as MetadataTemplateBrowserListBox}from"./metadata-template-browser-list-box.js";import{Button,SearchInput}from"@box/blueprint-web";import classNames from"clsx";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import{Plus}from"@box/blueprint-web-assets/icons/Medium";import '../styles/metadata-template-browser-container.css';var metadata_template_browser_container_module_default={container:`_container_1wehq_1`,searchInput:`_searchInput_1wehq_9`,searchInputWithBreadcrumb:`_searchInputWithBreadcrumb_1wehq_13`,createTemplateButton:`_createTemplateButton_1wehq_17`};function MetadataTemplateBrowserContainer(){let{formatMessage}=useIntl(),{isDisabled,isNamespacesEnabled}=useConsumerState(),{setSearchValue,createTemplate}=useBrowserActions(),{namespaceFQN
|
|
1
|
+
import{useBrowseNode,useBrowseState,useBrowserActions,useConsumerState,useNavigationState,useSearchState}from"../esm/lib/contexts/hooks.js";import{t as BreadcrumbNavigation}from"./breadcrumb-navigation.js";import{useCanCreateInCurrentNamespace}from"../esm/lib/hooks/use-can-create-in-current-namespace.js";import{messages}from"../esm/lib/components/messages.js";import{useIsInitialBrowseLoading}from"../esm/lib/hooks/use-is-initial-browse-loading.js";import{t as MetadataTemplateBrowserListBox}from"./metadata-template-browser-list-box.js";import{Button,SearchInput}from"@box/blueprint-web";import classNames from"clsx";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import{Plus}from"@box/blueprint-web-assets/icons/Medium";import '../styles/metadata-template-browser-container.css';var metadata_template_browser_container_module_default={container:`_container_1wehq_1`,searchInput:`_searchInput_1wehq_9`,searchInputWithBreadcrumb:`_searchInputWithBreadcrumb_1wehq_13`,createTemplateButton:`_createTemplateButton_1wehq_17`};function MetadataTemplateBrowserContainer(){let{formatMessage}=useIntl(),{isDisabled,isNamespacesEnabled}=useConsumerState(),{setSearchValue,createTemplate}=useBrowserActions(),{namespaceFQN}=useNavigationState(),canCreateInCurrentNamespace=useCanCreateInCurrentNamespace(),{searchValue}=useSearchState(),{namespaces,templates,isNamespacesExhausted}=useBrowseNode(),{isFetching}=useBrowseState(),isInitialBrowseLoading=useIsInitialBrowseLoading(),isBrowseListEmpty=!isFetching&&isNamespacesExhausted&&namespaces.length===0&&templates.length===0,showCreateButton=canCreateInCurrentNamespace&&!isInitialBrowseLoading&&!isFetching&&!isBrowseListEmpty&&searchValue.length===0;return jsxs(`div`,{className:metadata_template_browser_container_module_default.container,children:[jsx(SearchInput,{className:classNames(metadata_template_browser_container_module_default.searchInput,{[metadata_template_browser_container_module_default.searchInputWithBreadcrumb]:!isInitialBrowseLoading&&isNamespacesEnabled&&searchValue.length===0}),disabled:isDisabled||isInitialBrowseLoading,onChange:setSearchValue,placeholder:formatMessage(messages.searchInputPlaceholder),searchInputAriaLabel:formatMessage(messages.searchInputAriaLabel),searchInputClearAriaLabel:formatMessage(messages.searchInputClearAriaLabel)}),!isInitialBrowseLoading&&jsx(BreadcrumbNavigation,{}),showCreateButton&&jsx(Button,{className:metadata_template_browser_container_module_default.createTemplateButton,disabled:isDisabled,startIcon:Plus,onClick:()=>createTemplate(namespaceFQN),variant:`tertiary`,size:`large`,children:formatMessage(messages.createTemplateButtonLabel)}),jsx(MetadataTemplateBrowserListBox,{})]})}export{MetadataTemplateBrowserContainer as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useBrowseNode,useBrowseState,useBrowserActions,useConsumerState,useNavigationState}from"../esm/lib/contexts/hooks.js";import{ErrorState}from"../esm/lib/components/error-state/error-state.js";import{messages}from"../esm/lib/components/messages.js";import{t as MetadataTemplateBrowserContainer}from"./metadata-template-browser-container.js";import{EmptyState,Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{useEffect,useRef}from"react";import{jsx,jsxs}from"react/jsx-runtime";import{NoTemplates}from"@box/blueprint-web-assets/illustrations/Medium";import '../styles/metadata-template-browser-controller.css';var metadata_template_browser_controller_module_default={container:`_container_14phx_1`};function MetadataTemplateBrowserController(){let{isLoading:isConsumerLoading,isNamespacesEnabled}=useConsumerState(),{formatMessage}=useIntl(),{initialLoad,retry}=useBrowserActions(),{path
|
|
1
|
+
import{useBrowseNode,useBrowseState,useBrowserActions,useConsumerState,useNavigationState}from"../esm/lib/contexts/hooks.js";import{useCanCreateInCurrentNamespace}from"../esm/lib/hooks/use-can-create-in-current-namespace.js";import{ErrorState}from"../esm/lib/components/error-state/error-state.js";import{messages}from"../esm/lib/components/messages.js";import{t as MetadataTemplateBrowserContainer}from"./metadata-template-browser-container.js";import{EmptyState,Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{useEffect,useRef}from"react";import{jsx,jsxs}from"react/jsx-runtime";import{NoTemplates}from"@box/blueprint-web-assets/illustrations/Medium";import '../styles/metadata-template-browser-controller.css';var metadata_template_browser_controller_module_default={container:`_container_14phx_1`};function MetadataTemplateBrowserController(){let{isLoading:isConsumerLoading,isNamespacesEnabled}=useConsumerState(),{formatMessage}=useIntl(),{initialLoad,retry}=useBrowserActions(),{path}=useNavigationState(),canCreateInCurrentNamespace=useCanCreateInCurrentNamespace(),{namespaces,templates}=useBrowseNode(),{isFetching,initialLoadError}=useBrowseState(),hasInitiallyLoadedRef=useRef(!1);useEffect(()=>{!isConsumerLoading&&!hasInitiallyLoadedRef.current&&(hasInitiallyLoadedRef.current=!0,initialLoad())},[isConsumerLoading,initialLoad]);let hasItems=namespaces.length>0||templates.length>0,hasInitialLoadError=initialLoadError!==null,isAtRoot=path.length===0,isBrowseEmpty=!isFetching&&!isConsumerLoading&&!hasItems&&!hasInitialLoadError&&isAtRoot&&!canCreateInCurrentNamespace&&isNamespacesEnabled,showContainer=!hasInitialLoadError&&!isBrowseEmpty;return jsxs(`div`,{className:metadata_template_browser_controller_module_default.container,children:[hasInitialLoadError&&jsx(ErrorState,{body:formatMessage(messages.initialLoadErrorBody),onRetry:retry}),isBrowseEmpty&&jsx(EmptyState,{body:jsx(Text,{as:`p`,children:formatMessage(messages.initialEmptyStateBody)}),illustration:NoTemplates,size:`small`}),showContainer&&jsx(MetadataTemplateBrowserContainer,{})]})}export{MetadataTemplateBrowserController as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useBrowseNode,useBrowseState,useBrowserActions,useConsumerState,useNavigationState}from"../../contexts/hooks.js";import{t as TemplateRowVariant}from"../../../../chunks/types.js";import{ErrorState}from"../error-state/error-state.js";import{t as LoaderSkeleton}from"../../../../chunks/loader-skeleton.js";import{NamespaceRow}from"../namespace-row/namespace-row.js";import{TemplateRow}from"../template-row/template-row.js";import{t as VirtualizedGridList}from"../../../../chunks/virtualized-grid-list.js";import{messages}from"./messages.js";import{EmptyState,Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{useCallback}from"react";import{jsx}from"react/jsx-runtime";import{NoTemplates}from"@box/blueprint-web-assets/illustrations/Medium";function BrowseList({onAction,selectedKeys}){let{formatMessage}=useIntl(),{namespaces,templates,isNamespacesExhausted,namespaceNextMarker,templateNextMarker}=useBrowseNode(),{isFetching,isFetchingMore,browseError,loadMoreError}=useBrowseState(),{loadMore,retry,editTemplate,createTemplate}=useBrowserActions(),{namespaceFQN
|
|
1
|
+
import{useBrowseNode,useBrowseState,useBrowserActions,useConsumerState,useNavigationState}from"../../contexts/hooks.js";import{useCanCreateInCurrentNamespace}from"../../hooks/use-can-create-in-current-namespace.js";import{t as TemplateRowVariant}from"../../../../chunks/types.js";import{ErrorState}from"../error-state/error-state.js";import{t as LoaderSkeleton}from"../../../../chunks/loader-skeleton.js";import{NamespaceRow}from"../namespace-row/namespace-row.js";import{TemplateRow}from"../template-row/template-row.js";import{t as VirtualizedGridList}from"../../../../chunks/virtualized-grid-list.js";import{messages}from"./messages.js";import{EmptyState,Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{useCallback}from"react";import{jsx}from"react/jsx-runtime";import{NoTemplates}from"@box/blueprint-web-assets/illustrations/Medium";function BrowseList({onAction,selectedKeys}){let{formatMessage}=useIntl(),{namespaces,templates,isNamespacesExhausted,namespaceNextMarker,templateNextMarker}=useBrowseNode(),{isFetching,isFetchingMore,browseError,loadMoreError}=useBrowseState(),{loadMore,retry,editTemplate,createTemplate}=useBrowserActions(),{namespaceFQN}=useNavigationState(),canCreateInCurrentNamespace=useCanCreateInCurrentNamespace(),{isDisabled}=useConsumerState(),hasMoreBrowseItems=namespaceNextMarker!==void 0||isNamespacesExhausted&&templateNextMarker!==void 0,renderItem=useCallback(item=>item.kind===`namespace`?jsx(NamespaceRow,{namespace:item.namespace}):jsx(TemplateRow,{onEdit:editTemplate,template:item.template,variant:TemplateRowVariant.Browse}),[editTemplate]);if(isFetching)return jsx(LoaderSkeleton,{});if(browseError!==null)return jsx(ErrorState,{body:formatMessage(messages.browseErrorBody),onRetry:retry});let items=[...namespaces.map(namespace=>({id:namespace.fqn,kind:`namespace`,namespace})),...templates.map(template=>({id:template.id,kind:`template`,template}))];return items.length===0?jsx(EmptyState,{body:jsx(Text,{as:`p`,children:formatMessage(messages.emptyStateBody)}),illustration:NoTemplates,size:`small`,children:canCreateInCurrentNamespace&&jsx(EmptyState.PrimaryAction,{disabled:isDisabled,onClick:()=>createTemplate(namespaceFQN),children:formatMessage(messages.createFirstTemplateButtonLabel)})}):jsx(VirtualizedGridList,{ariaLabel:formatMessage(messages.listAriaLabel),isFetchingMore,items,listType:TemplateRowVariant.Browse,loadMoreError,onAction,hasMoreItems:hasMoreBrowseItems,onLoadMore:loadMore,onRetry:loadMore,selectedKeys,children:renderItem})}export{BrowseList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useConsumerState}from"../../contexts/hooks.js";import{t as TemplateRowVariant}from"../../../../chunks/types.js";import{t as BrowserRow}from"../../../../chunks/browser-row.js";import{messages}from"./messages.js";import{IconButton,Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{Fragment,useCallback}from"react";import{jsx,jsxs}from"react/jsx-runtime";import{Metadata}from"@box/blueprint-web-assets/icons/Medium";import{Pencil}from"@box/blueprint-web-assets/icons/Fill";var deriveBreadcrumbPath=template=>{if(!template.ancestors||template.ancestors.length===0)return;let lastIndex=template.ancestors.length-1;return template.ancestors.map((ancestor,index)=>jsxs(Fragment,{children:[index>0&&jsx(Text,{"aria-hidden":`true`,as:`span`,color:`textOnLightSecondary`,variant:`caption`,children:` / `}),jsx(Text,{as:`span`,color:`textOnLightSecondary`,variant:index===lastIndex?`captionBold`:`caption`,children:ancestor.displayName})]},ancestor.fqn))};function TemplateRow({template,variant,onEdit}){let{formatMessage}=useIntl(),{isDisabled,appliedTemplateIds}=useConsumerState(),isApplied=appliedTemplateIds.has(template.id),handleEditClick=useCallback(event=>{event.stopPropagation(),onEdit(template.id)},[onEdit,template.id]),isSearchVariant=variant===TemplateRowVariant.Search,showEditButton
|
|
1
|
+
import{useConsumerState}from"../../contexts/hooks.js";import{t as TemplateRowVariant}from"../../../../chunks/types.js";import{t as BrowserRow}from"../../../../chunks/browser-row.js";import{messages}from"./messages.js";import{IconButton,Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{Fragment,useCallback}from"react";import{jsx,jsxs}from"react/jsx-runtime";import{Metadata}from"@box/blueprint-web-assets/icons/Medium";import{Pencil}from"@box/blueprint-web-assets/icons/Fill";var deriveBreadcrumbPath=template=>{if(!template.ancestors||template.ancestors.length===0)return;let lastIndex=template.ancestors.length-1;return template.ancestors.map((ancestor,index)=>jsxs(Fragment,{children:[index>0&&jsx(Text,{"aria-hidden":`true`,as:`span`,color:`textOnLightSecondary`,variant:`caption`,children:` / `}),jsx(Text,{as:`span`,color:`textOnLightSecondary`,variant:index===lastIndex?`captionBold`:`caption`,children:ancestor.displayName})]},ancestor.fqn))};function TemplateRow({template,variant,onEdit}){let{formatMessage}=useIntl(),{isDisabled,appliedTemplateIds,isTemplateEditingEnabled}=useConsumerState(),isApplied=appliedTemplateIds.has(template.id),handleEditClick=useCallback(event=>{event.stopPropagation(),onEdit(template.id)},[onEdit,template.id]),isSearchVariant=variant===TemplateRowVariant.Search,showEditButton=isTemplateEditingEnabled&&!!template.canEdit;return jsx(BrowserRow,{id:template.id,isApplied,isTrailingSlotHoverOnly:showEditButton,leadingIcon:isSearchVariant?void 0:jsx(Metadata,{}),subtitle:isSearchVariant?deriveBreadcrumbPath(template):void 0,title:template.displayName,tooltipContent:isApplied?formatMessage(messages.alreadyApplied):void 0,trailingSlot:showEditButton?jsx(`div`,{onPointerDown:e=>e.stopPropagation(),children:jsx(IconButton,{"aria-label":formatMessage(messages.editAriaLabel,{displayName:template.displayName}),disabled:isDisabled,icon:Pencil,onClick:handleEditClick,size:`x-small`})}):void 0})}export{TemplateRow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useTemplateBrowserActions}from"./use-template-browser-actions.js";import{createContext,useMemo}from"react";import{jsx}from"react/jsx-runtime";var NavigationStateContext=createContext(null);function NavigationStateContextProvider({children,namespaceFQN,path,canCreateInCurrentNamespace}){let value=useMemo(()=>({namespaceFQN,path,canCreateInCurrentNamespace}),[namespaceFQN,path,canCreateInCurrentNamespace]);return jsx(NavigationStateContext.Provider,{value,children})}var BrowseStateContext=createContext(null);function BrowseStateContextProvider({children,browseByFqn,isFetching,isFetchingMore,initialLoadError,browseError,loadMoreError}){let value=useMemo(()=>({browseByFqn,isFetching,isFetchingMore,initialLoadError,browseError,loadMoreError}),[browseByFqn,isFetching,isFetchingMore,initialLoadError,browseError,loadMoreError]);return jsx(BrowseStateContext.Provider,{value,children})}var SearchStateContext=createContext(null);function SearchStateContextProvider({children,searchValue,searchQuery,searchResults,searchNextMarker,isFetchingSearch,searchError}){let value=useMemo(()=>({searchValue,searchQuery,searchResults,searchNextMarker,isFetchingSearch,searchError}),[searchValue,searchQuery,searchResults,searchNextMarker,isFetchingSearch,searchError]);return jsx(SearchStateContext.Provider,{value,children})}var SelectionStateContext=createContext(null);function SelectionStateContextProvider({children,selectedTemplateId}){let value=useMemo(()=>({selectedTemplateId}),[selectedTemplateId]);return jsx(SelectionStateContext.Provider,{value,children})}var ConsumerStateContext=createContext(null),EMPTY_APPLIED_TEMPLATE_IDS=new Set;function ConsumerStateContextProvider({children,isLoading=!1,isDisabled=!1,isNamespacesEnabled=!1,appliedTemplateIds=EMPTY_APPLIED_TEMPLATE_IDS}){let value=useMemo(()=>({isLoading,isDisabled,isNamespacesEnabled,appliedTemplateIds}),[isLoading,isDisabled,isNamespacesEnabled,appliedTemplateIds]);return jsx(ConsumerStateContext.Provider,{value,children})}var BrowserActionsContext=createContext(null);function BrowserActionsContextProvider({children,itemsServiceRef,eventServiceRef,isNamespacesEnabledRef,stateRef,dispatch}){let actions=useTemplateBrowserActions(itemsServiceRef,eventServiceRef,isNamespacesEnabledRef,stateRef,dispatch);return jsx(BrowserActionsContext.Provider,{value:actions,children})}export{BrowseStateContext,BrowseStateContextProvider,BrowserActionsContext,BrowserActionsContextProvider,ConsumerStateContext,ConsumerStateContextProvider,NavigationStateContext,NavigationStateContextProvider,SearchStateContext,SearchStateContextProvider,SelectionStateContext,SelectionStateContextProvider};
|
|
1
|
+
import{useTemplateBrowserActions}from"./use-template-browser-actions.js";import{createContext,useMemo}from"react";import{jsx}from"react/jsx-runtime";var NavigationStateContext=createContext(null);function NavigationStateContextProvider({children,namespaceFQN,path,canCreateInCurrentNamespace}){let value=useMemo(()=>({namespaceFQN,path,canCreateInCurrentNamespace}),[namespaceFQN,path,canCreateInCurrentNamespace]);return jsx(NavigationStateContext.Provider,{value,children})}var BrowseStateContext=createContext(null);function BrowseStateContextProvider({children,browseByFqn,isFetching,isFetchingMore,initialLoadError,browseError,loadMoreError}){let value=useMemo(()=>({browseByFqn,isFetching,isFetchingMore,initialLoadError,browseError,loadMoreError}),[browseByFqn,isFetching,isFetchingMore,initialLoadError,browseError,loadMoreError]);return jsx(BrowseStateContext.Provider,{value,children})}var SearchStateContext=createContext(null);function SearchStateContextProvider({children,searchValue,searchQuery,searchResults,searchNextMarker,isFetchingSearch,searchError}){let value=useMemo(()=>({searchValue,searchQuery,searchResults,searchNextMarker,isFetchingSearch,searchError}),[searchValue,searchQuery,searchResults,searchNextMarker,isFetchingSearch,searchError]);return jsx(SearchStateContext.Provider,{value,children})}var SelectionStateContext=createContext(null);function SelectionStateContextProvider({children,selectedTemplateId}){let value=useMemo(()=>({selectedTemplateId}),[selectedTemplateId]);return jsx(SelectionStateContext.Provider,{value,children})}var ConsumerStateContext=createContext(null),EMPTY_APPLIED_TEMPLATE_IDS=new Set;function ConsumerStateContextProvider({children,isLoading=!1,isDisabled=!1,isNamespacesEnabled=!1,appliedTemplateIds=EMPTY_APPLIED_TEMPLATE_IDS,isTemplateCreationEnabled=!1,isTemplateEditingEnabled=!1}){let value=useMemo(()=>({isLoading,isDisabled,isNamespacesEnabled,appliedTemplateIds,isTemplateCreationEnabled,isTemplateEditingEnabled}),[isLoading,isDisabled,isNamespacesEnabled,appliedTemplateIds,isTemplateCreationEnabled,isTemplateEditingEnabled]);return jsx(ConsumerStateContext.Provider,{value,children})}var BrowserActionsContext=createContext(null);function BrowserActionsContextProvider({children,itemsServiceRef,eventServiceRef,isNamespacesEnabledRef,stateRef,dispatch}){let actions=useTemplateBrowserActions(itemsServiceRef,eventServiceRef,isNamespacesEnabledRef,stateRef,dispatch);return jsx(BrowserActionsContext.Provider,{value:actions,children})}export{BrowseStateContext,BrowseStateContextProvider,BrowserActionsContext,BrowserActionsContextProvider,ConsumerStateContext,ConsumerStateContextProvider,NavigationStateContext,NavigationStateContextProvider,SearchStateContext,SearchStateContextProvider,SelectionStateContext,SelectionStateContextProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useConsumerState,useNavigationState}from"../contexts/hooks.js";function useCanCreateInCurrentNamespace(){let{isTemplateCreationEnabled}=useConsumerState(),{canCreateInCurrentNamespace}=useNavigationState();return isTemplateCreationEnabled&&canCreateInCurrentNamespace}export{useCanCreateInCurrentNamespace};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConsumerStateContextProvider}from"./contexts/contexts.js";import{MetadataTemplateBrowserProvider}from"./contexts/provider.js";import{t as MetadataTemplateBrowserController}from"../../chunks/metadata-template-browser-controller.js";import{TooltipProvider}from"@box/blueprint-web";import{jsx}from"react/jsx-runtime";function MetadataTemplateBrowser({enterpriseId,itemsService,eventService,isLoading,isDisabled,isNamespacesEnabled,initialSelectedTemplateId,initialNavigation,canCreateAtRoot,appliedTemplateIds}){return jsx(TooltipProvider,{children:jsx(ConsumerStateContextProvider,{appliedTemplateIds,isDisabled,isLoading,isNamespacesEnabled,children:jsx(MetadataTemplateBrowserProvider,{namespaceFQN:enterpriseId,itemsService,eventService,initialSelectedTemplateId,initialNavigation,canCreateAtRoot,isNamespacesEnabled,children:jsx(MetadataTemplateBrowserController,{})})})})}export{MetadataTemplateBrowser};
|
|
1
|
+
import{ConsumerStateContextProvider}from"./contexts/contexts.js";import{MetadataTemplateBrowserProvider}from"./contexts/provider.js";import{t as MetadataTemplateBrowserController}from"../../chunks/metadata-template-browser-controller.js";import{TooltipProvider}from"@box/blueprint-web";import{jsx}from"react/jsx-runtime";function MetadataTemplateBrowser({enterpriseId,itemsService,eventService,isLoading,isDisabled,isNamespacesEnabled,initialSelectedTemplateId,initialNavigation,canCreateAtRoot,appliedTemplateIds}){return jsx(TooltipProvider,{children:jsx(ConsumerStateContextProvider,{appliedTemplateIds,isDisabled,isLoading,isNamespacesEnabled,isTemplateCreationEnabled:!!itemsService.createTemplate,isTemplateEditingEnabled:!!itemsService.updateTemplate,children:jsx(MetadataTemplateBrowserProvider,{namespaceFQN:enterpriseId,itemsService,eventService,initialSelectedTemplateId,initialNavigation,canCreateAtRoot,isNamespacesEnabled,children:jsx(MetadataTemplateBrowserController,{})})})})}export{MetadataTemplateBrowser};
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* (disabled) and loading confined to the list region; breadcrumbs stay hidden until
|
|
6
6
|
* the first browse completes.
|
|
7
7
|
*
|
|
8
|
-
* The create-template button appears below the breadcrumb when
|
|
9
|
-
*
|
|
8
|
+
* The create-template button appears below the breadcrumb when creation is offered
|
|
9
|
+
* here (`useCanCreateInCurrentNamespace`), browse mode is active (no search
|
|
10
10
|
* query), no fetch is in progress, and the list is not empty. When the list is empty,
|
|
11
11
|
* `BrowseList` shows its own "Create first template" affordance instead.
|
|
12
12
|
*/
|
|
@@ -36,8 +36,10 @@ export interface ConsumerStateContextProviderProps {
|
|
|
36
36
|
readonly isDisabled?: boolean;
|
|
37
37
|
readonly isNamespacesEnabled?: boolean;
|
|
38
38
|
readonly appliedTemplateIds?: ReadonlySet<string>;
|
|
39
|
+
readonly isTemplateCreationEnabled?: boolean;
|
|
40
|
+
readonly isTemplateEditingEnabled?: boolean;
|
|
39
41
|
}
|
|
40
|
-
export declare function ConsumerStateContextProvider({ children, isLoading, isDisabled, isNamespacesEnabled, appliedTemplateIds, }: Readonly<ConsumerStateContextProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare function ConsumerStateContextProvider({ children, isLoading, isDisabled, isNamespacesEnabled, appliedTemplateIds, isTemplateCreationEnabled, isTemplateEditingEnabled, }: Readonly<ConsumerStateContextProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
41
43
|
/** Exposes all browser action creators (navigate, search, select, retry, etc.) to the component tree. */
|
|
42
44
|
export declare const BrowserActionsContext: import('react').Context<BrowserActionsContextValue | null>;
|
|
43
45
|
interface BrowserActionsContextProviderProps {
|
|
@@ -5,6 +5,7 @@ export interface MetadataTemplateBrowserProps {
|
|
|
5
5
|
/**
|
|
6
6
|
* Data service implementation: reads for namespaces, templates, and search, plus the
|
|
7
7
|
* optional create and update operations that back the browser's own affordances.
|
|
8
|
+
* Omit both operations for a selection-only browser.
|
|
8
9
|
*/
|
|
9
10
|
itemsService: ItemsService;
|
|
10
11
|
/** Observer callbacks invoked on state transitions (namespace change, search, template selection). */
|
|
@@ -32,8 +33,7 @@ export interface MetadataTemplateBrowserProps {
|
|
|
32
33
|
initialNavigation?: BrowserNavigation;
|
|
33
34
|
/**
|
|
34
35
|
* Whether template creation is allowed at the root (enterprise) namespace.
|
|
35
|
-
*
|
|
36
|
-
* button is shown below the breadcrumb in browse mode.
|
|
36
|
+
* Has no effect unless `itemsService.createTemplate` is provided.
|
|
37
37
|
* @default false
|
|
38
38
|
*/
|
|
39
39
|
canCreateAtRoot?: boolean;
|
|
@@ -47,9 +47,9 @@ export interface CreateMockItemsServiceOptions {
|
|
|
47
47
|
errors?: Partial<Record<ItemsServiceMethod, ErrorConfig>>;
|
|
48
48
|
/** Throws only on paginated calls (when a marker is present) to the given method. */
|
|
49
49
|
loadMoreErrors?: Partial<Record<ItemsServiceMethod, Error | string>>;
|
|
50
|
-
/** Optional create operation; omit to
|
|
50
|
+
/** Optional create operation; omit to hide create affordances regardless of `canCreate`. */
|
|
51
51
|
createTemplate?: ItemsService['createTemplate'];
|
|
52
|
-
/** Optional update operation; omit to
|
|
52
|
+
/** Optional update operation; omit to hide row edit regardless of `canEdit`. */
|
|
53
53
|
updateTemplate?: ItemsService['updateTemplate'];
|
|
54
54
|
}
|
|
55
55
|
export declare const DEFAULT_TEMPLATES_BY_FQN: Record<string, MetadataTemplate[]>;
|
|
@@ -61,16 +61,15 @@ export interface ItemsService {
|
|
|
61
61
|
* create UI unmounts the browser store it and pass it back as
|
|
62
62
|
* `initialNavigation` so the next mount opens at the same place.
|
|
63
63
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* they appear.
|
|
64
|
+
* Omit to hide every create-template affordance. When provided,
|
|
65
|
+
* `canCreateAtRoot` and `MetadataNamespace.canCreate` decide where they appear.
|
|
67
66
|
*/
|
|
68
67
|
createTemplate?: (namespaceFQN: string, navigation: BrowserNavigation) => Promise<MetadataTemplate | undefined>;
|
|
69
68
|
/**
|
|
70
69
|
* Updates the template identified by `templateId` under the same contract as
|
|
71
70
|
* `createTemplate`, resolving with the updated template or `undefined`.
|
|
72
71
|
*
|
|
73
|
-
*
|
|
72
|
+
* Omit to hide the row edit affordance. When provided,
|
|
74
73
|
* `MetadataTemplate.canEdit` decides which rows show it.
|
|
75
74
|
*/
|
|
76
75
|
updateTemplate?: (templateId: string, navigation: BrowserNavigation) => Promise<MetadataTemplate | undefined>;
|
|
@@ -151,6 +150,10 @@ export interface ConsumerStateContextValue {
|
|
|
151
150
|
isNamespacesEnabled: boolean;
|
|
152
151
|
/** Set of template IDs that are already applied and should be shown as disabled with a tooltip. */
|
|
153
152
|
appliedTemplateIds: ReadonlySet<string>;
|
|
153
|
+
/** True when `itemsService.createTemplate` is provided. Permission flags still decide where create appears. */
|
|
154
|
+
isTemplateCreationEnabled: boolean;
|
|
155
|
+
/** True when `itemsService.updateTemplate` is provided. `MetadataTemplate.canEdit` still decides per row. */
|
|
156
|
+
isTemplateEditingEnabled: boolean;
|
|
154
157
|
}
|
|
155
158
|
export interface BrowserActionsContextValue {
|
|
156
159
|
/** Fetches the root level on mount: namespaces and templates under the enterprise FQN. */
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-template-browser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@box/blueprint-web": "^18.9.
|
|
7
|
-
"@box/blueprint-web-assets": "^5.
|
|
6
|
+
"@box/blueprint-web": "^18.9.3",
|
|
7
|
+
"@box/blueprint-web-assets": "^5.14.0",
|
|
8
8
|
"lodash": "^4.17.15",
|
|
9
9
|
"react": "^18.0.0",
|
|
10
10
|
"react-aria-components": "1.16.0",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"react-intl": "^6.4.2"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@box/blueprint-web": "^18.9.
|
|
16
|
-
"@box/blueprint-web-assets": "^5.
|
|
15
|
+
"@box/blueprint-web": "^18.9.3",
|
|
16
|
+
"@box/blueprint-web-assets": "^5.14.0",
|
|
17
17
|
"@box/eslint-plugin-blueprint": "2.3.2",
|
|
18
|
-
"@box/storybook-utils": "1.4.
|
|
18
|
+
"@box/storybook-utils": "1.4.30",
|
|
19
19
|
"react-intl": "^6.4.2"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|