@progress/kendo-react-layout 13.4.0-develop.5 → 14.0.0-develop.2

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.
@@ -5,144 +5,202 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as d from "react";
8
+ import * as n from "react";
9
9
  import r from "prop-types";
10
- import { TabStripNavigation as f } from "./TabStripNavigation.mjs";
11
- import { TabStripContent as S } from "./TabStripContent.mjs";
12
- import { Navigation as g, classNames as v, kendoThemeMaps as x } from "@progress/kendo-react-common";
13
- const p = class p extends d.Component {
14
- constructor(l) {
15
- super(l), this.tabStripRef = d.createRef(), this.itemsNavRef = d.createRef(), this.onScroll = () => {
16
- const i = this.horizontalScroll(), o = this.itemsNavRef.current;
17
- if (!o)
18
- return;
19
- const e = o.scrollLeft, t = o.clientWidth, n = o.scrollWidth, s = o.scrollTop, c = o.scrollHeight, h = o.clientHeight;
20
- let a = null;
21
- const m = i ? n > t : c > h, b = this.props.dir === "rtl";
22
- m ? i ? e + t === n || (b && t - e) === n ? a = "end" : e === 0 || b && -e === 0 ? a = "start" : e > 0 && e + t < n || -e > 0 && t - e < n ? a = "middle" : a = null : c - (s + h) === 0 ? a = "bottom" : s === 0 ? a = "top" : s > 0 && c - (s + h) > 0 ? a = "middle" : a = null : a = null, this.setState({ containerScrollPosition: a });
23
- }, this.onSelect = (i) => {
24
- this.props.selected !== i && this.props.onSelect && this.props.onSelect({
25
- selected: i
10
+ import { TabStripNavigation as Y } from "./TabStripNavigation.mjs";
11
+ import { TabStripContent as ie } from "./TabStripContent.mjs";
12
+ import { Navigation as ce, classNames as ae, kendoThemeMaps as ue } from "@progress/kendo-react-common";
13
+ const de = {
14
+ animation: !0,
15
+ tabPosition: "top",
16
+ tabAlignment: "start",
17
+ keepTabsMounted: !1,
18
+ buttonScrollSpeed: 100,
19
+ mouseScrollSpeed: 10,
20
+ scrollButtons: "auto",
21
+ scrollButtonsPosition: "split",
22
+ renderAllContent: !1
23
+ }, E = n.forwardRef((Z, _) => {
24
+ const R = { ...de, ...Z }, {
25
+ id: m,
26
+ animation: H,
27
+ children: M,
28
+ selected: u,
29
+ onSelect: A,
30
+ style: ee,
31
+ tabContentStyle: O,
32
+ tabPosition: p,
33
+ tabAlignment: z,
34
+ tabIndex: L,
35
+ className: W,
36
+ dir: v,
37
+ renderAllContent: P,
38
+ keepTabsMounted: K,
39
+ size: h,
40
+ scrollable: g,
41
+ scrollButtons: x,
42
+ scrollButtonsPosition: j,
43
+ buttonScrollSpeed: F,
44
+ mouseScrollSpeed: te,
45
+ prevButton: U,
46
+ nextButton: $
47
+ } = R, [f, ne] = n.useState(null), oe = n.useRef({ props: R }), C = n.useRef(null), D = n.useRef(null), T = n.useRef(void 0), I = n.useRef(void 0), q = n.useCallback(() => ({ props: R }), [R]);
48
+ n.useImperativeHandle(oe, q), n.useImperativeHandle(_, q);
49
+ const y = n.useMemo(() => m ? m + "-content-panel-id" : void 0, [m]), w = n.useMemo(() => m ? m + "-nav-item-id" : void 0, [m]), S = n.useMemo(() => n.Children.toArray(M).filter(Boolean), [M]), G = n.useCallback(() => /top|bottom/.test(p || "top"), [p]), k = n.useCallback(() => {
50
+ const s = G(), i = D.current;
51
+ if (!i)
52
+ return;
53
+ const a = i.scrollLeft, t = i.clientWidth, e = i.scrollWidth, l = i.scrollTop, o = i.scrollHeight, d = i.clientHeight;
54
+ let c = null;
55
+ const re = s ? e > t : o > d, X = v === "rtl";
56
+ re ? s ? a + t === e || (X && t - a) === e ? c = "end" : a === 0 || X && -a === 0 ? c = "start" : a > 0 && a + t < e || -a > 0 && t - a < e ? c = "middle" : c = null : o - (l + d) === 0 ? c = "bottom" : l === 0 ? c = "top" : l > 0 && o - (l + d) > 0 ? c = "middle" : c = null : c = null, ne(c);
57
+ }, [G, v]), B = n.useCallback(
58
+ (s) => {
59
+ u !== s && A && A({
60
+ selected: s
26
61
  });
27
- }, this.onKeyDown = (i) => {
28
- this.navigation && this.navigation.triggerKeyboardEvent(i);
29
- }, this.onKeyboardSelect = (i) => {
30
- const o = this.children();
31
- o && o[i].props.disabled || this.onSelect(i);
32
- }, this.renderContent = (i) => {
33
- const { selected: o, children: e, tabContentStyle: t } = i, n = d.Children.count(e);
34
- return o < n && o > -1 ? /* @__PURE__ */ d.createElement(S, { index: o, ...i, style: t }) : null;
35
- }, this.state = {
36
- containerScrollPosition: null
37
- }, this.itemsNavRef = d.createRef();
38
- }
39
- get contentPanelId() {
40
- return this.props.id + "-content-panel-id";
41
- }
42
- get navItemId() {
43
- return this.props.id + "-nav-item-id";
44
- }
45
- /** @hidden */
46
- componentDidMount() {
47
- var o;
48
- const l = this.tabStripRef.current, i = l && getComputedStyle(l).direction === "rtl" || !1;
49
- l && (this.navigation = new g({
62
+ },
63
+ [u, A]
64
+ ), b = n.useCallback(
65
+ (s) => {
66
+ var t, e;
67
+ const i = S;
68
+ ((e = (t = i == null ? void 0 : i[s]) == null ? void 0 : t.props) == null ? void 0 : e.disabled) || B(s);
69
+ },
70
+ [S, B]
71
+ ), J = n.useCallback((s) => {
72
+ I.current && I.current.triggerKeyboardEvent(s);
73
+ }, []);
74
+ n.useEffect(() => {
75
+ var a;
76
+ const s = C.current, i = s && getComputedStyle(s).direction === "rtl" || !1;
77
+ return s && (I.current = new ce({
50
78
  tabIndex: 0,
51
- root: this.tabStripRef,
79
+ root: C,
52
80
  rovingTabIndex: !0,
53
81
  focusClass: "k-focus",
54
82
  selectors: [".k-tabstrip .k-tabstrip-item"],
55
83
  keyboardEvents: {
56
84
  keydown: {
57
- ArrowLeft: (e, t, n) => {
58
- n.preventDefault();
59
- const s = t.elements.indexOf(e), c = s !== 0 ? s - 1 : t.elements.length - 1, h = s !== t.elements.length - 1 ? s + 1 : 0;
60
- i ? (t.focusNext(e), this.onKeyboardSelect(h)) : (t.focusPrevious(e), this.onKeyboardSelect(c));
85
+ ArrowLeft: (t, e, l) => {
86
+ l.preventDefault();
87
+ const o = e.elements.indexOf(t), d = o !== 0 ? o - 1 : e.elements.length - 1, c = o !== e.elements.length - 1 ? o + 1 : 0;
88
+ i ? (e.focusNext(t), b(c)) : (e.focusPrevious(t), b(d));
61
89
  },
62
- ArrowRight: (e, t, n) => {
63
- n.preventDefault();
64
- const s = t.elements.indexOf(e), c = s !== 0 ? s - 1 : t.elements.length - 1, h = s !== t.elements.length - 1 ? s + 1 : 0;
65
- i ? (t.focusPrevious(e), this.onKeyboardSelect(c)) : (t.focusNext(e), this.onKeyboardSelect(h));
90
+ ArrowRight: (t, e, l) => {
91
+ l.preventDefault();
92
+ const o = e.elements.indexOf(t), d = o !== 0 ? o - 1 : e.elements.length - 1, c = o !== e.elements.length - 1 ? o + 1 : 0;
93
+ i ? (e.focusPrevious(t), b(d)) : (e.focusNext(t), b(c));
66
94
  },
67
- ArrowDown: (e, t, n) => {
68
- n.preventDefault();
69
- const s = t.elements.indexOf(e), c = s !== t.elements.length - 1 ? s + 1 : 0;
70
- t.focusNext(e), this.onKeyboardSelect(c);
95
+ ArrowDown: (t, e, l) => {
96
+ l.preventDefault();
97
+ const o = e.elements.indexOf(t), d = o !== e.elements.length - 1 ? o + 1 : 0;
98
+ e.focusNext(t), b(d);
71
99
  },
72
- ArrowUp: (e, t, n) => {
73
- n.preventDefault();
74
- const s = t.elements.indexOf(e), c = s !== 0 ? s - 1 : t.elements.length - 1;
75
- t.focusPrevious(e), this.onKeyboardSelect(c);
100
+ ArrowUp: (t, e, l) => {
101
+ l.preventDefault();
102
+ const o = e.elements.indexOf(t), d = o !== 0 ? o - 1 : e.elements.length - 1;
103
+ e.focusPrevious(t), b(d);
76
104
  },
77
- Home: (e, t, n) => {
78
- n.preventDefault(), t.focusElement(t.first, e), this.onKeyboardSelect(0);
105
+ Home: (t, e, l) => {
106
+ l.preventDefault(), e.focusElement(e.first, t), b(0);
79
107
  },
80
- End: (e, t, n) => {
81
- n.preventDefault(), t.focusElement(t.last, e), this.onKeyboardSelect(t.elements.length - 1);
108
+ End: (t, e, l) => {
109
+ l.preventDefault(), e.focusElement(e.last, t), b(e.elements.length - 1);
82
110
  }
83
111
  }
84
112
  }
85
- }), (o = this.navigation) == null || o.initializeRovingTab(this.props.selected), this.onScroll(), this.resizeObserver = window.ResizeObserver && new ResizeObserver(() => this.onScroll()), this.tabStripRef.current && this.resizeObserver && this.resizeObserver.observe(this.tabStripRef.current));
86
- }
87
- /** @hidden */
88
- componentWillUnmount() {
89
- var l;
90
- (l = this.navigation) == null || l.removeFocusListener(), this.resizeObserver && this.resizeObserver.disconnect();
91
- }
92
- horizontalScroll() {
93
- return /top|bottom/.test(this.props.tabPosition || "top");
94
- }
95
- /**
96
- * @hidden
97
- */
98
- render() {
99
- const l = {
100
- itemsNavRef: this.itemsNavRef,
101
- ...this.props,
102
- children: this.children(),
103
- contentPanelId: this.contentPanelId,
104
- renderAllContent: this.props.renderAllContent,
105
- navItemId: this.navItemId,
106
- onKeyDown: this.onKeyDown,
107
- onSelect: this.onSelect,
108
- onScroll: this.onScroll,
109
- containerScrollPosition: this.state.containerScrollPosition,
110
- scrollButtons: this.props.scrollButtons === "hidden" || this.state.containerScrollPosition === null && this.props.scrollButtons === "auto" ? "hidden" : "visible"
111
- }, { scrollable: i, scrollButtons: o, size: e, tabPosition: t, tabIndex: n } = l, s = t === "bottom", c = v(
112
- "k-tabstrip k-pos-relative",
113
+ }), (a = I.current) == null || a.initializeRovingTab(u), k(), T.current = window.ResizeObserver && new ResizeObserver(() => k()), C.current && T.current && T.current.observe(C.current)), () => {
114
+ var t;
115
+ (t = I.current) == null || t.removeFocusListener(), T.current && T.current.disconnect();
116
+ };
117
+ }, [u, b, k]);
118
+ const se = n.useMemo(() => {
119
+ const s = n.Children.count(S);
120
+ return u < s && u > -1 ? /* @__PURE__ */ n.createElement(
121
+ ie,
113
122
  {
114
- [`k-tabstrip-${x.sizeMap[e] || e}`]: e,
115
- "k-tabstrip-left": t === "left",
116
- "k-tabstrip-right": t === "right",
117
- "k-tabstrip-bottom": t === "bottom",
118
- "k-tabstrip-top": t === "top",
119
- "k-tabstrip-scrollable": i,
120
- "k-tabstrip-scrollable-start k-tabstrip-scrollable-end": i && o === "visible",
121
- "k-tabstrip-scrollable-start": i && (o === "auto" || !o) && (this.state.containerScrollPosition === "end" || this.state.containerScrollPosition === "middle"),
122
- "k-tabstrip-scrollable-end": i && o === "auto" && (this.state.containerScrollPosition === "start" || this.state.containerScrollPosition === "middle")
123
+ index: u,
124
+ selected: u,
125
+ contentPanelId: y,
126
+ navItemId: w,
127
+ animation: H,
128
+ keepTabsMounted: K,
129
+ renderAllContent: P,
130
+ style: O
123
131
  },
124
- this.props.className
125
- );
126
- return /* @__PURE__ */ d.createElement(
127
- "div",
132
+ S
133
+ ) : null;
134
+ }, [u, S, y, w, H, K, P, O]), N = x === "hidden" || f === null && x === "auto" ? "hidden" : "visible", Q = n.useMemo(
135
+ () => ({
136
+ itemsNavRef: D,
137
+ children: S,
138
+ selected: u,
139
+ tabIndex: L,
140
+ tabPosition: p,
141
+ tabAlignment: z,
142
+ size: h,
143
+ scrollable: g,
144
+ scrollButtons: N,
145
+ scrollButtonsPosition: j,
146
+ buttonScrollSpeed: F,
147
+ mouseScrollSpeed: te,
148
+ prevButton: U,
149
+ nextButton: $,
150
+ dir: v,
151
+ contentPanelId: y,
152
+ renderAllContent: P,
153
+ navItemId: w,
154
+ onKeyDown: J,
155
+ onSelect: B,
156
+ onScroll: k,
157
+ containerScrollPosition: f
158
+ }),
159
+ [
160
+ D,
161
+ S,
162
+ u,
163
+ L,
164
+ p,
165
+ z,
166
+ h,
167
+ g,
168
+ N,
169
+ j,
170
+ F,
171
+ U,
172
+ $,
173
+ v,
174
+ y,
175
+ P,
176
+ w,
177
+ J,
178
+ B,
179
+ k,
180
+ f
181
+ ]
182
+ ), V = p === "bottom", le = n.useMemo(
183
+ () => ae(
184
+ "k-tabstrip k-pos-relative",
128
185
  {
129
- id: this.props.id,
130
- ref: this.tabStripRef,
131
- dir: this.props.dir,
132
- className: c,
133
- style: this.props.style,
134
- onScroll: this.onScroll
186
+ [`k-tabstrip-${ue.sizeMap[h || "medium"] || h}`]: h,
187
+ "k-tabstrip-left": p === "left",
188
+ "k-tabstrip-right": p === "right",
189
+ "k-tabstrip-bottom": p === "bottom",
190
+ "k-tabstrip-top": p === "top",
191
+ "k-tabstrip-scrollable": g,
192
+ "k-tabstrip-scrollable-start k-tabstrip-scrollable-end": g && N === "visible",
193
+ "k-tabstrip-scrollable-start": g && x === "auto" && (f === "end" || f === "middle"),
194
+ "k-tabstrip-scrollable-end": g && x === "auto" && (f === "start" || f === "middle")
135
195
  },
136
- !s && /* @__PURE__ */ d.createElement(f, { ...l, tabIndex: n }),
137
- this.renderContent(l),
138
- s && /* @__PURE__ */ d.createElement(f, { ...l, tabIndex: n })
139
- );
140
- }
141
- children() {
142
- return d.Children.toArray(this.props.children).filter((l) => l);
143
- }
144
- };
145
- p.propTypes = {
196
+ W
197
+ ),
198
+ [h, p, g, x, N, f, W]
199
+ );
200
+ return /* @__PURE__ */ n.createElement("div", { id: m, ref: C, dir: v, className: le, style: ee, onScroll: k }, !V && /* @__PURE__ */ n.createElement(Y, { ...Q }), se, V && /* @__PURE__ */ n.createElement(Y, { ...Q }));
201
+ });
202
+ E.displayName = "TabStrip";
203
+ E.propTypes = {
146
204
  id: r.string,
147
205
  animation: r.bool,
148
206
  children: r.node,
@@ -156,22 +214,11 @@ p.propTypes = {
156
214
  className: r.string,
157
215
  dir: r.string,
158
216
  renderAllContent: r.bool,
159
- size: r.oneOf(["small", "medium", "large", null]),
217
+ size: r.oneOf(["small", "medium", "large"]),
160
218
  scrollButtons: r.oneOf(["auto", "visible", "hidden"]),
161
219
  scrollButtonsPosition: r.oneOf(["split", "start", "end", "around", "before", "after"])
162
- }, p.defaultProps = {
163
- animation: !0,
164
- tabPosition: "top",
165
- tabAlignment: "start",
166
- keepTabsMounted: !1,
167
- buttonScrollSpeed: 100,
168
- mouseScrollSpeed: 10,
169
- scrollButtons: "auto",
170
- scrollButtonsPosition: "split",
171
- size: void 0,
172
- renderAllContent: !1
173
220
  };
174
- let u = p;
221
+ const ge = E;
175
222
  export {
176
- u as TabStrip
223
+ ge as TabStrip
177
224
  };
@@ -5,7 +5,6 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import { default as PropTypes } from 'prop-types';
9
8
  import * as React from 'react';
10
9
  /**
11
10
  * The props that are passed to the TabStripContent by the TabStrip.
@@ -48,23 +47,4 @@ export interface TabStripContentProps {
48
47
  */
49
48
  navItemId?: string;
50
49
  }
51
- export declare class TabStripContent extends React.Component<TabStripContentProps, {}> {
52
- /**
53
- * @hidden
54
- */
55
- static propTypes: {
56
- animation: PropTypes.Requireable<boolean>;
57
- children: PropTypes.Requireable<NonNullable<PropTypes.ReactElementLike | (PropTypes.ReactElementLike | null | undefined)[] | null | undefined>>;
58
- selected: PropTypes.Requireable<number>;
59
- style: PropTypes.Requireable<object>;
60
- };
61
- private contentId;
62
- /**
63
- * @hidden
64
- */
65
- render(): React.JSX.Element | React.JSX.Element[] | null | undefined;
66
- private renderContent;
67
- private renderAllContent;
68
- private renderChild;
69
- private childFactory;
70
- }
50
+ export declare const TabStripContent: React.FC<TabStripContentProps>;
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),i=require("prop-types"),h=require("@progress/kendo-react-animation"),u=require("@progress/kendo-react-common");function b(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const r=b(y),c=class c extends r.Component{constructor(){super(...arguments),this.contentId=this.props.contentPanelId,this.childFactory=e=>r.cloneElement(e,{...e.props,in:e.props.children.props.id===String(this.contentId+this.props.selected)})}render(){const{children:e,selected:t,contentPanelId:n,keepTabsMounted:s,navItemId:o,renderAllContent:l}=this.props,d=e&&typeof t=="number"&&r.Children.toArray(e)[t],m=u.classNames("k-tabstrip-content","k-active",d&&d.props.contentClassName);return l?this.renderAllContent(e):r.createElement("div",{className:m,style:this.props.style,id:n,role:"tabpanel","aria-hidden":s,"aria-labelledby":`${o}-${(t==null?void 0:t.toString())||""}`,tabIndex:0},this.renderContent(e))}renderContent(e){return this.props.keepTabsMounted?r.Children.map(this.props.children,(t,n)=>this.renderChild(t,n)):this.renderChild(r.Children.toArray(e)[this.props.selected],this.props.selected)}renderAllContent(e){return r.Children.map(e,(t,n)=>{const s=t,o=n===this.props.selected,l=u.classNames("k-tabstrip-content",{"k-active":o},s.props.contentClassName);return r.createElement("div",{className:l,style:this.props.style,id:`${this.props.contentPanelId}-${n}`,role:"tabpanel","aria-hidden":!o,hidden:!o,"aria-labelledby":`${this.props.navItemId}-${n}`},this.props.animation?r.createElement(h.Fade,{key:`${n}-${o}`,appear:!0,enter:!0,exit:!1},s.props.children):s.props.children)})}renderChild(e,t){const n=t===this.props.selected,s={style:{display:n?void 0:"none"}},o={position:"initial",display:n?void 0:"none"};return e.props.disabled?null:this.props.animation?r.createElement(h.Fade,{appear:!0,exit:this.props.keepTabsMounted,style:o,childFactory:this.props.keepTabsMounted?this.childFactory:void 0},r.createElement("div",{...s,id:String(this.contentId+t),key:t},e.props.children)):r.createElement("div",{...s,key:t},e.props.children)}};c.propTypes={animation:i.bool,children:i.oneOfType([i.element,i.arrayOf(i.element)]),selected:i.number,style:i.object};let p=c;exports.TabStripContent=p;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react"),c=require("prop-types"),v=require("@progress/kendo-react-animation"),S=require("@progress/kendo-react-common");function N(s){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const e in s)if(e!=="default"){const l=Object.getOwnPropertyDescriptor(s,e);Object.defineProperty(o,e,l.get?l:{enumerable:!0,get:()=>s[e]})}}return o.default=s,Object.freeze(o)}const t=N(M),h=s=>{const{children:o,selected:e,contentPanelId:l,keepTabsMounted:p,navItemId:b,renderAllContent:g,animation:d,style:y}=s,u=l,k=t.useCallback(n=>t.cloneElement(n,{...n.props,in:n.props.children.props.id===String(u+e)}),[u,e]),C=t.useCallback((n,r)=>{const a=r===e,i={style:{display:a?void 0:"none"}},f={display:a?void 0:"none"};return n.props.disabled?null:d?t.createElement(v.Fade,{appear:!0,exit:p,style:f,childFactory:p?k:void 0},t.createElement("div",{...i,id:String(u+r),key:r},n.props.children)):t.createElement("div",{...i,key:r},n.props.children)},[e,d,p,k,u]),O=t.useCallback(n=>p?t.Children.map(n,(r,a)=>C(r,a)):C(t.Children.toArray(n)[e],e),[p,C,e]),T=t.useMemo(()=>t.Children.map(o,(n,r)=>{const a=n,i=r===e,f=S.classNames("k-tabstrip-content",{"k-active":i},a.props.contentClassName),E=d?t.createElement(v.Fade,{key:`${r}-${i}`,appear:!0,enter:!0,exit:!1},a.props.children):a.props.children;return t.createElement("div",{className:f,style:y,id:`${l}-${r}`,role:"tabpanel","aria-hidden":!i,hidden:!i,"aria-labelledby":`${b}-${r}`},E)}),[o,e,l,b,y,d]),m=t.useMemo(()=>!o||typeof e!="number"?null:t.Children.toArray(o)[e],[o,e]),$=t.useMemo(()=>S.classNames("k-tabstrip-content","k-active",m==null?void 0:m.props.contentClassName),[m]);return g?T:t.createElement("div",{className:$,style:y,id:l,role:"tabpanel","aria-hidden":p,"aria-labelledby":`${b}-${(e==null?void 0:e.toString())||""}`,tabIndex:0},O(o))};h.propTypes={animation:c.bool,children:c.oneOfType([c.element,c.arrayOf(c.element)]),selected:c.number,style:c.object};h.displayName="TabStripContent";exports.TabStripContent=h;
@@ -5,96 +5,88 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as n from "react";
9
- import i from "prop-types";
10
- import { Fade as d } from "@progress/kendo-react-animation";
11
- import { classNames as c } from "@progress/kendo-react-common";
12
- const l = class l extends n.Component {
13
- constructor() {
14
- super(...arguments), this.contentId = this.props.contentPanelId, this.childFactory = (e) => n.cloneElement(e, {
15
- ...e.props,
16
- in: e.props.children.props.id === String(this.contentId + this.props.selected)
17
- });
18
- }
19
- /**
20
- * @hidden
21
- */
22
- render() {
23
- const { children: e, selected: t, contentPanelId: r, keepTabsMounted: s, navItemId: o, renderAllContent: p } = this.props, a = e && typeof t == "number" && n.Children.toArray(e)[t], m = c(
8
+ import * as e from "react";
9
+ import l from "prop-types";
10
+ import { Fade as f } from "@progress/kendo-react-animation";
11
+ import { classNames as v } from "@progress/kendo-react-common";
12
+ const k = ($) => {
13
+ const { children: s, selected: t, contentPanelId: p, keepTabsMounted: i, navItemId: u, renderAllContent: E, animation: c, style: y } = $, d = p, h = e.useCallback(
14
+ (n) => e.cloneElement(n, {
15
+ ...n.props,
16
+ in: n.props.children.props.id === String(d + t)
17
+ }),
18
+ [d, t]
19
+ ), b = e.useCallback(
20
+ (n, r) => {
21
+ const o = r === t, a = {
22
+ style: {
23
+ display: o ? void 0 : "none"
24
+ }
25
+ }, C = {
26
+ display: o ? void 0 : "none"
27
+ };
28
+ return n.props.disabled ? null : c ? /* @__PURE__ */ e.createElement(
29
+ f,
30
+ {
31
+ appear: !0,
32
+ exit: i,
33
+ style: C,
34
+ childFactory: i ? h : void 0
35
+ },
36
+ /* @__PURE__ */ e.createElement("div", { ...a, id: String(d + r), key: r }, n.props.children)
37
+ ) : /* @__PURE__ */ e.createElement("div", { ...a, key: r }, n.props.children);
38
+ },
39
+ [t, c, i, h, d]
40
+ ), S = e.useCallback(
41
+ (n) => i ? e.Children.map(n, (r, o) => b(r, o)) : b(
42
+ e.Children.toArray(n)[t],
43
+ t
44
+ ),
45
+ [i, b, t]
46
+ ), I = e.useMemo(() => e.Children.map(s, (n, r) => {
47
+ const o = n, a = r === t, C = v(
24
48
  "k-tabstrip-content",
25
- "k-active",
26
- a && a.props.contentClassName
27
- );
28
- return p ? this.renderAllContent(e) : /* @__PURE__ */ n.createElement(
49
+ { "k-active": a },
50
+ o.props.contentClassName
51
+ ), N = c ? /* @__PURE__ */ e.createElement(f, { key: `${r}-${a}`, appear: !0, enter: !0, exit: !1 }, o.props.children) : o.props.children;
52
+ return /* @__PURE__ */ e.createElement(
29
53
  "div",
30
54
  {
31
- className: m,
32
- style: this.props.style,
33
- id: r,
55
+ className: C,
56
+ style: y,
57
+ id: `${p}-${r}`,
34
58
  role: "tabpanel",
35
- "aria-hidden": s,
36
- "aria-labelledby": `${o}-${(t == null ? void 0 : t.toString()) || ""}`,
37
- tabIndex: 0
59
+ "aria-hidden": !a,
60
+ hidden: !a,
61
+ "aria-labelledby": `${u}-${r}`
38
62
  },
39
- this.renderContent(e)
40
- );
41
- }
42
- renderContent(e) {
43
- return this.props.keepTabsMounted ? n.Children.map(this.props.children, (t, r) => this.renderChild(t, r)) : this.renderChild(
44
- n.Children.toArray(e)[this.props.selected],
45
- this.props.selected
63
+ N
46
64
  );
47
- }
48
- renderAllContent(e) {
49
- return n.Children.map(e, (t, r) => {
50
- const s = t, o = r === this.props.selected, p = c(
51
- "k-tabstrip-content",
52
- { "k-active": o },
53
- s.props.contentClassName
54
- );
55
- return /* @__PURE__ */ n.createElement(
56
- "div",
57
- {
58
- className: p,
59
- style: this.props.style,
60
- id: `${this.props.contentPanelId}-${r}`,
61
- role: "tabpanel",
62
- "aria-hidden": !o,
63
- hidden: !o,
64
- "aria-labelledby": `${this.props.navItemId}-${r}`
65
- },
66
- this.props.animation ? /* @__PURE__ */ n.createElement(d, { key: `${r}-${o}`, appear: !0, enter: !0, exit: !1 }, s.props.children) : s.props.children
67
- );
68
- });
69
- }
70
- renderChild(e, t) {
71
- const r = t === this.props.selected, s = {
72
- style: {
73
- display: r ? void 0 : "none"
74
- }
75
- }, o = {
76
- position: "initial",
77
- display: r ? void 0 : "none"
78
- };
79
- return e.props.disabled ? null : this.props.animation ? /* @__PURE__ */ n.createElement(
80
- d,
81
- {
82
- appear: !0,
83
- exit: this.props.keepTabsMounted,
84
- style: o,
85
- childFactory: this.props.keepTabsMounted ? this.childFactory : void 0
86
- },
87
- /* @__PURE__ */ n.createElement("div", { ...s, id: String(this.contentId + t), key: t }, e.props.children)
88
- ) : /* @__PURE__ */ n.createElement("div", { ...s, key: t }, e.props.children);
89
- }
65
+ }), [s, t, p, u, y, c]), m = e.useMemo(() => !s || typeof t != "number" ? null : e.Children.toArray(s)[t], [s, t]), M = e.useMemo(
66
+ () => v("k-tabstrip-content", "k-active", m == null ? void 0 : m.props.contentClassName),
67
+ [m]
68
+ );
69
+ return E ? I : /* @__PURE__ */ e.createElement(
70
+ "div",
71
+ {
72
+ className: M,
73
+ style: y,
74
+ id: p,
75
+ role: "tabpanel",
76
+ "aria-hidden": i,
77
+ "aria-labelledby": `${u}-${(t == null ? void 0 : t.toString()) || ""}`,
78
+ tabIndex: 0
79
+ },
80
+ S(s)
81
+ );
90
82
  };
91
- l.propTypes = {
92
- animation: i.bool,
93
- children: i.oneOfType([i.element, i.arrayOf(i.element)]),
94
- selected: i.number,
95
- style: i.object
83
+ k.propTypes = {
84
+ animation: l.bool,
85
+ children: l.oneOfType([l.element, l.arrayOf(l.element)]),
86
+ selected: l.number,
87
+ style: l.object
96
88
  };
97
- let h = l;
89
+ k.displayName = "TabStripContent";
98
90
  export {
99
- h as TabStripContent
91
+ k as TabStripContent
100
92
  };
@@ -5,7 +5,6 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import { default as PropTypes } from 'prop-types';
9
8
  import { TabStripSize, ScrollButtons, ScrollButtonsPosition } from './TabStrip.js';
10
9
  import { ButtonProps } from '@progress/kendo-react-buttons';
11
10
  import * as React from 'react';
@@ -102,43 +101,4 @@ export interface TabStripNavigationProps {
102
101
  */
103
102
  itemsNavRef?: React.RefObject<HTMLUListElement | null>;
104
103
  }
105
- export declare class TabStripNavigation extends React.Component<TabStripNavigationProps, {}> {
106
- /**
107
- * @hidden
108
- */
109
- static propTypes: {
110
- children: PropTypes.Requireable<NonNullable<PropTypes.ReactElementLike | (PropTypes.ReactElementLike | null | undefined)[] | null | undefined>>;
111
- onSelect: PropTypes.Requireable<(...args: any[]) => any>;
112
- onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
113
- onScroll: PropTypes.Requireable<(...args: any[]) => any>;
114
- selected: PropTypes.Requireable<number>;
115
- tabIndex: PropTypes.Requireable<number>;
116
- scrollable: PropTypes.Requireable<boolean>;
117
- size: PropTypes.Requireable<string>;
118
- scrollButtons: PropTypes.Requireable<string>;
119
- scrollButtonsPosition: PropTypes.Requireable<string>;
120
- containerScrollPosition: PropTypes.Requireable<string | null>;
121
- };
122
- private itemsNavRef;
123
- /**
124
- * @hidden
125
- */
126
- componentDidMount(): void;
127
- /**
128
- * @hidden
129
- */
130
- componentDidUpdate(prevProps: Readonly<TabStripNavigationProps>): void;
131
- private onScroll;
132
- /**
133
- * @hidden
134
- */
135
- render(): React.JSX.Element;
136
- private scrollToSelected;
137
- private horizontalScroll;
138
- private isRtl;
139
- private arrowClickPrev;
140
- private arrowClickNext;
141
- private handleArrowClick;
142
- private setNewScrollPosition;
143
- private renderArrow;
144
- }
104
+ export declare const TabStripNavigation: React.FC<TabStripNavigationProps>;