@box/combobox-with-api 0.25.0

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.
Files changed (101) hide show
  1. package/LICENSE +379 -0
  2. package/chunks/dynamic-loading-tree.js +423 -0
  3. package/esm/index.js +8 -0
  4. package/esm/lib/components/combobox-with-api/combobox-with-api-container.js +47 -0
  5. package/esm/lib/components/combobox-with-api/combobox-with-api-error.js +26 -0
  6. package/esm/lib/components/combobox-with-api/combobox-with-api.js +37 -0
  7. package/esm/lib/components/combobox-with-api/messages.js +10 -0
  8. package/esm/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js +207 -0
  9. package/esm/lib/components/combobox-with-api-pagination/index.js +4 -0
  10. package/esm/lib/components/combobox-with-api-pagination/messages.js +34 -0
  11. package/esm/lib/components/combobox-with-api-pagination/request.js +6 -0
  12. package/esm/lib/components/combobox-with-api-pagination/use-async-list.js +137 -0
  13. package/esm/lib/components/combobox-with-api-pagination/utils/is-abort-error.js +13 -0
  14. package/esm/lib/components/combobox-with-api-pagination/utils/use-controllable-state.js +40 -0
  15. package/esm/lib/components/combobox-with-api-pagination/utils/use-intersection-observer.js +87 -0
  16. package/esm/lib/components/combobox-with-api-tree-view/combobox-with-api-tree-view.js +125 -0
  17. package/esm/lib/components/combobox-with-api-tree-view/dynamic-loading-tree.js +10 -0
  18. package/esm/lib/components/combobox-with-api-tree-view/index.js +4 -0
  19. package/esm/lib/components/combobox-with-api-tree-view/tree-utils.js +26 -0
  20. package/i18n/bn-IN.js +10 -0
  21. package/i18n/bn-IN.properties +16 -0
  22. package/i18n/da-DK.js +10 -0
  23. package/i18n/da-DK.properties +16 -0
  24. package/i18n/de-DE.js +10 -0
  25. package/i18n/de-DE.properties +16 -0
  26. package/i18n/en-AU.js +10 -0
  27. package/i18n/en-AU.properties +16 -0
  28. package/i18n/en-CA.js +10 -0
  29. package/i18n/en-CA.properties +16 -0
  30. package/i18n/en-GB.js +10 -0
  31. package/i18n/en-GB.properties +16 -0
  32. package/i18n/en-US.js +10 -0
  33. package/i18n/en-US.properties +16 -0
  34. package/i18n/en-x-pseudo.js +10 -0
  35. package/i18n/en-x-pseudo.properties +16 -0
  36. package/i18n/es-419.js +10 -0
  37. package/i18n/es-419.properties +16 -0
  38. package/i18n/es-ES.js +10 -0
  39. package/i18n/es-ES.properties +16 -0
  40. package/i18n/fi-FI.js +10 -0
  41. package/i18n/fi-FI.properties +16 -0
  42. package/i18n/fr-CA.js +10 -0
  43. package/i18n/fr-CA.properties +16 -0
  44. package/i18n/fr-FR.js +10 -0
  45. package/i18n/fr-FR.properties +16 -0
  46. package/i18n/hi-IN.js +10 -0
  47. package/i18n/hi-IN.properties +16 -0
  48. package/i18n/it-IT.js +10 -0
  49. package/i18n/it-IT.properties +16 -0
  50. package/i18n/ja-JP.js +10 -0
  51. package/i18n/ja-JP.properties +16 -0
  52. package/i18n/json/src/lib/components/combobox-with-api/messages.json +1 -0
  53. package/i18n/json/src/lib/components/combobox-with-api-pagination/messages.json +1 -0
  54. package/i18n/ko-KR.js +10 -0
  55. package/i18n/ko-KR.properties +16 -0
  56. package/i18n/nb-NO.js +10 -0
  57. package/i18n/nb-NO.properties +16 -0
  58. package/i18n/nl-NL.js +10 -0
  59. package/i18n/nl-NL.properties +16 -0
  60. package/i18n/pl-PL.js +10 -0
  61. package/i18n/pl-PL.properties +16 -0
  62. package/i18n/pt-BR.js +10 -0
  63. package/i18n/pt-BR.properties +16 -0
  64. package/i18n/ru-RU.js +10 -0
  65. package/i18n/ru-RU.properties +16 -0
  66. package/i18n/sv-SE.js +10 -0
  67. package/i18n/sv-SE.properties +16 -0
  68. package/i18n/tr-TR.js +10 -0
  69. package/i18n/tr-TR.properties +16 -0
  70. package/i18n/zh-CN.js +10 -0
  71. package/i18n/zh-CN.properties +16 -0
  72. package/i18n/zh-TW.js +10 -0
  73. package/i18n/zh-TW.properties +16 -0
  74. package/package.json +55 -0
  75. package/styles/combobox-with-api-error.css +1 -0
  76. package/styles/combobox-with-api-pagination.css +1 -0
  77. package/styles/dynamic-loading-tree.css +1 -0
  78. package/types/index.d.ts +4 -0
  79. package/types/lib/components/combobox-with-api/combobox-with-api-container.d.ts +3 -0
  80. package/types/lib/components/combobox-with-api/combobox-with-api-error.d.ts +3 -0
  81. package/types/lib/components/combobox-with-api/combobox-with-api.d.ts +3 -0
  82. package/types/lib/components/combobox-with-api/messages.d.ts +8 -0
  83. package/types/lib/components/combobox-with-api/stories/shared.d.ts +8 -0
  84. package/types/lib/components/combobox-with-api/types.d.ts +39 -0
  85. package/types/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.d.ts +17 -0
  86. package/types/lib/components/combobox-with-api-pagination/index.d.ts +2 -0
  87. package/types/lib/components/combobox-with-api-pagination/messages.d.ts +38 -0
  88. package/types/lib/components/combobox-with-api-pagination/request.d.ts +7 -0
  89. package/types/lib/components/combobox-with-api-pagination/stories/shared.d.ts +38 -0
  90. package/types/lib/components/combobox-with-api-pagination/types.d.ts +49 -0
  91. package/types/lib/components/combobox-with-api-pagination/use-async-list.d.ts +63 -0
  92. package/types/lib/components/combobox-with-api-pagination/utils/is-abort-error.d.ts +1 -0
  93. package/types/lib/components/combobox-with-api-pagination/utils/use-controllable-state.d.ts +8 -0
  94. package/types/lib/components/combobox-with-api-pagination/utils/use-intersection-observer.d.ts +28 -0
  95. package/types/lib/components/combobox-with-api-tree-view/combobox-with-api-tree-view.d.ts +21 -0
  96. package/types/lib/components/combobox-with-api-tree-view/dynamic-loading-tree.d.ts +23 -0
  97. package/types/lib/components/combobox-with-api-tree-view/index.d.ts +3 -0
  98. package/types/lib/components/combobox-with-api-tree-view/stories/mock-api-response.d.ts +11 -0
  99. package/types/lib/components/combobox-with-api-tree-view/stories/shared.d.ts +26 -0
  100. package/types/lib/components/combobox-with-api-tree-view/tree-utils.d.ts +22 -0
  101. package/types/lib/components/combobox-with-api-tree-view/types.d.ts +60 -0
@@ -0,0 +1,21 @@
1
+ import { TreeOptionType } from '../combobox-with-api-pagination/types';
2
+ export declare const ComboboxWithApiTreeView: import('react').ForwardRefExoticComponent<{
3
+ levels: import('./types').Level[];
4
+ selectableLevels: number[];
5
+ defaultFetcher(input: import('../combobox-with-api-pagination/types').TreeQueryInput): Promise<import('../combobox-with-api-pagination/types').FetcherResponse<TreeOptionType>>;
6
+ placeholder?: string;
7
+ includeTextInputOption?: boolean;
8
+ noResultMessage?: import('react').ReactElement | string;
9
+ onInputValueChange?: (inputValue: string) => void;
10
+ multiselect?: boolean;
11
+ onValueChange?: (selectedOptions: TreeOptionType[]) => void;
12
+ value?: TreeOptionType[];
13
+ defaultValue?: TreeOptionType[];
14
+ disabled?: boolean;
15
+ loadingAriaLabel?: string;
16
+ portalElement?: HTMLElement | (() => HTMLElement);
17
+ experimentalVirtualization?: boolean;
18
+ className?: string;
19
+ hideLabel?: boolean;
20
+ treeAriaLabel?: string;
21
+ } & import('@box/blueprint-web').Labelable & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,23 @@
1
+ import { NodeId, TreeProps } from '@box/tree';
2
+ import { TreeOptionType } from '../combobox-with-api-pagination/types';
3
+ import { ComboboxWithApiTreeViewProps, Level } from './types';
4
+ export interface SearchResultsNameProps {
5
+ levelName: string;
6
+ parentDisplayValue: string;
7
+ displayValue: string;
8
+ }
9
+ export declare const SearchResultsName: ({ levelName, parentDisplayValue, displayValue }: SearchResultsNameProps) => import("react/jsx-runtime").JSX.Element;
10
+ export interface DynamicLoadingTreeProps {
11
+ ariaLabel: string;
12
+ onSelect: TreeProps['onNodeSelect'];
13
+ selectedNodes: NodeId[];
14
+ defaultFetcher: ComboboxWithApiTreeViewProps<TreeOptionType>['defaultFetcher'];
15
+ levels: Level[];
16
+ selectableLevels: number[];
17
+ multiselect: boolean;
18
+ open: boolean;
19
+ searchInput: string;
20
+ noResultMessage: string | React.ReactElement;
21
+ loadingAriaLabel: string;
22
+ }
23
+ export declare const DynamicLoadingTree: ({ ariaLabel, onSelect, selectedNodes, defaultFetcher, levels, selectableLevels, multiselect, open, searchInput, noResultMessage, loadingAriaLabel, }: DynamicLoadingTreeProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export type { TreeOptionType, TreeQueryInput } from '../combobox-with-api-pagination/types';
2
+ export { ComboboxWithApiTreeView } from './combobox-with-api-tree-view';
3
+ export type { ComboboxWithApiTreeViewProps, Level } from './types';
@@ -0,0 +1,11 @@
1
+ export declare const apiResponse: {
2
+ id: string;
3
+ ancestors: {
4
+ id: string;
5
+ displayName: string;
6
+ level: number;
7
+ }[];
8
+ displayName: string;
9
+ level: number;
10
+ selectable: boolean;
11
+ }[];
@@ -0,0 +1,26 @@
1
+ import { FetcherResponse, TreeOptionType, TreeQueryInput } from '../../combobox-with-api-pagination/types';
2
+ export declare const defaultArgs: {
3
+ label: string;
4
+ defaultFetcher: ({ ...options }: TreeQueryInput) => Promise<FetcherResponse<TreeOptionType>>;
5
+ portalElement: () => HTMLElement;
6
+ multiselect: true;
7
+ selectableLevels: number[];
8
+ treeAriaLabel: string;
9
+ levels: {
10
+ displayName: string;
11
+ description: string;
12
+ level: number;
13
+ }[];
14
+ };
15
+ interface MockFetcherProps extends TreeQueryInput {
16
+ options?: unknown[];
17
+ delay?: number;
18
+ failOnLoadMore?: boolean;
19
+ failOnLoadMoreTimes?: number;
20
+ failOnLoadLevel?: number;
21
+ failOnLoadLevelTimes?: number;
22
+ }
23
+ export declare const mockTreeFetcher: ({ delay, signal, level, searchInput, ancestorId, marker, failOnLoadMore, options, failOnLoadMoreTimes, failOnLoadLevel, failOnLoadLevelTimes, }: MockFetcherProps) => Promise<FetcherResponse<TreeOptionType>>;
24
+ export declare const findNode: (name: string) => TreeOptionType;
25
+ export declare const mockRejectedFetcher: ({ delay }: MockFetcherProps) => Promise<FetcherResponse<TreeOptionType>>;
26
+ export { mockTreeFetcher as mockFetcher };
@@ -0,0 +1,22 @@
1
+ import { LoadingNode, LoadMoreNode, ReloadNode } from '@box/tree';
2
+ import { NodeId } from './types';
3
+ export declare const getServiceNode: (parentId: NodeId, parentName: string, variant: "reload" | "loadMore" | "loading") => LoadMoreNode | ReloadNode | LoadingNode | {
4
+ name: string;
5
+ id: string;
6
+ parent: import('@box/tree').NodeId;
7
+ children: any[];
8
+ metadata: {
9
+ variant: "loading" | "loadMore" | "reload";
10
+ };
11
+ };
12
+ export declare const RootTreeNode: {
13
+ name: string;
14
+ id: string;
15
+ parent: any;
16
+ children: any[];
17
+ metadata: {
18
+ variant: string;
19
+ level: number;
20
+ displayValue: string;
21
+ };
22
+ };
@@ -0,0 +1,60 @@
1
+ import { Labelable } from '@box/blueprint-web';
2
+ import { Node } from '@box/tree';
3
+ import { ReactElement } from 'react';
4
+ import { FetcherResponse, TreeOptionType, TreeQueryInput } from '../combobox-with-api-pagination/types';
5
+ export type NodeId = Node['id'];
6
+ export type ItemType = {
7
+ id: NodeId;
8
+ name: string | ReactElement;
9
+ parent: NodeId | null;
10
+ children: NodeId[];
11
+ marker?: string;
12
+ status?: 'loading' | 'error' | 'success';
13
+ };
14
+ export interface TreeState {
15
+ [id: string]: TreeNode;
16
+ }
17
+ export declare enum ActionTypes {
18
+ LOAD_DATA = "LOAD_DATA",
19
+ LOAD_ERROR = "LOAD_DATA_ERROR",
20
+ LOAD_SUCCESS = "LOAD_DATA_SUCCESS",
21
+ LOAD_MORE = "LOAD_DATA_SUCCESS",
22
+ RESET = "RESET"
23
+ }
24
+ export interface AcitonPayload {
25
+ id: NodeId;
26
+ items?: ItemType[];
27
+ marker?: string;
28
+ }
29
+ export interface TreeStateUpdateAction {
30
+ type: ActionTypes;
31
+ payload: AcitonPayload;
32
+ }
33
+ export type TreeNode = ItemType & {
34
+ metadata: unknown;
35
+ };
36
+ export interface Level {
37
+ displayName: string;
38
+ description: string;
39
+ level: number;
40
+ }
41
+ export type ComboboxWithApiTreeViewProps<T extends TreeOptionType> = {
42
+ levels: Level[];
43
+ selectableLevels: number[];
44
+ defaultFetcher(input: TreeQueryInput): Promise<FetcherResponse<T>>;
45
+ placeholder?: string;
46
+ includeTextInputOption?: boolean;
47
+ noResultMessage?: ReactElement | string;
48
+ onInputValueChange?: (inputValue: string) => void;
49
+ multiselect?: boolean;
50
+ onValueChange?: (selectedOptions: T[]) => void;
51
+ value?: T[];
52
+ defaultValue?: T[];
53
+ disabled?: boolean;
54
+ loadingAriaLabel?: string;
55
+ portalElement?: HTMLElement | (() => HTMLElement);
56
+ experimentalVirtualization?: boolean;
57
+ className?: string;
58
+ hideLabel?: boolean;
59
+ treeAriaLabel?: string;
60
+ } & Labelable;