@react-fabric/date 1.0.0-beta.6 → 1.0.0-beta.60

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 (110) 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/DateHeader.js +16 -8
  5. package/dist/cjs/components/DatePage.js +2 -3
  6. package/dist/cjs/components/TimeSliders.js +5 -6
  7. package/dist/cjs/display/DateDisplay.js +24 -2
  8. package/dist/cjs/display/DateDuration.js +143 -0
  9. package/dist/cjs/hijri/DateConverter.js +154 -0
  10. package/dist/cjs/hijri/FormatDate.js +116 -0
  11. package/dist/cjs/hijri/HijriDate.js +531 -0
  12. package/dist/cjs/hijri/StringDateParser.js +74 -0
  13. package/dist/cjs/hijri/index.js +17 -1025
  14. package/dist/cjs/hijri/initializer.js +113 -0
  15. package/dist/cjs/hijri/locales.js +19 -0
  16. package/dist/cjs/hijri/safe.js +17 -0
  17. package/dist/cjs/i18n/ar.json.js +191 -3
  18. package/dist/cjs/i18n/en.json.js +63 -1
  19. package/dist/cjs/i18n/index.js +0 -6
  20. package/dist/cjs/index.js +13 -2
  21. package/dist/cjs/panels/DatePanel.js +26 -0
  22. package/dist/cjs/{superdate → panels}/EventPanel.js +2 -1
  23. package/dist/cjs/panels/RangePanel.js +23 -0
  24. package/dist/cjs/utils/dateUtil.js +1 -4
  25. package/dist/esm/components/DateHeader.js +16 -8
  26. package/dist/esm/components/DatePage.js +2 -3
  27. package/dist/esm/components/TimeSliders.js +5 -6
  28. package/dist/esm/display/DateDisplay.js +24 -2
  29. package/dist/esm/display/DateDuration.js +143 -0
  30. package/dist/esm/hijri/DateConverter.js +152 -0
  31. package/dist/esm/hijri/FormatDate.js +113 -0
  32. package/dist/esm/hijri/HijriDate.js +528 -0
  33. package/dist/esm/hijri/StringDateParser.js +74 -0
  34. package/dist/esm/hijri/index.js +17 -1025
  35. package/dist/esm/hijri/initializer.js +113 -0
  36. package/dist/esm/hijri/locales.js +18 -0
  37. package/dist/esm/hijri/safe.js +14 -0
  38. package/dist/esm/i18n/ar.json.js +191 -3
  39. package/dist/esm/i18n/en.json.js +63 -2
  40. package/dist/esm/i18n/index.js +0 -6
  41. package/dist/esm/index.js +6 -1
  42. package/dist/esm/panels/DatePanel.js +26 -0
  43. package/dist/esm/{superdate → panels}/EventPanel.js +2 -1
  44. package/dist/esm/panels/RangePanel.js +23 -0
  45. package/dist/esm/utils/dateUtil.js +1 -4
  46. package/dist/types/display/DateDisplay.d.ts +21 -3
  47. package/dist/types/display/DateDuration.d.ts +31 -0
  48. package/dist/types/hijri/DateConverter.d.ts +13 -0
  49. package/dist/types/hijri/FormatDate.d.ts +19 -0
  50. package/dist/types/hijri/HijriDate.d.ts +214 -0
  51. package/dist/types/hijri/StringDateParser.d.ts +11 -0
  52. package/dist/types/hijri/index.d.ts +2 -2
  53. package/dist/types/hijri/initializer.d.ts +129 -0
  54. package/dist/types/hijri/locales.d.ts +19 -0
  55. package/dist/types/hijri/safe.d.ts +3 -0
  56. package/dist/types/index.d.ts +6 -1
  57. package/dist/types/panels/DatePanel.d.ts +26 -0
  58. package/dist/types/panels/EventPanel.d.ts +17 -0
  59. package/dist/types/panels/RangePanel.d.ts +22 -0
  60. package/dist/types/types/index.d.ts +8 -40
  61. package/package.json +13 -16
  62. package/src/components/DateHeader.tsx +4 -8
  63. package/src/components/DatePage.tsx +2 -3
  64. package/src/components/TimeSliders.tsx +5 -6
  65. package/src/display/DateDisplay.tsx +32 -4
  66. package/src/display/DateDuration.tsx +180 -0
  67. package/src/hijri/DateConverter.js +175 -0
  68. package/src/hijri/FormatDate.js +134 -0
  69. package/src/hijri/HijriDate.js +477 -0
  70. package/src/hijri/StringDateParser.js +68 -0
  71. package/src/hijri/index.js +16 -1535
  72. package/src/hijri/initializer.js +96 -0
  73. package/src/hijri/locales.js +109 -0
  74. package/src/hijri/safe.js +16 -0
  75. package/src/i18n/ar.json +190 -1
  76. package/src/i18n/en.json +60 -0
  77. package/src/i18n/index.ts +0 -3
  78. package/src/index.ts +7 -1
  79. package/src/panels/DatePanel.tsx +26 -0
  80. package/src/{superdate → panels}/EventPanel.tsx +21 -3
  81. package/src/panels/RangePanel.tsx +23 -0
  82. package/src/types/index.ts +8 -43
  83. package/src/utils/dateUtil.ts +1 -5
  84. package/dist/cjs/components/Date.module.css +0 -1
  85. package/dist/cjs/i18n/superdate/ar.json.js +0 -86
  86. package/dist/cjs/i18n/superdate/en.json.js +0 -93
  87. package/dist/cjs/superdate/QuickSelect.js +0 -134
  88. package/dist/cjs/superdate/RelativeInput.js +0 -79
  89. package/dist/cjs/superdate/RelativePanel.js +0 -91
  90. package/dist/cjs/superdate/SuperDate.module.css +0 -1
  91. package/dist/cjs/superdate/Superdate.js +0 -177
  92. package/dist/esm/components/Date.module.css +0 -1
  93. package/dist/esm/i18n/superdate/ar.json.js +0 -79
  94. package/dist/esm/i18n/superdate/en.json.js +0 -85
  95. package/dist/esm/superdate/QuickSelect.js +0 -134
  96. package/dist/esm/superdate/RelativeInput.js +0 -79
  97. package/dist/esm/superdate/RelativePanel.js +0 -91
  98. package/dist/esm/superdate/SuperDate.module.css +0 -1
  99. package/dist/esm/superdate/Superdate.js +0 -176
  100. package/dist/types/superdate/EventPanel.d.ts +0 -4
  101. package/dist/types/superdate/QuickSelect.d.ts +0 -1
  102. package/dist/types/superdate/RelativeInput.d.ts +0 -1
  103. package/dist/types/superdate/RelativePanel.d.ts +0 -1
  104. package/dist/types/superdate/Superdate.d.ts +0 -17
  105. package/src/i18n/superdate/ar.json +0 -70
  106. package/src/i18n/superdate/en.json +0 -75
  107. package/src/superdate/QuickSelect.tsx +0 -121
  108. package/src/superdate/RelativeInput.tsx +0 -64
  109. package/src/superdate/RelativePanel.tsx +0 -103
  110. package/src/superdate/Superdate.tsx +0 -198
@@ -22,7 +22,6 @@
22
22
  */
23
23
 
24
24
  import {
25
- type ColorType,
26
25
  type CssProp,
27
26
  type TestProps,
28
27
  } from "@react-fabric/core/dist/types/types";
@@ -63,6 +62,14 @@ format?:
63
62
  | string;
64
63
  */
65
64
 
65
+ export interface EventType<D = DateLike> {
66
+ label: string;
67
+ icon?: string;
68
+ start: D;
69
+ end: D;
70
+ hijri?: boolean;
71
+ }
72
+
66
73
  export interface BaseProps {
67
74
  min?: DateLike;
68
75
  max?: DateLike;
@@ -82,45 +89,3 @@ export interface RangeProps extends BaseProps, CssProp, TestProps {
82
89
  onChange?: (dates: [start: string, end: string]) => void;
83
90
  presets?: Record<string, [DateLike, DateLike]>;
84
91
  }
85
-
86
- export interface EventType<D = DateLike> {
87
- label: string;
88
- icon?: string;
89
- start: D;
90
- end: D;
91
- hijri?: boolean;
92
- }
93
-
94
- export interface PresetType {
95
- value: string;
96
- label: string;
97
- }
98
-
99
- export interface SuperDateProps extends TestProps {
100
- as?: "button" | "chip";
101
- color?: ColorType;
102
- variant?: "solid" | "outline" | "link";
103
- disabled?: boolean;
104
- /**
105
- * relative date value
106
- */
107
- value?: string;
108
- /**
109
- * change handler
110
- */
111
- onChange?: (value: string, dates: [string, string]) => void;
112
- /**
113
- * list of calendar events
114
- */
115
- events?: EventType[];
116
- /**
117
- * list of calendar events
118
- */
119
- recurringEvents?: EventType[];
120
- /**
121
- * list of relative presets
122
- *
123
- * {value:'$year-5|$year', label:'last 5 years'}
124
- */
125
- presets?: PresetType[];
126
- }
@@ -52,7 +52,6 @@ import {
52
52
  startOfQuarter,
53
53
  } from "date-fns";
54
54
  import { DatePart, PageType, type DateLike } from "../types";
55
- // import { parseDate } from "./dateMath";
56
55
  import { isNil, isString } from "@react-fabric/utilities";
57
56
  import {
58
57
  arSA as ar,
@@ -85,7 +84,7 @@ const Locales: KeyValue = {
85
84
  zh,
86
85
  };
87
86
 
88
- // eslint-disable-next-line @typescript-eslint/no-namespace
87
+
89
88
  export namespace DateUtil {
90
89
  const translateNumber = (d: string) => {
91
90
  return d
@@ -547,6 +546,3 @@ export namespace DateUtil {
547
546
  return new Date(dt);
548
547
  };
549
548
  }
550
-
551
- // @ts-expect-error ignore
552
- window.DateUtil = DateUtil;
@@ -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,86 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var separator = " ⇽ ";
6
- var label = {
7
- quick: "حدد مسرعا",
8
- relative: "نسبيا",
9
- events: "الأحداث",
10
- absolute: "مطلق",
11
- preset: "المسبقة",
12
- current: "تيار",
13
- previous: "السابق",
14
- from: "من عند",
15
- to: "إلى",
16
- "+": "من الان",
17
- "-": "منذ",
18
- apply: "يتقدم",
19
- $now: "الآن",
20
- $minute: "دقيقة",
21
- $hour: "ساعة",
22
- $day: "يوم",
23
- $week: "أسبوع",
24
- $month: "شهر",
25
- $quarter: "ربع",
26
- $year: "عام",
27
- $decade: "عقد"
28
- };
29
- var now = {
30
- $day: "اليوم",
31
- $week: "هذا الاسبوع",
32
- $month: "هذا الشهر",
33
- $quarter: "هذا الربع",
34
- $year: "هذه السنة",
35
- $decade: "هذا العقد"
36
- };
37
- var next = {
38
- $day: "غدا",
39
- $week: "الاسبوع القادم",
40
- $month: "الشهر القادم",
41
- $quarter: "الربع القادم",
42
- $year: "العام القادم",
43
- $decade: "العقد القادم",
44
- $minute: "بعد دقيقة",
45
- $hour: "بعد ساعة",
46
- $minute_plural: "بعد {{count}} دقائق",
47
- $hour_plural: "بعد {{count}} ساعات",
48
- $day_plural: "بعد {{count}} أيام",
49
- $week_plural: "بعد {{count}} أسابيع",
50
- $month_plural: "بعد {{count}} أشهر",
51
- $quarter_plural: "بعد {{count}} أرباع",
52
- $year_plural: "بعد {{count}} سنوات",
53
- $decade_plural: "بعد {{count}} عقود"
54
- };
55
- var prev = {
56
- $day: "في الامس",
57
- $week: "الاسبوع الماضي",
58
- $month: "الشهر الماضي",
59
- $quarter: "الربع الأخير",
60
- $year: "العام الماضي",
61
- $decade: "العقد الماضي",
62
- $minute: "منذ دقيقة",
63
- $hour: "منذ ساعة",
64
- $minute_plural: "منذ {{count}} دقيقة",
65
- $hour_plural: "منذ {{count}} ساعات",
66
- $day_plural: "منذ {{count}} أيام",
67
- $week_plural: "من {{count}} اسابيع",
68
- $month_plural: "قبل {{count}} أشهر",
69
- $quarter_plural: "منذ {{count}} أرباع",
70
- $year_plural: "منذ {{count}} سنوات",
71
- $decade_plural: "منذ {{count}} عقود"
72
- };
73
- var arSuper = {
74
- separator: separator,
75
- label: label,
76
- now: now,
77
- next: next,
78
- prev: prev
79
- };
80
-
81
- exports.default = arSuper;
82
- exports.label = label;
83
- exports.next = next;
84
- exports.now = now;
85
- exports.prev = prev;
86
- exports.separator = separator;
@@ -1,93 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var separator = " ⇾ ";
6
- var event = {
7
- ramadan: "Ramadan",
8
- christmas: "Christmas",
9
- newYear: "New Year"
10
- };
11
- var label = {
12
- quick: "Quick Select",
13
- relative: "Relative",
14
- absolute: "Absolute",
15
- events: "Events",
16
- preset: "Presets",
17
- current: "Current",
18
- previous: "Previous",
19
- from: "From",
20
- to: "To",
21
- "+": "From now",
22
- "-": "Ago",
23
- apply: "Apply",
24
- $now: "Now",
25
- $minute: "Minute",
26
- $hour: "Hour",
27
- $day: "Day",
28
- $week: "Week",
29
- $month: "Month",
30
- $quarter: "Quarter",
31
- $year: "Year",
32
- $decade: "Decade"
33
- };
34
- var now = {
35
- $day: "Today",
36
- $week: "This week",
37
- $month: "This month",
38
- $quarter: "This quarter",
39
- $year: "This year",
40
- $decade: "This decade"
41
- };
42
- var next = {
43
- $day: "Tomorrow",
44
- $week: "Next week",
45
- $month: "Next month",
46
- $quarter: "Next quarter",
47
- $year: "Next year",
48
- $decade: "Next decade",
49
- $minute: "A minute later",
50
- $hour: "An hour later",
51
- $minute_other: "{{count}} minutes later",
52
- $hour_other: "{{count}} hours later",
53
- $day_other: "{{count}} days later",
54
- $week_other: "{{count}} weeks later",
55
- $month_other: "{{count}} months later",
56
- $quarter_other: "{{count}} quarters later",
57
- $year_other: "{{count}} years later",
58
- $decade_other: "{{count}} decades later"
59
- };
60
- var prev = {
61
- $day: "Yesterday",
62
- $week: "Last week",
63
- $month: "Last month",
64
- $quarter: "Last quarter",
65
- $year: "Last year",
66
- $decade: "Last decade",
67
- $minute: "A minute ago",
68
- $hour: "An hour ago",
69
- $minute_other: "{{count}} minutes ago",
70
- $hour_other: "{{count}} hours ago",
71
- $day_other: "{{count}} days ago",
72
- $week_other: "{{count}} weeks ago",
73
- $month_other: "{{count}} months ago",
74
- $quarter_other: "{{count}} quarters ago",
75
- $year_other: "{{count}} years ago",
76
- $decade_other: "{{count}} decades ago"
77
- };
78
- var enSuper = {
79
- separator: separator,
80
- event: event,
81
- label: label,
82
- now: now,
83
- next: next,
84
- prev: prev
85
- };
86
-
87
- exports.default = enSuper;
88
- exports.event = event;
89
- exports.label = label;
90
- exports.next = next;
91
- exports.now = now;
92
- exports.prev = prev;
93
- exports.separator = separator;
@@ -1,134 +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 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 = utilities.yup.object({
60
- rel: utilities.yup.object({
61
- diff: utilities.yup.number().required().label("Difference"),
62
- op: utilities.yup.string().required().oneOf(["+", "-"]).label("Operator"),
63
- part: utilities.yup.string().required().oneOf(Object.values(index.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 = reactI18next.useTranslation(),
73
- t = _useTranslation.t;
74
- var handleChange = react.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(index.DatePart.NOW));
80
- }, []);
81
- var defaultValue = react.useMemo(function () {
82
- if (value !== null && value !== void 0 && value.endsWith(index.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__*/jsxRuntime.jsxs(core.Content, {
100
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
101
- className: "inline-block origin-left rtl:origin-right",
102
- style: {
103
- zoom: 0.85
104
- },
105
- children: /*#__PURE__*/jsxRuntime.jsx(form.Form, {
106
- schema: schema,
107
- onSubmit: handleChange,
108
- defaultValues: defaultValue,
109
- children: /*#__PURE__*/jsxRuntime.jsx(RelativeInput.RelativeInput, {
110
- label: t("superdate:label.relative"),
111
- prefix: "rel",
112
- showApply: true
113
- })
114
- })
115
- }), /*#__PURE__*/jsxRuntime.jsx(core.Divider, {
116
- children: t("superdate:label.preset")
117
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
118
- className: "grid grid-cols-3 flex-row text-sm gap-2",
119
- children: presets.map(function (pr) {
120
- return /*#__PURE__*/jsxRuntime.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
- exports.QuickSelect = QuickSelect;
@@ -1,79 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('@react-fabric/core');
4
- var form = require('@react-fabric/form');
5
- var reactI18next = require('react-i18next');
6
- var index = require('../types/index.js');
7
- var jsxRuntime = require('react/jsx-runtime');
8
-
9
- /*
10
- * React Fabric
11
- * @version: 1.0.0
12
- *
13
- *
14
- * The MIT License (MIT)
15
- * Copyright (c) 2024 Adarsh Pastakia
16
- *
17
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
18
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
19
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
20
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
21
- * subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all copies or substantial
24
- * portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
27
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
- */
31
-
32
- var RelativeInput = function RelativeInput(_ref) {
33
- var label = _ref.label,
34
- prefix = _ref.prefix,
35
- showApply = _ref.showApply;
36
- var _useTranslation = reactI18next.useTranslation("superdate"),
37
- t = _useTranslation.t;
38
- return /*#__PURE__*/jsxRuntime.jsxs(form.Field, {
39
- label: label,
40
- className: "mb-2",
41
- children: [/*#__PURE__*/jsxRuntime.jsx(form.Controller, {
42
- name: "".concat(prefix, ".diff"),
43
- children: /*#__PURE__*/jsxRuntime.jsx(form.Number, {
44
- width: "5rem",
45
- min: 1,
46
- max: 99
47
- })
48
- }), /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
49
- name: "".concat(prefix, ".part"),
50
- children: /*#__PURE__*/jsxRuntime.jsx(form.Select, {
51
- width: "6rem",
52
- options: Object.values(index.DatePart).slice(1).map(function (dt) {
53
- return {
54
- id: dt,
55
- label: t("label.".concat(dt))
56
- };
57
- })
58
- })
59
- }), /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
60
- name: "".concat(prefix, ".op"),
61
- children: /*#__PURE__*/jsxRuntime.jsx(form.Select, {
62
- width: "7rem",
63
- options: [{
64
- id: "-",
65
- label: t("label.-")
66
- }, {
67
- id: "+",
68
- label: t("label.+")
69
- }]
70
- })
71
- }), showApply && /*#__PURE__*/jsxRuntime.jsx(core.Button, {
72
- variant: "solid",
73
- type: "submit",
74
- children: t("label.apply")
75
- })]
76
- });
77
- };
78
-
79
- exports.RelativeInput = RelativeInput;
@@ -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}}}