@instructure/ui-tree-browser 8.14.1-snapshot.46 → 8.14.1-snapshot.63
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/es/TreeBrowser/TreeBrowserLocator.js +2 -1
- package/es/TreeBrowser/TreeButton/index.js +14 -15
- package/es/TreeBrowser/TreeCollection/index.js +18 -31
- package/es/TreeBrowser/TreeCollection/props.js +1 -9
- package/es/TreeBrowser/TreeNode/index.js +10 -13
- package/es/TreeBrowser/TreeNode/props.js +0 -8
- package/es/TreeBrowser/index.js +36 -32
- package/es/TreeBrowser/props.js +0 -55
- package/lib/TreeBrowser/TreeBrowserLocator.js +2 -1
- package/lib/TreeBrowser/TreeButton/index.js +14 -14
- package/lib/TreeBrowser/TreeCollection/index.js +17 -30
- package/lib/TreeBrowser/TreeCollection/props.js +1 -9
- package/lib/TreeBrowser/TreeNode/index.js +10 -12
- package/lib/TreeBrowser/TreeNode/props.js +0 -8
- package/lib/TreeBrowser/index.js +37 -33
- package/lib/TreeBrowser/props.js +0 -55
- package/package.json +15 -15
- package/src/TreeBrowser/TreeButton/index.tsx +21 -36
- package/src/TreeBrowser/TreeButton/props.ts +11 -10
- package/src/TreeBrowser/TreeCollection/index.tsx +57 -108
- package/src/TreeBrowser/TreeCollection/props.ts +17 -32
- package/src/TreeBrowser/TreeNode/index.tsx +10 -21
- package/src/TreeBrowser/TreeNode/props.ts +5 -7
- package/src/TreeBrowser/index.tsx +81 -108
- package/src/TreeBrowser/props.ts +133 -59
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TreeBrowser/TreeButton/index.d.ts +5 -51
- package/types/TreeBrowser/TreeButton/index.d.ts.map +1 -1
- package/types/TreeBrowser/TreeButton/props.d.ts +11 -10
- package/types/TreeBrowser/TreeButton/props.d.ts.map +1 -1
- package/types/TreeBrowser/TreeCollection/index.d.ts +33 -85
- package/types/TreeBrowser/TreeCollection/index.d.ts.map +1 -1
- package/types/TreeBrowser/TreeCollection/props.d.ts +11 -25
- package/types/TreeBrowser/TreeCollection/props.d.ts.map +1 -1
- package/types/TreeBrowser/TreeNode/index.d.ts +4 -12
- package/types/TreeBrowser/TreeNode/index.d.ts.map +1 -1
- package/types/TreeBrowser/TreeNode/props.d.ts +5 -1
- package/types/TreeBrowser/TreeNode/props.d.ts.map +1 -1
- package/types/TreeBrowser/index.d.ts +35 -73
- package/types/TreeBrowser/index.d.ts.map +1 -1
- package/types/TreeBrowser/props.d.ts +113 -16
- package/types/TreeBrowser/props.d.ts.map +1 -1
|
@@ -1,34 +1,131 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { PropValidators, TreeBrowserTheme } from '@instructure/shared-types';
|
|
3
2
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion';
|
|
3
|
+
import React, { ReactElement } from 'react';
|
|
4
|
+
import type { TreeBrowserButtonProps } from './TreeButton/props';
|
|
4
5
|
declare type TreeBrowserOwnProps = {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* a normalized hash of collections, keyed by id, that contains an
|
|
8
|
+
* :id, :name, :items (an array of item ids), :collections (an array of
|
|
9
|
+
* collection ids), optional :descriptor text, optional :containerRef function,
|
|
10
|
+
* an optional :renderBeforeItems TreeNode, and an optional :renderAfterItems TreeNode.
|
|
11
|
+
* Each collection must have a unique id.
|
|
12
|
+
*/
|
|
13
|
+
collections: Record<number | string, Collection>;
|
|
14
|
+
/**
|
|
15
|
+
* a hash of items, keyed by id, that contain an :id, :name,
|
|
16
|
+
* optional :descriptor text, and optional :thumbnail url
|
|
17
|
+
*/
|
|
18
|
+
items: Record<number, CollectionItem>;
|
|
19
|
+
/**
|
|
20
|
+
* specifies the id of the root level collection, if present.
|
|
21
|
+
* if no root is specified, all collections will be rendered
|
|
22
|
+
* at the top level
|
|
23
|
+
**/
|
|
7
24
|
rootId?: string | number;
|
|
8
|
-
|
|
25
|
+
/**
|
|
26
|
+
* an array of expanded collection ids, must be accompanied by an 'onCollectionToggle' prop
|
|
27
|
+
*/
|
|
28
|
+
expanded?: (string | number | undefined)[];
|
|
29
|
+
/**
|
|
30
|
+
* an array of collection ids to expand by default
|
|
31
|
+
*/
|
|
9
32
|
defaultExpanded?: (string | number)[];
|
|
33
|
+
/**
|
|
34
|
+
* There are 2 types of tree selection: single and multi.
|
|
35
|
+
* This is set up to allow for "multi" in the future without having to deprecate the old API.
|
|
36
|
+
*/
|
|
10
37
|
selectionType?: 'none' | 'single';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
getCollectionProps?: (...args: any[]) => any;
|
|
38
|
+
onCollectionToggle?: (collection: CollectionData) => void;
|
|
39
|
+
onItemClick?: (data: CollectionData) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Whether or not to show the root collection specified in rootId prop or
|
|
42
|
+
* to begin with its immediate subcollections and items instead
|
|
43
|
+
*/
|
|
18
44
|
showRootCollection?: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
45
|
+
/**
|
|
46
|
+
* An optional label to assist visually impaired users
|
|
47
|
+
*/
|
|
22
48
|
treeLabel?: string;
|
|
23
|
-
|
|
49
|
+
/**
|
|
50
|
+
* An optional compare function to specify order of the collections and the items
|
|
51
|
+
*/
|
|
24
52
|
sortOrder?: (obj1: any, obj2: any) => number;
|
|
53
|
+
} & TreeBrowserBaseProps;
|
|
54
|
+
declare type TreeBrowserBaseProps = {
|
|
55
|
+
/**
|
|
56
|
+
* A function called with each item's props as an argument. The return value of this function is a
|
|
57
|
+
* props object which will be passed to the item when it is rendered. This is useful for situations where
|
|
58
|
+
* you need to render the item differently depending on it's props. For example, if you would like to
|
|
59
|
+
* display a different icon for items with a certain name.
|
|
60
|
+
*/
|
|
61
|
+
getItemProps?: (props: Record<string, any>) => Record<string, any>;
|
|
62
|
+
/**
|
|
63
|
+
* A function called with each collection's props as an argument. The return value of this function is a
|
|
64
|
+
* props object which will be passed to the collection when it is rendered. This is useful for situations where
|
|
65
|
+
* you need to render the collection differently depending on it's props. For example, if you would like to
|
|
66
|
+
* display a different icon for collections with a certain name.
|
|
67
|
+
*/
|
|
68
|
+
getCollectionProps?: (props: Record<string, any>) => TreeBrowserButtonProps;
|
|
69
|
+
onCollectionClick?: (e: React.MouseEvent, data: CollectionData) => void;
|
|
70
|
+
} & TreeBrowserCommonProps;
|
|
71
|
+
declare type TreeBrowserCommonProps = {
|
|
72
|
+
size?: 'small' | 'medium' | 'large';
|
|
73
|
+
variant?: 'folderTree' | 'indent';
|
|
74
|
+
collectionIcon?: React.ReactNode | ((props: unknown) => React.ReactNode);
|
|
75
|
+
collectionIconExpanded?: React.ReactNode | ((props: unknown) => React.ReactNode);
|
|
76
|
+
itemIcon?: React.ReactNode | ((props: unknown) => React.ReactNode);
|
|
77
|
+
renderContent?: (props: TreeBrowserButtonProps) => JSX.Element;
|
|
25
78
|
};
|
|
26
79
|
declare type PropKeys = keyof TreeBrowserOwnProps;
|
|
27
80
|
declare type AllowedPropKeys = Readonly<Array<PropKeys>>;
|
|
28
81
|
declare type TreeBrowserProps = TreeBrowserOwnProps & WithStyleProps<TreeBrowserTheme, TreeBrowserStyle>;
|
|
29
82
|
declare type TreeBrowserStyle = ComponentStyle<'treeBrowser'>;
|
|
83
|
+
declare type CollectionBase = {
|
|
84
|
+
id: number | string;
|
|
85
|
+
name: string;
|
|
86
|
+
descriptor?: string;
|
|
87
|
+
/**
|
|
88
|
+
* A function that returns a reference to the underlying HTML container
|
|
89
|
+
* @param el The DOM HTMLElement
|
|
90
|
+
*/
|
|
91
|
+
containerRef?: (el: HTMLElement | null) => void;
|
|
92
|
+
/**
|
|
93
|
+
* children of type TreeNode
|
|
94
|
+
*/
|
|
95
|
+
renderBeforeItems?: ReactElement;
|
|
96
|
+
/**
|
|
97
|
+
* children of type TreeNode
|
|
98
|
+
*/
|
|
99
|
+
renderAfterItems?: ReactElement;
|
|
100
|
+
};
|
|
101
|
+
declare type Collection = CollectionBase & {
|
|
102
|
+
items?: number[];
|
|
103
|
+
collections?: (number | string)[];
|
|
104
|
+
};
|
|
105
|
+
declare type CollectionItem = {
|
|
106
|
+
id: number | string;
|
|
107
|
+
name: string;
|
|
108
|
+
descriptor?: string;
|
|
109
|
+
thumbnail?: string;
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
};
|
|
112
|
+
declare type CollectionProps = {
|
|
113
|
+
collections?: CollectionProps[];
|
|
114
|
+
items?: CollectionItem[];
|
|
115
|
+
expanded?: boolean;
|
|
116
|
+
isCollectionFlattened?: boolean;
|
|
117
|
+
} & CollectionBase;
|
|
118
|
+
declare type CollectionData = {
|
|
119
|
+
id?: number | string;
|
|
120
|
+
expanded?: boolean;
|
|
121
|
+
type: 'child' | 'collection' | 'item';
|
|
122
|
+
};
|
|
30
123
|
declare const propTypes: PropValidators<PropKeys>;
|
|
31
124
|
declare const allowedProps: AllowedPropKeys;
|
|
32
|
-
|
|
125
|
+
declare type TreeBrowserState = {
|
|
126
|
+
selection: string;
|
|
127
|
+
expanded?: (string | number | undefined)[];
|
|
128
|
+
};
|
|
129
|
+
export type { TreeBrowserProps, TreeBrowserState, TreeBrowserStyle, CollectionData, Collection, CollectionItem, CollectionProps, TreeBrowserBaseProps, TreeBrowserCommonProps };
|
|
33
130
|
export { propTypes, allowedProps };
|
|
34
131
|
//# sourceMappingURL=props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/TreeBrowser/props.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/TreeBrowser/props.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1E,OAAO,KAAK,EAAE,E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