@progress/kendo-react-dateinputs 14.4.1 → 14.5.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.
Files changed (35) hide show
  1. package/calendar/components/Calendar.d.ts +35 -110
  2. package/calendar/components/Calendar.js +5 -5
  3. package/calendar/components/Calendar.mjs +288 -313
  4. package/calendar/components/CalendarCell.d.ts +1 -10
  5. package/calendar/components/CalendarCell.js +1 -1
  6. package/calendar/components/CalendarCell.mjs +68 -78
  7. package/calendar/components/Header.d.ts +10 -23
  8. package/calendar/components/Header.js +1 -1
  9. package/calendar/components/Header.mjs +41 -55
  10. package/calendar/components/HorizontalViewList.d.ts +28 -26
  11. package/calendar/components/HorizontalViewList.js +1 -1
  12. package/calendar/components/HorizontalViewList.mjs +112 -102
  13. package/calendar/components/MultiViewCalendar.d.ts +39 -141
  14. package/calendar/components/MultiViewCalendar.js +1 -1
  15. package/calendar/components/MultiViewCalendar.mjs +331 -373
  16. package/calendar/components/Navigation.d.ts +19 -39
  17. package/calendar/components/Navigation.js +1 -1
  18. package/calendar/components/Navigation.mjs +95 -107
  19. package/calendar/components/TodayCommand.d.ts +8 -25
  20. package/calendar/components/TodayCommand.js +1 -1
  21. package/calendar/components/TodayCommand.mjs +44 -61
  22. package/calendar/components/View.d.ts +11 -42
  23. package/calendar/components/View.js +1 -1
  24. package/calendar/components/View.mjs +111 -137
  25. package/calendar/components/ViewList.d.ts +25 -65
  26. package/calendar/components/ViewList.js +1 -1
  27. package/calendar/components/ViewList.mjs +207 -225
  28. package/calendar/services/ScrollSyncService.d.ts +4 -4
  29. package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
  30. package/package-metadata.js +1 -1
  31. package/package-metadata.mjs +2 -2
  32. package/package.json +8 -8
  33. package/virtualization/Virtualization.d.ts +25 -63
  34. package/virtualization/Virtualization.js +1 -1
  35. package/virtualization/Virtualization.mjs +163 -168
@@ -5,233 +5,215 @@
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 o from "prop-types";
10
- import { classNames as p, uCalendar as m } from "@progress/kendo-react-common";
11
- import { cloneDate as T, getDate as g, isEqualDate as E } from "@progress/kendo-date-math";
12
- import { provideIntlService as N, registerForIntl as O } from "@progress/kendo-react-intl";
13
- import { Virtualization as H } from "../../virtualization/Virtualization.mjs";
14
- import { View as z } from "./View.mjs";
15
- import { Header as A } from "./Header.mjs";
16
- import { WeekNamesService as R } from "../services/WeekNamesService.mjs";
17
- import { dateInRange as D, isInRange as _, getToday as q } from "../../utils.mjs";
18
- import { CalendarViewEnum as c } from "../models/CalendarViewEnum.mjs";
19
- import { TodayCommand as F } from "./TodayCommand.mjs";
20
- const M = 5, d = class d extends a.Component {
21
- constructor(n) {
22
- super(n), this.virtualization = null, this.calendarView = null, this.table = null, this.intl = null, this.bottomOffset = 0, this.viewOffset = 0, this.viewHeight = 0, this._element = null, this.isActive = !1, this.animateToIndex = !0, this.shouldScroll = !1, this.weekService = null, this.focusActiveDate = () => {
23
- if (!this._element)
24
- return;
25
- const e = this._element.querySelector("td.k-focus"), i = this._element.querySelector(".k-state-pending-focus");
26
- e && e[0] && e[0].classList.remove("k-focus"), i && i.classList.add("k-focus"), this.isActive = !0;
27
- }, this.blurActiveDate = () => {
28
- if (!this._element)
29
- return;
30
- const e = this._element.querySelector("td.k-focus");
31
- e && e.classList.remove("k-focus"), this.isActive = !1;
32
- }, this.handleVirtualizationMount = (e) => {
33
- if (this.virtualization = e, this.virtualization && this.table) {
34
- this.table.style.transform = `translateY(${this.viewOffset}px)`;
35
- const i = D(this.props.focusedDate, this.props.min, this.props.max), t = this.props.service.skip(i, this.props.min);
36
- this.virtualization.scrollToIndex(t);
37
- }
38
- }, this.buildMonthView = (e, i) => {
39
- const { unstyled: t } = this.props, s = t && t.uCalendar;
40
- return /* @__PURE__ */ a.createElement(
41
- "table",
42
- {
43
- key: "calendar-view-list-weekdays",
44
- className: p(m.table({ c: s, weekdays: !0 })),
45
- role: "grid",
46
- tabIndex: this.props.tabIndex
47
- },
48
- /* @__PURE__ */ a.createElement("colgroup", null, e.map((l, r) => /* @__PURE__ */ a.createElement("col", { key: r }))),
49
- /* @__PURE__ */ a.createElement("thead", { className: p(m.thead({ c: s })) }, /* @__PURE__ */ a.createElement("tr", { className: p(m.tr({ c: s })) }, i.map((l, r) => /* @__PURE__ */ a.createElement("th", { key: r, className: p(m.th({ c: s })) }, l))))
50
- );
51
- }, this.buildDates = (e, i) => {
52
- const t = this.props.cellUID, { unstyled: s } = this.props, l = s && s.uCalendar;
53
- return /* @__PURE__ */ a.createElement(
54
- "table",
55
- {
56
- className: p(m.table({ c: l })),
57
- ref: (r) => {
58
- this.table = r;
59
- },
60
- role: "grid",
61
- tabIndex: this.props.tabIndex,
62
- "aria-activedescendant": t + this.props.focusedDate.getTime()
63
- },
64
- /* @__PURE__ */ a.createElement("colgroup", null, e.map((r, h) => /* @__PURE__ */ a.createElement("col", { key: h }))),
65
- i.map((r) => /* @__PURE__ */ a.createElement(
66
- z,
67
- {
68
- ref: (h) => {
69
- this.calendarView || (this.calendarView = h);
70
- },
71
- key: r.getTime(),
72
- activeView: this.props.activeView,
73
- viewDate: r,
74
- min: this.props.min,
75
- max: this.props.max,
76
- cellUID: t,
77
- focusedDate: this.props.focusedDate,
78
- cell: this.props.cell,
79
- selectedDate: this.props.value,
80
- showWeekNumbers: this.weekNumber,
81
- onChange: this.handleDateChange,
82
- bus: this.props.bus,
83
- service: this.props.service,
84
- weekCell: this.props.weekCell,
85
- showOtherMonthDays: this.props.showOtherMonthDays,
86
- unstyled: s
87
- }
88
- ))
89
- );
90
- }, this.calculateHeights = () => {
91
- if (!this.props.dom)
92
- return;
93
- const e = this.props.activeView === c.month ? this.props.dom.scrollableContentHeight : this.props.dom.scrollableYearContentHeight;
94
- this.bottomOffset = e - this.props.dom.viewHeight(this.props.activeView), this.viewOffset = -1 * this.props.dom.headerHeight, this.viewHeight = this.props.dom.viewHeight(this.props.activeView) || 1;
95
- }, this.getTake = (e, i) => Math.min(i - e, this.take), this.handleScrollAction = ({ index: e, scrollAction: i, pageAction: t }) => {
96
- const s = t ? t.skip : this.state.skip;
97
- if ((this.state.index !== e || this.state.skip !== s) && this.setState({ index: e, skip: s }), this.table && i) {
98
- const l = `translateY(${i.offset}px)`;
99
- this.table.style.transform = l;
100
- }
101
- }, this.handleTodayClick = (e) => {
102
- this.shouldScroll = !0, this.handleDateChange.call(void 0, e, !0);
103
- }, this.handleDateChange = (e, i = !1) => {
104
- const { onChange: t } = this.props;
105
- if (t) {
106
- const s = {
107
- syntheticEvent: e.syntheticEvent,
108
- nativeEvent: e.nativeEvent,
109
- value: T(e.value),
110
- target: this,
111
- isTodayClick: i
112
- };
113
- t.call(void 0, s);
114
- }
115
- }, this.lastView = this.props.activeView, this.lastFocus = this.props.focusedDate, this.state = {
116
- skip: this.props.service.skip(this.props.focusedDate, this.props.min),
117
- index: this.props.service.skip(this.props.focusedDate, this.props.min)
118
- };
119
- }
120
- get element() {
121
- return this._element;
122
- }
123
- get weekNames() {
124
- return this.intl = N(this), this.weekService = new R(this.intl), this.weekService.getWeekNames(this.weekNumber, this.props.weekDaysFormat);
125
- }
126
- get weekNumber() {
127
- return !!(this.props.showWeekNumbers && this.props.activeView === c.month);
128
- }
129
- get take() {
130
- return this.props.take !== void 0 ? this.props.take : d.defaultProps.take;
131
- }
132
- get animate() {
133
- return !!(this.props.smoothScroll && this.animateToIndex);
134
- }
135
- get todayIsInRange() {
136
- return _(q(), g(this.props.min), g(this.props.max));
137
- }
138
- componentDidUpdate(n, e) {
139
- this.shouldScroll = !1, this.indexToScroll !== void 0 && this.virtualization && this.virtualization[this.animate ? "animateToIndex" : "scrollToIndex"](this.indexToScroll), this.isActive && this.focusActiveDate(), this.lastView = this.props.activeView, this.indexToScroll = void 0;
140
- }
141
- render() {
142
- const { activeView: n, min: e, max: i, service: t, unstyled: s } = this.props, l = s && s.uCalendar;
143
- this.calculateHeights();
144
- const r = this.lastView !== n, h = D(this.props.focusedDate, e, i), u = r ? t.skip(h, e) : this.state.skip, w = t.total(e, i), x = this.getTake(u, w), y = t.addToDate(e, u), S = t.addToDate(e, this.state.index), k = new Array(t.rowLength(this.weekNumber)).fill(""), b = n !== this.lastView;
145
- this.animateToIndex = !b, (b || !E(this.lastFocus, h) || this.shouldScroll || !this.props.shouldScroll || this.props.shouldScroll()) && (this.indexToScroll = this.props.service.skip(h, this.props.min)), this.lastFocus = h;
146
- const C = p(
147
- m.view({
148
- c: l,
149
- month: n === c.month,
150
- year: n === c.year,
151
- decade: n === c.decade,
152
- century: n === c.century
153
- })
154
- ), I = this.buildDates(k, t.datesList(y, x)), V = /* @__PURE__ */ a.createElement(a.Fragment, null, /* @__PURE__ */ a.createElement(
155
- A,
156
- {
157
- key: "calendar-view-list-header",
158
- currentDate: S,
159
- min: this.props.min,
160
- max: this.props.max,
161
- activeView: this.props.activeView,
162
- bus: this.props.bus,
163
- service: this.props.service,
164
- headerTitle: this.props.headerTitle,
165
- header: this.props.header,
166
- unstyled: s,
167
- commands: /* @__PURE__ */ a.createElement(
168
- F,
169
- {
170
- min: this.props.min,
171
- max: this.props.max,
172
- onClick: this.handleTodayClick,
173
- disabled: !this.todayIsInRange,
174
- tabIndex: this.props.tabIndex,
175
- unstyled: s
176
- }
177
- )
178
- }
179
- ), this.props.activeView === c.month && this.buildMonthView(k, this.weekNames), /* @__PURE__ */ a.createElement(
180
- H,
181
- {
182
- key: "calendar-view-list-content",
183
- skip: u,
184
- take: this.take,
185
- total: w,
186
- itemHeight: this.viewHeight,
187
- topOffset: this.viewOffset,
188
- bottomOffset: this.bottomOffset,
189
- scrollOffsetSize: this.viewOffset,
190
- maxScrollDifference: this.viewHeight,
191
- onScroll: this.props.onScroll,
192
- onScrollAction: this.handleScrollAction,
193
- onMount: (f) => !this.virtualization && this.handleVirtualizationMount(f),
194
- children: I,
195
- tabIndex: this.props.tabIndex,
196
- unstyled: s
197
- }
198
- ));
199
- return /* @__PURE__ */ a.createElement(
200
- "div",
201
- {
202
- ref: (f) => {
203
- this._element = f;
204
- },
205
- className: C
206
- },
207
- this.props.dom.didCalculate ? V : null
208
- );
209
- }
210
- };
211
- d.propTypes = {
212
- activeView: o.number.isRequired,
213
- bottomOffset: o.number,
214
- cellUID: o.string.isRequired,
215
- focusedDate: o.instanceOf(Date).isRequired,
216
- max: o.instanceOf(Date).isRequired,
217
- min: o.instanceOf(Date).isRequired,
218
- onChange: o.func,
219
- showWeekNumbers: o.bool,
220
- smoothScroll: o.bool,
221
- take: o.number,
222
- value: o.instanceOf(Date),
223
- viewHeight: o.number,
224
- viewOffset: o.number,
225
- weekDaysFormat: o.oneOf(["short", "abbreviated", "narrow"]),
226
- tabIndex: o.number
227
- }, d.defaultProps = {
228
- take: M,
8
+ import * as t from "react";
9
+ import { classNames as p, uCalendar as v } from "@progress/kendo-react-common";
10
+ import { getDate as K, isEqualDate as Se, cloneDate as Ce } from "@progress/kendo-date-math";
11
+ import { useInternationalization as be } from "@progress/kendo-react-intl";
12
+ import { Virtualization as Ne } from "../../virtualization/Virtualization.mjs";
13
+ import { View as Ve } from "./View.mjs";
14
+ import { Header as Te } from "./Header.mjs";
15
+ import { WeekNamesService as xe } from "../services/WeekNamesService.mjs";
16
+ import { isInRange as Ie, getToday as He, dateInRange as j } from "../../utils.mjs";
17
+ import { CalendarViewEnum as u } from "../models/CalendarViewEnum.mjs";
18
+ import { TodayCommand as Le } from "./TodayCommand.mjs";
19
+ const Oe = 5, E = {
20
+ take: Oe,
229
21
  showWeekNumbers: !1,
230
22
  weekDaysFormat: "short",
231
23
  smoothScroll: !0
232
- };
233
- let v = d;
234
- O(v);
24
+ }, G = t.forwardRef((J, Q) => {
25
+ const {
26
+ take: H = E.take,
27
+ showWeekNumbers: X = E.showWeekNumbers,
28
+ weekDaysFormat: Z = E.weekDaysFormat,
29
+ smoothScroll: ee = E.smoothScroll,
30
+ activeView: n,
31
+ bus: L,
32
+ cellUID: O,
33
+ dom: a,
34
+ focusedDate: m,
35
+ max: c,
36
+ min: r,
37
+ cell: te,
38
+ onScroll: ne,
39
+ onChange: W,
40
+ service: o,
41
+ value: re,
42
+ weekCell: oe,
43
+ showOtherMonthDays: se,
44
+ headerTitle: ae,
45
+ header: ce,
46
+ shouldScroll: z,
47
+ tabIndex: f,
48
+ unstyled: d
49
+ } = J, S = !!(X && n === u.month), le = Ie(He(), K(r), K(c)), A = () => {
50
+ if (!i.current)
51
+ return;
52
+ const e = i.current.querySelector("td.k-focus"), s = i.current.querySelector(".k-state-pending-focus");
53
+ e && e[0] && e[0].classList.remove("k-focus"), s && s.classList.add("k-focus"), N.current = !0;
54
+ }, ie = () => {
55
+ if (!i.current)
56
+ return;
57
+ const e = i.current.querySelector("td.k-focus");
58
+ e && e.classList.remove("k-focus"), N.current = !1;
59
+ }, F = (e, s = !1) => {
60
+ if (W) {
61
+ const k = {
62
+ syntheticEvent: e.syntheticEvent,
63
+ nativeEvent: e.nativeEvent,
64
+ value: Ce(e.value),
65
+ target: C.current,
66
+ isTodayClick: s
67
+ };
68
+ W(k);
69
+ }
70
+ }, ue = (e) => {
71
+ V.current = !0, F(e, !0);
72
+ }, me = ({ index: e, scrollAction: s, pageAction: k }) => {
73
+ const D = k ? k.skip : void 0;
74
+ if (de((w) => {
75
+ const $ = D !== void 0 ? D : w.skip;
76
+ return w.index !== e || w.skip !== $ ? { index: e, skip: $ } : w;
77
+ }), g.current && s) {
78
+ const w = `translateY(${s.offset}px)`;
79
+ g.current.style.transform = w;
80
+ }
81
+ }, fe = (e) => {
82
+ if (l.current = e, l.current && g.current) {
83
+ const s = -1 * a.headerHeight;
84
+ g.current.style.transform = `translateY(${s}px)`;
85
+ const k = j(m, r, c), D = o.skip(k, r);
86
+ l.current.scrollToIndex(D);
87
+ }
88
+ }, l = t.useRef(null), C = t.useRef(null);
89
+ t.useImperativeHandle(
90
+ C,
91
+ () => ({
92
+ get element() {
93
+ return i.current;
94
+ },
95
+ get virtualization() {
96
+ return l.current;
97
+ },
98
+ focusActiveDate: A,
99
+ blurActiveDate: ie
100
+ })
101
+ ), t.useImperativeHandle(Q, () => C.current);
102
+ const i = t.useRef(null), g = t.useRef(null), b = t.useRef(n), q = t.useRef(m), N = t.useRef(!1), M = t.useRef(!0), V = t.useRef(!1), y = t.useRef(void 0), [B, de] = t.useState(() => {
103
+ const e = o.skip(m, r);
104
+ return { skip: e, index: e };
105
+ });
106
+ t.useEffect(() => {
107
+ if (V.current = !1, y.current !== void 0 && l.current) {
108
+ const e = !!(ee && M.current);
109
+ l.current[e ? "animateToIndex" : "scrollToIndex"](y.current);
110
+ }
111
+ N.current && A(), b.current = n, y.current = void 0;
112
+ });
113
+ const he = be(), ke = new xe(he).getWeekNames(S, Z), h = d && d.uCalendar;
114
+ let Y = 0, T = 0, x = 1;
115
+ a && (Y = (n === u.month ? a.scrollableContentHeight : a.scrollableYearContentHeight) - a.viewHeight(n), T = -1 * a.headerHeight, x = a.viewHeight(n) || 1);
116
+ const we = b.current !== n, R = j(m, r, c), I = we ? o.skip(R, r) : B.skip, P = o.total(r, c), pe = Math.min(P - I, H), ve = o.addToDate(r, I), ge = o.addToDate(r, B.index), U = Array.from({ length: o.rowLength(S) }, (e, s) => s), _ = n !== b.current;
117
+ M.current = !_, (_ || !Se(q.current, R) || V.current || !z || z()) && (y.current = o.skip(R, r)), q.current = R;
118
+ const ye = p(
119
+ v.view({
120
+ c: h,
121
+ month: n === u.month,
122
+ year: n === u.year,
123
+ decade: n === u.decade,
124
+ century: n === u.century
125
+ })
126
+ ), Re = /* @__PURE__ */ t.createElement(
127
+ "table",
128
+ {
129
+ className: p(v.table({ c: h })),
130
+ ref: g,
131
+ role: "grid",
132
+ tabIndex: f != null ? f : 0,
133
+ "aria-activedescendant": O + m.getTime()
134
+ },
135
+ /* @__PURE__ */ t.createElement("colgroup", null, U.map((e) => /* @__PURE__ */ t.createElement("col", { key: e }))),
136
+ o.datesList(ve, pe).map((e) => /* @__PURE__ */ t.createElement(
137
+ Ve,
138
+ {
139
+ key: e.getTime(),
140
+ activeView: n,
141
+ viewDate: e,
142
+ min: r,
143
+ max: c,
144
+ cellUID: O,
145
+ focusedDate: m,
146
+ cell: te,
147
+ selectedDate: re,
148
+ showWeekNumbers: S,
149
+ onChange: F,
150
+ bus: L,
151
+ service: o,
152
+ weekCell: oe,
153
+ showOtherMonthDays: se,
154
+ unstyled: d
155
+ }
156
+ ))
157
+ ), De = n === u.month ? /* @__PURE__ */ t.createElement(
158
+ "table",
159
+ {
160
+ key: "calendar-view-list-weekdays",
161
+ className: p(v.table({ c: h, weekdays: !0 })),
162
+ role: "grid",
163
+ tabIndex: f
164
+ },
165
+ /* @__PURE__ */ t.createElement("colgroup", null, U.map((e) => /* @__PURE__ */ t.createElement("col", { key: e }))),
166
+ /* @__PURE__ */ t.createElement("thead", { className: p(v.thead({ c: h })) }, /* @__PURE__ */ t.createElement("tr", { className: p(v.tr({ c: h })) }, ke.map((e) => /* @__PURE__ */ t.createElement("th", { key: e, className: p(v.th({ c: h })) }, e))))
167
+ ) : null, Ee = /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
168
+ Te,
169
+ {
170
+ key: "calendar-view-list-header",
171
+ currentDate: ge,
172
+ min: r,
173
+ max: c,
174
+ activeView: n,
175
+ bus: L,
176
+ service: o,
177
+ headerTitle: ae,
178
+ header: ce,
179
+ unstyled: d,
180
+ commands: /* @__PURE__ */ t.createElement(
181
+ Le,
182
+ {
183
+ min: r,
184
+ max: c,
185
+ onClick: ue,
186
+ disabled: !le,
187
+ tabIndex: f,
188
+ unstyled: d
189
+ }
190
+ )
191
+ }
192
+ ), De, /* @__PURE__ */ t.createElement(
193
+ Ne,
194
+ {
195
+ key: "calendar-view-list-content",
196
+ skip: I,
197
+ take: H,
198
+ total: P,
199
+ itemHeight: x,
200
+ topOffset: T,
201
+ bottomOffset: Y,
202
+ scrollOffsetSize: T,
203
+ maxScrollDifference: x,
204
+ onScroll: ne,
205
+ onScrollAction: me,
206
+ onMount: (e) => !l.current && fe(e),
207
+ tabIndex: f,
208
+ unstyled: d
209
+ },
210
+ Re
211
+ ));
212
+ return /* @__PURE__ */ t.createElement("div", { ref: i, className: ye }, a.didCalculate ? Ee : null);
213
+ });
214
+ G.displayName = "KendoReactViewList";
215
+ const $e = G;
235
216
  export {
236
- v as ViewList
217
+ $e as ViewList,
218
+ E as viewListDefaultProps
237
219
  };
@@ -5,7 +5,7 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import { Virtualization } from '../../virtualization/Virtualization.js';
8
+ import { VirtualizationHandle } from '../../virtualization/Virtualization.js';
9
9
  import { DOMService } from './DOMService.js';
10
10
  import { CalendarViewEnum } from '../models/CalendarViewEnum.js';
11
11
  /**
@@ -21,8 +21,8 @@ export declare class ScrollSyncService {
21
21
  private navScrolled;
22
22
  constructor(dom: DOMService);
23
23
  configure(activeView: CalendarViewEnum): void;
24
- sync(navigator: Virtualization, view: Virtualization, e: any): void;
24
+ sync(navigator: VirtualizationHandle, view: VirtualizationHandle, e: any): void;
25
25
  scrollSiblingOf(scrolledElement: any): void;
26
- siblingComponent(scrollableElement: HTMLElement): Virtualization;
27
- calculateScroll(component: Virtualization, scrollTop: number): number;
26
+ siblingComponent(scrollableElement: HTMLElement): VirtualizationHandle;
27
+ calculateScroll(component: VirtualizationHandle, scrollTop: number): number;
28
28
  }