This repository was archived by the owner on Sep 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathoneNoteSingleNotebookPicker.tsx
More file actions
53 lines (43 loc) · 2.79 KB
/
oneNoteSingleNotebookPicker.tsx
File metadata and controls
53 lines (43 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as React from 'react';
import './index.css';
import { OneNotePickerBase } from './oneNotePickerBase';
import { SectionGroupRenderStrategy } from './components/sectionGroupRenderStrategy';
import { SectionRenderStrategy } from './components/sectionRenderStrategy';
import { ExpandableNode } from './components/treeView/expandableNode';
import { LeafNode } from './components/treeView/leafNode';
import { ExpandableNodeRenderStrategy } from './components/treeView/expandableNodeRenderStrategy';
import { GlobalProps } from './props/globalProps';
import { SectionGroup } from './oneNoteDataStructures/sectionGroup';
import { Section } from './oneNoteDataStructures/section';
export interface OneNoteSingleNotebookPickerProps extends GlobalProps {
sectionGroups: SectionGroup[];
sections: Section[];
}
export class OneNoteSingleNotebookPicker extends OneNotePickerBase<OneNoteSingleNotebookPickerProps, {}> {
protected rootNodes(): JSX.Element[] {
const { sectionGroups, sections, globals } = this.props;
const { focusOnMount, ariaSelectedId } = globals;
const sectionGroupRenderStrategies: ExpandableNodeRenderStrategy[] =
sectionGroups.map(sectionGroup => new SectionGroupRenderStrategy(sectionGroup, globals));
const sectionRenderStrategies: ExpandableNodeRenderStrategy[] =
sections.map(section => new SectionRenderStrategy(section, globals));
const noSectionGroups = sectionGroups.length === 0;
const sectionGroupNodes = sectionGroupRenderStrategies.map((renderStrategy, i) =>
<ExpandableNode globals={this.props.globals} expanded={renderStrategy.isExpanded()} node={renderStrategy}
treeViewId={this.treeViewId()} key={renderStrategy.getId()}
id={renderStrategy.getId()} tabbable={i === 0} focusOnMount={focusOnMount && i === 0}
ariaSelected={ariaSelectedId ? renderStrategy.isAriaSelected() : i === 0}></ExpandableNode>);
const sectionNodes = sectionRenderStrategies.map((renderStrategy, i) =>
!!this.props.globals.callbacks.onPageSelected ?
<ExpandableNode globals={this.props.globals} expanded={renderStrategy.isExpanded()} node={renderStrategy}
treeViewId={this.treeViewId()} key={renderStrategy.getId()}
id={renderStrategy.getId()} tabbable={noSectionGroups && i === 0}
focusOnMount={focusOnMount && noSectionGroups && i === 0}
ariaSelected={ariaSelectedId ? renderStrategy.isAriaSelected() : noSectionGroups && i === 0}></ExpandableNode> :
<LeafNode globals={this.props.globals} node={renderStrategy} treeViewId={this.treeViewId()} key={renderStrategy.getId()}
id={renderStrategy.getId()} tabbable={noSectionGroups && i === 0}
focusOnMount={focusOnMount && noSectionGroups && i === 0}
ariaSelected={ariaSelectedId ? renderStrategy.isAriaSelected() : noSectionGroups && i === 0}></LeafNode>);
return [...sectionNodes, ...sectionGroupNodes];
}
}