@react-fabric/date 1.0.0-beta.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.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  3. package/dist/cjs/components/Date.module.css +1 -0
  4. package/dist/cjs/components/DateCell.js +98 -0
  5. package/dist/cjs/components/DateHeader.js +142 -0
  6. package/dist/cjs/components/DatePage.js +59 -0
  7. package/dist/cjs/components/DecadePage.js +34 -0
  8. package/dist/cjs/components/MonthPage.js +33 -0
  9. package/dist/cjs/components/TimeSliders.js +131 -0
  10. package/dist/cjs/components/YearPage.js +34 -0
  11. package/dist/cjs/display/DateDisplay.js +35 -0
  12. package/dist/cjs/hijri/index.js +1029 -0
  13. package/dist/cjs/i18n/ar.json.js +25 -0
  14. package/dist/cjs/i18n/en.json.js +21 -0
  15. package/dist/cjs/i18n/index.js +39 -0
  16. package/dist/cjs/i18n/superdate/ar.json.js +86 -0
  17. package/dist/cjs/i18n/superdate/en.json.js +93 -0
  18. package/dist/cjs/index.js +20 -0
  19. package/dist/cjs/panels/BasePanel.js +73 -0
  20. package/dist/cjs/panels/DatePanel.js +205 -0
  21. package/dist/cjs/panels/RangePanel.js +340 -0
  22. package/dist/cjs/superdate/EventPanel.js +173 -0
  23. package/dist/cjs/superdate/QuickSelect.js +134 -0
  24. package/dist/cjs/superdate/RelativeInput.js +79 -0
  25. package/dist/cjs/superdate/RelativePanel.js +91 -0
  26. package/dist/cjs/superdate/SuperDate.module.css +1 -0
  27. package/dist/cjs/superdate/Superdate.js +169 -0
  28. package/dist/cjs/types/index.js +61 -0
  29. package/dist/cjs/utils/dateUtil.js +436 -0
  30. package/dist/esm/components/Date.module.css +1 -0
  31. package/dist/esm/components/DateCell.js +98 -0
  32. package/dist/esm/components/DateHeader.js +142 -0
  33. package/dist/esm/components/DatePage.js +59 -0
  34. package/dist/esm/components/DecadePage.js +34 -0
  35. package/dist/esm/components/MonthPage.js +33 -0
  36. package/dist/esm/components/TimeSliders.js +131 -0
  37. package/dist/esm/components/YearPage.js +34 -0
  38. package/dist/esm/display/DateDisplay.js +35 -0
  39. package/dist/esm/hijri/index.js +1029 -0
  40. package/dist/esm/i18n/ar.json.js +21 -0
  41. package/dist/esm/i18n/en.json.js +18 -0
  42. package/dist/esm/i18n/index.js +39 -0
  43. package/dist/esm/i18n/superdate/ar.json.js +79 -0
  44. package/dist/esm/i18n/superdate/en.json.js +85 -0
  45. package/dist/esm/index.js +9 -0
  46. package/dist/esm/panels/BasePanel.js +73 -0
  47. package/dist/esm/panels/DatePanel.js +205 -0
  48. package/dist/esm/panels/RangePanel.js +340 -0
  49. package/dist/esm/superdate/EventPanel.js +173 -0
  50. package/dist/esm/superdate/QuickSelect.js +134 -0
  51. package/dist/esm/superdate/RelativeInput.js +79 -0
  52. package/dist/esm/superdate/RelativePanel.js +91 -0
  53. package/dist/esm/superdate/SuperDate.module.css +1 -0
  54. package/dist/esm/superdate/Superdate.js +168 -0
  55. package/dist/esm/types/index.js +60 -0
  56. package/dist/esm/utils/dateUtil.js +438 -0
  57. package/dist/types/components/DateCell.d.ts +15 -0
  58. package/dist/types/components/DateHeader.d.ts +14 -0
  59. package/dist/types/components/DatePage.d.ts +6 -0
  60. package/dist/types/components/DecadePage.d.ts +6 -0
  61. package/dist/types/components/MonthPage.d.ts +6 -0
  62. package/dist/types/components/TimeSliders.d.ts +10 -0
  63. package/dist/types/components/YearPage.d.ts +6 -0
  64. package/dist/types/display/DateDisplay.d.ts +15 -0
  65. package/dist/types/hijri/index.d.ts +2 -0
  66. package/dist/types/i18n/index.d.ts +1 -0
  67. package/dist/types/index.d.ts +7 -0
  68. package/dist/types/panels/BasePanel.d.ts +25 -0
  69. package/dist/types/panels/DatePanel.d.ts +2 -0
  70. package/dist/types/panels/RangePanel.d.ts +2 -0
  71. package/dist/types/superdate/EventPanel.d.ts +4 -0
  72. package/dist/types/superdate/QuickSelect.d.ts +1 -0
  73. package/dist/types/superdate/RelativeInput.d.ts +1 -0
  74. package/dist/types/superdate/RelativePanel.d.ts +1 -0
  75. package/dist/types/superdate/Superdate.d.ts +17 -0
  76. package/dist/types/types/index.d.ts +70 -0
  77. package/dist/types/utils/dateUtil.d.ts +30 -0
  78. package/package.json +58 -0
  79. package/src/components/Date.module.css +75 -0
  80. package/src/components/DateCell.tsx +181 -0
  81. package/src/components/DateHeader.tsx +223 -0
  82. package/src/components/DatePage.tsx +107 -0
  83. package/src/components/DecadePage.tsx +53 -0
  84. package/src/components/MonthPage.tsx +52 -0
  85. package/src/components/TimeSliders.tsx +196 -0
  86. package/src/components/YearPage.tsx +53 -0
  87. package/src/display/DateDisplay.tsx +88 -0
  88. package/src/hijri/index.js +1540 -0
  89. package/src/i18n/ar.json +14 -0
  90. package/src/i18n/en.json +13 -0
  91. package/src/i18n/index.ts +31 -0
  92. package/src/i18n/superdate/ar.json +70 -0
  93. package/src/i18n/superdate/en.json +75 -0
  94. package/src/index.ts +32 -0
  95. package/src/panels/BasePanel.tsx +130 -0
  96. package/src/panels/DatePanel.tsx +235 -0
  97. package/src/panels/RangePanel.tsx +400 -0
  98. package/src/superdate/EventPanel.tsx +200 -0
  99. package/src/superdate/QuickSelect.tsx +121 -0
  100. package/src/superdate/RelativeInput.tsx +64 -0
  101. package/src/superdate/RelativePanel.tsx +103 -0
  102. package/src/superdate/SuperDate.module.css +30 -0
  103. package/src/superdate/Superdate.tsx +186 -0
  104. package/src/types/index.ts +121 -0
  105. package/src/utils/dateUtil.ts +551 -0
@@ -0,0 +1,59 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import { getDay } from 'date-fns';
6
+ import i18next from 'i18next';
7
+ import { useMemo, Fragment, createElement } from 'react';
8
+ import { DateUtil } from '../utils/dateUtil.js';
9
+ import { DateCell } from './DateCell.js';
10
+ import classNames from 'classnames';
11
+ import { PageType } from '../types/index.js';
12
+ import classes from './Date.module.css';
13
+ import { jsxs, jsx } from 'react/jsx-runtime';
14
+
15
+ var _excluded = ["pageDate", "isHijri"];
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ var rows = [0, 1, 2, 3, 4, 5];
19
+ var cols = [0, 1, 2, 3, 4, 5, 6];
20
+ var DatePage = function DatePage(_ref) {
21
+ var pageDate = _ref.pageDate,
22
+ isHijri = _ref.isHijri,
23
+ props = _objectWithoutProperties(_ref, _excluded);
24
+ var startDate = useMemo(function () {
25
+ var first = DateUtil.startOfMonth(pageDate, isHijri);
26
+ var current = getDay(first);
27
+ return DateUtil.addDays(first, (current < 3 ? -7 : 0) + current * -1, isHijri);
28
+ }, [isHijri, pageDate]);
29
+ return /*#__PURE__*/jsxs("div", {
30
+ className: classNames("grid grid-cols-8 area-content", props.page !== PageType.DATE && "invisible"),
31
+ children: [/*#__PURE__*/jsx("div", {
32
+ className: classNames(classes.dateHeader, "px-1 text-center bg-tint-50 h-7")
33
+ }), cols.map(function (col) {
34
+ var dt = DateUtil.addDays(startDate, col, isHijri);
35
+ return /*#__PURE__*/jsx("div", {
36
+ className: classNames(classes.dateHeader, "font-medium text-sm p-1 mx-px text-center text-muted bg-tint-50 h-7"),
37
+ children: DateUtil.format(dt, "eeeeee", i18next.language, isHijri)
38
+ }, dt.toISOString());
39
+ }), rows.map(function (row) {
40
+ return /*#__PURE__*/jsxs(Fragment, {
41
+ children: [/*#__PURE__*/jsx("div", {
42
+ className: "px-1 py-1.5 m-px text-xs text-center text-tint-300",
43
+ children: DateUtil.getWeek(DateUtil.addDays(startDate, row * 7, isHijri), i18next.language, isHijri)
44
+ }, row), cols.map(function (col) {
45
+ var dt = DateUtil.addDays(startDate, row * 7 + col, isHijri);
46
+ return /*#__PURE__*/createElement(DateCell, _objectSpread(_objectSpread({}, props), {}, {
47
+ date: dt,
48
+ page: PageType.DATE,
49
+ isHijri: isHijri,
50
+ key: dt.toISOString(),
51
+ isMuted: !DateUtil.isSameMonth(dt, pageDate, isHijri)
52
+ }));
53
+ })]
54
+ }, row);
55
+ })]
56
+ });
57
+ };
58
+
59
+ export { DatePage };
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import { useMemo } from 'react';
6
+ import { DateUtil } from '../utils/dateUtil.js';
7
+ import { DateCell } from './DateCell.js';
8
+ import { jsx } from 'react/jsx-runtime';
9
+
10
+ var _excluded = ["pageDate", "isHijri"];
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ var cols = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
14
+ var DecadePage = function DecadePage(_ref) {
15
+ var pageDate = _ref.pageDate,
16
+ isHijri = _ref.isHijri,
17
+ props = _objectWithoutProperties(_ref, _excluded);
18
+ var startDate = useMemo(function () {
19
+ return DateUtil.startOfCentury(pageDate, isHijri);
20
+ }, [isHijri, pageDate]);
21
+ return /*#__PURE__*/jsx("div", {
22
+ className: "grid grid-cols-3 area-content place-content-center",
23
+ children: cols.map(function (col) {
24
+ return /*#__PURE__*/jsx(DateCell, _objectSpread({
25
+ isHijri: isHijri,
26
+ className: "px-1 py-3",
27
+ date: DateUtil.addYears(startDate, col * 10, isHijri),
28
+ isMuted: col === -1 || col === 10
29
+ }, props), col);
30
+ })
31
+ });
32
+ };
33
+
34
+ export { DecadePage };
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import { useMemo } from 'react';
6
+ import { DateUtil } from '../utils/dateUtil.js';
7
+ import { DateCell } from './DateCell.js';
8
+ import { jsx } from 'react/jsx-runtime';
9
+
10
+ var _excluded = ["pageDate", "isHijri"];
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ var cols = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
14
+ var MonthPage = function MonthPage(_ref) {
15
+ var pageDate = _ref.pageDate,
16
+ isHijri = _ref.isHijri,
17
+ props = _objectWithoutProperties(_ref, _excluded);
18
+ var startDate = useMemo(function () {
19
+ return DateUtil.startOfYear(pageDate, isHijri);
20
+ }, [isHijri, pageDate]);
21
+ return /*#__PURE__*/jsx("div", {
22
+ className: "grid grid-cols-3 area-content place-content-center",
23
+ children: cols.map(function (col) {
24
+ return /*#__PURE__*/jsx(DateCell, _objectSpread({
25
+ isHijri: isHijri,
26
+ className: "px-1 py-3",
27
+ date: DateUtil.addMonths(startDate, col, isHijri)
28
+ }, props), col);
29
+ })
30
+ });
31
+ };
32
+
33
+ export { MonthPage };
@@ -0,0 +1,131 @@
1
+ 'use client';
2
+
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import { useDebounce } from '@react-fabric/core';
5
+ import classNames from 'classnames';
6
+ import { useRef, useState, useEffect, useCallback } from 'react';
7
+ import classes from './Date.module.css';
8
+ import { jsxs, jsx } from 'react/jsx-runtime';
9
+
10
+ var TimeSlider = function TimeSlider(_ref) {
11
+ var _ref$hour = _ref.hour,
12
+ hour = _ref$hour === void 0 ? 0 : _ref$hour,
13
+ _ref$minute = _ref.minute,
14
+ minute = _ref$minute === void 0 ? 0 : _ref$minute,
15
+ onTimeChange = _ref.onTimeChange;
16
+ var hourRef = useRef(null);
17
+ var minuteRef = useRef(null);
18
+ var _useState = useState(hour),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ h = _useState2[0],
21
+ setH = _useState2[1];
22
+ var _useState3 = useState(minute),
23
+ _useState4 = _slicedToArray(_useState3, 2),
24
+ m = _useState4[0],
25
+ setM = _useState4[1];
26
+ useEffect(function () {
27
+ var _hourRef$current;
28
+ setH(hour);
29
+ (_hourRef$current = hourRef.current) === null || _hourRef$current === void 0 || (_hourRef$current = _hourRef$current.children.item(hour + 1)) === null || _hourRef$current === void 0 || _hourRef$current.scrollIntoView({
30
+ block: "center"
31
+ });
32
+ }, [hour]);
33
+ useEffect(function () {
34
+ var _minuteRef$current;
35
+ setM(minute);
36
+ (_minuteRef$current = minuteRef.current) === null || _minuteRef$current === void 0 || (_minuteRef$current = _minuteRef$current.children.item(minute + 1)) === null || _minuteRef$current === void 0 || _minuteRef$current.scrollIntoView({
37
+ block: "center"
38
+ });
39
+ }, [minute]);
40
+ var fireChange = useDebounce(onTimeChange, [onTimeChange]);
41
+ var calculateTime = useCallback(function () {
42
+ var _hourRef$current$scro, _hourRef$current2, _offsetHeight, _hourRef$current3, _minuteRef$current$sc, _minuteRef$current2, _offsetHeight2, _minuteRef$current3;
43
+ var hourTop = (_hourRef$current$scro = (_hourRef$current2 = hourRef.current) === null || _hourRef$current2 === void 0 ? void 0 : _hourRef$current2.scrollTop) !== null && _hourRef$current$scro !== void 0 ? _hourRef$current$scro : 0;
44
+ var hourHeight = (_offsetHeight = (_hourRef$current3 = hourRef.current) === null || _hourRef$current3 === void 0 || (_hourRef$current3 = _hourRef$current3.children.item(1)) === null || _hourRef$current3 === void 0 ? void 0 : _hourRef$current3.offsetHeight) !== null && _offsetHeight !== void 0 ? _offsetHeight : 0;
45
+ var minuteTop = (_minuteRef$current$sc = (_minuteRef$current2 = minuteRef.current) === null || _minuteRef$current2 === void 0 ? void 0 : _minuteRef$current2.scrollTop) !== null && _minuteRef$current$sc !== void 0 ? _minuteRef$current$sc : 0;
46
+ var minuteHeight = (_offsetHeight2 = (_minuteRef$current3 = minuteRef.current) === null || _minuteRef$current3 === void 0 || (_minuteRef$current3 = _minuteRef$current3.children.item(1)) === null || _minuteRef$current3 === void 0 ? void 0 : _minuteRef$current3.offsetHeight) !== null && _offsetHeight2 !== void 0 ? _offsetHeight2 : 0;
47
+ var hour = Math.round(hourTop / hourHeight);
48
+ var minute = Math.round(minuteTop / minuteHeight);
49
+ setH(hour);
50
+ setM(minute);
51
+ fireChange({
52
+ hour: hour,
53
+ minute: minute
54
+ });
55
+ }, [onTimeChange]);
56
+ return /*#__PURE__*/jsxs("div", {
57
+ className: classNames("area-[time] flex flex-col flex-nowrap border-s border-s-tint-50 overflow-hidden bg-base"),
58
+ children: [/*#__PURE__*/jsxs("div", {
59
+ className: "flex",
60
+ children: [/*#__PURE__*/jsx("div", {
61
+ className: classNames(classes.dateHeader, "flex-1 font-medium text-muted text-sm p-1 mx-px text-center bg-tint-50"),
62
+ children: "H"
63
+ }), /*#__PURE__*/jsx("div", {
64
+ className: classNames(classes.dateHeader, "flex-1 font-medium text-muted text-sm p-1 mx-px text-center bg-tint-50"),
65
+ children: "M"
66
+ })]
67
+ }), /*#__PURE__*/jsxs("div", {
68
+ className: "flex flex-1 flex-nowrap overflow-hidden relative",
69
+ children: [/*#__PURE__*/jsxs("div", {
70
+ className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory", classes.timeSlider),
71
+ onScroll: calculateTime,
72
+ ref: hourRef,
73
+ children: [/*#__PURE__*/jsx("div", {
74
+ className: "w-full"
75
+ }), Array(24).fill(0).map(function (_, i) {
76
+ return /*#__PURE__*/jsx("div", {
77
+ role: "none",
78
+ className: classNames("ps-2 pe-1 snap-center outline outline-muted", i === h && "font-medium text-primary-600"),
79
+ "data-skew": i === h - 5 || i === h + 5 ? 5 : i === h - 4 || i === h + 4 ? 4 : i === h - 3 || i === h + 3 ? 3 : i === h - 2 || i === h + 2 ? 2 : i === h - 1 || i === h + 1 ? 1 : undefined,
80
+ "data-selected": i === h,
81
+ onClick: function onClick(e) {
82
+ e.currentTarget.scrollIntoView({
83
+ block: "center",
84
+ behavior: "smooth"
85
+ });
86
+ },
87
+ children: /*#__PURE__*/jsx("div", {
88
+ children: i.toString(10).padStart(2, "0")
89
+ })
90
+ }, i);
91
+ }), /*#__PURE__*/jsx("div", {
92
+ className: "w-full"
93
+ })]
94
+ }), /*#__PURE__*/jsxs("div", {
95
+ className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory", classes.timeSlider),
96
+ onScroll: calculateTime,
97
+ ref: minuteRef,
98
+ children: [/*#__PURE__*/jsx("div", {
99
+ className: "w-full"
100
+ }), Array(60).fill(0).map(function (_, i) {
101
+ return /*#__PURE__*/jsx("div", {
102
+ role: "none",
103
+ className: classNames("ps-1 pe-2 snap-center outline outline-muted", i === m && "font-medium text-primary-600"),
104
+ "data-skew": i === m - 5 || i === m + 5 ? 5 : i === m - 4 || i === m + 4 ? 4 : i === m - 3 || i === m + 3 ? 3 : i === m - 2 || i === m + 2 ? 2 : i === m - 1 || i === m + 1 ? 1 : undefined,
105
+ "data-selected": i === m,
106
+ onClick: function onClick(e) {
107
+ e.currentTarget.scrollIntoView({
108
+ block: "center",
109
+ behavior: "smooth"
110
+ });
111
+ },
112
+ children: /*#__PURE__*/jsx("div", {
113
+ children: i.toString(10).padStart(2, "0")
114
+ })
115
+ }, i);
116
+ }), /*#__PURE__*/jsx("div", {
117
+ className: "w-full"
118
+ })]
119
+ }), /*#__PURE__*/jsxs("div", {
120
+ className: "border rounded border-primary-500 absolute top-1/2 -translate-y-1/2 h-6 w-full flex items-center justify-between bg-primary-200/10",
121
+ children: [/*#__PURE__*/jsx("div", {
122
+ className: "border-s-4 border-t-4 border-b-4 border-transparent border-s-primary-500"
123
+ }), /*#__PURE__*/jsx("div", {
124
+ className: "border-e-4 border-t-4 border-b-4 border-transparent border-e-primary-500"
125
+ })]
126
+ })]
127
+ })]
128
+ });
129
+ };
130
+
131
+ export { TimeSlider };
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import { useMemo } from 'react';
6
+ import { DateUtil } from '../utils/dateUtil.js';
7
+ import { DateCell } from './DateCell.js';
8
+ import { jsx } from 'react/jsx-runtime';
9
+
10
+ var _excluded = ["pageDate", "isHijri"];
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ var cols = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
14
+ var YearPage = function YearPage(_ref) {
15
+ var pageDate = _ref.pageDate,
16
+ isHijri = _ref.isHijri,
17
+ props = _objectWithoutProperties(_ref, _excluded);
18
+ var startDate = useMemo(function () {
19
+ return DateUtil.startOfDecade(pageDate, isHijri);
20
+ }, [isHijri, pageDate]);
21
+ return /*#__PURE__*/jsx("div", {
22
+ className: "grid grid-cols-3 area-content place-content-center",
23
+ children: cols.map(function (col) {
24
+ return /*#__PURE__*/jsx(DateCell, _objectSpread({
25
+ isHijri: isHijri,
26
+ className: "px-1 py-3",
27
+ date: DateUtil.addYears(startDate, col, isHijri),
28
+ isMuted: col === -1 || col === 10
29
+ }, props), col);
30
+ })
31
+ });
32
+ };
33
+
34
+ export { YearPage };
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import { useGlobals, Tooltip, Dropdown } from '@react-fabric/core';
6
+ import { DateUtil } from '../utils/dateUtil.js';
7
+ import { jsx, jsxs } from 'react/jsx-runtime';
8
+
9
+ var _excluded = ["date", "className", "format", "children"];
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ var DateDisplay = function DateDisplay(_ref) {
13
+ var date = _ref.date,
14
+ className = _ref.className,
15
+ _ref$format = _ref.format,
16
+ format = _ref$format === void 0 ? "eee, PPpp" : _ref$format,
17
+ children = _ref.children,
18
+ aria = _objectWithoutProperties(_ref, _excluded);
19
+ var _useGlobals = useGlobals(),
20
+ currentCalendar = _useGlobals.currentCalendar,
21
+ currentLocale = _useGlobals.currentLocale;
22
+ var dtLabel = /*#__PURE__*/jsx(Tooltip, {
23
+ content: DateUtil.format(date, format, currentLocale, currentCalendar !== "hijri"),
24
+ children: /*#__PURE__*/jsx("span", _objectSpread(_objectSpread({
25
+ className: className
26
+ }, aria), {}, {
27
+ children: DateUtil.format(date, format, currentLocale, currentCalendar === "hijri")
28
+ }))
29
+ });
30
+ return children ? /*#__PURE__*/jsxs(Dropdown, {
31
+ children: [dtLabel, children]
32
+ }) : dtLabel;
33
+ };
34
+
35
+ export { DateDisplay };