@progress/kendo-react-layout 9.4.0-develop.9 → 9.4.0

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,27 +5,39 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as a from "react";
9
- import l from "prop-types";
10
- import { TabStripNavigation as h } from "./TabStripNavigation.mjs";
11
- import { TabStripContent as b } from "./TabStripContent.mjs";
12
- import { validatePackage as u, shouldShowValidationUI as g, Navigation as S, classNames as y, WatermarkOverlay as x } from "@progress/kendo-react-common";
13
- import { packageMetadata as m } from "../package-metadata.mjs";
14
- const d = class d extends a.Component {
15
- constructor(o) {
16
- super(o), this.tabStripRef = a.createRef(), this.showLicenseWatermark = !1, this.onSelect = (n) => {
17
- this.props.selected !== n && this.props.onSelect && this.props.onSelect({
18
- selected: n
8
+ import * as c from "react";
9
+ import r from "prop-types";
10
+ import { TabStripNavigation as m } from "./TabStripNavigation.mjs";
11
+ import { TabStripContent as g } from "./TabStripContent.mjs";
12
+ import { validatePackage as v, shouldShowValidationUI as y, Navigation as k, classNames as x, kendoThemeMaps as I, WatermarkOverlay as P } from "@progress/kendo-react-common";
13
+ import { packageMetadata as u } from "../package-metadata.mjs";
14
+ const p = class p extends c.Component {
15
+ constructor(l) {
16
+ super(l), this.tabStripRef = c.createRef(), this.itemsNavRef = c.createRef(), this.showLicenseWatermark = !1, this.onScroll = () => {
17
+ const i = this.horizontalScroll(), o = this.itemsNavRef.current;
18
+ if (!o)
19
+ return;
20
+ const e = o.scrollLeft, t = o.clientWidth, n = o.scrollWidth, s = o.scrollTop, a = o.scrollHeight, d = o.clientHeight;
21
+ let h = null;
22
+ const S = i ? n > t : a > d, f = this.props.dir === "rtl";
23
+ S ? i ? e + t === n || (f && t - e) === n ? h = "end" : e === 0 || f && -e === 0 ? h = "start" : e > 0 && e + t < n || -e > 0 && t - e < n ? h = "middle" : h = null : a - (s + d) === 0 ? h = "bottom" : s === 0 ? h = "top" : s > 0 && a - (s + d) > 0 ? h = "middle" : h = null : h = null, this.setState({ containerScrollPosition: h });
24
+ }, this.handleResize = () => {
25
+ this.onScroll();
26
+ }, this.onSelect = (i) => {
27
+ this.props.selected !== i && this.props.onSelect && this.props.onSelect({
28
+ selected: i
19
29
  });
20
- }, this.onKeyDown = (n) => {
21
- this.navigation.triggerKeyboardEvent(n);
22
- }, this.onKeyboardSelect = (n) => {
23
- const i = this.children();
24
- i && i[n].props.disabled || this.onSelect(n);
25
- }, this.renderContent = (n) => {
26
- const { selected: i, children: t, tabContentStyle: e } = n, r = a.Children.count(t);
27
- return i < r && i > -1 ? /* @__PURE__ */ a.createElement(b, { index: i, ...n, style: e }) : null;
28
- }, u(m), this.showLicenseWatermark = g(m);
30
+ }, this.onKeyDown = (i) => {
31
+ this.navigation && this.navigation.triggerKeyboardEvent(i);
32
+ }, this.onKeyboardSelect = (i) => {
33
+ const o = this.children();
34
+ o && o[i].props.disabled || this.onSelect(i);
35
+ }, this.renderContent = (i) => {
36
+ const { selected: o, children: e, tabContentStyle: t } = i, n = c.Children.count(e);
37
+ return o < n && o > -1 ? /* @__PURE__ */ c.createElement(g, { index: o, ...i, style: t }) : null;
38
+ }, v(u), this.showLicenseWatermark = y(u), this.state = {
39
+ containerScrollPosition: null
40
+ }, this.itemsNavRef = c.createRef();
29
41
  }
30
42
  get contentPanelId() {
31
43
  return this.props.id + "-content-panel-id";
@@ -35,9 +47,9 @@ const d = class d extends a.Component {
35
47
  }
36
48
  /** @hidden */
37
49
  componentDidMount() {
38
- var i;
39
- const o = this.tabStripRef.current, n = o && getComputedStyle(o).direction === "rtl" || !1;
40
- o && (this.navigation = new S({
50
+ var o;
51
+ const l = this.tabStripRef.current, i = l && getComputedStyle(l).direction === "rtl" || !1;
52
+ l && (this.navigation = new k({
41
53
  tabIndex: 0,
42
54
  root: this.tabStripRef,
43
55
  rovingTabIndex: !0,
@@ -45,106 +57,126 @@ const d = class d extends a.Component {
45
57
  selectors: [".k-tabstrip .k-tabstrip-item"],
46
58
  keyboardEvents: {
47
59
  keydown: {
48
- ArrowLeft: (t, e, r) => {
49
- r.preventDefault();
50
- const s = e.elements.indexOf(t), c = s !== 0 ? s - 1 : e.elements.length - 1, p = s !== e.elements.length - 1 ? s + 1 : 0;
51
- n ? (e.focusNext(t), this.onKeyboardSelect(p)) : (e.focusPrevious(t), this.onKeyboardSelect(c));
60
+ ArrowLeft: (e, t, n) => {
61
+ n.preventDefault();
62
+ const s = t.elements.indexOf(e), a = s !== 0 ? s - 1 : t.elements.length - 1, d = s !== t.elements.length - 1 ? s + 1 : 0;
63
+ i ? (t.focusNext(e), this.onKeyboardSelect(d)) : (t.focusPrevious(e), this.onKeyboardSelect(a));
52
64
  },
53
- ArrowRight: (t, e, r) => {
54
- r.preventDefault();
55
- const s = e.elements.indexOf(t), c = s !== 0 ? s - 1 : e.elements.length - 1, p = s !== e.elements.length - 1 ? s + 1 : 0;
56
- n ? (e.focusPrevious(t), this.onKeyboardSelect(c)) : (e.focusNext(t), this.onKeyboardSelect(p));
65
+ ArrowRight: (e, t, n) => {
66
+ n.preventDefault();
67
+ const s = t.elements.indexOf(e), a = s !== 0 ? s - 1 : t.elements.length - 1, d = s !== t.elements.length - 1 ? s + 1 : 0;
68
+ i ? (t.focusPrevious(e), this.onKeyboardSelect(a)) : (t.focusNext(e), this.onKeyboardSelect(d));
57
69
  },
58
- ArrowDown: (t, e, r) => {
59
- r.preventDefault();
60
- const s = e.elements.indexOf(t), c = s !== e.elements.length - 1 ? s + 1 : 0;
61
- e.focusNext(t), this.onKeyboardSelect(c);
70
+ ArrowDown: (e, t, n) => {
71
+ n.preventDefault();
72
+ const s = t.elements.indexOf(e), a = s !== t.elements.length - 1 ? s + 1 : 0;
73
+ t.focusNext(e), this.onKeyboardSelect(a);
62
74
  },
63
- ArrowUp: (t, e, r) => {
64
- r.preventDefault();
65
- const s = e.elements.indexOf(t), c = s !== 0 ? s - 1 : e.elements.length - 1;
66
- e.focusPrevious(t), this.onKeyboardSelect(c);
75
+ ArrowUp: (e, t, n) => {
76
+ n.preventDefault();
77
+ const s = t.elements.indexOf(e), a = s !== 0 ? s - 1 : t.elements.length - 1;
78
+ t.focusPrevious(e), this.onKeyboardSelect(a);
67
79
  },
68
- Home: (t, e, r) => {
69
- r.preventDefault(), e.focusElement(e.first, t), this.onKeyboardSelect(0);
80
+ Home: (e, t, n) => {
81
+ n.preventDefault(), t.focusElement(t.first, e), this.onKeyboardSelect(0);
70
82
  },
71
- End: (t, e, r) => {
72
- r.preventDefault(), e.focusElement(e.last, t), this.onKeyboardSelect(e.elements.length - 1);
83
+ End: (e, t, n) => {
84
+ n.preventDefault(), t.focusElement(t.last, e), this.onKeyboardSelect(t.elements.length - 1);
73
85
  }
74
86
  }
75
87
  }
76
- }), (i = this.navigation) == null || i.initializeRovingTab(this.props.selected));
88
+ }), (o = this.navigation) == null || o.initializeRovingTab(this.props.selected), this.onScroll(), this.resizeObserver = new ResizeObserver(() => this.onScroll()), this.tabStripRef.current && this.resizeObserver.observe(this.tabStripRef.current));
77
89
  }
78
90
  /** @hidden */
79
91
  componentWillUnmount() {
80
- var o;
81
- (o = this.navigation) == null || o.removeFocusListener();
92
+ var l;
93
+ (l = this.navigation) == null || l.removeFocusListener();
94
+ }
95
+ horizontalScroll() {
96
+ return /top|bottom/.test(this.props.tabPosition || "top");
82
97
  }
83
98
  /**
84
99
  * @hidden
85
100
  */
86
101
  render() {
87
- const o = {
102
+ const l = {
103
+ itemsNavRef: this.itemsNavRef,
88
104
  ...this.props,
89
105
  children: this.children(),
90
106
  contentPanelId: this.contentPanelId,
91
107
  renderAllContent: this.props.renderAllContent,
92
108
  navItemId: this.navItemId,
93
109
  onKeyDown: this.onKeyDown,
94
- onSelect: this.onSelect
95
- }, { tabPosition: n, tabIndex: i } = o, t = n === "bottom", e = y(
110
+ onSelect: this.onSelect,
111
+ onScroll: this.onScroll,
112
+ containerScrollPosition: this.state.containerScrollPosition,
113
+ scrollButtons: this.props.scrollButtons === "hidden" || this.state.containerScrollPosition === null && this.props.scrollButtons === "auto" ? "hidden" : "visible"
114
+ }, { scrollable: i, scrollButtons: o, size: e, tabPosition: t, tabIndex: n } = l, s = t === "bottom", a = x(
96
115
  "k-tabstrip k-pos-relative",
97
116
  {
98
- "k-tabstrip-left": n === "left",
99
- "k-tabstrip-right": n === "right",
100
- "k-tabstrip-bottom": n === "bottom",
101
- "k-tabstrip-top": n === "top",
102
- "k-tabstrip-scrollable": this.props.scrollable
117
+ [`k-tabstrip-${I.sizeMap[e] || e}`]: e,
118
+ "k-tabstrip-left": t === "left",
119
+ "k-tabstrip-right": t === "right",
120
+ "k-tabstrip-bottom": t === "bottom",
121
+ "k-tabstrip-top": t === "top",
122
+ "k-tabstrip-scrollable": i,
123
+ "k-tabstrip-scrollable-start k-tabstrip-scrollable-end": i && o === "visible",
124
+ "k-tabstrip-scrollable-start": i && (o === "auto" || !o) && (this.state.containerScrollPosition === "end" || this.state.containerScrollPosition === "middle"),
125
+ "k-tabstrip-scrollable-end": i && o === "auto" && (this.state.containerScrollPosition === "start" || this.state.containerScrollPosition === "middle")
103
126
  },
104
127
  this.props.className
105
128
  );
106
- return /* @__PURE__ */ a.createElement(
129
+ return /* @__PURE__ */ c.createElement(
107
130
  "div",
108
131
  {
109
132
  id: this.props.id,
110
133
  ref: this.tabStripRef,
111
134
  dir: this.props.dir,
112
- className: e,
113
- style: this.props.style
135
+ className: a,
136
+ style: this.props.style,
137
+ onScroll: this.onScroll,
138
+ onResize: this.handleResize
114
139
  },
115
- !t && /* @__PURE__ */ a.createElement(h, { ...o, tabIndex: i }),
116
- this.renderContent(o),
117
- t && /* @__PURE__ */ a.createElement(h, { ...o, tabIndex: i }),
118
- this.showLicenseWatermark && /* @__PURE__ */ a.createElement(x, null)
140
+ !s && /* @__PURE__ */ c.createElement(m, { ...l, tabIndex: n }),
141
+ this.renderContent(l),
142
+ s && /* @__PURE__ */ c.createElement(m, { ...l, tabIndex: n }),
143
+ this.showLicenseWatermark && /* @__PURE__ */ c.createElement(P, null)
119
144
  );
120
145
  }
121
146
  children() {
122
- return a.Children.toArray(this.props.children).filter((o) => o);
147
+ return c.Children.toArray(this.props.children).filter((l) => l);
123
148
  }
124
149
  };
125
- d.propTypes = {
126
- animation: l.bool,
127
- children: l.node,
128
- onSelect: l.func,
129
- selected: l.number,
130
- style: l.object,
131
- tabContentStyle: l.object,
132
- tabPosition: l.string,
133
- tabAlignment: l.string,
134
- tabIndex: l.number,
135
- className: l.string,
136
- dir: l.string
137
- }, d.defaultProps = {
150
+ p.propTypes = {
151
+ id: r.string,
152
+ animation: r.bool,
153
+ children: r.node,
154
+ onSelect: r.func,
155
+ selected: r.number,
156
+ style: r.object,
157
+ tabContentStyle: r.object,
158
+ tabPosition: r.string,
159
+ tabAlignment: r.string,
160
+ tabIndex: r.number,
161
+ className: r.string,
162
+ dir: r.string,
163
+ renderAllContent: r.bool,
164
+ size: r.oneOf(["small", "medium", "large", null]),
165
+ scrollButtons: r.oneOf(["auto", "visible", "hidden"]),
166
+ scrollButtonsPosition: r.oneOf(["split", "start", "end", "around", "before", "after"])
167
+ }, p.defaultProps = {
138
168
  animation: !0,
139
169
  tabPosition: "top",
140
170
  tabAlignment: "start",
141
171
  keepTabsMounted: !1,
142
172
  buttonScrollSpeed: 100,
143
- scrollButtonsPosition: "around",
144
173
  mouseScrollSpeed: 10,
174
+ scrollButtons: "auto",
175
+ scrollButtonsPosition: "split",
176
+ size: "medium",
145
177
  renderAllContent: !1
146
178
  };
147
- let f = d;
179
+ let b = p;
148
180
  export {
149
- f as TabStrip
181
+ b as TabStrip
150
182
  };
@@ -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"),f=require("prop-types"),M=require("./TabStripNavigationItem.js"),N=require("@progress/kendo-react-common"),E=require("@progress/kendo-react-buttons"),m=require("@progress/kendo-svg-icons"),y=require("@progress/kendo-react-intl"),v=require("./messages/index.js");function z(h){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(s,t,r.get?r:{enumerable:!0,get:()=>h[t]})}}return s.default=h,Object.freeze(s)}const a=z(L),O=h=>Array.apply(null,Array(h)),W=h=>h.preventDefault(),S="smooth",p="prev",g="next",k=class k extends a.Component{constructor(s){super(s),this.itemsNavRef=a.createRef(),this.isRtl=()=>this.props.dir==="rtl",this.onWheel=t=>{t.stopPropagation();const r=t.deltaY<0?p:g;this.setNewScrollPosition(r,t)},this.arrowClickPrev=t=>{this.handleArrowClick(p,t)},this.arrowClickNext=t=>{this.handleArrowClick(g,t)},this.handleArrowClick=(t,r)=>{this.setNewScrollPosition(t,r)},this.setNewScrollPosition=(t,r)=>{const e=this.itemsNavRef.current;if(!e)return;const c=this.horizontalScroll(),n=c?e.scrollWidth-e.offsetWidth:e.scrollHeight-e.offsetHeight,l=(r.type==="click"?this.props.buttonScrollSpeed:this.props.mouseScrollSpeed)||0;let o=c?e.scrollLeft:e.scrollTop,i=c?e.scrollWidth-e.scrollLeft:e.scrollHeight-e.scrollTop,u=e.scrollWidth-e.scrollLeft*-1;this.isRtl()&&this.horizontalScroll()?(t===p&&o<0&&(o+=l,u+=l),t===g&&o<n&&(o-=l,u-=l),o=Math.min(0,Math.min(n,o))):(t===p&&o>0&&(o-=l,i+=l),t===g&&o<n&&(o+=l,i-=l),o=Math.max(0,Math.min(n,o)));const d=o===0,T=r.type==="click"?S:void 0;if(c){const w=this.isRtl()?Math.round(u)<=e.clientWidth||Math.floor(u)<=e.clientWidth:Math.round(i)<=e.clientWidth||Math.floor(i)<=e.clientWidth;this.setState({disabledPrev:d,disabledNext:w}),e.scrollTo({left:o,behavior:T})}else this.setState({disabledPrev:d,disabledNext:Math.round(i)<=e.clientHeight||Math.floor(i)<=e.clientHeight}),e.scrollTo({top:o,behavior:T})},this.renderArrow=(t,r)=>{const e=this.horizontalScroll(),c=y.provideLocalizationService(this),n={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:c.toLanguageString(v.prevArrowTitle,v.messages[v.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:c.toLanguageString(v.nextArrowTitle,v.messages[v.nextArrowTitle])}},l=(t===p?this.props.prevButton:this.props.nextButton)||E.Button,o=t===p?this.arrowClickPrev:this.arrowClickNext;return a.createElement(l,{disabled:r,className:`${n[t].arrowTab}`,onClick:o,icon:n[t].fontIcon,svgIcon:n[t].svgIcon,onMouseDown:W,tabIndex:-1,fillMode:"flat",title:n[t].title})},this.state={disabledPrev:this.props.selected===0,disabledNext:this.props.selected===a.Children.count(this.props.children)-1}}componentDidMount(){this.props.scrollable&&this.scrollToSelected()}componentDidUpdate(s){const{scrollable:t,selected:r}=this.props;t&&s.selected!==r&&(this.scrollToSelected(),this.setState({disabledPrev:r===0,disabledNext:r===a.Children.count(this.props.children)-1}))}render(){const{selected:s,tabPosition:t,tabAlignment:r,children:e,onSelect:c,onKeyDown:n,navItemId:l,contentPanelId:o,renderAllContent:i,scrollable:u,scrollButtonsPosition:d}=this.props,T=a.Children.count(e),w=a.Children.toArray(e);let I;e&&(I=O(T).map((D,b,x)=>{const C={active:s===b,disabled:w[b].props.disabled,index:b,title:w[b].props.title,first:b===0,last:b===x.length-1,contentPanelId:o,renderAllContent:i,id:l,onSelect:c};return a.createElement(M.TabStripNavigationItem,{key:b,...C})}));const R=N.classNames("k-tabstrip-items-wrapper",{"k-hstack":t==="top"||t==="bottom","k-vstack":t==="left"||t==="right"}),A=N.classNames("k-tabstrip-items","k-reset",`k-tabstrip-items-${r}`);return a.createElement("div",{className:R},u?a.createElement(a.Fragment,null,(d==="around"||d==="before")&&this.renderArrow(p,this.state.disabledPrev),d==="before"&&this.renderArrow(g,this.state.disabledNext),a.createElement("ul",{ref:this.itemsNavRef,className:A,role:"tablist",tabIndex:this.props.tabIndex,onKeyDown:n,onWheel:this.onWheel,"aria-orientation":t==="left"||t==="right"?"vertical":void 0},I),d==="after"&&this.renderArrow(p,this.state.disabledPrev),(d==="around"||d==="after")&&this.renderArrow(g,this.state.disabledNext)):a.createElement("ul",{className:A,role:"tablist",tabIndex:this.props.tabIndex,onKeyDown:n},I))}scrollToSelected(){const s=this.itemsNavRef.current,t=s&&s.children[this.props.selected||0];if(t instanceof HTMLElement&&s instanceof HTMLElement){const r=this.horizontalScroll(),e=r?s.offsetWidth:s.offsetHeight,c=r?t.offsetWidth:t.offsetHeight,n=r?"left":"top";let l=r?s.scrollLeft:s.scrollTop,o=0;if(this.isRtl()){const i=t.offsetLeft;l=l*-1,i<0?(o=i-c+s.offsetLeft,s.scrollTo({[n]:o,behavior:S})):i+c>e-l&&(o=l+i-c,s.scrollTo({[n]:o,behavior:S}))}else{const i=r?t.offsetLeft-s.offsetLeft:t.offsetTop-s.offsetTop;l+e<i+c?(o=i+c-e,s.scrollTo({[n]:o,behavior:S})):l>i&&(o=i,s.scrollTo({[n]:o,behavior:S}))}}}horizontalScroll(){return/top|bottom/.test(this.props.tabPosition||"top")}};k.propTypes={children:f.oneOfType([f.element,f.arrayOf(f.element)]),onSelect:f.func,onKeyDown:f.func,selected:f.number,tabIndex:f.number};let P=k;exports.TabStripNavigation=P;
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;
@@ -5,77 +5,63 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as a from "react";
9
- import f from "prop-types";
10
- import { TabStripNavigationItem as W } from "./TabStripNavigationItem.mjs";
11
- import { classNames as I } from "@progress/kendo-react-common";
12
- import { Button as z } from "@progress/kendo-react-buttons";
13
- import { caretAltRightIcon as k, caretAltLeftIcon as A, caretAltUpIcon as D, caretAltDownIcon as H } from "@progress/kendo-svg-icons";
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 { caretAltRightIcon as k, caretAltLeftIcon as I, caretAltUpIcon as D, caretAltDownIcon as H } from "@progress/kendo-svg-icons";
14
14
  import { provideLocalizationService as y } from "@progress/kendo-react-intl";
15
- import { prevArrowTitle as N, messages as x, nextArrowTitle as C } from "./messages/index.mjs";
16
- const B = (w) => Array.apply(null, Array(w)), O = (w) => w.preventDefault(), u = "smooth", d = "prev", b = "next", T = class T extends a.Component {
17
- constructor(s) {
18
- super(s), this.itemsNavRef = a.createRef(), this.isRtl = () => this.props.dir === "rtl", this.onWheel = (t) => {
19
- t.stopPropagation();
20
- const r = t.deltaY < 0 ? d : b;
21
- this.setNewScrollPosition(r, t);
22
- }, this.arrowClickPrev = (t) => {
23
- this.handleArrowClick(d, t);
15
+ import { prevArrowTitle as A, messages as P, nextArrowTitle 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);
24
23
  }, this.arrowClickNext = (t) => {
25
- this.handleArrowClick(b, t);
26
- }, this.handleArrowClick = (t, r) => {
27
- this.setNewScrollPosition(t, r);
28
- }, this.setNewScrollPosition = (t, r) => {
29
- const e = this.itemsNavRef.current;
30
- if (!e)
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)
31
30
  return;
32
- const c = this.horizontalScroll(), n = c ? e.scrollWidth - e.offsetWidth : e.scrollHeight - e.offsetHeight, l = (r.type === "click" ? this.props.buttonScrollSpeed : this.props.mouseScrollSpeed) || 0;
33
- let o = c ? e.scrollLeft : e.scrollTop, i = c ? e.scrollWidth - e.scrollLeft : e.scrollHeight - e.scrollTop, m = e.scrollWidth - e.scrollLeft * -1;
34
- this.isRtl() && this.horizontalScroll() ? (t === d && o < 0 && (o += l, m += l), t === b && o < n && (o -= l, m -= l), o = Math.min(0, Math.min(n, o))) : (t === d && o > 0 && (o -= l, i += l), t === b && o < n && (o += l, i -= l), o = Math.max(0, Math.min(n, o)));
35
- const h = o === 0, v = r.type === "click" ? u : void 0;
36
- if (c) {
37
- const S = this.isRtl() ? Math.round(m) <= e.clientWidth || Math.floor(m) <= e.clientWidth : Math.round(i) <= e.clientWidth || Math.floor(i) <= e.clientWidth;
38
- this.setState({
39
- disabledPrev: h,
40
- disabledNext: S
41
- }), e.scrollTo({ left: o, behavior: v });
42
- } else
43
- this.setState({
44
- disabledPrev: h,
45
- disabledNext: Math.round(i) <= e.clientHeight || Math.floor(i) <= e.clientHeight
46
- }), e.scrollTo({ top: o, behavior: v });
47
- }, this.renderArrow = (t, r) => {
48
- const e = this.horizontalScroll(), c = y(this), n = {
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 = {
49
38
  prev: {
50
39
  arrowTab: "k-tabstrip-prev",
51
- fontIcon: e ? this.isRtl() ? "caret-alt-right" : "caret-alt-left" : "caret-alt-up",
52
- svgIcon: e ? this.isRtl() ? k : A : D,
53
- title: c.toLanguageString(N, x[N])
40
+ fontIcon: o ? this.isRtl() ? "caret-alt-right" : "caret-alt-left" : "caret-alt-up",
41
+ svgIcon: o ? this.isRtl() ? k : I : D,
42
+ title: s.toLanguageString(A, P[A])
54
43
  },
55
44
  next: {
56
45
  arrowTab: "k-tabstrip-next",
57
- fontIcon: e ? this.isRtl() ? "caret-alt-left" : "caret-alt-right" : "caret-alt-down",
58
- svgIcon: e ? this.isRtl() ? A : k : H,
59
- title: c.toLanguageString(C, x[C])
46
+ fontIcon: o ? this.isRtl() ? "caret-alt-left" : "caret-alt-right" : "caret-alt-down",
47
+ svgIcon: o ? this.isRtl() ? I : k : H,
48
+ title: s.toLanguageString(R, P[R])
60
49
  }
61
- }, l = (t === d ? this.props.prevButton : this.props.nextButton) || z, o = t === d ? this.arrowClickPrev : this.arrowClickNext;
62
- return /* @__PURE__ */ a.createElement(
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(
63
52
  l,
64
53
  {
65
- disabled: r,
66
- className: `${n[t].arrowTab}`,
67
- onClick: o,
68
- icon: n[t].fontIcon,
69
- svgIcon: n[t].svgIcon,
70
- onMouseDown: O,
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,
71
60
  tabIndex: -1,
72
61
  fillMode: "flat",
73
- title: n[t].title
62
+ title: r[t].title
74
63
  }
75
64
  );
76
- }, this.state = {
77
- disabledPrev: this.props.selected === 0,
78
- disabledNext: this.props.selected === a.Children.count(this.props.children) - 1
79
65
  };
80
66
  }
81
67
  /**
@@ -87,75 +73,77 @@ const B = (w) => Array.apply(null, Array(w)), O = (w) => w.preventDefault(), u =
87
73
  /**
88
74
  * @hidden
89
75
  */
90
- componentDidUpdate(s) {
91
- const { scrollable: t, selected: r } = this.props;
92
- t && s.selected !== r && (this.scrollToSelected(), this.setState({
93
- disabledPrev: r === 0,
94
- disabledNext: r === a.Children.count(this.props.children) - 1
95
- }));
76
+ componentDidUpdate(t) {
77
+ const { scrollable: o, selected: s } = this.props;
78
+ o && t.selected !== s && this.scrollToSelected();
96
79
  }
97
80
  /**
98
81
  * @hidden
99
82
  */
100
83
  render() {
101
84
  const {
102
- selected: s,
103
- tabPosition: t,
104
- tabAlignment: r,
105
- children: e,
106
- onSelect: c,
107
- onKeyDown: n,
108
- navItemId: l,
109
- contentPanelId: o,
110
- renderAllContent: i,
111
- scrollable: m,
112
- scrollButtonsPosition: h
113
- } = this.props, v = a.Children.count(e), S = a.Children.toArray(e);
114
- let g;
115
- e && (g = B(v).map((U, p, M) => {
116
- const E = {
117
- active: s === p,
118
- disabled: S[p].props.disabled,
119
- index: p,
120
- title: S[p].props.title,
121
- first: p === 0,
122
- last: p === M.length - 1,
123
- contentPanelId: o,
124
- renderAllContent: i,
125
- id: l,
126
- onSelect: c
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
127
112
  };
128
- return /* @__PURE__ */ a.createElement(W, { key: p, ...E });
113
+ return /* @__PURE__ */ h.createElement(x, { key: d, ...O });
129
114
  }));
130
- const L = I("k-tabstrip-items-wrapper", {
131
- "k-hstack": t === "top" || t === "bottom",
132
- "k-vstack": t === "left" || t === "right"
133
- }), P = I("k-tabstrip-items", "k-reset", `k-tabstrip-items-${r}`);
134
- return /* @__PURE__ */ a.createElement("div", { className: L }, m ? /* @__PURE__ */ a.createElement(a.Fragment, null, (h === "around" || h === "before") && this.renderArrow(d, this.state.disabledPrev), h === "before" && this.renderArrow(b, this.state.disabledNext), /* @__PURE__ */ a.createElement(
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(
135
123
  "ul",
136
124
  {
137
125
  ref: this.itemsNavRef,
138
- className: P,
126
+ className: T,
139
127
  role: "tablist",
140
128
  tabIndex: this.props.tabIndex,
141
- onKeyDown: n,
142
- onWheel: this.onWheel,
143
- "aria-orientation": t === "left" || t === "right" ? "vertical" : void 0
129
+ onKeyDown: i,
130
+ onScroll: this.onScroll,
131
+ "aria-orientation": o === "left" || o === "right" ? "vertical" : void 0
144
132
  },
145
- g
146
- ), h === "after" && this.renderArrow(d, this.state.disabledPrev), (h === "around" || h === "after") && this.renderArrow(b, this.state.disabledNext)) : /* @__PURE__ */ a.createElement("ul", { className: P, role: "tablist", tabIndex: this.props.tabIndex, onKeyDown: n }, g));
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));
147
135
  }
148
136
  scrollToSelected() {
149
- const s = this.itemsNavRef.current, t = s && s.children[this.props.selected || 0];
150
- if (t instanceof HTMLElement && s instanceof HTMLElement) {
151
- const r = this.horizontalScroll(), e = r ? s.offsetWidth : s.offsetHeight, c = r ? t.offsetWidth : t.offsetHeight, n = r ? "left" : "top";
152
- let l = r ? s.scrollLeft : s.scrollTop, o = 0;
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;
153
141
  if (this.isRtl()) {
154
- const i = t.offsetLeft;
155
- l = l * -1, i < 0 ? (o = i - c + s.offsetLeft, s.scrollTo({ [n]: o, behavior: u })) : i + c > e - l && (o = l + i - c, s.scrollTo({ [n]: o, behavior: u }));
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 }));
156
144
  } else {
157
- const i = r ? t.offsetLeft - s.offsetLeft : t.offsetTop - s.offsetTop;
158
- l + e < i + c ? (o = i + c - e, s.scrollTo({ [n]: o, behavior: u })) : l > i && (o = i, s.scrollTo({ [n]: o, behavior: u }));
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 }));
159
147
  }
160
148
  }
161
149
  }
@@ -163,14 +151,20 @@ const B = (w) => Array.apply(null, Array(w)), O = (w) => w.preventDefault(), u =
163
151
  return /top|bottom/.test(this.props.tabPosition || "top");
164
152
  }
165
153
  };
166
- T.propTypes = {
167
- children: f.oneOfType([f.element, f.arrayOf(f.element)]),
168
- onSelect: f.func,
169
- onKeyDown: f.func,
170
- selected: f.number,
171
- tabIndex: f.number
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])
172
166
  };
173
- let R = T;
167
+ let C = w;
174
168
  export {
175
- R as TabStripNavigation
169
+ C as TabStripNavigation
176
170
  };