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

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,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>;
@@ -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 L=require("react"),n=require("prop-types"),E=require("./TabStripNavigationItem.js"),w=require("@progress/kendo-react-common"),B=require("@progress/kendo-react-buttons"),m=require("@progress/kendo-svg-icons"),x=require("@progress/kendo-react-intl"),b=require("./messages/index.js");function y(d){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>d[e]})}}return t.default=d,Object.freeze(t)}const h=y(L),M=d=>Array.apply(null,Array(d)),v="smooth",f="prev",S="next",I=class I extends h.Component{constructor(){super(...arguments),this.itemsNavRef=this.props.itemsNavRef||h.createRef(),this.onScroll=()=>{var t,e;(e=(t=this.props).onScroll)==null||e.call(t)},this.isRtl=()=>this.props.dir==="rtl",this.arrowClickPrev=t=>{this.handleArrowClick(f,t)},this.arrowClickNext=t=>{this.handleArrowClick(S,t)},this.handleArrowClick=(t,e)=>{this.setNewScrollPosition(t,e)},this.setNewScrollPosition=(t,e)=>{const o=this.itemsNavRef.current;if(!o)return;const r=this.horizontalScroll(),l=r?o.scrollWidth-o.offsetWidth:o.scrollHeight-o.offsetHeight,i=(e.type==="click"?this.props.buttonScrollSpeed:this.props.mouseScrollSpeed)||0;let s=r?o.scrollLeft:o.scrollTop;this.isRtl()&&this.horizontalScroll()?(t===f&&s<0&&(s+=i),t===S&&s<l&&(s-=i),s=Math.min(0,Math.min(l,s))):(t===f&&s>0&&(s-=i),t===S&&s<l&&(s+=i),s=Math.max(0,Math.min(l,s)));const c=e.type==="click"?v:void 0;r?o.scrollTo({left:s,behavior:c}):o.scrollTo({top:s,behavior:c})},this.renderArrow=t=>{const e=this.horizontalScroll(),o=x.provideLocalizationService(this),r={prev:{arrowTab:"k-tabstrip-prev",fontIcon:e?this.isRtl()?"caret-alt-right":"caret-alt-left":"caret-alt-up",svgIcon:e?this.isRtl()?m.caretAltRightIcon:m.caretAltLeftIcon:m.caretAltUpIcon,title:o.toLanguageString(b.prevArrowTitle,b.messages[b.prevArrowTitle])},next:{arrowTab:"k-tabstrip-next",fontIcon:e?this.isRtl()?"caret-alt-left":"caret-alt-right":"caret-alt-down",svgIcon:e?this.isRtl()?m.caretAltLeftIcon:m.caretAltRightIcon:m.caretAltDownIcon,title:o.toLanguageString(b.nextArrowTitle,b.messages[b.nextArrowTitle])}},l=(t===f?this.props.prevButton:this.props.nextButton)||B.Button,i=t===f?this.arrowClickPrev:this.arrowClickNext,s=this.props.containerScrollPosition===null||t===f&&(this.props.containerScrollPosition==="start"||this.props.containerScrollPosition==="top")||t===S&&(this.props.containerScrollPosition==="end"||this.props.containerScrollPosition==="bottom");return h.createElement(l,{disabled:s,className:w.classNames(`${r[t].arrowTab}`),onClick:i,icon:r[t].fontIcon,svgIcon:r[t].svgIcon,size:this.props.size,tabIndex:-1,fillMode:"flat",title:r[t].title})}}componentDidMount(){this.props.scrollable&&this.scrollToSelected()}componentDidUpdate(t){const{scrollable:e,selected:o}=this.props;e&&t.selected!==o&&this.scrollToSelected()}render(){const{selected:t,tabPosition:e,tabAlignment:o,children:r,onSelect:l,onKeyDown:i,navItemId:s,contentPanelId:c,renderAllContent:a,scrollable:R,scrollButtons:g,scrollButtonsPosition:p}=this.props,N=h.Children.count(r),A=h.Children.toArray(r);let T;r&&(T=M(N).map((D,u,O)=>{const z={active:t===u,disabled:A[u].props.disabled,index:u,title:A[u].props.title,first:u===0,last:u===O.length-1,contentPanelId:c,renderAllContent:a,id:s,onSelect:l,onScroll:this.onScroll};return h.createElement(E.TabStripNavigationItem,{key:u,...z})}));const C=w.classNames("k-tabstrip-items-wrapper k-tabstrip-items-wrapper-scroll",{"k-hstack":e==="top"||e==="bottom","k-vstack":e==="left"||e==="right"}),P=w.classNames("k-tabstrip-items k-tabstrip-items-scroll k-reset",`k-tabstrip-items-${o}`);return h.createElement("div",{className:C},R?h.createElement(h.Fragment,null,g!=="hidden"&&p&&["split","start","around","before"].includes(p)&&this.renderArrow(f),g!=="hidden"&&(p==="start"||p==="before")&&this.renderArrow(S),h.createElement("ul",{ref:this.itemsNavRef,className:P,role:"tablist",tabIndex:this.props.tabIndex,onKeyDown:i,onScroll:this.onScroll,"aria-orientation":e==="left"||e==="right"?"vertical":void 0},T),g!=="hidden"&&(p==="end"||p==="after")&&this.renderArrow(f),g!=="hidden"&&p&&["split","end","around","after"].includes(p)&&this.renderArrow(S)):h.createElement("ul",{className:P,role:"tablist",tabIndex:this.props.tabIndex,onKeyDown:i},T))}scrollToSelected(){const t=this.itemsNavRef.current,e=t&&t.children[this.props.selected||0];if(e instanceof HTMLElement&&t instanceof HTMLElement){const o=this.horizontalScroll(),r=o?t.offsetWidth:t.offsetHeight,l=o?e.offsetWidth:e.offsetHeight,i=o?"left":"top";let s=o?t.scrollLeft:t.scrollTop,c=0;if(this.isRtl()){const a=e.offsetLeft;s=s*-1,a<0?(c=a-l+t.offsetLeft,t.scrollTo({[i]:c,behavior:v})):a+l>r-s&&(c=s+a-l,t.scrollTo({[i]:c,behavior:v}))}else{const a=o?e.offsetLeft-t.offsetLeft:e.offsetTop-t.offsetTop;s+r<a+l?(c=a+l-r,t.scrollTo({[i]:c,behavior:v})):s>a&&(c=a,t.scrollTo({[i]:c,behavior:v}))}}}horizontalScroll(){return/top|bottom/.test(this.props.tabPosition||"top")}};I.propTypes={children:n.oneOfType([n.element,n.arrayOf(n.element)]),onSelect:n.func,onKeyDown:n.func,onScroll:n.func,selected:n.number,tabIndex:n.number,scrollable:n.bool,size:n.oneOf(["small","medium","large"]),scrollButtons:n.oneOf(["auto","visible","hidden"]),scrollButtonsPosition:n.oneOf(["split","start","end","around","before","after"]),containerScrollPosition:n.oneOf(["start","end","top","bottom","middle",null])};let k=I;exports.TabStripNavigation=k;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ft=require("react"),r=require("prop-types"),ut=require("./TabStripNavigationItem.js"),M=require("@progress/kendo-react-common"),bt=require("@progress/kendo-react-buttons"),I=require("@progress/kendo-svg-icons"),dt=require("@progress/kendo-react-intl"),S=require("./messages/index.js");function mt(b){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(b){for(const s in b)if(s!=="default"){const T=Object.getOwnPropertyDescriptor(b,s);Object.defineProperty(d,s,T.get?T:{enumerable:!0,get:()=>b[s]})}}return d.default=b,Object.freeze(d)}const n=mt(ft),pt=b=>Array.from({length:b}),C="smooth",p="prev",k="next",x=b=>{const{selected:d,tabPosition:s,tabAlignment:T,children:w,onSelect:y,onKeyDown:q,onScroll:A,navItemId:R,contentPanelId:F,renderAllContent:D,scrollable:E,scrollButtons:P,scrollButtonsPosition:m,tabIndex:_,buttonScrollSpeed:j,mouseScrollSpeed:W,prevButton:$,nextButton:K,dir:U,size:V,containerScrollPosition:v,itemsNavRef:ot}=b,nt=n.useRef(null),N=ot||nt,H=dt.useLocalization(),g=n.useCallback(()=>/top|bottom/.test(s||"top"),[s]),h=n.useCallback(()=>U==="rtl",[U]),X=n.useCallback(()=>{const t=N.current,e=t==null?void 0:t.children[d||0];if(e instanceof HTMLElement&&t instanceof HTMLElement){const l=g(),u=l?t.offsetWidth:t.offsetHeight,c=l?e.offsetWidth:e.offsetHeight,i=l?"left":"top";let o=l?t.scrollLeft:t.scrollTop,a=0;if(h()){const f=e.offsetLeft;o=o*-1,f<0?(a=f-c+t.offsetLeft,t.scrollTo({[i]:a,behavior:C})):f+c>u-o&&(a=o+f-c,t.scrollTo({[i]:a,behavior:C}))}else{const f=l?e.offsetLeft-t.offsetLeft:e.offsetTop-t.offsetTop;o+u<f+c?(a=f+c-u,t.scrollTo({[i]:a,behavior:C})):o>f&&(a=f,t.scrollTo({[i]:a,behavior:C}))}}},[N,d,g,h]);n.useEffect(()=>{E&&X()},[E,d,X]);const B=n.useCallback(()=>{A==null||A()},[A]),G=n.useCallback((t,e)=>{const l=N.current;if(!l)return;const u=g(),c=u?l.scrollWidth-l.offsetWidth:l.scrollHeight-l.offsetHeight,i=(e.type==="click"?j:W)||0;let o=u?l.scrollLeft:l.scrollTop;h()&&g()?(t===p&&o<0&&(o+=i),t===k&&o<c&&(o-=i),o=Math.min(0,Math.min(c,o))):(t===p&&o>0&&(o-=i),t===k&&o<c&&(o+=i),o=Math.max(0,Math.min(c,o)));const a=e.type==="click"?C:void 0;u?l.scrollTo({left:o,behavior:a}):l.scrollTo({top:o,behavior:a})},[N,g,h,j,W]),z=n.useCallback((t,e)=>{G(t,e)},[G]),J=n.useCallback(t=>{z(p,t)},[z]),Q=n.useCallback(t=>{z(k,t)},[z]),O=n.useCallback(t=>{const e=g(),l=h(),c=e?l?"caret-alt-right":"caret-alt-left":"caret-alt-up",i=l?I.caretAltRightIcon:I.caretAltLeftIcon,o=e?i:I.caretAltUpIcon,f=e?l?"caret-alt-left":"caret-alt-right":"caret-alt-down",st=l?I.caretAltLeftIcon:I.caretAltRightIcon,rt=e?st:I.caretAltDownIcon,L={prev:{arrowTab:"k-tabstrip-prev",fontIcon:c,svgIcon:o,title:H.toLanguageString(S.prevArrowTitle,S.messages[S.prevArrowTitle])},next:{arrowTab:"k-tabstrip-next",fontIcon:f,svgIcon:rt,title:H.toLanguageString(S.nextArrowTitle,S.messages[S.nextArrowTitle])}},ct=(t===p?$:K)||bt.Button,at=t===p?J:Q,it=v===null||t===p&&(v==="start"||v==="top")||t===k&&(v==="end"||v==="bottom");return n.createElement(ct,{disabled:it,className:M.classNames(`${L[t].arrowTab}`),onClick:at,icon:L[t].fontIcon,svgIcon:L[t].svgIcon,size:V,tabIndex:-1,fillMode:"flat",title:L[t].title})},[g,h,$,K,J,Q,v,V,H]),Y=n.Children.count(w),Z=n.Children.toArray(w),tt=n.useMemo(()=>w?pt(Y).map((t,e,l)=>{const u={active:d===e,disabled:Z[e].props.disabled,index:e,title:Z[e].props.title,first:e===0,last:e===l.length-1,contentPanelId:F,renderAllContent:D,id:R,onSelect:y,onScroll:B};return n.createElement(ut.TabStripNavigationItem,{key:`${R}-${e}`,...u})}):null,[w,Y,d,F,D,R,y,B]),lt=n.useMemo(()=>M.classNames("k-tabstrip-items-wrapper k-tabstrip-items-wrapper-scroll",{"k-hstack":s==="top"||s==="bottom","k-vstack":s==="left"||s==="right"}),[s]),et=n.useMemo(()=>M.classNames("k-tabstrip-items k-tabstrip-items-scroll k-reset",`k-tabstrip-items-${T}`),[T]);return n.createElement("div",{className:lt},E?n.createElement(n.Fragment,null,P!=="hidden"&&m&&["split","start","around","before"].includes(m)&&O(p),P!=="hidden"&&(m==="start"||m==="before")&&O(k),n.createElement("ul",{ref:N,className:et,role:"tablist",tabIndex:_,onKeyDown:q,onScroll:B,"aria-orientation":s==="left"||s==="right"?"vertical":void 0},tt),P!=="hidden"&&(m==="end"||m==="after")&&O(p),P!=="hidden"&&m&&["split","end","around","after"].includes(m)&&O(k)):n.createElement("ul",{className:et,role:"tablist",tabIndex:_,onKeyDown:q},tt))};x.propTypes={children:r.oneOfType([r.element,r.arrayOf(r.element)]),onSelect:r.func,onKeyDown:r.func,onScroll:r.func,selected:r.number,tabIndex:r.number,scrollable:r.bool,size:r.oneOf(["small","medium","large"]),scrollButtons:r.oneOf(["auto","visible","hidden"]),scrollButtonsPosition:r.oneOf(["split","start","end","around","before","after"]),containerScrollPosition:r.oneOf(["start","end","top","bottom","middle",null])};x.displayName="TabStripNavigation";exports.TabStripNavigation=x;
@@ -5,166 +5,179 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as h from "react";
9
- import n from "prop-types";
10
- import { TabStripNavigationItem as x } from "./TabStripNavigationItem.mjs";
11
- import { classNames as v } from "@progress/kendo-react-common";
12
- import { Button as M } from "@progress/kendo-react-buttons";
13
- import { caretAltLeftIcon as k, caretAltRightIcon as I, caretAltDownIcon as D, caretAltUpIcon as H } from "@progress/kendo-svg-icons";
14
- import { provideLocalizationService as y } from "@progress/kendo-react-intl";
15
- import { nextArrowTitle as A, messages as P, prevArrowTitle as R } from "./messages/index.mjs";
16
- const W = (z) => Array.apply(null, Array(z)), b = "smooth", f = "prev", m = "next", w = class w extends h.Component {
17
- constructor() {
18
- super(...arguments), this.itemsNavRef = this.props.itemsNavRef || h.createRef(), this.onScroll = () => {
19
- var t, o;
20
- (o = (t = this.props).onScroll) == null || o.call(t);
21
- }, this.isRtl = () => this.props.dir === "rtl", this.arrowClickPrev = (t) => {
22
- this.handleArrowClick(f, t);
23
- }, this.arrowClickNext = (t) => {
24
- this.handleArrowClick(m, t);
25
- }, this.handleArrowClick = (t, o) => {
26
- this.setNewScrollPosition(t, o);
27
- }, this.setNewScrollPosition = (t, o) => {
28
- const s = this.itemsNavRef.current;
29
- if (!s)
8
+ import * as n from "react";
9
+ import r from "prop-types";
10
+ import { TabStripNavigationItem as bt } from "./TabStripNavigationItem.mjs";
11
+ import { classNames as x } from "@progress/kendo-react-common";
12
+ import { Button as pt } from "@progress/kendo-react-buttons";
13
+ import { caretAltLeftIcon as Z, caretAltRightIcon as tt, caretAltDownIcon as ut, caretAltUpIcon as dt } from "@progress/kendo-svg-icons";
14
+ import { useLocalization as vt } from "@progress/kendo-react-intl";
15
+ import { nextArrowTitle as ot, messages as et, prevArrowTitle as nt } from "./messages/index.mjs";
16
+ const ht = (P) => Array.from({ length: P }), S = "smooth", p = "prev", h = "next", lt = (P) => {
17
+ const {
18
+ selected: g,
19
+ tabPosition: m,
20
+ tabAlignment: B,
21
+ children: k,
22
+ onSelect: O,
23
+ onKeyDown: R,
24
+ onScroll: T,
25
+ navItemId: E,
26
+ contentPanelId: M,
27
+ renderAllContent: F,
28
+ scrollable: H,
29
+ scrollButtons: C,
30
+ scrollButtonsPosition: b,
31
+ tabIndex: y,
32
+ buttonScrollSpeed: D,
33
+ mouseScrollSpeed: W,
34
+ prevButton: $,
35
+ nextButton: _,
36
+ dir: K,
37
+ size: U,
38
+ containerScrollPosition: d,
39
+ itemsNavRef: rt
40
+ } = P, st = n.useRef(null), I = rt || st, L = vt(), u = n.useCallback(() => /top|bottom/.test(m || "top"), [m]), v = n.useCallback(() => K === "rtl", [K]), V = n.useCallback(() => {
41
+ const t = I.current, o = t == null ? void 0 : t.children[g || 0];
42
+ if (o instanceof HTMLElement && t instanceof HTMLElement) {
43
+ const l = u(), i = l ? t.offsetWidth : t.offsetHeight, s = l ? o.offsetWidth : o.offsetHeight, f = l ? "left" : "top";
44
+ let e = l ? t.scrollLeft : t.scrollTop, c = 0;
45
+ if (v()) {
46
+ const a = o.offsetLeft;
47
+ e = e * -1, a < 0 ? (c = a - s + t.offsetLeft, t.scrollTo({ [f]: c, behavior: S })) : a + s > i - e && (c = e + a - s, t.scrollTo({ [f]: c, behavior: S }));
48
+ } else {
49
+ const a = l ? o.offsetLeft - t.offsetLeft : o.offsetTop - t.offsetTop;
50
+ e + i < a + s ? (c = a + s - i, t.scrollTo({ [f]: c, behavior: S })) : e > a && (c = a, t.scrollTo({ [f]: c, behavior: S }));
51
+ }
52
+ }
53
+ }, [I, g, u, v]);
54
+ n.useEffect(() => {
55
+ H && V();
56
+ }, [H, g, V]);
57
+ const A = n.useCallback(() => {
58
+ T == null || T();
59
+ }, [T]), X = n.useCallback(
60
+ (t, o) => {
61
+ const l = I.current;
62
+ if (!l)
30
63
  return;
31
- const r = this.horizontalScroll(), l = r ? s.scrollWidth - s.offsetWidth : s.scrollHeight - s.offsetHeight, i = (o.type === "click" ? this.props.buttonScrollSpeed : this.props.mouseScrollSpeed) || 0;
32
- let e = r ? s.scrollLeft : s.scrollTop;
33
- this.isRtl() && this.horizontalScroll() ? (t === f && e < 0 && (e += i), t === m && e < l && (e -= i), e = Math.min(0, Math.min(l, e))) : (t === f && e > 0 && (e -= i), t === m && e < l && (e += i), e = Math.max(0, Math.min(l, e)));
34
- const c = o.type === "click" ? b : void 0;
35
- r ? s.scrollTo({ left: e, behavior: c }) : s.scrollTo({ top: e, behavior: c });
36
- }, this.renderArrow = (t) => {
37
- const o = this.horizontalScroll(), s = y(this), r = {
64
+ const i = u(), s = i ? l.scrollWidth - l.offsetWidth : l.scrollHeight - l.offsetHeight, f = (o.type === "click" ? D : W) || 0;
65
+ let e = i ? l.scrollLeft : l.scrollTop;
66
+ v() && u() ? (t === p && e < 0 && (e += f), t === h && e < s && (e -= f), e = Math.min(0, Math.min(s, e))) : (t === p && e > 0 && (e -= f), t === h && e < s && (e += f), e = Math.max(0, Math.min(s, e)));
67
+ const c = o.type === "click" ? S : void 0;
68
+ i ? l.scrollTo({ left: e, behavior: c }) : l.scrollTo({ top: e, behavior: c });
69
+ },
70
+ [I, u, v, D, W]
71
+ ), N = n.useCallback(
72
+ (t, o) => {
73
+ X(t, o);
74
+ },
75
+ [X]
76
+ ), j = n.useCallback(
77
+ (t) => {
78
+ N(p, t);
79
+ },
80
+ [N]
81
+ ), q = n.useCallback(
82
+ (t) => {
83
+ N(h, t);
84
+ },
85
+ [N]
86
+ ), z = n.useCallback(
87
+ (t) => {
88
+ const o = u(), l = v(), s = o ? l ? "caret-alt-right" : "caret-alt-left" : "caret-alt-up", e = o ? l ? tt : Z : dt, a = o ? l ? "caret-alt-left" : "caret-alt-right" : "caret-alt-down", at = o ? l ? Z : tt : ut, w = {
38
89
  prev: {
39
90
  arrowTab: "k-tabstrip-prev",
40
- fontIcon: o ? this.isRtl() ? "caret-alt-right" : "caret-alt-left" : "caret-alt-up",
41
- svgIcon: o ? this.isRtl() ? I : k : H,
42
- title: s.toLanguageString(R, P[R])
91
+ fontIcon: s,
92
+ svgIcon: e,
93
+ title: L.toLanguageString(nt, et[nt])
43
94
  },
44
95
  next: {
45
96
  arrowTab: "k-tabstrip-next",
46
- fontIcon: o ? this.isRtl() ? "caret-alt-left" : "caret-alt-right" : "caret-alt-down",
47
- svgIcon: o ? this.isRtl() ? k : I : D,
48
- title: s.toLanguageString(A, P[A])
97
+ fontIcon: a,
98
+ svgIcon: at,
99
+ title: L.toLanguageString(ot, et[ot])
49
100
  }
50
- }, l = (t === f ? this.props.prevButton : this.props.nextButton) || M, i = t === f ? this.arrowClickPrev : this.arrowClickNext, e = this.props.containerScrollPosition === null || t === f && (this.props.containerScrollPosition === "start" || this.props.containerScrollPosition === "top") || t === m && (this.props.containerScrollPosition === "end" || this.props.containerScrollPosition === "bottom");
51
- return /* @__PURE__ */ h.createElement(
52
- l,
101
+ }, it = (t === p ? $ : _) || pt, ft = t === p ? j : q, mt = d === null || t === p && (d === "start" || d === "top") || t === h && (d === "end" || d === "bottom");
102
+ return /* @__PURE__ */ n.createElement(
103
+ it,
53
104
  {
54
- disabled: e,
55
- className: v(`${r[t].arrowTab}`),
56
- onClick: i,
57
- icon: r[t].fontIcon,
58
- svgIcon: r[t].svgIcon,
59
- size: this.props.size,
105
+ disabled: mt,
106
+ className: x(`${w[t].arrowTab}`),
107
+ onClick: ft,
108
+ icon: w[t].fontIcon,
109
+ svgIcon: w[t].svgIcon,
110
+ size: U,
60
111
  tabIndex: -1,
61
112
  fillMode: "flat",
62
- title: r[t].title
113
+ title: w[t].title
63
114
  }
64
115
  );
116
+ },
117
+ [
118
+ u,
119
+ v,
120
+ $,
121
+ _,
122
+ j,
123
+ q,
124
+ d,
125
+ U,
126
+ L
127
+ ]
128
+ ), G = n.Children.count(k), J = n.Children.toArray(k), Q = n.useMemo(() => k ? ht(G).map((t, o, l) => {
129
+ const i = {
130
+ active: g === o,
131
+ disabled: J[o].props.disabled,
132
+ index: o,
133
+ title: J[o].props.title,
134
+ first: o === 0,
135
+ last: o === l.length - 1,
136
+ contentPanelId: M,
137
+ renderAllContent: F,
138
+ id: E,
139
+ onSelect: O,
140
+ onScroll: A
65
141
  };
66
- }
67
- /**
68
- * @hidden
69
- */
70
- componentDidMount() {
71
- this.props.scrollable && this.scrollToSelected();
72
- }
73
- /**
74
- * @hidden
75
- */
76
- componentDidUpdate(t) {
77
- const { scrollable: o, selected: s } = this.props;
78
- o && t.selected !== s && this.scrollToSelected();
79
- }
80
- /**
81
- * @hidden
82
- */
83
- render() {
84
- const {
85
- selected: t,
86
- tabPosition: o,
87
- tabAlignment: s,
88
- children: r,
89
- onSelect: l,
90
- onKeyDown: i,
91
- navItemId: e,
92
- contentPanelId: c,
93
- renderAllContent: a,
94
- scrollable: L,
95
- scrollButtons: u,
96
- scrollButtonsPosition: p
97
- } = this.props, E = h.Children.count(r), g = h.Children.toArray(r);
98
- let S;
99
- r && (S = W(E).map((U, d, B) => {
100
- const O = {
101
- active: t === d,
102
- disabled: g[d].props.disabled,
103
- index: d,
104
- title: g[d].props.title,
105
- first: d === 0,
106
- last: d === B.length - 1,
107
- contentPanelId: c,
108
- renderAllContent: a,
109
- id: e,
110
- onSelect: l,
111
- onScroll: this.onScroll
112
- };
113
- return /* @__PURE__ */ h.createElement(x, { key: d, ...O });
114
- }));
115
- const N = v("k-tabstrip-items-wrapper k-tabstrip-items-wrapper-scroll", {
116
- "k-hstack": o === "top" || o === "bottom",
117
- "k-vstack": o === "left" || o === "right"
118
- }), T = v(
119
- "k-tabstrip-items k-tabstrip-items-scroll k-reset",
120
- `k-tabstrip-items-${s}`
121
- );
122
- return /* @__PURE__ */ h.createElement("div", { className: N }, L ? /* @__PURE__ */ h.createElement(h.Fragment, null, u !== "hidden" && p && ["split", "start", "around", "before"].includes(p) && this.renderArrow(f), u !== "hidden" && (p === "start" || p === "before") && this.renderArrow(m), /* @__PURE__ */ h.createElement(
123
- "ul",
124
- {
125
- ref: this.itemsNavRef,
126
- className: T,
127
- role: "tablist",
128
- tabIndex: this.props.tabIndex,
129
- onKeyDown: i,
130
- onScroll: this.onScroll,
131
- "aria-orientation": o === "left" || o === "right" ? "vertical" : void 0
132
- },
133
- S
134
- ), u !== "hidden" && (p === "end" || p === "after") && this.renderArrow(f), u !== "hidden" && p && ["split", "end", "around", "after"].includes(p) && this.renderArrow(m)) : /* @__PURE__ */ h.createElement("ul", { className: T, role: "tablist", tabIndex: this.props.tabIndex, onKeyDown: i }, S));
135
- }
136
- scrollToSelected() {
137
- const t = this.itemsNavRef.current, o = t && t.children[this.props.selected || 0];
138
- if (o instanceof HTMLElement && t instanceof HTMLElement) {
139
- const s = this.horizontalScroll(), r = s ? t.offsetWidth : t.offsetHeight, l = s ? o.offsetWidth : o.offsetHeight, i = s ? "left" : "top";
140
- let e = s ? t.scrollLeft : t.scrollTop, c = 0;
141
- if (this.isRtl()) {
142
- const a = o.offsetLeft;
143
- e = e * -1, a < 0 ? (c = a - l + t.offsetLeft, t.scrollTo({ [i]: c, behavior: b })) : a + l > r - e && (c = e + a - l, t.scrollTo({ [i]: c, behavior: b }));
144
- } else {
145
- const a = s ? o.offsetLeft - t.offsetLeft : o.offsetTop - t.offsetTop;
146
- e + r < a + l ? (c = a + l - r, t.scrollTo({ [i]: c, behavior: b })) : e > a && (c = a, t.scrollTo({ [i]: c, behavior: b }));
147
- }
148
- }
149
- }
150
- horizontalScroll() {
151
- return /top|bottom/.test(this.props.tabPosition || "top");
152
- }
142
+ return /* @__PURE__ */ n.createElement(bt, { key: `${E}-${o}`, ...i });
143
+ }) : null, [k, G, g, M, F, E, O, A]), ct = n.useMemo(
144
+ () => x("k-tabstrip-items-wrapper k-tabstrip-items-wrapper-scroll", {
145
+ "k-hstack": m === "top" || m === "bottom",
146
+ "k-vstack": m === "left" || m === "right"
147
+ }),
148
+ [m]
149
+ ), Y = n.useMemo(
150
+ () => x("k-tabstrip-items k-tabstrip-items-scroll k-reset", `k-tabstrip-items-${B}`),
151
+ [B]
152
+ );
153
+ return /* @__PURE__ */ n.createElement("div", { className: ct }, H ? /* @__PURE__ */ n.createElement(n.Fragment, null, C !== "hidden" && b && ["split", "start", "around", "before"].includes(b) && z(p), C !== "hidden" && (b === "start" || b === "before") && z(h), /* @__PURE__ */ n.createElement(
154
+ "ul",
155
+ {
156
+ ref: I,
157
+ className: Y,
158
+ role: "tablist",
159
+ tabIndex: y,
160
+ onKeyDown: R,
161
+ onScroll: A,
162
+ "aria-orientation": m === "left" || m === "right" ? "vertical" : void 0
163
+ },
164
+ Q
165
+ ), C !== "hidden" && (b === "end" || b === "after") && z(p), C !== "hidden" && b && ["split", "end", "around", "after"].includes(b) && z(h)) : /* @__PURE__ */ n.createElement("ul", { className: Y, role: "tablist", tabIndex: y, onKeyDown: R }, Q));
153
166
  };
154
- w.propTypes = {
155
- children: n.oneOfType([n.element, n.arrayOf(n.element)]),
156
- onSelect: n.func,
157
- onKeyDown: n.func,
158
- onScroll: n.func,
159
- selected: n.number,
160
- tabIndex: n.number,
161
- scrollable: n.bool,
162
- size: n.oneOf(["small", "medium", "large"]),
163
- scrollButtons: n.oneOf(["auto", "visible", "hidden"]),
164
- scrollButtonsPosition: n.oneOf(["split", "start", "end", "around", "before", "after"]),
165
- containerScrollPosition: n.oneOf(["start", "end", "top", "bottom", "middle", null])
167
+ lt.propTypes = {
168
+ children: r.oneOfType([r.element, r.arrayOf(r.element)]),
169
+ onSelect: r.func,
170
+ onKeyDown: r.func,
171
+ onScroll: r.func,
172
+ selected: r.number,
173
+ tabIndex: r.number,
174
+ scrollable: r.bool,
175
+ size: r.oneOf(["small", "medium", "large"]),
176
+ scrollButtons: r.oneOf(["auto", "visible", "hidden"]),
177
+ scrollButtonsPosition: r.oneOf(["split", "start", "end", "around", "before", "after"]),
178
+ containerScrollPosition: r.oneOf(["start", "end", "top", "bottom", "middle", null])
166
179
  };
167
- let C = w;
180
+ lt.displayName = "TabStripNavigation";
168
181
  export {
169
- C as TabStripNavigation
182
+ lt as TabStripNavigation
170
183
  };
@@ -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 by the TabStripNavigation to the TabStripNavigationItem.
@@ -52,31 +51,10 @@ export interface TabStripNavigationItemProps {
52
51
  */
53
52
  renderAllContent?: boolean;
54
53
  }
55
- export declare class TabStripNavigationItem extends React.Component<TabStripNavigationItemProps, {}> {
56
- /**
57
- * @hidden
58
- */
59
- static propTypes: {
60
- active: PropTypes.Requireable<boolean>;
61
- disabled: PropTypes.Requireable<boolean>;
62
- index: PropTypes.Requireable<number>;
63
- onSelect: PropTypes.Requireable<(...args: any[]) => any>;
64
- title: PropTypes.Requireable<NonNullable<string | PropTypes.ReactElementLike | null | undefined>>;
65
- first: PropTypes.Requireable<boolean>;
66
- last: PropTypes.Requireable<boolean>;
67
- };
68
- /**
69
- * @hidden
70
- */
71
- private itemRef;
72
- /**
73
- * @hidden
74
- */
54
+ /**
55
+ * Represents the TabStripNavigationItem component.
56
+ */
57
+ export declare const TabStripNavigationItem: React.ForwardRefExoticComponent<TabStripNavigationItemProps & React.RefAttributes<{
75
58
  focus: () => void;
76
59
  blur: () => void;
77
- /**
78
- * @hidden
79
- */
80
- render(): React.JSX.Element;
81
- private onClick;
82
- }
60
+ }>>;