@jetbrains/ring-ui-built 7.0.107 → 7.0.109

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 (107) hide show
  1. package/components/_helpers/date-picker.js +1 -1
  2. package/components/_helpers/theme.js +15 -14
  3. package/components/alert-service/alert-service.d.ts +2 -2
  4. package/components/alert-service/alert-service.js +2 -2
  5. package/components/auth/auth-core.js +1 -0
  6. package/components/auth/auth.js +1 -0
  7. package/components/auth/iframe-flow.js +1 -0
  8. package/components/auth/token-validator.js +1 -0
  9. package/components/auth-dialog/auth-dialog.js +1 -0
  10. package/components/auth-dialog-service/auth-dialog-service.js +1 -0
  11. package/components/avatar/avatar.js +1 -0
  12. package/components/avatar-stack/avatar-stack.js +1 -0
  13. package/components/banner/banner.js +1 -0
  14. package/components/button-group/button-group.js +18 -1
  15. package/components/checkbox/checkbox.d.ts +1 -0
  16. package/components/checkbox/checkbox.js +3 -1
  17. package/components/components/util-stories.js +3 -0
  18. package/components/confirm/confirm.js +1 -0
  19. package/components/confirm-service/confirm-service.js +1 -0
  20. package/components/data-list/data-list.js +1 -0
  21. package/components/data-list/selection.js +1 -0
  22. package/components/data-list/title.js +1 -0
  23. package/components/date-picker/animate-date.d.ts +1 -0
  24. package/components/date-picker/animate-date.js +39 -0
  25. package/components/date-picker/consts.d.ts +21 -4
  26. package/components/date-picker/consts.js +18 -1
  27. package/components/date-picker/date-picker.d.ts +48 -1
  28. package/components/date-picker/date-picker.js +44 -17
  29. package/components/date-picker/date-popup.d.ts +3 -9
  30. package/components/date-picker/date-popup.js +59 -72
  31. package/components/date-picker/day.js +24 -15
  32. package/components/date-picker/month-names.js +76 -72
  33. package/components/date-picker/month-slider.d.ts +5 -20
  34. package/components/date-picker/month-slider.js +129 -47
  35. package/components/date-picker/month.d.ts +4 -0
  36. package/components/date-picker/month.js +81 -76
  37. package/components/date-picker/months.js +75 -191
  38. package/components/date-picker/scroll-arith.d.ts +35 -0
  39. package/components/date-picker/scroll-arith.js +74 -0
  40. package/components/date-picker/use-intersection-observer.d.ts +6 -0
  41. package/components/date-picker/use-intersection-observer.js +93 -0
  42. package/components/date-picker/use-scroll-behavior.d.ts +8 -0
  43. package/components/date-picker/use-scroll-behavior.js +223 -0
  44. package/components/date-picker/weekdays.js +3 -0
  45. package/components/date-picker/years.d.ts +1 -18
  46. package/components/date-picker/years.js +259 -78
  47. package/components/dialog/dialog.js +1 -0
  48. package/components/dropdown-menu/dropdown-menu.js +1 -0
  49. package/components/editable-heading/editable-heading.js +1 -0
  50. package/components/error-bubble/error-bubble.js +1 -0
  51. package/components/footer/footer.d.ts +1 -1
  52. package/components/global/dom.d.ts +1 -1
  53. package/components/global/dom.js +1 -1
  54. package/components/header/header.js +1 -0
  55. package/components/header/profile.js +1 -0
  56. package/components/header/services.js +1 -0
  57. package/components/header/smart-profile.js +1 -0
  58. package/components/header/smart-services.js +1 -0
  59. package/components/heading/heading.d.ts +4 -4
  60. package/components/list/list-item.js +1 -0
  61. package/components/list/list-users-groups-source.js +1 -0
  62. package/components/list/list.js +1 -0
  63. package/components/login-dialog/login-dialog.js +1 -0
  64. package/components/login-dialog/service.js +1 -0
  65. package/components/message/message.js +1 -0
  66. package/components/old-browsers-message/old-browsers-message-stop.js +1 -0
  67. package/components/old-browsers-message/old-browsers-message.js +1 -0
  68. package/components/old-browsers-message/white-list.js +3 -2
  69. package/components/pager/pager.js +1 -0
  70. package/components/popup/popup.js +1 -0
  71. package/components/popup/position-css.js +1 -0
  72. package/components/popup/position.js +1 -0
  73. package/components/popup-menu/popup-menu.js +1 -0
  74. package/components/query-assist/query-assist-suggestions.js +1 -0
  75. package/components/query-assist/query-assist.js +1 -0
  76. package/components/select/select-filter.js +1 -0
  77. package/components/select/select-popup.js +1 -0
  78. package/components/select/select.js +1 -0
  79. package/components/shortcuts/core.js +1 -0
  80. package/components/shortcuts/shortcuts-hoc.js +1 -0
  81. package/components/shortcuts/shortcuts.js +1 -0
  82. package/components/slider/slider.js +1 -0
  83. package/components/style.css +1 -1
  84. package/components/table/disable-hover-hoc.js +1 -0
  85. package/components/table/header.js +1 -1
  86. package/components/table/multitable.js +1 -0
  87. package/components/table/row-with-focus-sensor.js +2 -1
  88. package/components/table/row.js +1 -0
  89. package/components/table/simple-table.js +2 -1
  90. package/components/table/smart-table.js +2 -1
  91. package/components/table/table.js +2 -1
  92. package/components/tabs/collapsible-more.js +1 -0
  93. package/components/tabs/collapsible-tabs.js +1 -0
  94. package/components/tabs/dumb-tabs.js +1 -0
  95. package/components/tabs/smart-tabs.js +1 -0
  96. package/components/tabs/tabs.js +1 -0
  97. package/components/tags-input/tags-input.js +1 -0
  98. package/components/tooltip/tooltip.js +1 -0
  99. package/components/user-agreement/service.js +1 -0
  100. package/components/user-agreement/user-agreement.js +1 -0
  101. package/components/user-card/card.js +1 -0
  102. package/components/user-card/smart-user-card-tooltip.js +1 -0
  103. package/components/user-card/tooltip.js +1 -0
  104. package/components/user-card/user-card.js +1 -0
  105. package/components/util-stories.d.ts +1 -0
  106. package/package.json +3 -3
  107. package/typings.d.ts +5 -0
@@ -1,62 +1,144 @@
1
- import { PureComponent } from 'react';
1
+ import { c } from 'react-compiler-runtime';
2
+ import { useState } from 'react';
2
3
  import classNames from 'classnames';
3
4
  import { addYears } from 'date-fns/addYears';
4
- import { startOfDay } from 'date-fns/startOfDay';
5
- import { subYears } from 'date-fns/subYears';
6
- import linearFunction from '../global/linear-function.js';
7
- import units, { yearScrollSpeed } from './consts.js';
5
+ import { startOfYear } from 'date-fns';
6
+ import units from './consts.js';
7
+ import scheduleRAF from '../global/schedule-raf.js';
8
8
  import { s as styles } from '../_helpers/date-picker.js';
9
- import { jsx } from 'react/jsx-runtime';
9
+ import { jsx, Fragment } from 'react/jsx-runtime';
10
10
  import 'date-fns/add';
11
+ import '../global/sniffer.js';
12
+ import 'sniffr';
11
13
 
12
- const COVERYEARS = 3;
13
- class MonthSlider extends PureComponent {
14
- state = {
15
- dragging: false
16
- };
17
- componentDidUpdate(prevProps, prevState) {
18
- if (this.state.dragging && !prevState.dragging) {
19
- window.addEventListener('mousemove', this.onMouseMove);
20
- window.addEventListener('mouseup', this.onMouseUp);
21
- } else if (!this.state.dragging && prevState.dragging) {
22
- window.removeEventListener('mousemove', this.onMouseMove);
23
- window.removeEventListener('mouseup', this.onMouseUp);
14
+ const scheduleScroll = scheduleRAF();
15
+ function MonthSlider(t0) {
16
+ const $ = c(21);
17
+ if ($[0] !== "ebbd4a21f88e38a284a06e4f0c7cea8f6e0df6c98e2e21ebc395ef8031346aae") {
18
+ for (let $i = 0; $i < 21; $i += 1) {
19
+ $[$i] = Symbol.for("react.memo_cache_sentinel");
24
20
  }
21
+ $[0] = "ebbd4a21f88e38a284a06e4f0c7cea8f6e0df6c98e2e21ebc395ef8031346aae";
25
22
  }
26
- onMouseDown = () => {
27
- this.setState({
28
- dragging: true
29
- });
30
- };
31
- onMouseUp = () => {
32
- this.setState({
33
- dragging: false
34
- });
35
- };
36
- onMouseMove = e => {
37
- this.props.onScroll(linearFunction(0, Number(this.props.scrollDate), yearScrollSpeed).y(e.movementY));
38
- };
39
- render() {
40
- let year = subYears(startOfDay(this.props.scrollDate), 1);
41
- const years = [year];
42
- for (let i = 0; i <= COVERYEARS; i++) {
43
- year = addYears(year, 1);
44
- years.push(year);
45
- }
46
- const classes = classNames(styles.monthSlider, {
47
- [styles.dragging]: this.state.dragging
48
- });
49
- return /*#__PURE__*/jsx("div", {
50
- children: years.map(date => /*#__PURE__*/jsx("button", {
23
+ const {
24
+ scrollDate,
25
+ setScrollDate
26
+ } = t0;
27
+ const [dragStart, setDragStart] = useState(null);
28
+ let t1;
29
+ if ($[1] !== scrollDate.date) {
30
+ t1 = e => {
31
+ const pointerId = e.pointerId;
32
+ setDragStart({
33
+ y: e.pageY,
34
+ scrollDate: Number(scrollDate.date),
35
+ pointerId
36
+ });
37
+ e.currentTarget.setPointerCapture(pointerId);
38
+ };
39
+ $[1] = scrollDate.date;
40
+ $[2] = t1;
41
+ } else {
42
+ t1 = $[2];
43
+ }
44
+ const onPointerDown = t1;
45
+ let t2;
46
+ if ($[3] !== dragStart || $[4] !== setScrollDate) {
47
+ t2 = e_0 => {
48
+ scheduleScroll(() => {
49
+ if (!dragStart) {
50
+ return;
51
+ }
52
+ const {
53
+ y: startY,
54
+ scrollDate: startDate
55
+ } = dragStart;
56
+ const yearFraction = (e_0.pageY - startY) / units.calHeight;
57
+ const startDatePlusOneYear = Number(addYears(new Date(startDate), 1));
58
+ const newScrollDate = startDate + yearFraction * (startDatePlusOneYear - startDate);
59
+ setScrollDate({
60
+ date: newScrollDate,
61
+ source: "other"
62
+ });
63
+ });
64
+ };
65
+ $[3] = dragStart;
66
+ $[4] = setScrollDate;
67
+ $[5] = t2;
68
+ } else {
69
+ t2 = $[5];
70
+ }
71
+ const onPointerMove = t2;
72
+ let t3;
73
+ if ($[6] !== dragStart) {
74
+ t3 = e_1 => {
75
+ if (!dragStart) {
76
+ return;
77
+ }
78
+ const {
79
+ pointerId: pointerId_0
80
+ } = dragStart;
81
+ setDragStart(null);
82
+ e_1.currentTarget.releasePointerCapture?.(pointerId_0);
83
+ };
84
+ $[6] = dragStart;
85
+ $[7] = t3;
86
+ } else {
87
+ t3 = $[7];
88
+ }
89
+ const onPointerUp = t3;
90
+ let t4;
91
+ let yearStart;
92
+ if ($[8] !== scrollDate.date) {
93
+ yearStart = startOfYear(scrollDate.date);
94
+ t4 = addYears(yearStart, 1);
95
+ $[8] = scrollDate.date;
96
+ $[9] = t4;
97
+ $[10] = yearStart;
98
+ } else {
99
+ t4 = $[9];
100
+ yearStart = $[10];
101
+ }
102
+ const yearEnd = t4;
103
+ const yearFraction_0 = (Number(scrollDate.date) - Number(yearStart)) / (Number(yearEnd) - Number(yearStart));
104
+ const t5 = yearFraction_0 - 1;
105
+ const t6 = yearFraction_0 + 1;
106
+ let t7;
107
+ if ($[11] !== t5 || $[12] !== t6 || $[13] !== yearFraction_0) {
108
+ t7 = [t5, yearFraction_0, t6];
109
+ $[11] = t5;
110
+ $[12] = t6;
111
+ $[13] = yearFraction_0;
112
+ $[14] = t7;
113
+ } else {
114
+ t7 = $[14];
115
+ }
116
+ const offsets = t7;
117
+ let t8;
118
+ if ($[15] !== dragStart || $[16] !== offsets || $[17] !== onPointerDown || $[18] !== onPointerMove || $[19] !== onPointerUp) {
119
+ t8 = /*#__PURE__*/jsx(Fragment, {
120
+ children: offsets.map(offset => /*#__PURE__*/jsx("button", {
51
121
  type: "button",
52
- className: classes,
122
+ className: classNames(styles.monthSlider, dragStart && styles.dragging),
53
123
  style: {
54
- top: Math.floor(this.props.pxToDate.x(Number(date)) - units.cellSize)
124
+ top: offset * units.calHeight - units.cellSize
55
125
  },
56
- onMouseDown: this.onMouseDown
57
- }, +date))
126
+ onPointerDown: onPointerDown,
127
+ onPointerMove: onPointerMove,
128
+ onPointerUp: onPointerUp,
129
+ onPointerCancel: onPointerUp
130
+ }, Math.floor(offset)))
58
131
  });
132
+ $[15] = dragStart;
133
+ $[16] = offsets;
134
+ $[17] = onPointerDown;
135
+ $[18] = onPointerMove;
136
+ $[19] = onPointerUp;
137
+ $[20] = t8;
138
+ } else {
139
+ t8 = $[20];
59
140
  }
141
+ return t8;
60
142
  }
61
143
 
62
144
  export { MonthSlider as default };
@@ -1,5 +1,9 @@
1
+ import { type Locale } from 'date-fns';
1
2
  import { type MonthsProps } from './consts';
3
+ import { type IntersectionObserverHandle } from './use-intersection-observer';
2
4
  export interface MonthProps extends MonthsProps {
3
5
  month: Date;
6
+ intersectionObserverHandle: IntersectionObserverHandle | null;
4
7
  }
5
8
  export default function Month(props: MonthProps): import("react").JSX.Element;
9
+ export declare function getMonthHeight(monthStart: Date | number, locale: Locale | undefined): number;
@@ -1,15 +1,16 @@
1
1
  import { c } from 'react-compiler-runtime';
2
- import { addDays } from 'date-fns/addDays';
3
- import { endOfMonth } from 'date-fns/endOfMonth';
4
2
  import { format } from 'date-fns/format';
5
3
  import { getDay } from 'date-fns/getDay';
6
- import { setDay } from 'date-fns/setDay';
4
+ import { getDaysInMonth, setDate } from 'date-fns';
5
+ import { useRef, createElement } from 'react';
7
6
  import Day from './day.js';
8
- import { shiftWeekArray, getWeekStartsOn, weekdays, FIFTH_DAY, WEEK } from './consts.js';
7
+ import units, { getWeekStartsOn, WEEK } from './consts.js';
8
+ import { useVisibility } from './use-intersection-observer.js';
9
9
  import { s as styles } from '../_helpers/date-picker.js';
10
- import { jsx, jsxs } from 'react/jsx-runtime';
11
- import { createElement } from 'react';
10
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
11
+ import 'core-js/modules/es.array.includes.js';
12
12
  import 'classnames';
13
+ import 'date-fns/addDays';
13
14
  import 'date-fns/getDate';
14
15
  import 'date-fns/isAfter';
15
16
  import 'date-fns/isBefore';
@@ -17,97 +18,101 @@ import 'date-fns/isSameDay';
17
18
  import 'date-fns/isToday';
18
19
  import 'date-fns/startOfDay';
19
20
  import 'date-fns/add';
21
+ import '../global/sniffer.js';
22
+ import 'sniffr';
20
23
 
21
24
  function Month(props) {
22
- const $ = c(20);
23
- if ($[0] !== "14b913afec6a0e367382e049e14b38f0432cb1747486488d23fa5601f7987406") {
24
- for (let $i = 0; $i < 20; $i += 1) {
25
+ const $ = c(13);
26
+ if ($[0] !== "2f6fe4553edaada7486df2c003273bf4ae27149a404d6c91c9c721f7d6c02b8b") {
27
+ for (let $i = 0; $i < 13; $i += 1) {
25
28
  $[$i] = Symbol.for("react.memo_cache_sentinel");
26
29
  }
27
- $[0] = "14b913afec6a0e367382e049e14b38f0432cb1747486488d23fa5601f7987406";
30
+ $[0] = "2f6fe4553edaada7486df2c003273bf4ae27149a404d6c91c9c721f7d6c02b8b";
28
31
  }
29
- const start = props.month;
30
- const end = endOfMonth(start);
31
32
  const {
32
- locale
33
+ month,
34
+ locale,
35
+ intersectionObserverHandle
33
36
  } = props;
34
- const weekday = getDay(start);
37
+ const containerRef = useRef(null);
38
+ const visible = useVisibility(intersectionObserverHandle, containerRef);
35
39
  let t0;
36
- if ($[1] !== props.locale) {
37
- t0 = shiftWeekArray(Object.values(weekdays), getWeekStartsOn(props.locale));
38
- $[1] = props.locale;
39
- $[2] = t0;
40
+ if ($[1] !== locale || $[2] !== month || $[3] !== visible) {
41
+ t0 = visible ? {} : {
42
+ height: getMonthHeight(month, locale)
43
+ };
44
+ $[1] = locale;
45
+ $[2] = month;
46
+ $[3] = visible;
47
+ $[4] = t0;
40
48
  } else {
41
- t0 = $[2];
42
- }
43
- const weekDays = t0;
44
- const fifthDayOfWeek = weekDays[FIFTH_DAY];
45
- let days;
46
- if ($[3] !== end || $[4] !== fifthDayOfWeek || $[5] !== start || $[6] !== weekday) {
47
- let day = setDay(start, weekday >= fifthDayOfWeek ? fifthDayOfWeek : fifthDayOfWeek - WEEK);
48
- days = [];
49
- while (day < end) {
50
- days.push(day);
51
- day = addDays(day, 1);
52
- }
53
- $[3] = end;
54
- $[4] = fifthDayOfWeek;
55
- $[5] = start;
56
- $[6] = weekday;
57
- $[7] = days;
58
- } else {
59
- days = $[7];
49
+ t0 = $[4];
60
50
  }
61
51
  let t1;
62
- if ($[8] !== locale || $[9] !== props.month) {
63
- t1 = format(props.month, "LLLL", {
64
- locale
52
+ if ($[5] !== locale || $[6] !== month || $[7] !== props || $[8] !== visible) {
53
+ t1 = visible && /*#__PURE__*/jsxs(Fragment, {
54
+ children: [/*#__PURE__*/jsx("span", {
55
+ className: styles.monthTitle,
56
+ children: format(month, "LLLL", {
57
+ locale
58
+ })
59
+ }), Array.from({
60
+ length: getPaddingCellsNum(month, locale)
61
+ }, (_, i) => /*#__PURE__*/createElement(Day, {
62
+ ...props,
63
+ day: new Date(0),
64
+ empty: true,
65
+ key: `e_${i}`
66
+ })), Array.from({
67
+ length: getDaysInMonth(month)
68
+ }, (__0, i_0) => /*#__PURE__*/createElement(Day, {
69
+ ...props,
70
+ day: setDate(month, i_0 + 1),
71
+ empty: false,
72
+ key: i_0
73
+ }))]
65
74
  });
66
- $[8] = locale;
67
- $[9] = props.month;
68
- $[10] = t1;
75
+ $[5] = locale;
76
+ $[6] = month;
77
+ $[7] = props;
78
+ $[8] = visible;
79
+ $[9] = t1;
69
80
  } else {
70
- t1 = $[10];
81
+ t1 = $[9];
71
82
  }
72
83
  let t2;
73
- if ($[11] !== t1) {
74
- t2 = /*#__PURE__*/jsx("span", {
75
- className: styles.monthTitle,
84
+ if ($[10] !== t0 || $[11] !== t1) {
85
+ t2 = /*#__PURE__*/jsx("div", {
86
+ className: styles.month,
87
+ ref: containerRef,
88
+ style: t0,
76
89
  children: t1
77
90
  });
91
+ $[10] = t0;
78
92
  $[11] = t1;
79
93
  $[12] = t2;
80
94
  } else {
81
95
  t2 = $[12];
82
96
  }
83
- let t3;
84
- if ($[13] !== days || $[14] !== props || $[15] !== start) {
85
- t3 = days.map(date => /*#__PURE__*/createElement(Day, {
86
- ...props,
87
- day: date,
88
- empty: date < start,
89
- key: +date
90
- }));
91
- $[13] = days;
92
- $[14] = props;
93
- $[15] = start;
94
- $[16] = t3;
95
- } else {
96
- t3 = $[16];
97
- }
98
- let t4;
99
- if ($[17] !== t2 || $[18] !== t3) {
100
- t4 = /*#__PURE__*/jsxs("div", {
101
- className: styles.month,
102
- children: [t2, t3]
103
- });
104
- $[17] = t2;
105
- $[18] = t3;
106
- $[19] = t4;
107
- } else {
108
- t4 = $[19];
109
- }
110
- return t4;
97
+ return t2;
98
+ }
99
+ const cellsPerMonthName = 4;
100
+ /**
101
+ * Between the month name and the first month day
102
+ */
103
+ function getPaddingCellsNum(monthStart, locale) {
104
+ const monthStartWeekdaySundayBased = getDay(monthStart);
105
+ const weekStartDay = getWeekStartsOn(locale);
106
+ const monthStartWeekday = (monthStartWeekdaySundayBased - weekStartDay + WEEK) % WEEK;
107
+ if (monthStartWeekday >= cellsPerMonthName) return monthStartWeekday - cellsPerMonthName;
108
+ const upperPadding = WEEK - cellsPerMonthName;
109
+ const lowerPadding = monthStartWeekday;
110
+ return upperPadding + lowerPadding;
111
+ }
112
+ function getMonthHeight(monthStart, locale) {
113
+ const totalCells = cellsPerMonthName + getPaddingCellsNum(monthStart, locale) + getDaysInMonth(new Date(monthStart));
114
+ const monthLines = Math.ceil(totalCells / WEEK);
115
+ return monthLines * units.cellSize;
111
116
  }
112
117
 
113
- export { Month as default };
118
+ export { Month as default, getMonthHeight };