Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree widget #1516

Merged
merged 72 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
e828b63
Initial tree implementation
May 12, 2020
d0c3bf3
Additional events, theme & example updates
May 13, 2020
70d13af
Material theme
May 14, 2020
d8e3011
Converted API to use flat data structure
May 15, 2020
665cb00
Custom renderer child implementation
May 15, 2020
67c15df
Added `Array.fill` shim
May 18, 2020
74c9393
Tree uses `ListItem` for each node.
May 19, 2020
feff92d
Consolidated diffing and value tracking
May 20, 2020
4cdc344
Keyboard navigation
May 22, 2020
fb80246
Wrapped examples in `Example` widget
May 26, 2020
9d3023b
Converted to use data middleware
May 28, 2020
392f118
Exported TreeNode widget; renamed data to TreeNodeOption
May 28, 2020
c1b8c5f
Tree widget tests
Jun 10, 2020
2a1bd1a
Tweaked test to avoid framework bug
Jun 11, 2020
7b60b63
Additional tests - Keyboard navigation
Jun 11, 2020
099d8ba
Readme docs
Jun 15, 2020
af80cd0
Started remote source example
samends Jul 16, 2020
56c34f0
Added initial remote source
samends Jul 20, 2020
1c40d74
Updated remote source example
samends Jul 21, 2020
f44e8b9
Experiment
samends Aug 12, 2020
db49226
Added to tree widget
samends Aug 12, 2020
4fe74a7
Updated examples
samends Aug 14, 2020
f1d49ec
Fixed example
samends Aug 14, 2020
ec24d4f
Added onkeydown function update to tree widget
samends Aug 18, 2020
ac13123
Removed console.logs
samends Aug 18, 2020
453d006
Updated function name, removed unused interface
samends Aug 18, 2020
49e6385
Updated unit tests
samends Aug 19, 2020
d58dd0a
Removed unneeded classes, added class definitions
samends Aug 19, 2020
ac297e9
Changed 'node' value name to 'id'
samends Aug 19, 2020
1932458
Removed widget title comment
samends Aug 19, 2020
80b84f3
Update typing in tree node
samends Aug 19, 2020
a8dfc8e
Removed css spacers
samends Aug 25, 2020
a779a59
Added initialExpanded and initialChecked
samends Aug 25, 2020
0bbb82e
Updated unit tests
samends Aug 25, 2020
c879f45
Added tests
samends Aug 25, 2020
cc651c4
Updated remote source
samends Aug 26, 2020
15e1c8c
Removed focus outline
samends Aug 27, 2020
11829da
Added parentSelection property, onCheck triggers with 'onSelect' event'
samends Aug 27, 2020
045ff89
Prevent nodes from expanding onkeydown if they have no children
samends Aug 27, 2020
e9bbba8
Updated glitch project address
samends Aug 28, 2020
e66b3d9
Added controlled and partial expanded and checked options
samends Sep 2, 2020
5e45898
Updated keydown behavior
samends Sep 2, 2020
cc5ac76
Merged with master
samends Sep 2, 2020
3084c78
Fixed unit tests
samends Sep 2, 2020
6a94b96
Added test
samends Sep 2, 2020
7d9e85a
Increased unit tests
samends Sep 2, 2020
d518014
Added another test
samends Sep 2, 2020
2ed6fd0
Updated loading code
samends Sep 3, 2020
a4e0afc
Added test
samends Sep 3, 2020
75b16d4
Added import for noop
samends Sep 15, 2020
1696b19
Updated onCheck and onExpand to take node id array, updated checkedNo…
samends Sep 17, 2020
5971940
Updated failing tests
samends Sep 17, 2020
a701b18
Changed onSelect to onValue
samends Sep 17, 2020
e8e0e17
Updated controlled example
samends Sep 17, 2020
49ba8b5
Updated expandedNodes to expanded and checkedNodes to checked in the …
samends Sep 17, 2020
bb26736
Updated selecteNode to selected
samends Sep 21, 2020
03caef6
Updated 'selected' property to 'value'
samends Sep 21, 2020
205561f
Removed controlled check for
samends Sep 21, 2020
954ae5e
Added expanded, disabled, checked, selected as boolean to TreeNode wi…
samends Sep 21, 2020
11f6c34
Removed controlledExpandedNodes, controlledCheckedNodes, set checked …
samends Sep 21, 2020
2c36874
Updated tests
samends Sep 21, 2020
08669a4
Removed unneeded code
samends Sep 22, 2020
1c15821
Added focus call
samends Sep 22, 2020
44e8aec
Updated unit tests
samends Sep 22, 2020
3aab4d8
Removed focus property from root node
samends Sep 23, 2020
e1eedc7
Updated unit tests
samends Sep 23, 2020
a13de05
Added descriptive roles to elements
samends Sep 23, 2020
f3b2ac2
Updated default theme
samends Sep 23, 2020
49e7221
Updated onValue, onExpand, onActive TreeNode widget parameters
samends Sep 24, 2020
cda44bf
Updated controlled example
samends Sep 24, 2020
37ec24e
Updated list item material theme background, updated tree widget mate…
samends Sep 24, 2020
731057d
Added surface background to tree widget material theme
samends Sep 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dojorc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"src/time-picker",
"src/title-pane",
"src/tooltip",
"src/tree",
"src/trigger-popup",
"src/two-column-layout",
"src/typeahead"
Expand Down
41 changes: 41 additions & 0 deletions src/examples/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ import CustomIconResult from './widgets/result/CustomIcon';
import BasicWizard from './widgets/wizard/Basic';
import VerticalWizard from './widgets/wizard/Vertical';
import ErrorWizard from './widgets/wizard/Error';
import BasicTree from './widgets/tree/Basic';
import CheckableTree from './widgets/tree/Checkable';
import CustomRendererTree from './widgets/tree/CustomRenderer';
import ControlledTree from './widgets/tree/Controlled';
import RemoteSource from './widgets/tree/RemoteSource';
import InitialStateTree from './widgets/tree/InitialState';
import PopupConfirmation from './widgets/popup-confirmation/Basic';
import PopupConfirmationUnderlay from './widgets/popup-confirmation/Underlay';

Expand Down Expand Up @@ -1804,6 +1810,41 @@ export const config = {
}
}
},
tree: {
examples: [
{
filename: 'Checkable',
module: CheckableTree,
title: 'Checkable Nodes'
},
{
filename: 'CustomRenderer',
module: CustomRendererTree,
title: 'Custom Renderer'
},
{
filename: 'Controlled',
module: ControlledTree,
title: 'Controlled Usage'
},
{
filename: 'RemoteSource',
module: RemoteSource,
title: 'Remote Source'
},
{
filename: 'InitialState',
module: InitialStateTree,
title: 'Tree with initial state'
}
],
overview: {
example: {
filename: 'Basic',
module: BasicTree
}
}
},
'two-column-layout': {
examples: [
{
Expand Down
60 changes: 60 additions & 0 deletions src/examples/src/widgets/tree/Basic.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { create, tsx } from '@dojo/framework/core/vdom';
import {
createMemoryResourceTemplate,
createResourceMiddleware
} from '@dojo/framework/core/middleware/resources';
import Example from '../../Example';
import Tree, { TreeNodeOption } from '@dojo/widgets/tree';

const resource = createResourceMiddleware();
const factory = create({ resource });
const nodes: TreeNodeOption[] = [
{
id: 'c9ae529a',
value: 'parent 1',
parent: 'root',
hasChildren: true
},
{
id: 'cde74420',
value: 'parent 1-0',
parent: 'c9ae529a',
hasChildren: true
},
{
id: 'e2065522',
value: 'parent 1-1',
parent: 'c9ae529a',
hasChildren: true
},
{
id: 'de48r11ea',
value: 'child-1',
parent: 'cde74420',
hasChildren: false
},
{
id: 'd8fada34',
value: 'child-2',
parent: 'cde74420',
hasChildren: false
},
{
id: 'e73a11b4',
value: 'child-3',
parent: 'e2065522',
hasChildren: false
}
];
const template = createMemoryResourceTemplate<TreeNodeOption>();

export default factory(function Basic({ id, middleware: { resource } }) {
return (
<Example>
<Tree
selectable={true}
resource={resource({ template, initOptions: { id, data: nodes } })}
/>
</Example>
);
});
60 changes: 60 additions & 0 deletions src/examples/src/widgets/tree/Checkable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { create, tsx } from '@dojo/framework/core/vdom';
import {
createMemoryResourceTemplate,
createResourceMiddleware
} from '@dojo/framework/core/middleware/resources';
import Tree, { TreeNodeOption } from '@dojo/widgets/tree';
import Example from '../../Example';

const resource = createResourceMiddleware();
const factory = create({ resource });
const nodes: TreeNodeOption[] = [
{
id: 'c9ae529a',
value: 'parent 1',
parent: 'root',
hasChildren: true
},
{
id: 'cde74420',
value: 'parent 1-0',
parent: 'c9ae529a',
hasChildren: true
},
{
id: 'e2065522',
value: 'parent 1-1',
parent: 'c9ae529a',
hasChildren: true
},
{
id: 'de48r11ea',
value: 'child-1',
parent: 'cde74420',
hasChildren: false
},
{
id: 'd8fada34',
value: 'child-2',
parent: 'cde74420',
hasChildren: false
},
{
id: 'e73a11b4',
value: 'child-3',
parent: 'e2065522',
hasChildren: false
}
];
const template = createMemoryResourceTemplate<TreeNodeOption>();

export default factory(function Checkable({ id, middleware: { resource } }) {
return (
<Example>
<Tree
checkable={true}
resource={resource({ template, initOptions: { id, data: nodes } })}
/>
</Example>
);
});
99 changes: 99 additions & 0 deletions src/examples/src/widgets/tree/Controlled.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { create, tsx } from '@dojo/framework/core/vdom';
import {
createMemoryResourceTemplate,
createResourceMiddleware
} from '@dojo/framework/core/middleware/resources';
import { createICacheMiddleware } from '@dojo/framework/core/middleware/icache';
import Tree, { TreeNodeOption } from '@dojo/widgets/tree';
import Example from '../../Example';

interface ControlledCache {
expanded?: string[];
checked?: string[];
}
const resource = createResourceMiddleware();
const icache = createICacheMiddleware<ControlledCache>();
const factory = create({ icache, resource });
const nodes: TreeNodeOption[] = [
{
id: 'c9ae529a',
value: 'parent 1',
parent: 'root',
hasChildren: true
},
{
id: 'cde74420',
value: 'parent 1-0',
parent: 'c9ae529a',
hasChildren: true
},
{
id: 'e2065522',
value: 'parent 1-1',
parent: 'c9ae529a',
hasChildren: true
},
{
id: 'de48r11ea',
value: 'child-1',
parent: 'cde74420',
hasChildren: false
},
{
id: 'd8fada34',
value: 'child-2',
parent: 'cde74420',
hasChildren: false
},
{
id: 'e73a11b4',
value: 'child-3',
parent: 'e2065522',
hasChildren: false
}
];
const template = createMemoryResourceTemplate<TreeNodeOption>();

export default factory(function Advanced({ id, middleware: { icache, resource } }) {
const expanded = icache.getOrSet('expanded', []);
const checked = icache.getOrSet('checked', []);

return (
<Example>
<Tree
checkable={true}
selectable={true}
onExpand={(ids) => {}}
expandedIds={expanded}
checkedIds={checked}
resource={resource({ template, initOptions: { id, data: nodes } })}
/>
<ul>
<li>
<button
onclick={() => {
icache.set(
'expanded',
expanded && expanded.length !== 0 ? [] : ['c9ae529a', 'cde74420']
);
}}
>
Toggle Expand
</button>
</li>
<li>
<button
onclick={() => {
icache.set(
'checked',
checked && checked.length !== 0 ? [] : ['de48r11ea']
);
}}
>
Toggle Checked
</button>
</li>
</ul>
</Example>
);
});
67 changes: 67 additions & 0 deletions src/examples/src/widgets/tree/CustomRenderer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { create, tsx } from '@dojo/framework/core/vdom';
import {
createMemoryResourceTemplate,
createResourceMiddleware
} from '@dojo/framework/core/middleware/resources';
import Tree, { TreeNodeOption } from '@dojo/widgets/tree';
import Icon from '@dojo/widgets/icon';
import Example from '../../Example';

const resource = createResourceMiddleware();
const factory = create({ resource });
const nodes: TreeNodeOption[] = [
{
id: 'c9ae529a',
value: 'parent 1',
parent: 'root',
hasChildren: true
},
{
id: 'cde74420',
value: 'parent 1-0',
parent: 'c9ae529a',
hasChildren: true
},
{
id: 'e2065522',
value: 'parent 1-1',
parent: 'c9ae529a',
hasChildren: true
},
{
id: 'de48r11ea',
value: 'child-1',
parent: 'cde74420',
hasChildren: false
},
{
id: 'd8fada34',
value: 'child-2',
parent: 'cde74420',
hasChildren: false
},
{
id: 'e73a11b4',
value: 'child-3',
parent: 'e2065522',
hasChildren: false
}
];
const template = createMemoryResourceTemplate<TreeNodeOption>();

export default factory(function CustomIcons({ id, middleware: { resource } }) {
return (
<Example>
<Tree resource={resource({ template, initOptions: { id, data: nodes } })}>
{(node) => (
<div styles={{ display: 'flex' }}>
<div styles={{ marginRight: '5px' }}>
<Icon type="starIcon" />
</div>
<div>{node.value}</div>
</div>
)}
</Tree>
</Example>
);
});
Loading