@activecollab/components 2.0.212 → 2.0.214
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/components/DatePicker/DatePicker.js +678 -301
- package/dist/cjs/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/cjs/components/DatePicker/Styles.js +91 -37
- package/dist/cjs/components/DatePicker/Styles.js.map +1 -1
- package/dist/cjs/components/DatePicker/index.js +0 -11
- package/dist/cjs/components/DatePicker/index.js.map +1 -1
- package/dist/cjs/components/Display/DisplayHours.js +4 -6
- package/dist/cjs/components/Display/DisplayHours.js.map +1 -1
- package/dist/cjs/components/Display/types.js.map +1 -1
- package/dist/cjs/components/SelectDate/SelectDate.js +126 -280
- package/dist/cjs/components/SelectDate/SelectDate.js.map +1 -1
- package/dist/cjs/components/SelectDate/index.js +0 -11
- package/dist/cjs/components/SelectDate/index.js.map +1 -1
- package/dist/cjs/components/Steppers/DateStepper/DateStepper.js +94 -100
- package/dist/cjs/components/Steppers/DateStepper/DateStepper.js.map +1 -1
- package/dist/cjs/components/Steppers/DateStepper/index.js +0 -11
- package/dist/cjs/components/Steppers/DateStepper/index.js.map +1 -1
- package/dist/cjs/components/index.js +0 -11
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/utils/currencyUtils.js +1 -20
- package/dist/cjs/utils/currencyUtils.js.map +1 -1
- package/dist/cjs/utils/currencyUtils.test.js +0 -5
- package/dist/cjs/utils/currencyUtils.test.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.d.ts +64 -26
- package/dist/esm/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +619 -278
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/DatePicker/Styles.d.ts +21 -9
- package/dist/esm/components/DatePicker/Styles.d.ts.map +1 -1
- package/dist/esm/components/DatePicker/Styles.js +89 -30
- package/dist/esm/components/DatePicker/Styles.js.map +1 -1
- package/dist/esm/components/DatePicker/index.d.ts +0 -1
- package/dist/esm/components/DatePicker/index.d.ts.map +1 -1
- package/dist/esm/components/DatePicker/index.js +0 -1
- package/dist/esm/components/DatePicker/index.js.map +1 -1
- package/dist/esm/components/Display/DisplayHours.d.ts.map +1 -1
- package/dist/esm/components/Display/DisplayHours.js +4 -6
- package/dist/esm/components/Display/DisplayHours.js.map +1 -1
- package/dist/esm/components/Display/types.d.ts +1 -1
- package/dist/esm/components/Display/types.d.ts.map +1 -1
- package/dist/esm/components/Display/types.js.map +1 -1
- package/dist/esm/components/SelectDate/SelectDate.d.ts +20 -19
- package/dist/esm/components/SelectDate/SelectDate.d.ts.map +1 -1
- package/dist/esm/components/SelectDate/SelectDate.js +124 -246
- package/dist/esm/components/SelectDate/SelectDate.js.map +1 -1
- package/dist/esm/components/SelectDate/index.d.ts +0 -1
- package/dist/esm/components/SelectDate/index.d.ts.map +1 -1
- package/dist/esm/components/SelectDate/index.js +0 -1
- package/dist/esm/components/SelectDate/index.js.map +1 -1
- package/dist/esm/components/Steppers/DateStepper/DateStepper.d.ts +10 -7
- package/dist/esm/components/Steppers/DateStepper/DateStepper.d.ts.map +1 -1
- package/dist/esm/components/Steppers/DateStepper/DateStepper.js +88 -97
- package/dist/esm/components/Steppers/DateStepper/DateStepper.js.map +1 -1
- package/dist/esm/components/Steppers/DateStepper/index.d.ts +0 -1
- package/dist/esm/components/Steppers/DateStepper/index.d.ts.map +1 -1
- package/dist/esm/components/Steppers/DateStepper/index.js +0 -1
- package/dist/esm/components/Steppers/DateStepper/index.js.map +1 -1
- package/dist/esm/components/index.d.ts +0 -1
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +0 -1
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/utils/currencyUtils.d.ts +0 -1
- package/dist/esm/utils/currencyUtils.d.ts.map +1 -1
- package/dist/esm/utils/currencyUtils.js +0 -10
- package/dist/esm/utils/currencyUtils.js.map +1 -1
- package/dist/esm/utils/currencyUtils.test.js +1 -6
- package/dist/esm/utils/currencyUtils.test.js.map +1 -1
- package/dist/index.js +218 -1581
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -3
- package/dist/cjs/components/DatePicker/CustomNavBarElement.js +0 -41
- package/dist/cjs/components/DatePicker/CustomNavBarElement.js.map +0 -1
- package/dist/cjs/components/DatePicker/DatePickerV2.js +0 -734
- package/dist/cjs/components/DatePicker/DatePickerV2.js.map +0 -1
- package/dist/cjs/components/DatePicker/StylesV2.js +0 -100
- package/dist/cjs/components/DatePicker/StylesV2.js.map +0 -1
- package/dist/cjs/components/Pickers/NavBarElement.js +0 -52
- package/dist/cjs/components/Pickers/NavBarElement.js.map +0 -1
- package/dist/cjs/components/Pickers/Styles.js +0 -76
- package/dist/cjs/components/Pickers/Styles.js.map +0 -1
- package/dist/cjs/components/Pickers/YearMonthPicker.js +0 -80
- package/dist/cjs/components/Pickers/YearMonthPicker.js.map +0 -1
- package/dist/cjs/components/Pickers/index.js +0 -28
- package/dist/cjs/components/Pickers/index.js.map +0 -1
- package/dist/cjs/components/SelectDate/DatePickerForm.js +0 -94
- package/dist/cjs/components/SelectDate/DatePickerForm.js.map +0 -1
- package/dist/cjs/components/SelectDate/SelectDateV2.js +0 -263
- package/dist/cjs/components/SelectDate/SelectDateV2.js.map +0 -1
- package/dist/cjs/components/Steppers/DateStepper/DateStepperV2.js +0 -276
- package/dist/cjs/components/Steppers/DateStepper/DateStepperV2.js.map +0 -1
- package/dist/esm/components/DatePicker/CustomNavBarElement.d.ts +0 -12
- package/dist/esm/components/DatePicker/CustomNavBarElement.d.ts.map +0 -1
- package/dist/esm/components/DatePicker/CustomNavBarElement.js +0 -34
- package/dist/esm/components/DatePicker/CustomNavBarElement.js.map +0 -1
- package/dist/esm/components/DatePicker/DatePickerV2.d.ts +0 -68
- package/dist/esm/components/DatePicker/DatePickerV2.d.ts.map +0 -1
- package/dist/esm/components/DatePicker/DatePickerV2.js +0 -649
- package/dist/esm/components/DatePicker/DatePickerV2.js.map +0 -1
- package/dist/esm/components/DatePicker/StylesV2.d.ts +0 -22
- package/dist/esm/components/DatePicker/StylesV2.d.ts.map +0 -1
- package/dist/esm/components/DatePicker/StylesV2.js +0 -93
- package/dist/esm/components/DatePicker/StylesV2.js.map +0 -1
- package/dist/esm/components/Pickers/NavBarElement.d.ts +0 -9
- package/dist/esm/components/Pickers/NavBarElement.d.ts.map +0 -1
- package/dist/esm/components/Pickers/NavBarElement.js +0 -45
- package/dist/esm/components/Pickers/NavBarElement.js.map +0 -1
- package/dist/esm/components/Pickers/Styles.d.ts +0 -18
- package/dist/esm/components/Pickers/Styles.d.ts.map +0 -1
- package/dist/esm/components/Pickers/Styles.js +0 -56
- package/dist/esm/components/Pickers/Styles.js.map +0 -1
- package/dist/esm/components/Pickers/YearMonthPicker.d.ts +0 -17
- package/dist/esm/components/Pickers/YearMonthPicker.d.ts.map +0 -1
- package/dist/esm/components/Pickers/YearMonthPicker.js +0 -59
- package/dist/esm/components/Pickers/YearMonthPicker.js.map +0 -1
- package/dist/esm/components/Pickers/index.d.ts +0 -3
- package/dist/esm/components/Pickers/index.d.ts.map +0 -1
- package/dist/esm/components/Pickers/index.js +0 -3
- package/dist/esm/components/Pickers/index.js.map +0 -1
- package/dist/esm/components/SelectDate/DatePickerForm.d.ts +0 -39
- package/dist/esm/components/SelectDate/DatePickerForm.d.ts.map +0 -1
- package/dist/esm/components/SelectDate/DatePickerForm.js +0 -80
- package/dist/esm/components/SelectDate/DatePickerForm.js.map +0 -1
- package/dist/esm/components/SelectDate/SelectDateV2.d.ts +0 -102
- package/dist/esm/components/SelectDate/SelectDateV2.d.ts.map +0 -1
- package/dist/esm/components/SelectDate/SelectDateV2.js +0 -223
- package/dist/esm/components/SelectDate/SelectDateV2.js.map +0 -1
- package/dist/esm/components/Steppers/DateStepper/DateStepperV2.d.ts +0 -45
- package/dist/esm/components/Steppers/DateStepper/DateStepperV2.d.ts.map +0 -1
- package/dist/esm/components/Steppers/DateStepper/DateStepperV2.js +0 -241
- package/dist/esm/components/Steppers/DateStepper/DateStepperV2.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisplayHours.js","names":["React","forwardRef","formatHours","formatNumber","
|
|
1
|
+
{"version":3,"file":"DisplayHours.js","names":["React","forwardRef","formatHours","formatNumber","Tooltip","Typography","DisplayHours","_ref","ref","value","variant","thousandSeparator","decimalSeparator","trimZeroMinutes","trimDecimals","decimalSpaces","format","disableTooltip","className","withLeadingZero","as","rest","shouldDisplayShort","longValue","shortValue","createElement","title","disable","_extends","displayName"],"sources":["../../../../src/components/Display/DisplayHours.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\nimport { DisplayHoursProps } from \"./types\";\nimport { formatHours, formatNumber } from \"../../utils\";\nimport { Tooltip } from \"../Tooltip\";\nimport { Typography } from \"../Typography/Typography\";\n\nexport const DisplayHours = forwardRef<HTMLSpanElement, DisplayHoursProps>(\n (\n {\n value,\n variant = \"Body 2\",\n thousandSeparator = \",\",\n decimalSeparator = \".\",\n trimZeroMinutes = false,\n trimDecimals = true,\n decimalSpaces = 2,\n format = \"long\",\n disableTooltip = false,\n className,\n withLeadingZero,\n as = \"span\",\n ...rest\n },\n ref\n ) => {\n const shouldDisplayShort = format === \"short\" && value >= 1000;\n\n const longValue = formatHours(\n value,\n withLeadingZero,\n trimZeroMinutes,\n \"long\"\n );\n const shortValue = formatNumber(\n value,\n thousandSeparator,\n decimalSeparator,\n trimDecimals,\n decimalSpaces,\n \"short\"\n );\n\n if (shouldDisplayShort) {\n return (\n <Tooltip title={formatHours(value)} disable={disableTooltip}>\n <Typography\n as={as}\n variant={variant}\n className={className}\n ref={ref}\n {...rest}\n >\n {shortValue}\n </Typography>\n </Tooltip>\n );\n }\n\n return (\n <Typography\n as={as}\n variant={variant}\n className={className}\n ref={ref}\n {...rest}\n >\n {longValue}\n </Typography>\n );\n }\n);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ACExB,KAAA,CAAAyB,aAAA,CAACpB,UAAU,EAAAuB,QAAA;IACTR,EAAE,EAAEA,EAAG;IACPV,OAAO,EAAEA,OAAQ;IACjBQ,SAAS,EAAEA,SAAU;IACrBV,GAAG,EAAEA;EAAI,GACLa,IAAI,GAEPE,SACS,CAAC;AAEjB,CACF,CAAC;AAEDjB,YAAY,CAACuB,WAAW,GAAG,cAAc"}
|
|
@@ -11,7 +11,7 @@ export interface DisplayNumberProps extends Omit<TypographyProps<"span">, "child
|
|
|
11
11
|
shortenThreshold?: number;
|
|
12
12
|
}
|
|
13
13
|
export interface DisplayHoursProps extends Omit<TypographyProps<"span">, "children"> {
|
|
14
|
-
value:
|
|
14
|
+
value: number;
|
|
15
15
|
thousandSeparator?: string;
|
|
16
16
|
decimalSeparator?: string;
|
|
17
17
|
trimZeroMinutes?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/Display/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IACjD,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IACjD,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/Display/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IACjD,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/Display/types.ts"],"sourcesContent":["import { FormatType } from \"../../utils/types\";\nimport { TypographyProps } from \"../Typography/Typography\";\n\nexport interface DisplayNumberProps\n extends Omit<TypographyProps<\"span\">, \"children\"> {\n value: string | number;\n thousandSeparator?: string;\n decimalSeparator?: string;\n trimDecimals?: boolean;\n decimalSpaces?: number;\n format?: FormatType;\n disableTooltip?: boolean;\n shortenThreshold?: number;\n}\n\nexport interface DisplayHoursProps\n extends Omit<TypographyProps<\"span\">, \"children\"> {\n value:
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/components/Display/types.ts"],"sourcesContent":["import { FormatType } from \"../../utils/types\";\nimport { TypographyProps } from \"../Typography/Typography\";\n\nexport interface DisplayNumberProps\n extends Omit<TypographyProps<\"span\">, \"children\"> {\n value: string | number;\n thousandSeparator?: string;\n decimalSeparator?: string;\n trimDecimals?: boolean;\n decimalSpaces?: number;\n format?: FormatType;\n disableTooltip?: boolean;\n shortenThreshold?: number;\n}\n\nexport interface DisplayHoursProps\n extends Omit<TypographyProps<\"span\">, \"children\"> {\n value: number;\n thousandSeparator?: string;\n decimalSeparator?: string;\n trimZeroMinutes?: boolean;\n trimDecimals?: boolean;\n decimalSpaces?: number;\n format?: FormatType;\n disableTooltip?: boolean;\n withLeadingZero?: boolean;\n}\n"],"mappings":""}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ElementType, FC, CSSProperties } from "react";
|
|
2
|
-
import { DayModifiers } from "react-day-picker";
|
|
3
2
|
import { Placement } from "@popperjs/core";
|
|
4
|
-
import {
|
|
3
|
+
import { Moment } from "moment";
|
|
4
|
+
import { DaysToModify } from "./types";
|
|
5
|
+
import { ChangeMode, TimestampDateRange } from "../DatePicker/DatePicker";
|
|
5
6
|
type TriggerStringType = "text" | "icon" | "inline";
|
|
6
7
|
type TriggerFunctionType = (text: string) => JSX.Element;
|
|
7
8
|
export interface ISelectDate {
|
|
@@ -26,35 +27,29 @@ export interface ISelectDate {
|
|
|
26
27
|
/** Tooltip text */
|
|
27
28
|
tooltipText?: string;
|
|
28
29
|
/** Called when day is clicked */
|
|
29
|
-
onDayClick?: (day:
|
|
30
|
-
/** Save changes
|
|
31
|
-
onSave?: (dates?:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/** On cancel closes datepicker or opens disard modal in atomic mode */
|
|
30
|
+
onDayClick?: (day: Moment, modifiers: string[]) => void;
|
|
31
|
+
/** Save changes callback */
|
|
32
|
+
onSave?: (dates?: TimestampDateRange) => void;
|
|
33
|
+
/** Changing dates callback */
|
|
34
|
+
onChange?: (dates?: TimestampDateRange) => void;
|
|
35
|
+
/** On cancel closes datepicker or opens discard modal in atomic mode */
|
|
36
36
|
onCancel?: () => void;
|
|
37
37
|
/** Clear dates when they are not required */
|
|
38
38
|
onClear?: () => void;
|
|
39
39
|
/** Use this callback to get is picker visible */
|
|
40
40
|
onToggleDatePicker?: (value: boolean) => void;
|
|
41
41
|
/** Set selected day or days */
|
|
42
|
-
selectedDays?:
|
|
43
|
-
from: number;
|
|
44
|
-
to: number;
|
|
45
|
-
};
|
|
42
|
+
selectedDays?: TimestampDateRange;
|
|
46
43
|
/** Set month */
|
|
47
|
-
defaultMonth?:
|
|
44
|
+
defaultMonth?: Moment;
|
|
48
45
|
/** Set selection range */
|
|
49
|
-
selectionMode?:
|
|
46
|
+
selectionMode?: ChangeMode;
|
|
50
47
|
/** Set is date required */
|
|
51
48
|
required?: boolean;
|
|
52
49
|
/** Set default show on date picker (only for text and icon mode) */
|
|
53
50
|
defaultShowDatePicker?: boolean;
|
|
54
51
|
/** Long date format (Always show year) */
|
|
55
52
|
longDateFormat?: boolean;
|
|
56
|
-
/** Set is date required */
|
|
57
|
-
defaultTimezoneAware?: boolean;
|
|
58
53
|
/** Set first day of week */
|
|
59
54
|
firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
60
55
|
/** One of icon types */
|
|
@@ -74,7 +69,7 @@ export interface ISelectDate {
|
|
|
74
69
|
/** Background style for clickable element after the menu is open (opacity, color, etc...) */
|
|
75
70
|
backgroundElementClass?: string;
|
|
76
71
|
/** Days to modify */
|
|
77
|
-
daysToModify?:
|
|
72
|
+
daysToModify?: DaysToModify[];
|
|
78
73
|
/** Array of weekend days */
|
|
79
74
|
weekends?: number[];
|
|
80
75
|
/** Weekend label */
|
|
@@ -94,7 +89,13 @@ export interface ISelectDate {
|
|
|
94
89
|
/** Position of selectDate menu */
|
|
95
90
|
position?: Placement;
|
|
96
91
|
/** Disable days before specified date */
|
|
97
|
-
disableDaysBefore?:
|
|
92
|
+
disableDaysBefore?: Moment;
|
|
93
|
+
/** Disable days after specified date */
|
|
94
|
+
disabledDaysAfter?: Moment;
|
|
95
|
+
/** Enable year selector */
|
|
96
|
+
enableYearPicker?: boolean;
|
|
97
|
+
/** Disable aniamtions */
|
|
98
|
+
disableAnimations?: boolean;
|
|
98
99
|
}
|
|
99
100
|
export declare const SelectDate: FC<ISelectDate>;
|
|
100
101
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectDate.d.ts","sourceRoot":"","sources":["../../../../src/components/SelectDate/SelectDate.tsx"],"names":[],"mappings":"AAAA,OAAc,
|
|
1
|
+
{"version":3,"file":"SelectDate.d.ts","sourceRoot":"","sources":["../../../../src/components/SelectDate/SelectDate.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,WAAW,EAAE,EAAE,EAAW,aAAa,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EACL,UAAU,EAEV,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAElC,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AACpD,KAAK,mBAAmB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC;AA2BzD,MAAM,WAAW,WAAW;IAC1B,8CAA8C;IAC9C,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IA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,CAAC,EAAE,MAAM,CAAC;IAC3B,2BAA2B;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yBAAyB;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,WAAW,CAqPtC,CAAC"}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
-
import moment from "moment";
|
|
4
|
-
import { DatePickerForm } from "./DatePickerForm";
|
|
3
|
+
import moment from "moment-timezone";
|
|
5
4
|
import { SelectDateTarget } from "./SelectDateTarget";
|
|
6
|
-
import {
|
|
5
|
+
import { StyledSelectDate, StyledSelectDateButton } from "./Styles";
|
|
7
6
|
import { formatDate } from "../../utils/dateUtils";
|
|
8
|
-
import {
|
|
9
|
-
import { Menu } from "../Menu/Menu";
|
|
10
|
-
import { Tooltip } from "../Tooltip/Tooltip";
|
|
11
|
-
const getUtcTimestampFromDate = date => {
|
|
12
|
-
return moment.utc([date.getFullYear(), date.getMonth(), date.getDate()]).unix();
|
|
13
|
-
};
|
|
7
|
+
import { DatePicker, toMoment } from "../DatePicker/DatePicker";
|
|
14
8
|
const isDayInRange = (day, data) => {
|
|
9
|
+
const fromMoment = moment.unix(data.from).utc();
|
|
10
|
+
const toMoment = moment.unix(data.to).utc();
|
|
15
11
|
if (data.repeating) {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
12
|
+
const year = day.year();
|
|
13
|
+
const from = moment.utc({
|
|
14
|
+
year,
|
|
15
|
+
month: fromMoment.month(),
|
|
16
|
+
date: fromMoment.date()
|
|
17
|
+
});
|
|
18
|
+
const to = moment.utc({
|
|
19
|
+
year,
|
|
20
|
+
month: toMoment.month(),
|
|
21
|
+
date: toMoment.date()
|
|
22
|
+
});
|
|
23
|
+
return day.isSameOrAfter(from, "day") && day.isSameOrBefore(to, "day");
|
|
19
24
|
}
|
|
20
|
-
return day
|
|
25
|
+
return day.isSameOrAfter(fromMoment, "day") && day.isSameOrBefore(toMoment, "day");
|
|
21
26
|
};
|
|
22
27
|
export const SelectDate = _ref => {
|
|
23
28
|
let {
|
|
@@ -35,7 +40,6 @@ export const SelectDate = _ref => {
|
|
|
35
40
|
onCancel,
|
|
36
41
|
onToggleDatePicker,
|
|
37
42
|
required: dateRequired = false,
|
|
38
|
-
defaultTimezoneAware = false,
|
|
39
43
|
longDateFormat = false,
|
|
40
44
|
defaultShowDatePicker = false,
|
|
41
45
|
firstDayOfWeek = 0,
|
|
@@ -48,7 +52,7 @@ export const SelectDate = _ref => {
|
|
|
48
52
|
targetTextClassName,
|
|
49
53
|
targetIconClassName,
|
|
50
54
|
backgroundElementClass,
|
|
51
|
-
dateFormat
|
|
55
|
+
dateFormat,
|
|
52
56
|
defaultMonth,
|
|
53
57
|
daysToModify = [],
|
|
54
58
|
weekends = [],
|
|
@@ -61,251 +65,86 @@ export const SelectDate = _ref => {
|
|
|
61
65
|
popperClassName,
|
|
62
66
|
popperTooltipStyle,
|
|
63
67
|
position,
|
|
64
|
-
disableDaysBefore
|
|
68
|
+
disableDaysBefore,
|
|
69
|
+
enableYearPicker,
|
|
70
|
+
disableAnimations,
|
|
71
|
+
disabledDaysAfter,
|
|
72
|
+
onChange
|
|
65
73
|
} = _ref;
|
|
66
|
-
const [timezoneAware, setTimezoneAware] = useState(defaultTimezoneAware);
|
|
67
|
-
const localization = useLocalization();
|
|
68
|
-
const dateFormat = passedDateFormat ? passedDateFormat : localization.dateFormat;
|
|
69
74
|
const labelText = useMemo(() => {
|
|
70
75
|
if (!selectedDays) {
|
|
71
76
|
return defaultLabelText;
|
|
77
|
+
} else if (!selectedDays.from && !selectedDays.to) {
|
|
78
|
+
return defaultLabelText;
|
|
72
79
|
} else {
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const formattedStartDate = formatDate(startDate, dateFormat, longDateFormat);
|
|
77
|
-
if (selectedDays.from === selectedDays.to) {
|
|
80
|
+
const formattedEndDate = selectedDays.to ? formatDate(toMoment(selectedDays.to), dateFormat, longDateFormat) : "";
|
|
81
|
+
const formattedStartDate = selectedDays.from ? formatDate(toMoment(selectedDays == null ? void 0 : selectedDays.from), dateFormat, longDateFormat) : "";
|
|
82
|
+
if (selectedDays.to && selectedDays.from && toMoment(selectedDays.from).isSame(toMoment(selectedDays.to))) {
|
|
78
83
|
return formattedEndDate;
|
|
79
84
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}, [selectedDays, dateFormat, timezoneAware, defaultLabelText, longDateFormat]);
|
|
83
|
-
const modifiedDates = useMemo(() => {
|
|
84
|
-
if (typeof selectedDays === "object" && !!selectedDays.from && !!selectedDays.to) {
|
|
85
|
-
if (timezoneAware) {
|
|
86
|
-
return {
|
|
87
|
-
from: moment.unix(selectedDays.from).toDate(),
|
|
88
|
-
to: moment.unix(selectedDays.to).toDate()
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
const offsetFrom = moment.unix(selectedDays.from).utcOffset() * 60;
|
|
92
|
-
const offsetTo = moment.unix(selectedDays.to).utcOffset() * 60;
|
|
93
|
-
return {
|
|
94
|
-
from: new Date((selectedDays.from - offsetFrom) * 1000),
|
|
95
|
-
to: new Date((selectedDays.to - offsetTo) * 1000)
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}, [selectedDays, timezoneAware]);
|
|
99
|
-
const handleModifiedSave = useCallback(selectedDates => {
|
|
100
|
-
setTimezoneAware(false);
|
|
101
|
-
if (typeof onSave === "function") {
|
|
102
|
-
if (typeof selectedDates === "object" && Object.prototype.hasOwnProperty.call(selectedDates, "from") && Object.prototype.hasOwnProperty.call(selectedDates, "to")) {
|
|
103
|
-
onSave({
|
|
104
|
-
from: getUtcTimestampFromDate(selectedDates.from),
|
|
105
|
-
to: getUtcTimestampFromDate(selectedDates.to)
|
|
106
|
-
});
|
|
107
|
-
} else {
|
|
108
|
-
onSave(undefined);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}, [onSave]);
|
|
112
|
-
const getDefaultMonth = useCallback(() => {
|
|
113
|
-
let date = new Date();
|
|
114
|
-
if (typeof selectedDays === "object" && !!selectedDays.from) {
|
|
115
|
-
date = timezoneAware ? new Date(selectedDays.from * 1000) : new Date((selectedDays.from - moment.unix(selectedDays.from).utcOffset() * 60) * 1000);
|
|
116
|
-
} else if (defaultMonth) {
|
|
117
|
-
date = defaultMonth;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// forcing second day in month
|
|
121
|
-
return new Date(date.getFullYear(), date.getMonth(), 2);
|
|
122
|
-
}, [defaultMonth, selectedDays, timezoneAware]);
|
|
123
|
-
const [month, setMonth] = useState(getDefaultMonth);
|
|
124
|
-
const handleMonthChange = useCallback(month => {
|
|
125
|
-
setMonth(month);
|
|
126
|
-
}, [setMonth]);
|
|
127
|
-
const [newDates, setNewDates] = useState(modifiedDates);
|
|
128
|
-
const [showDiscardModal, setShowDiscardModal] = useState(false);
|
|
129
|
-
const [showDatePicker, setShowDatePicker] = useState(defaultShowDatePicker);
|
|
130
|
-
const disabledSaveButton = useMemo(() => {
|
|
131
|
-
return (modifiedDates == null ? void 0 : modifiedDates.from) === (newDates == null ? void 0 : newDates.from) && (modifiedDates == null ? void 0 : modifiedDates.to) === (newDates == null ? void 0 : newDates.to);
|
|
132
|
-
}, [modifiedDates, newDates]);
|
|
133
|
-
useEffect(() => {
|
|
134
|
-
setShowDatePicker(defaultShowDatePicker);
|
|
135
|
-
}, [defaultShowDatePicker]);
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
setNewDates(modifiedDates);
|
|
138
|
-
}, [modifiedDates]);
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
typeof onToggleDatePicker === "function" && onToggleDatePicker(showDatePicker);
|
|
141
|
-
}, [showDatePicker, onToggleDatePicker]);
|
|
142
|
-
useEffect(() => {
|
|
143
|
-
if (!showDatePicker) {
|
|
144
|
-
setMonth(getDefaultMonth());
|
|
145
|
-
}
|
|
146
|
-
}, [showDatePicker, getDefaultMonth]);
|
|
147
|
-
const handleSave = useCallback(() => {
|
|
148
|
-
handleModifiedSave(newDates);
|
|
149
|
-
setShowDatePicker(false);
|
|
150
|
-
}, [newDates, handleModifiedSave]);
|
|
151
|
-
const handleChange = useCallback(dates => {
|
|
152
|
-
if (mode !== "atomic") {
|
|
153
|
-
handleModifiedSave(dates);
|
|
154
|
-
}
|
|
155
|
-
setNewDates(dates);
|
|
156
|
-
}, [mode, handleModifiedSave]);
|
|
157
|
-
const handleBeforeCloseMenu = useCallback(() => {
|
|
158
|
-
let result = true;
|
|
159
|
-
if (modifiedDates && !newDates || !modifiedDates && newDates) {
|
|
160
|
-
result = false;
|
|
161
|
-
}
|
|
162
|
-
const selectedDaysFrom = modifiedDates == null ? void 0 : modifiedDates.from;
|
|
163
|
-
const selectedDaysTo = modifiedDates == null ? void 0 : modifiedDates.to;
|
|
164
|
-
const newDatesFrom = newDates == null ? void 0 : newDates.from;
|
|
165
|
-
const newDatesTo = newDates == null ? void 0 : newDates.to;
|
|
166
|
-
if (selectedDaysFrom && newDatesFrom && selectedDaysTo && newDatesTo && (moment(selectedDaysFrom).format("DD-MM-YYYY") !== moment(newDatesFrom).format("DD-MM-YYYY") || moment(selectedDaysTo).format("DD-MM-YYYY") !== moment(newDatesTo).format("DD-MM-YYYY"))) {
|
|
167
|
-
result = false;
|
|
168
|
-
}
|
|
169
|
-
if (!result) {
|
|
170
|
-
setShowDiscardModal(true);
|
|
171
|
-
}
|
|
172
|
-
return result;
|
|
173
|
-
}, [modifiedDates, newDates]);
|
|
174
|
-
const handleClose = useCallback(() => {
|
|
175
|
-
if (mode !== "atomic" || handleBeforeCloseMenu()) {
|
|
176
|
-
typeof onCancel === "function" && onCancel();
|
|
177
|
-
setShowDatePicker(false);
|
|
178
|
-
}
|
|
179
|
-
}, [mode, onCancel, handleBeforeCloseMenu]);
|
|
180
|
-
const handleCancel = useCallback(event => {
|
|
181
|
-
event && event.preventDefault();
|
|
182
|
-
return handleClose();
|
|
183
|
-
}, [handleClose]);
|
|
184
|
-
const handleShowDatePicker = useCallback(() => {
|
|
185
|
-
setShowDatePicker(!showDatePicker);
|
|
186
|
-
}, [showDatePicker]);
|
|
187
|
-
const handleCloseDiscardModal = useCallback(() => {
|
|
188
|
-
setShowDiscardModal(false);
|
|
189
|
-
}, []);
|
|
190
|
-
const handleClear = useCallback(() => {
|
|
191
|
-
if (!dateRequired) {
|
|
192
|
-
setNewDates(undefined);
|
|
193
|
-
if (mode === "instant") {
|
|
194
|
-
handleModifiedSave(undefined);
|
|
85
|
+
if (!selectedDays.to && selectedDays.from) {
|
|
86
|
+
return formattedStartDate;
|
|
195
87
|
}
|
|
88
|
+
return formattedStartDate + " - " + formattedEndDate;
|
|
196
89
|
}
|
|
197
|
-
}, [
|
|
198
|
-
const handleSaveDiscardModal = useCallback(() => {
|
|
199
|
-
setNewDates(modifiedDates);
|
|
200
|
-
setShowDiscardModal(false);
|
|
201
|
-
setShowDatePicker(false);
|
|
202
|
-
}, [modifiedDates]);
|
|
90
|
+
}, [selectedDays, dateFormat, defaultLabelText, longDateFormat]);
|
|
203
91
|
const modifiers = useMemo(() => {
|
|
204
92
|
const userAvailabilities = daysToModify.filter(data => data.type === "user_day_off");
|
|
205
93
|
const globalDaysOff = daysToModify.filter(data => data.type === "global_day_off");
|
|
206
94
|
const selectableGlobalDaysOff = daysToModify.filter(data => data.type === "selectable_global_day_off");
|
|
207
95
|
return {
|
|
208
96
|
userAvailability: day => {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
97
|
+
const matchedData = userAvailabilities.find(data => isDayInRange(day, data));
|
|
98
|
+
return {
|
|
99
|
+
matched: !!matchedData,
|
|
100
|
+
title: matchedData ? matchedData.title : null
|
|
101
|
+
};
|
|
212
102
|
},
|
|
213
103
|
weekend: day => {
|
|
214
|
-
|
|
104
|
+
const isWeekend = weekends.includes(day.day());
|
|
105
|
+
return {
|
|
106
|
+
matched: isWeekend,
|
|
107
|
+
title: isWeekend ? weekendLabel : null
|
|
108
|
+
};
|
|
215
109
|
},
|
|
216
110
|
nonWorkingDay: day => {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
111
|
+
if (weekends.includes(day.day())) {
|
|
112
|
+
return {
|
|
113
|
+
matched: true,
|
|
114
|
+
title: ""
|
|
115
|
+
};
|
|
220
116
|
}
|
|
221
117
|
const nonWorkingDays = [...selectableGlobalDaysOff, ...globalDaysOff];
|
|
222
|
-
const
|
|
223
|
-
return
|
|
118
|
+
const matchedData = nonWorkingDays.find(data => isDayInRange(day, data));
|
|
119
|
+
return {
|
|
120
|
+
matched: !!matchedData,
|
|
121
|
+
title: matchedData ? matchedData.title : null
|
|
122
|
+
};
|
|
224
123
|
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
// return true if day is weekend day
|
|
232
|
-
if (!weekendIsSelectable && weekends.some(value => value === day.getDay())) {
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
// construct new date because react-day-picker returns date with hours set
|
|
236
|
-
const currentDay = new Date(day.getFullYear(), day.getMonth(), day.getDate());
|
|
237
|
-
return globalDaysOff.some(data => isDayInRange(currentDay, data));
|
|
124
|
+
nonWorkingDaysOfWeek: day => {
|
|
125
|
+
const isNonWorkingDay = nonWorkingDaysOfWeek.includes(day.day());
|
|
126
|
+
return {
|
|
127
|
+
matched: isNonWorkingDay,
|
|
128
|
+
title: isNonWorkingDay ? nonWorkingDaysOfWeekLabel : null
|
|
129
|
+
};
|
|
238
130
|
},
|
|
239
|
-
|
|
240
|
-
|
|
131
|
+
day_disabled: day => {
|
|
132
|
+
const globalDayOff = globalDaysOff.find(data => isDayInRange(day, data));
|
|
133
|
+
return {
|
|
134
|
+
matched: !!globalDayOff,
|
|
135
|
+
title: null
|
|
136
|
+
};
|
|
241
137
|
}
|
|
242
138
|
};
|
|
243
|
-
}, [daysToModify, nonWorkingDaysOfWeek,
|
|
244
|
-
const renderDay = useCallback(props => {
|
|
245
|
-
const titles = [];
|
|
246
|
-
if (weekends.some(value => props.date.getDay() === value)) {
|
|
247
|
-
titles.push(weekendLabel);
|
|
248
|
-
}
|
|
249
|
-
if (nonWorkingDaysOfWeek.includes(props.date.getDay())) {
|
|
250
|
-
titles.push(nonWorkingDaysOfWeekLabel);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// construct new date because react-day-picker returns date with hours set
|
|
254
|
-
const currentDay = new Date(props.date.getFullYear(), props.date.getMonth(), props.date.getDate());
|
|
255
|
-
daysToModify.forEach(data => {
|
|
256
|
-
if (isDayInRange(currentDay, data)) {
|
|
257
|
-
titles.push(data.title);
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
const child = /*#__PURE__*/React.createElement("div", {
|
|
261
|
-
className: "c-DayPicker-Day-Number"
|
|
262
|
-
}, props.date.getDate());
|
|
263
|
-
if (titles.length) {
|
|
264
|
-
const title = /*#__PURE__*/React.createElement("div", {
|
|
265
|
-
key: "title-wrapper-" + props.date.getDate()
|
|
266
|
-
}, titles.map((title, index) => /*#__PURE__*/React.createElement("div", {
|
|
267
|
-
key: "title-text-" + index
|
|
268
|
-
}, title)));
|
|
269
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
270
|
-
title: title,
|
|
271
|
-
popperTooltipClassName: popperTooltipClassName,
|
|
272
|
-
popperTooltipStyle: popperTooltipStyle
|
|
273
|
-
}, child);
|
|
274
|
-
}
|
|
275
|
-
return child;
|
|
276
|
-
}, [weekends, nonWorkingDaysOfWeek, daysToModify, weekendLabel, nonWorkingDaysOfWeekLabel, popperTooltipClassName, popperTooltipStyle]);
|
|
277
|
-
const renderDatePickerForm = useCallback(() => {
|
|
278
|
-
return /*#__PURE__*/React.createElement(DatePickerForm, {
|
|
279
|
-
onMonthChange: handleMonthChange,
|
|
280
|
-
month: month,
|
|
281
|
-
mode: mode,
|
|
282
|
-
selectionMode: selectionMode,
|
|
283
|
-
dateRequired: dateRequired,
|
|
284
|
-
selectedDays: newDates,
|
|
285
|
-
firstDayOfWeek: firstDayOfWeek,
|
|
286
|
-
saveButtonText: saveButtonText,
|
|
287
|
-
cancelButtonText: cancelButtonText,
|
|
288
|
-
clearButtonText: clearButtonText,
|
|
289
|
-
onDayClick: onDayClick,
|
|
290
|
-
onSave: handleSave,
|
|
291
|
-
onChange: handleChange,
|
|
292
|
-
onCancel: handleCancel,
|
|
293
|
-
onClear: handleClear,
|
|
294
|
-
disabledSaveButton: disabledSaveButton,
|
|
295
|
-
modifiers: modifiers,
|
|
296
|
-
renderDay: renderDay
|
|
297
|
-
});
|
|
298
|
-
}, [handleMonthChange, month, mode, selectionMode, dateRequired, newDates, firstDayOfWeek, saveButtonText, cancelButtonText, clearButtonText, onDayClick, handleSave, handleChange, handleCancel, handleClear, disabledSaveButton, modifiers, renderDay]);
|
|
139
|
+
}, [daysToModify, nonWorkingDaysOfWeek, nonWorkingDaysOfWeekLabel, weekendLabel, weekends]);
|
|
299
140
|
const renderTargetEl = useMemo(() => {
|
|
300
141
|
if (labelType === "icon" && icon) {
|
|
301
142
|
return /*#__PURE__*/React.createElement(SelectDateTarget, {
|
|
302
143
|
icon: icon,
|
|
303
144
|
title: tooltipText,
|
|
304
145
|
targetIconClassName: targetIconClassName,
|
|
305
|
-
forceHideTooltip: showDatePicker,
|
|
306
146
|
popperTooltipClassName: popperTooltipClassName,
|
|
307
|
-
popperTooltipStyle: popperTooltipStyle
|
|
308
|
-
active: showDatePicker
|
|
147
|
+
popperTooltipStyle: popperTooltipStyle
|
|
309
148
|
});
|
|
310
149
|
}
|
|
311
150
|
if (typeof labelType === "function") {
|
|
@@ -317,29 +156,68 @@ export const SelectDate = _ref => {
|
|
|
317
156
|
}, /*#__PURE__*/React.createElement("span", {
|
|
318
157
|
className: targetTextClassName
|
|
319
158
|
}, labelText));
|
|
320
|
-
}, [icon, labelText, labelType, popperTooltipClassName, popperTooltipStyle,
|
|
159
|
+
}, [icon, labelText, labelType, popperTooltipClassName, popperTooltipStyle, targetClassName, targetIconClassName, targetTextClassName, tooltipText]);
|
|
321
160
|
return /*#__PURE__*/React.createElement(StyledSelectDate, {
|
|
322
161
|
className: "select-date"
|
|
323
|
-
}, labelType !== "inline" ? /*#__PURE__*/React.createElement(
|
|
162
|
+
}, labelType !== "inline" ? /*#__PURE__*/React.createElement(DatePicker, {
|
|
324
163
|
target: renderTargetEl,
|
|
325
|
-
open: showDatePicker,
|
|
326
|
-
onOpen: handleShowDatePicker,
|
|
327
|
-
onBeforeClose: handleBeforeCloseMenu,
|
|
328
|
-
onClose: handleClose,
|
|
329
164
|
position: position,
|
|
330
165
|
menuClassName: menuClassName,
|
|
331
166
|
popperClassName: popperClassName,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
167
|
+
month: defaultMonth,
|
|
168
|
+
instant: mode === "instant",
|
|
169
|
+
mode: selectionMode,
|
|
170
|
+
required: dateRequired,
|
|
171
|
+
selected: selectedDays,
|
|
172
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
173
|
+
saveLabel: saveButtonText,
|
|
174
|
+
cancelLabel: cancelButtonText,
|
|
175
|
+
clearLabel: clearButtonText,
|
|
176
|
+
onSave: onSave,
|
|
177
|
+
onChange: onChange,
|
|
178
|
+
onClose: onCancel,
|
|
179
|
+
modifiers: modifiers,
|
|
180
|
+
modalHeaderText: modalHeaderText,
|
|
181
|
+
modalDiscardMessage: modalDiscardMessage,
|
|
182
|
+
modalDiscardBtnText: modalDiscardBtnText,
|
|
183
|
+
modalCancelBtnText: modalCancelBtnText,
|
|
184
|
+
disabledDaysBefore: disableDaysBefore,
|
|
185
|
+
disabledDaysAfter: disabledDaysAfter,
|
|
186
|
+
backgroundElementClass: backgroundElementClass,
|
|
187
|
+
disabled: weekendIsSelectable ? [] : weekends,
|
|
188
|
+
popperTooltipClassName: popperTooltipClassName,
|
|
189
|
+
popperTooltipStyle: popperTooltipStyle,
|
|
190
|
+
open: defaultShowDatePicker,
|
|
191
|
+
onCalendarToggle: onToggleDatePicker,
|
|
192
|
+
onDayClick: onDayClick,
|
|
193
|
+
enableConfirmModal: mode === "atomic" && !dateRequired,
|
|
194
|
+
disableYearPicker: !enableYearPicker,
|
|
195
|
+
disableAnimations: disableAnimations,
|
|
196
|
+
showControls: true
|
|
197
|
+
}) : /*#__PURE__*/React.createElement(DatePicker, {
|
|
198
|
+
month: defaultMonth,
|
|
199
|
+
instant: mode === "instant",
|
|
200
|
+
mode: selectionMode,
|
|
201
|
+
required: dateRequired,
|
|
202
|
+
selected: selectedDays,
|
|
203
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
204
|
+
saveLabel: saveButtonText,
|
|
205
|
+
cancelLabel: cancelButtonText,
|
|
206
|
+
clearLabel: clearButtonText,
|
|
207
|
+
disabledDaysBefore: disableDaysBefore,
|
|
208
|
+
disabledDaysAfter: disabledDaysAfter,
|
|
209
|
+
popperTooltipClassName: popperTooltipClassName,
|
|
210
|
+
popperTooltipStyle: popperTooltipStyle,
|
|
211
|
+
disabled: weekendIsSelectable ? [] : weekends,
|
|
212
|
+
onSave: onSave,
|
|
213
|
+
onChange: onChange,
|
|
214
|
+
modifiers: modifiers,
|
|
215
|
+
onDayClick: onDayClick,
|
|
216
|
+
disableYearPicker: !enableYearPicker,
|
|
217
|
+
disableAnimations: disableAnimations,
|
|
218
|
+
showControls: true,
|
|
219
|
+
open: true
|
|
220
|
+
}));
|
|
343
221
|
};
|
|
344
222
|
SelectDate.displayName = "SelectDate";
|
|
345
223
|
//# sourceMappingURL=SelectDate.js.map
|