@box/metadata-template-browser 1.16.3
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/LICENSE +379 -0
- package/README.md +57 -0
- package/dist/chunks/types.js +6 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/lib/components/breadcrumb-navigation/breadcrumb-navigation.js +51 -0
- package/dist/esm/lib/components/breadcrumb-navigation/index.js +4 -0
- package/dist/esm/lib/components/breadcrumb-navigation/messages.js +18 -0
- package/dist/esm/lib/components/browse-list/browse-list.js +83 -0
- package/dist/esm/lib/components/browse-list/index.js +4 -0
- package/dist/esm/lib/components/browse-list/messages.js +18 -0
- package/dist/esm/lib/components/browser-row/browser-row.js +63 -0
- package/dist/esm/lib/components/browser-row/index.js +4 -0
- package/dist/esm/lib/components/error-state/error-state.js +32 -0
- package/dist/esm/lib/components/error-state/index.js +4 -0
- package/dist/esm/lib/components/error-state/messages.js +10 -0
- package/dist/esm/lib/components/index.js +24 -0
- package/dist/esm/lib/components/load-more-feedback/index.js +6 -0
- package/dist/esm/lib/components/load-more-feedback/load-more-error-row.js +44 -0
- package/dist/esm/lib/components/load-more-feedback/load-more-loading-row.js +34 -0
- package/dist/esm/lib/components/load-more-feedback/messages.js +22 -0
- package/dist/esm/lib/components/loader-skeleton/index.js +4 -0
- package/dist/esm/lib/components/loader-skeleton/loader-skeleton.js +26 -0
- package/dist/esm/lib/components/messages.js +30 -0
- package/dist/esm/lib/components/metadata-template-browser-container.js +35 -0
- package/dist/esm/lib/components/metadata-template-browser-controller.js +58 -0
- package/dist/esm/lib/components/metadata-template-browser-list-box/index.js +4 -0
- package/dist/esm/lib/components/metadata-template-browser-list-box/metadata-template-browser-list-box.js +65 -0
- package/dist/esm/lib/components/namespace-row/index.js +4 -0
- package/dist/esm/lib/components/namespace-row/messages.js +10 -0
- package/dist/esm/lib/components/namespace-row/namespace-row.js +32 -0
- package/dist/esm/lib/components/search-list/index.js +4 -0
- package/dist/esm/lib/components/search-list/messages.js +22 -0
- package/dist/esm/lib/components/search-list/search-list.js +76 -0
- package/dist/esm/lib/components/template-row/index.js +4 -0
- package/dist/esm/lib/components/template-row/messages.js +10 -0
- package/dist/esm/lib/components/template-row/template-row.js +70 -0
- package/dist/esm/lib/components/virtualized-grid-list/grid-list-load-more-sentinel.js +49 -0
- package/dist/esm/lib/components/virtualized-grid-list/index.js +4 -0
- package/dist/esm/lib/components/virtualized-grid-list/messages.js +10 -0
- package/dist/esm/lib/components/virtualized-grid-list/virtualized-grid-list.js +66 -0
- package/dist/esm/lib/constants.js +14 -0
- package/dist/esm/lib/contexts/contexts.js +129 -0
- package/dist/esm/lib/contexts/hooks.js +46 -0
- package/dist/esm/lib/contexts/index.js +17 -0
- package/dist/esm/lib/contexts/provider.js +59 -0
- package/dist/esm/lib/contexts/reducer.js +180 -0
- package/dist/esm/lib/contexts/use-template-browser-actions.js +263 -0
- package/dist/esm/lib/hooks/use-is-initial-browse-loading.js +16 -0
- package/dist/esm/lib/metadata-template-browser.js +27 -0
- package/dist/i18n/bn-IN.js +26 -0
- package/dist/i18n/bn-IN.properties +48 -0
- package/dist/i18n/da-DK.js +26 -0
- package/dist/i18n/da-DK.properties +48 -0
- package/dist/i18n/de-DE.js +26 -0
- package/dist/i18n/de-DE.properties +48 -0
- package/dist/i18n/en-AU.js +26 -0
- package/dist/i18n/en-AU.properties +48 -0
- package/dist/i18n/en-CA.js +26 -0
- package/dist/i18n/en-CA.properties +48 -0
- package/dist/i18n/en-GB.js +26 -0
- package/dist/i18n/en-GB.properties +48 -0
- package/dist/i18n/en-US.js +26 -0
- package/dist/i18n/en-US.properties +48 -0
- package/dist/i18n/en-x-pseudo.js +26 -0
- package/dist/i18n/en-x-pseudo.properties +48 -0
- package/dist/i18n/es-419.js +26 -0
- package/dist/i18n/es-419.properties +48 -0
- package/dist/i18n/es-ES.js +26 -0
- package/dist/i18n/es-ES.properties +48 -0
- package/dist/i18n/fi-FI.js +26 -0
- package/dist/i18n/fi-FI.properties +48 -0
- package/dist/i18n/fr-CA.js +26 -0
- package/dist/i18n/fr-CA.properties +48 -0
- package/dist/i18n/fr-FR.js +26 -0
- package/dist/i18n/fr-FR.properties +48 -0
- package/dist/i18n/hi-IN.js +26 -0
- package/dist/i18n/hi-IN.properties +48 -0
- package/dist/i18n/it-IT.js +26 -0
- package/dist/i18n/it-IT.properties +48 -0
- package/dist/i18n/ja-JP.js +26 -0
- package/dist/i18n/ja-JP.properties +48 -0
- package/dist/i18n/json/src/lib/components/breadcrumb-navigation/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/browse-list/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/error-state/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/load-more-feedback/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/namespace-row/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/search-list/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/template-row/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/virtualized-grid-list/messages.json +1 -0
- package/dist/i18n/ko-KR.js +26 -0
- package/dist/i18n/ko-KR.properties +48 -0
- package/dist/i18n/nb-NO.js +26 -0
- package/dist/i18n/nb-NO.properties +48 -0
- package/dist/i18n/nl-NL.js +26 -0
- package/dist/i18n/nl-NL.properties +48 -0
- package/dist/i18n/pl-PL.js +26 -0
- package/dist/i18n/pl-PL.properties +48 -0
- package/dist/i18n/pt-BR.js +26 -0
- package/dist/i18n/pt-BR.properties +48 -0
- package/dist/i18n/ru-RU.js +26 -0
- package/dist/i18n/ru-RU.properties +48 -0
- package/dist/i18n/sv-SE.js +26 -0
- package/dist/i18n/sv-SE.properties +48 -0
- package/dist/i18n/tr-TR.js +26 -0
- package/dist/i18n/tr-TR.properties +48 -0
- package/dist/i18n/zh-CN.js +26 -0
- package/dist/i18n/zh-CN.properties +48 -0
- package/dist/i18n/zh-TW.js +26 -0
- package/dist/i18n/zh-TW.properties +48 -0
- package/dist/styles/breadcrumb-navigation.css +1 -0
- package/dist/styles/browser-row.css +1 -0
- package/dist/styles/grid-list-load-more-sentinel.css +1 -0
- package/dist/styles/load-more-error-row.css +1 -0
- package/dist/styles/load-more-loading-row.css +1 -0
- package/dist/styles/loader-skeleton.css +1 -0
- package/dist/styles/metadata-template-browser-container.css +1 -0
- package/dist/styles/metadata-template-browser-controller.css +1 -0
- package/dist/styles/metadata-template-browser-list-box.css +1 -0
- package/dist/styles/virtualized-grid-list.css +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/lib/components/breadcrumb-navigation/breadcrumb-navigation.d.ts +12 -0
- package/dist/types/lib/components/breadcrumb-navigation/index.d.ts +1 -0
- package/dist/types/lib/components/breadcrumb-navigation/messages.d.ts +17 -0
- package/dist/types/lib/components/browse-list/browse-list.d.ts +23 -0
- package/dist/types/lib/components/browse-list/index.d.ts +2 -0
- package/dist/types/lib/components/browse-list/messages.d.ts +17 -0
- package/dist/types/lib/components/browser-row/browser-row.d.ts +25 -0
- package/dist/types/lib/components/browser-row/index.d.ts +1 -0
- package/dist/types/lib/components/error-state/error-state.d.ts +11 -0
- package/dist/types/lib/components/error-state/index.d.ts +2 -0
- package/dist/types/lib/components/error-state/messages.d.ts +7 -0
- package/dist/types/lib/components/index.d.ts +15 -0
- package/dist/types/lib/components/load-more-feedback/index.d.ts +2 -0
- package/dist/types/lib/components/load-more-feedback/load-more-error-row.d.ts +10 -0
- package/dist/types/lib/components/load-more-feedback/load-more-loading-row.d.ts +6 -0
- package/dist/types/lib/components/load-more-feedback/messages.d.ts +22 -0
- package/dist/types/lib/components/loader-skeleton/index.d.ts +1 -0
- package/dist/types/lib/components/loader-skeleton/loader-skeleton.d.ts +5 -0
- package/dist/types/lib/components/messages.d.ts +32 -0
- package/dist/types/lib/components/metadata-template-browser-container.d.ts +8 -0
- package/dist/types/lib/components/metadata-template-browser-controller.d.ts +11 -0
- package/dist/types/lib/components/metadata-template-browser-list-box/index.d.ts +1 -0
- package/dist/types/lib/components/metadata-template-browser-list-box/metadata-template-browser-list-box.d.ts +6 -0
- package/dist/types/lib/components/namespace-row/index.d.ts +2 -0
- package/dist/types/lib/components/namespace-row/messages.d.ts +7 -0
- package/dist/types/lib/components/namespace-row/namespace-row.d.ts +10 -0
- package/dist/types/lib/components/search-list/index.d.ts +2 -0
- package/dist/types/lib/components/search-list/messages.d.ts +22 -0
- package/dist/types/lib/components/search-list/search-list.d.ts +12 -0
- package/dist/types/lib/components/template-row/index.d.ts +2 -0
- package/dist/types/lib/components/template-row/messages.d.ts +7 -0
- package/dist/types/lib/components/template-row/template-row.d.ts +19 -0
- package/dist/types/lib/components/virtualized-grid-list/grid-list-load-more-sentinel.d.ts +15 -0
- package/dist/types/lib/components/virtualized-grid-list/index.d.ts +2 -0
- package/dist/types/lib/components/virtualized-grid-list/messages.d.ts +7 -0
- package/dist/types/lib/components/virtualized-grid-list/virtualized-grid-list.d.ts +37 -0
- package/dist/types/lib/constants.d.ts +8 -0
- package/dist/types/lib/contexts/contexts.d.ts +47 -0
- package/dist/types/lib/contexts/hooks.d.ts +13 -0
- package/dist/types/lib/contexts/index.d.ts +7 -0
- package/dist/types/lib/contexts/provider.d.ts +14 -0
- package/dist/types/lib/contexts/reducer.d.ts +106 -0
- package/dist/types/lib/contexts/use-template-browser-actions.d.ts +9 -0
- package/dist/types/lib/hooks/use-is-initial-browse-loading.d.ts +7 -0
- package/dist/types/lib/metadata-template-browser.d.ts +23 -0
- package/dist/types/lib/stories/shared/constants.d.ts +16 -0
- package/dist/types/lib/stories/shared/create-mock-event-service.d.ts +2 -0
- package/dist/types/lib/stories/shared/create-mock-items-service.d.ts +53 -0
- package/dist/types/lib/stories/shared/generate-namespaces.d.ts +6 -0
- package/dist/types/lib/stories/shared/generate-templates.d.ts +8 -0
- package/dist/types/lib/stories/shared/index.d.ts +8 -0
- package/dist/types/lib/stories/shared/paginate-items.d.ts +2 -0
- package/dist/types/lib/stories/shared/story-container.d.ts +5 -0
- package/dist/types/lib/stories/shared/story-interaction-helpers.d.ts +30 -0
- package/dist/types/lib/types.d.ts +116 -0
- package/package.json +49 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BreadcrumbEntry, LevelCache, MetadataNamespace, MetadataTemplate } from '../types';
|
|
2
|
+
export declare enum BrowserActionType {
|
|
3
|
+
NavigateTo = "NAVIGATE_TO",
|
|
4
|
+
NavigateBack = "NAVIGATE_BACK",
|
|
5
|
+
BrowseFetchStart = "BROWSE_FETCH_START",
|
|
6
|
+
BrowseLoaded = "BROWSE_LOADED",
|
|
7
|
+
InitialLoadError = "INITIAL_LOAD_ERROR",
|
|
8
|
+
BrowseError = "BROWSE_ERROR",
|
|
9
|
+
LoadMoreStart = "LOAD_MORE_START",
|
|
10
|
+
LoadMoreNamespacesLoaded = "LOAD_MORE_NAMESPACES_LOADED",
|
|
11
|
+
LoadMoreTemplatesLoaded = "LOAD_MORE_TEMPLATES_LOADED",
|
|
12
|
+
LoadMoreError = "LOAD_MORE_ERROR",
|
|
13
|
+
SearchValueChange = "SEARCH_VALUE_CHANGE",
|
|
14
|
+
SearchFetchStart = "SEARCH_FETCH_START",
|
|
15
|
+
SearchLoaded = "SEARCH_LOADED",
|
|
16
|
+
SearchError = "SEARCH_ERROR",
|
|
17
|
+
SearchClear = "SEARCH_CLEAR",
|
|
18
|
+
LoadMoreSearchLoaded = "LOAD_MORE_SEARCH_LOADED",
|
|
19
|
+
TemplateSelect = "TEMPLATE_SELECT"
|
|
20
|
+
}
|
|
21
|
+
/** Complete reducer state for the metadata template browser, split into navigation, browse, search, and selection slices. */
|
|
22
|
+
export interface BrowserState {
|
|
23
|
+
namespaceFQN: string;
|
|
24
|
+
path: BreadcrumbEntry[];
|
|
25
|
+
namespaces: MetadataNamespace[];
|
|
26
|
+
templates: MetadataTemplate[];
|
|
27
|
+
isNamespacesExhausted: boolean;
|
|
28
|
+
namespaceNextMarker: string | undefined;
|
|
29
|
+
templateNextMarker: string | undefined;
|
|
30
|
+
isFetching: boolean;
|
|
31
|
+
isFetchingMore: boolean;
|
|
32
|
+
initialLoadError: string | null;
|
|
33
|
+
browseError: string | null;
|
|
34
|
+
loadMoreError: string | null;
|
|
35
|
+
searchValue: string;
|
|
36
|
+
searchQuery: string;
|
|
37
|
+
searchResults: MetadataTemplate[];
|
|
38
|
+
searchNextMarker: string | undefined;
|
|
39
|
+
isFetchingSearch: boolean;
|
|
40
|
+
searchError: string | null;
|
|
41
|
+
selectedTemplateId: string | null;
|
|
42
|
+
}
|
|
43
|
+
/** Union of all dispatchable actions that drive `BrowserState` transitions. */
|
|
44
|
+
export type BrowserAction = {
|
|
45
|
+
type: BrowserActionType.NavigateTo;
|
|
46
|
+
namespace: MetadataNamespace;
|
|
47
|
+
} | {
|
|
48
|
+
type: BrowserActionType.NavigateBack;
|
|
49
|
+
fqn: string;
|
|
50
|
+
cached: LevelCache;
|
|
51
|
+
} | {
|
|
52
|
+
type: BrowserActionType.BrowseFetchStart;
|
|
53
|
+
} | {
|
|
54
|
+
type: BrowserActionType.BrowseLoaded;
|
|
55
|
+
namespaces: MetadataNamespace[];
|
|
56
|
+
namespaceNextMarker?: string;
|
|
57
|
+
templates: MetadataTemplate[];
|
|
58
|
+
templateNextMarker?: string;
|
|
59
|
+
} | {
|
|
60
|
+
type: BrowserActionType.InitialLoadError;
|
|
61
|
+
error: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: BrowserActionType.BrowseError;
|
|
64
|
+
error: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: BrowserActionType.LoadMoreStart;
|
|
67
|
+
} | {
|
|
68
|
+
type: BrowserActionType.LoadMoreNamespacesLoaded;
|
|
69
|
+
entries: MetadataNamespace[];
|
|
70
|
+
nextMarker?: string;
|
|
71
|
+
/** First page of templates, populated only when namespaces become exhausted on this page. */
|
|
72
|
+
templates?: MetadataTemplate[];
|
|
73
|
+
templateNextMarker?: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: BrowserActionType.LoadMoreTemplatesLoaded;
|
|
76
|
+
entries: MetadataTemplate[];
|
|
77
|
+
nextMarker?: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: BrowserActionType.LoadMoreError;
|
|
80
|
+
error: string;
|
|
81
|
+
} | {
|
|
82
|
+
type: BrowserActionType.SearchValueChange;
|
|
83
|
+
value: string;
|
|
84
|
+
} | {
|
|
85
|
+
type: BrowserActionType.SearchFetchStart;
|
|
86
|
+
query: string;
|
|
87
|
+
} | {
|
|
88
|
+
type: BrowserActionType.SearchLoaded;
|
|
89
|
+
results: MetadataTemplate[];
|
|
90
|
+
nextMarker?: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: BrowserActionType.SearchError;
|
|
93
|
+
error: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: BrowserActionType.SearchClear;
|
|
96
|
+
} | {
|
|
97
|
+
type: BrowserActionType.LoadMoreSearchLoaded;
|
|
98
|
+
entries: MetadataTemplate[];
|
|
99
|
+
nextMarker?: string;
|
|
100
|
+
} | {
|
|
101
|
+
type: BrowserActionType.TemplateSelect;
|
|
102
|
+
template: MetadataTemplate;
|
|
103
|
+
};
|
|
104
|
+
export declare const initialState: BrowserState;
|
|
105
|
+
/** Pure reducer for `BrowserState`. */
|
|
106
|
+
export declare function browserReducer(state: BrowserState, action: BrowserAction): BrowserState;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { BrowserActionsContextValue, EventService, ItemsService, LevelCache } from '../types';
|
|
3
|
+
import { BrowserAction, BrowserState } from './reducer';
|
|
4
|
+
/**
|
|
5
|
+
* Returns a stable memoized object of all browser action creators.
|
|
6
|
+
* Services and state are accessed via refs to avoid recreating actions on
|
|
7
|
+
* every render. Consumed exclusively by `BrowserActionsContextProvider`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useTemplateBrowserActions(itemsServiceRef: MutableRefObject<ItemsService>, eventServiceRef: MutableRefObject<EventService>, stateRef: MutableRefObject<BrowserState>, dispatch: React.Dispatch<BrowserAction>, levelCache: MutableRefObject<Map<string, LevelCache>>): BrowserActionsContextValue;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True while the template browser cannot show meaningful browse rows yet: the
|
|
3
|
+
* consumer is still loading external data, or the root-level browse fetch is in
|
|
4
|
+
* flight before any namespace or template rows exist. Used to keep search chrome
|
|
5
|
+
* visible (disabled) and show loading only in the list region.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useIsInitialBrowseLoading(): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EventService, ItemsService } from './types';
|
|
2
|
+
export interface MetadataTemplateBrowserProps {
|
|
3
|
+
/** Enterprise ID used as the root namespace FQN (e.g. "enterprise_123"). */
|
|
4
|
+
enterpriseId: string;
|
|
5
|
+
/** Data-fetching service implementation for namespaces, templates, and search. */
|
|
6
|
+
itemsService: ItemsService;
|
|
7
|
+
/** Observer callbacks invoked on state transitions (namespace change, search, template selection, template edit). */
|
|
8
|
+
eventService: EventService;
|
|
9
|
+
/**
|
|
10
|
+
* When true, suppresses the initial data fetch and shows loading in the list
|
|
11
|
+
* region only (search stays visible and disabled; breadcrumbs hidden until load completes).
|
|
12
|
+
*/
|
|
13
|
+
isLoading?: boolean;
|
|
14
|
+
/** When true, disables the search input and all row interactions. */
|
|
15
|
+
isDisabled?: boolean;
|
|
16
|
+
/** Template ID to auto-select after the initial load completes. */
|
|
17
|
+
initialSelectedTemplateId?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Public entry point for the metadata template browser.
|
|
21
|
+
* Wraps the provider and controller into a single composable component.
|
|
22
|
+
*/
|
|
23
|
+
export declare function MetadataTemplateBrowser({ enterpriseId, itemsService, eventService, isLoading, isDisabled, initialSelectedTemplateId, }: Readonly<MetadataTemplateBrowserProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BreadcrumbEntry, MetadataNamespace } from '../../types';
|
|
2
|
+
export declare const ROOT_NAMESPACE = "enterprise_123";
|
|
3
|
+
export declare const DEFAULT_SCOPE = "enterprise_123";
|
|
4
|
+
export declare const LEGAL_FQN = "enterprise_123.legal";
|
|
5
|
+
export declare const CONTRACTS_FQN = "enterprise_123.legal.contracts";
|
|
6
|
+
export declare const NAMESPACE_DOMAINS: string[];
|
|
7
|
+
export declare const TEMPLATE_AREAS: string[];
|
|
8
|
+
export interface DefaultTemplateSpec {
|
|
9
|
+
count: number;
|
|
10
|
+
canEdit?: boolean | ((index: number) => boolean);
|
|
11
|
+
}
|
|
12
|
+
export declare const toTitleCase: (value: string) => string;
|
|
13
|
+
export declare const getNamespaceDisplayName: (namespaceFqn: string) => string;
|
|
14
|
+
export declare const DEFAULT_NAMESPACES_BY_FQN: Record<string, MetadataNamespace[]>;
|
|
15
|
+
export declare const DEFAULT_TEMPLATE_SPECS_BY_FQN: Record<string, DefaultTemplateSpec>;
|
|
16
|
+
export declare const createAncestors: (namespace: string) => BreadcrumbEntry[];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ItemsService, MetadataNamespace, MetadataTemplate } from '../../types';
|
|
2
|
+
type ItemsServiceMethod = 'getNamespaces' | 'getTemplates' | 'getSearchResults';
|
|
3
|
+
/**
|
|
4
|
+
* Returns an error for a given call or null/undefined to let it succeed.
|
|
5
|
+
* Receives a 0-based call index that increments on every call to the method.
|
|
6
|
+
*/
|
|
7
|
+
type ErrorResolver = (callIndex: number) => Error | string | null | undefined;
|
|
8
|
+
/** Static error (always throws) or a per-call resolver function. */
|
|
9
|
+
type ErrorConfig = Error | string | ErrorResolver;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the latency in milliseconds for a given call.
|
|
12
|
+
* Receives a 0-based call index that increments on every call to the method.
|
|
13
|
+
* Return 0 to skip the delay for that call.
|
|
14
|
+
*/
|
|
15
|
+
type LatencyResolver = (callIndex: number) => number;
|
|
16
|
+
export interface CreateMockItemsServiceOptions {
|
|
17
|
+
/** Global latency applied to all methods. Defaults to 0. */
|
|
18
|
+
latency?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Per-method latency overrides. Takes precedence over the global `latency`.
|
|
21
|
+
* Use a LatencyResolver to vary the delay per call (0-based call index).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // First call slow (e.g. initial search), all subsequent calls instant:
|
|
25
|
+
* latencyPerCall: { getSearchResults: callIndex => callIndex === 0 ? 500 : 0 }
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Method always slow (e.g. to hold in loading state):
|
|
29
|
+
* latencyPerCall: { getSearchResults: () => 999999 }
|
|
30
|
+
*/
|
|
31
|
+
latencyPerCall?: Partial<Record<ItemsServiceMethod, LatencyResolver>>;
|
|
32
|
+
namespacesByFqn?: Record<string, MetadataNamespace[]>;
|
|
33
|
+
templatesByFqn?: Record<string, MetadataTemplate[]>;
|
|
34
|
+
searchResultsByQuery?: Record<string, MetadataTemplate[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Configures errors for each method. Pass a string or Error to always throw,
|
|
37
|
+
* or an ErrorResolver function to control behavior per call (0-based call index).
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Always fail:
|
|
41
|
+
* errors: { getNamespaces: 'Network error' }
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Fail only the first call (e.g. to test retry recovery):
|
|
45
|
+
* errors: { getNamespaces: callIndex => callIndex === 0 ? 'Network error' : null }
|
|
46
|
+
*/
|
|
47
|
+
errors?: Partial<Record<ItemsServiceMethod, ErrorConfig>>;
|
|
48
|
+
/** Throws only on paginated calls (when a marker is present) to the given method. */
|
|
49
|
+
loadMoreErrors?: Partial<Record<ItemsServiceMethod, Error | string>>;
|
|
50
|
+
}
|
|
51
|
+
export declare const DEFAULT_TEMPLATES_BY_FQN: Record<string, MetadataTemplate[]>;
|
|
52
|
+
export declare const createMockItemsService: (options?: CreateMockItemsServiceOptions) => ItemsService;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BreadcrumbEntry, MetadataTemplate } from '../../types';
|
|
2
|
+
export interface GenerateTemplatesOptions {
|
|
3
|
+
namespace?: string;
|
|
4
|
+
canEdit?: boolean | ((index: number) => boolean);
|
|
5
|
+
ancestors?: BreadcrumbEntry[] | ((index: number) => BreadcrumbEntry[]);
|
|
6
|
+
}
|
|
7
|
+
export declare const createTemplate: (overrides?: Partial<MetadataTemplate>) => MetadataTemplate;
|
|
8
|
+
export declare const generateTemplates: (count: number, options?: GenerateTemplatesOptions) => MetadataTemplate[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './story-interaction-helpers';
|
|
3
|
+
export * from './create-mock-event-service';
|
|
4
|
+
export * from './create-mock-items-service';
|
|
5
|
+
export * from './generate-namespaces';
|
|
6
|
+
export * from './generate-templates';
|
|
7
|
+
export * from './paginate-items';
|
|
8
|
+
export * from './story-container';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { within } from 'storybook/test';
|
|
2
|
+
/**
|
|
3
|
+
* Return type of `within(canvasElement)` in story `play` functions — bound Testing Library queries.
|
|
4
|
+
*/
|
|
5
|
+
export type StoryPlayCanvas = ReturnType<typeof within>;
|
|
6
|
+
/**
|
|
7
|
+
* Small delay between keystrokes so controlled inputs and lodash debounce behave consistently
|
|
8
|
+
* under Playwright’s headless Chromium on CI (Linux), where zero-delay typing can batch oddly.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SEARCH_INPUT_KEY_DELAY_MS = 15;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves when the search field exists and is interactive. While initial browse (or consumer
|
|
13
|
+
* loading) is in flight, the input stays `disabled`; `findByRole('searchbox')` alone returns too
|
|
14
|
+
* early on slow CI. `focusAndTypeInSearchBox` calls this automatically; import it only for
|
|
15
|
+
* stories that assert loaded chrome (e.g. search enabled) without going through that helper.
|
|
16
|
+
*/
|
|
17
|
+
export declare function waitForSearchBoxInteractive(canvas: StoryPlayCanvas): Promise<HTMLElement>;
|
|
18
|
+
/**
|
|
19
|
+
* Waits for an interactive search box, focuses the field, types with a stable per-key delay,
|
|
20
|
+
* then returns the searchbox for follow-up typing (e.g. appending to the same field).
|
|
21
|
+
*/
|
|
22
|
+
export declare function focusAndTypeInSearchBox(canvas: StoryPlayCanvas, text: string): Promise<HTMLElement>;
|
|
23
|
+
/**
|
|
24
|
+
* Waits for the search-results grid after debounced search has run.
|
|
25
|
+
*/
|
|
26
|
+
export declare function findSearchResultsGrid(canvas: StoryPlayCanvas): Promise<HTMLElement>;
|
|
27
|
+
/**
|
|
28
|
+
* Waits for the list loading region shown during an in-flight search.
|
|
29
|
+
*/
|
|
30
|
+
export declare function findLoadingTemplatesStatus(canvas: StoryPlayCanvas): Promise<HTMLElement>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export declare enum TemplateRowVariant {
|
|
2
|
+
Browse = "browse",
|
|
3
|
+
Search = "search"
|
|
4
|
+
}
|
|
5
|
+
export interface MetadataNamespace {
|
|
6
|
+
id: string;
|
|
7
|
+
displayName: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MetadataTemplate {
|
|
10
|
+
id: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
copyInstanceOnItemCopy?: boolean;
|
|
13
|
+
displayName: string;
|
|
14
|
+
fields?: MetadataField[];
|
|
15
|
+
hidden?: boolean;
|
|
16
|
+
scope?: string;
|
|
17
|
+
templateKey?: string;
|
|
18
|
+
namespace?: string;
|
|
19
|
+
canEdit?: boolean;
|
|
20
|
+
ancestors?: BreadcrumbEntry[];
|
|
21
|
+
}
|
|
22
|
+
export interface MetadataField {
|
|
23
|
+
id: string;
|
|
24
|
+
type?: MetadataFieldType;
|
|
25
|
+
description?: string;
|
|
26
|
+
displayName: string;
|
|
27
|
+
hidden?: boolean;
|
|
28
|
+
key: string;
|
|
29
|
+
options?: MetadataFieldOption[] | null;
|
|
30
|
+
}
|
|
31
|
+
export type MetadataFieldType = 'date' | 'enum' | 'float' | 'integer' | 'multiSelect' | 'string' | 'taxonomy';
|
|
32
|
+
export interface MetadataFieldOption {
|
|
33
|
+
id: string;
|
|
34
|
+
key: string;
|
|
35
|
+
}
|
|
36
|
+
export interface FetchParams {
|
|
37
|
+
limit: number;
|
|
38
|
+
marker?: string;
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}
|
|
41
|
+
export interface FetchResponse<T> {
|
|
42
|
+
entries: T[];
|
|
43
|
+
next_marker?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ItemsService {
|
|
46
|
+
getNamespaces?: (namespaceFQN: string, params: FetchParams) => Promise<FetchResponse<MetadataNamespace>>;
|
|
47
|
+
getTemplates?: (namespaceFQN: string, params: FetchParams) => Promise<FetchResponse<MetadataTemplate>>;
|
|
48
|
+
getSearchResults?: (query: string, params: FetchParams) => Promise<FetchResponse<MetadataTemplate>>;
|
|
49
|
+
}
|
|
50
|
+
export interface EventService {
|
|
51
|
+
onNamespaceChange?: (namespaceFQN: string) => Promise<void>;
|
|
52
|
+
onSearchChange?: (query: string) => Promise<void>;
|
|
53
|
+
onTemplateSelect?: (template: MetadataTemplate) => Promise<void>;
|
|
54
|
+
onTemplateEdit?: (templateId: string) => void;
|
|
55
|
+
}
|
|
56
|
+
export interface BreadcrumbEntry {
|
|
57
|
+
fqn: string;
|
|
58
|
+
displayName: string;
|
|
59
|
+
}
|
|
60
|
+
export interface SearchStateContextValue {
|
|
61
|
+
searchValue: string;
|
|
62
|
+
searchQuery: string;
|
|
63
|
+
searchResults: MetadataTemplate[];
|
|
64
|
+
searchNextMarker: string | undefined;
|
|
65
|
+
isFetchingSearch: boolean;
|
|
66
|
+
searchError: string | null;
|
|
67
|
+
}
|
|
68
|
+
export interface NavigationStateContextValue {
|
|
69
|
+
namespaceFQN: string;
|
|
70
|
+
path: BreadcrumbEntry[];
|
|
71
|
+
}
|
|
72
|
+
export interface BrowseStateContextValue {
|
|
73
|
+
namespaces: MetadataNamespace[];
|
|
74
|
+
templates: MetadataTemplate[];
|
|
75
|
+
isNamespacesExhausted: boolean;
|
|
76
|
+
namespaceNextMarker: string | undefined;
|
|
77
|
+
templateNextMarker: string | undefined;
|
|
78
|
+
isFetching: boolean;
|
|
79
|
+
isFetchingMore: boolean;
|
|
80
|
+
initialLoadError: string | null;
|
|
81
|
+
browseError: string | null;
|
|
82
|
+
loadMoreError: string | null;
|
|
83
|
+
}
|
|
84
|
+
export interface SelectionStateContextValue {
|
|
85
|
+
selectedTemplateId: string | null;
|
|
86
|
+
}
|
|
87
|
+
/** Embedding-app flags: consumer loading gate and global interaction disabled (e.g. submit). */
|
|
88
|
+
export interface ConsumerStateContextValue {
|
|
89
|
+
isLoading: boolean;
|
|
90
|
+
isDisabled: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface BrowserActionsContextValue {
|
|
93
|
+
/** Fetches the root level on mount: namespaces and templates under the enterprise FQN. */
|
|
94
|
+
initialLoad: () => Promise<void>;
|
|
95
|
+
/** Navigates into a namespace, loading its child namespaces and templates. */
|
|
96
|
+
navigateTo: (namespace: MetadataNamespace) => Promise<void>;
|
|
97
|
+
/** Navigates back to the level identified by `fqn`, restoring it from cache. */
|
|
98
|
+
navigateBack: (fqn: string) => void;
|
|
99
|
+
/** Updates the search query; an empty string exits search mode and returns to browse. */
|
|
100
|
+
setSearchValue: (value: string) => void;
|
|
101
|
+
/** Fetches the next page of results for the current browse level or search query. */
|
|
102
|
+
loadMore: () => Promise<void>;
|
|
103
|
+
/** Notifies the event service that the user has selected a template. */
|
|
104
|
+
selectTemplate: (template: MetadataTemplate) => Promise<void>;
|
|
105
|
+
/** Notifies the event service that the user wants to edit a template. */
|
|
106
|
+
editTemplate: (templateId: string) => void;
|
|
107
|
+
/** Re-runs the failing operation based on the current mode (browse or search). */
|
|
108
|
+
retry: () => Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
export interface LevelCache {
|
|
111
|
+
namespaces: MetadataNamespace[];
|
|
112
|
+
templates: MetadataTemplate[];
|
|
113
|
+
namespaceNextMarker: string | undefined;
|
|
114
|
+
templateNextMarker: string | undefined;
|
|
115
|
+
isNamespacesExhausted: boolean;
|
|
116
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@box/metadata-template-browser",
|
|
3
|
+
"version": "1.16.3",
|
|
4
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"@box/blueprint-web": "^13.15.1",
|
|
7
|
+
"@box/blueprint-web-assets": "^4.111.7",
|
|
8
|
+
"lodash": "^4.17.15",
|
|
9
|
+
"react": "^18.0.0",
|
|
10
|
+
"react-aria-components": "1.7.1",
|
|
11
|
+
"react-dom": "^18.0.0",
|
|
12
|
+
"react-intl": "^6.4.2"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@box/blueprint-web": "^13.15.1",
|
|
16
|
+
"@box/blueprint-web-assets": "^4.111.7",
|
|
17
|
+
"@box/eslint-plugin-blueprint": "1.1.6",
|
|
18
|
+
"@box/storybook-utils": "0.17.7",
|
|
19
|
+
"react-intl": "^6.4.2"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"main": "./dist/esm/index.js",
|
|
28
|
+
"module": "./dist/esm/index.js",
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"require": "./dist/esm/index.js",
|
|
33
|
+
"import": "./dist/esm/index.js",
|
|
34
|
+
"types": "./dist/types/index.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./*": {
|
|
37
|
+
"require": "./dist/esm/*",
|
|
38
|
+
"import": "./dist/esm/*",
|
|
39
|
+
"types": "./dist/types/*"
|
|
40
|
+
},
|
|
41
|
+
"./i18n/*": {
|
|
42
|
+
"require": "./dist/i18n/*",
|
|
43
|
+
"import": "./dist/i18n/*"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"sideEffects": [
|
|
47
|
+
"**/*.css"
|
|
48
|
+
]
|
|
49
|
+
}
|