@react-fabric/date 1.0.0-beta.9 → 1.0.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 (139) hide show
  1. package/README.md +2 -9
  2. package/{src/components/Date.module.css → css/_date.css} +5 -5
  3. package/{src/superdate/SuperDate.module.css → css/styles.css} +2 -8
  4. package/dist/cjs/components/DateCell.js +5 -7
  5. package/dist/cjs/components/DateHeader.js +27 -20
  6. package/dist/cjs/components/DatePage.js +10 -12
  7. package/dist/cjs/components/DecadePage.js +3 -3
  8. package/dist/cjs/components/MonthPage.js +3 -3
  9. package/dist/cjs/components/TimeSliders.js +36 -35
  10. package/dist/cjs/components/YearPage.js +3 -3
  11. package/dist/cjs/display/DateDisplay.js +25 -8
  12. package/dist/cjs/display/DateDuration.js +155 -0
  13. package/dist/cjs/hijri/DateConverter.js +154 -0
  14. package/dist/cjs/hijri/FormatDate.js +116 -0
  15. package/dist/cjs/hijri/HijriDate.js +531 -0
  16. package/dist/cjs/hijri/StringDateParser.js +74 -0
  17. package/dist/cjs/hijri/index.js +15 -1025
  18. package/dist/cjs/hijri/initializer.js +113 -0
  19. package/dist/cjs/hijri/locales.js +19 -0
  20. package/dist/cjs/hijri/safe.js +17 -0
  21. package/dist/cjs/i18n/ar/date.json.js +213 -0
  22. package/dist/cjs/i18n/en/date.json.js +83 -0
  23. package/dist/cjs/i18n/index.js +4 -10
  24. package/dist/cjs/index.js +41 -2
  25. package/dist/cjs/panels/BasePanel.js +6 -5
  26. package/dist/cjs/panels/DatePanel.js +45 -21
  27. package/dist/cjs/{superdate → panels}/EventPanel.js +28 -12
  28. package/dist/cjs/panels/RangePanel.js +49 -19
  29. package/dist/cjs/utils/dateUtil.js +3 -5
  30. package/dist/esm/components/DateCell.js +6 -8
  31. package/dist/esm/components/DateHeader.js +28 -21
  32. package/dist/esm/components/DatePage.js +11 -13
  33. package/dist/esm/components/DecadePage.js +3 -3
  34. package/dist/esm/components/MonthPage.js +3 -3
  35. package/dist/esm/components/TimeSliders.js +38 -37
  36. package/dist/esm/components/YearPage.js +3 -3
  37. package/dist/esm/display/DateDisplay.js +26 -9
  38. package/dist/esm/display/DateDuration.js +155 -0
  39. package/dist/esm/hijri/DateConverter.js +152 -0
  40. package/dist/esm/hijri/FormatDate.js +113 -0
  41. package/dist/esm/hijri/HijriDate.js +528 -0
  42. package/dist/esm/hijri/StringDateParser.js +74 -0
  43. package/dist/esm/hijri/index.js +15 -1025
  44. package/dist/esm/hijri/initializer.js +113 -0
  45. package/dist/esm/hijri/locales.js +18 -0
  46. package/dist/esm/hijri/safe.js +14 -0
  47. package/dist/esm/i18n/ar/date.json.js +209 -0
  48. package/dist/esm/i18n/en/date.json.js +79 -0
  49. package/dist/esm/i18n/index.js +2 -8
  50. package/dist/esm/index.js +36 -1
  51. package/dist/esm/panels/BasePanel.js +6 -5
  52. package/dist/esm/panels/DatePanel.js +48 -24
  53. package/dist/esm/{superdate → panels}/EventPanel.js +29 -13
  54. package/dist/esm/panels/RangePanel.js +52 -22
  55. package/dist/esm/utils/dateUtil.js +4 -6
  56. package/dist/types/components/DateCell.d.ts +1 -1
  57. package/dist/types/components/DateHeader.d.ts +1 -1
  58. package/dist/types/components/DatePage.d.ts +1 -1
  59. package/dist/types/components/DecadePage.d.ts +1 -1
  60. package/dist/types/components/MonthPage.d.ts +1 -1
  61. package/dist/types/components/TimeSliders.d.ts +1 -1
  62. package/dist/types/components/YearPage.d.ts +1 -1
  63. package/dist/types/display/DateDisplay.d.ts +17 -4
  64. package/dist/types/display/DateDuration.d.ts +25 -0
  65. package/dist/types/hijri/DateConverter.d.ts +13 -0
  66. package/dist/types/hijri/FormatDate.d.ts +19 -0
  67. package/dist/types/hijri/HijriDate.d.ts +214 -0
  68. package/dist/types/hijri/StringDateParser.d.ts +11 -0
  69. package/dist/types/hijri/index.d.ts +2 -2
  70. package/dist/types/hijri/initializer.d.ts +129 -0
  71. package/dist/types/hijri/locales.d.ts +19 -0
  72. package/dist/types/hijri/safe.d.ts +3 -0
  73. package/dist/types/index.d.ts +32 -1
  74. package/dist/types/panels/BasePanel.d.ts +1 -1
  75. package/dist/types/panels/DatePanel.d.ts +22 -1
  76. package/dist/types/panels/EventPanel.d.ts +17 -0
  77. package/dist/types/panels/RangePanel.d.ts +19 -1
  78. package/dist/types/types/index.d.ts +8 -40
  79. package/package.json +14 -21
  80. package/src/components/DateCell.tsx +20 -75
  81. package/src/components/DateHeader.tsx +27 -78
  82. package/src/components/DatePage.tsx +11 -36
  83. package/src/components/DecadePage.tsx +2 -2
  84. package/src/components/MonthPage.tsx +2 -2
  85. package/src/components/TimeSliders.tsx +20 -60
  86. package/src/components/YearPage.tsx +2 -2
  87. package/src/display/DateDisplay.tsx +26 -38
  88. package/src/display/DateDuration.tsx +170 -0
  89. package/src/hijri/DateConverter.js +175 -0
  90. package/src/hijri/FormatDate.js +134 -0
  91. package/src/hijri/HijriDate.js +477 -0
  92. package/src/hijri/StringDateParser.js +68 -0
  93. package/src/hijri/index.js +16 -1535
  94. package/src/hijri/initializer.js +96 -0
  95. package/src/hijri/locales.js +109 -0
  96. package/src/hijri/safe.js +16 -0
  97. package/src/i18n/ar/date.json +203 -0
  98. package/src/i18n/en/date.json +73 -0
  99. package/src/i18n/index.ts +2 -5
  100. package/src/index.ts +29 -18
  101. package/src/panels/BasePanel.tsx +7 -10
  102. package/src/panels/DatePanel.tsx +41 -33
  103. package/src/{superdate → panels}/EventPanel.tsx +52 -53
  104. package/src/panels/RangePanel.tsx +54 -60
  105. package/src/types/index.ts +8 -43
  106. package/src/utils/dateUtil.ts +26 -82
  107. package/dist/cjs/components/Date.module.css +0 -1
  108. package/dist/cjs/i18n/ar.json.js +0 -25
  109. package/dist/cjs/i18n/en.json.js +0 -21
  110. package/dist/cjs/i18n/superdate/ar.json.js +0 -86
  111. package/dist/cjs/i18n/superdate/en.json.js +0 -93
  112. package/dist/cjs/superdate/QuickSelect.js +0 -134
  113. package/dist/cjs/superdate/RelativeInput.js +0 -79
  114. package/dist/cjs/superdate/RelativePanel.js +0 -91
  115. package/dist/cjs/superdate/SuperDate.module.css +0 -1
  116. package/dist/cjs/superdate/Superdate.js +0 -177
  117. package/dist/esm/components/Date.module.css +0 -1
  118. package/dist/esm/i18n/ar.json.js +0 -21
  119. package/dist/esm/i18n/en.json.js +0 -18
  120. package/dist/esm/i18n/superdate/ar.json.js +0 -79
  121. package/dist/esm/i18n/superdate/en.json.js +0 -85
  122. package/dist/esm/superdate/QuickSelect.js +0 -134
  123. package/dist/esm/superdate/RelativeInput.js +0 -79
  124. package/dist/esm/superdate/RelativePanel.js +0 -91
  125. package/dist/esm/superdate/SuperDate.module.css +0 -1
  126. package/dist/esm/superdate/Superdate.js +0 -176
  127. package/dist/types/superdate/EventPanel.d.ts +0 -4
  128. package/dist/types/superdate/QuickSelect.d.ts +0 -1
  129. package/dist/types/superdate/RelativeInput.d.ts +0 -1
  130. package/dist/types/superdate/RelativePanel.d.ts +0 -1
  131. package/dist/types/superdate/Superdate.d.ts +0 -17
  132. package/src/i18n/ar.json +0 -14
  133. package/src/i18n/en.json +0 -13
  134. package/src/i18n/superdate/ar.json +0 -70
  135. package/src/i18n/superdate/en.json +0 -75
  136. package/src/superdate/QuickSelect.tsx +0 -121
  137. package/src/superdate/RelativeInput.tsx +0 -64
  138. package/src/superdate/RelativePanel.tsx +0 -103
  139. package/src/superdate/Superdate.tsx +0 -198
@@ -1,91 +0,0 @@
1
- 'use strict';
2
-
3
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
- var core = require('@react-fabric/core');
5
- var form = require('@react-fabric/form');
6
- var utilities = require('@react-fabric/utilities');
7
- var react = require('react');
8
- var reactI18next = require('react-i18next');
9
- var index = require('../types/index.js');
10
- var RelativeInput = require('./RelativeInput.js');
11
- var jsxRuntime = require('react/jsx-runtime');
12
-
13
- var schema = utilities.yup.object({
14
- from: utilities.yup.object({
15
- diff: utilities.yup.number().required().label("Difference"),
16
- op: utilities.yup.string().required().oneOf(["+", "-"]).label("Operator"),
17
- part: utilities.yup.string().required().oneOf(Object.values(index.DatePart)).label("Date part")
18
- }),
19
- to: utilities.yup.object({
20
- diff: utilities.yup.number().required().label("Difference"),
21
- op: utilities.yup.string().required().oneOf(["+", "-"]).label("Operator"),
22
- part: utilities.yup.string().required().oneOf(Object.values(index.DatePart)).label("Date part")
23
- })
24
- });
25
- var RelativePanel = function RelativePanel(_ref) {
26
- var _ref$value = _ref.value,
27
- value = _ref$value === void 0 ? "" : _ref$value,
28
- onChange = _ref.onChange;
29
- var _useTranslation = reactI18next.useTranslation("superdate"),
30
- t = _useTranslation.t;
31
- var handleChange = react.useCallback(function (_ref2) {
32
- var to = _ref2.to,
33
- from = _ref2.from;
34
- onChange("".concat(from.part).concat(from.op).concat(from.diff, "|").concat(to.part).concat(to.op).concat(to.diff));
35
- }, []);
36
- var defaultValue = react.useMemo(function () {
37
- if (value !== null && value !== void 0 && value.match(/^(\$\w+)([+-])(\d+)?\|(\$\w+)([+-])(\d+)?$/)) {
38
- var _value$split$shift$ma, _value$split$pop$matc;
39
- var _ref3 = (_value$split$shift$ma = value.split("|").shift().match(/^(\$\w+)([+-])(\d+)?$/)) !== null && _value$split$shift$ma !== void 0 ? _value$split$shift$ma : [],
40
- _ref4 = _slicedToArray(_ref3, 4),
41
- part = _ref4[1],
42
- op = _ref4[2],
43
- _ref4$ = _ref4[3],
44
- diff = _ref4$ === void 0 ? "0" : _ref4$;
45
- var _ref5 = (_value$split$pop$matc = value.split("|").pop().match(/^(\$\w+)([+-])(\d+)?$/)) !== null && _value$split$pop$matc !== void 0 ? _value$split$pop$matc : [],
46
- _ref6 = _slicedToArray(_ref5, 4),
47
- toPart = _ref6[1],
48
- toOp = _ref6[2],
49
- _ref6$ = _ref6[3],
50
- toDiff = _ref6$ === void 0 ? "0" : _ref6$;
51
- return {
52
- from: {
53
- part: part,
54
- op: op,
55
- diff: diff
56
- },
57
- to: {
58
- part: toPart,
59
- op: toOp,
60
- diff: toDiff
61
- }
62
- };
63
- }
64
- }, [value]);
65
- return /*#__PURE__*/jsxRuntime.jsx(core.Content, {
66
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
67
- className: "scale-90",
68
- children: /*#__PURE__*/jsxRuntime.jsxs(form.Form, {
69
- schema: schema,
70
- defaultValues: defaultValue,
71
- onSubmit: handleChange,
72
- children: [/*#__PURE__*/jsxRuntime.jsx(RelativeInput.RelativeInput, {
73
- label: t("label.from"),
74
- prefix: "from"
75
- }), /*#__PURE__*/jsxRuntime.jsx(RelativeInput.RelativeInput, {
76
- label: t("label.to"),
77
- prefix: "to"
78
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
79
- className: "flex justify-end",
80
- children: /*#__PURE__*/jsxRuntime.jsx(core.Button, {
81
- variant: "solid",
82
- type: "submit",
83
- children: t("label.apply")
84
- })
85
- })]
86
- })
87
- })
88
- });
89
- };
90
-
91
- exports.RelativePanel = RelativePanel;
@@ -1 +0,0 @@
1
- @layer comp{.superDate{&:root{font-size:10px}}}
@@ -1,177 +0,0 @@
1
- 'use strict';
2
-
3
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
5
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
6
- var react$1 = require('@floating-ui/react');
7
- var core = require('@react-fabric/core');
8
- var classNames = require('classnames');
9
- var react = require('react');
10
- var reactI18next = require('react-i18next');
11
- var RangePanel = require('../panels/RangePanel.js');
12
- var dateUtil = require('../utils/dateUtil.js');
13
- var EventPanel = require('./EventPanel.js');
14
- var QuickSelect = require('./QuickSelect.js');
15
- var RelativePanel = require('./RelativePanel.js');
16
- var SuperDate_module = require('./SuperDate.module.css');
17
- var jsxRuntime = require('react/jsx-runtime');
18
-
19
- var _excluded = ["as", "color", "variant", "disabled", "onChange", "value", "data-test-value", "data-testid"];
20
- 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; }
21
- 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; }
22
- var SuperDateTabs = function SuperDateTabs(_ref) {
23
- var events = _ref.events,
24
- value = _ref.value,
25
- presets = _ref.presets,
26
- recurringEvents = _ref.recurringEvents,
27
- onChange = _ref.onChange;
28
- var _useTranslation = reactI18next.useTranslation("superdate"),
29
- t = _useTranslation.t;
30
- var tree = react$1.useFloatingTree();
31
- var _useGlobals = core.useGlobals(),
32
- currentCalendar = _useGlobals.currentCalendar,
33
- currentLocale = _useGlobals.currentLocale;
34
- var isHijri = react.useMemo(function () {
35
- return currentCalendar === "hijri";
36
- }, [currentCalendar]);
37
- var _useState = react.useState(""),
38
- _useState2 = _slicedToArray(_useState, 2),
39
- currentValue = _useState2[0],
40
- setCurrentValue = _useState2[1];
41
- var _useState3 = react.useState("quick"),
42
- _useState4 = _slicedToArray(_useState3, 2),
43
- activeTab = _useState4[0],
44
- setActiveTab = _useState4[1];
45
- react.useEffect(function () {
46
- if (value !== null && value !== void 0 && value.match(/^(\$\w+)([+-])(\d+)\|(\$\w+)([+-])(\d+)$/)) setActiveTab("relative");else if (value && !(value !== null && value !== void 0 && value.match(/^(\$\w+)/))) setActiveTab("absolute");else setActiveTab("quick");
47
- value && setCurrentValue(value);
48
- }, [value]);
49
- var handleChange = react.useCallback(function (value) {
50
- var _parsed$, _parsed$$toISOString, _parsed$2, _parsed$2$toISOString;
51
- var parsed = dateUtil.DateUtil.parseRange(value);
52
- setCurrentValue(value);
53
- onChange === null || onChange === void 0 || onChange(value, [(_parsed$ = parsed[0]) === null || _parsed$ === void 0 || (_parsed$$toISOString = _parsed$.toISOString) === null || _parsed$$toISOString === void 0 ? void 0 : _parsed$$toISOString.call(_parsed$), (_parsed$2 = parsed[1]) === null || _parsed$2 === void 0 || (_parsed$2$toISOString = _parsed$2.toISOString) === null || _parsed$2$toISOString === void 0 ? void 0 : _parsed$2$toISOString.call(_parsed$2)]);
54
- tree === null || tree === void 0 || tree.events.emit("close");
55
- }, [isHijri, currentLocale]);
56
- return /*#__PURE__*/jsxRuntime.jsx("div", {
57
- className: classNames("rounded-capped outline select-none overflow-hidden grid", SuperDate_module.superDate),
58
- children: /*#__PURE__*/jsxRuntime.jsxs(core.TabPanel, {
59
- headerClassName: "border-b",
60
- onChange: setActiveTab,
61
- activeTab: activeTab,
62
- children: [/*#__PURE__*/jsxRuntime.jsx(core.Tab, {
63
- id: "quick",
64
- label: t("label.quick"),
65
- children: /*#__PURE__*/jsxRuntime.jsx(QuickSelect.QuickSelect, {
66
- value: currentValue,
67
- onChange: handleChange,
68
- presets: presets
69
- })
70
- }), /*#__PURE__*/jsxRuntime.jsx(core.Tab, {
71
- id: "relative",
72
- label: t("label.relative"),
73
- children: /*#__PURE__*/jsxRuntime.jsx(RelativePanel.RelativePanel, {
74
- value: currentValue,
75
- onChange: handleChange
76
- })
77
- }), /*#__PURE__*/jsxRuntime.jsx(core.Tab, {
78
- id: "absolute",
79
- label: t("label.absolute"),
80
- children: /*#__PURE__*/jsxRuntime.jsx(core.Content, {
81
- className: "p-0",
82
- children: /*#__PURE__*/jsxRuntime.jsx(RangePanel.RangePanel, {
83
- withTime: true,
84
- showHijriToggle: true,
85
- value: currentValue ? dateUtil.DateUtil.parseRange(currentValue) : undefined,
86
- showApply: true,
87
- onChange: function onChange(_ref2) {
88
- var _ref3 = _slicedToArray(_ref2, 2),
89
- start = _ref3[0],
90
- end = _ref3[1];
91
- return handleChange === null || handleChange === void 0 ? void 0 : handleChange("".concat(start, "|").concat(end));
92
- }
93
- })
94
- })
95
- }), /*#__PURE__*/jsxRuntime.jsx(core.Tab, {
96
- id: "events",
97
- label: t("label.events"),
98
- children: /*#__PURE__*/jsxRuntime.jsx(EventPanel.EventPanel, {
99
- isHijri: isHijri,
100
- onChange: handleChange,
101
- events: events,
102
- recurringEvents: recurringEvents
103
- })
104
- })]
105
- })
106
- });
107
- };
108
-
109
- /**
110
- * Superdate panel provides ability to select relative and absolute dates
111
- *
112
- * Relative dates parts
113
- * `$now`,
114
- * `$minute`,
115
- * `$hour`,
116
- * `$day`,
117
- * `$week`,
118
- * `$month`,
119
- * `$quarter`,
120
- * `$year`,
121
- * `$decade`
122
- */
123
- var SuperDate = function SuperDate(_ref4) {
124
- var _DateUtil$relativeLab;
125
- var _ref4$as = _ref4.as,
126
- as = _ref4$as === void 0 ? "button" : _ref4$as,
127
- _ref4$color = _ref4.color,
128
- color = _ref4$color === void 0 ? "primary" : _ref4$color,
129
- variant = _ref4.variant,
130
- disabled = _ref4.disabled,
131
- onChange = _ref4.onChange,
132
- value = _ref4.value,
133
- testValue = _ref4["data-test-value"],
134
- testId = _ref4["data-testid"],
135
- props = _objectWithoutProperties(_ref4, _excluded);
136
- var _useGlobals2 = core.useGlobals(),
137
- currentCalendar = _useGlobals2.currentCalendar,
138
- currentLocale = _useGlobals2.currentLocale;
139
- var isHijri = react.useMemo(function () {
140
- return currentCalendar === "hijri";
141
- }, [currentCalendar]);
142
- var _useState5 = react.useState(),
143
- _useState6 = _slicedToArray(_useState5, 2),
144
- relValue = _useState6[0],
145
- setRelative = _useState6[1];
146
- react.useEffect(function () {
147
- setRelative(value);
148
- }, [value]);
149
- var handleChange = react.useCallback(function (value) {
150
- var _parsed$3, _parsed$3$toISOString, _parsed$4, _parsed$4$toISOString;
151
- var parsed = dateUtil.DateUtil.parseRange(value);
152
- setRelative(value);
153
- onChange === null || onChange === void 0 || onChange(value, [(_parsed$3 = parsed[0]) === null || _parsed$3 === void 0 || (_parsed$3$toISOString = _parsed$3.toISOString) === null || _parsed$3$toISOString === void 0 ? void 0 : _parsed$3$toISOString.call(_parsed$3), (_parsed$4 = parsed[1]) === null || _parsed$4 === void 0 || (_parsed$4$toISOString = _parsed$4.toISOString) === null || _parsed$4$toISOString === void 0 ? void 0 : _parsed$4$toISOString.call(_parsed$4)]);
154
- }, [isHijri, currentLocale]);
155
- var E = as === "button" ? core.Button : core.Chip;
156
- return /*#__PURE__*/jsxRuntime.jsxs(core.Dropdown, {
157
- showArrow: true,
158
- children: [/*#__PURE__*/jsxRuntime.jsx(core.Tooltip, {
159
- content: dateUtil.DateUtil.relativeTooltip(relValue, isHijri),
160
- children: /*#__PURE__*/jsxRuntime.jsx(E, {
161
- icon: core.CoreIcons.clock,
162
- color: color,
163
- disabled: disabled,
164
- variant: variant,
165
- "data-test-value": testValue,
166
- "data-testid": testId,
167
- children: (_DateUtil$relativeLab = dateUtil.DateUtil.relativeLabel(relValue, isHijri)) !== null && _DateUtil$relativeLab !== void 0 ? _DateUtil$relativeLab : ""
168
- })
169
- }), /*#__PURE__*/jsxRuntime.jsx(SuperDateTabs, _objectSpread(_objectSpread({}, props), {}, {
170
- value: relValue,
171
- onChange: handleChange
172
- }))]
173
- });
174
- };
175
-
176
- exports.SuperDate = SuperDate;
177
- exports.SuperDateTabs = SuperDateTabs;
@@ -1 +0,0 @@
1
- @layer comp{.dateHeader{box-shadow:inset 0 -1px 0 theme(colors.tint.200/50%)}.timeSlider{height:11.25rem;&:after,&:before{box-shadow:0 0 3rem .25rem theme(colors.tint.600);content:"";display:block;z-index:10}&:before{position:sticky;top:0}&:after{bottom:0;position:sticky}&>:first-child,&>:last-child{height:calc(50% - .75rem)}& [data-skew="1"]>div{opacity:.9;transform:scaleY(.9)}& [data-skew="2"]>div{opacity:.75;transform:scaleY(.75)}& [data-skew="3"]>div{opacity:.65;transform:scaleY(.65)}& [data-skew="4"]>div{opacity:.5;transform:scaleY(.5)}}}
@@ -1,21 +0,0 @@
1
- 'use client';
2
-
3
- var label = {
4
- prevMonth: "الشهر الماضى",
5
- prevYear: "السنة الماضية",
6
- prevDecade: "العقد السابق",
7
- nextMonth: "الشهر القادم",
8
- nextYear: "العام القادم",
9
- nextDecade: "العقد القادم",
10
- today: "اليوم",
11
- hijri: "هجري",
12
- gregorian: "ميلادي"
13
- };
14
- var number = {
15
- };
16
- var ar = {
17
- label: label,
18
- number: number
19
- };
20
-
21
- export { ar as default, label, number };
@@ -1,18 +0,0 @@
1
- 'use client';
2
-
3
- var label = {
4
- prevMonth: "Previous Month",
5
- prevYear: "Previous Year",
6
- prevDecade: "Previous Decade",
7
- nextMonth: "Next Month",
8
- nextYear: "Next Year",
9
- nextDecade: "Next Decade",
10
- today: "Today",
11
- hijri: "Hijri",
12
- gregorian: "Gregorian"
13
- };
14
- var en = {
15
- label: label
16
- };
17
-
18
- export { en as default, label };
@@ -1,79 +0,0 @@
1
- 'use client';
2
-
3
- var separator = " ⇽ ";
4
- var label = {
5
- quick: "حدد مسرعا",
6
- relative: "نسبيا",
7
- events: "الأحداث",
8
- absolute: "مطلق",
9
- preset: "المسبقة",
10
- current: "تيار",
11
- previous: "السابق",
12
- from: "من عند",
13
- to: "إلى",
14
- "+": "من الان",
15
- "-": "منذ",
16
- apply: "يتقدم",
17
- $now: "الآن",
18
- $minute: "دقيقة",
19
- $hour: "ساعة",
20
- $day: "يوم",
21
- $week: "أسبوع",
22
- $month: "شهر",
23
- $quarter: "ربع",
24
- $year: "عام",
25
- $decade: "عقد"
26
- };
27
- var now = {
28
- $day: "اليوم",
29
- $week: "هذا الاسبوع",
30
- $month: "هذا الشهر",
31
- $quarter: "هذا الربع",
32
- $year: "هذه السنة",
33
- $decade: "هذا العقد"
34
- };
35
- var next = {
36
- $day: "غدا",
37
- $week: "الاسبوع القادم",
38
- $month: "الشهر القادم",
39
- $quarter: "الربع القادم",
40
- $year: "العام القادم",
41
- $decade: "العقد القادم",
42
- $minute: "بعد دقيقة",
43
- $hour: "بعد ساعة",
44
- $minute_plural: "بعد {{count}} دقائق",
45
- $hour_plural: "بعد {{count}} ساعات",
46
- $day_plural: "بعد {{count}} أيام",
47
- $week_plural: "بعد {{count}} أسابيع",
48
- $month_plural: "بعد {{count}} أشهر",
49
- $quarter_plural: "بعد {{count}} أرباع",
50
- $year_plural: "بعد {{count}} سنوات",
51
- $decade_plural: "بعد {{count}} عقود"
52
- };
53
- var prev = {
54
- $day: "في الامس",
55
- $week: "الاسبوع الماضي",
56
- $month: "الشهر الماضي",
57
- $quarter: "الربع الأخير",
58
- $year: "العام الماضي",
59
- $decade: "العقد الماضي",
60
- $minute: "منذ دقيقة",
61
- $hour: "منذ ساعة",
62
- $minute_plural: "منذ {{count}} دقيقة",
63
- $hour_plural: "منذ {{count}} ساعات",
64
- $day_plural: "منذ {{count}} أيام",
65
- $week_plural: "من {{count}} اسابيع",
66
- $month_plural: "قبل {{count}} أشهر",
67
- $quarter_plural: "منذ {{count}} أرباع",
68
- $year_plural: "منذ {{count}} سنوات",
69
- $decade_plural: "منذ {{count}} عقود"
70
- };
71
- var arSuper = {
72
- separator: separator,
73
- label: label,
74
- now: now,
75
- next: next,
76
- prev: prev
77
- };
78
-
79
- export { arSuper as default, label, next, now, prev, separator };
@@ -1,85 +0,0 @@
1
- 'use client';
2
-
3
- var separator = " ⇾ ";
4
- var event = {
5
- ramadan: "Ramadan",
6
- christmas: "Christmas",
7
- newYear: "New Year"
8
- };
9
- var label = {
10
- quick: "Quick Select",
11
- relative: "Relative",
12
- absolute: "Absolute",
13
- events: "Events",
14
- preset: "Presets",
15
- current: "Current",
16
- previous: "Previous",
17
- from: "From",
18
- to: "To",
19
- "+": "From now",
20
- "-": "Ago",
21
- apply: "Apply",
22
- $now: "Now",
23
- $minute: "Minute",
24
- $hour: "Hour",
25
- $day: "Day",
26
- $week: "Week",
27
- $month: "Month",
28
- $quarter: "Quarter",
29
- $year: "Year",
30
- $decade: "Decade"
31
- };
32
- var now = {
33
- $day: "Today",
34
- $week: "This week",
35
- $month: "This month",
36
- $quarter: "This quarter",
37
- $year: "This year",
38
- $decade: "This decade"
39
- };
40
- var next = {
41
- $day: "Tomorrow",
42
- $week: "Next week",
43
- $month: "Next month",
44
- $quarter: "Next quarter",
45
- $year: "Next year",
46
- $decade: "Next decade",
47
- $minute: "A minute later",
48
- $hour: "An hour later",
49
- $minute_other: "{{count}} minutes later",
50
- $hour_other: "{{count}} hours later",
51
- $day_other: "{{count}} days later",
52
- $week_other: "{{count}} weeks later",
53
- $month_other: "{{count}} months later",
54
- $quarter_other: "{{count}} quarters later",
55
- $year_other: "{{count}} years later",
56
- $decade_other: "{{count}} decades later"
57
- };
58
- var prev = {
59
- $day: "Yesterday",
60
- $week: "Last week",
61
- $month: "Last month",
62
- $quarter: "Last quarter",
63
- $year: "Last year",
64
- $decade: "Last decade",
65
- $minute: "A minute ago",
66
- $hour: "An hour ago",
67
- $minute_other: "{{count}} minutes ago",
68
- $hour_other: "{{count}} hours ago",
69
- $day_other: "{{count}} days ago",
70
- $week_other: "{{count}} weeks ago",
71
- $month_other: "{{count}} months ago",
72
- $quarter_other: "{{count}} quarters ago",
73
- $year_other: "{{count}} years ago",
74
- $decade_other: "{{count}} decades ago"
75
- };
76
- var enSuper = {
77
- separator: separator,
78
- event: event,
79
- label: label,
80
- now: now,
81
- next: next,
82
- prev: prev
83
- };
84
-
85
- export { enSuper as default, event, label, next, now, prev, separator };
@@ -1,134 +0,0 @@
1
- 'use client';
2
-
3
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
- import { Content, Divider } from '@react-fabric/core';
5
- import { Form } from '@react-fabric/form';
6
- import { yup } from '@react-fabric/utilities';
7
- import { useCallback, useMemo } from 'react';
8
- import { useTranslation } from 'react-i18next';
9
- import { DatePart } from '../types/index.js';
10
- import { RelativeInput } from './RelativeInput.js';
11
- import { jsxs, jsx } from 'react/jsx-runtime';
12
-
13
- var DEFAULT_PRESETS = [{
14
- value: "$day",
15
- label: "superdate:now.$day"
16
- }, {
17
- value: "$day-1",
18
- label: "superdate:prev.$day"
19
- }, {
20
- value: "$day+1",
21
- label: "superdate:next.$day"
22
- }, {
23
- value: "$week",
24
- label: "superdate:now.$week"
25
- }, {
26
- value: "$week-1",
27
- label: "superdate:prev.$week"
28
- }, {
29
- value: "$week+1",
30
- label: "superdate:next.$week"
31
- }, {
32
- value: "$month",
33
- label: "superdate:now.$month"
34
- }, {
35
- value: "$month-1",
36
- label: "superdate:prev.$month"
37
- }, {
38
- value: "$month+1",
39
- label: "superdate:next.$month"
40
- }, {
41
- value: "$quarter",
42
- label: "superdate:now.$quarter"
43
- }, {
44
- value: "$quarter-1",
45
- label: "superdate:prev.$quarter"
46
- }, {
47
- value: "$quarter+1",
48
- label: "superdate:next.$quarter"
49
- }, {
50
- value: "$year",
51
- label: "superdate:now.$year"
52
- }, {
53
- value: "$year-1",
54
- label: "superdate:prev.$year"
55
- }, {
56
- value: "$year+1",
57
- label: "superdate:next.$year"
58
- }];
59
- var schema = yup.object({
60
- rel: yup.object({
61
- diff: yup.number().required().label("Difference"),
62
- op: yup.string().required().oneOf(["+", "-"]).label("Operator"),
63
- part: yup.string().required().oneOf(Object.values(DatePart)).label("Date part")
64
- })
65
- });
66
- var QuickSelect = function QuickSelect(_ref) {
67
- var _ref$presets = _ref.presets,
68
- presets = _ref$presets === void 0 ? DEFAULT_PRESETS : _ref$presets,
69
- _ref$value = _ref.value,
70
- value = _ref$value === void 0 ? "" : _ref$value,
71
- onChange = _ref.onChange;
72
- var _useTranslation = useTranslation(),
73
- t = _useTranslation.t;
74
- var handleChange = useCallback(function (_ref2) {
75
- var _ref2$rel = _ref2.rel,
76
- part = _ref2$rel.part,
77
- diff = _ref2$rel.diff,
78
- op = _ref2$rel.op;
79
- onChange("".concat(part).concat(op).concat(diff, "|").concat(DatePart.NOW));
80
- }, []);
81
- var defaultValue = useMemo(function () {
82
- if (value !== null && value !== void 0 && value.endsWith(DatePart.NOW)) {
83
- var _value$split$shift$ma;
84
- var _ref3 = (_value$split$shift$ma = value.split("|").shift().match(/^(\$\w+)([+-])(\d+)?$/)) !== null && _value$split$shift$ma !== void 0 ? _value$split$shift$ma : [],
85
- _ref4 = _slicedToArray(_ref3, 4),
86
- part = _ref4[1],
87
- op = _ref4[2],
88
- _ref4$ = _ref4[3],
89
- diff = _ref4$ === void 0 ? "0" : _ref4$;
90
- return {
91
- rel: {
92
- part: part,
93
- op: op,
94
- diff: diff
95
- }
96
- };
97
- }
98
- }, [value]);
99
- return /*#__PURE__*/jsxs(Content, {
100
- children: [/*#__PURE__*/jsx("div", {
101
- className: "inline-block origin-left rtl:origin-right",
102
- style: {
103
- zoom: 0.85
104
- },
105
- children: /*#__PURE__*/jsx(Form, {
106
- schema: schema,
107
- onSubmit: handleChange,
108
- defaultValues: defaultValue,
109
- children: /*#__PURE__*/jsx(RelativeInput, {
110
- label: t("superdate:label.relative"),
111
- prefix: "rel",
112
- showApply: true
113
- })
114
- })
115
- }), /*#__PURE__*/jsx(Divider, {
116
- children: t("superdate:label.preset")
117
- }), /*#__PURE__*/jsx("div", {
118
- className: "grid grid-cols-3 flex-row text-sm gap-2",
119
- children: presets.map(function (pr) {
120
- return /*#__PURE__*/jsx("button", {
121
- className: "link appearance-none text-start",
122
- onClick: function onClick() {
123
- return onChange === null || onChange === void 0 ? void 0 : onChange(pr.value);
124
- },
125
- children: t(pr.label, {
126
- defaultValue: pr.label
127
- })
128
- }, pr.value);
129
- })
130
- })]
131
- });
132
- };
133
-
134
- export { QuickSelect };