@tedi-design-system/react 18.2.0-rc.2 → 18.2.0-rc.4
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/bundle-stats.html +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/prop-types/external/react-is/index.cjs.js +1 -1
- package/external/prop-types/external/react-is/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/tedi/components/content/calendar/calendar.cjs.js +1 -1
- package/src/tedi/components/content/calendar/calendar.d.ts +39 -3
- package/src/tedi/components/content/calendar/calendar.es.js +121 -101
- package/src/tedi/components/content/calendar/calendar.module.scss.cjs.js +1 -1
- package/src/tedi/components/content/calendar/calendar.module.scss.es.js +5 -2
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.cjs.js +1 -1
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.d.ts +4 -2
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.es.js +42 -42
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.module.scss.cjs.js +1 -1
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.module.scss.es.js +1 -0
- package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field.d.ts +10 -1
- package/src/tedi/components/form/date-field/date-field.es.js +221 -218
- package/src/tedi/components/form/date-field/date-picker-modal/date-picker-modal.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-picker-modal/date-picker-modal.d.ts +3 -0
- package/src/tedi/components/form/date-field/date-picker-modal/date-picker-modal.es.js +41 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),J=require("../../../../../../external/classnames/index.cjs.js"),d=require("react"),Q=require("../../../base/typography/heading/heading.cjs.js"),C=require("../../../buttons/button/button.cjs.js"),U=require("../../../buttons/closing-button/closing-button.cjs.js"),W=require("../../../content/calendar/calendar.cjs.js"),X=require("../date-field-helpers.cjs.js"),u=require("./date-picker-modal.module.scss.cjs.js"),Z=require("../../../../providers/label-provider/use-labels.cjs.js"),c=require("../../../overlays/modal/modal.cjs.js"),$=require("../../../overlays/modal/modal-context.cjs.js"),D=(e,r)=>e instanceof Date?e:Array.isArray(e)&&e.length>0?[...e].sort((o,l)=>o.getTime()-l.getTime())[0]:e&&typeof e=="object"&&"from"in e&&e.from instanceof Date?e.from:e&&typeof e=="object"&&"to"in e&&e.to instanceof Date?e.to:r??new Date,v=({title:e})=>{const{labelId:r,onOpenChange:o}=$.useModal();return t.jsxs("div",{className:u.default["tedi-date-picker-modal__header"],children:[t.jsx(Q.Heading,{element:"h2",modifiers:"h4",id:r,className:u.default["tedi-date-picker-modal__title"],children:e}),t.jsx(U.ClosingButton,{size:"small",onClick:()=>o(!1)})]})},q=e=>{const{open:r,onOpenChange:o,value:l,onConfirm:S,mode:n="single",numberOfMonths:T,locale:_,localeCode:w,showOutsideDays:N=!0,disabledMatchers:A,required:p,availableDays:B,footer:O,monthYearSelectType:H,dayStatus:L,showNavigation:P,selectionLevel:f="days",initialView:y,initialMonth:g,modalProps:i,title:R,...V}=e,{getLabel:b}=Z.useLabels(),[a,m]=d.useState(l),[F,M]=d.useState(y??f),[I,j]=d.useState(()=>D(l,g));d.useEffect(()=>{r&&(m(l),M(y??f),j(D(l,g)))},[r,l,f,y,g]);const K=d.useCallback((s,h)=>{m(n==="range"?G=>X.resolveRangeSelection(s,G,h):s)},[n]),z=d.useCallback(s=>{m(h=>n==="range"?{from:s,to:void 0}:n==="multiple"?[...Array.isArray(h)?h:[],s]:s)},[n]),E=n==="multiple"?Array.isArray(a)&&a.length>0:n==="range"?!!a&&typeof a=="object"&&"from"in a&&a.from instanceof Date:a instanceof Date,k=p===!0&&!E,Y=()=>{k||(S(a),o(!1))},x=R??b(n==="range"?"date-field.modal-title-range":n==="multiple"?"date-field.modal-title-multiple":"date-field.modal-title");return t.jsx(c.Modal,{open:r,onToggle:o,children:t.jsxs(c.Modal.Content,{position:"center","aria-label":x,...i,md:{width:"max-content",...i==null?void 0:i.md},sm:{width:"full",...i==null?void 0:i.sm},className:J.default(u.default["tedi-date-picker-modal"],i==null?void 0:i.className),children:[t.jsx(c.Modal.Header,{children:t.jsx(v,{title:x})}),t.jsx(c.Modal.Body,{className:u.default["tedi-date-picker-modal__body"],children:t.jsx(W.Calendar,{...V,numberOfMonths:T,view:F,selectionLevel:f,currentMonth:I,setCurrentMonth:j,setView:M,mode:n,value:a,locale:_,localeCode:w,showOutsideDays:N,disabledMatchers:A,required:p,availableDays:B,footer:O,monthYearSelectType:H,dayStatus:L,showNavigation:P,handleSelect:K,applyValue:z,className:u.default["tedi-date-picker-modal__calendar"],bordered:!1})}),t.jsxs(c.Modal.Footer,{children:[t.jsx(C.Button,{visualType:"secondary",onClick:()=>o(!1),children:b("date-field.cancel")}),t.jsx(C.Button,{onClick:Y,disabled:k,children:b("date-field.confirm")})]})]})})};q.displayName="DatePickerModal";exports.DatePickerModal=q;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { DateRange, DayPickerProps, Locale, Matcher } from 'react-day-picker';
|
|
3
|
+
import { DayStatusFn } from '../../../content/calendar/calendar';
|
|
3
4
|
import { ModalContentProps } from '../../../overlays/modal';
|
|
4
5
|
import { CalendarView } from '../date-field';
|
|
5
6
|
type DateFieldMode = 'single' | 'multiple' | 'range';
|
|
@@ -27,6 +28,8 @@ export interface DatePickerModalProps extends Omit<DayPickerProps, 'mode' | 'sel
|
|
|
27
28
|
availableDays?: Date[] | ((date: Date) => boolean);
|
|
28
29
|
footer?: React.ReactNode;
|
|
29
30
|
monthYearSelectType?: 'dropdown' | 'grid';
|
|
31
|
+
/** Per-day status overlay forwarded to `Calendar`. */
|
|
32
|
+
dayStatus?: DayStatusFn;
|
|
30
33
|
showNavigation?: boolean;
|
|
31
34
|
selectionLevel?: CalendarView;
|
|
32
35
|
/** Grid the calendar opens on, independent of `selectionLevel`. Defaults to `selectionLevel`. */
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { jsx as o, jsxs as b } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { useState as g, useEffect as
|
|
4
|
-
import { Heading as
|
|
2
|
+
import Q from "../../../../../../external/classnames/index.es.js";
|
|
3
|
+
import { useState as g, useEffect as U, useCallback as w } from "react";
|
|
4
|
+
import { Heading as W } from "../../../base/typography/heading/heading.es.js";
|
|
5
5
|
import { Button as T } from "../../../buttons/button/button.es.js";
|
|
6
|
-
import { ClosingButton as
|
|
7
|
-
import { Calendar as
|
|
8
|
-
import { resolveRangeSelection as
|
|
6
|
+
import { ClosingButton as X } from "../../../buttons/closing-button/closing-button.es.js";
|
|
7
|
+
import { Calendar as Z } from "../../../content/calendar/calendar.es.js";
|
|
8
|
+
import { resolveRangeSelection as $ } from "../date-field-helpers.es.js";
|
|
9
9
|
import c from "./date-picker-modal.module.scss.es.js";
|
|
10
|
-
import { useLabels as
|
|
10
|
+
import { useLabels as v } from "../../../../providers/label-provider/use-labels.es.js";
|
|
11
11
|
import { Modal as d } from "../../../overlays/modal/modal.es.js";
|
|
12
|
-
import { useModal as
|
|
13
|
-
const _ = (e, n) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [...e].sort((a, l) => a.getTime() - l.getTime())[0] : e && typeof e == "object" && "from" in e && e.from instanceof Date ? e.from : e && typeof e == "object" && "to" in e && e.to instanceof Date ? e.to : n ?? /* @__PURE__ */ new Date(),
|
|
14
|
-
const { labelId: n, onOpenChange: a } =
|
|
12
|
+
import { useModal as ee } from "../../../overlays/modal/modal-context.es.js";
|
|
13
|
+
const _ = (e, n) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [...e].sort((a, l) => a.getTime() - l.getTime())[0] : e && typeof e == "object" && "from" in e && e.from instanceof Date ? e.from : e && typeof e == "object" && "to" in e && e.to instanceof Date ? e.to : n ?? /* @__PURE__ */ new Date(), te = ({ title: e }) => {
|
|
14
|
+
const { labelId: n, onOpenChange: a } = ee();
|
|
15
15
|
return /* @__PURE__ */ b("div", { className: c["tedi-date-picker-modal__header"], children: [
|
|
16
|
-
/* @__PURE__ */ o(
|
|
17
|
-
/* @__PURE__ */ o(
|
|
16
|
+
/* @__PURE__ */ o(W, { element: "h2", modifiers: "h4", id: n, className: c["tedi-date-picker-modal__title"], children: e }),
|
|
17
|
+
/* @__PURE__ */ o(X, { size: "small", onClick: () => a(!1) })
|
|
18
18
|
] });
|
|
19
|
-
},
|
|
19
|
+
}, ie = (e) => {
|
|
20
20
|
const {
|
|
21
21
|
open: n,
|
|
22
22
|
onOpenChange: a,
|
|
23
23
|
value: l,
|
|
24
24
|
onConfirm: A,
|
|
25
25
|
mode: t = "single",
|
|
26
|
-
numberOfMonths:
|
|
27
|
-
locale:
|
|
26
|
+
numberOfMonths: S,
|
|
27
|
+
locale: j,
|
|
28
28
|
localeCode: x,
|
|
29
29
|
showOutsideDays: O = !0,
|
|
30
30
|
disabledMatchers: B,
|
|
@@ -32,30 +32,31 @@ const _ = (e, n) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [
|
|
|
32
32
|
availableDays: H,
|
|
33
33
|
footer: L,
|
|
34
34
|
monthYearSelectType: V,
|
|
35
|
-
|
|
35
|
+
dayStatus: I,
|
|
36
|
+
showNavigation: K,
|
|
36
37
|
selectionLevel: m = "days",
|
|
37
38
|
initialView: h,
|
|
38
39
|
initialMonth: p,
|
|
39
40
|
modalProps: i,
|
|
40
|
-
title:
|
|
41
|
-
...
|
|
42
|
-
} = e, { getLabel: y } =
|
|
43
|
-
|
|
41
|
+
title: q,
|
|
42
|
+
...z
|
|
43
|
+
} = e, { getLabel: y } = v(), [r, f] = g(l), [E, C] = g(h ?? m), [F, D] = g(() => _(l, p));
|
|
44
|
+
U(() => {
|
|
44
45
|
n && (f(l), C(h ?? m), D(_(l, p)));
|
|
45
46
|
}, [n, l, m, h, p]);
|
|
46
|
-
const
|
|
47
|
+
const R = w(
|
|
47
48
|
(s, u) => {
|
|
48
|
-
f(t === "range" ? (
|
|
49
|
+
f(t === "range" ? (P) => $(s, P, u) : s);
|
|
49
50
|
},
|
|
50
51
|
[t]
|
|
51
|
-
),
|
|
52
|
+
), Y = w(
|
|
52
53
|
(s) => {
|
|
53
54
|
f((u) => t === "range" ? { from: s, to: void 0 } : t === "multiple" ? [...Array.isArray(u) ? u : [], s] : s);
|
|
54
55
|
},
|
|
55
56
|
[t]
|
|
56
|
-
),
|
|
57
|
+
), G = t === "multiple" ? Array.isArray(r) && r.length > 0 : t === "range" ? !!r && typeof r == "object" && "from" in r && r.from instanceof Date : r instanceof Date, M = k === !0 && !G, J = () => {
|
|
57
58
|
M || (A(r), a(!1));
|
|
58
|
-
}, N =
|
|
59
|
+
}, N = q ?? y(t === "range" ? "date-field.modal-title-range" : t === "multiple" ? "date-field.modal-title-multiple" : "date-field.modal-title");
|
|
59
60
|
return /* @__PURE__ */ o(d, { open: n, onToggle: a, children: /* @__PURE__ */ b(
|
|
60
61
|
d.Content,
|
|
61
62
|
{
|
|
@@ -64,22 +65,22 @@ const _ = (e, n) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [
|
|
|
64
65
|
...i,
|
|
65
66
|
md: { width: "max-content", ...i == null ? void 0 : i.md },
|
|
66
67
|
sm: { width: "full", ...i == null ? void 0 : i.sm },
|
|
67
|
-
className:
|
|
68
|
+
className: Q(c["tedi-date-picker-modal"], i == null ? void 0 : i.className),
|
|
68
69
|
children: [
|
|
69
|
-
/* @__PURE__ */ o(d.Header, { children: /* @__PURE__ */ o(
|
|
70
|
+
/* @__PURE__ */ o(d.Header, { children: /* @__PURE__ */ o(te, { title: N }) }),
|
|
70
71
|
/* @__PURE__ */ o(d.Body, { className: c["tedi-date-picker-modal__body"], children: /* @__PURE__ */ o(
|
|
71
|
-
|
|
72
|
+
Z,
|
|
72
73
|
{
|
|
73
|
-
...
|
|
74
|
-
numberOfMonths:
|
|
75
|
-
view:
|
|
74
|
+
...z,
|
|
75
|
+
numberOfMonths: S,
|
|
76
|
+
view: E,
|
|
76
77
|
selectionLevel: m,
|
|
77
|
-
currentMonth:
|
|
78
|
+
currentMonth: F,
|
|
78
79
|
setCurrentMonth: D,
|
|
79
80
|
setView: C,
|
|
80
81
|
mode: t,
|
|
81
82
|
value: r,
|
|
82
|
-
locale:
|
|
83
|
+
locale: j,
|
|
83
84
|
localeCode: x,
|
|
84
85
|
showOutsideDays: O,
|
|
85
86
|
disabledMatchers: B,
|
|
@@ -87,22 +88,23 @@ const _ = (e, n) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [
|
|
|
87
88
|
availableDays: H,
|
|
88
89
|
footer: L,
|
|
89
90
|
monthYearSelectType: V,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
dayStatus: I,
|
|
92
|
+
showNavigation: K,
|
|
93
|
+
handleSelect: R,
|
|
94
|
+
applyValue: Y,
|
|
93
95
|
className: c["tedi-date-picker-modal__calendar"],
|
|
94
96
|
bordered: !1
|
|
95
97
|
}
|
|
96
98
|
) }),
|
|
97
99
|
/* @__PURE__ */ b(d.Footer, { children: [
|
|
98
100
|
/* @__PURE__ */ o(T, { visualType: "secondary", onClick: () => a(!1), children: y("date-field.cancel") }),
|
|
99
|
-
/* @__PURE__ */ o(T, { onClick:
|
|
101
|
+
/* @__PURE__ */ o(T, { onClick: J, disabled: M, children: y("date-field.confirm") })
|
|
100
102
|
] })
|
|
101
103
|
]
|
|
102
104
|
}
|
|
103
105
|
) });
|
|
104
106
|
};
|
|
105
|
-
|
|
107
|
+
ie.displayName = "DatePickerModal";
|
|
106
108
|
export {
|
|
107
|
-
|
|
109
|
+
ie as DatePickerModal
|
|
108
110
|
};
|