@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 a=require("./jsx-runtime-BB_1_6y_.cjs"),j=require("./button-DVrteFz9.cjs"),m=require("./calendar-CpUN6BGK.cjs"),q=require("./combobox-BalI1GHE.cjs"),p=require("./popover-cGp_rNLg.cjs"),o=require("react");function L(c,n,u){return m.addDays(c,-n,u)}function P({dateRange:c,onDateRangeChange:n,labels:u,combobox:R,calendar:v,"aria-invalid":h,disabled:D}){const x=o.useRef(null),d=o.useRef(void 0),[i,s]=o.useState(void 0),[g,r]=o.useState(!1),[l,C]=o.useState(c),t={...{last7Days:"Last 7 days",last30Days:"Last 30 days",last90Days:"Last 90 days",custom:"Custom",placeholder:"Date",cancel:"Cancel",apply:"Apply"},...u},E=e=>{const f=m.startOfDay(new Date),b={"7_days":7,"30_days":30,"90_days":90}[e];return b?{from:L(f,b),to:f}:{from:void 0,to:void 0}},y=e=>{s(d.current),r(!1)},S=e=>{if(e==="custom"){d.current=i,s(e),r(!0);return}s(e),n(E(e))},k=()=>{if(l?.from&&l?.to){n(l),s("custom"),r(!1);return}s(d.current),r(!1)};return a.jsxRuntimeExports.jsxs(a.jsxRuntimeExports.Fragment,{children:[a.jsxRuntimeExports.jsx(q.Combobox,{alwaysShowPlaceholder:!0,selectedFeedback:"check",icon:"calendar_today",options:[{label:t.last7Days,value:"7_days"},{label:t.last30Days,value:"30_days"},{label:t.last90Days,value:"90_days"},{label:t.custom,value:"custom"}],labels:{placeholder:t.placeholder},value:i,onValueChange:S,"aria-invalid":h,disabled:D,ref:e=>{x.current=e},...R}),a.jsxRuntimeExports.jsxs(p.Popover,{open:g,onOpenChange:e=>{!e&&i==="custom"&&y()},children:[a.jsxRuntimeExports.jsx(p.PopoverAnchor,{virtualRef:x}),a.jsxRuntimeExports.jsxs(p.PopoverContent,{align:"start",children:[a.jsxRuntimeExports.jsx(m.Calendar,{required:!0,mode:"range",selected:l,onSelect:C,captionLayout:"dropdown",classNames:{root:"adm:p-0!"},...v}),a.jsxRuntimeExports.jsxs("div",{className:"adm:mt-2 adm:flex adm:justify-end adm:gap-2",children:[a.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:()=>y(),children:t.cancel}),a.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:k,children:t.apply})]})]})]})]})}exports.DatePickerSelector=P;
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 h } from "./button-B0lWuG-D.js";
3
- import { b as _, C as P, s as O } from "./calendar-CfqtuOWv.js";
4
- import { C as S } from "./combobox-CtSJw4m1.js";
5
- import { P as A, c as B, b as F } from "./popover-DcQ18EVl.js";
6
- import { useRef as v, useState as u } from "react";
7
- function M(n, o, c) {
8
- return _(n, -o, c);
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 H({
11
- dateRange: n,
12
- onDateRangeChange: o,
13
- labels: c,
14
- combobox: b,
15
- calendar: x,
16
- "aria-invalid": C,
17
- disabled: D
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 m = v(null), d = v(void 0), [i, t] = u(void 0), [j, l] = u(!1), [r, g] = u(n), s = { ...{
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
- }, ...c }, R = (a) => {
28
- const y = O(/* @__PURE__ */ new Date()), f = {
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 f ? { from: M(y, f), to: y } : { from: void 0, to: void 0 };
34
- }, p = (a) => {
35
- t(d.current), l(!1);
36
- }, k = (a) => {
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
- d.current = i, t(a), l(!0);
51
+ m.current = p, t(a), c(!0);
39
52
  return;
40
53
  }
41
- t(a), o(R(a));
42
- }, L = () => {
43
- if (r?.from && r?.to) {
44
- o(r), t("custom"), l(!1);
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(d.current), l(!1);
60
+ t(m.current), c(!1);
48
61
  };
49
62
  return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
50
63
  /* @__PURE__ */ e.jsx(
51
- S,
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: i,
64
- onValueChange: k,
65
- "aria-invalid": C,
66
- disabled: D,
76
+ value: p,
77
+ onValueChange: T,
78
+ "aria-invalid": g,
79
+ disabled: _,
67
80
  ref: (a) => {
68
- m.current = a;
81
+ f.current = a;
69
82
  },
70
- ...b
83
+ ...C
71
84
  }
72
85
  ),
73
86
  /* @__PURE__ */ e.jsxs(
74
- A,
87
+ w,
75
88
  {
76
- open: j,
89
+ open: k,
77
90
  onOpenChange: (a) => {
78
- !a && i === "custom" && p();
91
+ !a && p === "custom" && v();
79
92
  },
80
93
  children: [
81
- /* @__PURE__ */ e.jsx(B, { virtualRef: m }),
82
- /* @__PURE__ */ e.jsxs(F, { align: "start", children: [
94
+ /* @__PURE__ */ e.jsx(B, { virtualRef: f }),
95
+ /* @__PURE__ */ e.jsxs(M, { align: "start", children: [
83
96
  /* @__PURE__ */ e.jsx(
84
- P,
97
+ F,
85
98
  {
86
99
  required: !0,
87
100
  mode: "range",
88
- selected: r,
89
- onSelect: g,
101
+ selected: d,
102
+ onSelect: L,
90
103
  captionLayout: "dropdown",
91
104
  classNames: { root: "adm:p-0!" },
92
- ...x
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(h, { variant: "link", onClick: () => p(), children: s.cancel }),
97
- /* @__PURE__ */ e.jsx(h, { variant: "link", onClick: L, children: s.apply })
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
- H as DatePickerSelector
119
+ J as DatePickerSelector
107
120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamosuiteservices/ui",
3
- "version": "2.16.0",
3
+ "version": "2.16.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",