@progress/kendo-react-layout 4.14.0-dev.202112221027 → 4.14.0-dev.202201131122

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 (73) hide show
  1. package/LICENSE.md +1 -1
  2. package/NOTICE.txt +54 -21
  3. package/README.md +1 -1
  4. package/dist/cdn/js/kendo-react-layout.js +1 -1
  5. package/dist/es/expansionpanel/ExpansionPanel.d.ts +6 -0
  6. package/dist/es/expansionpanel/ExpansionPanel.js +72 -0
  7. package/dist/es/expansionpanel/ExpansionPanelContent.d.ts +5 -0
  8. package/dist/es/expansionpanel/ExpansionPanelContent.js +21 -0
  9. package/dist/es/expansionpanel/index.d.ts +3 -0
  10. package/dist/es/expansionpanel/index.js +2 -0
  11. package/dist/es/expansionpanel/interfaces.d.ts +77 -0
  12. package/dist/es/expansionpanel/interfaces.js +0 -0
  13. package/dist/es/main.d.ts +5 -1
  14. package/dist/es/main.js +1 -0
  15. package/dist/es/package-metadata.js +1 -1
  16. package/dist/es/panelbar/PanelBar.d.ts +10 -30
  17. package/dist/es/panelbar/PanelBar.js +131 -45
  18. package/dist/es/panelbar/PanelBarItem.d.ts +1 -89
  19. package/dist/es/panelbar/PanelBarItem.js +3 -1
  20. package/dist/es/panelbar/interfaces/NavigationAction.d.ts +8 -0
  21. package/dist/es/panelbar/interfaces/NavigationAction.js +9 -0
  22. package/dist/es/panelbar/interfaces/PanelBarItemClickEventArguments.d.ts +8 -0
  23. package/dist/es/panelbar/interfaces/PanelBarItemClickEventArguments.js +0 -0
  24. package/dist/es/panelbar/interfaces/PanelBarItemProps.d.ts +90 -0
  25. package/dist/es/panelbar/interfaces/PanelBarItemProps.js +0 -0
  26. package/dist/es/panelbar/{PanelBarInterface.d.ts → interfaces/PanelBarProps.d.ts} +19 -23
  27. package/dist/es/panelbar/interfaces/PanelBarProps.js +0 -0
  28. package/dist/es/panelbar/interfaces/PanelBarSelectEventArguments.d.ts +15 -0
  29. package/dist/es/panelbar/interfaces/PanelBarSelectEventArguments.js +0 -0
  30. package/dist/es/panelbar/interfaces/RenderPanelBarItem.d.ts +16 -0
  31. package/dist/es/panelbar/interfaces/RenderPanelBarItem.js +0 -0
  32. package/dist/es/panelbar/util.d.ts +19 -5
  33. package/dist/es/panelbar/util.js +75 -21
  34. package/dist/npm/expansionpanel/ExpansionPanel.d.ts +6 -0
  35. package/dist/npm/expansionpanel/ExpansionPanel.js +74 -0
  36. package/dist/npm/expansionpanel/ExpansionPanelContent.d.ts +5 -0
  37. package/dist/npm/expansionpanel/ExpansionPanelContent.js +23 -0
  38. package/dist/npm/expansionpanel/index.d.ts +3 -0
  39. package/dist/npm/expansionpanel/index.js +7 -0
  40. package/dist/npm/expansionpanel/interfaces.d.ts +77 -0
  41. package/dist/npm/{panelbar/PanelBarInterface.js → expansionpanel/interfaces.js} +0 -1
  42. package/dist/npm/main.d.ts +5 -1
  43. package/dist/npm/main.js +1 -0
  44. package/dist/npm/package-metadata.js +1 -1
  45. package/dist/npm/panelbar/PanelBar.d.ts +10 -30
  46. package/dist/npm/panelbar/PanelBar.js +132 -46
  47. package/dist/npm/panelbar/PanelBarItem.d.ts +1 -89
  48. package/dist/npm/panelbar/PanelBarItem.js +3 -1
  49. package/dist/npm/panelbar/interfaces/NavigationAction.d.ts +8 -0
  50. package/dist/npm/panelbar/interfaces/NavigationAction.js +11 -0
  51. package/dist/npm/panelbar/interfaces/PanelBarItemClickEventArguments.d.ts +8 -0
  52. package/dist/npm/panelbar/interfaces/PanelBarItemClickEventArguments.js +2 -0
  53. package/dist/npm/panelbar/interfaces/PanelBarItemProps.d.ts +90 -0
  54. package/dist/npm/panelbar/interfaces/PanelBarItemProps.js +2 -0
  55. package/dist/npm/panelbar/{PanelBarInterface.d.ts → interfaces/PanelBarProps.d.ts} +19 -23
  56. package/dist/npm/panelbar/interfaces/PanelBarProps.js +2 -0
  57. package/dist/npm/panelbar/interfaces/PanelBarSelectEventArguments.d.ts +15 -0
  58. package/dist/npm/panelbar/interfaces/PanelBarSelectEventArguments.js +2 -0
  59. package/dist/npm/panelbar/interfaces/RenderPanelBarItem.d.ts +16 -0
  60. package/dist/npm/panelbar/interfaces/RenderPanelBarItem.js +2 -0
  61. package/dist/npm/panelbar/util.d.ts +19 -5
  62. package/dist/npm/panelbar/util.js +77 -21
  63. package/dist/systemjs/kendo-react-layout.js +1 -1
  64. package/package.json +13 -13
  65. package/dist/es/panelbar/PanelBarInterface.js +0 -1
  66. package/dist/es/panelbar/services/navigationService.d.ts +0 -23
  67. package/dist/es/panelbar/services/navigationService.js +0 -51
  68. package/dist/es/panelbar/services/selectionService.d.ts +0 -23
  69. package/dist/es/panelbar/services/selectionService.js +0 -88
  70. package/dist/npm/panelbar/services/navigationService.d.ts +0 -23
  71. package/dist/npm/panelbar/services/navigationService.js +0 -53
  72. package/dist/npm/panelbar/services/selectionService.d.ts +0 -23
  73. package/dist/npm/panelbar/services/selectionService.js +0 -90
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ import { ExpansionPanelHandle, ExpansionPanelProps } from './interfaces';
3
+ /**
4
+ * Represents the [KendoReact ExpansionPanel component]({% slug overview_expansionpanel %}).
5
+ */
6
+ export declare const ExpansionPanel: React.ForwardRefExoticComponent<ExpansionPanelProps & React.RefAttributes<ExpansionPanelHandle>>;
@@ -0,0 +1,72 @@
1
+ import * as React from 'react';
2
+ import * as PropTypes from 'prop-types';
3
+ import { classNames, getTabIndex, useRtl, validatePackage, dispatchEvent, Keys, useAsyncFocusBlur } from '@progress/kendo-react-common';
4
+ import { packageMetadata } from '../package-metadata';
5
+ /**
6
+ * Represents the [KendoReact ExpansionPanel component]({% slug overview_expansionpanel %}).
7
+ */
8
+ export var ExpansionPanel = React.forwardRef(function (props, target) {
9
+ var _a;
10
+ validatePackage(packageMetadata);
11
+ var elementRef = React.useRef(null);
12
+ var _b = React.useState(false), focused = _b[0], setFocused = _b[1];
13
+ var getImperativeHandle = React.useCallback(function () { return ({ element: elementRef.current }); }, []);
14
+ React.useImperativeHandle(target, getImperativeHandle);
15
+ var _c = props.expanded, expanded = _c === void 0 ? false : _c, disabled = props.disabled, title = props.title, subtitle = props.subtitle, onAction = props.onAction, expandIcon = props.expandIcon, collapseIcon = props.collapseIcon;
16
+ var onClick = React.useCallback(function (event) {
17
+ dispatchEvent(onAction, event, getImperativeHandle(), { expanded: expanded });
18
+ }, [onAction, expanded]);
19
+ var onKeyDown = React.useCallback(function (event) {
20
+ if (event.keyCode === Keys.enter || event.keyCode === Keys.space) {
21
+ dispatchEvent(onAction, event, getImperativeHandle(), { expanded: expanded });
22
+ }
23
+ }, [onAction, expanded]);
24
+ var handleFocus = React.useCallback(function () {
25
+ if (props.disabled) {
26
+ return;
27
+ }
28
+ setFocused(true);
29
+ }, [props.disabled]);
30
+ var handleBlur = React.useCallback(function () {
31
+ if (props.disabled) {
32
+ return;
33
+ }
34
+ setFocused(false);
35
+ }, [props.disabled]);
36
+ var _d = useAsyncFocusBlur({ onFocus: handleFocus, onBlur: handleBlur }), onFocus = _d.onFocus, onBlur = _d.onBlur;
37
+ return (React.createElement("div", { ref: elementRef, className: classNames('k-expander', props.className, {
38
+ 'k-expanded': expanded,
39
+ 'k-state-focus': focused && !disabled,
40
+ 'k-state-disabled': disabled
41
+ }), onFocus: onFocus, onBlur: onBlur, style: props.style, id: props.id, "aria-expanded": expanded, "aria-disabled": disabled, dir: useRtl(elementRef, props.dir), tabIndex: getTabIndex(props.tabIndex, disabled), onKeyDown: disabled ? undefined : onKeyDown },
42
+ React.createElement("div", { className: "k-expander-header", onClick: disabled ? undefined : onClick },
43
+ title !== undefined ? React.createElement("div", { className: "k-expander-title" }, title) : undefined,
44
+ React.createElement("span", { className: "k-spacer" }),
45
+ subtitle !== undefined ? React.createElement("div", { className: "k-expander-sub-title" }, subtitle) : undefined,
46
+ React.createElement("span", { className: "k-expander-indicator" },
47
+ React.createElement("span", { className: classNames((_a = {},
48
+ // expand icon
49
+ _a[String(expandIcon)] = Boolean(!expanded && expandIcon),
50
+ _a['k-icon k-i-arrow-chevron-down'] = !expanded && !expandIcon,
51
+ // collapse icon
52
+ _a[String(collapseIcon)] = Boolean(expanded && collapseIcon),
53
+ _a['k-icon k-i-arrow-chevron-up'] = expanded && !collapseIcon,
54
+ _a)) }))),
55
+ props.children));
56
+ });
57
+ ExpansionPanel.propTypes = {
58
+ children: PropTypes.node,
59
+ className: PropTypes.string,
60
+ style: PropTypes.object,
61
+ dir: PropTypes.string,
62
+ id: PropTypes.string,
63
+ tabIndex: PropTypes.number,
64
+ title: PropTypes.node,
65
+ subtitle: PropTypes.node,
66
+ expandIcon: PropTypes.string,
67
+ collapseIcon: PropTypes.string,
68
+ expanded: PropTypes.bool,
69
+ disabled: PropTypes.bool,
70
+ onAction: PropTypes.func
71
+ };
72
+ ExpansionPanel.displayName = 'KendoReactExpansionPanel';
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Represents the KendoReact ExpansionPanelContent component.
4
+ */
5
+ export declare const ExpansionPanelContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,21 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { classNames } from '@progress/kendo-react-common';
13
+ import * as React from 'react';
14
+ /**
15
+ * Represents the KendoReact ExpansionPanelContent component.
16
+ */
17
+ export var ExpansionPanelContent = React.forwardRef(function (props, ref) {
18
+ return (React.createElement("div", __assign({ ref: ref }, props, { className: classNames('k-expander-content-wrapper', props.className) }),
19
+ React.createElement("div", { className: 'k-expander-content' }, props.children)));
20
+ });
21
+ ExpansionPanelContent.displayName = 'KendoReactExpansionPanelContent';
@@ -0,0 +1,3 @@
1
+ export * from './ExpansionPanel';
2
+ export * from './ExpansionPanelContent';
3
+ export * from './interfaces';
@@ -0,0 +1,2 @@
1
+ export * from './ExpansionPanel';
2
+ export * from './ExpansionPanelContent';
@@ -0,0 +1,77 @@
1
+ /// <reference types="react" />
2
+ import { BaseEvent } from '@progress/kendo-react-common';
3
+ /**
4
+ * The ExpansionPanel ref.
5
+ */
6
+ export interface ExpansionPanelHandle {
7
+ /**
8
+ * The ExpansionPanel element.
9
+ */
10
+ element: HTMLDivElement | null;
11
+ }
12
+ /**
13
+ * The arguments for the `onAction` ExpansionPanel event.
14
+ */
15
+ export interface ExpansionPanelActionEvent extends BaseEvent<ExpansionPanelHandle> {
16
+ /**
17
+ * Represents the `expanded` state of the ExpansionPanel.
18
+ */
19
+ expanded: boolean;
20
+ }
21
+ /**
22
+ * The props of the ExpansionPanel component.
23
+ */
24
+ export interface ExpansionPanelProps {
25
+ /**
26
+ * The React elements that will be rendered inside the ExpansionPanel.
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * Sets additional CSS classes to the ExpansionPanel.
31
+ */
32
+ className?: string;
33
+ /**
34
+ * Sets additional CSS styles to the ExpansionPanel.
35
+ */
36
+ style?: React.CSSProperties;
37
+ /**
38
+ * Sets the `id` property of the root ExpansionPanel element.
39
+ */
40
+ id?: string;
41
+ /**
42
+ * Specifies the primary text in the header of the ExpansionPanel.
43
+ */
44
+ title?: React.ReactNode;
45
+ /**
46
+ * Specifies the secondary text in the header of the ExpansionPanel, which is rendered next to the collapse/expand icon.
47
+ */
48
+ subtitle?: React.ReactNode;
49
+ /**
50
+ * Sets a custom icon via css class(es), for the expanded state of the ExpansionPanel.
51
+ */
52
+ expandIcon?: string;
53
+ /**
54
+ * Sets a custom icon via css class(es), for the collapsed state of the ExpansionPanel.
55
+ */
56
+ collapseIcon?: string;
57
+ /**
58
+ * Sets the `dir` property of the ExpansionPanel.
59
+ */
60
+ dir?: string;
61
+ /**
62
+ * Sets the `tabIndex` property of the ExpansionPanel.
63
+ */
64
+ tabIndex?: number;
65
+ /**
66
+ * Sets the `expanded` state of the ExpansionPanel.
67
+ */
68
+ expanded?: boolean;
69
+ /**
70
+ * Sets the `disabled` state of the ExpansionPanel.
71
+ */
72
+ disabled?: boolean;
73
+ /**
74
+ * The event handler that will be fired when the expanded state of the ExpansionPanel is about to change.
75
+ */
76
+ onAction?: (event: ExpansionPanelActionEvent) => void;
77
+ }
File without changes
package/dist/es/main.d.ts CHANGED
@@ -6,7 +6,10 @@ export * from './tabstrip/TabStripTab';
6
6
  export * from './panelbar/PanelBar';
7
7
  export * from './panelbar/PanelBarItem';
8
8
  export * from './panelbar/util';
9
- export * from './panelbar/PanelBarInterface';
9
+ export * from './panelbar/interfaces/PanelBarProps';
10
+ export * from './panelbar/interfaces/PanelBarItemProps';
11
+ export * from './panelbar/interfaces/RenderPanelBarItem';
12
+ export * from './panelbar/interfaces/PanelBarSelectEventArguments';
10
13
  export * from './menu/components/Menu';
11
14
  export * from './menu/components/MenuItemLink';
12
15
  export * from './menu/components/MenuItem';
@@ -71,3 +74,4 @@ export * from './breadcrumb/BreadcrumbOrderedList';
71
74
  export * from './breadcrumb/BreadcrumbListItem';
72
75
  export * from './breadcrumb/BreadcrumbDelimiter';
73
76
  export * from './breadcrumb/BreadcrumbLink';
77
+ export * from './expansionpanel';
package/dist/es/main.js CHANGED
@@ -41,3 +41,4 @@ export * from './breadcrumb/BreadcrumbOrderedList';
41
41
  export * from './breadcrumb/BreadcrumbListItem';
42
42
  export * from './breadcrumb/BreadcrumbDelimiter';
43
43
  export * from './breadcrumb/BreadcrumbLink';
44
+ export * from './expansionpanel';
@@ -5,7 +5,7 @@ export var packageMetadata = {
5
5
  name: '@progress/kendo-react-layout',
6
6
  productName: 'KendoReact',
7
7
  productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
8
- publishDate: 1640167833,
8
+ publishDate: 1642071855,
9
9
  version: '',
10
10
  licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
11
11
  };
@@ -1,25 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import * as PropTypes from 'prop-types';
3
- import { PanelBarItemProps } from './PanelBarItem';
4
- import { PanelBarInterface, PanelBarItemClickEventArguments } from './PanelBarInterface';
5
- import { NavigationAction } from './services/navigationService';
6
- /**
7
- * Represents the props of the [KendoReact PanelBar component]({% slug overview_panelbar %}).
8
- */
9
- export interface PanelBarProps extends PanelBarInterface {
10
- /**
11
- * The child can be either a single PanelBarItem or a PanelBarItem array.
12
- */
13
- children?: React.ReactNode;
14
- /**
15
- * The class name that is set to the PanelBar.
16
- */
17
- className?: string;
18
- /**
19
- * Determines if the PanelBar items will be mounted after expand collapse. Defaults to `false`.
20
- */
21
- keepItemsMounted?: boolean;
22
- }
3
+ import { PanelBarProps } from '../main';
4
+ import { PanelBarItemClickEventArguments } from './interfaces/PanelBarItemClickEventArguments';
5
+ import { NavigationAction } from './interfaces/NavigationAction';
23
6
  /**
24
7
  * @hidden
25
8
  */
@@ -60,15 +43,12 @@ export declare class PanelBar extends React.Component<PanelBarProps, PanelBarSta
60
43
  readonly state: PanelBarState;
61
44
  private activeDescendant?;
62
45
  private _element;
63
- private _selectionService;
64
- private _navigationService;
65
46
  private nextTickId;
66
- private readonly selected;
47
+ private readonly expandMode;
48
+ private readonly selectedItem;
49
+ private readonly expandedItems;
50
+ private readonly children;
67
51
  constructor(props: PanelBarProps);
68
- /**
69
- * @hidden
70
- */
71
- componentDidUpdate(prevProps: PanelBarProps): void;
72
52
  /**
73
53
  * @hidden
74
54
  */
@@ -76,15 +56,15 @@ export declare class PanelBar extends React.Component<PanelBarProps, PanelBarSta
76
56
  /**
77
57
  * @hidden
78
58
  */
79
- onSelect: (child: React.ReactElement<PanelBarItemProps, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)>, expanded: string[]) => void;
59
+ onSelect: (event: any) => void;
80
60
  /**
81
61
  * @hidden
82
62
  */
83
- onFocus: (child: React.ReactElement<PanelBarItemProps, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)>) => void;
63
+ onFocus: (event: any, step?: number) => void;
84
64
  /**
85
65
  * @hidden
86
66
  */
87
- onNavigate: (action: NavigationAction) => void;
67
+ onNavigate: (event: any, action: NavigationAction) => void;
88
68
  /**
89
69
  * @hidden
90
70
  */
@@ -25,12 +25,11 @@ var __assign = (this && this.__assign) || function () {
25
25
  import * as React from 'react';
26
26
  import * as PropTypes from 'prop-types';
27
27
  import { PanelBarItem } from './PanelBarItem';
28
- import { renderChildren, getInitialState } from './util';
29
- import { SelectionService } from './services/selectionService';
30
- import { NavigationService, NavigationAction } from './services/navigationService';
31
- import { classNames } from '@progress/kendo-react-common';
28
+ import { renderChildren, getInitialState, flatVisibleChildren, flatChildren, isArrayEqual, getFirstId } from './util';
29
+ import { classNames, Keys } from '@progress/kendo-react-common';
32
30
  import { validatePackage } from '@progress/kendo-react-common';
33
31
  import { packageMetadata } from '../package-metadata';
32
+ import { NavigationAction } from './interfaces/NavigationAction';
34
33
  var PanelBar = /** @class */ (function (_super) {
35
34
  __extends(PanelBar, _super);
36
35
  function PanelBar(props) {
@@ -40,44 +39,88 @@ var PanelBar = /** @class */ (function (_super) {
40
39
  * @hidden
41
40
  */
42
41
  _this.handleSelect = function (event) {
43
- var state = __assign({}, _this.state, { selected: _this.selected });
44
- _this._selectionService.select(event.uniquePrivateKey, renderChildren(_this.props.animation, _this.props.keepItemsMounted, state, _this.handleSelect, _this.props.children), state.expanded);
45
- _this._selectionService.focus(event.uniquePrivateKey, 0, renderChildren(_this.props.animation, _this.props.keepItemsMounted, state, _this.handleSelect, _this.props.children));
42
+ _this.onSelect(event);
43
+ _this.onFocus(event);
46
44
  };
47
45
  /**
48
46
  * @hidden
49
47
  */
50
- _this.onSelect = function (child, expanded) {
51
- _this.setState({ selected: child.props.uniquePrivateKey, expanded: expanded }, function () {
52
- if (_this.props.onSelect) {
53
- _this.props.onSelect.call(undefined, {
54
- target: child,
55
- action: 'select'
56
- });
48
+ _this.onSelect = function (event) {
49
+ var flattenChildren = flatChildren(React.Children.toArray(_this.children));
50
+ var selectedChild;
51
+ var newExpanded;
52
+ flattenChildren.forEach(function (child) {
53
+ if (child.props.uniquePrivateKey === (event.uniquePrivateKey || _this.state.focused)) {
54
+ selectedChild = child;
57
55
  }
58
56
  });
57
+ switch (_this.expandMode) {
58
+ case 'single':
59
+ newExpanded = selectedChild.props.parentUniquePrivateKey.concat([selectedChild.props.uniquePrivateKey]);
60
+ if (isArrayEqual(_this.expandedItems, newExpanded)) {
61
+ if (selectedChild.props.parentUniquePrivateKey) {
62
+ newExpanded = selectedChild.props.parentUniquePrivateKey.slice();
63
+ }
64
+ else {
65
+ newExpanded = [];
66
+ }
67
+ }
68
+ break;
69
+ case 'multiple':
70
+ newExpanded = _this.expandedItems.slice();
71
+ var index = newExpanded.indexOf(selectedChild.props.uniquePrivateKey);
72
+ index === -1 ? newExpanded.push(selectedChild.props.uniquePrivateKey) : newExpanded.splice(index, 1);
73
+ break;
74
+ default:
75
+ newExpanded = _this.expandedItems.slice();
76
+ break;
77
+ }
78
+ _this.setState({ selected: selectedChild.props.uniquePrivateKey, expanded: newExpanded });
79
+ if (_this.props.onSelect) {
80
+ _this.props.onSelect.call(undefined, {
81
+ target: selectedChild,
82
+ expandedItems: newExpanded
83
+ });
84
+ }
59
85
  };
60
86
  /**
61
87
  * @hidden
62
88
  */
63
- _this.onFocus = function (child) {
64
- _this.activeDescendant = child.props.id;
65
- _this.setState({ focused: child.props.uniquePrivateKey });
89
+ _this.onFocus = function (event, step) {
90
+ if (step === void 0) { step = 0; }
91
+ var flattenChildren = flatVisibleChildren(React.Children.toArray(_this.children));
92
+ var focusedChild;
93
+ flattenChildren.forEach(function (child, ixd) {
94
+ if (child.props.uniquePrivateKey === (event.uniquePrivateKey || _this.state.focused)) {
95
+ var index = ixd + step < 0
96
+ ? 0
97
+ : ixd + step > flattenChildren.length
98
+ ? flattenChildren.length - 1
99
+ : ixd + step;
100
+ focusedChild = flattenChildren[index];
101
+ }
102
+ });
103
+ if (focusedChild) {
104
+ _this.activeDescendant = focusedChild.props.id;
105
+ _this.setState({ focused: focusedChild.props.uniquePrivateKey });
106
+ }
66
107
  };
67
108
  /**
68
109
  * @hidden
69
110
  */
70
- _this.onNavigate = function (action) {
71
- var state = __assign({}, _this.state, { selected: _this.selected });
111
+ _this.onNavigate = function (event, action) {
112
+ var step;
72
113
  switch (action) {
73
114
  case NavigationAction.Previous:
74
- _this._selectionService.focus(state.focused, -1, renderChildren(_this.props.animation, _this.props.keepItemsMounted, state, _this.handleSelect, _this.props.children));
115
+ step = -1;
116
+ _this.onFocus(event, step);
75
117
  break;
76
118
  case NavigationAction.Next:
77
- _this._selectionService.focus(state.focused, 1, renderChildren(_this.props.animation, _this.props.keepItemsMounted, state, _this.handleSelect, _this.props.children));
119
+ step = 1;
120
+ _this.onFocus(event, step);
78
121
  break;
79
122
  case NavigationAction.Toggle:
80
- _this._selectionService.select(state.focused, renderChildren(_this.props.animation, _this.props.keepItemsMounted, state, _this.handleSelect, _this.props.children), state.expanded);
123
+ _this.onSelect(event);
81
124
  break;
82
125
  default:
83
126
  }
@@ -95,18 +138,52 @@ var PanelBar = /** @class */ (function (_super) {
95
138
  };
96
139
  _this.handleKeyDown = function (event) {
97
140
  var rtl = _this._element && (getComputedStyle(_this._element).direction === 'rtl') || false;
98
- var target = event.target, currentTarget = event.currentTarget;
99
- if (target === currentTarget) {
100
- _this._navigationService.navigate(event, rtl);
141
+ if (event.target === event.currentTarget) {
142
+ var keyCode = event.keyCode;
143
+ var action = void 0;
144
+ switch (keyCode) {
145
+ case Keys.left:
146
+ action = !rtl ? NavigationAction.Previous : NavigationAction.Next;
147
+ break;
148
+ case Keys.up:
149
+ action = NavigationAction.Previous;
150
+ break;
151
+ case Keys.right:
152
+ action = !rtl ? NavigationAction.Next : NavigationAction.Previous;
153
+ break;
154
+ case Keys.down:
155
+ action = NavigationAction.Next;
156
+ break;
157
+ case Keys.space:
158
+ case Keys.enter:
159
+ action = NavigationAction.Toggle;
160
+ break;
161
+ default:
162
+ action = null;
163
+ break;
164
+ }
165
+ if (action !== null) {
166
+ event.preventDefault();
167
+ _this.onNavigate(event, action);
168
+ }
101
169
  }
102
170
  };
103
171
  validatePackage(packageMetadata);
104
- _this.state = getInitialState(props, props.expandMode || 'multiple');
105
- _this._selectionService = new SelectionService(_this.onSelect, _this.onFocus, _this.props.expandMode || 'multiple');
106
- _this._navigationService = new NavigationService(_this.onNavigate);
172
+ var initialState = getInitialState(props, _this.expandMode);
173
+ if (!initialState.focused) {
174
+ initialState.focused = getFirstId(props);
175
+ }
176
+ _this.state = initialState;
107
177
  return _this;
108
178
  }
109
- Object.defineProperty(PanelBar.prototype, "selected", {
179
+ Object.defineProperty(PanelBar.prototype, "expandMode", {
180
+ get: function () {
181
+ return this.props.expandMode || 'multiple';
182
+ },
183
+ enumerable: true,
184
+ configurable: true
185
+ });
186
+ Object.defineProperty(PanelBar.prototype, "selectedItem", {
110
187
  get: function () {
111
188
  var _a = this.props.selected, selected = _a === void 0 ? this.state.selected : _a;
112
189
  return selected;
@@ -114,15 +191,30 @@ var PanelBar = /** @class */ (function (_super) {
114
191
  enumerable: true,
115
192
  configurable: true
116
193
  });
117
- /**
118
- * @hidden
119
- */
120
- PanelBar.prototype.componentDidUpdate = function (prevProps) {
121
- var newProps = this.props;
122
- if (newProps.expandMode !== prevProps.expandMode) {
123
- this._selectionService.setExpandMode(newProps.expandMode);
124
- }
125
- };
194
+ Object.defineProperty(PanelBar.prototype, "expandedItems", {
195
+ get: function () {
196
+ var expanded = this.props.isControlled ? this.props.expanded || [] : this.state.expanded;
197
+ return expanded;
198
+ },
199
+ enumerable: true,
200
+ configurable: true
201
+ });
202
+ Object.defineProperty(PanelBar.prototype, "children", {
203
+ get: function () {
204
+ var state = __assign({}, this.state, { selected: this.selectedItem });
205
+ var renderState = {
206
+ animation: this.props.animation,
207
+ keepItemsMounted: this.props.keepItemsMounted,
208
+ state: state,
209
+ expanded: this.expandedItems,
210
+ handleSelect: this.handleSelect,
211
+ children: this.props.children
212
+ };
213
+ return renderChildren(renderState);
214
+ },
215
+ enumerable: true,
216
+ configurable: true
217
+ });
126
218
  /**
127
219
  * @hidden
128
220
  */
@@ -131,16 +223,10 @@ var PanelBar = /** @class */ (function (_super) {
131
223
  var ariaProps = {
132
224
  'aria-activedescendant': this.activeDescendant
133
225
  };
134
- var state = __assign({}, this.state, { selected: this.selected });
135
- var children = renderChildren(this.props.animation, this.props.keepItemsMounted, state, this.handleSelect, this.props.children);
136
226
  var className = classNames('k-panelbar', this.props.className);
137
- return (React.createElement("ul", __assign({ ref: function (div) { _this._element = div; }, dir: this.props.dir, role: 'tree', tabIndex: 0, onKeyDown: this.handleKeyDown, onFocus: this.handleWrapperFocus, onBlur: this.handleWrapperBlur, className: className, style: this.props.style }, ariaProps), children));
227
+ return (React.createElement("ul", __assign({ ref: function (div) { _this._element = div; }, dir: this.props.dir, role: 'tree', tabIndex: 0, onKeyDown: this.handleKeyDown, onFocus: this.handleWrapperFocus, onBlur: this.handleWrapperBlur, className: className, style: this.props.style }, ariaProps), this.children));
138
228
  };
139
229
  PanelBar.prototype.nextTick = function (f) {
140
- // XXX: use window.setTimeout due to async focus/blur events in IE, and missing relatedTarget prop.
141
- // XXX: https://github.com/facebook/react/issues/3751
142
- // Handles multiple focus events happening at the same time.
143
- clearTimeout(this.nextTickId);
144
230
  this.nextTickId = window.setTimeout(function () { return f(); });
145
231
  };
146
232
  /**
@@ -1,94 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import * as PropTypes from 'prop-types';
3
- /**
4
- * Represents the props of the PanelBarItem component.
5
- */
6
- export interface PanelBarItemProps {
7
- /**
8
- * Allows individual animation control over the child ([see example]({% slug animations_panelbar %})). By default, it is controlled by the PanelBar component.
9
- */
10
- animation?: boolean;
11
- /**
12
- * Can be any of PanelBar items, an array of PanelBar items, or a custom component.
13
- */
14
- children?: React.ReactNode;
15
- /**
16
- * The class name that is set to the PanelBarItem component.
17
- */
18
- className?: string;
19
- /**
20
- * The class name that is set to the PanelBarItem header.
21
- */
22
- headerClassName?: string;
23
- /**
24
- * Sets the initial expanded state of the PanelBarItem ([see example]({% slug statesitems_panelbar %}#toc-expanded-items)). Controlled by the PanelBar component.
25
- */
26
- expanded?: boolean;
27
- /**
28
- * Sets the disabled state of the PanelBarItem ([see example]({% slug statesitems_panelbar %}#toc-disabled-items)).
29
- */
30
- disabled?: boolean;
31
- /**
32
- * @hidden
33
- */
34
- onSelect?: Function;
35
- /**
36
- * @hidden
37
- */
38
- level?: number;
39
- /**
40
- * Defines an icon that will be rendered next to the title ([see example]({% slug titlesitems_panelbar %}#toc-adding-icons)).
41
- */
42
- icon?: string;
43
- /**
44
- * Defines an icon with a custom CSS class that will be rendered next to the title ([see example]({% slug titlesitems_panelbar %}#toc-adding-icons)).
45
- */
46
- iconClass?: string;
47
- /**
48
- * Defines the location of the image that will be displayed next to the title ([see example]({% slug titlesitems_panelbar %}#toc-adding-images)).
49
- */
50
- imageUrl?: string;
51
- /**
52
- * Sets the initial selected state of the PanelBarItem. Controlled by the PanelBarItem component ([see example]({% slug statesitems_panelbar %}#toc-selected-items)).
53
- */
54
- selected?: boolean;
55
- /**
56
- * Sets the title of the PanelBar item ([see example]({% slug titlesitems_panelbar %}#toc-getting-started)).
57
- */
58
- title?: React.ReactNode;
59
- /**
60
- * Allows the component to set the `id` property to each item. If not set, a default `id` is applied.
61
- */
62
- id?: string;
63
- /**
64
- * Sets the initial focused state of the PanelBarItem. Controlled by the PanelBar component.
65
- */
66
- focused?: boolean;
67
- /**
68
- * @hidden
69
- */
70
- parentExpanded?: boolean;
71
- /**
72
- * @hidden
73
- */
74
- content?: any;
75
- /**
76
- * Used to identify the PanelBarItems inside the PanelBar ([see example]({% slug controlling_state_panelbar %})). Does not depend on the state of the PanelBarItem.
77
- */
78
- uniquePrivateKey?: string;
79
- /**
80
- * @hidden
81
- */
82
- parentUniquePrivateKey?: string[];
83
- /**
84
- * @hidden
85
- */
86
- keepItemsMounted?: boolean;
87
- /**
88
- * Sets a custom property. Contained in the PanelBarItem props that are returned from the `onSelect` PanelBar event.
89
- */
90
- [customProp: string]: any;
91
- }
3
+ import { PanelBarItemProps } from '../main';
92
4
  /** @hidden */
93
5
  interface PanelBarItemState {
94
6
  show: boolean;
@@ -103,7 +103,9 @@ var PanelBarItem = /** @class */ (function (_super) {
103
103
  var arrow = (!disabled && children) ? React.createElement("span", { className: panelBarItemArrowClassName }) : null;
104
104
  var opened = (!disabled && expanded);
105
105
  var content = opened || keepItemsMounted
106
- ? (React.createElement("ul", { role: "group", className: "k-panelbar-group k-panel k-group", style: { display: keepItemsMounted ? (this.state.show ? 'block' : 'none') : 'block' } }, children))
106
+ ? (React.createElement("ul", { role: "group", className: "k-panelbar-group k-panel k-group", style: { display: keepItemsMounted
107
+ ? (this.state.show ? 'block' : 'none')
108
+ : 'block' } }, children))
107
109
  : null;
108
110
  var child = ((animation !== undefined ? animation : true) && !disabled && children)
109
111
  ? (React.createElement(Reveal, { transitionEnterDuration: 200, transitionExitDuration: 200, key: uniquePrivateKey + '_animation', style: animationStyle, children: content, childFactory: keepItemsMounted && this.childFactory, unmountOnExit: !keepItemsMounted, onBeforeEnter: function () { return keepItemsMounted && _this.setState({ show: true }); }, onAfterExited: function () { return keepItemsMounted && _this.setState({ show: false }); } }))
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @hidden
3
+ */
4
+ export declare enum NavigationAction {
5
+ Toggle = 0,
6
+ Next = 1,
7
+ Previous = 2
8
+ }