@react-fabric/date 1.0.0-beta.31 → 1.0.0-beta.33
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.
- package/README.md +2 -9
- package/dist/cjs/hijri/DateConverter.js +154 -0
- package/dist/cjs/hijri/FormatDate.js +115 -0
- package/dist/cjs/hijri/HijriDate.js +531 -0
- package/dist/cjs/hijri/StringDateParser.js +74 -0
- package/dist/cjs/hijri/index.js +17 -1025
- package/dist/cjs/hijri/initializer.js +113 -0
- package/dist/cjs/hijri/locales.js +19 -0
- package/dist/cjs/hijri/safe.js +17 -0
- package/dist/cjs/i18n/index.js +0 -6
- package/dist/cjs/index.js +11 -2
- package/dist/cjs/{superdate → panels}/EventPanel.js +1 -1
- package/dist/esm/hijri/DateConverter.js +152 -0
- package/dist/esm/hijri/FormatDate.js +112 -0
- package/dist/esm/hijri/HijriDate.js +528 -0
- package/dist/esm/hijri/StringDateParser.js +74 -0
- package/dist/esm/hijri/index.js +17 -1025
- package/dist/esm/hijri/initializer.js +113 -0
- package/dist/esm/hijri/locales.js +18 -0
- package/dist/esm/hijri/safe.js +14 -0
- package/dist/esm/i18n/index.js +0 -6
- package/dist/esm/index.js +5 -1
- package/dist/esm/{superdate → panels}/EventPanel.js +1 -1
- package/dist/types/hijri/DateConverter.d.ts +13 -0
- package/dist/types/hijri/FormatDate.d.ts +19 -0
- package/dist/types/hijri/HijriDate.d.ts +214 -0
- package/dist/types/hijri/StringDateParser.d.ts +11 -0
- package/dist/types/hijri/index.d.ts +2 -2
- package/dist/types/hijri/initializer.d.ts +129 -0
- package/dist/types/hijri/locales.d.ts +19 -0
- package/dist/types/hijri/safe.d.ts +3 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/panels/EventPanel.d.ts +17 -0
- package/dist/types/types/index.d.ts +8 -40
- package/package.json +4 -6
- package/src/hijri/DateConverter.js +175 -0
- package/src/hijri/FormatDate.js +132 -0
- package/src/hijri/HijriDate.js +477 -0
- package/src/hijri/StringDateParser.js +68 -0
- package/src/hijri/index.js +16 -1535
- package/src/hijri/initializer.js +96 -0
- package/src/hijri/locales.js +109 -0
- package/src/hijri/safe.js +16 -0
- package/src/i18n/index.ts +0 -3
- package/src/index.ts +6 -1
- package/src/{superdate → panels}/EventPanel.tsx +20 -3
- package/src/types/index.ts +8 -43
- package/src/utils/dateUtil.ts +0 -1
- package/dist/cjs/i18n/superdate/ar.json.js +0 -86
- package/dist/cjs/i18n/superdate/en.json.js +0 -93
- package/dist/cjs/superdate/QuickSelect.js +0 -134
- package/dist/cjs/superdate/RelativeInput.js +0 -79
- package/dist/cjs/superdate/RelativePanel.js +0 -91
- package/dist/cjs/superdate/SuperDate.module.css +0 -1
- package/dist/cjs/superdate/Superdate.js +0 -177
- package/dist/esm/i18n/superdate/ar.json.js +0 -79
- package/dist/esm/i18n/superdate/en.json.js +0 -85
- package/dist/esm/superdate/QuickSelect.js +0 -134
- package/dist/esm/superdate/RelativeInput.js +0 -79
- package/dist/esm/superdate/RelativePanel.js +0 -91
- package/dist/esm/superdate/SuperDate.module.css +0 -1
- package/dist/esm/superdate/Superdate.js +0 -176
- package/dist/types/superdate/EventPanel.d.ts +0 -4
- package/dist/types/superdate/QuickSelect.d.ts +0 -1
- package/dist/types/superdate/RelativeInput.d.ts +0 -1
- package/dist/types/superdate/RelativePanel.d.ts +0 -1
- package/dist/types/superdate/Superdate.d.ts +0 -17
- package/src/i18n/superdate/ar.json +0 -70
- package/src/i18n/superdate/en.json +0 -75
- package/src/superdate/QuickSelect.tsx +0 -121
- package/src/superdate/RelativeInput.tsx +0 -64
- package/src/superdate/RelativePanel.tsx +0 -103
- package/src/superdate/SuperDate.module.css +0 -30
- package/src/superdate/Superdate.tsx +0 -198
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Button } from '@react-fabric/core';
|
|
4
|
-
import { Field, Controller, Number, Select } from '@react-fabric/form';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import { DatePart } from '../types/index.js';
|
|
7
|
-
import { jsxs, jsx } from '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 = useTranslation("superdate"),
|
|
37
|
-
t = _useTranslation.t;
|
|
38
|
-
return /*#__PURE__*/jsxs(Field, {
|
|
39
|
-
label: label,
|
|
40
|
-
className: "mb-2",
|
|
41
|
-
children: [/*#__PURE__*/jsx(Controller, {
|
|
42
|
-
name: "".concat(prefix, ".diff"),
|
|
43
|
-
children: /*#__PURE__*/jsx(Number, {
|
|
44
|
-
width: "5rem",
|
|
45
|
-
min: 1,
|
|
46
|
-
max: 99
|
|
47
|
-
})
|
|
48
|
-
}), /*#__PURE__*/jsx(Controller, {
|
|
49
|
-
name: "".concat(prefix, ".part"),
|
|
50
|
-
children: /*#__PURE__*/jsx(Select, {
|
|
51
|
-
width: "6rem",
|
|
52
|
-
options: Object.values(DatePart).slice(1).map(function (dt) {
|
|
53
|
-
return {
|
|
54
|
-
id: dt,
|
|
55
|
-
label: t("label.".concat(dt))
|
|
56
|
-
};
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
}), /*#__PURE__*/jsx(Controller, {
|
|
60
|
-
name: "".concat(prefix, ".op"),
|
|
61
|
-
children: /*#__PURE__*/jsx(Select, {
|
|
62
|
-
width: "7rem",
|
|
63
|
-
options: [{
|
|
64
|
-
id: "-",
|
|
65
|
-
label: t("label.-")
|
|
66
|
-
}, {
|
|
67
|
-
id: "+",
|
|
68
|
-
label: t("label.+")
|
|
69
|
-
}]
|
|
70
|
-
})
|
|
71
|
-
}), showApply && /*#__PURE__*/jsx(Button, {
|
|
72
|
-
variant: "solid",
|
|
73
|
-
type: "submit",
|
|
74
|
-
children: t("label.apply")
|
|
75
|
-
})]
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export { RelativeInput };
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
-
import { Content, Button } 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 { jsx, jsxs } from 'react/jsx-runtime';
|
|
12
|
-
|
|
13
|
-
var schema = yup.object({
|
|
14
|
-
from: yup.object({
|
|
15
|
-
diff: yup.number().required().label("Difference"),
|
|
16
|
-
op: yup.string().required().oneOf(["+", "-"]).label("Operator"),
|
|
17
|
-
part: yup.string().required().oneOf(Object.values(DatePart)).label("Date part")
|
|
18
|
-
}),
|
|
19
|
-
to: yup.object({
|
|
20
|
-
diff: yup.number().required().label("Difference"),
|
|
21
|
-
op: yup.string().required().oneOf(["+", "-"]).label("Operator"),
|
|
22
|
-
part: yup.string().required().oneOf(Object.values(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 = useTranslation("superdate"),
|
|
30
|
-
t = _useTranslation.t;
|
|
31
|
-
var handleChange = 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 = 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__*/jsx(Content, {
|
|
66
|
-
children: /*#__PURE__*/jsx("div", {
|
|
67
|
-
className: "scale-90",
|
|
68
|
-
children: /*#__PURE__*/jsxs(Form, {
|
|
69
|
-
schema: schema,
|
|
70
|
-
defaultValues: defaultValue,
|
|
71
|
-
onSubmit: handleChange,
|
|
72
|
-
children: [/*#__PURE__*/jsx(RelativeInput, {
|
|
73
|
-
label: t("label.from"),
|
|
74
|
-
prefix: "from"
|
|
75
|
-
}), /*#__PURE__*/jsx(RelativeInput, {
|
|
76
|
-
label: t("label.to"),
|
|
77
|
-
prefix: "to"
|
|
78
|
-
}), /*#__PURE__*/jsx("div", {
|
|
79
|
-
className: "flex justify-end",
|
|
80
|
-
children: /*#__PURE__*/jsx(Button, {
|
|
81
|
-
variant: "solid",
|
|
82
|
-
type: "submit",
|
|
83
|
-
children: t("label.apply")
|
|
84
|
-
})
|
|
85
|
-
})]
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export { RelativePanel };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@layer comp{.superDate{&:root{font-size:10px}}}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
6
|
-
import { useFloatingTree } from '@floating-ui/react';
|
|
7
|
-
import { useGlobals, Dropdown, Tooltip, CoreIcons, TabPanel, Tab, Content, Button, Chip } from '@react-fabric/core';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import { useMemo, useState, useEffect, useCallback } from 'react';
|
|
10
|
-
import { useTranslation } from 'react-i18next';
|
|
11
|
-
import { RangePanel } from '../panels/RangePanel.js';
|
|
12
|
-
import { DateUtil } from '../utils/dateUtil.js';
|
|
13
|
-
import { EventPanel } from './EventPanel.js';
|
|
14
|
-
import { QuickSelect } from './QuickSelect.js';
|
|
15
|
-
import { RelativePanel } from './RelativePanel.js';
|
|
16
|
-
import classes from './SuperDate.module.css';
|
|
17
|
-
import { jsxs, jsx } from '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 = useTranslation("superdate"),
|
|
29
|
-
t = _useTranslation.t;
|
|
30
|
-
var tree = useFloatingTree();
|
|
31
|
-
var _useGlobals = useGlobals(),
|
|
32
|
-
currentCalendar = _useGlobals.currentCalendar,
|
|
33
|
-
currentLocale = _useGlobals.currentLocale;
|
|
34
|
-
var isHijri = useMemo(function () {
|
|
35
|
-
return currentCalendar === "hijri";
|
|
36
|
-
}, [currentCalendar]);
|
|
37
|
-
var _useState = useState(""),
|
|
38
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
-
currentValue = _useState2[0],
|
|
40
|
-
setCurrentValue = _useState2[1];
|
|
41
|
-
var _useState3 = useState("quick"),
|
|
42
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
|
-
activeTab = _useState4[0],
|
|
44
|
-
setActiveTab = _useState4[1];
|
|
45
|
-
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 = useCallback(function (value) {
|
|
50
|
-
var _parsed$, _parsed$$toISOString, _parsed$2, _parsed$2$toISOString;
|
|
51
|
-
var parsed = 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__*/jsx("div", {
|
|
57
|
-
className: classNames("rounded-capped outline select-none overflow-hidden grid", classes.superDate),
|
|
58
|
-
children: /*#__PURE__*/jsxs(TabPanel, {
|
|
59
|
-
headerClassName: "border-b",
|
|
60
|
-
onChange: setActiveTab,
|
|
61
|
-
activeTab: activeTab,
|
|
62
|
-
children: [/*#__PURE__*/jsx(Tab, {
|
|
63
|
-
id: "quick",
|
|
64
|
-
label: t("label.quick"),
|
|
65
|
-
children: /*#__PURE__*/jsx(QuickSelect, {
|
|
66
|
-
value: currentValue,
|
|
67
|
-
onChange: handleChange,
|
|
68
|
-
presets: presets
|
|
69
|
-
})
|
|
70
|
-
}), /*#__PURE__*/jsx(Tab, {
|
|
71
|
-
id: "relative",
|
|
72
|
-
label: t("label.relative"),
|
|
73
|
-
children: /*#__PURE__*/jsx(RelativePanel, {
|
|
74
|
-
value: currentValue,
|
|
75
|
-
onChange: handleChange
|
|
76
|
-
})
|
|
77
|
-
}), /*#__PURE__*/jsx(Tab, {
|
|
78
|
-
id: "absolute",
|
|
79
|
-
label: t("label.absolute"),
|
|
80
|
-
children: /*#__PURE__*/jsx(Content, {
|
|
81
|
-
className: "p-0",
|
|
82
|
-
children: /*#__PURE__*/jsx(RangePanel, {
|
|
83
|
-
withTime: true,
|
|
84
|
-
showHijriToggle: true,
|
|
85
|
-
value: currentValue ? 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__*/jsx(Tab, {
|
|
96
|
-
id: "events",
|
|
97
|
-
label: t("label.events"),
|
|
98
|
-
children: /*#__PURE__*/jsx(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 = useGlobals(),
|
|
137
|
-
currentCalendar = _useGlobals2.currentCalendar,
|
|
138
|
-
currentLocale = _useGlobals2.currentLocale;
|
|
139
|
-
var isHijri = useMemo(function () {
|
|
140
|
-
return currentCalendar === "hijri";
|
|
141
|
-
}, [currentCalendar]);
|
|
142
|
-
var _useState5 = useState(),
|
|
143
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
144
|
-
relValue = _useState6[0],
|
|
145
|
-
setRelative = _useState6[1];
|
|
146
|
-
useEffect(function () {
|
|
147
|
-
setRelative(value);
|
|
148
|
-
}, [value]);
|
|
149
|
-
var handleChange = useCallback(function (value) {
|
|
150
|
-
var _parsed$3, _parsed$3$toISOString, _parsed$4, _parsed$4$toISOString;
|
|
151
|
-
var parsed = 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" ? Button : Chip;
|
|
156
|
-
return /*#__PURE__*/jsxs(Dropdown, {
|
|
157
|
-
showArrow: true,
|
|
158
|
-
children: [/*#__PURE__*/jsx(Tooltip, {
|
|
159
|
-
content: DateUtil.relativeTooltip(relValue, isHijri),
|
|
160
|
-
children: /*#__PURE__*/jsx(E, {
|
|
161
|
-
icon: 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.relativeLabel(relValue, isHijri)) !== null && _DateUtil$relativeLab !== void 0 ? _DateUtil$relativeLab : ""
|
|
168
|
-
})
|
|
169
|
-
}), /*#__PURE__*/jsx(SuperDateTabs, _objectSpread(_objectSpread({}, props), {}, {
|
|
170
|
-
value: relValue,
|
|
171
|
-
onChange: handleChange
|
|
172
|
-
}))]
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export { SuperDate, SuperDateTabs };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const QuickSelect: ({ presets, value, onChange, }: KeyValue) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const RelativeInput: ({ label, prefix, showApply }: KeyValue) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const RelativePanel: ({ value, onChange }: KeyValue) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type SuperDateProps } from "../types";
|
|
2
|
-
export declare const SuperDateTabs: ({ events, value, presets, recurringEvents, onChange, }: SuperDateProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
/**
|
|
4
|
-
* Superdate panel provides ability to select relative and absolute dates
|
|
5
|
-
*
|
|
6
|
-
* Relative dates parts
|
|
7
|
-
* `$now`,
|
|
8
|
-
* `$minute`,
|
|
9
|
-
* `$hour`,
|
|
10
|
-
* `$day`,
|
|
11
|
-
* `$week`,
|
|
12
|
-
* `$month`,
|
|
13
|
-
* `$quarter`,
|
|
14
|
-
* `$year`,
|
|
15
|
-
* `$decade`
|
|
16
|
-
*/
|
|
17
|
-
export declare const SuperDate: ({ as, color, variant, disabled, onChange, value, "data-test-value": testValue, "data-testid": testId, ...props }: SuperDateProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"separator": " ⇽ ",
|
|
3
|
-
"label": {
|
|
4
|
-
"quick": "حدد مسرعا",
|
|
5
|
-
"relative": "نسبيا",
|
|
6
|
-
"events": "الأحداث",
|
|
7
|
-
"absolute": "مطلق",
|
|
8
|
-
"preset": "المسبقة",
|
|
9
|
-
"current": "تيار",
|
|
10
|
-
"previous": "السابق",
|
|
11
|
-
"from": "من عند",
|
|
12
|
-
"to": "إلى",
|
|
13
|
-
"+": "من الان",
|
|
14
|
-
"-": "منذ",
|
|
15
|
-
"apply": "يتقدم",
|
|
16
|
-
"$now": "الآن",
|
|
17
|
-
"$minute": "دقيقة",
|
|
18
|
-
"$hour": "ساعة",
|
|
19
|
-
"$day": "يوم",
|
|
20
|
-
"$week": "أسبوع",
|
|
21
|
-
"$month": "شهر",
|
|
22
|
-
"$quarter": "ربع",
|
|
23
|
-
"$year": "عام",
|
|
24
|
-
"$decade": "عقد"
|
|
25
|
-
},
|
|
26
|
-
"now": {
|
|
27
|
-
"$day": "اليوم",
|
|
28
|
-
"$week": "هذا الاسبوع",
|
|
29
|
-
"$month": "هذا الشهر",
|
|
30
|
-
"$quarter": "هذا الربع",
|
|
31
|
-
"$year": "هذه السنة",
|
|
32
|
-
"$decade": "هذا العقد"
|
|
33
|
-
},
|
|
34
|
-
"next": {
|
|
35
|
-
"$day": "غدا",
|
|
36
|
-
"$week": "الاسبوع القادم",
|
|
37
|
-
"$month": "الشهر القادم",
|
|
38
|
-
"$quarter": "الربع القادم",
|
|
39
|
-
"$year": "العام القادم",
|
|
40
|
-
"$decade": "العقد القادم",
|
|
41
|
-
"$minute": "بعد دقيقة",
|
|
42
|
-
"$hour": "بعد ساعة",
|
|
43
|
-
"$minute_plural": "بعد {{count}} دقائق",
|
|
44
|
-
"$hour_plural": "بعد {{count}} ساعات",
|
|
45
|
-
"$day_plural": "بعد {{count}} أيام",
|
|
46
|
-
"$week_plural": "بعد {{count}} أسابيع",
|
|
47
|
-
"$month_plural": "بعد {{count}} أشهر",
|
|
48
|
-
"$quarter_plural": "بعد {{count}} أرباع",
|
|
49
|
-
"$year_plural": "بعد {{count}} سنوات",
|
|
50
|
-
"$decade_plural": "بعد {{count}} عقود"
|
|
51
|
-
},
|
|
52
|
-
"prev": {
|
|
53
|
-
"$day": "في الامس",
|
|
54
|
-
"$week": "الاسبوع الماضي",
|
|
55
|
-
"$month": "الشهر الماضي",
|
|
56
|
-
"$quarter": "الربع الأخير",
|
|
57
|
-
"$year": "العام الماضي",
|
|
58
|
-
"$decade": "العقد الماضي",
|
|
59
|
-
"$minute": "منذ دقيقة",
|
|
60
|
-
"$hour": "منذ ساعة",
|
|
61
|
-
"$minute_plural": "منذ {{count}} دقيقة",
|
|
62
|
-
"$hour_plural": "منذ {{count}} ساعات",
|
|
63
|
-
"$day_plural": "منذ {{count}} أيام",
|
|
64
|
-
"$week_plural": "من {{count}} اسابيع",
|
|
65
|
-
"$month_plural": "قبل {{count}} أشهر",
|
|
66
|
-
"$quarter_plural": "منذ {{count}} أرباع",
|
|
67
|
-
"$year_plural": "منذ {{count}} سنوات",
|
|
68
|
-
"$decade_plural": "منذ {{count}} عقود"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"separator": " ⇾ ",
|
|
3
|
-
"event": {
|
|
4
|
-
"ramadan": "Ramadan",
|
|
5
|
-
"christmas": "Christmas",
|
|
6
|
-
"newYear": "New Year"
|
|
7
|
-
},
|
|
8
|
-
"label": {
|
|
9
|
-
"quick": "Quick Select",
|
|
10
|
-
"relative": "Relative",
|
|
11
|
-
"absolute": "Absolute",
|
|
12
|
-
"events": "Events",
|
|
13
|
-
"preset": "Presets",
|
|
14
|
-
"current": "Current",
|
|
15
|
-
"previous": "Previous",
|
|
16
|
-
"from": "From",
|
|
17
|
-
"to": "To",
|
|
18
|
-
"+": "From now",
|
|
19
|
-
"-": "Ago",
|
|
20
|
-
"apply": "Apply",
|
|
21
|
-
"$now": "Now",
|
|
22
|
-
"$minute": "Minute",
|
|
23
|
-
"$hour": "Hour",
|
|
24
|
-
"$day": "Day",
|
|
25
|
-
"$week": "Week",
|
|
26
|
-
"$month": "Month",
|
|
27
|
-
"$quarter": "Quarter",
|
|
28
|
-
"$year": "Year",
|
|
29
|
-
"$decade": "Decade"
|
|
30
|
-
},
|
|
31
|
-
"now": {
|
|
32
|
-
"$day": "Today",
|
|
33
|
-
"$week": "This week",
|
|
34
|
-
"$month": "This month",
|
|
35
|
-
"$quarter": "This quarter",
|
|
36
|
-
"$year": "This year",
|
|
37
|
-
"$decade": "This decade"
|
|
38
|
-
},
|
|
39
|
-
"next": {
|
|
40
|
-
"$day": "Tomorrow",
|
|
41
|
-
"$week": "Next week",
|
|
42
|
-
"$month": "Next month",
|
|
43
|
-
"$quarter": "Next quarter",
|
|
44
|
-
"$year": "Next year",
|
|
45
|
-
"$decade": "Next decade",
|
|
46
|
-
"$minute": "A minute later",
|
|
47
|
-
"$hour": "An hour later",
|
|
48
|
-
"$minute_other": "{{count}} minutes later",
|
|
49
|
-
"$hour_other": "{{count}} hours later",
|
|
50
|
-
"$day_other": "{{count}} days later",
|
|
51
|
-
"$week_other": "{{count}} weeks later",
|
|
52
|
-
"$month_other": "{{count}} months later",
|
|
53
|
-
"$quarter_other": "{{count}} quarters later",
|
|
54
|
-
"$year_other": "{{count}} years later",
|
|
55
|
-
"$decade_other": "{{count}} decades later"
|
|
56
|
-
},
|
|
57
|
-
"prev": {
|
|
58
|
-
"$day": "Yesterday",
|
|
59
|
-
"$week": "Last week",
|
|
60
|
-
"$month": "Last month",
|
|
61
|
-
"$quarter": "Last quarter",
|
|
62
|
-
"$year": "Last year",
|
|
63
|
-
"$decade": "Last decade",
|
|
64
|
-
"$minute": "A minute ago",
|
|
65
|
-
"$hour": "An hour ago",
|
|
66
|
-
"$minute_other": "{{count}} minutes ago",
|
|
67
|
-
"$hour_other": "{{count}} hours ago",
|
|
68
|
-
"$day_other": "{{count}} days ago",
|
|
69
|
-
"$week_other": "{{count}} weeks ago",
|
|
70
|
-
"$month_other": "{{count}} months ago",
|
|
71
|
-
"$quarter_other": "{{count}} quarters ago",
|
|
72
|
-
"$year_other": "{{count}} years ago",
|
|
73
|
-
"$decade_other": "{{count}} decades ago"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { Content, Divider } from "@react-fabric/core";
|
|
25
|
-
import { Form } from "@react-fabric/form";
|
|
26
|
-
import { yup } from "@react-fabric/utilities";
|
|
27
|
-
import { useCallback, useMemo } from "react";
|
|
28
|
-
import { useTranslation } from "react-i18next";
|
|
29
|
-
import { DatePart } from "../types";
|
|
30
|
-
import { RelativeInput } from "./RelativeInput";
|
|
31
|
-
|
|
32
|
-
const DEFAULT_PRESETS = [
|
|
33
|
-
{ value: "$day", label: "superdate:now.$day" },
|
|
34
|
-
{ value: "$day-1", label: "superdate:prev.$day" },
|
|
35
|
-
{ value: "$day+1", label: "superdate:next.$day" },
|
|
36
|
-
{ value: "$week", label: "superdate:now.$week" },
|
|
37
|
-
{ value: "$week-1", label: "superdate:prev.$week" },
|
|
38
|
-
{ value: "$week+1", label: "superdate:next.$week" },
|
|
39
|
-
{ value: "$month", label: "superdate:now.$month" },
|
|
40
|
-
{ value: "$month-1", label: "superdate:prev.$month" },
|
|
41
|
-
{ value: "$month+1", label: "superdate:next.$month" },
|
|
42
|
-
{ value: "$quarter", label: "superdate:now.$quarter" },
|
|
43
|
-
{ value: "$quarter-1", label: "superdate:prev.$quarter" },
|
|
44
|
-
{ value: "$quarter+1", label: "superdate:next.$quarter" },
|
|
45
|
-
{ value: "$year", label: "superdate:now.$year" },
|
|
46
|
-
{ value: "$year-1", label: "superdate:prev.$year" },
|
|
47
|
-
{ value: "$year+1", label: "superdate:next.$year" },
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
const schema = yup.object({
|
|
51
|
-
rel: yup.object({
|
|
52
|
-
diff: yup.number().required().label("Difference"),
|
|
53
|
-
op: yup.string().required().oneOf(["+", "-"]).label("Operator"),
|
|
54
|
-
part: yup
|
|
55
|
-
.string()
|
|
56
|
-
.required()
|
|
57
|
-
.oneOf(Object.values(DatePart))
|
|
58
|
-
.label("Date part"),
|
|
59
|
-
}),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export const QuickSelect = ({
|
|
63
|
-
presets = DEFAULT_PRESETS,
|
|
64
|
-
value = "",
|
|
65
|
-
onChange,
|
|
66
|
-
}: KeyValue) => {
|
|
67
|
-
const { t } = useTranslation();
|
|
68
|
-
|
|
69
|
-
const handleChange = useCallback(
|
|
70
|
-
({ rel: { part, diff, op } }: yup.InferType<typeof schema>) => {
|
|
71
|
-
onChange(`${part}${op}${diff}|${DatePart.NOW}`);
|
|
72
|
-
},
|
|
73
|
-
[],
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const defaultValue = useMemo(() => {
|
|
77
|
-
if (value?.endsWith(DatePart.NOW)) {
|
|
78
|
-
const [, part, op, diff = "0"] =
|
|
79
|
-
value
|
|
80
|
-
.split("|")
|
|
81
|
-
.shift()
|
|
82
|
-
.match(/^(\$\w+)([+-])(\d+)?$/) ?? [];
|
|
83
|
-
return {
|
|
84
|
-
rel: { part, op, diff },
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}, [value]);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<Content>
|
|
91
|
-
<div
|
|
92
|
-
className="inline-block origin-left rtl:origin-right"
|
|
93
|
-
style={{ zoom: 0.85 }}
|
|
94
|
-
>
|
|
95
|
-
<Form
|
|
96
|
-
schema={schema}
|
|
97
|
-
onSubmit={handleChange}
|
|
98
|
-
defaultValues={defaultValue}
|
|
99
|
-
>
|
|
100
|
-
<RelativeInput
|
|
101
|
-
label={t("superdate:label.relative")}
|
|
102
|
-
prefix="rel"
|
|
103
|
-
showApply
|
|
104
|
-
/>
|
|
105
|
-
</Form>
|
|
106
|
-
</div>
|
|
107
|
-
<Divider>{t("superdate:label.preset")}</Divider>
|
|
108
|
-
<div className="grid grid-cols-3 flex-row text-sm gap-2">
|
|
109
|
-
{presets.map((pr: KeyValue) => (
|
|
110
|
-
<button
|
|
111
|
-
key={pr.value}
|
|
112
|
-
className="link appearance-none text-start"
|
|
113
|
-
onClick={() => onChange?.(pr.value)}
|
|
114
|
-
>
|
|
115
|
-
{t(pr.label, { defaultValue: pr.label })}
|
|
116
|
-
</button>
|
|
117
|
-
))}
|
|
118
|
-
</div>
|
|
119
|
-
</Content>
|
|
120
|
-
);
|
|
121
|
-
};
|