@adamosuiteservices/ui 2.16.0 → 2.16.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-BB_1_6y_.cjs"),j=require("./button-DVrteFz9.cjs"),s=require("./calendar-CpUN6BGK.cjs"),L=require("./combobox-BalI1GHE.cjs"),x=require("./popover-cGp_rNLg.cjs"),l=require("react");function R(c,u,m){return s.addDays(c,-u,m)}function T({dateRange:c,onDateRangeChange:u,labels:m,combobox:h,calendar:D,"aria-invalid":g,disabled:C}){const f=l.useRef(null),p=l.useRef(void 0),E=e=>{if(!e.from||!e.to)return;const r=s.startOfDay(new Date),b=[{value:"7_days",days:7},{value:"30_days",days:30},{value:"90_days",days:90}];for(const n of b){const q=R(r,n.days);if(s.startOfDay(e.from).getTime()===q.getTime()&&s.startOfDay(e.to).getTime()===r.getTime())return n.value}return"custom"},[y,o]=l.useState(()=>E(c)),[_,d]=l.useState(!1),[i,S]=l.useState(c),a={...{last7Days:"Last 7 days",last30Days:"Last 30 days",last90Days:"Last 90 days",custom:"Custom",placeholder:"Date",cancel:"Cancel",apply:"Apply"},...m},k=e=>{const r=s.startOfDay(new Date),n={"7_days":7,"30_days":30,"90_days":90}[e];return n?{from:R(r,n),to:r}:{from:void 0,to:void 0}},v=e=>{o(p.current),d(!1)},O=e=>{if(e==="custom"){p.current=y,o(e),d(!0);return}o(e),u(k(e))},P=()=>{if(i?.from&&i?.to){u(i),o("custom"),d(!1);return}o(p.current),d(!1)};return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(L.Combobox,{alwaysShowPlaceholder:!0,selectedFeedback:"check",icon:"calendar_today",options:[{label:a.last7Days,value:"7_days"},{label:a.last30Days,value:"30_days"},{label:a.last90Days,value:"90_days"},{label:a.custom,value:"custom"}],labels:{placeholder:a.placeholder},value:y,onValueChange:O,"aria-invalid":g,disabled:C,ref:e=>{f.current=e},...h}),t.jsxRuntimeExports.jsxs(x.Popover,{open:_,onOpenChange:e=>{!e&&y==="custom"&&v()},children:[t.jsxRuntimeExports.jsx(x.PopoverAnchor,{virtualRef:f}),t.jsxRuntimeExports.jsxs(x.PopoverContent,{align:"start",children:[t.jsxRuntimeExports.jsx(s.Calendar,{required:!0,mode:"range",selected:i,onSelect:S,captionLayout:"dropdown",classNames:{root:"adm:p-0!"},...D}),t.jsxRuntimeExports.jsxs("div",{className:"adm:mt-2 adm:flex adm:justify-end adm:gap-2",children:[t.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:()=>v(),children:a.cancel}),t.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:P,children:a.apply})]})]})]})]})}exports.DatePickerSelector=T;
|
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-BzflLqGi.js";
|
|
2
|
-
import { B as
|
|
3
|
-
import { b as
|
|
4
|
-
import { C as
|
|
5
|
-
import { P as
|
|
6
|
-
import { useRef as
|
|
7
|
-
function
|
|
8
|
-
return
|
|
2
|
+
import { B as b } from "./button-B0lWuG-D.js";
|
|
3
|
+
import { b as A, C as F, s as i } from "./calendar-CfqtuOWv.js";
|
|
4
|
+
import { C as V } from "./combobox-CtSJw4m1.js";
|
|
5
|
+
import { P as w, c as B, b as M } from "./popover-DcQ18EVl.js";
|
|
6
|
+
import { useRef as x, useState as y } from "react";
|
|
7
|
+
function D(l, n, u) {
|
|
8
|
+
return A(l, -n, u);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
dateRange:
|
|
12
|
-
onDateRangeChange:
|
|
13
|
-
labels:
|
|
14
|
-
combobox:
|
|
15
|
-
calendar:
|
|
16
|
-
"aria-invalid":
|
|
17
|
-
disabled:
|
|
10
|
+
function J({
|
|
11
|
+
dateRange: l,
|
|
12
|
+
onDateRangeChange: n,
|
|
13
|
+
labels: u,
|
|
14
|
+
combobox: C,
|
|
15
|
+
calendar: j,
|
|
16
|
+
"aria-invalid": g,
|
|
17
|
+
disabled: _
|
|
18
18
|
}) {
|
|
19
|
-
const
|
|
19
|
+
const f = x(null), m = x(void 0), R = (a) => {
|
|
20
|
+
if (!a.from || !a.to) return;
|
|
21
|
+
const o = i(/* @__PURE__ */ new Date()), h = [
|
|
22
|
+
{ value: "7_days", days: 7 },
|
|
23
|
+
{ value: "30_days", days: 30 },
|
|
24
|
+
{ value: "90_days", days: 90 }
|
|
25
|
+
];
|
|
26
|
+
for (const r of h) {
|
|
27
|
+
const S = D(o, r.days);
|
|
28
|
+
if (i(a.from).getTime() === S.getTime() && i(a.to).getTime() === o.getTime())
|
|
29
|
+
return r.value;
|
|
30
|
+
}
|
|
31
|
+
return "custom";
|
|
32
|
+
}, [p, t] = y(() => R(l)), [k, c] = y(!1), [d, L] = y(l), s = { ...{
|
|
20
33
|
last7Days: "Last 7 days",
|
|
21
34
|
last30Days: "Last 30 days",
|
|
22
35
|
last90Days: "Last 90 days",
|
|
@@ -24,31 +37,31 @@ function H({
|
|
|
24
37
|
placeholder: "Date",
|
|
25
38
|
cancel: "Cancel",
|
|
26
39
|
apply: "Apply"
|
|
27
|
-
}, ...
|
|
28
|
-
const
|
|
40
|
+
}, ...u }, P = (a) => {
|
|
41
|
+
const o = i(/* @__PURE__ */ new Date()), r = {
|
|
29
42
|
"7_days": 7,
|
|
30
43
|
"30_days": 30,
|
|
31
44
|
"90_days": 90
|
|
32
45
|
}[a];
|
|
33
|
-
return
|
|
34
|
-
},
|
|
35
|
-
t(
|
|
36
|
-
},
|
|
46
|
+
return r ? { from: D(o, r), to: o } : { from: void 0, to: void 0 };
|
|
47
|
+
}, v = (a) => {
|
|
48
|
+
t(m.current), c(!1);
|
|
49
|
+
}, T = (a) => {
|
|
37
50
|
if (a === "custom") {
|
|
38
|
-
|
|
51
|
+
m.current = p, t(a), c(!0);
|
|
39
52
|
return;
|
|
40
53
|
}
|
|
41
|
-
t(a),
|
|
42
|
-
},
|
|
43
|
-
if (
|
|
44
|
-
|
|
54
|
+
t(a), n(P(a));
|
|
55
|
+
}, O = () => {
|
|
56
|
+
if (d?.from && d?.to) {
|
|
57
|
+
n(d), t("custom"), c(!1);
|
|
45
58
|
return;
|
|
46
59
|
}
|
|
47
|
-
t(
|
|
60
|
+
t(m.current), c(!1);
|
|
48
61
|
};
|
|
49
62
|
return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
50
63
|
/* @__PURE__ */ e.jsx(
|
|
51
|
-
|
|
64
|
+
V,
|
|
52
65
|
{
|
|
53
66
|
alwaysShowPlaceholder: !0,
|
|
54
67
|
selectedFeedback: "check",
|
|
@@ -60,41 +73,41 @@ function H({
|
|
|
60
73
|
{ label: s.custom, value: "custom" }
|
|
61
74
|
],
|
|
62
75
|
labels: { placeholder: s.placeholder },
|
|
63
|
-
value:
|
|
64
|
-
onValueChange:
|
|
65
|
-
"aria-invalid":
|
|
66
|
-
disabled:
|
|
76
|
+
value: p,
|
|
77
|
+
onValueChange: T,
|
|
78
|
+
"aria-invalid": g,
|
|
79
|
+
disabled: _,
|
|
67
80
|
ref: (a) => {
|
|
68
|
-
|
|
81
|
+
f.current = a;
|
|
69
82
|
},
|
|
70
|
-
...
|
|
83
|
+
...C
|
|
71
84
|
}
|
|
72
85
|
),
|
|
73
86
|
/* @__PURE__ */ e.jsxs(
|
|
74
|
-
|
|
87
|
+
w,
|
|
75
88
|
{
|
|
76
|
-
open:
|
|
89
|
+
open: k,
|
|
77
90
|
onOpenChange: (a) => {
|
|
78
|
-
!a &&
|
|
91
|
+
!a && p === "custom" && v();
|
|
79
92
|
},
|
|
80
93
|
children: [
|
|
81
|
-
/* @__PURE__ */ e.jsx(B, { virtualRef:
|
|
82
|
-
/* @__PURE__ */ e.jsxs(
|
|
94
|
+
/* @__PURE__ */ e.jsx(B, { virtualRef: f }),
|
|
95
|
+
/* @__PURE__ */ e.jsxs(M, { align: "start", children: [
|
|
83
96
|
/* @__PURE__ */ e.jsx(
|
|
84
|
-
|
|
97
|
+
F,
|
|
85
98
|
{
|
|
86
99
|
required: !0,
|
|
87
100
|
mode: "range",
|
|
88
|
-
selected:
|
|
89
|
-
onSelect:
|
|
101
|
+
selected: d,
|
|
102
|
+
onSelect: L,
|
|
90
103
|
captionLayout: "dropdown",
|
|
91
104
|
classNames: { root: "adm:p-0!" },
|
|
92
|
-
...
|
|
105
|
+
...j
|
|
93
106
|
}
|
|
94
107
|
),
|
|
95
108
|
/* @__PURE__ */ e.jsxs("div", { className: "adm:mt-2 adm:flex adm:justify-end adm:gap-2", children: [
|
|
96
|
-
/* @__PURE__ */ e.jsx(
|
|
97
|
-
/* @__PURE__ */ e.jsx(
|
|
109
|
+
/* @__PURE__ */ e.jsx(b, { variant: "link", onClick: () => v(), children: s.cancel }),
|
|
110
|
+
/* @__PURE__ */ e.jsx(b, { variant: "link", onClick: O, children: s.apply })
|
|
98
111
|
] })
|
|
99
112
|
] })
|
|
100
113
|
]
|
|
@@ -103,5 +116,5 @@ function H({
|
|
|
103
116
|
] });
|
|
104
117
|
}
|
|
105
118
|
export {
|
|
106
|
-
|
|
119
|
+
J as DatePickerSelector
|
|
107
120
|
};
|