@react-fabric/date 1.0.0-beta.51 → 1.0.0-beta.52
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/dist/cjs/display/DateDisplay.js +17 -0
- package/dist/cjs/display/DateDuration.js +16 -0
- package/dist/cjs/hijri/FormatDate.js +4 -3
- package/dist/cjs/panels/DatePanel.js +26 -0
- package/dist/cjs/panels/RangePanel.js +22 -0
- package/dist/esm/display/DateDisplay.js +17 -0
- package/dist/esm/display/DateDuration.js +16 -0
- package/dist/esm/hijri/FormatDate.js +4 -3
- package/dist/esm/panels/DatePanel.js +26 -0
- package/dist/esm/panels/RangePanel.js +22 -0
- package/dist/types/display/DateDisplay.d.ts +17 -0
- package/dist/types/display/DateDuration.d.ts +16 -0
- package/dist/types/panels/DatePanel.d.ts +26 -0
- package/dist/types/panels/RangePanel.d.ts +22 -0
- package/package.json +4 -4
- package/src/display/DateDisplay.tsx +17 -0
- package/src/display/DateDuration.tsx +16 -0
- package/src/hijri/FormatDate.js +3 -1
- package/src/panels/DatePanel.tsx +26 -0
- package/src/panels/RangePanel.tsx +22 -0
|
@@ -10,6 +10,23 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
10
10
|
var _excluded = ["date", "className", "format", "children", "showAlternateDate"];
|
|
11
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
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
|
+
/**
|
|
14
|
+
* DateDisplay component to display a formatted gregorian or hijri date with optional tooltip and dropdown.
|
|
15
|
+
* It uses the current calendar and locale from the global context.
|
|
16
|
+
* It formats the date using the provided format or a default format.
|
|
17
|
+
* If `showAlternateDate` is true, it shows a tooltip with the formatted date.
|
|
18
|
+
* If `children` are provided, it wraps the date in a dropdown.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props - The component props.
|
|
21
|
+
* @returns {JSX.Element} - The rendered component.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* <DateDisplay date={new Date()} />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
29
|
+
*/
|
|
13
30
|
var DateDisplay = function DateDisplay(_ref) {
|
|
14
31
|
var date = _ref.date,
|
|
15
32
|
className = _ref.className,
|
|
@@ -14,6 +14,22 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
14
14
|
var _excluded = ["date", "children", "className", "format"];
|
|
15
15
|
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; }
|
|
16
16
|
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; }
|
|
17
|
+
/**
|
|
18
|
+
* DateDuration component to display the duration from a given date to now.
|
|
19
|
+
* It calculates the difference in years, months, weeks, days, hours, minutes, and seconds,
|
|
20
|
+
* and displays it in a human-readable format.
|
|
21
|
+
* It uses the current locale for translations.
|
|
22
|
+
*
|
|
23
|
+
* @param {Props} props - The properties for the component.
|
|
24
|
+
* @returns {JSX.Element} The rendered component.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```jsx
|
|
28
|
+
* <DateDuration date={new Date("2020-01-01")} />
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
32
|
+
*/
|
|
17
33
|
var DateDuration = function DateDuration(_ref) {
|
|
18
34
|
var date = _ref.date,
|
|
19
35
|
children = _ref.children,
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var HijriDate = require('./HijriDate.js');
|
|
6
|
+
|
|
5
7
|
var dateFormat = function () {
|
|
6
8
|
var token = /P{1,4}|p{1,4}|d{1,2}|e{3,6}|M{1,4}|yy(?:yy)?|([Hhms])\1?|[a]{1,4}|[LloSZ]|('at')|"[^"]*"|'[^']*'/g,
|
|
7
9
|
pad = function pad(val, len) {
|
|
@@ -16,9 +18,8 @@ var dateFormat = function () {
|
|
|
16
18
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
17
19
|
utc: false
|
|
18
20
|
};
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
defaultLocale = _require$default.defaultLocale;
|
|
21
|
+
var locales = HijriDate.default.locales,
|
|
22
|
+
defaultLocale = HijriDate.default.defaultLocale;
|
|
22
23
|
options.locale = options.locale || defaultLocale;
|
|
23
24
|
if (!locales[options.locale]) {
|
|
24
25
|
throw new Error("Locale ".concat(options.locale, " is not supported yet .\n Please, try to extend \"HijriDate.locales\" :\n i.e: HijriDate.locales.").concat(options.locale, " = {dayNames:[..14 items..], monthNames:[..24 items..]}\n "));
|
|
@@ -17,6 +17,32 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
17
17
|
var _excluded = ["className", "max", "min", "dateDisabled", "onChange", "showHijriToggle", "value", "withTime"];
|
|
18
18
|
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; }
|
|
19
19
|
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; }
|
|
20
|
+
/**
|
|
21
|
+
* DatePanel component to display a date picker with options for selecting a date and time.
|
|
22
|
+
* It allows switching between Gregorian and Hijri calendars, and includes buttons for selecting today or canceling the selection.
|
|
23
|
+
* It uses the current calendar and locale from the global context.
|
|
24
|
+
* It handles date selection, time changes, and page navigation within the date picker.
|
|
25
|
+
* It also supports disabling specific dates and setting minimum and maximum date limits.
|
|
26
|
+
*
|
|
27
|
+
* @param {DateProps} props - The properties for the DatePanel component.
|
|
28
|
+
* @return {JSX.Element} The rendered DatePanel component.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```jsx
|
|
32
|
+
* <DatePanel
|
|
33
|
+
* className="my-date-panel"
|
|
34
|
+
* max="2025-12-31"
|
|
35
|
+
* min="2020-01-01"
|
|
36
|
+
* dateDisabled={["2023-01-01", "2023-12-25"]}
|
|
37
|
+
* onChange={(date) => console.log("Selected date:", date)}
|
|
38
|
+
* showHijriToggle={true}
|
|
39
|
+
* value={new Date()}
|
|
40
|
+
* withTime={true}
|
|
41
|
+
* />
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-panel--datepanels}
|
|
45
|
+
*/
|
|
20
46
|
var DatePanel = function DatePanel(_ref) {
|
|
21
47
|
var className = _ref.className,
|
|
22
48
|
max = _ref.max,
|
|
@@ -17,6 +17,28 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
17
17
|
var _excluded = ["className", "max", "min", "dateDisabled", "onChange", "showHijriToggle", "value", "withTime", "showApply"];
|
|
18
18
|
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; }
|
|
19
19
|
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; }
|
|
20
|
+
/**
|
|
21
|
+
* RangePanel component to display a date range picker with options for selecting a start and end date.
|
|
22
|
+
* It allows switching between Gregorian and Hijri calendars, and includes buttons for applying or canceling the selection.
|
|
23
|
+
* It uses the current calendar and locale from the global context.
|
|
24
|
+
* It handles date selection, time changes, and page navigation within the date picker.
|
|
25
|
+
* It also supports disabling specific dates and setting minimum and maximum date limits.
|
|
26
|
+
*
|
|
27
|
+
* @param {RangeProps} props - The properties for the RangePanel component.
|
|
28
|
+
* @return {JSX.Element} The rendered RangePanel component.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```jsx
|
|
32
|
+
* <RangePanel
|
|
33
|
+
* className="my-range-panel"
|
|
34
|
+
* max="2025-12-31"
|
|
35
|
+
* min="2020-01-01"
|
|
36
|
+
* dateDisabled={["2023-01-01", "2023-12-25"]}
|
|
37
|
+
* onChange={(dateRange) => console.log("Selected date range:", dateRange)}
|
|
38
|
+
* />
|
|
39
|
+
* ```
|
|
40
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/date-date-panel--range-panel}
|
|
41
|
+
*/
|
|
20
42
|
var RangePanel = function RangePanel(_ref) {
|
|
21
43
|
var className = _ref.className,
|
|
22
44
|
max = _ref.max,
|
|
@@ -10,6 +10,23 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
10
10
|
var _excluded = ["date", "className", "format", "children", "showAlternateDate"];
|
|
11
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
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
|
+
/**
|
|
14
|
+
* DateDisplay component to display a formatted gregorian or hijri date with optional tooltip and dropdown.
|
|
15
|
+
* It uses the current calendar and locale from the global context.
|
|
16
|
+
* It formats the date using the provided format or a default format.
|
|
17
|
+
* If `showAlternateDate` is true, it shows a tooltip with the formatted date.
|
|
18
|
+
* If `children` are provided, it wraps the date in a dropdown.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props - The component props.
|
|
21
|
+
* @returns {JSX.Element} - The rendered component.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* <DateDisplay date={new Date()} />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
29
|
+
*/
|
|
13
30
|
var DateDisplay = function DateDisplay(_ref) {
|
|
14
31
|
var date = _ref.date,
|
|
15
32
|
className = _ref.className,
|
|
@@ -14,6 +14,22 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
14
14
|
var _excluded = ["date", "children", "className", "format"];
|
|
15
15
|
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; }
|
|
16
16
|
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; }
|
|
17
|
+
/**
|
|
18
|
+
* DateDuration component to display the duration from a given date to now.
|
|
19
|
+
* It calculates the difference in years, months, weeks, days, hours, minutes, and seconds,
|
|
20
|
+
* and displays it in a human-readable format.
|
|
21
|
+
* It uses the current locale for translations.
|
|
22
|
+
*
|
|
23
|
+
* @param {Props} props - The properties for the component.
|
|
24
|
+
* @returns {JSX.Element} The rendered component.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```jsx
|
|
28
|
+
* <DateDuration date={new Date("2020-01-01")} />
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
32
|
+
*/
|
|
17
33
|
var DateDuration = function DateDuration(_ref) {
|
|
18
34
|
var date = _ref.date,
|
|
19
35
|
children = _ref.children,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import HijriDate from './HijriDate.js';
|
|
4
|
+
|
|
3
5
|
var dateFormat = function () {
|
|
4
6
|
var token = /P{1,4}|p{1,4}|d{1,2}|e{3,6}|M{1,4}|yy(?:yy)?|([Hhms])\1?|[a]{1,4}|[LloSZ]|('at')|"[^"]*"|'[^']*'/g,
|
|
5
7
|
pad = function pad(val, len) {
|
|
@@ -14,9 +16,8 @@ var dateFormat = function () {
|
|
|
14
16
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
15
17
|
utc: false
|
|
16
18
|
};
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
defaultLocale = _require$default.defaultLocale;
|
|
19
|
+
var locales = HijriDate.locales,
|
|
20
|
+
defaultLocale = HijriDate.defaultLocale;
|
|
20
21
|
options.locale = options.locale || defaultLocale;
|
|
21
22
|
if (!locales[options.locale]) {
|
|
22
23
|
throw new Error("Locale ".concat(options.locale, " is not supported yet .\n Please, try to extend \"HijriDate.locales\" :\n i.e: HijriDate.locales.").concat(options.locale, " = {dayNames:[..14 items..], monthNames:[..24 items..]}\n "));
|
|
@@ -17,6 +17,32 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
17
17
|
var _excluded = ["className", "max", "min", "dateDisabled", "onChange", "showHijriToggle", "value", "withTime"];
|
|
18
18
|
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; }
|
|
19
19
|
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; }
|
|
20
|
+
/**
|
|
21
|
+
* DatePanel component to display a date picker with options for selecting a date and time.
|
|
22
|
+
* It allows switching between Gregorian and Hijri calendars, and includes buttons for selecting today or canceling the selection.
|
|
23
|
+
* It uses the current calendar and locale from the global context.
|
|
24
|
+
* It handles date selection, time changes, and page navigation within the date picker.
|
|
25
|
+
* It also supports disabling specific dates and setting minimum and maximum date limits.
|
|
26
|
+
*
|
|
27
|
+
* @param {DateProps} props - The properties for the DatePanel component.
|
|
28
|
+
* @return {JSX.Element} The rendered DatePanel component.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```jsx
|
|
32
|
+
* <DatePanel
|
|
33
|
+
* className="my-date-panel"
|
|
34
|
+
* max="2025-12-31"
|
|
35
|
+
* min="2020-01-01"
|
|
36
|
+
* dateDisabled={["2023-01-01", "2023-12-25"]}
|
|
37
|
+
* onChange={(date) => console.log("Selected date:", date)}
|
|
38
|
+
* showHijriToggle={true}
|
|
39
|
+
* value={new Date()}
|
|
40
|
+
* withTime={true}
|
|
41
|
+
* />
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-panel--datepanels}
|
|
45
|
+
*/
|
|
20
46
|
var DatePanel = function DatePanel(_ref) {
|
|
21
47
|
var className = _ref.className,
|
|
22
48
|
max = _ref.max,
|
|
@@ -17,6 +17,28 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
17
17
|
var _excluded = ["className", "max", "min", "dateDisabled", "onChange", "showHijriToggle", "value", "withTime", "showApply"];
|
|
18
18
|
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; }
|
|
19
19
|
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; }
|
|
20
|
+
/**
|
|
21
|
+
* RangePanel component to display a date range picker with options for selecting a start and end date.
|
|
22
|
+
* It allows switching between Gregorian and Hijri calendars, and includes buttons for applying or canceling the selection.
|
|
23
|
+
* It uses the current calendar and locale from the global context.
|
|
24
|
+
* It handles date selection, time changes, and page navigation within the date picker.
|
|
25
|
+
* It also supports disabling specific dates and setting minimum and maximum date limits.
|
|
26
|
+
*
|
|
27
|
+
* @param {RangeProps} props - The properties for the RangePanel component.
|
|
28
|
+
* @return {JSX.Element} The rendered RangePanel component.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```jsx
|
|
32
|
+
* <RangePanel
|
|
33
|
+
* className="my-range-panel"
|
|
34
|
+
* max="2025-12-31"
|
|
35
|
+
* min="2020-01-01"
|
|
36
|
+
* dateDisabled={["2023-01-01", "2023-12-25"]}
|
|
37
|
+
* onChange={(dateRange) => console.log("Selected date range:", dateRange)}
|
|
38
|
+
* />
|
|
39
|
+
* ```
|
|
40
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/date-date-panel--range-panel}
|
|
41
|
+
*/
|
|
20
42
|
var RangePanel = function RangePanel(_ref) {
|
|
21
43
|
var className = _ref.className,
|
|
22
44
|
max = _ref.max,
|
|
@@ -13,4 +13,21 @@ export interface Props extends CssProp, AriaProps, TestProps, Partial<ChildrenPr
|
|
|
13
13
|
format?: string;
|
|
14
14
|
showAlternateDate?: boolean;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* DateDisplay component to display a formatted gregorian or hijri date with optional tooltip and dropdown.
|
|
18
|
+
* It uses the current calendar and locale from the global context.
|
|
19
|
+
* It formats the date using the provided format or a default format.
|
|
20
|
+
* If `showAlternateDate` is true, it shows a tooltip with the formatted date.
|
|
21
|
+
* If `children` are provided, it wraps the date in a dropdown.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} props - The component props.
|
|
24
|
+
* @returns {JSX.Element} - The rendered component.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```jsx
|
|
28
|
+
* <DateDisplay date={new Date()} />
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
32
|
+
*/
|
|
16
33
|
export declare const DateDisplay: ({ date, className, format, children, showAlternateDate, ...aria }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,4 +12,20 @@ export interface Props extends CssProp, AriaProps, TestProps, Partial<ChildrenPr
|
|
|
12
12
|
*/
|
|
13
13
|
format?: string;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* DateDuration component to display the duration from a given date to now.
|
|
17
|
+
* It calculates the difference in years, months, weeks, days, hours, minutes, and seconds,
|
|
18
|
+
* and displays it in a human-readable format.
|
|
19
|
+
* It uses the current locale for translations.
|
|
20
|
+
*
|
|
21
|
+
* @param {Props} props - The properties for the component.
|
|
22
|
+
* @returns {JSX.Element} The rendered component.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```jsx
|
|
26
|
+
* <DateDuration date={new Date("2020-01-01")} />
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
30
|
+
*/
|
|
15
31
|
export declare const DateDuration: ({ date, children, className, format, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,28 @@
|
|
|
1
1
|
import { type DateProps } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* DatePanel component to display a date picker with options for selecting a date and time.
|
|
4
|
+
* It allows switching between Gregorian and Hijri calendars, and includes buttons for selecting today or canceling the selection.
|
|
5
|
+
* It uses the current calendar and locale from the global context.
|
|
6
|
+
* It handles date selection, time changes, and page navigation within the date picker.
|
|
7
|
+
* It also supports disabling specific dates and setting minimum and maximum date limits.
|
|
8
|
+
*
|
|
9
|
+
* @param {DateProps} props - The properties for the DatePanel component.
|
|
10
|
+
* @return {JSX.Element} The rendered DatePanel component.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```jsx
|
|
14
|
+
* <DatePanel
|
|
15
|
+
* className="my-date-panel"
|
|
16
|
+
* max="2025-12-31"
|
|
17
|
+
* min="2020-01-01"
|
|
18
|
+
* dateDisabled={["2023-01-01", "2023-12-25"]}
|
|
19
|
+
* onChange={(date) => console.log("Selected date:", date)}
|
|
20
|
+
* showHijriToggle={true}
|
|
21
|
+
* value={new Date()}
|
|
22
|
+
* withTime={true}
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-panel--datepanels}
|
|
27
|
+
*/
|
|
2
28
|
export declare const DatePanel: ({ className, max, min, dateDisabled, onChange, showHijriToggle, value, withTime, ...rest }: DateProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,24 @@
|
|
|
1
1
|
import { type RangeProps } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* RangePanel component to display a date range picker with options for selecting a start and end date.
|
|
4
|
+
* It allows switching between Gregorian and Hijri calendars, and includes buttons for applying or canceling the selection.
|
|
5
|
+
* It uses the current calendar and locale from the global context.
|
|
6
|
+
* It handles date selection, time changes, and page navigation within the date picker.
|
|
7
|
+
* It also supports disabling specific dates and setting minimum and maximum date limits.
|
|
8
|
+
*
|
|
9
|
+
* @param {RangeProps} props - The properties for the RangePanel component.
|
|
10
|
+
* @return {JSX.Element} The rendered RangePanel component.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```jsx
|
|
14
|
+
* <RangePanel
|
|
15
|
+
* className="my-range-panel"
|
|
16
|
+
* max="2025-12-31"
|
|
17
|
+
* min="2020-01-01"
|
|
18
|
+
* dateDisabled={["2023-01-01", "2023-12-25"]}
|
|
19
|
+
* onChange={(dateRange) => console.log("Selected date range:", dateRange)}
|
|
20
|
+
* />
|
|
21
|
+
* ```
|
|
22
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/date-date-panel--range-panel}
|
|
23
|
+
*/
|
|
2
24
|
export declare const RangePanel: ({ className, max, min, dateDisabled, onChange, showHijriToggle, value, withTime, showApply, ...rest }: RangeProps) => import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/date",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.52",
|
|
4
4
|
"description": "RUF: Date package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
39
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
38
|
+
"@react-fabric/core": "^1.0.0-beta.52",
|
|
39
|
+
"@react-fabric/utilities": "^1.0.0-beta.52",
|
|
40
40
|
"classnames": "^2.5.1",
|
|
41
41
|
"date-fns": "^4.1.0",
|
|
42
42
|
"resize-observer-polyfill": "^1.5.1"
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"node": ">=18.12.0",
|
|
55
55
|
"npm": ">=8.19.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "0eabb9d88d91af93d657bcc209b226fd576e8260"
|
|
58
58
|
}
|
|
@@ -51,6 +51,23 @@ export interface Props
|
|
|
51
51
|
showAlternateDate?: boolean;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* DateDisplay component to display a formatted gregorian or hijri date with optional tooltip and dropdown.
|
|
56
|
+
* It uses the current calendar and locale from the global context.
|
|
57
|
+
* It formats the date using the provided format or a default format.
|
|
58
|
+
* If `showAlternateDate` is true, it shows a tooltip with the formatted date.
|
|
59
|
+
* If `children` are provided, it wraps the date in a dropdown.
|
|
60
|
+
*
|
|
61
|
+
* @param {Object} props - The component props.
|
|
62
|
+
* @returns {JSX.Element} - The rendered component.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```jsx
|
|
66
|
+
* <DateDisplay date={new Date()} />
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
70
|
+
*/
|
|
54
71
|
export const DateDisplay = ({
|
|
55
72
|
date,
|
|
56
73
|
className,
|
|
@@ -52,6 +52,22 @@ export interface Props
|
|
|
52
52
|
format?: string;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* DateDuration component to display the duration from a given date to now.
|
|
57
|
+
* It calculates the difference in years, months, weeks, days, hours, minutes, and seconds,
|
|
58
|
+
* and displays it in a human-readable format.
|
|
59
|
+
* It uses the current locale for translations.
|
|
60
|
+
*
|
|
61
|
+
* @param {Props} props - The properties for the component.
|
|
62
|
+
* @returns {JSX.Element} The rendered component.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```jsx
|
|
66
|
+
* <DateDuration date={new Date("2020-01-01")} />
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
70
|
+
*/
|
|
55
71
|
export const DateDuration = ({
|
|
56
72
|
date,
|
|
57
73
|
children,
|
package/src/hijri/FormatDate.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import HijriDate from "./HijriDate";
|
|
2
|
+
|
|
1
3
|
const dateFormat = (function () {
|
|
2
4
|
const token =
|
|
3
5
|
/P{1,4}|p{1,4}|d{1,2}|e{3,6}|M{1,4}|yy(?:yy)?|([Hhms])\1?|[a]{1,4}|[LloSZ]|('at')|"[^"]*"|'[^']*'/g,
|
|
@@ -19,7 +21,7 @@ const dateFormat = (function () {
|
|
|
19
21
|
utc: false,
|
|
20
22
|
},
|
|
21
23
|
) {
|
|
22
|
-
const { locales, defaultLocale } =
|
|
24
|
+
const { locales, defaultLocale } = HijriDate;
|
|
23
25
|
options.locale = options.locale || defaultLocale;
|
|
24
26
|
if (!locales[options.locale]) {
|
|
25
27
|
throw new Error(`Locale ${options.locale} is not supported yet .
|
package/src/panels/DatePanel.tsx
CHANGED
|
@@ -46,6 +46,32 @@ type PanelActions =
|
|
|
46
46
|
| { type: "changePage"; page: PageType }
|
|
47
47
|
| { type: "changePageDate"; date: Date; pageChange: boolean };
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* DatePanel component to display a date picker with options for selecting a date and time.
|
|
51
|
+
* It allows switching between Gregorian and Hijri calendars, and includes buttons for selecting today or canceling the selection.
|
|
52
|
+
* It uses the current calendar and locale from the global context.
|
|
53
|
+
* It handles date selection, time changes, and page navigation within the date picker.
|
|
54
|
+
* It also supports disabling specific dates and setting minimum and maximum date limits.
|
|
55
|
+
*
|
|
56
|
+
* @param {DateProps} props - The properties for the DatePanel component.
|
|
57
|
+
* @return {JSX.Element} The rendered DatePanel component.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```jsx
|
|
61
|
+
* <DatePanel
|
|
62
|
+
* className="my-date-panel"
|
|
63
|
+
* max="2025-12-31"
|
|
64
|
+
* min="2020-01-01"
|
|
65
|
+
* dateDisabled={["2023-01-01", "2023-12-25"]}
|
|
66
|
+
* onChange={(date) => console.log("Selected date:", date)}
|
|
67
|
+
* showHijriToggle={true}
|
|
68
|
+
* value={new Date()}
|
|
69
|
+
* withTime={true}
|
|
70
|
+
* />
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-panel--datepanels}
|
|
74
|
+
*/
|
|
49
75
|
export const DatePanel = ({
|
|
50
76
|
className,
|
|
51
77
|
max,
|
|
@@ -58,6 +58,28 @@ type PanelActions =
|
|
|
58
58
|
pageChange?: boolean;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* RangePanel component to display a date range picker with options for selecting a start and end date.
|
|
63
|
+
* It allows switching between Gregorian and Hijri calendars, and includes buttons for applying or canceling the selection.
|
|
64
|
+
* It uses the current calendar and locale from the global context.
|
|
65
|
+
* It handles date selection, time changes, and page navigation within the date picker.
|
|
66
|
+
* It also supports disabling specific dates and setting minimum and maximum date limits.
|
|
67
|
+
*
|
|
68
|
+
* @param {RangeProps} props - The properties for the RangePanel component.
|
|
69
|
+
* @return {JSX.Element} The rendered RangePanel component.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```jsx
|
|
73
|
+
* <RangePanel
|
|
74
|
+
* className="my-range-panel"
|
|
75
|
+
* max="2025-12-31"
|
|
76
|
+
* min="2020-01-01"
|
|
77
|
+
* dateDisabled={["2023-01-01", "2023-12-25"]}
|
|
78
|
+
* onChange={(dateRange) => console.log("Selected date range:", dateRange)}
|
|
79
|
+
* />
|
|
80
|
+
* ```
|
|
81
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/date-date-panel--range-panel}
|
|
82
|
+
*/
|
|
61
83
|
export const RangePanel = ({
|
|
62
84
|
className,
|
|
63
85
|
max,
|