@frontify/fondue 12.0.0-beta.128 → 12.0.0-beta.129
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/components/DatePicker/DatePicker.d.ts +6 -2
- package/dist/components/DatePicker/DatePicker.es.js +118 -111
- package/dist/components/DatePicker/DatePicker.es.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.es.js +51 -51
- package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
- package/dist/components/Tree/TreeItem.es.js +7 -7
- package/dist/components/Tree/TreeItem.es.js.map +1 -1
- package/dist/extractedThirdPartyStyles.css +5 -1
- package/dist/index.cjs.js +12 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +7 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import DatepickerComponent, { ReactDatePicker } from 'react-datepicker';
|
|
2
3
|
import { Validation } from '../../utilities/validation';
|
|
3
4
|
type SingleDatePickerProps = {
|
|
4
5
|
variant?: 'single';
|
|
@@ -25,10 +26,13 @@ export type DatePickerProps = {
|
|
|
25
26
|
customTrigger?: React.ReactNode;
|
|
26
27
|
children?: React.ReactNode;
|
|
27
28
|
hasPopperArrow?: boolean;
|
|
29
|
+
preventOpenOnFocus?: boolean;
|
|
28
30
|
filterDate?: (date: Date) => boolean;
|
|
29
31
|
onOpen?: () => void;
|
|
30
32
|
onClose?: () => void;
|
|
31
33
|
onBlur?: () => void;
|
|
34
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
32
35
|
} & (SingleDatePickerProps | RangeDatePickerProps);
|
|
33
|
-
export
|
|
36
|
+
export type ReactDatePickerRef = ReactDatePicker<never, boolean>;
|
|
37
|
+
export declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<DatepickerComponent<never, boolean>>>;
|
|
34
38
|
export {};
|
|
@@ -1,117 +1,124 @@
|
|
|
1
1
|
import { IconSize as r } from "../../foundation/Icon/IconSize.es.js";
|
|
2
|
-
import { format as
|
|
3
|
-
import e, { useState as
|
|
4
|
-
import
|
|
2
|
+
import { format as v, getYear as A } from "date-fns";
|
|
3
|
+
import e, { forwardRef as H, useState as T } from "react";
|
|
4
|
+
import V from "react-datepicker";
|
|
5
5
|
import "./DatePicker.css.es.js";
|
|
6
|
-
import { DatePickerTrigger as
|
|
7
|
-
import { Validation as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
6
|
+
import { DatePickerTrigger as Y } from "./DatePickerTrigger.es.js";
|
|
7
|
+
import { Validation as q } from "../../utilities/validation.es.js";
|
|
8
|
+
import G from "../../foundation/Icon/Generated/IconCaretLeftDouble.es.js";
|
|
9
|
+
import J from "../../foundation/Icon/Generated/IconCaretLeft.es.js";
|
|
10
|
+
import K from "../../foundation/Icon/Generated/IconCaretRight.es.js";
|
|
11
|
+
import O from "../../foundation/Icon/Generated/IconCaretRightDouble.es.js";
|
|
12
12
|
import { Button as i } from "../Button/Button.es.js";
|
|
13
|
-
import { ButtonStyle as n, ButtonSize as
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
13
|
+
import { ButtonStyle as n, ButtonSize as o, ButtonEmphasis as s } from "../Button/ButtonTypes.es.js";
|
|
14
|
+
const Q = (m, a) => m === "single" ? a < new Date() ? "past-date" : "future-date" : "range-day", U = H(
|
|
15
|
+
({
|
|
16
|
+
placeHolder: m = "Select a date",
|
|
17
|
+
isClearable: a,
|
|
18
|
+
shouldCloseOnSelect: u,
|
|
19
|
+
onChange: d,
|
|
20
|
+
onOpen: l,
|
|
21
|
+
onClose: c,
|
|
22
|
+
onBlur: w,
|
|
23
|
+
onKeyDown: y,
|
|
24
|
+
dateFormat: D = "dd MMM yyyy",
|
|
25
|
+
value: k,
|
|
26
|
+
startDate: E,
|
|
27
|
+
endDate: g,
|
|
28
|
+
minDate: z,
|
|
29
|
+
maxDate: C,
|
|
30
|
+
validation: M = q.Default,
|
|
31
|
+
customTrigger: h,
|
|
32
|
+
children: S = /* @__PURE__ */ e.createElement(e.Fragment, null),
|
|
33
|
+
hasPopperArrow: I = !0,
|
|
34
|
+
preventOpenOnFocus: b = !1,
|
|
35
|
+
filterDate: N = () => !0,
|
|
36
|
+
variant: f = "single"
|
|
37
|
+
}, R) => {
|
|
38
|
+
const [W, p] = T(!1), x = () => {
|
|
39
|
+
p(!0), l == null || l();
|
|
40
|
+
}, B = () => {
|
|
41
|
+
p(!1), c == null || c();
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ e.createElement("div", { "data-test-id": "date-picker" }, /* @__PURE__ */ e.createElement(
|
|
44
|
+
V,
|
|
45
|
+
{
|
|
46
|
+
calendarClassName: "tw-rounded-sm tw-border tw-border-line-x-strong react-datepicker-wrap",
|
|
47
|
+
selected: k,
|
|
48
|
+
startDate: E,
|
|
49
|
+
endDate: g,
|
|
50
|
+
minDate: z,
|
|
51
|
+
maxDate: C,
|
|
52
|
+
calendarStartDay: 1,
|
|
53
|
+
onChange: d,
|
|
54
|
+
onKeyDown: y,
|
|
55
|
+
onBlur: w,
|
|
56
|
+
selectsRange: f === "range",
|
|
57
|
+
showPopperArrow: I,
|
|
58
|
+
preventOpenOnFocus: b,
|
|
59
|
+
filterDate: N,
|
|
60
|
+
customInput: h ?? /* @__PURE__ */ e.createElement(
|
|
61
|
+
Y,
|
|
62
|
+
{
|
|
63
|
+
isCalendarOpen: W,
|
|
64
|
+
isClearable: a,
|
|
65
|
+
placeHolder: m,
|
|
66
|
+
validation: M,
|
|
67
|
+
onDateChanged: d
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
ref: R,
|
|
71
|
+
formatWeekDay: (t) => t.slice(0, 1),
|
|
72
|
+
isClearable: a,
|
|
73
|
+
dateFormat: D,
|
|
74
|
+
onCalendarClose: B,
|
|
75
|
+
onCalendarOpen: x,
|
|
76
|
+
shouldCloseOnSelect: u,
|
|
77
|
+
dayClassName: (t) => Q(f, t),
|
|
78
|
+
renderCustomHeader: ({ date: t, decreaseMonth: P, increaseMonth: F, increaseYear: L, decreaseYear: j }) => /* @__PURE__ */ e.createElement("div", { className: "tw-flex tw-justify-between tw-pb-4 tw-px-0" }, /* @__PURE__ */ e.createElement(
|
|
79
|
+
i,
|
|
80
|
+
{
|
|
81
|
+
style: n.Default,
|
|
82
|
+
size: o.Medium,
|
|
83
|
+
onClick: j,
|
|
84
|
+
emphasis: s.Weak,
|
|
85
|
+
icon: /* @__PURE__ */ e.createElement(G, { size: r.Size20 })
|
|
86
|
+
}
|
|
87
|
+
), /* @__PURE__ */ e.createElement(
|
|
88
|
+
i,
|
|
89
|
+
{
|
|
90
|
+
style: n.Default,
|
|
91
|
+
size: o.Medium,
|
|
92
|
+
onClick: P,
|
|
93
|
+
emphasis: s.Weak,
|
|
94
|
+
icon: /* @__PURE__ */ e.createElement(J, { size: r.Size20 })
|
|
95
|
+
}
|
|
96
|
+
), /* @__PURE__ */ e.createElement("p", { className: "tw-font-sans tw-font-semibold tw-grow tw-self-center" }, v(t, "MMMM"), " ", A(t)), /* @__PURE__ */ e.createElement(
|
|
97
|
+
i,
|
|
98
|
+
{
|
|
99
|
+
style: n.Default,
|
|
100
|
+
size: o.Medium,
|
|
101
|
+
onClick: F,
|
|
102
|
+
emphasis: s.Weak,
|
|
103
|
+
icon: /* @__PURE__ */ e.createElement(K, { size: r.Size20 })
|
|
104
|
+
}
|
|
105
|
+
), /* @__PURE__ */ e.createElement(
|
|
106
|
+
i,
|
|
107
|
+
{
|
|
108
|
+
style: n.Default,
|
|
109
|
+
size: o.Medium,
|
|
110
|
+
onClick: L,
|
|
111
|
+
emphasis: s.Weak,
|
|
112
|
+
icon: /* @__PURE__ */ e.createElement(O, { size: r.Size20 })
|
|
113
|
+
}
|
|
114
|
+
))
|
|
115
|
+
},
|
|
116
|
+
S
|
|
117
|
+
));
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
U.displayName = "FondueDatePicker";
|
|
114
121
|
export {
|
|
115
|
-
|
|
122
|
+
U as DatePicker
|
|
116
123
|
};
|
|
117
124
|
//# sourceMappingURL=DatePicker.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.es.js","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Button, ButtonEmphasis, ButtonSize, ButtonStyle } from '@components/Button';\nimport { IconSize } from '@foundation/Icon/IconSize';\nimport { format, getYear } from 'date-fns';\nimport React, { FC, useState } from 'react';\nimport DatepickerComponent from 'react-datepicker';\nimport './DatePicker.css';\nimport { DatePickerTrigger } from './DatePickerTrigger';\nimport { IconCaretLeft, IconCaretLeftDouble, IconCaretRight, IconCaretRightDouble } from '@foundation/Icon/Generated';\nimport { Validation } from '@utilities/validation';\n\ntype SingleDatePickerProps = {\n variant?: 'single';\n onChange: (date: Date | null) => void;\n startDate?: null;\n endDate?: null;\n};\n\ntype RangeDatePickerProps = {\n variant: 'range';\n onChange: (date: [Date | null, Date | null] | null) => void;\n startDate: Date | null;\n endDate: Date | null;\n};\n\nexport type DatePickerProps = {\n placeHolder?: string;\n isClearable?: boolean;\n shouldCloseOnSelect?: boolean;\n dateFormat?: string;\n /** @description when the variant is of type 'range', the value should be the startDate */\n value?: Date | null;\n minDate?: Date;\n maxDate?: Date;\n validation?: Validation;\n customTrigger?: React.ReactNode;\n children?: React.ReactNode;\n hasPopperArrow?: boolean;\n filterDate?: (date: Date) => boolean;\n onOpen?: () => void;\n onClose?: () => void;\n onBlur?: () => void;\n} & (SingleDatePickerProps | RangeDatePickerProps);\n\nconst getDayClasses = (variant: DatePickerProps['variant'], date: Date) => {\n if (variant === 'single') {\n return date < new Date() ? 'past-date' : 'future-date';\n }\n return 'range-day';\n};\n\nexport const DatePicker: FC<DatePickerProps> = ({\n placeHolder = 'Select a date',\n isClearable,\n shouldCloseOnSelect,\n onChange,\n onOpen,\n onClose,\n onBlur,\n dateFormat = 'dd MMM yyyy',\n value,\n startDate,\n endDate,\n minDate,\n maxDate,\n validation = Validation.Default,\n customTrigger,\n children = <></>,\n hasPopperArrow = true,\n filterDate = () => true,\n variant = 'single',\n}) => {\n const [isCalendarOpen, setIsCalendarOpen] = useState<boolean>(false);\n\n const handleOpen = () => {\n setIsCalendarOpen(true);\n onOpen?.();\n };\n\n const handleClose = () => {\n setIsCalendarOpen(false);\n onClose?.();\n };\n\n return (\n <div data-test-id=\"date-picker\">\n <DatepickerComponent\n calendarClassName=\"tw-rounded-sm tw-border tw-border-line-x-strong react-datepicker-wrap\"\n selected={value}\n startDate={startDate}\n endDate={endDate}\n minDate={minDate}\n maxDate={maxDate}\n calendarStartDay={1}\n onChange={onChange}\n onBlur={onBlur}\n selectsRange={variant === 'range' ? true : false}\n showPopperArrow={hasPopperArrow}\n filterDate={filterDate}\n customInput={\n customTrigger ?? (\n <DatePickerTrigger\n isCalendarOpen={isCalendarOpen}\n isClearable={isClearable}\n placeHolder={placeHolder}\n validation={validation}\n onDateChanged={onChange}\n />\n )\n }\n formatWeekDay={(day) => day.slice(0, 1)}\n isClearable={isClearable}\n dateFormat={dateFormat}\n onCalendarClose={handleClose}\n onCalendarOpen={handleOpen}\n shouldCloseOnSelect={shouldCloseOnSelect}\n dayClassName={(date) => getDayClasses(variant, date)}\n renderCustomHeader={({ date, decreaseMonth, increaseMonth, increaseYear, decreaseYear }) => (\n <div className=\"tw-flex tw-justify-between tw-pb-4 tw-px-0\">\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={decreaseYear}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretLeftDouble size={IconSize.Size20} />}\n />\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={decreaseMonth}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretLeft size={IconSize.Size20} />}\n />\n <p className=\"tw-font-sans tw-font-semibold tw-grow tw-self-center\">\n {format(date, 'MMMM')} {getYear(date)}\n </p>\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={increaseMonth}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretRight size={IconSize.Size20} />}\n />\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={increaseYear}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretRightDouble size={IconSize.Size20} />}\n />\n </div>\n )}\n >\n {children}\n </DatepickerComponent>\n </div>\n );\n};\nDatePicker.displayName = 'FondueDatePicker';\n"],"names":["getDayClasses","variant","date","DatePicker","placeHolder","isClearable","shouldCloseOnSelect","onChange","onOpen","onClose","onBlur","dateFormat","value","startDate","endDate","minDate","maxDate","validation","Validation","customTrigger","children","React","hasPopperArrow","filterDate","isCalendarOpen","setIsCalendarOpen","useState","handleOpen","handleClose","DatepickerComponent","DatePickerTrigger","day","decreaseMonth","increaseMonth","increaseYear","decreaseYear","Button","ButtonStyle","ButtonSize","ButtonEmphasis","IconCaretLeftDouble","IconSize","IconCaretLeft","format","getYear","IconCaretRight","IconCaretRightDouble"],"mappings":";;;;;;;;;;;;;AA6CA,MAAMA,IAAgB,CAACC,GAAqCC,MACpDD,MAAY,WACLC,IAAO,IAAI,SAAS,cAAc,gBAEtC,aAGEC,IAAkC,CAAC;AAAA,EAC5C,aAAAC,IAAc;AAAA,EACd,aAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC,IAAaC,EAAW;AAAA,EACxB,eAAAC;AAAA,EACA,UAAAC,IAAa,gBAAAC,EAAA,cAAAA,EAAA,UAAA,IAAA;AAAA,EACb,gBAAAC,IAAiB;AAAA,EACjB,YAAAC,IA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A,UACjB,SAASH;AAAA,UACT,UAAUI,EAAe;AAAA,UACzB,MAAM,gBAAAlB,EAAA,cAACmB,GAAoB,EAAA,MAAMC,EAAS,QAAQ;AAAA,QAAA;AAAA,MAEtD,GAAA,gBAAApB,EAAA;AAAA,QAACe;AAAA,QAAA;AAAA,UACG,OAAOC,EAAY;AAAA,UACnB,MAAMC,EAAW;AAAA,UACjB,SAASN;AAAA,UACT,UAAUO,EAAe;AAAA,UACzB,MAAM,gBAAAlB,EAAA,cAACqB,GAAc,EAAA,MAAMD,EAAS,QAAQ;AAAA,QAAA;AAAA,MAAA,GAEhD,gBAAApB,EAAA,cAAC,KAAE,EAAA,WAAU,uDACR,GAAAsB,EAAOzC,GAAM,MAAM,GAAE,KAAE0C,EAAQ1C,CAAI,CACxC,GACA,gBAAAmB,EAAA;AAAA,QAACe;AAAA,QAAA;AAAA,UACG,OAAOC,EAAY;AAAA,UACnB,MAAMC,EAAW;AAAA,UACjB,SAASL;AAAA,UACT,UAAUM,EAAe;AAAA,UACzB,MAAM,gBAAAlB,EAAA,cAACwB,GAAe,EAAA,MAAMJ,EAAS,QAAQ;AAAA,QAAA;AAAA,MAEjD,GAAA,gBAAApB,EAAA;AAAA,QAACe;AAAA,QAAA;AAAA,UACG,OAAOC,EAAY;AAAA,UACnB,MAAMC,EAAW;AAAA,UACjB,SAASJ;AAAA,UACT,UAAUK,EAAe;AAAA,UACzB,MAAM,gBAAAlB,EAAA,cAACyB,GAAqB,EAAA,MAAML,EAAS,QAAQ;AAAA,QAAA;AAAA,MAAA,CAE3D;AAAA,IAAA;AAAA,IAGHrB;AAAA,EAAA,CAET;AAER;AACAjB,EAAW,cAAc;"}
|
|
1
|
+
{"version":3,"file":"DatePicker.es.js","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Button, ButtonEmphasis, ButtonSize, ButtonStyle } from '@components/Button';\nimport { IconSize } from '@foundation/Icon/IconSize';\nimport { format, getYear } from 'date-fns';\nimport React, { forwardRef, useState } from 'react';\nimport DatepickerComponent, { ReactDatePicker } from 'react-datepicker';\nimport './DatePicker.css';\nimport { DatePickerTrigger } from './DatePickerTrigger';\nimport { IconCaretLeft, IconCaretLeftDouble, IconCaretRight, IconCaretRightDouble } from '@foundation/Icon/Generated';\nimport { Validation } from '@utilities/validation';\n\ntype SingleDatePickerProps = {\n variant?: 'single';\n onChange: (date: Date | null) => void;\n startDate?: null;\n endDate?: null;\n};\n\ntype RangeDatePickerProps = {\n variant: 'range';\n onChange: (date: [Date | null, Date | null] | null) => void;\n startDate: Date | null;\n endDate: Date | null;\n};\n\nexport type DatePickerProps = {\n placeHolder?: string;\n isClearable?: boolean;\n shouldCloseOnSelect?: boolean;\n dateFormat?: string;\n /** @description when the variant is of type 'range', the value should be the startDate */\n value?: Date | null;\n minDate?: Date;\n maxDate?: Date;\n validation?: Validation;\n customTrigger?: React.ReactNode;\n children?: React.ReactNode;\n hasPopperArrow?: boolean;\n preventOpenOnFocus?: boolean;\n filterDate?: (date: Date) => boolean;\n onOpen?: () => void;\n onClose?: () => void;\n onBlur?: () => void;\n onKeyDown?: (event: React.KeyboardEvent<HTMLDivElement>) => void;\n} & (SingleDatePickerProps | RangeDatePickerProps);\n\nconst getDayClasses = (variant: DatePickerProps['variant'], date: Date) => {\n if (variant === 'single') {\n return date < new Date() ? 'past-date' : 'future-date';\n }\n return 'range-day';\n};\n\nexport type ReactDatePickerRef = ReactDatePicker<never, boolean>;\n\nexport const DatePicker = forwardRef<ReactDatePicker<never, boolean>, DatePickerProps>(\n (\n {\n placeHolder = 'Select a date',\n isClearable,\n shouldCloseOnSelect,\n onChange,\n onOpen,\n onClose,\n onBlur,\n onKeyDown,\n dateFormat = 'dd MMM yyyy',\n value,\n startDate,\n endDate,\n minDate,\n maxDate,\n validation = Validation.Default,\n customTrigger,\n children = <></>,\n hasPopperArrow = true,\n preventOpenOnFocus = false,\n filterDate = () => true,\n variant = 'single',\n },\n ref,\n ) => {\n const [isCalendarOpen, setIsCalendarOpen] = useState<boolean>(false);\n\n const handleOpen = () => {\n setIsCalendarOpen(true);\n onOpen?.();\n };\n\n const handleClose = () => {\n setIsCalendarOpen(false);\n onClose?.();\n };\n\n return (\n <div data-test-id=\"date-picker\">\n <DatepickerComponent\n calendarClassName=\"tw-rounded-sm tw-border tw-border-line-x-strong react-datepicker-wrap\"\n selected={value}\n startDate={startDate}\n endDate={endDate}\n minDate={minDate}\n maxDate={maxDate}\n calendarStartDay={1}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onBlur={onBlur}\n selectsRange={variant === 'range' ? true : false}\n showPopperArrow={hasPopperArrow}\n preventOpenOnFocus={preventOpenOnFocus}\n filterDate={filterDate}\n customInput={\n customTrigger ?? (\n <DatePickerTrigger\n isCalendarOpen={isCalendarOpen}\n isClearable={isClearable}\n placeHolder={placeHolder}\n validation={validation}\n onDateChanged={onChange}\n />\n )\n }\n ref={ref}\n formatWeekDay={(day) => day.slice(0, 1)}\n isClearable={isClearable}\n dateFormat={dateFormat}\n onCalendarClose={handleClose}\n onCalendarOpen={handleOpen}\n shouldCloseOnSelect={shouldCloseOnSelect}\n dayClassName={(date) => getDayClasses(variant, date)}\n renderCustomHeader={({ date, decreaseMonth, increaseMonth, increaseYear, decreaseYear }) => (\n <div className=\"tw-flex tw-justify-between tw-pb-4 tw-px-0\">\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={decreaseYear}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretLeftDouble size={IconSize.Size20} />}\n />\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={decreaseMonth}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretLeft size={IconSize.Size20} />}\n />\n <p className=\"tw-font-sans tw-font-semibold tw-grow tw-self-center\">\n {format(date, 'MMMM')} {getYear(date)}\n </p>\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={increaseMonth}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretRight size={IconSize.Size20} />}\n />\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={increaseYear}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretRightDouble size={IconSize.Size20} />}\n />\n </div>\n )}\n >\n {children}\n </DatepickerComponent>\n </div>\n );\n },\n);\n\nDatePicker.displayName = 'FondueDatePicker';\n"],"names":["getDayClasses","variant","date","DatePicker","forwardRef","placeHolder","isClearable","shouldCloseOnSelect","onChange","onOpen","onClose","onBlur","onKeyDown","dateFormat","value","startDate","endDate","minDate","maxDate","validation","Validation","customTrigger","children","React","hasPopperArrow","preventOpenOnFocus","filterDate","ref","isCalendarOpen","setIsCalendarOpen","useState","handleOpen","handleClose","DatepickerComponent","DatePickerTrigger","day","decreaseMonth","increaseMonth","increaseYear","decreaseYear","Button","ButtonStyle","ButtonSize","ButtonEmphasis","IconCaretLeftDouble","IconSize","IconCaretLeft","format","getYear","IconCaretRight","IconCaretRightDouble"],"mappings":";;;;;;;;;;;;;AA+CA,MAAMA,IAAgB,CAACC,GAAqCC,MACpDD,MAAY,WACLC,IAAO,IAAI,SAAS,cAAc,gBAEtC,aAKEC,IAAaC;AAAA,EACtB,CACI;AAAA,IACI,aAAAC,IAAc;AAAA,IACd,aAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,SAAAC;AAAA,IACA,SAAAC;AAAA,IACA,YAAAC,IAAaC,EAAW;AAAA,IACxB,eAAAC;AAAA,IACA,UAAAC,IAAa,gBAAAC,EAAA,cAAAA,EAAA,UAAA,IAAA;AAAA,IACb,gBAAAC,IAAiB;AAAA,IACjB,oBAAAC,IAAqB;AAAA,IACrB,YAA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-
import { FOCUS_VISIBLE_STYLE as
|
|
4
|
-
import { merge as
|
|
2
|
+
import { useLink as ce } from "@react-aria/link";
|
|
3
|
+
import { FOCUS_VISIBLE_STYLE as me } from "../../utilities/focusStyle.es.js";
|
|
4
|
+
import { merge as w } from "../../utilities/merge.es.js";
|
|
5
5
|
import t, { useState as E, useRef as D, useMemo as pe, useCallback as g, useEffect as V, useLayoutEffect as ue, cloneElement as C } from "react";
|
|
6
6
|
import { BrightHeader as be, brightHeaderArrowBackgroundColors as T } from "./BrightHeader.es.js";
|
|
7
7
|
import { usePopper as Ee } from "react-popper";
|
|
@@ -29,34 +29,34 @@ const he = {
|
|
|
29
29
|
["Right-Middle"]: "right",
|
|
30
30
|
["Bottom-Middle"]: "bottom",
|
|
31
31
|
["Left-Middle"]: "left"
|
|
32
|
-
}, ke = (e,
|
|
32
|
+
}, ke = (e, o, l) => {
|
|
33
33
|
switch (!0) {
|
|
34
34
|
case e.toString().includes("Top".toLowerCase()):
|
|
35
35
|
return "before:tw-border-t-0 before:tw-border-l-0 tw-bottom-[-6px] before:tw-dark before:tw-bg-base";
|
|
36
36
|
case e.toString().includes("Right".toLowerCase()):
|
|
37
|
-
return
|
|
37
|
+
return w([
|
|
38
38
|
"before:tw-border-t-0 before:tw-border-r-0 tw-left-[-5px]",
|
|
39
|
-
|
|
39
|
+
o && l === "Start" && e.toString().includes("Start".toLowerCase()) ? T[o] : "before:tw-dark before:tw-bg-base"
|
|
40
40
|
]);
|
|
41
41
|
case e.toString().includes("Bottom".toLowerCase()):
|
|
42
|
-
return
|
|
42
|
+
return w([
|
|
43
43
|
"before:tw-border-b-0 before:tw-border-r-0 tw-top-[-6px]",
|
|
44
|
-
|
|
44
|
+
o ? T[o] : "before:tw-dark before:tw-bg-base"
|
|
45
45
|
]);
|
|
46
46
|
case e.toString().includes("Left".toLowerCase()):
|
|
47
|
-
return
|
|
47
|
+
return w([
|
|
48
48
|
"before:tw-border-b-0 before:tw-border-l-0 tw-right-[-5px]",
|
|
49
|
-
|
|
49
|
+
o && l === "Start" && e.toString().includes("Start".toLowerCase()) ? T[o] : "before:tw-dark before:tw-bg-base"
|
|
50
50
|
]);
|
|
51
51
|
default:
|
|
52
52
|
return "before:tw-border-b-0 before:tw-border-r-0 tw-top-[-6px] before:tw-dark before:tw-bg-base";
|
|
53
53
|
}
|
|
54
54
|
}, xe = ({
|
|
55
55
|
content: e,
|
|
56
|
-
tooltipIcon:
|
|
57
|
-
heading:
|
|
56
|
+
tooltipIcon: o,
|
|
57
|
+
heading: l,
|
|
58
58
|
headingIcon: S,
|
|
59
|
-
linkUrl:
|
|
59
|
+
linkUrl: m,
|
|
60
60
|
linkLabel: Q,
|
|
61
61
|
brightHeader: p,
|
|
62
62
|
buttons: s,
|
|
@@ -75,17 +75,17 @@ const he = {
|
|
|
75
75
|
var _;
|
|
76
76
|
const [L, P] = E(
|
|
77
77
|
null
|
|
78
|
-
), N = D(null), a = A || Z, { linkProps: H } =
|
|
79
|
-
() =>
|
|
80
|
-
[
|
|
81
|
-
), ee = he[`${y}-${B}`], [u, te] = E(null), [h,
|
|
78
|
+
), N = D(null), a = A || Z, { linkProps: H } = ce({ isDisabled: a }, N), U = pe(
|
|
79
|
+
() => m || p || s || l || S,
|
|
80
|
+
[m, p, s, l, S]
|
|
81
|
+
), ee = he[`${y}-${B}`], [u, te] = E(null), [h, re] = E(null), [oe, se] = E(null), O = ge(), f = Ee(L, u, {
|
|
82
82
|
placement: ee,
|
|
83
83
|
strategy: "fixed",
|
|
84
84
|
modifiers: [
|
|
85
85
|
{
|
|
86
86
|
name: "arrow",
|
|
87
87
|
options: {
|
|
88
|
-
element:
|
|
88
|
+
element: oe
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
{
|
|
@@ -99,47 +99,47 @@ const he = {
|
|
|
99
99
|
enabled: X
|
|
100
100
|
}
|
|
101
101
|
]
|
|
102
|
-
}), ae = ((_ =
|
|
103
|
-
|
|
102
|
+
}), ae = ((_ = f.state) == null ? void 0 : _.placement) ?? y, ne = ke(ae, p, B), [i, d] = E(!1), n = D(null), le = g(() => {
|
|
103
|
+
n.current && clearTimeout(n.current), n.current = setTimeout(() => d(!1), z);
|
|
104
104
|
}, [z]), F = g(() => {
|
|
105
|
-
if (
|
|
106
|
-
|
|
105
|
+
if (n.current && clearTimeout(n.current), x) {
|
|
106
|
+
n.current = setTimeout(() => d(!0), x);
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
d(!0);
|
|
110
110
|
}, [x]), ie = g(
|
|
111
|
-
(
|
|
112
|
-
var
|
|
113
|
-
const b =
|
|
111
|
+
(r) => {
|
|
112
|
+
var c;
|
|
113
|
+
const b = r.path ?? ((c = r.composedPath) == null ? void 0 : c.call(r));
|
|
114
114
|
b && [L, h, u].some((fe) => b.includes(fe)) && F();
|
|
115
115
|
},
|
|
116
116
|
[F, L, h, u]
|
|
117
117
|
), de = g(
|
|
118
|
-
(
|
|
119
|
-
const { relatedTarget: b } =
|
|
120
|
-
(!b || ![u, h].some((
|
|
118
|
+
(r) => {
|
|
119
|
+
const { relatedTarget: b } = r;
|
|
120
|
+
(!b || ![u, h].some((c) => c == null ? void 0 : c.contains(b))) && d(!1);
|
|
121
121
|
},
|
|
122
122
|
[u, h]
|
|
123
123
|
), I = a ? {} : {
|
|
124
|
-
onMouseOver: (
|
|
124
|
+
onMouseOver: (r) => ie(r.nativeEvent),
|
|
125
125
|
onMouseLeave: le,
|
|
126
|
-
onFocus: () =>
|
|
126
|
+
onFocus: () => d(!0),
|
|
127
127
|
onBlur: de
|
|
128
128
|
};
|
|
129
129
|
V(() => {
|
|
130
|
-
|
|
130
|
+
n.current && clearTimeout(n.current), d(a ? !1 : M);
|
|
131
131
|
}, [M, a]);
|
|
132
132
|
const k = g(
|
|
133
|
-
(
|
|
134
|
-
|
|
133
|
+
(r) => {
|
|
134
|
+
i && r.key === "Escape" && d(!1);
|
|
135
135
|
},
|
|
136
|
-
[
|
|
136
|
+
[i]
|
|
137
137
|
);
|
|
138
138
|
return ue(() => {
|
|
139
|
-
typeof
|
|
140
|
-
}, [
|
|
139
|
+
typeof f.update == "function" && i && f.update();
|
|
140
|
+
}, [i]), V(() => (i ? window.addEventListener("keydown", k) : window.removeEventListener("keydown", k), () => {
|
|
141
141
|
window.removeEventListener("keydown", k);
|
|
142
|
-
}), [k,
|
|
142
|
+
}), [k, i]), /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("div", { ...I, ref: re }, R && C(R, {
|
|
143
143
|
ref: P,
|
|
144
144
|
"aria-describedby": O,
|
|
145
145
|
"aria-disabled": a
|
|
@@ -148,39 +148,39 @@ const he = {
|
|
|
148
148
|
{
|
|
149
149
|
ref: te,
|
|
150
150
|
"aria-hidden": a,
|
|
151
|
-
className:
|
|
151
|
+
className: w([
|
|
152
152
|
"tw-popper-container tw-inline-block tw-max-w-[200px] tw-dark tw-bg-base tw-rounded-md tw-shadow-mid tw-text-text tw-z-[120000]",
|
|
153
|
-
!
|
|
153
|
+
!i && "tw-opacity-0 tw-h-0 tw-w-0 tw-overflow-hidden"
|
|
154
154
|
]),
|
|
155
155
|
"data-test-id": "tooltip",
|
|
156
156
|
role: "tooltip",
|
|
157
157
|
id: O,
|
|
158
|
-
style:
|
|
159
|
-
...
|
|
158
|
+
style: f.styles.popper,
|
|
159
|
+
...f.attributes.popper,
|
|
160
160
|
...I
|
|
161
161
|
},
|
|
162
162
|
p && /* @__PURE__ */ t.createElement(be, { headerStyle: p }),
|
|
163
163
|
/* @__PURE__ */ t.createElement(
|
|
164
164
|
"div",
|
|
165
165
|
{
|
|
166
|
-
className:
|
|
166
|
+
className: w([
|
|
167
167
|
"tw-px-4 tw-dark tw-bg-base tw-rounded-md tw-relative tw-z-[120000]",
|
|
168
168
|
U ? J.small : J.large,
|
|
169
|
-
|
|
169
|
+
m ? K.small : K.large
|
|
170
170
|
])
|
|
171
171
|
},
|
|
172
|
-
|
|
173
|
-
/* @__PURE__ */ t.createElement("div", { className: "tw-flex" },
|
|
174
|
-
|
|
172
|
+
l && /* @__PURE__ */ t.createElement("h4", { className: "tw-flex tw-text-m tw-font-bold tw-mb-1" }, S && /* @__PURE__ */ t.createElement("span", { className: "tw-mr-1.5" }, C(S, { size: $.Size20 })), l),
|
|
173
|
+
/* @__PURE__ */ t.createElement("div", { className: "tw-flex" }, o && /* @__PURE__ */ t.createElement("span", { className: "tw-shrink-0 tw-mr-1 tw-leading-4" }, C(o, { size: $.Size16 })), /* @__PURE__ */ t.createElement("span", { className: "tw-text-s tw-min-w-0 tw-break-words" }, e)),
|
|
174
|
+
m && /* @__PURE__ */ t.createElement(
|
|
175
175
|
"a",
|
|
176
176
|
{
|
|
177
177
|
...H,
|
|
178
178
|
"data-test-id": "tooltip-link",
|
|
179
179
|
ref: N,
|
|
180
|
-
href:
|
|
180
|
+
href: m,
|
|
181
181
|
target: "_blank",
|
|
182
182
|
rel: "noopener noreferrer",
|
|
183
|
-
className:
|
|
183
|
+
className: w(["tw-text-xs tw-text-black-40 tw-underline tw-mt-1", me])
|
|
184
184
|
},
|
|
185
185
|
Q ?? "Click here to learn more."
|
|
186
186
|
),
|
|
@@ -212,8 +212,8 @@ const he = {
|
|
|
212
212
|
"data-test-id": "popover-arrow",
|
|
213
213
|
"data-popper-arrow": v,
|
|
214
214
|
ref: se,
|
|
215
|
-
style:
|
|
216
|
-
className:
|
|
215
|
+
style: f.styles.arrow,
|
|
216
|
+
className: w([
|
|
217
217
|
v && "tw-popper-arrow tw-z-[110000] tw-absolute tw-w-3 tw-h-3 tw-pointer-events-none before:tw-absolute before:tw-w-3 before:tw-h-3 before:tw-rotate-45 before:tw-border before:tw-border-line",
|
|
218
218
|
v && ne
|
|
219
219
|
])
|