@progress/kendo-react-layout 5.11.1-dev.202302171102 → 5.12.0-dev.202302211105

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.
@@ -17,26 +17,56 @@ export interface ActionSheetProps {
17
17
  * Specifies the text that is rendered as title.
18
18
  */
19
19
  title?: string;
20
+ /**
21
+ * **Deprecated**. Fires when the modal overlay is clicked. Use `onClose` event instead.
22
+ *
23
+ * @deprecated
24
+ */
25
+ onOverlayClick?: (event: React.SyntheticEvent) => void;
20
26
  /**
21
27
  * Fires when the modal overlay is clicked.
22
28
  */
23
- onOverlayClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
29
+ onClose?: (event: React.SyntheticEvent) => void;
24
30
  /**
25
31
  * Fires when an ActionSheet item is clicked.
26
32
  */
33
+ onItemSelect?: (event: {
34
+ syntheticEvent: React.SyntheticEvent;
35
+ title?: string;
36
+ item?: any;
37
+ }) => void;
38
+ /**
39
+ * **Deprecated**. Fires when an ActionSheet item is clicked. Use `onItemSelect` event instead.
40
+ *
41
+ * @deprecated
42
+ */
27
43
  onItemClick?: (event: {
28
- syntheticEvent: React.MouseEvent<HTMLSpanElement>;
44
+ syntheticEvent: React.SyntheticEvent;
29
45
  title?: string;
46
+ item?: any;
30
47
  }) => void;
31
48
  /**
32
49
  * Represents the children that are passed to the ActionSheet.
33
50
  */
34
51
  children?: any;
52
+ /**
53
+ * Specifies the `tabIndex` of the ActionSheet.
54
+ */
55
+ tabIndex?: number;
56
+ /**
57
+ * Specifies if the ActionSheet can be navigatable with keyboard.
58
+ * Defaults to `true`.
59
+ */
60
+ navigatable: boolean;
61
+ /**
62
+ * Specifies the selectors of the navigatable elements inside the templates of the ActionSheet.
63
+ */
64
+ navigatableElements: string[];
35
65
  }
36
66
  /**
37
67
  * Represents the [KendoReact ActionSheet]({% slug overview_actionsheet %}) component.
38
68
  */
39
- export declare class ActionSheet extends React.Component<ActionSheetProps, {}> {
69
+ export declare class ActionSheet extends React.Component<ActionSheetProps> {
40
70
  /**
41
71
  * @hidden
42
72
  */
@@ -48,10 +78,20 @@ export declare class ActionSheet extends React.Component<ActionSheetProps, {}> {
48
78
  items: PropTypes.Requireable<any[]>;
49
79
  subTitle: PropTypes.Requireable<string>;
50
80
  title: PropTypes.Requireable<string>;
81
+ navigatable: PropTypes.Requireable<boolean>;
82
+ navigatableElements: PropTypes.Requireable<any[]>;
83
+ };
84
+ /**
85
+ * @hidden
86
+ */
87
+ static defaultProps: {
88
+ navigatable: boolean;
89
+ navigatableElements: never[];
51
90
  };
52
91
  private actionSheetAnimationRef;
53
92
  private actionSheetTitleClass;
54
93
  private ariaLabeledBy;
94
+ private navigation?;
55
95
  /**
56
96
  * @hidden
57
97
  */
@@ -64,5 +104,11 @@ export declare class ActionSheet extends React.Component<ActionSheetProps, {}> {
64
104
  * @hidden
65
105
  */
66
106
  render(): JSX.Element;
107
+ private handleKeyDown;
108
+ private onTab;
109
+ private handleOverlayClick;
110
+ private handleItemClick;
111
+ private onEnter;
112
+ private onEscape;
67
113
  private children;
68
114
  }
@@ -24,9 +24,18 @@ var __assign = (this && this.__assign) || function () {
24
24
  };
25
25
  return __assign.apply(this, arguments);
26
26
  };
27
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
28
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
29
+ if (ar || !(i in from)) {
30
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
31
+ ar[i] = from[i];
32
+ }
33
+ }
34
+ return to.concat(ar || Array.prototype.slice.call(from));
35
+ };
27
36
  import * as React from 'react';
28
37
  import * as PropTypes from 'prop-types';
29
- import { validatePackage } from '@progress/kendo-react-common';
38
+ import { validatePackage, Navigation, FOCUSABLE_ELEMENTS } from '@progress/kendo-react-common';
30
39
  import { packageMetadata } from '../package-metadata';
31
40
  import { ActionSheetItem } from './ActionSheetItem';
32
41
  import { headerDisplayName } from './ActionSheetHeader';
@@ -45,6 +54,68 @@ var ActionSheet = /** @class */ (function (_super) {
45
54
  _this.actionSheetAnimationRef = React.createRef();
46
55
  _this.actionSheetTitleClass = 'k-actionsheet-title';
47
56
  _this.ariaLabeledBy = _this.actionSheetTitleClass + 1;
57
+ _this.handleKeyDown = function (e) {
58
+ if (_this.props.navigatable) {
59
+ _this.navigation.triggerKeyboardEvent(e);
60
+ }
61
+ };
62
+ _this.onTab = function (target, nav, ev) {
63
+ ev.preventDefault();
64
+ if (ev.shiftKey) {
65
+ nav.focusPrevious(target);
66
+ }
67
+ else {
68
+ nav.focusNext(target);
69
+ }
70
+ };
71
+ _this.handleOverlayClick = function (ev) {
72
+ if (_this.props.onOverlayClick) {
73
+ _this.props.onOverlayClick.call(undefined, ev);
74
+ }
75
+ if (_this.props.onClose) {
76
+ _this.props.onClose.call(undefined, ev);
77
+ }
78
+ };
79
+ _this.handleItemClick = function (ev) {
80
+ if (_this.props.onItemClick) {
81
+ _this.props.onItemClick.call(undefined, ev);
82
+ }
83
+ if (_this.props.onItemSelect) {
84
+ _this.props.onItemSelect.call(undefined, ev);
85
+ }
86
+ };
87
+ _this.onEnter = function (target, nav, ev) {
88
+ var isItem = target.className && target.className.indexOf('k-actionsheet-item') !== -1;
89
+ var allItems = nav.elements.filter(function (e) { return e.className.indexOf('k-actionsheet-item') !== -1; });
90
+ if (isItem && _this.props.onItemClick) {
91
+ ev.preventDefault();
92
+ var item = _this.props.items[allItems.indexOf(target)];
93
+ _this.props.onItemClick.call(undefined, {
94
+ syntheticEvent: ev,
95
+ item: item,
96
+ title: item && item.title
97
+ });
98
+ }
99
+ if (isItem && _this.props.onItemSelect) {
100
+ ev.preventDefault();
101
+ var item = _this.props.items[allItems.indexOf(target)];
102
+ _this.props.onItemSelect.call(undefined, {
103
+ syntheticEvent: ev,
104
+ item: item,
105
+ title: item && item.title
106
+ });
107
+ }
108
+ };
109
+ _this.onEscape = function (_target, _nav, ev) {
110
+ if (_this.props.onOverlayClick) {
111
+ ev.preventDefault();
112
+ _this.props.onOverlayClick.call(undefined, ev);
113
+ }
114
+ if (_this.props.onClose) {
115
+ ev.preventDefault();
116
+ _this.props.onClose.call(undefined, ev);
117
+ }
118
+ };
48
119
  validatePackage(packageMetadata);
49
120
  return _this;
50
121
  }
@@ -52,9 +123,34 @@ var ActionSheet = /** @class */ (function (_super) {
52
123
  * @hidden
53
124
  */
54
125
  ActionSheet.prototype.componentDidMount = function () {
126
+ var _this = this;
55
127
  if (this.actionSheetAnimationRef.current) {
56
128
  this.actionSheetAnimationRef.current.style.setProperty('--kendo-actionsheet-height', 'auto');
57
129
  this.actionSheetAnimationRef.current.style.setProperty('--kendo-actionsheet-max-height', 'none');
130
+ if (this.props.navigatable) {
131
+ this.navigation = new Navigation({
132
+ tabIndex: this.props.tabIndex || 0,
133
+ root: this.actionSheetAnimationRef,
134
+ rovingTabIndex: false,
135
+ selectors: __spreadArray([
136
+ '.k-actionsheet-item'
137
+ ], [
138
+ '.k-actionsheet-footer',
139
+ '.k-actionsheet-content',
140
+ '.k-actionsheet-header'
141
+ ].map(function (selector) {
142
+ return FOCUSABLE_ELEMENTS.concat(_this.props.navigatableElements).map(function (focusableSelector) { return "".concat(selector, " ").concat(focusableSelector); });
143
+ }).flat(), true),
144
+ keyboardEvents: {
145
+ keydown: {
146
+ 'Tab': this.onTab,
147
+ 'Enter': this.onEnter,
148
+ 'Escape': this.onEscape
149
+ }
150
+ }
151
+ });
152
+ this.navigation.focusElement(this.navigation.first, null);
153
+ }
58
154
  }
59
155
  };
60
156
  /**
@@ -68,25 +164,24 @@ var ActionSheet = /** @class */ (function (_super) {
68
164
  var shouldRenderSeparator = (topGroupItems && topGroupItems.length > 0) && (bottomGroupItems && bottomGroupItems.length > 0);
69
165
  var children = this.children(this.props.children);
70
166
  return (React.createElement("div", { className: "k-actionsheet-container" },
71
- React.createElement("div", { className: "k-overlay", onClick: this.props.onOverlayClick }),
167
+ React.createElement("div", { className: "k-overlay", onClick: this.handleOverlayClick }),
72
168
  React.createElement("div", { className: "k-animation-container" },
73
169
  React.createElement("div", { className: "k-child-animation-container", style: { bottom: '0px', width: '100%' } },
74
- React.createElement("div", { className: "k-actionsheet k-actionsheet-bottom", role: "dialog", "aria-modal": "true", "aria-hidden": false, "aria-labelledby": this.ariaLabeledBy, ref: this.actionSheetAnimationRef },
170
+ React.createElement("div", { className: "k-actionsheet k-actionsheet-bottom", role: "dialog", "aria-modal": "true", "aria-hidden": false, "aria-labelledby": this.ariaLabeledBy, ref: this.actionSheetAnimationRef, onKeyDown: this.handleKeyDown },
75
171
  (children[headerDisplayName] || this.props.title || this.props.subTitle) && (React.createElement("div", { className: "k-actionsheet-titlebar" },
76
172
  React.createElement("div", { className: "k-actionsheet-titlebar-group k-hbox" },
77
173
  React.createElement("div", { className: this.actionSheetTitleClass, id: this.ariaLabeledBy }, children[headerDisplayName] ||
78
174
  React.createElement(React.Fragment, null,
79
175
  React.createElement("div", { className: "k-text-center" }, this.props.title),
80
176
  this.props.subTitle && React.createElement("div", { className: "k-actionsheet-subtitle k-text-center" }, this.props.subTitle)))))),
81
- React.createElement("div", { className: "k-actionsheet-content" }, children[contentDisplayName] ||
82
- React.createElement(React.Fragment, null,
83
- React.createElement("div", { className: "k-list-ul", role: "group" }, topGroupItems && topGroupItems.map(function (props, idx) {
84
- return (React.createElement(ActionSheetItem, __assign({}, props, { key: idx, focused: idx === 0, onClick: _this.props.onItemClick })));
85
- })),
86
- shouldRenderSeparator && React.createElement("hr", { className: "k-hr" }),
87
- React.createElement("div", { className: "k-list-ul", role: "group" }, bottomGroupItems && bottomGroupItems.map(function (props, idx) {
88
- return React.createElement(ActionSheetItem, __assign({ key: idx }, props, { onClick: _this.props.onItemClick }));
89
- })))),
177
+ children[contentDisplayName] || React.createElement("div", { className: "k-actionsheet-content" },
178
+ React.createElement("div", { className: "k-list-ul", role: "group" }, topGroupItems && topGroupItems.map(function (item, idx) {
179
+ return (React.createElement(ActionSheetItem, __assign({}, item, { id: idx, key: idx, item: item, tabIndex: _this.props.tabIndex || 0, onClick: _this.handleItemClick })));
180
+ })),
181
+ shouldRenderSeparator && React.createElement("hr", { className: "k-hr" }),
182
+ React.createElement("div", { className: "k-list-ul", role: "group" }, bottomGroupItems && bottomGroupItems.map(function (item, idx) {
183
+ return (React.createElement(ActionSheetItem, __assign({}, item, { id: idx + ((topGroupItems === null || topGroupItems === void 0 ? void 0 : topGroupItems.length) || 0), key: idx, item: item, tabIndex: _this.props.tabIndex || 0, onClick: _this.handleItemClick })));
184
+ }))),
90
185
  children[footerDisplayName])))));
91
186
  };
92
187
  ;
@@ -108,7 +203,16 @@ var ActionSheet = /** @class */ (function (_super) {
108
203
  ActionSheet.propTypes = {
109
204
  items: PropTypes.array,
110
205
  subTitle: PropTypes.string,
111
- title: PropTypes.string
206
+ title: PropTypes.string,
207
+ navigatable: PropTypes.bool,
208
+ navigatableElements: PropTypes.array
209
+ };
210
+ /**
211
+ * @hidden
212
+ */
213
+ ActionSheet.defaultProps = {
214
+ navigatable: true,
215
+ navigatableElements: []
112
216
  };
113
217
  return ActionSheet;
114
218
  }(React.Component));
@@ -1,4 +1,6 @@
1
+ import * as React from 'react';
1
2
  import * as PropTypes from 'prop-types';
3
+ import { classNames } from '@progress/kendo-react-common';
2
4
  /**
3
5
  * @hidden
4
6
  */
@@ -6,7 +8,12 @@ export var contentDisplayName = 'ActionSheetContent';
6
8
  /**
7
9
  * The KendoReact ActionSheetContent component.
8
10
  */
9
- export var ActionSheetContent = function (props) { return props.children; };
11
+ export var ActionSheetContent = function (props) {
12
+ return (React.createElement("div", { className: classNames('k-actionsheet-content', props.className) }, props.children));
13
+ };
14
+ ActionSheetContent.propTypes = {
15
+ className: PropTypes.string
16
+ };
10
17
  /**
11
18
  * @hidden
12
19
  */
@@ -1,4 +1,6 @@
1
+ import * as React from 'react';
1
2
  import * as PropTypes from 'prop-types';
3
+ import { classNames } from '@progress/kendo-react-common';
2
4
  /**
3
5
  * @hidden
4
6
  */
@@ -6,7 +8,12 @@ export var footerDisplayName = 'ActionSheetFooter';
6
8
  /**
7
9
  * The KendoReact ActionSheetFooter component.
8
10
  */
9
- export var ActionSheetFooter = function (props) { return props.children; };
11
+ export var ActionSheetFooter = function (props) {
12
+ return (React.createElement("div", { className: classNames('k-actionsheet-footer', props.className) }, props.children));
13
+ };
14
+ ActionSheetFooter.propTypes = {
15
+ className: PropTypes.string
16
+ };
10
17
  /**
11
18
  * @hidden
12
19
  */
@@ -1,4 +1,6 @@
1
+ import * as React from 'react';
1
2
  import * as PropTypes from 'prop-types';
3
+ import { classNames } from '@progress/kendo-react-common';
2
4
  /**
3
5
  * @hidden
4
6
  */
@@ -6,7 +8,12 @@ export var headerDisplayName = 'ActionSheetHeader';
6
8
  /**
7
9
  * The KendoReact ActionSheetHeader component.
8
10
  */
9
- export var ActionSheetHeader = function (props) { return props.children; };
11
+ export var ActionSheetHeader = function (props) {
12
+ return (React.createElement("div", { className: classNames('k-actionsheet-header', props.className) }, props.children));
13
+ };
14
+ ActionSheetHeader.propTypes = {
15
+ className: PropTypes.string
16
+ };
10
17
  /**
11
18
  * @hidden
12
19
  */
@@ -5,19 +5,22 @@ import { classNames } from '@progress/kendo-react-common';
5
5
  * The KendoReact ActionSheetItem component.
6
6
  */
7
7
  export var ActionSheetItem = function (props) {
8
- var defaultTabIndex = 0;
9
8
  var itemRef = React.useRef(null);
10
9
  var onClick = React.useCallback(function (event) {
11
10
  if (props.onClick) {
12
- props.onClick.call(undefined, { syntheticEvent: event, title: props.title });
11
+ props.onClick.call(undefined, {
12
+ syntheticEvent: event,
13
+ item: props.item,
14
+ title: props.title
15
+ });
13
16
  }
14
- }, [props.title, props.onClick]);
17
+ }, [props.item, props.title, props.onClick]);
15
18
  React.useEffect(function () {
16
19
  if (itemRef.current && props.focused) {
17
20
  itemRef.current.focus();
18
21
  }
19
22
  }, [props.focused]);
20
- return (React.createElement("span", { style: props.style, className: classNames('k-actionsheet-item', 'k-cursor-pointer', props.disabled && 'k-disabled', props.className), role: "button", ref: itemRef, "aria-disabled": props.disabled, tabIndex: props.tabIndex || defaultTabIndex, onClick: onClick },
23
+ return (React.createElement("span", { style: props.style, tabIndex: props.tabIndex, className: classNames('k-actionsheet-item', 'k-cursor-pointer', props.disabled && 'k-disabled', props.className), ref: itemRef, role: "button", "aria-disabled": props.disabled, onClick: onClick },
21
24
  React.createElement("span", { className: "k-actionsheet-action" },
22
25
  props.icon && React.createElement("span", { className: "k-icon-wrap" }, props.icon),
23
26
  (props.title || props.description) && (React.createElement("span", { className: "k-actionsheet-item-text" },
@@ -2,6 +2,10 @@
2
2
  * @hidden
3
3
  */
4
4
  export interface ActionSheetChildrenProps {
5
+ /**
6
+ * ClassName of the rendered element.
7
+ */
8
+ className?: any;
5
9
  /**
6
10
  * Represents the children that are passed to the ActionSheet.
7
11
  */
@@ -12,7 +12,12 @@ export interface ActionSheetItemProps {
12
12
  */
13
13
  style?: React.CSSProperties;
14
14
  /**
15
- * Specifies the `tabIndex` of the ActionSheet.
15
+ * **Deprecated**. Specifies the `tabIndex` of the ActionSheetItem.
16
+ *
17
+ * Set the tabIndex to the ActionSheet component instead.
18
+ *
19
+ * @deprecated
20
+ *
16
21
  */
17
22
  tabIndex?: number;
18
23
  /**
@@ -36,15 +41,27 @@ export interface ActionSheetItemProps {
36
41
  * Specifies the text content of the ActionSheet item.
37
42
  */
38
43
  title?: string;
44
+ /**
45
+ * Specifies the ActionSheet item.
46
+ */
47
+ item?: any;
39
48
  /**
40
49
  * @hidden
41
50
  */
42
51
  onClick?: (event: {
43
- syntheticEvent: React.MouseEvent<HTMLSpanElement>;
52
+ syntheticEvent: React.SyntheticEvent;
44
53
  title?: string;
45
54
  }) => void;
55
+ /**
56
+ * @hidden
57
+ */
58
+ onKeyDown?: (event: React.SyntheticEvent, title: string | undefined, id: number | undefined) => void;
46
59
  /**
47
60
  * @hidden
48
61
  */
49
62
  focused?: boolean;
63
+ /**
64
+ * @hidden
65
+ */
66
+ id?: number;
50
67
  }
@@ -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: 1676630656,
8
+ publishDate: 1676976502,
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
  };
@@ -17,26 +17,56 @@ export interface ActionSheetProps {
17
17
  * Specifies the text that is rendered as title.
18
18
  */
19
19
  title?: string;
20
+ /**
21
+ * **Deprecated**. Fires when the modal overlay is clicked. Use `onClose` event instead.
22
+ *
23
+ * @deprecated
24
+ */
25
+ onOverlayClick?: (event: React.SyntheticEvent) => void;
20
26
  /**
21
27
  * Fires when the modal overlay is clicked.
22
28
  */
23
- onOverlayClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
29
+ onClose?: (event: React.SyntheticEvent) => void;
24
30
  /**
25
31
  * Fires when an ActionSheet item is clicked.
26
32
  */
33
+ onItemSelect?: (event: {
34
+ syntheticEvent: React.SyntheticEvent;
35
+ title?: string;
36
+ item?: any;
37
+ }) => void;
38
+ /**
39
+ * **Deprecated**. Fires when an ActionSheet item is clicked. Use `onItemSelect` event instead.
40
+ *
41
+ * @deprecated
42
+ */
27
43
  onItemClick?: (event: {
28
- syntheticEvent: React.MouseEvent<HTMLSpanElement>;
44
+ syntheticEvent: React.SyntheticEvent;
29
45
  title?: string;
46
+ item?: any;
30
47
  }) => void;
31
48
  /**
32
49
  * Represents the children that are passed to the ActionSheet.
33
50
  */
34
51
  children?: any;
52
+ /**
53
+ * Specifies the `tabIndex` of the ActionSheet.
54
+ */
55
+ tabIndex?: number;
56
+ /**
57
+ * Specifies if the ActionSheet can be navigatable with keyboard.
58
+ * Defaults to `true`.
59
+ */
60
+ navigatable: boolean;
61
+ /**
62
+ * Specifies the selectors of the navigatable elements inside the templates of the ActionSheet.
63
+ */
64
+ navigatableElements: string[];
35
65
  }
36
66
  /**
37
67
  * Represents the [KendoReact ActionSheet]({% slug overview_actionsheet %}) component.
38
68
  */
39
- export declare class ActionSheet extends React.Component<ActionSheetProps, {}> {
69
+ export declare class ActionSheet extends React.Component<ActionSheetProps> {
40
70
  /**
41
71
  * @hidden
42
72
  */
@@ -48,10 +78,20 @@ export declare class ActionSheet extends React.Component<ActionSheetProps, {}> {
48
78
  items: PropTypes.Requireable<any[]>;
49
79
  subTitle: PropTypes.Requireable<string>;
50
80
  title: PropTypes.Requireable<string>;
81
+ navigatable: PropTypes.Requireable<boolean>;
82
+ navigatableElements: PropTypes.Requireable<any[]>;
83
+ };
84
+ /**
85
+ * @hidden
86
+ */
87
+ static defaultProps: {
88
+ navigatable: boolean;
89
+ navigatableElements: never[];
51
90
  };
52
91
  private actionSheetAnimationRef;
53
92
  private actionSheetTitleClass;
54
93
  private ariaLabeledBy;
94
+ private navigation?;
55
95
  /**
56
96
  * @hidden
57
97
  */
@@ -64,5 +104,11 @@ export declare class ActionSheet extends React.Component<ActionSheetProps, {}> {
64
104
  * @hidden
65
105
  */
66
106
  render(): JSX.Element;
107
+ private handleKeyDown;
108
+ private onTab;
109
+ private handleOverlayClick;
110
+ private handleItemClick;
111
+ private onEnter;
112
+ private onEscape;
67
113
  private children;
68
114
  }