@sth87/shadcn-design-system 0.0.7 → 0.0.8

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.
Files changed (95) hide show
  1. package/dist/cjs/components/DatePicker/DatePicker.cjs +1 -1
  2. package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
  3. package/dist/cjs/components/DatePicker/RangePicker.cjs +1 -1
  4. package/dist/cjs/components/DatePicker/RangePicker.cjs.map +1 -1
  5. package/dist/cjs/components/DatePicker/TimePicker.cjs +1 -1
  6. package/dist/cjs/components/DatePicker/TimePicker.cjs.map +1 -1
  7. package/dist/cjs/components/Glass/Glass.cjs.map +1 -1
  8. package/dist/cjs/components/Pagination/Pagination.cjs.map +1 -1
  9. package/dist/cjs/components/Slider/Slider.cjs.map +1 -1
  10. package/dist/cjs/components/Switch/Switch.cjs.map +1 -1
  11. package/dist/cjs/components/Table/TableFilter/data-table-date-filter.cjs.map +1 -1
  12. package/dist/cjs/components/Table/TableFilter/data-table-filter-popover.cjs.map +1 -1
  13. package/dist/cjs/components/Table/data-table-column-header.cjs.map +1 -1
  14. package/dist/cjs/components/Table/data-table-pagination.cjs.map +1 -1
  15. package/dist/cjs/components/Table/data-table.cjs.map +1 -1
  16. package/dist/cjs/components/Tabs/Tabs.cjs +1 -1
  17. package/dist/cjs/components/Tabs/Tabs.cjs.map +1 -1
  18. package/dist/cjs/components/Tour/Tour.cjs.map +1 -1
  19. package/dist/cjs/components/Upload/Upload.cjs.map +1 -1
  20. package/dist/esm/components/DatePicker/DatePicker.js +11 -11
  21. package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
  22. package/dist/esm/components/DatePicker/RangePicker.js +11 -11
  23. package/dist/esm/components/DatePicker/RangePicker.js.map +1 -1
  24. package/dist/esm/components/DatePicker/TimePicker.js +17 -17
  25. package/dist/esm/components/DatePicker/TimePicker.js.map +1 -1
  26. package/dist/esm/components/Glass/Glass.js.map +1 -1
  27. package/dist/esm/components/Pagination/Pagination.js.map +1 -1
  28. package/dist/esm/components/Slider/Slider.js.map +1 -1
  29. package/dist/esm/components/Switch/Switch.js.map +1 -1
  30. package/dist/esm/components/Table/TableFilter/data-table-date-filter.js.map +1 -1
  31. package/dist/esm/components/Table/TableFilter/data-table-filter-popover.js.map +1 -1
  32. package/dist/esm/components/Table/data-table-column-header.js.map +1 -1
  33. package/dist/esm/components/Table/data-table-pagination.js.map +1 -1
  34. package/dist/esm/components/Table/data-table.js.map +1 -1
  35. package/dist/esm/components/Tabs/Tabs.js +1 -1
  36. package/dist/esm/components/Tabs/Tabs.js.map +1 -1
  37. package/dist/esm/components/Tour/Tour.js.map +1 -1
  38. package/dist/esm/components/Upload/Upload.js.map +1 -1
  39. package/dist/types/components/Accordion/index.d.ts +1 -1
  40. package/dist/types/components/Accordion/index.d.ts.map +1 -1
  41. package/dist/types/components/Badge/index.d.ts +1 -2
  42. package/dist/types/components/Badge/index.d.ts.map +1 -1
  43. package/dist/types/components/Breadcrumb/index.d.ts +1 -1
  44. package/dist/types/components/Breadcrumb/index.d.ts.map +1 -1
  45. package/dist/types/components/Button/index.d.ts +2 -4
  46. package/dist/types/components/Button/index.d.ts.map +1 -1
  47. package/dist/types/components/Checkbox/index.d.ts +1 -2
  48. package/dist/types/components/Checkbox/index.d.ts.map +1 -1
  49. package/dist/types/components/Collapsible/index.d.ts +1 -2
  50. package/dist/types/components/Collapsible/index.d.ts.map +1 -1
  51. package/dist/types/components/DatePicker/DatePicker.d.ts +1 -1
  52. package/dist/types/components/DatePicker/DatePicker.d.ts.map +1 -1
  53. package/dist/types/components/DatePicker/TimePicker.d.ts +1 -1
  54. package/dist/types/components/DatePicker/TimePicker.d.ts.map +1 -1
  55. package/dist/types/components/Dialog/index.d.ts +1 -1
  56. package/dist/types/components/Dialog/index.d.ts.map +1 -1
  57. package/dist/types/components/Glass/Glass.d.ts +1 -1
  58. package/dist/types/components/Glass/Glass.d.ts.map +1 -1
  59. package/dist/types/components/Glass/index.d.ts +1 -1
  60. package/dist/types/components/Glass/index.d.ts.map +1 -1
  61. package/dist/types/components/Input/index.d.ts +1 -2
  62. package/dist/types/components/Input/index.d.ts.map +1 -1
  63. package/dist/types/components/InputOTP/index.d.ts +1 -2
  64. package/dist/types/components/InputOTP/index.d.ts.map +1 -1
  65. package/dist/types/components/Pagination/Pagination.d.ts +1 -1
  66. package/dist/types/components/Pagination/Pagination.d.ts.map +1 -1
  67. package/dist/types/components/Radio/index.d.ts +1 -2
  68. package/dist/types/components/Radio/index.d.ts.map +1 -1
  69. package/dist/types/components/ScrollArea/index.d.ts +1 -2
  70. package/dist/types/components/ScrollArea/index.d.ts.map +1 -1
  71. package/dist/types/components/Select/index.d.ts +1 -1
  72. package/dist/types/components/Select/index.d.ts.map +1 -1
  73. package/dist/types/components/Sheet/index.d.ts +1 -1
  74. package/dist/types/components/Sheet/index.d.ts.map +1 -1
  75. package/dist/types/components/Skeleton/index.d.ts +1 -2
  76. package/dist/types/components/Skeleton/index.d.ts.map +1 -1
  77. package/dist/types/components/Slider/index.d.ts +1 -2
  78. package/dist/types/components/Slider/index.d.ts.map +1 -1
  79. package/dist/types/components/Switch/index.d.ts +1 -2
  80. package/dist/types/components/Switch/index.d.ts.map +1 -1
  81. package/dist/types/components/Table/data-table-pagination.d.ts +1 -2
  82. package/dist/types/components/Table/data-table-pagination.d.ts.map +1 -1
  83. package/dist/types/components/Table/data-table.d.ts +1 -2
  84. package/dist/types/components/Table/data-table.d.ts.map +1 -1
  85. package/dist/types/components/Table/index.d.ts +2 -1
  86. package/dist/types/components/Table/index.d.ts.map +1 -1
  87. package/dist/types/components/Tabs/index.d.ts +1 -2
  88. package/dist/types/components/Tabs/index.d.ts.map +1 -1
  89. package/dist/types/components/Textarea/index.d.ts +1 -2
  90. package/dist/types/components/Textarea/index.d.ts.map +1 -1
  91. package/dist/types/components/Toggle/index.d.ts +1 -2
  92. package/dist/types/components/Toggle/index.d.ts.map +1 -1
  93. package/dist/types/components/Tour/Tour.d.ts +1 -1
  94. package/dist/types/components/Tour/Tour.d.ts.map +1 -1
  95. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),ge=require("react"),me=require("../../packages/ui/src/components/calendar.cjs"),T=require("../../packages/ui/src/components/popover.cjs"),m=require("../../packages/ui/src/components/drawer.cjs");require("@radix-ui/react-slot");require("../../packages/ui/src/components/button.cjs");require("../../packages/ui/src/components/button-group.cjs");require("../../packages/ui/src/components/input.cjs");require("../../packages/ui/src/components/textarea.cjs");require("@radix-ui/react-label");const q=require("../../packages/ui/src/lib/utils.cjs");require("../../packages/ui/src/components/select.cjs");require("../../packages/ui/src/components/combobox.cjs");require("@radix-ui/react-tooltip");require("@radix-ui/react-separator");require("../../packages/ui/src/components/switch.cjs");require("@radix-ui/react-scroll-area");require("../../packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("../../packages/ui/src/components/badge.cjs");const pe=require("lucide-react");require("../../packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("../../packages/ui/src/components/input-otp.cjs");require("../../packages/ui/src/components/radio-group.cjs");require("../../packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("../../packages/ui/src/components/tabs.cjs");require("../../packages/ui/src/components/toggle.cjs");const qe=require("../Input/Input.cjs"),ve=require("../Button/Button.cjs"),we=require("./TimePicker.cjs"),v=require("react-device-detect"),w=require("date-fns"),U=require("date-fns/locale"),K=require("../../constants/common.cjs");function be(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const b=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,b.get?b:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const M=be(ge);function he(s,n=K.DATE_FORMAT,t){return s?w.format(s,n,t?{locale:t}:void 0):""}const j=(s,n=K.DATE_FORMAT)=>{const t=w.parse(s,n,new Date);return w.isValid(t)?t:void 0};function xe(s){return s.replace(/dd|MM|yyyy/g,n=>{switch(n){case"dd":case"MM":return"99";case"yyyy":return"9999";default:return n}}).replace(/d|M|y/g,n=>{switch(n){case"d":case"M":return"9";case"y":return"9";default:return n}})}function ye({value:s,onChange:n,onSelect:t,calendarClassName:b,side:$="bottom",align:G="end",format:p="dd/MM/yyyy",language:J="vi",mask:z,closeOnSelect:Q=!1,calendarConfig:P,desktopMode:O="popover",mobileMode:W="drawer",showOutsideDays:X=!0,children:S,showTime:l=!1,timeFormat:h="HH:mm",hideDate:F=!1,numberOfMonths:Y=1,variant:Z="default",color:_="primary",timePickerMode:ee="wheel",hourInterval:re=1,minuteInterval:te=1,secondInterval:ne=1,disabledTimes:ie,disabledTimeRanges:se,showNowButton:ae=!1,nowButtonLabel:oe="Now",timePickerLabel:ue,...u}){let d,k;typeof p=="string"?(d=p,k=p):(d=p.input,k=p.output);let N;z===!0?N=xe(d):typeof z=="string"&&(N=z);const A=s?j(s,d):void 0,[I,x]=M.useState(!1),[a,c]=M.useState(A),[ce,y]=M.useState(A),[C,f]=M.useState(s||""),H=P?.locale?P?.locale:J==="en"?U.enUS:U.vi,R=v.isMobile?W:O,o=e=>{if(!e)return"";let r=he(e,k,H);return l&&(r+=` ${w.format(e,h)}`),r},le=e=>{c(e),f(o(e)),t?.(e,o(e))},de=e=>{if(!e){f(""),c(void 0),t?.(void 0,void 0);return}f(e);const r=j(e,d);r?(c(r),y(r),t?.(r,o(r))):(c(void 0),t?.(void 0,void 0))},fe=(e,r,D)=>{if(!D){n?.(e,r,void 0);return}const g=new Date(a||new Date);g.setHours(D.getHours(),D.getMinutes(),D.getSeconds(),0),c(g),f(o(g)),t?.(g,o(g)),n?.(e,o(g),g)},V=S?S({value:C,date:a,onSelect:le,onChange:de}):i.jsxs(ve.default,{variant:"ghost",className:"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors",size:u.size,children:[i.jsx(pe.CalendarIcon,{className:q.cn({"size-3":u.size==="xs"||u.size==="sm","size-3.5":!u.size||u.size==="normal","size-4":u.size==="lg"||u.size==="xl"})}),i.jsx("span",{className:"sr-only",children:"Select date"})]}),L=i.jsxs("div",{className:q.cn("flex items-stretch mx-auto w-full",l&&!F?"gap-0 md:max-w-lg":"",v.isMobile?"max-w-md md:max-w-md lg:max-w-lg":""),children:[!F&&i.jsx(me.Calendar,{...P,mode:"single",selected:a,captionLayout:"dropdown",month:ce,onMonthChange:y,numberOfMonths:v.isMobile?1:Y||1,variant:Z,color:_,onSelect:e=>{let r=e;e&&a&&l&&(r=new Date(e),r.setHours(a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds())),c(r),f(o(r)),t?.(r,o(r)),Q&&!l&&x(!1)},locale:H,formatters:{formatMonthDropdown:e=>e.toLocaleString(H.code,{month:"short"})},showOutsideDays:X,className:q.cn("my-auto bg-transparent mx-auto",{"[--cell-size:clamp(0px,calc(100vw/7.5),52px)] mb-8 bg-transparent":v.isMobile&&!l||O==="drawer","[--cell-size:clamp(0px,calc(100vw/7.5),34px)]":!v.isMobile&&O!=="drawer","w-full":R==="drawer"&&l},b)}),l&&i.jsx("div",{className:"border-l border-border",children:i.jsx(we.TimePicker,{value:a?w.format(a,h):void 0,format:h,onChange:fe,showHours:!0,showMinutes:!0,showSeconds:h==="HH:mm:ss",mode:ee,hourInterval:re,minuteInterval:te,secondInterval:ne,disabledTimes:ie,disabledTimeRanges:se,showNowButton:ae,nowButtonLabel:oe,timeLabel:ue,standalone:!1,color:_})})]}),B=i.jsxs(T.Popover,{open:I,onOpenChange:x,children:[i.jsx(T.PopoverTrigger,{asChild:!0,disabled:u.disabled,children:V}),i.jsx(T.PopoverContent,{className:q.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background/50"),side:$,align:G,children:L})]}),E=i.jsxs(m.Drawer,{open:I,onOpenChange:x,children:[i.jsx(m.DrawerTrigger,{asChild:!0,children:V}),i.jsxs(m.DrawerContent,{className:q.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background"),children:[i.jsxs(m.DrawerHeader,{className:"sr-only",children:[i.jsx(m.DrawerTitle,{children:"Select date"}),i.jsx(m.DrawerDescription,{children:"Set date"})]}),L]})]});return S?R==="drawer"?E:B:i.jsx(qe.default,{...u,clearable:!0,value:C,mask:N,onChange:e=>{f(e.target.value);const r=j(e.target.value,d);r?(c(r),y(r),t?.(r,o(r)),n?.(e,o(r),r)):(t?.(void 0,void 0),n?.(e,void 0,void 0))},onBlur:()=>{j(C,d)||(f(""),c(void 0),y(void 0),t?.(void 0,void 0))},onKeyDown:e=>{e.key==="ArrowDown"&&(e.preventDefault(),x(!0))},suffixIcon:R==="drawer"?E:B})}exports.DatePicker=ye;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),ge=require("react"),me=require("../../packages/ui/src/components/calendar.cjs"),T=require("../../packages/ui/src/components/popover.cjs"),m=require("../../packages/ui/src/components/drawer.cjs");require("@radix-ui/react-slot");require("../../packages/ui/src/components/button.cjs");require("../../packages/ui/src/components/button-group.cjs");require("../../packages/ui/src/components/input.cjs");require("../../packages/ui/src/components/textarea.cjs");require("@radix-ui/react-label");const q=require("../../packages/ui/src/lib/utils.cjs");require("../../packages/ui/src/components/select.cjs");require("../../packages/ui/src/components/combobox.cjs");require("@radix-ui/react-tooltip");require("@radix-ui/react-separator");require("../../packages/ui/src/components/switch.cjs");require("@radix-ui/react-scroll-area");require("../../packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("../../packages/ui/src/components/badge.cjs");const pe=require("lucide-react");require("../../packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("../../packages/ui/src/components/input-otp.cjs");require("../../packages/ui/src/components/radio-group.cjs");require("../../packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("../../packages/ui/src/components/tabs.cjs");require("../../packages/ui/src/components/toggle.cjs");const qe=require("./TimePicker.cjs"),v=require("react-device-detect"),w=require("date-fns"),U=require("date-fns/locale"),K=require("../../constants/common.cjs"),ve=require("../Button/Button.cjs"),we=require("../Input/Input.cjs");function be(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const b=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,b.get?b:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const M=be(ge);function he(s,n=K.DATE_FORMAT,t){return s?w.format(s,n,t?{locale:t}:void 0):""}const j=(s,n=K.DATE_FORMAT)=>{const t=w.parse(s,n,new Date);return w.isValid(t)?t:void 0};function xe(s){return s.replace(/dd|MM|yyyy/g,n=>{switch(n){case"dd":case"MM":return"99";case"yyyy":return"9999";default:return n}}).replace(/d|M|y/g,n=>{switch(n){case"d":case"M":return"9";case"y":return"9";default:return n}})}function ye({value:s,onChange:n,onSelect:t,calendarClassName:b,side:$="bottom",align:G="end",format:p="dd/MM/yyyy",language:J="vi",mask:z,closeOnSelect:Q=!1,calendarConfig:P,desktopMode:O="popover",mobileMode:W="drawer",showOutsideDays:X=!0,children:S,showTime:l=!1,timeFormat:h="HH:mm",hideDate:F=!1,numberOfMonths:Y=1,variant:Z="default",color:_="primary",timePickerMode:ee="wheel",hourInterval:re=1,minuteInterval:te=1,secondInterval:ne=1,disabledTimes:ie,disabledTimeRanges:se,showNowButton:ae=!1,nowButtonLabel:oe="Now",timePickerLabel:ue,...u}){let d,k;typeof p=="string"?(d=p,k=p):(d=p.input,k=p.output);let N;z===!0?N=xe(d):typeof z=="string"&&(N=z);const A=s?j(s,d):void 0,[I,x]=M.useState(!1),[a,c]=M.useState(A),[ce,y]=M.useState(A),[C,f]=M.useState(s||""),H=P?.locale?P?.locale:J==="en"?U.enUS:U.vi,R=v.isMobile?W:O,o=e=>{if(!e)return"";let r=he(e,k,H);return l&&(r+=` ${w.format(e,h)}`),r},le=e=>{c(e),f(o(e)),t?.(e,o(e))},de=e=>{if(!e){f(""),c(void 0),t?.(void 0,void 0);return}f(e);const r=j(e,d);r?(c(r),y(r),t?.(r,o(r))):(c(void 0),t?.(void 0,void 0))},fe=(e,r,D)=>{if(!D){n?.(e,r,void 0);return}const g=new Date(a||new Date);g.setHours(D.getHours(),D.getMinutes(),D.getSeconds(),0),c(g),f(o(g)),t?.(g,o(g)),n?.(e,o(g),g)},V=S?S({value:C,date:a,onSelect:le,onChange:de}):i.jsxs(ve.default,{variant:"ghost",className:"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors",size:u.size,children:[i.jsx(pe.CalendarIcon,{className:q.cn({"size-3":u.size==="xs"||u.size==="sm","size-3.5":!u.size||u.size==="normal","size-4":u.size==="lg"||u.size==="xl"})}),i.jsx("span",{className:"sr-only",children:"Select date"})]}),L=i.jsxs("div",{className:q.cn("flex items-stretch mx-auto w-full",l&&!F?"gap-0 md:max-w-lg":"",v.isMobile?"max-w-md md:max-w-md lg:max-w-lg":""),children:[!F&&i.jsx(me.Calendar,{...P,mode:"single",selected:a,captionLayout:"dropdown",month:ce,onMonthChange:y,numberOfMonths:v.isMobile?1:Y||1,variant:Z,color:_,onSelect:e=>{let r=e;e&&a&&l&&(r=new Date(e),r.setHours(a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds())),c(r),f(o(r)),t?.(r,o(r)),Q&&!l&&x(!1)},locale:H,formatters:{formatMonthDropdown:e=>e.toLocaleString(H.code,{month:"short"})},showOutsideDays:X,className:q.cn("my-auto bg-transparent mx-auto",{"[--cell-size:clamp(0px,calc(100vw/7.5),52px)] mb-8 bg-transparent":v.isMobile&&!l||O==="drawer","[--cell-size:clamp(0px,calc(100vw/7.5),34px)]":!v.isMobile&&O!=="drawer","w-full":R==="drawer"&&l},b)}),l&&i.jsx("div",{className:"border-l border-border",children:i.jsx(qe.TimePicker,{value:a?w.format(a,h):void 0,format:h,onChange:fe,showHours:!0,showMinutes:!0,showSeconds:h==="HH:mm:ss",mode:ee,hourInterval:re,minuteInterval:te,secondInterval:ne,disabledTimes:ie,disabledTimeRanges:se,showNowButton:ae,nowButtonLabel:oe,timeLabel:ue,standalone:!1,color:_})})]}),B=i.jsxs(T.Popover,{open:I,onOpenChange:x,children:[i.jsx(T.PopoverTrigger,{asChild:!0,disabled:u.disabled,children:V}),i.jsx(T.PopoverContent,{className:q.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background/50"),side:$,align:G,children:L})]}),E=i.jsxs(m.Drawer,{open:I,onOpenChange:x,children:[i.jsx(m.DrawerTrigger,{asChild:!0,children:V}),i.jsxs(m.DrawerContent,{className:q.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background"),children:[i.jsxs(m.DrawerHeader,{className:"sr-only",children:[i.jsx(m.DrawerTitle,{children:"Select date"}),i.jsx(m.DrawerDescription,{children:"Set date"})]}),L]})]});return S?R==="drawer"?E:B:i.jsx(we.default,{...u,clearable:!0,value:C,mask:N,onChange:e=>{f(e.target.value);const r=j(e.target.value,d);r?(c(r),y(r),t?.(r,o(r)),n?.(e,o(r),r)):(t?.(void 0,void 0),n?.(e,void 0,void 0))},onBlur:()=>{j(C,d)||(f(""),c(void 0),y(void 0),t?.(void 0,void 0))},onKeyDown:e=>{e.key==="ArrowDown"&&(e.preventDefault(),x(!0))},suffixIcon:R==="drawer"?E:B})}exports.DatePicker=ye;
2
2
  //# sourceMappingURL=DatePicker.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.cjs","sources":["../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n CalendarDayButton as SCalendarDayButton,\n type CalendarDayButtonProps as SCalendarDayButtonProps,\n Calendar,\n type CalendarProps,\n type CalendarColor,\n} from \"@dsui/ui/components/calendar\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@dsui/ui/components/popover\";\nimport {\n Drawer,\n DrawerContent,\n DrawerDescription,\n DrawerHeader,\n DrawerTitle,\n DrawerTrigger,\n} from \"@dsui/ui/components/drawer\";\nimport { cn } from \"@dsui/ui/index\";\nimport Input, { type InputProps } from \"../Input/Input\";\nimport Button from \"../Button/Button\";\nimport {\n TimePicker,\n type TimePickerMode,\n type DisabledTimeRange,\n} from \"./TimePicker\";\nimport { CalendarIcon } from \"lucide-react\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport { isMobile } from \"react-device-detect\";\nimport { format as dfFormat, parse, isValid, type Locale } from \"date-fns\";\nimport { vi, enUS } from \"date-fns/locale\";\nimport { DATE_FORMAT } from \"@/constants/common\";\n\nfunction formatDate(\n date: Date | undefined,\n outputFormat: string = DATE_FORMAT,\n locale?: Locale\n) {\n if (!date) return \"\";\n\n return dfFormat(date, outputFormat, locale ? { locale } : undefined);\n}\n\nconst parseDate = (\n str: string,\n inputFormat: string = DATE_FORMAT\n): Date | undefined => {\n const date = parse(str, inputFormat, new Date());\n return isValid(date) ? date : undefined;\n};\n\nfunction generateMaskFromFormat(format: string): string {\n return format\n .replace(/dd|MM|yyyy/g, (match) => {\n switch (match) {\n case \"dd\":\n case \"MM\":\n return \"99\";\n case \"yyyy\":\n return \"9999\";\n default:\n return match;\n }\n })\n .replace(/d|M|y/g, (match) => {\n switch (match) {\n case \"d\":\n case \"M\":\n return \"9\";\n case \"y\":\n return \"9\";\n default:\n return match;\n }\n });\n}\n\nexport type FormatType = string | { input: string; output: string };\n\nexport type DatePickerRenderProps = {\n value: string;\n date?: Date;\n onSelect: (date?: Date) => void;\n onChange: (text?: string) => void;\n};\n\nexport type DatePickerProps = Omit<\n InputProps,\n \"value\" | \"onChange\" | \"onSelect\" | \"mask\" | \"children\"\n> & {\n value?: string;\n onChange?: (\n event?: React.ChangeEvent<HTMLInputElement>,\n value?: string,\n date?: Date\n ) => void;\n onSelect?: (date?: Date, value?: string) => void;\n calendarClassName?: string;\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n align?: \"start\" | \"center\" | \"end\";\n size?: VariantProps<typeof Input>[\"size\"];\n format?: FormatType;\n language?: \"vi\" | \"en\";\n mask?: boolean | string;\n closeOnSelect?: boolean;\n calendarConfig?: CalendarProps;\n desktopMode?: \"popover\" | \"drawer\";\n mobileMode?: \"popover\" | \"drawer\";\n showOutsideDays?: boolean;\n children?: (props: DatePickerRenderProps) => React.ReactNode;\n showTime?: boolean;\n timeFormat?: \"HH:mm\" | \"HH:mm:ss\";\n hideDate?: boolean;\n numberOfMonths?: number;\n variant?: \"default\" | \"rounded\";\n color?: CalendarColor;\n\n // TimePicker configuration options\n timePickerMode?: TimePickerMode; // Display mode: 'wheel' (default), 'select', 'compact'\n hourInterval?: number; // Hour interval (e.g., 1, 2, 3) - defaults to 1\n minuteInterval?: number; // Minute interval (e.g., 5, 10, 15, 30) - defaults to 1\n secondInterval?: number; // Second interval (e.g., 5, 10, 15, 30) - defaults to 1\n disabledTimes?: string[]; // Array of disabled times in \"HH:mm\" or \"HH:mm:ss\" format\n disabledTimeRanges?: DisabledTimeRange[]; // Array of disabled time ranges\n showNowButton?: boolean; // Show \"Now\" button to select current time\n nowButtonLabel?: string; // Label for \"Now\" button (defaults to \"Now\")\n timePickerLabel?:\n | boolean\n | { hours?: string; minutes?: string; seconds?: string };\n};\n\nexport function DatePicker({\n value,\n onChange,\n onSelect,\n calendarClassName,\n side = \"bottom\",\n align = \"end\",\n format = \"dd/MM/yyyy\",\n language = \"vi\",\n mask,\n closeOnSelect = false,\n calendarConfig,\n desktopMode = \"popover\",\n mobileMode = \"drawer\",\n showOutsideDays = true,\n children,\n showTime = false,\n timeFormat = \"HH:mm\",\n hideDate = false,\n numberOfMonths = 1,\n variant = \"default\",\n color = \"primary\",\n // TimePicker props\n timePickerMode = \"wheel\",\n hourInterval = 1,\n minuteInterval = 1,\n secondInterval = 1,\n disabledTimes,\n disabledTimeRanges,\n showNowButton = false,\n nowButtonLabel = \"Now\",\n timePickerLabel,\n ...props\n}: DatePickerProps) {\n let inputFormat: string;\n let outputFormat: string;\n if (typeof format === \"string\") {\n inputFormat = format;\n outputFormat = format;\n } else {\n inputFormat = format.input;\n outputFormat = format.output;\n }\n\n // Determine the mask to use\n let maskToUse: string | undefined;\n if (mask === true) {\n maskToUse = generateMaskFromFormat(inputFormat);\n } else if (typeof mask === \"string\") {\n maskToUse = mask;\n }\n // If mask is false or undefined, maskToUse remains undefined\n\n const initialDate = value ? parseDate(value, inputFormat) : undefined;\n\n const [open, setOpen] = React.useState(false);\n const [date, setDate] = React.useState<Date | undefined>(initialDate);\n const [month, setMonth] = React.useState<Date | undefined>(initialDate);\n const [inputValue, setInputValue] = React.useState(value || \"\");\n\n const _locale: Locale = calendarConfig?.locale\n ? (calendarConfig?.locale as Locale)\n : language === \"en\"\n ? enUS\n : vi;\n\n const mode = isMobile ? mobileMode : desktopMode;\n\n // Helper to format date-time based on showTime and timeFormat\n const formatDateTimeValue = (d: Date | undefined): string => {\n if (!d) return \"\";\n let result = formatDate(d, outputFormat, _locale);\n if (showTime) {\n result += ` ${dfFormat(d, timeFormat)}`;\n }\n return result;\n };\n\n // Helper functions for render props\n const handleSelectForRenderProp = (date?: Date) => {\n setDate(date);\n setInputValue(formatDateTimeValue(date));\n onSelect?.(date, formatDateTimeValue(date));\n };\n\n const handleChangeForRenderProp = (text?: string) => {\n if (!text) {\n setInputValue(\"\");\n setDate(undefined);\n onSelect?.(undefined, undefined);\n return;\n }\n setInputValue(text);\n const parsedDate = parseDate(text, inputFormat);\n if (parsedDate) {\n setDate(parsedDate);\n setMonth(parsedDate);\n onSelect?.(parsedDate, formatDateTimeValue(parsedDate));\n } else {\n setDate(undefined);\n onSelect?.(undefined, undefined);\n }\n };\n\n const handleTimeChange = (\n event?: React.ChangeEvent<HTMLInputElement>,\n value?: string,\n newDate?: Date\n ) => {\n if (!newDate) {\n // Handle clear/invalid time\n onChange?.(event, value, undefined);\n return;\n }\n\n // Merge: keep date (year, month, day) from Calendar, take time (hours, minutes, seconds) from TimePicker\n const mergedDate = new Date(date || new Date());\n mergedDate.setHours(\n newDate.getHours(),\n newDate.getMinutes(),\n newDate.getSeconds(),\n 0\n );\n\n setDate(mergedDate);\n setInputValue(formatDateTimeValue(mergedDate));\n onSelect?.(mergedDate, formatDateTimeValue(mergedDate));\n onChange?.(event, formatDateTimeValue(mergedDate), mergedDate);\n };\n\n // Determine trigger component\n const triggerComponent = children ? (\n children({\n value: inputValue,\n date,\n onSelect: handleSelectForRenderProp,\n onChange: handleChangeForRenderProp,\n })\n ) : (\n <Button\n variant=\"ghost\"\n className=\"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors\"\n size={props.size}\n >\n <CalendarIcon\n className={cn({\n \"size-3\": props.size === \"xs\" || props.size === \"sm\",\n \"size-3.5\": !props.size || props.size === \"normal\",\n \"size-4\": props.size === \"lg\" || props.size === \"xl\",\n })}\n />\n <span className=\"sr-only\">Select date</span>\n </Button>\n );\n\n const calendarSelection = (\n <div\n className={cn(\n \"flex items-stretch mx-auto w-full\",\n showTime && !hideDate ? \"gap-0 md:max-w-lg\" : \"\",\n // mode === \"drawer\" ? \"mb-6\" : \"\",\n isMobile ? \"max-w-md md:max-w-md lg:max-w-lg\" : \"\"\n )}\n >\n {!hideDate && (\n <Calendar\n {...calendarConfig}\n mode=\"single\"\n selected={date}\n captionLayout=\"dropdown\"\n month={month}\n onMonthChange={setMonth}\n numberOfMonths={isMobile ? 1 : numberOfMonths || 1}\n variant={variant}\n color={color}\n onSelect={(selectedDate) => {\n // Preserve time from current date when selecting new date\n let newDate = selectedDate;\n if (selectedDate && date && showTime) {\n newDate = new Date(selectedDate);\n newDate.setHours(\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n date.getMilliseconds()\n );\n }\n setDate(newDate);\n setInputValue(formatDateTimeValue(newDate));\n onSelect?.(newDate, formatDateTimeValue(newDate));\n if (closeOnSelect && !showTime) setOpen(false);\n }}\n locale={_locale}\n formatters={{\n formatMonthDropdown: (date) =>\n date.toLocaleString(_locale.code, { month: \"short\" }),\n }}\n showOutsideDays={showOutsideDays}\n className={cn(\n \"my-auto bg-transparent mx-auto\",\n {\n \"[--cell-size:clamp(0px,calc(100vw/7.5),52px)] mb-8 bg-transparent\":\n (isMobile && !showTime) || desktopMode === \"drawer\",\n \"[--cell-size:clamp(0px,calc(100vw/7.5),34px)]\":\n !isMobile && desktopMode !== \"drawer\",\n \"w-full\": mode === \"drawer\" && showTime,\n },\n calendarClassName\n )}\n />\n )}\n {showTime && (\n <div className=\"border-l border-border\">\n <TimePicker\n value={date ? dfFormat(date, timeFormat) : undefined}\n format={timeFormat}\n onChange={handleTimeChange}\n showHours\n showMinutes\n showSeconds={timeFormat === \"HH:mm:ss\"}\n mode={timePickerMode}\n hourInterval={hourInterval}\n minuteInterval={minuteInterval}\n secondInterval={secondInterval}\n disabledTimes={disabledTimes}\n disabledTimeRanges={disabledTimeRanges}\n showNowButton={showNowButton}\n nowButtonLabel={nowButtonLabel}\n timeLabel={timePickerLabel}\n standalone={false}\n color={color}\n />\n </div>\n )}\n </div>\n );\n\n const popPicker = (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild disabled={props.disabled}>\n {triggerComponent}\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n \"w-auto overflow-hidden p-0\",\n \"backdrop-blur bg-background/50\"\n )}\n side={side}\n align={align}\n >\n {calendarSelection}\n </PopoverContent>\n </Popover>\n );\n\n const drawPicker = (\n <Drawer open={open} onOpenChange={setOpen}>\n <DrawerTrigger asChild>{triggerComponent}</DrawerTrigger>\n <DrawerContent\n className={cn(\n \"w-auto overflow-hidden p-0\",\n \"backdrop-blur bg-background\"\n )}\n >\n <DrawerHeader className=\"sr-only\">\n <DrawerTitle>Select date</DrawerTitle>\n <DrawerDescription>Set date</DrawerDescription>\n </DrawerHeader>\n {calendarSelection}\n </DrawerContent>\n </Drawer>\n );\n\n // If children is provided, use render prop pattern with picker\n if (children) {\n return mode === \"drawer\" ? drawPicker : popPicker;\n }\n\n // Default input rendering\n return (\n <Input\n {...props}\n clearable\n value={inputValue}\n mask={maskToUse}\n onChange={(e) => {\n setInputValue(e.target.value);\n const date = parseDate(e.target.value, inputFormat);\n if (date) {\n setDate(date);\n setMonth(date);\n onSelect?.(date, formatDateTimeValue(date));\n onChange?.(e, formatDateTimeValue(date), date);\n } else {\n onSelect?.(undefined, undefined);\n onChange?.(e, undefined, undefined);\n }\n }}\n onBlur={() => {\n const parsedDate = parseDate(inputValue, inputFormat);\n if (!parsedDate) {\n setInputValue(\"\");\n setDate(undefined);\n setMonth(undefined);\n onSelect?.(undefined, undefined);\n }\n }}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setOpen(true);\n }\n }}\n suffixIcon={mode === \"drawer\" ? drawPicker : popPicker}\n />\n );\n}\n\nexport const CalendarDayButton = SCalendarDayButton;\nexport type CalendarDayButtonProps = SCalendarDayButtonProps;\n"],"names":["formatDate","date","outputFormat","DATE_FORMAT","locale","dfFormat","parseDate","str","inputFormat","parse","isValid","generateMaskFromFormat","format","match","DatePicker","value","onChange","onSelect","calendarClassName","side","align","language","mask","closeOnSelect","calendarConfig","desktopMode","mobileMode","showOutsideDays","children","showTime","timeFormat","hideDate","numberOfMonths","variant","color","timePickerMode","hourInterval","minuteInterval","secondInterval","disabledTimes","disabledTimeRanges","showNowButton","nowButtonLabel","timePickerLabel","props","maskToUse","initialDate","open","setOpen","React","setDate","month","setMonth","inputValue","setInputValue","_locale","enUS","vi","mode","isMobile","formatDateTimeValue","d","result","handleSelectForRenderProp","handleChangeForRenderProp","text","parsedDate","handleTimeChange","event","newDate","mergedDate","triggerComponent","jsxs","Button","jsx","CalendarIcon","cn","calendarSelection","Calendar","selectedDate","TimePicker","popPicker","Popover","PopoverTrigger","PopoverContent","drawPicker","Drawer","DrawerTrigger","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","Input"],"mappings":"6nEAoCA,SAASA,GACPC,E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":3,"file":"DatePicker.cjs","sources":["../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n CalendarDayButton as SCalendarDayButton,\n type CalendarDayButtonProps as SCalendarDayButtonProps,\n Calendar,\n type CalendarProps,\n type CalendarColor,\n} from \"@dsui/ui/components/calendar\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@dsui/ui/components/popover\";\nimport {\n Drawer,\n DrawerContent,\n DrawerDescription,\n DrawerHeader,\n DrawerTitle,\n DrawerTrigger,\n} from \"@dsui/ui/components/drawer\";\nimport { cn } from \"@dsui/ui/index\";\nimport { Input, type InputProps } from \"../Input\";\nimport { Button } from \"../Button\";\nimport {\n TimePicker,\n type TimePickerMode,\n type DisabledTimeRange,\n} from \"./TimePicker\";\nimport { CalendarIcon } from \"lucide-react\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport { isMobile } from \"react-device-detect\";\nimport { format as dfFormat, parse, isValid, type Locale } from \"date-fns\";\nimport { vi, enUS } from \"date-fns/locale\";\nimport { DATE_FORMAT } from \"@/constants/common\";\n\nfunction formatDate(\n date: Date | undefined,\n outputFormat: string = DATE_FORMAT,\n locale?: Locale\n) {\n if (!date) return \"\";\n\n return dfFormat(date, outputFormat, locale ? { locale } : undefined);\n}\n\nconst parseDate = (\n str: string,\n inputFormat: string = DATE_FORMAT\n): Date | undefined => {\n const date = parse(str, inputFormat, new Date());\n return isValid(date) ? date : undefined;\n};\n\nfunction generateMaskFromFormat(format: string): string {\n return format\n .replace(/dd|MM|yyyy/g, (match) => {\n switch (match) {\n case \"dd\":\n case \"MM\":\n return \"99\";\n case \"yyyy\":\n return \"9999\";\n default:\n return match;\n }\n })\n .replace(/d|M|y/g, (match) => {\n switch (match) {\n case \"d\":\n case \"M\":\n return \"9\";\n case \"y\":\n return \"9\";\n default:\n return match;\n }\n });\n}\n\nexport type FormatType = string | { input: string; output: string };\n\nexport type DatePickerRenderProps = {\n value: string;\n date?: Date;\n onSelect: (date?: Date) => void;\n onChange: (text?: string) => void;\n};\n\nexport type DatePickerProps = Omit<\n InputProps,\n \"value\" | \"onChange\" | \"onSelect\" | \"mask\" | \"children\"\n> & {\n value?: string;\n onChange?: (\n event?: React.ChangeEvent<HTMLInputElement>,\n value?: string,\n date?: Date\n ) => void;\n onSelect?: (date?: Date, value?: string) => void;\n calendarClassName?: string;\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n align?: \"start\" | \"center\" | \"end\";\n size?: VariantProps<typeof Input>[\"size\"];\n format?: FormatType;\n language?: \"vi\" | \"en\";\n mask?: boolean | string;\n closeOnSelect?: boolean;\n calendarConfig?: CalendarProps;\n desktopMode?: \"popover\" | \"drawer\";\n mobileMode?: \"popover\" | \"drawer\";\n showOutsideDays?: boolean;\n children?: (props: DatePickerRenderProps) => React.ReactNode;\n showTime?: boolean;\n timeFormat?: \"HH:mm\" | \"HH:mm:ss\";\n hideDate?: boolean;\n numberOfMonths?: number;\n variant?: \"default\" | \"rounded\";\n color?: CalendarColor;\n\n // TimePicker configuration options\n timePickerMode?: TimePickerMode; // Display mode: 'wheel' (default), 'select', 'compact'\n hourInterval?: number; // Hour interval (e.g., 1, 2, 3) - defaults to 1\n minuteInterval?: number; // Minute interval (e.g., 5, 10, 15, 30) - defaults to 1\n secondInterval?: number; // Second interval (e.g., 5, 10, 15, 30) - defaults to 1\n disabledTimes?: string[]; // Array of disabled times in \"HH:mm\" or \"HH:mm:ss\" format\n disabledTimeRanges?: DisabledTimeRange[]; // Array of disabled time ranges\n showNowButton?: boolean; // Show \"Now\" button to select current time\n nowButtonLabel?: string; // Label for \"Now\" button (defaults to \"Now\")\n timePickerLabel?:\n | boolean\n | { hours?: string; minutes?: string; seconds?: string };\n};\n\nexport function DatePicker({\n value,\n onChange,\n onSelect,\n calendarClassName,\n side = \"bottom\",\n align = \"end\",\n format = \"dd/MM/yyyy\",\n language = \"vi\",\n mask,\n closeOnSelect = false,\n calendarConfig,\n desktopMode = \"popover\",\n mobileMode = \"drawer\",\n showOutsideDays = true,\n children,\n showTime = false,\n timeFormat = \"HH:mm\",\n hideDate = false,\n numberOfMonths = 1,\n variant = \"default\",\n color = \"primary\",\n // TimePicker props\n timePickerMode = \"wheel\",\n hourInterval = 1,\n minuteInterval = 1,\n secondInterval = 1,\n disabledTimes,\n disabledTimeRanges,\n showNowButton = false,\n nowButtonLabel = \"Now\",\n timePickerLabel,\n ...props\n}: DatePickerProps) {\n let inputFormat: string;\n let outputFormat: string;\n if (typeof format === \"string\") {\n inputFormat = format;\n outputFormat = format;\n } else {\n inputFormat = format.input;\n outputFormat = format.output;\n }\n\n // Determine the mask to use\n let maskToUse: string | undefined;\n if (mask === true) {\n maskToUse = generateMaskFromFormat(inputFormat);\n } else if (typeof mask === \"string\") {\n maskToUse = mask;\n }\n // If mask is false or undefined, maskToUse remains undefined\n\n const initialDate = value ? parseDate(value, inputFormat) : undefined;\n\n const [open, setOpen] = React.useState(false);\n const [date, setDate] = React.useState<Date | undefined>(initialDate);\n const [month, setMonth] = React.useState<Date | undefined>(initialDate);\n const [inputValue, setInputValue] = React.useState(value || \"\");\n\n const _locale: Locale = calendarConfig?.locale\n ? (calendarConfig?.locale as Locale)\n : language === \"en\"\n ? enUS\n : vi;\n\n const mode = isMobile ? mobileMode : desktopMode;\n\n // Helper to format date-time based on showTime and timeFormat\n const formatDateTimeValue = (d: Date | undefined): string => {\n if (!d) return \"\";\n let result = formatDate(d, outputFormat, _locale);\n if (showTime) {\n result += ` ${dfFormat(d, timeFormat)}`;\n }\n return result;\n };\n\n // Helper functions for render props\n const handleSelectForRenderProp = (date?: Date) => {\n setDate(date);\n setInputValue(formatDateTimeValue(date));\n onSelect?.(date, formatDateTimeValue(date));\n };\n\n const handleChangeForRenderProp = (text?: string) => {\n if (!text) {\n setInputValue(\"\");\n setDate(undefined);\n onSelect?.(undefined, undefined);\n return;\n }\n setInputValue(text);\n const parsedDate = parseDate(text, inputFormat);\n if (parsedDate) {\n setDate(parsedDate);\n setMonth(parsedDate);\n onSelect?.(parsedDate, formatDateTimeValue(parsedDate));\n } else {\n setDate(undefined);\n onSelect?.(undefined, undefined);\n }\n };\n\n const handleTimeChange = (\n event?: React.ChangeEvent<HTMLInputElement>,\n value?: string,\n newDate?: Date\n ) => {\n if (!newDate) {\n // Handle clear/invalid time\n onChange?.(event, value, undefined);\n return;\n }\n\n // Merge: keep date (year, month, day) from Calendar, take time (hours, minutes, seconds) from TimePicker\n const mergedDate = new Date(date || new Date());\n mergedDate.setHours(\n newDate.getHours(),\n newDate.getMinutes(),\n newDate.getSeconds(),\n 0\n );\n\n setDate(mergedDate);\n setInputValue(formatDateTimeValue(mergedDate));\n onSelect?.(mergedDate, formatDateTimeValue(mergedDate));\n onChange?.(event, formatDateTimeValue(mergedDate), mergedDate);\n };\n\n // Determine trigger component\n const triggerComponent = children ? (\n children({\n value: inputValue,\n date,\n onSelect: handleSelectForRenderProp,\n onChange: handleChangeForRenderProp,\n })\n ) : (\n <Button\n variant=\"ghost\"\n className=\"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors\"\n size={props.size}\n >\n <CalendarIcon\n className={cn({\n \"size-3\": props.size === \"xs\" || props.size === \"sm\",\n \"size-3.5\": !props.size || props.size === \"normal\",\n \"size-4\": props.size === \"lg\" || props.size === \"xl\",\n })}\n />\n <span className=\"sr-only\">Select date</span>\n </Button>\n );\n\n const calendarSelection = (\n <div\n className={cn(\n \"flex items-stretch mx-auto w-full\",\n showTime && !hideDate ? \"gap-0 md:max-w-lg\" : \"\",\n // mode === \"drawer\" ? \"mb-6\" : \"\",\n isMobile ? \"max-w-md md:max-w-md lg:max-w-lg\" : \"\"\n )}\n >\n {!hideDate && (\n <Calendar\n {...calendarConfig}\n mode=\"single\"\n selected={date}\n captionLayout=\"dropdown\"\n month={month}\n onMonthChange={setMonth}\n numberOfMonths={isMobile ? 1 : numberOfMonths || 1}\n variant={variant}\n color={color}\n onSelect={(selectedDate) => {\n // Preserve time from current date when selecting new date\n let newDate = selectedDate;\n if (selectedDate && date && showTime) {\n newDate = new Date(selectedDate);\n newDate.setHours(\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n date.getMilliseconds()\n );\n }\n setDate(newDate);\n setInputValue(formatDateTimeValue(newDate));\n onSelect?.(newDate, formatDateTimeValue(newDate));\n if (closeOnSelect && !showTime) setOpen(false);\n }}\n locale={_locale}\n formatters={{\n formatMonthDropdown: (date) =>\n date.toLocaleString(_locale.code, { month: \"short\" }),\n }}\n showOutsideDays={showOutsideDays}\n className={cn(\n \"my-auto bg-transparent mx-auto\",\n {\n \"[--cell-size:clamp(0px,calc(100vw/7.5),52px)] mb-8 bg-transparent\":\n (isMobile && !showTime) || desktopMode === \"drawer\",\n \"[--cell-size:clamp(0px,calc(100vw/7.5),34px)]\":\n !isMobile && desktopMode !== \"drawer\",\n \"w-full\": mode === \"drawer\" && showTime,\n },\n calendarClassName\n )}\n />\n )}\n {showTime && (\n <div className=\"border-l border-border\">\n <TimePicker\n value={date ? dfFormat(date, timeFormat) : undefined}\n format={timeFormat}\n onChange={handleTimeChange}\n showHours\n showMinutes\n showSeconds={timeFormat === \"HH:mm:ss\"}\n mode={timePickerMode}\n hourInterval={hourInterval}\n minuteInterval={minuteInterval}\n secondInterval={secondInterval}\n disabledTimes={disabledTimes}\n disabledTimeRanges={disabledTimeRanges}\n showNowButton={showNowButton}\n nowButtonLabel={nowButtonLabel}\n timeLabel={timePickerLabel}\n standalone={false}\n color={color}\n />\n </div>\n )}\n </div>\n );\n\n const popPicker = (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild disabled={props.disabled}>\n {triggerComponent}\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n \"w-auto overflow-hidden p-0\",\n \"backdrop-blur bg-background/50\"\n )}\n side={side}\n align={align}\n >\n {calendarSelection}\n </PopoverContent>\n </Popover>\n );\n\n const drawPicker = (\n <Drawer open={open} onOpenChange={setOpen}>\n <DrawerTrigger asChild>{triggerComponent}</DrawerTrigger>\n <DrawerContent\n className={cn(\n \"w-auto overflow-hidden p-0\",\n \"backdrop-blur bg-background\"\n )}\n >\n <DrawerHeader className=\"sr-only\">\n <DrawerTitle>Select date</DrawerTitle>\n <DrawerDescription>Set date</DrawerDescription>\n </DrawerHeader>\n {calendarSelection}\n </DrawerContent>\n </Drawer>\n );\n\n // If children is provided, use render prop pattern with picker\n if (children) {\n return mode === \"drawer\" ? drawPicker : popPicker;\n }\n\n // Default input rendering\n return (\n <Input\n {...props}\n clearable\n value={inputValue}\n mask={maskToUse}\n onChange={(e) => {\n setInputValue(e.target.value);\n const date = parseDate(e.target.value, inputFormat);\n if (date) {\n setDate(date);\n setMonth(date);\n onSelect?.(date, formatDateTimeValue(date));\n onChange?.(e, formatDateTimeValue(date), date);\n } else {\n onSelect?.(undefined, undefined);\n onChange?.(e, undefined, undefined);\n }\n }}\n onBlur={() => {\n const parsedDate = parseDate(inputValue, inputFormat);\n if (!parsedDate) {\n setInputValue(\"\");\n setDate(undefined);\n setMonth(undefined);\n onSelect?.(undefined, undefined);\n }\n }}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setOpen(true);\n }\n }}\n suffixIcon={mode === \"drawer\" ? drawPicker : popPicker}\n />\n );\n}\n\nexport const CalendarDayButton = SCalendarDayButton;\nexport type CalendarDayButtonProps = SCalendarDayButtonProps;\n"],"names":["formatDate","date","outputFormat","DATE_FORMAT","locale","dfFormat","parseDate","str","inputFormat","parse","isValid","generateMaskFromFormat","format","match","DatePicker","value","onChange","onSelect","calendarClassName","side","align","language","mask","closeOnSelect","calendarConfig","desktopMode","mobileMode","showOutsideDays","children","showTime","timeFormat","hideDate","numberOfMonths","variant","color","timePickerMode","hourInterval","minuteInterval","secondInterval","disabledTimes","disabledTimeRanges","showNowButton","nowButtonLabel","timePickerLabel","props","maskToUse","initialDate","open","setOpen","React","setDate","month","setMonth","inputValue","setInputValue","_locale","enUS","vi","mode","isMobile","formatDateTimeValue","d","result","handleSelectForRenderProp","handleChangeForRenderProp","text","parsedDate","handleTimeChange","event","newDate","mergedDate","triggerComponent","jsxs","Button","jsx","CalendarIcon","cn","calendarSelection","Calendar","selectedDate","TimePicker","popPicker","Popover","PopoverTrigger","PopoverContent","drawPicker","Drawer","DrawerTrigger","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","Input"],"mappings":"6nEAoCA,SAASA,GACPC,EACAC,EAAuBC,EAAAA,YACvBC,EACA,CACA,OAAKH,EAEEI,EAAAA,OAASJ,EAAMC,EAAcE,EAAS,CAAE,OAAAA,CAAA,EAAW,MAAS,EAFjD,EAGpB,CAEA,MAAME,EAAY,CAChBC,EACAC,EAAsBL,gBACD,CACrB,MAAMF,EAAOQ,EAAAA,MAAMF,EAAKC,EAAa,IAAI,IAAM,EAC/C,OAAOE,UAAQT,CAAI,EAAIA,EAAO,MAChC,EAEA,SAASU,GAAuBC,EAAwB,CACtD,OAAOA,EACJ,QAAQ,cAAgBC,GAAU,CACjC,OAAQA,EAAA,CACN,IAAK,KACL,IAAK,KACH,MAAO,KACT,IAAK,OACH,MAAO,OACT,QACE,OAAOA,CAAA,CAEb,CAAC,EACA,QAAQ,SAAWA,GAAU,CAC5B,OAAQA,EAAA,CACN,IAAK,IACL,IAAK,IACH,MAAO,IACT,IAAK,IACH,MAAO,IACT,QACE,OAAOA,CAAA,CAEb,CAAC,CACL,CAwDO,SAASC,GAAW,CACzB,MAAAC,EACA,SAAAC,EACA,SAAAC,EACA,kBAAAC,EACA,KAAAC,EAAO,SACP,MAAAC,EAAQ,MACR,OAAAR,EAAS,aACT,SAAAS,EAAW,KACX,KAAAC,EACA,cAAAC,EAAgB,GAChB,eAAAC,EACA,YAAAC,EAAc,UACd,WAAAC,EAAa,SACb,gBAAAC,EAAkB,GAClB,SAAAC,EACA,SAAAC,EAAW,GACX,WAAAC,EAAa,QACb,SAAAC,EAAW,GACX,eAAAC,EAAiB,EACjB,QAAAC,EAAU,UACV,MAAAC,EAAQ,UAER,eAAAC,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CAAW,IAElD8C,EAAc,EAAE,EAChBJ,EAAQ,MAAS,EACjBE,EAAS,MAAS,EAClBnC,IAAW,OAAW,MAAS,EAEnC,EACA,UAAY,GAAM,CACZ,EAAE,MAAQ,cACZ,EAAE,eAAA,EACF+B,EAAQ,EAAI,EAEhB,EACA,WAAYU,IAAS,SAAW2B,EAAaJ,CAAA,CAAA,CAGnD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),Oe=require("react"),Se=require("../../packages/ui/src/components/calendar.cjs"),Z=require("../../packages/ui/src/components/popover.cjs"),P=require("../../packages/ui/src/components/drawer.cjs");require("@radix-ui/react-slot");require("../../packages/ui/src/components/button.cjs");require("../../packages/ui/src/components/button-group.cjs");require("../../packages/ui/src/components/input.cjs");require("../../packages/ui/src/components/textarea.cjs");require("@radix-ui/react-label");const z=require("../../packages/ui/src/lib/utils.cjs");require("../../packages/ui/src/components/select.cjs");require("../../packages/ui/src/components/combobox.cjs");require("@radix-ui/react-tooltip");require("@radix-ui/react-separator");require("../../packages/ui/src/components/switch.cjs");require("@radix-ui/react-scroll-area");require("../../packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("../../packages/ui/src/components/badge.cjs");const le=require("lucide-react");require("../../packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("../../packages/ui/src/components/input-otp.cjs");require("../../packages/ui/src/components/radio-group.cjs");require("../../packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("../../packages/ui/src/components/tabs.cjs");require("../../packages/ui/src/components/toggle.cjs");const Ie=require("../Input/Input.cjs"),ke=require("../Button/Button.cjs"),fe=require("./TimePicker.cjs"),S=require("react-device-detect"),H=require("date-fns"),de=require("date-fns/locale"),me=require("../../constants/common.cjs"),Ve=require("../FloatLabel.cjs");function Ce(u){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const f in u)if(f!=="default"){const w=Object.getOwnPropertyDescriptor(u,f);Object.defineProperty(a,f,w.get?w:{enumerable:!0,get:()=>u[f]})}}return a.default=u,Object.freeze(a)}const D=Ce(Oe);function $e(u,a=me.DATE_FORMAT,f){return u?H.format(u,a,f?{locale:f}:void 0):""}const j=(u,a=me.DATE_FORMAT)=>{const f=H.parse(u,a,new Date);return H.isValid(f)?f:void 0};function Le(u){return u.replace(/dd|MM|yyyy/g,a=>{switch(a){case"dd":case"MM":return"99";case"yyyy":return"9999";default:return a}}).replace(/d|M|y/g,a=>{switch(a){case"d":case"M":return"9";case"y":return"9";default:return a}})}function Ae({label:u,value:a,placeholder:f,onChange:w,onSelect:d,calendarClassName:ge,side:be="bottom",align:ve="end",format:O="dd/MM/yyyy",language:we="vi",mask:V,closeOnSelect:he=!1,showOutsideDays:qe=!0,calendarConfig:C,timeConfig:ee,desktopMode:I="popover",mobileMode:re="drawer",children:$,separator:pe=i.jsx(le.MoveRight,{className:"size-5"}),showTime:x=!1,timeFormat:h="HH:mm",hideDate:te=!1,numberOfMonths:De=1,variant:je="default",color:xe="primary",...s}){const oe=D.useId();let g,L;typeof O=="string"?(g=O,L=O):(g=O.input,L=O.output);let A;V===!0?A=Le(g):typeof V=="string"&&(A=V);const ne=a?.from?j(a.from,g):void 0,ye=a?.to?j(a.to,g):void 0,Me={from:ne,to:ye},[se,k]=D.useState(!1),[n,m]=D.useState(Me),[Te,E]=D.useState(ne||new Date),[F,q]=D.useState(a?.from||""),[R,p]=D.useState(a?.to||""),[_,B]=D.useState(void 0),[U,Y]=D.useState(void 0),K=D.useRef(null),G=D.useRef(null),ze=!!(F.trim()||R.trim()),J=C?.locale?C?.locale:we==="en"?de.enUS:de.vi,t=e=>{if(!e)return"";let r=$e(e,L,J);return x&&(r+=` ${H.format(e,h)}`),r},Fe=e=>{m(e);const r=t(e?.from),o=t(e?.to);q(r),p(o),d?.(e,{from:r,to:o})},Re=e=>{if(q(e),e.trim()===""){q(""),p("");const b={from:void 0,to:void 0};m(b),d?.(b,b);return}let r;x?r=j(e,`${g} ${h}`):r=j(e,g);const o={from:r,to:n?.to};r?(m(o),E(r),B(r),d?.(o,{from:t(r),to:t(n?.to)})):(m(o),d?.(o,{from:t(n?.from),to:t(n?.to)}))},Ne=e=>{if(p(e),e.trim()===""){q(""),p("");const b={from:void 0,to:void 0};m(b),d?.(b,b);return}let r;x?r=j(e,`${g} ${h}`):r=j(e,g);const o={from:n?.from,to:r};r?(m(o),Y(r),d?.(o,{from:t(n?.from),to:t(r)})):(m(o),d?.(o,{from:t(n?.from),to:void 0}))},Pe=e=>{if(e){B(e);const r=new Date(n?.from||new Date);r.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),0);const o={from:r,to:n?.to};m(o),q(t(r)),d?.(o,{from:t(r),to:t(n?.to)}),w?.(o,{from:t(r),to:t(n?.to)})}},He=e=>{if(e){Y(e);const r=new Date(n?.to||new Date);r.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),0);const o={from:n?.from,to:r};m(o),p(t(r)),d?.(o,{from:t(n?.from),to:t(r)}),w?.(o,{from:t(n?.from),to:t(r)})}},ie=$?$({fromValue:F,toValue:R,range:n,onSelect:Fe,onFromChange:Re,onToChange:Ne}):i.jsxs(ke.default,{variant:"ghost",className:"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors",size:s?.size,children:[i.jsx(le.CalendarIcon,{className:z.cn({"size-3":s.size==="xs"||s.size==="sm","size-3.5":!s.size||s.size==="normal","size-4":s.size==="lg"||s.size==="xl"})}),i.jsx("span",{className:"sr-only",children:"Select date range"})]}),ae=i.jsxs("div",{className:z.cn("flex items-stretch",x&&!te?"gap-0":""),children:[!te&&i.jsx(Se.Calendar,{...C,mode:"range",selected:n,captionLayout:"dropdown",month:Te,onMonthChange:E,numberOfMonths:S.isMobile?1:De||1,variant:je,color:xe,onSelect:e=>{let r=e;if(x){const c=_,l=U;r={from:e?.from?new Date(e.from.getFullYear(),e.from.getMonth(),e.from.getDate(),c?.getHours()||0,c?.getMinutes()||0,c?.getSeconds()||0):void 0,to:e?.to?new Date(e.to.getFullYear(),e.to.getMonth(),e.to.getDate(),l?.getHours()||0,l?.getMinutes()||0,l?.getSeconds()||0):void 0}}m(r);const o=t(r?.from),b=t(r?.to);q(o),p(b),d?.(r,{from:o,to:b}),w?.(r,{from:o,to:b}),he&&r?.from&&r?.to&&!x&&k(!1)},locale:J,formatters:{formatMonthDropdown:e=>e.toLocaleString(J.code,{month:"short"})},showOutsideDays:qe,className:z.cn("mx-auto",{"[--cell-size:clamp(0px,calc(100vw/7.5),52px)] mb-8 bg-transparent":S.isMobile||I==="drawer","[--cell-size:clamp(0px,calc(100vw/7.5),34px)]":!S.isMobile&&I!=="drawer"},ge)}),x&&i.jsxs("div",{className:"flex gap-0 border-l border-border",children:[i.jsx(fe.TimePicker,{...ee?.[0],value:_?H.format(_,h):void 0,onSelect:Pe,format:h,showHours:!0,showMinutes:!0,showSeconds:h==="HH:mm:ss",standalone:!1}),i.jsx("div",{className:"border-l border-border"}),i.jsx(fe.TimePicker,{...ee?.[1],value:U?H.format(U,h):void 0,onSelect:He,format:h,showHours:!0,showMinutes:!0,showSeconds:h==="HH:mm:ss",standalone:!1})]})]}),Q=i.jsxs(Z.Popover,{open:se,onOpenChange:k,children:[i.jsx(Z.PopoverTrigger,{asChild:!0,disabled:s.disabled,children:ie}),i.jsx(Z.PopoverContent,{className:z.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background/50"),side:be,align:ve,children:ae})]}),W=i.jsxs(P.Drawer,{open:se,onOpenChange:k,children:[i.jsx(P.DrawerTrigger,{asChild:!0,children:ie}),i.jsxs(P.DrawerContent,{className:z.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background"),children:[i.jsxs(P.DrawerHeader,{className:"sr-only",children:[i.jsx(P.DrawerTitle,{children:"Select date range"}),i.jsx(P.DrawerDescription,{children:"Set your date range"})]}),ae]})]});if($)return(S.isMobile?re:I)==="drawer"?W:Q;const ce=(e,r,o,b)=>{const c=e==="from";return i.jsx(Ie.default,{...s,...b,ref:c?K:G,id:oe,size:s.isFloatLabel?s.size?s.size:"xl":s.size,className:z.cn(s.className,"relative peer border-0 focus:ring-0 rounded-none hover:bg-transparent active:bg-transparent focus-visible:ring-0 focus-visible:border-0",c?"pr-0":""),label:s.isFloatLabel&&typeof u=="object"?c?u?.from||"":u?.to||"":"",placeholder:typeof f=="object"?c?f?.from||"":f?.to||"":f,clearable:!c,value:r,mask:A,onChange:l=>{const y=l.target.value;if(o(y),y.trim()===""){q(""),p("");const M={from:void 0,to:void 0};m(M),d?.(M,M),w?.(M,M);return}let v;x?v=j(y,`${g} ${h}`):v=j(y,g);const N=c?{from:v,to:n?.to}:{from:n?.from,to:v};if(v){m(N),c&&E(v),c?B(v):Y(v);const M=t(c?v:n?.from),ue=t(c?n?.to:v);d?.(N,{from:M,to:ue}),w?.(N,{from:c?y:F,to:c?R:y})}else d?.(N,{from:t(n?.from),to:c?t(n?.to):void 0}),w?.(N,{from:t(n?.from),to:c?t(n?.to):void 0})},onClear:c?void 0:()=>{q(""),p("");const l={from:void 0,to:void 0};m(l),d?.(l,l),w?.(l,l)},onBlur:()=>{const l=document.activeElement;l!==K.current&&l!==G.current&&setTimeout(()=>{const y=document.activeElement;if(y!==K.current&&y!==G.current){const v=T=>{if(T.trim()==="")return!0;let X;return x?X=j(T,`${g} ${h}`):X=j(T,g),!!X},N=v(F),M=v(R);if(!N||!M||F.trim()&&!R.trim()||!F.trim()&&R.trim()){q(""),p("");const T={from:void 0,to:void 0};m(T),d?.(T,T),w?.(T,T)}}},100)},onKeyDown:l=>{l.key==="ArrowDown"&&(l.preventDefault(),k(!0))}})};return i.jsxs("div",{className:z.cn("group relative flex items-center border rounded-md focus-within:ring-2 focus-within:ring-offset-2 bg-background transition-[color,box-shadow]",{"border-input focus-within:ring-ring":!s.state,"border-success focus-within:ring-success":s.state==="success","border-warning focus-within:ring-warning":s.state==="warning","border-error focus-within:ring-error":s.state==="error"}),children:[ce("from",F,q),i.jsx("span",{className:z.cn("text-muted-foreground select-none pl-2",{"opacity-30":s.disabled}),children:pe}),ce("to",R,p,{suffixIcon:S.isMobile?re==="drawer"?W:Q:I==="drawer"?W:Q}),s.isFloatLabel&&typeof u=="string"&&i.jsx(Ve.FloatingLabel,{htmlFor:oe,size:s.size,infoTooltip:s.infoTooltip,className:"z-10",shouldFloat:ze,children:u})]})}exports.RangePicker=Ae;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),Oe=require("react"),Se=require("../../packages/ui/src/components/calendar.cjs"),Z=require("../../packages/ui/src/components/popover.cjs"),P=require("../../packages/ui/src/components/drawer.cjs");require("@radix-ui/react-slot");require("../../packages/ui/src/components/button.cjs");require("../../packages/ui/src/components/button-group.cjs");require("../../packages/ui/src/components/input.cjs");require("../../packages/ui/src/components/textarea.cjs");require("@radix-ui/react-label");const z=require("../../packages/ui/src/lib/utils.cjs");require("../../packages/ui/src/components/select.cjs");require("../../packages/ui/src/components/combobox.cjs");require("@radix-ui/react-tooltip");require("@radix-ui/react-separator");require("../../packages/ui/src/components/switch.cjs");require("@radix-ui/react-scroll-area");require("../../packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("../../packages/ui/src/components/badge.cjs");const le=require("lucide-react");require("../../packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("../../packages/ui/src/components/input-otp.cjs");require("../../packages/ui/src/components/radio-group.cjs");require("../../packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("../../packages/ui/src/components/tabs.cjs");require("../../packages/ui/src/components/toggle.cjs");const fe=require("./TimePicker.cjs"),S=require("react-device-detect"),H=require("date-fns"),de=require("date-fns/locale"),me=require("../../constants/common.cjs"),Ie=require("../FloatLabel.cjs"),ke=require("../Button/Button.cjs"),Ve=require("../Input/Input.cjs");function Ce(u){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const f in u)if(f!=="default"){const w=Object.getOwnPropertyDescriptor(u,f);Object.defineProperty(a,f,w.get?w:{enumerable:!0,get:()=>u[f]})}}return a.default=u,Object.freeze(a)}const D=Ce(Oe);function $e(u,a=me.DATE_FORMAT,f){return u?H.format(u,a,f?{locale:f}:void 0):""}const j=(u,a=me.DATE_FORMAT)=>{const f=H.parse(u,a,new Date);return H.isValid(f)?f:void 0};function Le(u){return u.replace(/dd|MM|yyyy/g,a=>{switch(a){case"dd":case"MM":return"99";case"yyyy":return"9999";default:return a}}).replace(/d|M|y/g,a=>{switch(a){case"d":case"M":return"9";case"y":return"9";default:return a}})}function Ae({label:u,value:a,placeholder:f,onChange:w,onSelect:d,calendarClassName:ge,side:be="bottom",align:ve="end",format:O="dd/MM/yyyy",language:we="vi",mask:V,closeOnSelect:he=!1,showOutsideDays:qe=!0,calendarConfig:C,timeConfig:ee,desktopMode:I="popover",mobileMode:re="drawer",children:$,separator:pe=i.jsx(le.MoveRight,{className:"size-5"}),showTime:x=!1,timeFormat:h="HH:mm",hideDate:te=!1,numberOfMonths:De=1,variant:je="default",color:xe="primary",...s}){const oe=D.useId();let g,L;typeof O=="string"?(g=O,L=O):(g=O.input,L=O.output);let A;V===!0?A=Le(g):typeof V=="string"&&(A=V);const ne=a?.from?j(a.from,g):void 0,ye=a?.to?j(a.to,g):void 0,Me={from:ne,to:ye},[se,k]=D.useState(!1),[n,m]=D.useState(Me),[Te,E]=D.useState(ne||new Date),[F,q]=D.useState(a?.from||""),[R,p]=D.useState(a?.to||""),[_,B]=D.useState(void 0),[U,Y]=D.useState(void 0),K=D.useRef(null),G=D.useRef(null),ze=!!(F.trim()||R.trim()),J=C?.locale?C?.locale:we==="en"?de.enUS:de.vi,t=e=>{if(!e)return"";let r=$e(e,L,J);return x&&(r+=` ${H.format(e,h)}`),r},Fe=e=>{m(e);const r=t(e?.from),o=t(e?.to);q(r),p(o),d?.(e,{from:r,to:o})},Re=e=>{if(q(e),e.trim()===""){q(""),p("");const b={from:void 0,to:void 0};m(b),d?.(b,b);return}let r;x?r=j(e,`${g} ${h}`):r=j(e,g);const o={from:r,to:n?.to};r?(m(o),E(r),B(r),d?.(o,{from:t(r),to:t(n?.to)})):(m(o),d?.(o,{from:t(n?.from),to:t(n?.to)}))},Ne=e=>{if(p(e),e.trim()===""){q(""),p("");const b={from:void 0,to:void 0};m(b),d?.(b,b);return}let r;x?r=j(e,`${g} ${h}`):r=j(e,g);const o={from:n?.from,to:r};r?(m(o),Y(r),d?.(o,{from:t(n?.from),to:t(r)})):(m(o),d?.(o,{from:t(n?.from),to:void 0}))},Pe=e=>{if(e){B(e);const r=new Date(n?.from||new Date);r.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),0);const o={from:r,to:n?.to};m(o),q(t(r)),d?.(o,{from:t(r),to:t(n?.to)}),w?.(o,{from:t(r),to:t(n?.to)})}},He=e=>{if(e){Y(e);const r=new Date(n?.to||new Date);r.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),0);const o={from:n?.from,to:r};m(o),p(t(r)),d?.(o,{from:t(n?.from),to:t(r)}),w?.(o,{from:t(n?.from),to:t(r)})}},ie=$?$({fromValue:F,toValue:R,range:n,onSelect:Fe,onFromChange:Re,onToChange:Ne}):i.jsxs(ke.default,{variant:"ghost",className:"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors",size:s?.size,children:[i.jsx(le.CalendarIcon,{className:z.cn({"size-3":s.size==="xs"||s.size==="sm","size-3.5":!s.size||s.size==="normal","size-4":s.size==="lg"||s.size==="xl"})}),i.jsx("span",{className:"sr-only",children:"Select date range"})]}),ae=i.jsxs("div",{className:z.cn("flex items-stretch",x&&!te?"gap-0":""),children:[!te&&i.jsx(Se.Calendar,{...C,mode:"range",selected:n,captionLayout:"dropdown",month:Te,onMonthChange:E,numberOfMonths:S.isMobile?1:De||1,variant:je,color:xe,onSelect:e=>{let r=e;if(x){const c=_,l=U;r={from:e?.from?new Date(e.from.getFullYear(),e.from.getMonth(),e.from.getDate(),c?.getHours()||0,c?.getMinutes()||0,c?.getSeconds()||0):void 0,to:e?.to?new Date(e.to.getFullYear(),e.to.getMonth(),e.to.getDate(),l?.getHours()||0,l?.getMinutes()||0,l?.getSeconds()||0):void 0}}m(r);const o=t(r?.from),b=t(r?.to);q(o),p(b),d?.(r,{from:o,to:b}),w?.(r,{from:o,to:b}),he&&r?.from&&r?.to&&!x&&k(!1)},locale:J,formatters:{formatMonthDropdown:e=>e.toLocaleString(J.code,{month:"short"})},showOutsideDays:qe,className:z.cn("mx-auto",{"[--cell-size:clamp(0px,calc(100vw/7.5),52px)] mb-8 bg-transparent":S.isMobile||I==="drawer","[--cell-size:clamp(0px,calc(100vw/7.5),34px)]":!S.isMobile&&I!=="drawer"},ge)}),x&&i.jsxs("div",{className:"flex gap-0 border-l border-border",children:[i.jsx(fe.TimePicker,{...ee?.[0],value:_?H.format(_,h):void 0,onSelect:Pe,format:h,showHours:!0,showMinutes:!0,showSeconds:h==="HH:mm:ss",standalone:!1}),i.jsx("div",{className:"border-l border-border"}),i.jsx(fe.TimePicker,{...ee?.[1],value:U?H.format(U,h):void 0,onSelect:He,format:h,showHours:!0,showMinutes:!0,showSeconds:h==="HH:mm:ss",standalone:!1})]})]}),Q=i.jsxs(Z.Popover,{open:se,onOpenChange:k,children:[i.jsx(Z.PopoverTrigger,{asChild:!0,disabled:s.disabled,children:ie}),i.jsx(Z.PopoverContent,{className:z.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background/50"),side:be,align:ve,children:ae})]}),W=i.jsxs(P.Drawer,{open:se,onOpenChange:k,children:[i.jsx(P.DrawerTrigger,{asChild:!0,children:ie}),i.jsxs(P.DrawerContent,{className:z.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background"),children:[i.jsxs(P.DrawerHeader,{className:"sr-only",children:[i.jsx(P.DrawerTitle,{children:"Select date range"}),i.jsx(P.DrawerDescription,{children:"Set your date range"})]}),ae]})]});if($)return(S.isMobile?re:I)==="drawer"?W:Q;const ce=(e,r,o,b)=>{const c=e==="from";return i.jsx(Ve.default,{...s,...b,ref:c?K:G,id:oe,size:s.isFloatLabel?s.size?s.size:"xl":s.size,className:z.cn(s.className,"relative peer border-0 focus:ring-0 rounded-none hover:bg-transparent active:bg-transparent focus-visible:ring-0 focus-visible:border-0",c?"pr-0":""),label:s.isFloatLabel&&typeof u=="object"?c?u?.from||"":u?.to||"":"",placeholder:typeof f=="object"?c?f?.from||"":f?.to||"":f,clearable:!c,value:r,mask:A,onChange:l=>{const y=l.target.value;if(o(y),y.trim()===""){q(""),p("");const M={from:void 0,to:void 0};m(M),d?.(M,M),w?.(M,M);return}let v;x?v=j(y,`${g} ${h}`):v=j(y,g);const N=c?{from:v,to:n?.to}:{from:n?.from,to:v};if(v){m(N),c&&E(v),c?B(v):Y(v);const M=t(c?v:n?.from),ue=t(c?n?.to:v);d?.(N,{from:M,to:ue}),w?.(N,{from:c?y:F,to:c?R:y})}else d?.(N,{from:t(n?.from),to:c?t(n?.to):void 0}),w?.(N,{from:t(n?.from),to:c?t(n?.to):void 0})},onClear:c?void 0:()=>{q(""),p("");const l={from:void 0,to:void 0};m(l),d?.(l,l),w?.(l,l)},onBlur:()=>{const l=document.activeElement;l!==K.current&&l!==G.current&&setTimeout(()=>{const y=document.activeElement;if(y!==K.current&&y!==G.current){const v=T=>{if(T.trim()==="")return!0;let X;return x?X=j(T,`${g} ${h}`):X=j(T,g),!!X},N=v(F),M=v(R);if(!N||!M||F.trim()&&!R.trim()||!F.trim()&&R.trim()){q(""),p("");const T={from:void 0,to:void 0};m(T),d?.(T,T),w?.(T,T)}}},100)},onKeyDown:l=>{l.key==="ArrowDown"&&(l.preventDefault(),k(!0))}})};return i.jsxs("div",{className:z.cn("group relative flex items-center border rounded-md focus-within:ring-2 focus-within:ring-offset-2 bg-background transition-[color,box-shadow]",{"border-input focus-within:ring-ring":!s.state,"border-success focus-within:ring-success":s.state==="success","border-warning focus-within:ring-warning":s.state==="warning","border-error focus-within:ring-error":s.state==="error"}),children:[ce("from",F,q),i.jsx("span",{className:z.cn("text-muted-foreground select-none pl-2",{"opacity-30":s.disabled}),children:pe}),ce("to",R,p,{suffixIcon:S.isMobile?re==="drawer"?W:Q:I==="drawer"?W:Q}),s.isFloatLabel&&typeof u=="string"&&i.jsx(Ie.FloatingLabel,{htmlFor:oe,size:s.size,infoTooltip:s.infoTooltip,className:"z-10",shouldFloat:ze,children:u})]})}exports.RangePicker=Ae;
2
2
  //# sourceMappingURL=RangePicker.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RangePicker.cjs","sources":["../../../../src/components/DatePicker/RangePicker.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n CalendarDayButton as SCalendarDayButton,\n type CalendarDayButtonProps as SCalendarDayButtonProps,\n Calendar,\n type CalendarColor,\n} from \"@dsui/ui/components/calendar\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@dsui/ui/components/popover\";\nimport {\n Drawer,\n DrawerContent,\n DrawerDescription,\n DrawerHeader,\n DrawerTitle,\n DrawerTrigger,\n} from \"@dsui/ui/components/drawer\";\nimport { cn } from \"@dsui/ui/index\";\nimport Input, { type InputProps } from \"../Input/Input\";\nimport Button from \"../Button/Button\";\nimport { TimePicker } from \"./TimePicker\";\nimport { type DatePickerProps } from \"./DatePicker\";\nimport { CalendarIcon, MoveRight } from \"lucide-react\";\nimport { isMobile } from \"react-device-detect\";\nimport { format as dfFormat, parse, isValid, type Locale } from \"date-fns\";\nimport { vi, enUS } from \"date-fns/locale\";\nimport { DATE_FORMAT } from \"@/constants/common\";\nimport { FloatingLabel } from \"@/components/FloatLabel\";\n\nexport type DateRange = {\n from?: Date | undefined;\n to?: Date | undefined;\n};\n\nexport type DateRangeText = { from?: string; to?: string } | null;\n\nfunction formatDate(\n date: Date | undefined,\n outputFormat: string = DATE_FORMAT,\n locale?: Locale\n) {\n if (!date) return \"\";\n\n return dfFormat(date, outputFormat, locale ? { locale } : undefined);\n}\n\nconst parseDate = (\n str: string,\n inputFormat: string = DATE_FORMAT\n): Date | undefined => {\n const date = parse(str, inputFormat, new Date());\n return isValid(date) ? date : undefined;\n};\n\nfunction generateMaskFromFormat(format: string): string {\n return format\n .replace(/dd|MM|yyyy/g, (match) => {\n switch (match) {\n case \"dd\":\n case \"MM\":\n return \"99\";\n case \"yyyy\":\n return \"9999\";\n default:\n return match;\n }\n })\n .replace(/d|M|y/g, (match) => {\n switch (match) {\n case \"d\":\n case \"M\":\n return \"9\";\n case \"y\":\n return \"9\";\n default:\n return match;\n }\n });\n}\n\nexport type FormatType = string | { input: string; output: string };\n\nexport type RangePickerRenderProps = {\n fromValue: string;\n toValue: string;\n range?: DateRange;\n onSelect: (range?: DateRange) => void;\n onFromChange: (text: string) => void;\n onToChange: (text: string) => void;\n};\n\nexport type TimeConfig = Omit<\n React.ComponentProps<typeof TimePicker>,\n \"value\" | \"onSelect\" | \"format\"\n>;\n\nexport type RangePickerProps = Omit<\n DatePickerProps,\n \"value\" | \"onChange\" | \"onSelect\" | \"children\" | \"label\" | \"placeholder\"\n> & {\n label?: string | DateRangeText;\n placeholder?: string | DateRangeText;\n value?: DateRangeText;\n onChange?: (value?: DateRange, text?: DateRangeText) => void;\n onSelect?: (value?: DateRange, text?: DateRangeText) => void;\n children?: (props: RangePickerRenderProps) => React.ReactNode;\n separator?: React.ReactNode;\n timeConfig?: [TimeConfig, TimeConfig];\n numberOfMonths?: number;\n variant?: \"default\" | \"rounded\";\n color?: CalendarColor;\n};\n\nexport function RangePicker({\n label,\n value,\n placeholder,\n onChange,\n onSelect,\n calendarClassName,\n side = \"bottom\",\n align = \"end\",\n format = \"dd/MM/yyyy\",\n language = \"vi\",\n mask,\n closeOnSelect = false,\n showOutsideDays = true,\n calendarConfig,\n timeConfig,\n desktopMode = \"popover\",\n mobileMode = \"drawer\",\n children,\n separator = <MoveRight className=\"size-5\" />,\n showTime = false,\n timeFormat = \"HH:mm\",\n hideDate = false,\n numberOfMonths = 1,\n variant = \"default\",\n color = \"primary\",\n ...props\n}: RangePickerProps) {\n const inputId = React.useId();\n\n let inputFormat: string;\n let outputFormat: string;\n if (typeof format === \"string\") {\n inputFormat = format;\n outputFormat = format;\n } else {\n inputFormat = format.input;\n outputFormat = format.output;\n }\n\n // Determine the mask to use\n let maskToUse: string | undefined;\n if (mask === true) {\n maskToUse = generateMaskFromFormat(inputFormat);\n } else if (typeof mask === \"string\") {\n maskToUse = mask;\n }\n\n const initialFromDate = value?.from\n ? parseDate(value.from, inputFormat)\n : undefined;\n const initialToDate = value?.to\n ? parseDate(value.to, inputFormat)\n : undefined;\n const initialRange: DateRange = {\n from: initialFromDate,\n to: initialToDate,\n };\n\n const [open, setOpen] = React.useState(false);\n const [range, setRange] = React.useState<DateRange | undefined>(initialRange);\n const [month, setMonth] = React.useState<Date | undefined>(\n initialFromDate || new Date()\n );\n const [fromInputValue, setFromInputValue] = React.useState(value?.from || \"\");\n const [toInputValue, setToInputValue] = React.useState(value?.to || \"\");\n const [fromTime, setFromTime] = React.useState<Date | undefined>(undefined);\n const [toTime, setToTime] = React.useState<Date | undefined>(undefined);\n const fromInputRef = React.useRef<HTMLInputElement>(null);\n const toInputRef = React.useRef<HTMLInputElement>(null);\n\n const shouldFloat = !!(fromInputValue.trim() || toInputValue.trim());\n\n const _locale: Locale = calendarConfig?.locale\n ? (calendarConfig?.locale as Locale)\n : language === \"en\"\n ? enUS\n : vi;\n\n // Helper to format date-time based on showTime and timeFormat\n const formatDateTimeValue = (d: Date | undefined): string => {\n if (!d) return \"\";\n let result = formatDate(d, outputFormat, _locale);\n if (showTime) {\n result += ` ${dfFormat(d, timeFormat)}`;\n }\n return result;\n };\n\n // Helper functions for render props\n const handleSelectForRenderProp = (range?: DateRange) => {\n setRange(range);\n const fromFormatted = formatDateTimeValue(range?.from);\n const toFormatted = formatDateTimeValue(range?.to);\n setFromInputValue(fromFormatted);\n setToInputValue(toFormatted);\n onSelect?.(range, { from: fromFormatted, to: toFormatted });\n };\n\n const handleFromChangeForRenderProp = (text: string) => {\n setFromInputValue(text);\n\n // If the input is cleared (empty), clear both fields\n if (text.trim() === \"\") {\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = { from: undefined, to: undefined };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n return;\n }\n\n // Try to parse based on showTime\n let parsedDate: Date | undefined;\n if (showTime) {\n parsedDate = parseDate(text, `${inputFormat} ${timeFormat}`);\n } else {\n parsedDate = parseDate(text, inputFormat);\n }\n const newRange: DateRange = { from: parsedDate, to: range?.to };\n if (parsedDate) {\n setRange(newRange);\n setMonth(parsedDate);\n setFromTime(parsedDate);\n onSelect?.(newRange, {\n from: formatDateTimeValue(parsedDate),\n to: formatDateTimeValue(range?.to),\n });\n } else {\n setRange(newRange);\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: formatDateTimeValue(range?.to),\n });\n }\n };\n\n const handleToChangeForRenderProp = (text: string) => {\n setToInputValue(text);\n\n // If the input is cleared (empty), clear both fields\n if (text.trim() === \"\") {\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = { from: undefined, to: undefined };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n return;\n }\n\n // Try to parse based on showTime\n let parsedDate: Date | undefined;\n if (showTime) {\n parsedDate = parseDate(text, `${inputFormat} ${timeFormat}`);\n } else {\n parsedDate = parseDate(text, inputFormat);\n }\n const newRange: DateRange = {\n from: range?.from,\n to: parsedDate,\n };\n if (parsedDate) {\n setRange(newRange);\n setToTime(parsedDate);\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: formatDateTimeValue(parsedDate),\n });\n } else {\n setRange(newRange);\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: undefined,\n });\n }\n };\n\n const handleTimeChangeFrom = (date?: Date) => {\n if (date) {\n setFromTime(date);\n // Merge: keep date (year, month, day) from existing range.from, take time (hours, minutes, seconds) from TimePicker\n const mergedDate = new Date(range?.from || new Date());\n mergedDate.setHours(\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n 0\n );\n\n const newRange: DateRange = {\n from: mergedDate,\n to: range?.to,\n };\n setRange(newRange);\n setFromInputValue(formatDateTimeValue(mergedDate));\n onSelect?.(newRange, {\n from: formatDateTimeValue(mergedDate),\n to: formatDateTimeValue(range?.to),\n });\n onChange?.(newRange, {\n from: formatDateTimeValue(mergedDate),\n to: formatDateTimeValue(range?.to),\n });\n }\n };\n\n const handleTimeChangeTo = (date?: Date) => {\n if (date) {\n setToTime(date);\n // Merge: keep date (year, month, day) from existing range.to, take time (hours, minutes, seconds) from TimePicker\n const mergedDate = new Date(range?.to || new Date());\n mergedDate.setHours(\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n 0\n );\n\n const newRange: DateRange = {\n from: range?.from,\n to: mergedDate,\n };\n setRange(newRange);\n setToInputValue(formatDateTimeValue(mergedDate));\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: formatDateTimeValue(mergedDate),\n });\n onChange?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: formatDateTimeValue(mergedDate),\n });\n }\n };\n\n // Determine trigger component\n const triggerComponent = children ? (\n children({\n fromValue: fromInputValue,\n toValue: toInputValue,\n range,\n onSelect: handleSelectForRenderProp,\n onFromChange: handleFromChangeForRenderProp,\n onToChange: handleToChangeForRenderProp,\n })\n ) : (\n <Button\n variant=\"ghost\"\n className=\"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors\"\n size={props?.size}\n >\n <CalendarIcon\n className={cn({\n \"size-3\": props.size === \"xs\" || props.size === \"sm\",\n \"size-3.5\": !props.size || props.size === \"normal\",\n \"size-4\": props.size === \"lg\" || props.size === \"xl\",\n })}\n />\n <span className=\"sr-only\">Select date range</span>\n </Button>\n );\n\n const calendarSelection = (\n <div\n className={cn(\"flex items-stretch\", showTime && !hideDate ? \"gap-0\" : \"\")}\n >\n {!hideDate && (\n <Calendar\n {...calendarConfig}\n mode=\"range\"\n selected={range as any}\n captionLayout=\"dropdown\"\n month={month}\n onMonthChange={setMonth}\n numberOfMonths={isMobile ? 1 : numberOfMonths || 1}\n variant={variant}\n color={color}\n onSelect={(selectedRange) => {\n // Preserve time from TimePicker values if showTime is enabled\n let preservedRange = selectedRange;\n if (showTime) {\n // Get current time from TimePicker state\n const fromTimeObj = fromTime;\n const toTimeObj = toTime;\n\n preservedRange = {\n from: selectedRange?.from\n ? new Date(\n selectedRange.from.getFullYear(),\n selectedRange.from.getMonth(),\n selectedRange.from.getDate(),\n fromTimeObj?.getHours() || 0,\n fromTimeObj?.getMinutes() || 0,\n fromTimeObj?.getSeconds() || 0\n )\n : undefined,\n to: selectedRange?.to\n ? new Date(\n selectedRange.to.getFullYear(),\n selectedRange.to.getMonth(),\n selectedRange.to.getDate(),\n toTimeObj?.getHours() || 0,\n toTimeObj?.getMinutes() || 0,\n toTimeObj?.getSeconds() || 0\n )\n : undefined,\n };\n }\n setRange(preservedRange);\n const fromFormatted = formatDateTimeValue(preservedRange?.from);\n const toFormatted = formatDateTimeValue(preservedRange?.to);\n setFromInputValue(fromFormatted);\n setToInputValue(toFormatted);\n onSelect?.(preservedRange, {\n from: fromFormatted,\n to: toFormatted,\n });\n onChange?.(preservedRange, {\n from: fromFormatted,\n to: toFormatted,\n });\n if (\n closeOnSelect &&\n preservedRange?.from &&\n preservedRange?.to &&\n !showTime\n ) {\n setOpen(false);\n }\n }}\n locale={_locale}\n formatters={{\n formatMonthDropdown: (date) =>\n date.toLocaleString(_locale.code, { month: \"short\" }),\n }}\n showOutsideDays={showOutsideDays}\n className={cn(\n \"mx-auto\",\n {\n \"[--cell-size:clamp(0px,calc(100vw/7.5),52px)] mb-8 bg-transparent\":\n isMobile || desktopMode === \"drawer\",\n \"[--cell-size:clamp(0px,calc(100vw/7.5),34px)]\":\n !isMobile && desktopMode !== \"drawer\",\n },\n calendarClassName\n )}\n />\n )}\n {showTime && (\n <div className=\"flex gap-0 border-l border-border\">\n <TimePicker\n {...timeConfig?.[0]}\n value={fromTime ? dfFormat(fromTime, timeFormat) : undefined}\n onSelect={handleTimeChangeFrom}\n format={timeFormat}\n showHours\n showMinutes\n showSeconds={timeFormat === \"HH:mm:ss\"}\n standalone={false}\n />\n <div className=\"border-l border-border\" />\n <TimePicker\n {...timeConfig?.[1]}\n value={toTime ? dfFormat(toTime, timeFormat) : undefined}\n onSelect={handleTimeChangeTo}\n format={timeFormat}\n showHours\n showMinutes\n showSeconds={timeFormat === \"HH:mm:ss\"}\n standalone={false}\n />\n </div>\n )}\n </div>\n );\n\n const popPicker = (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild disabled={props.disabled}>\n {triggerComponent}\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n \"w-auto overflow-hidden p-0\",\n \"backdrop-blur bg-background/50\"\n )}\n side={side}\n align={align}\n >\n {calendarSelection}\n </PopoverContent>\n </Popover>\n );\n\n const drawPicker = (\n <Drawer open={open} onOpenChange={setOpen}>\n <DrawerTrigger asChild>{triggerComponent}</DrawerTrigger>\n <DrawerContent\n className={cn(\n \"w-auto overflow-hidden p-0\",\n \"backdrop-blur bg-background\"\n )}\n >\n <DrawerHeader className=\"sr-only\">\n <DrawerTitle>Select date range</DrawerTitle>\n <DrawerDescription>Set your date range</DrawerDescription>\n </DrawerHeader>\n {calendarSelection}\n </DrawerContent>\n </Drawer>\n );\n\n // If children is provided, use render prop pattern with picker\n if (children) {\n const mode = isMobile ? mobileMode : desktopMode;\n return mode === \"drawer\" ? drawPicker : popPicker;\n }\n\n // Helper function to render range input\n const renderRangeInput = (\n type: \"from\" | \"to\",\n inputValue: string,\n setInputValue: (value: string) => void,\n additionalProps?: Partial<InputProps>\n ) => {\n const isFrom = type === \"from\";\n\n return (\n <Input\n {...props}\n {...additionalProps}\n ref={isFrom ? fromInputRef : toInputRef}\n id={inputId}\n size={\n props.isFloatLabel ? (props.size ? props.size : \"xl\") : props.size\n }\n className={cn(\n props.className,\n \"relative peer border-0 focus:ring-0 rounded-none hover:bg-transparent active:bg-transparent focus-visible:ring-0 focus-visible:border-0\",\n isFrom ? \"pr-0\" : \"\"\n )}\n label={\n props.isFloatLabel && typeof label === \"object\"\n ? isFrom\n ? label?.from || \"\"\n : label?.to || \"\"\n : \"\"\n }\n placeholder={\n typeof placeholder === \"object\"\n ? isFrom\n ? placeholder?.from || \"\"\n : placeholder?.to || \"\"\n : placeholder\n }\n clearable={!isFrom}\n value={inputValue}\n mask={maskToUse}\n onChange={(e) => {\n const inputValue = e.target.value;\n setInputValue(inputValue);\n\n // If the input is cleared (empty), clear both fields\n if (inputValue.trim() === \"\") {\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = { from: undefined, to: undefined };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n onChange?.(newRange, newRange as DateRangeText);\n return;\n }\n\n // Try to parse based on showTime\n let date: Date | undefined;\n if (showTime) {\n date = parseDate(inputValue, `${inputFormat} ${timeFormat}`);\n } else {\n date = parseDate(inputValue, inputFormat);\n }\n const newRange: DateRange = isFrom\n ? { from: date, to: range?.to }\n : { from: range?.from, to: date };\n\n if (date) {\n setRange(newRange);\n if (isFrom) setMonth(date);\n // Update time state if time was parsed\n if (isFrom) {\n setFromTime(date);\n // setFromInputValue(formatDateTimeValue(date)); // Sync input value\n } else {\n setToTime(date);\n // setToInputValue(formatDateTimeValue(date)); // Sync input value\n }\n const fromFormatted = formatDateTimeValue(\n isFrom ? date : range?.from\n );\n const toFormatted = formatDateTimeValue(isFrom ? range?.to : date);\n onSelect?.(newRange, { from: fromFormatted, to: toFormatted });\n onChange?.(newRange, {\n from: isFrom ? inputValue : fromInputValue,\n to: isFrom ? toInputValue : inputValue,\n });\n\n // If from input and date is valid, auto-focus to to input if to is empty\n // if (isFrom && toInputRef.current && !toInputValue.trim()) {\n // requestAnimationFrame(() => toInputRef.current?.focus());\n // }\n } else {\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: isFrom ? formatDateTimeValue(range?.to) : undefined,\n });\n onChange?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: isFrom ? formatDateTimeValue(range?.to) : undefined,\n });\n }\n }}\n onClear={\n !isFrom\n ? () => {\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = { from: undefined, to: undefined };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n onChange?.(newRange, newRange as DateRangeText);\n }\n : undefined\n }\n onBlur={() => {\n // Check if blurring out of the entire range picker group\n const activeElement = document.activeElement;\n if (\n activeElement !== fromInputRef.current &&\n activeElement !== toInputRef.current\n ) {\n // Delay validation by 100ms\n setTimeout(() => {\n // Check again if still blurred out of the group\n const currentActiveElement = document.activeElement;\n if (\n currentActiveElement !== fromInputRef.current &&\n currentActiveElement !== toInputRef.current\n ) {\n // Blurred out of the group, validate both inputs\n const validateInput = (val: string) => {\n if (val.trim() === \"\") return true; // empty is valid (will clear)\n let parsed: Date | undefined;\n if (showTime) {\n parsed = parseDate(val, `${inputFormat} ${timeFormat}`);\n } else {\n parsed = parseDate(val, inputFormat);\n }\n return !!parsed;\n };\n\n const fromValid = validateInput(fromInputValue);\n const toValid = validateInput(toInputValue);\n\n // Clear if either is invalid, or if only one has value\n const shouldClear =\n !fromValid ||\n !toValid ||\n (fromInputValue.trim() && !toInputValue.trim()) ||\n (!fromInputValue.trim() && toInputValue.trim());\n\n if (shouldClear) {\n // If either is invalid, clear both\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = {\n from: undefined,\n to: undefined,\n };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n onChange?.(newRange, newRange as DateRangeText);\n }\n }\n }, 100);\n }\n }}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setOpen(true);\n }\n }}\n />\n );\n };\n\n // Default input rendering with two inputs\n return (\n <div\n className={cn(\n \"group relative flex items-center border rounded-md focus-within:ring-2 focus-within:ring-offset-2 bg-background transition-[color,box-shadow]\",\n {\n \"border-input focus-within:ring-ring\": !props.state,\n \"border-success focus-within:ring-success\": props.state === \"success\",\n \"border-warning focus-within:ring-warning\": props.state === \"warning\",\n \"border-error focus-within:ring-error\": props.state === \"error\",\n }\n )}\n >\n {renderRangeInput(\"from\", fromInputValue, setFromInputValue)}\n <span\n className={cn(\"text-muted-foreground select-none pl-2\", {\n \"opacity-30\": props.disabled,\n })}\n >\n {separator}\n </span>\n {renderRangeInput(\"to\", toInputValue, setToInputValue, {\n suffixIcon: isMobile\n ? mobileMode === \"drawer\"\n ? drawPicker\n : popPicker\n : desktopMode === \"drawer\"\n ? drawPicker\n : popPicker,\n })}\n {props.isFloatLabel && typeof label === \"string\" && (\n <FloatingLabel\n htmlFor={inputId}\n size={props.size}\n infoTooltip={props.infoTooltip}\n className=\"z-10\"\n shouldFloat={shouldFloat}\n >\n {label}\n </FloatingLabel>\n )}\n </div>\n );\n}\n\nexport const CalendarDayButton = SCalendarDayButton;\nexport type CalendarDayButtonProps = SCalendarDayButtonProps;\n"],"names":["formatDate","date","outputFormat","DATE_FORMAT","locale","dfFormat","parseDate","str","inputFormat","parse","isValid","generateMaskFromFormat","format","match","RangePicker","label","value","placeholder","onChange","onSelect","calendarClassName","side","align","language","mask","closeOnSelect","showOutsideDays","calendarConfig","timeConfig","desktopMode","mobileMode","children","separator","jsx","MoveRight","showTime","timeFormat","hideDate","numberOfMonths","variant","color","props","inputId","React","maskToUse","initialFromDate","initialToDate","initialRange","open","setOpen","range","setRange","month","setMonth","fromInputValue","setFromInputValue","toInputValue","setToInputValue","fromTime","setFromTime","toTime","setToTime","fromInputRef","toInputRef","shouldFloat","_locale","enUS","vi","formatDateTimeValue","d","result","handleSelectForRenderProp","fromFormatted","toFormatted","handleFromChangeForRenderProp","text","newRange","parsedDate","handleToChangeForRenderProp","handleTimeChangeFrom","mergedDate","handleTimeChangeTo","triggerComponent","jsxs","Button","CalendarIcon","cn","calendarSelection","Calendar","isMobile","selectedRange","preservedRange","fromTimeObj","toTimeObj","TimePicker","popPicker","Popover","PopoverTrigger","PopoverContent","drawPicker","Drawer","DrawerTrigger","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","renderRangeInput","type","inputValue","setInputValue","additionalProps","isFrom","Input","e","activeElement","currentActiveElement","validateInput","val","parsed","fromValid","toValid","FloatingLabel"],"mappings":"+pEAuCA,SAASA,GACPC,EACAC,EAAuBC,GAAAA,YACvBC,EACA,CACA,OAAKH,EAEEI,EAAAA,OAASJ,EAAMC,EAAcE,EAAS,CAAE,OAAAA,CAAA,EAAW,MAAS,EAFjD,EAGpB,CAEA,MAAME,EAAY,CAChBC,EACAC,EAAsBL,iBACD,CACrB,MAAMF,EAAOQ,EAAAA,MAAMF,EAAKC,EAAa,IAAI,IAAM,EAC/C,OAAOE,UAAQT,CAAI,EAAIA,EAAO,MAChC,EAEA,SAASU,GAAuBC,EAAwB,CACtD,OAAOA,EACJ,QAAQ,cAAgBC,GAAU,CACjC,OAAQA,EAAA,CACN,IAAK,KACL,IAAK,KACH,MAAO,KACT,IAAK,OACH,MAAO,OACT,QACE,OAAOA,CAAA,CAEb,CAAC,EACA,QAAQ,SAAWA,GAAU,CAC5B,OAAQA,EAAA,CACN,IAAK,IACL,IAAK,IACH,MAAO,IACT,IAAK,IACH,MAAO,IACT,QACE,OAAOA,CAAA,CAEb,CAAC,CACL,CAmCO,SAASC,GAAY,CAC1B,MAAAC,EACA,MAAAC,EACA,YAAAC,EACA,SAAAC,EACA,SAAAC,EACA,kBAAAC,GACA,KAAAC,GAAO,SACP,MAAAC,GAAQ,MACR,OAAAV,EAAS,aACT,SAAAW,GAAW,KACX,KAAAC,EACA,cAAAC,GAAgB,GAChB,gBAAAC,GAAkB,GAClB,eAAAC,EACA,WAAAC,GACA,YAAAC,EAAc,UACd,WAAAC,GA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DatePicker/RangePicker.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n CalendarDayButton as SCalendarDayButton,\n type CalendarDayButtonProps as SCalendarDayButtonProps,\n Calendar,\n type CalendarColor,\n} from \"@dsui/ui/components/calendar\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@dsui/ui/components/popover\";\nimport {\n Drawer,\n DrawerContent,\n DrawerDescription,\n DrawerHeader,\n DrawerTitle,\n DrawerTrigger,\n} from \"@dsui/ui/components/drawer\";\nimport { cn } from \"@dsui/ui/index\";\nimport { Input, type InputProps } from \"../Input\";\nimport { Button } from \"../Button\";\nimport { TimePicker } from \"./TimePicker\";\nimport { type DatePickerProps } from \"./DatePicker\";\nimport { CalendarIcon, MoveRight } from \"lucide-react\";\nimport { isMobile } from \"react-device-detect\";\nimport { format as dfFormat, parse, isValid, type Locale } from \"date-fns\";\nimport { vi, enUS } from \"date-fns/locale\";\nimport { DATE_FORMAT } from \"@/constants/common\";\nimport { FloatingLabel } from \"@/components/FloatLabel\";\n\nexport type DateRange = {\n from?: Date | undefined;\n to?: Date | undefined;\n};\n\nexport type DateRangeText = { from?: string; to?: string } | null;\n\nfunction formatDate(\n date: Date | undefined,\n outputFormat: string = DATE_FORMAT,\n locale?: Locale\n) {\n if (!date) return \"\";\n\n return dfFormat(date, outputFormat, locale ? { locale } : undefined);\n}\n\nconst parseDate = (\n str: string,\n inputFormat: string = DATE_FORMAT\n): Date | undefined => {\n const date = parse(str, inputFormat, new Date());\n return isValid(date) ? date : undefined;\n};\n\nfunction generateMaskFromFormat(format: string): string {\n return format\n .replace(/dd|MM|yyyy/g, (match) => {\n switch (match) {\n case \"dd\":\n case \"MM\":\n return \"99\";\n case \"yyyy\":\n return \"9999\";\n default:\n return match;\n }\n })\n .replace(/d|M|y/g, (match) => {\n switch (match) {\n case \"d\":\n case \"M\":\n return \"9\";\n case \"y\":\n return \"9\";\n default:\n return match;\n }\n });\n}\n\nexport type FormatType = string | { input: string; output: string };\n\nexport type RangePickerRenderProps = {\n fromValue: string;\n toValue: string;\n range?: DateRange;\n onSelect: (range?: DateRange) => void;\n onFromChange: (text: string) => void;\n onToChange: (text: string) => void;\n};\n\nexport type TimeConfig = Omit<\n React.ComponentProps<typeof TimePicker>,\n \"value\" | \"onSelect\" | \"format\"\n>;\n\nexport type RangePickerProps = Omit<\n DatePickerProps,\n \"value\" | \"onChange\" | \"onSelect\" | \"children\" | \"label\" | \"placeholder\"\n> & {\n label?: string | DateRangeText;\n placeholder?: string | DateRangeText;\n value?: DateRangeText;\n onChange?: (value?: DateRange, text?: DateRangeText) => void;\n onSelect?: (value?: DateRange, text?: DateRangeText) => void;\n children?: (props: RangePickerRenderProps) => React.ReactNode;\n separator?: React.ReactNode;\n timeConfig?: [TimeConfig, TimeConfig];\n numberOfMonths?: number;\n variant?: \"default\" | \"rounded\";\n color?: CalendarColor;\n};\n\nexport function RangePicker({\n label,\n value,\n placeholder,\n onChange,\n onSelect,\n calendarClassName,\n side = \"bottom\",\n align = \"end\",\n format = \"dd/MM/yyyy\",\n language = \"vi\",\n mask,\n closeOnSelect = false,\n showOutsideDays = true,\n calendarConfig,\n timeConfig,\n desktopMode = \"popover\",\n mobileMode = \"drawer\",\n children,\n separator = <MoveRight className=\"size-5\" />,\n showTime = false,\n timeFormat = \"HH:mm\",\n hideDate = false,\n numberOfMonths = 1,\n variant = \"default\",\n color = \"primary\",\n ...props\n}: RangePickerProps) {\n const inputId = React.useId();\n\n let inputFormat: string;\n let outputFormat: string;\n if (typeof format === \"string\") {\n inputFormat = format;\n outputFormat = format;\n } else {\n inputFormat = format.input;\n outputFormat = format.output;\n }\n\n // Determine the mask to use\n let maskToUse: string | undefined;\n if (mask === true) {\n maskToUse = generateMaskFromFormat(inputFormat);\n } else if (typeof mask === \"string\") {\n maskToUse = mask;\n }\n\n const initialFromDate = value?.from\n ? parseDate(value.from, inputFormat)\n : undefined;\n const initialToDate = value?.to\n ? parseDate(value.to, inputFormat)\n : undefined;\n const initialRange: DateRange = {\n from: initialFromDate,\n to: initialToDate,\n };\n\n const [open, setOpen] = React.useState(false);\n const [range, setRange] = React.useState<DateRange | undefined>(initialRange);\n const [month, setMonth] = React.useState<Date | undefined>(\n initialFromDate || new Date()\n );\n const [fromInputValue, setFromInputValue] = React.useState(value?.from || \"\");\n const [toInputValue, setToInputValue] = React.useState(value?.to || \"\");\n const [fromTime, setFromTime] = React.useState<Date | undefined>(undefined);\n const [toTime, setToTime] = React.useState<Date | undefined>(undefined);\n const fromInputRef = React.useRef<HTMLInputElement>(null);\n const toInputRef = React.useRef<HTMLInputElement>(null);\n\n const shouldFloat = !!(fromInputValue.trim() || toInputValue.trim());\n\n const _locale: Locale = calendarConfig?.locale\n ? (calendarConfig?.locale as Locale)\n : language === \"en\"\n ? enUS\n : vi;\n\n // Helper to format date-time based on showTime and timeFormat\n const formatDateTimeValue = (d: Date | undefined): string => {\n if (!d) return \"\";\n let result = formatDate(d, outputFormat, _locale);\n if (showTime) {\n result += ` ${dfFormat(d, timeFormat)}`;\n }\n return result;\n };\n\n // Helper functions for render props\n const handleSelectForRenderProp = (range?: DateRange) => {\n setRange(range);\n const fromFormatted = formatDateTimeValue(range?.from);\n const toFormatted = formatDateTimeValue(range?.to);\n setFromInputValue(fromFormatted);\n setToInputValue(toFormatted);\n onSelect?.(range, { from: fromFormatted, to: toFormatted });\n };\n\n const handleFromChangeForRenderProp = (text: string) => {\n setFromInputValue(text);\n\n // If the input is cleared (empty), clear both fields\n if (text.trim() === \"\") {\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = { from: undefined, to: undefined };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n return;\n }\n\n // Try to parse based on showTime\n let parsedDate: Date | undefined;\n if (showTime) {\n parsedDate = parseDate(text, `${inputFormat} ${timeFormat}`);\n } else {\n parsedDate = parseDate(text, inputFormat);\n }\n const newRange: DateRange = { from: parsedDate, to: range?.to };\n if (parsedDate) {\n setRange(newRange);\n setMonth(parsedDate);\n setFromTime(parsedDate);\n onSelect?.(newRange, {\n from: formatDateTimeValue(parsedDate),\n to: formatDateTimeValue(range?.to),\n });\n } else {\n setRange(newRange);\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: formatDateTimeValue(range?.to),\n });\n }\n };\n\n const handleToChangeForRenderProp = (text: string) => {\n setToInputValue(text);\n\n // If the input is cleared (empty), clear both fields\n if (text.trim() === \"\") {\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = { from: undefined, to: undefined };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n return;\n }\n\n // Try to parse based on showTime\n let parsedDate: Date | undefined;\n if (showTime) {\n parsedDate = parseDate(text, `${inputFormat} ${timeFormat}`);\n } else {\n parsedDate = parseDate(text, inputFormat);\n }\n const newRange: DateRange = {\n from: range?.from,\n to: parsedDate,\n };\n if (parsedDate) {\n setRange(newRange);\n setToTime(parsedDate);\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: formatDateTimeValue(parsedDate),\n });\n } else {\n setRange(newRange);\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: undefined,\n });\n }\n };\n\n const handleTimeChangeFrom = (date?: Date) => {\n if (date) {\n setFromTime(date);\n // Merge: keep date (year, month, day) from existing range.from, take time (hours, minutes, seconds) from TimePicker\n const mergedDate = new Date(range?.from || new Date());\n mergedDate.setHours(\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n 0\n );\n\n const newRange: DateRange = {\n from: mergedDate,\n to: range?.to,\n };\n setRange(newRange);\n setFromInputValue(formatDateTimeValue(mergedDate));\n onSelect?.(newRange, {\n from: formatDateTimeValue(mergedDate),\n to: formatDateTimeValue(range?.to),\n });\n onChange?.(newRange, {\n from: formatDateTimeValue(mergedDate),\n to: formatDateTimeValue(range?.to),\n });\n }\n };\n\n const handleTimeChangeTo = (date?: Date) => {\n if (date) {\n setToTime(date);\n // Merge: keep date (year, month, day) from existing range.to, take time (hours, minutes, seconds) from TimePicker\n const mergedDate = new Date(range?.to || new Date());\n mergedDate.setHours(\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n 0\n );\n\n const newRange: DateRange = {\n from: range?.from,\n to: mergedDate,\n };\n setRange(newRange);\n setToInputValue(formatDateTimeValue(mergedDate));\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: formatDateTimeValue(mergedDate),\n });\n onChange?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: formatDateTimeValue(mergedDate),\n });\n }\n };\n\n // Determine trigger component\n const triggerComponent = children ? (\n children({\n fromValue: fromInputValue,\n toValue: toInputValue,\n range,\n onSelect: handleSelectForRenderProp,\n onFromChange: handleFromChangeForRenderProp,\n onToChange: handleToChangeForRenderProp,\n })\n ) : (\n <Button\n variant=\"ghost\"\n className=\"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors\"\n size={props?.size}\n >\n <CalendarIcon\n className={cn({\n \"size-3\": props.size === \"xs\" || props.size === \"sm\",\n \"size-3.5\": !props.size || props.size === \"normal\",\n \"size-4\": props.size === \"lg\" || props.size === \"xl\",\n })}\n />\n <span className=\"sr-only\">Select date range</span>\n </Button>\n );\n\n const calendarSelection = (\n <div\n className={cn(\"flex items-stretch\", showTime && !hideDate ? \"gap-0\" : \"\")}\n >\n {!hideDate && (\n <Calendar\n {...calendarConfig}\n mode=\"range\"\n selected={range as any}\n captionLayout=\"dropdown\"\n month={month}\n onMonthChange={setMonth}\n numberOfMonths={isMobile ? 1 : numberOfMonths || 1}\n variant={variant}\n color={color}\n onSelect={(selectedRange) => {\n // Preserve time from TimePicker values if showTime is enabled\n let preservedRange = selectedRange;\n if (showTime) {\n // Get current time from TimePicker state\n const fromTimeObj = fromTime;\n const toTimeObj = toTime;\n\n preservedRange = {\n from: selectedRange?.from\n ? new Date(\n selectedRange.from.getFullYear(),\n selectedRange.from.getMonth(),\n selectedRange.from.getDate(),\n fromTimeObj?.getHours() || 0,\n fromTimeObj?.getMinutes() || 0,\n fromTimeObj?.getSeconds() || 0\n )\n : undefined,\n to: selectedRange?.to\n ? new Date(\n selectedRange.to.getFullYear(),\n selectedRange.to.getMonth(),\n selectedRange.to.getDate(),\n toTimeObj?.getHours() || 0,\n toTimeObj?.getMinutes() || 0,\n toTimeObj?.getSeconds() || 0\n )\n : undefined,\n };\n }\n setRange(preservedRange);\n const fromFormatted = formatDateTimeValue(preservedRange?.from);\n const toFormatted = formatDateTimeValue(preservedRange?.to);\n setFromInputValue(fromFormatted);\n setToInputValue(toFormatted);\n onSelect?.(preservedRange, {\n from: fromFormatted,\n to: toFormatted,\n });\n onChange?.(preservedRange, {\n from: fromFormatted,\n to: toFormatted,\n });\n if (\n closeOnSelect &&\n preservedRange?.from &&\n preservedRange?.to &&\n !showTime\n ) {\n setOpen(false);\n }\n }}\n locale={_locale}\n formatters={{\n formatMonthDropdown: (date) =>\n date.toLocaleString(_locale.code, { month: \"short\" }),\n }}\n showOutsideDays={showOutsideDays}\n className={cn(\n \"mx-auto\",\n {\n \"[--cell-size:clamp(0px,calc(100vw/7.5),52px)] mb-8 bg-transparent\":\n isMobile || desktopMode === \"drawer\",\n \"[--cell-size:clamp(0px,calc(100vw/7.5),34px)]\":\n !isMobile && desktopMode !== \"drawer\",\n },\n calendarClassName\n )}\n />\n )}\n {showTime && (\n <div className=\"flex gap-0 border-l border-border\">\n <TimePicker\n {...timeConfig?.[0]}\n value={fromTime ? dfFormat(fromTime, timeFormat) : undefined}\n onSelect={handleTimeChangeFrom}\n format={timeFormat}\n showHours\n showMinutes\n showSeconds={timeFormat === \"HH:mm:ss\"}\n standalone={false}\n />\n <div className=\"border-l border-border\" />\n <TimePicker\n {...timeConfig?.[1]}\n value={toTime ? dfFormat(toTime, timeFormat) : undefined}\n onSelect={handleTimeChangeTo}\n format={timeFormat}\n showHours\n showMinutes\n showSeconds={timeFormat === \"HH:mm:ss\"}\n standalone={false}\n />\n </div>\n )}\n </div>\n );\n\n const popPicker = (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild disabled={props.disabled}>\n {triggerComponent}\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n \"w-auto overflow-hidden p-0\",\n \"backdrop-blur bg-background/50\"\n )}\n side={side}\n align={align}\n >\n {calendarSelection}\n </PopoverContent>\n </Popover>\n );\n\n const drawPicker = (\n <Drawer open={open} onOpenChange={setOpen}>\n <DrawerTrigger asChild>{triggerComponent}</DrawerTrigger>\n <DrawerContent\n className={cn(\n \"w-auto overflow-hidden p-0\",\n \"backdrop-blur bg-background\"\n )}\n >\n <DrawerHeader className=\"sr-only\">\n <DrawerTitle>Select date range</DrawerTitle>\n <DrawerDescription>Set your date range</DrawerDescription>\n </DrawerHeader>\n {calendarSelection}\n </DrawerContent>\n </Drawer>\n );\n\n // If children is provided, use render prop pattern with picker\n if (children) {\n const mode = isMobile ? mobileMode : desktopMode;\n return mode === \"drawer\" ? drawPicker : popPicker;\n }\n\n // Helper function to render range input\n const renderRangeInput = (\n type: \"from\" | \"to\",\n inputValue: string,\n setInputValue: (value: string) => void,\n additionalProps?: Partial<InputProps>\n ) => {\n const isFrom = type === \"from\";\n\n return (\n <Input\n {...props}\n {...additionalProps}\n ref={isFrom ? fromInputRef : toInputRef}\n id={inputId}\n size={\n props.isFloatLabel ? (props.size ? props.size : \"xl\") : props.size\n }\n className={cn(\n props.className,\n \"relative peer border-0 focus:ring-0 rounded-none hover:bg-transparent active:bg-transparent focus-visible:ring-0 focus-visible:border-0\",\n isFrom ? \"pr-0\" : \"\"\n )}\n label={\n props.isFloatLabel && typeof label === \"object\"\n ? isFrom\n ? label?.from || \"\"\n : label?.to || \"\"\n : \"\"\n }\n placeholder={\n typeof placeholder === \"object\"\n ? isFrom\n ? placeholder?.from || \"\"\n : placeholder?.to || \"\"\n : placeholder\n }\n clearable={!isFrom}\n value={inputValue}\n mask={maskToUse}\n onChange={(e) => {\n const inputValue = e.target.value;\n setInputValue(inputValue);\n\n // If the input is cleared (empty), clear both fields\n if (inputValue.trim() === \"\") {\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = { from: undefined, to: undefined };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n onChange?.(newRange, newRange as DateRangeText);\n return;\n }\n\n // Try to parse based on showTime\n let date: Date | undefined;\n if (showTime) {\n date = parseDate(inputValue, `${inputFormat} ${timeFormat}`);\n } else {\n date = parseDate(inputValue, inputFormat);\n }\n const newRange: DateRange = isFrom\n ? { from: date, to: range?.to }\n : { from: range?.from, to: date };\n\n if (date) {\n setRange(newRange);\n if (isFrom) setMonth(date);\n // Update time state if time was parsed\n if (isFrom) {\n setFromTime(date);\n // setFromInputValue(formatDateTimeValue(date)); // Sync input value\n } else {\n setToTime(date);\n // setToInputValue(formatDateTimeValue(date)); // Sync input value\n }\n const fromFormatted = formatDateTimeValue(\n isFrom ? date : range?.from\n );\n const toFormatted = formatDateTimeValue(isFrom ? range?.to : date);\n onSelect?.(newRange, { from: fromFormatted, to: toFormatted });\n onChange?.(newRange, {\n from: isFrom ? inputValue : fromInputValue,\n to: isFrom ? toInputValue : inputValue,\n });\n\n // If from input and date is valid, auto-focus to to input if to is empty\n // if (isFrom && toInputRef.current && !toInputValue.trim()) {\n // requestAnimationFrame(() => toInputRef.current?.focus());\n // }\n } else {\n onSelect?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: isFrom ? formatDateTimeValue(range?.to) : undefined,\n });\n onChange?.(newRange, {\n from: formatDateTimeValue(range?.from),\n to: isFrom ? formatDateTimeValue(range?.to) : undefined,\n });\n }\n }}\n onClear={\n !isFrom\n ? () => {\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = { from: undefined, to: undefined };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n onChange?.(newRange, newRange as DateRangeText);\n }\n : undefined\n }\n onBlur={() => {\n // Check if blurring out of the entire range picker group\n const activeElement = document.activeElement;\n if (\n activeElement !== fromInputRef.current &&\n activeElement !== toInputRef.current\n ) {\n // Delay validation by 100ms\n setTimeout(() => {\n // Check again if still blurred out of the group\n const currentActiveElement = document.activeElement;\n if (\n currentActiveElement !== fromInputRef.current &&\n currentActiveElement !== toInputRef.current\n ) {\n // Blurred out of the group, validate both inputs\n const validateInput = (val: string) => {\n if (val.trim() === \"\") return true; // empty is valid (will clear)\n let parsed: Date | undefined;\n if (showTime) {\n parsed = parseDate(val, `${inputFormat} ${timeFormat}`);\n } else {\n parsed = parseDate(val, inputFormat);\n }\n return !!parsed;\n };\n\n const fromValid = validateInput(fromInputValue);\n const toValid = validateInput(toInputValue);\n\n // Clear if either is invalid, or if only one has value\n const shouldClear =\n !fromValid ||\n !toValid ||\n (fromInputValue.trim() && !toInputValue.trim()) ||\n (!fromInputValue.trim() && toInputValue.trim());\n\n if (shouldClear) {\n // If either is invalid, clear both\n setFromInputValue(\"\");\n setToInputValue(\"\");\n const newRange: DateRange = {\n from: undefined,\n to: undefined,\n };\n setRange(newRange);\n onSelect?.(newRange, newRange as DateRangeText);\n onChange?.(newRange, newRange as DateRangeText);\n }\n }\n }, 100);\n }\n }}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setOpen(true);\n }\n }}\n />\n );\n };\n\n // Default input rendering with two inputs\n return (\n <div\n className={cn(\n \"group relative flex items-center border rounded-md focus-within:ring-2 focus-within:ring-offset-2 bg-background transition-[color,box-shadow]\",\n {\n \"border-input focus-within:ring-ring\": !props.state,\n \"border-success focus-within:ring-success\": props.state === \"success\",\n \"border-warning focus-within:ring-warning\": props.state === \"warning\",\n \"border-error focus-within:ring-error\": props.state === \"error\",\n }\n )}\n >\n {renderRangeInput(\"from\", fromInputValue, setFromInputValue)}\n <span\n className={cn(\"text-muted-foreground select-none pl-2\", {\n \"opacity-30\": props.disabled,\n })}\n >\n {separator}\n </span>\n {renderRangeInput(\"to\", toInputValue, setToInputValue, {\n suffixIcon: isMobile\n ? mobileMode === \"drawer\"\n ? drawPicker\n : popPicker\n : desktopMode === \"drawer\"\n ? drawPicker\n : popPicker,\n })}\n {props.isFloatLabel && typeof label === \"string\" && (\n <FloatingLabel\n htmlFor={inputId}\n size={props.size}\n infoTooltip={props.infoTooltip}\n className=\"z-10\"\n shouldFloat={shouldFloat}\n >\n {label}\n </FloatingLabel>\n )}\n </div>\n );\n}\n\nexport const CalendarDayButton = SCalendarDayButton;\nexport type CalendarDayButtonProps = SCalendarDayButtonProps;\n"],"names":["formatDate","date","outputFormat","DATE_FORMAT","locale","dfFormat","parseDate","str","inputFormat","parse","isValid","generateMaskFromFormat","format","match","RangePicker","label","value","placeholder","onChange","onSelect","calendarClassName","side","align","language","mask","closeOnSelect","showOutsideDays","calendarConfig","timeConfig","desktopMode","mobileMode","children","separator","jsx","MoveRight","showTime","timeFormat","hideDate","numberOfMonths","variant","color","props","inputId","React","maskToUse","initialFromDate","initialToDate","initialRange","open","setOpen","range","setRange","month","setMonth","fromInputValue","setFromInputValue","toInputValue","setToInputValue","fromTime","setFromTime","toTime","setToTime","fromInputRef","toInputRef","shouldFloat","_locale","enUS","vi","formatDateTimeValue","d","result","handleSelectForRenderProp","fromFormatted","toFormatted","handleFromChangeForRenderProp","text","newRange","parsedDate","handleToChangeForRenderProp","handleTimeChangeFrom","mergedDate","handleTimeChangeTo","triggerComponent","jsxs","Button","CalendarIcon","cn","calendarSelection","Calendar","isMobile","selectedRange","preservedRange","fromTimeObj","toTimeObj","TimePicker","popPicker","Popover","PopoverTrigger","PopoverContent","drawPicker","Drawer","DrawerTrigger","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","renderRangeInput","type","inputValue","setInputValue","additionalProps","isFrom","Input","e","activeElement","currentActiveElement","validateInput","val","parsed","fromValid","toValid","FloatingLabel"],"mappings":"+pEAuCA,SAASA,GACPC,EACAC,EAAuBC,GAAAA,YACvBC,EACA,CACA,OAAKH,EAEEI,EAAAA,OAASJ,EAAMC,EAAcE,EAAS,CAAE,OAAAA,CAAA,EAAW,MAAS,EAFj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,EAEhB,CAAA,CAAA,CAGN,EAGA,OACEkC,EAAAA,KAAC,MAAA,CACC,UAAWG,EAAAA,GACT,gJACA,CACE,sCAAuC,CAAC7C,EAAM,MAC9C,2CAA4CA,EAAM,QAAU,UAC5D,2CAA4CA,EAAM,QAAU,UAC5D,uCAAwCA,EAAM,QAAU,OAAA,CAC1D,EAGD,SAAA,CAAAiE,GAAiB,OAAQpD,EAAgBC,CAAiB,EAC3DtB,EAAAA,IAAC,OAAA,CACC,UAAWqD,EAAAA,GAAG,yCAA0C,CACtD,aAAc7C,EAAM,QAAA,CACrB,EAEA,SAAAT,EAAA,CAAA,EAEF0E,GAAiB,KAAMlD,EAAcC,EAAiB,CACrD,WAAYgC,EAAAA,SACR3D,KAAe,SACbqE,EACAJ,EACFlE,IAAgB,SACdsE,EACAJ,CAAA,CACP,EACAtD,EAAM,cAAgB,OAAO1B,GAAU,UACtCkB,EAAAA,IAACwF,GAAAA,cAAA,CACC,QAAS/E,GACT,KAAMD,EAAM,KACZ,YAAaA,EAAM,YACnB,UAAU,OACV,YAAAuB,GAEC,SAAAjD,CAAA,CAAA,CACH,CAAA,CAAA,CAIR"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("react");require("@radix-ui/react-slot");require("../../packages/ui/src/components/button.cjs");require("../../packages/ui/src/components/button-group.cjs");require("../../packages/ui/src/components/input.cjs");require("../../packages/ui/src/components/textarea.cjs");require("@radix-ui/react-label");const b=require("../../packages/ui/src/lib/utils.cjs");require("../../packages/ui/src/components/select.cjs");require("../../packages/ui/src/components/combobox.cjs");require("@radix-ui/react-tooltip");const Oe=require("lucide-react");require("react-day-picker");const Y=require("../../packages/ui/src/components/popover.cjs");require("@radix-ui/react-separator");require("../../packages/ui/src/components/switch.cjs");const M=require("../../packages/ui/src/components/drawer.cjs");require("@radix-ui/react-scroll-area");require("../../packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("../../packages/ui/src/components/badge.cjs");require("../../packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("../../packages/ui/src/components/input-otp.cjs");require("../../packages/ui/src/components/radio-group.cjs");require("../../packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("../../packages/ui/src/components/tabs.cjs");require("../../packages/ui/src/components/toggle.cjs");const Z=require("../Button/Button.cjs"),Fe=require("../Select/Select.cjs"),Ie=require("../Input/Input.cjs"),je=require("react-device-detect"),_=require("../WheelColumn.cjs"),Ee=require("../TimeGridView.cjs"),E=require("date-fns"),B=(i,h=1)=>{const C=[];for(let x=0;x<i;x+=h)C.push(x);return C},I=i=>String(i).padStart(2,"0"),we=(i,h="HH:mm")=>!i||!E.isValid(i)?"":E.format(i,h),He=(i,h="HH:mm")=>{if(!i)return;const C=new Date,x=E.parse(i,h,C);if(E.isValid(x))return x};function $e(i){return i.replace(/HH|mm|ss/g,h=>{switch(h){case"HH":case"mm":case"ss":return"99";default:return h}}).replace(/H|m|s/g,()=>"9")}function ze({value:i,onChange:h,onSelect:C,showHours:x=!0,showMinutes:L=!0,showSeconds:k=!1,disabled:v=!1,className:ee,timeLabel:u,mask:$,format:S,mode:a="wheel",hourInterval:se=1,minuteInterval:te=1,secondInterval:re=1,disabledTimes:ne=[],disabledTimeRanges:oe=[],showNowButton:ie=!1,nowButtonLabel:ce="Now",standalone:ue=!0,desktopMode:ae="popover",mobileMode:Te="drawer",color:O="primary",...Ne}){let j,w;typeof S=="string"?(j=S,w=S):S?(j=S.input,w=S.output):(j=k?"HH:mm:ss":"HH:mm",w=k?"HH:mm:ss":"HH:mm");const[p,H]=n.useState(void 0),[g,T]=n.useState(void 0),[q,N]=n.useState(void 0),[z,le]=n.useState(!1);n.useEffect(()=>{if(i){const e=He(i,j);e&&(H(e.getHours()),T(e.getMinutes()),N(e.getSeconds()))}else H(void 0),T(void 0),N(void 0)},[i,j]);const U=n.useRef(null),G=n.useRef(null),A=n.useRef(null),W=n.useRef(null),D=n.useMemo(()=>B(24,se),[se]),y=n.useMemo(()=>B(60,te),[te]),R=n.useMemo(()=>B(60,re),[re]),l=n.useCallback((e,s,r=0)=>{const o=`${I(e??0)}:${I(s??0)}${k?`:${I(r??0)}`:""}`;if(ne.includes(o))return!0;for(const d of oe){const[f,c,m=0]=d.from.split(":").map(Number),[F,ke,Re=0]=d.to.split(":").map(Number),be=(e??0)*3600+(s??0)*60+(r??0),Pe=f*3600+c*60+m,Ve=F*3600+ke*60+Re;if(be>=Pe&&be<=Ve)return!0}return!1},[ne,oe,k]),J=n.useCallback(e=>{if(u)return typeof u=="boolean"?u?e==="hours"?"Hour":e==="minutes"?"Minute":"Second":void 0:typeof u=="string"?u:e==="hours"?u.hours||"Hour":e==="minutes"?u.minutes||"Minute":u.seconds||"Second"},[u]),fe=typeof u=="string"&&t.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase p-2 border-b w-full text-center",children:u},"common-label"),Se=n.useCallback((e,s,r=0)=>{const o=D.reduce((c,m)=>Math.abs(m-e)<Math.abs(c-e)?m:c),d=y.reduce((c,m)=>Math.abs(m-s)<Math.abs(c-s)?m:c),f=R.reduce((c,m)=>Math.abs(m-r)<Math.abs(c-r)?m:c);if(l(o,d,f)){for(const c of D)for(const m of y)for(const F of R)if(!l(c,m,F))return{h:c,m,s:F}}return{h:o,m:d,s:f}},[D,y,R,l]),P=n.useCallback((e,s,r)=>{const o=new Date;o.setHours(e,s,r,0);const d=we(o,w);C?.(o,d)},[w,C]),de=e=>{l(e,g,q)||(H(e),P(e,g??0,q??0))},me=e=>{l(p,e,q)||(T(e),P(p??0,e,q??0))},he=e=>{l(p,g,e)||(N(e),P(p??0,g??0,e))},V=n.useCallback(e=>{if(e.current){const s=e.current.querySelector("[data-selected]");if(s){const r=e.current,o=r.clientHeight,d=s.offsetTop,f=s.clientHeight,c=d-o/2+f/2;r.scrollTo({top:c,behavior:"smooth"})}}},[]),K=n.useCallback(()=>{a==="wheel"?(V(U),V(G),V(A)):a==="compact"&&V(W)},[U,G,A,W,a,V]),pe=()=>{const e=new Date,{h:s,m:r,s:o}=Se(e.getHours(),e.getMinutes(),e.getSeconds());H(s),T(r),N(o),P(s,r,o),setTimeout(()=>K(),100)};n.useEffect(()=>{const e=setTimeout(()=>K(),100);return()=>clearTimeout(e)},[z,a,K]);const Q=n.memo(({items:e,value:s,onChange:r,timeLabel:o,type:d})=>t.jsxs("div",{className:"flex flex-col gap-2",children:[o&&t.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase p-2 border-b w-full text-center",children:o}),t.jsx("div",{className:"p-2",children:t.jsx(Fe.default,{value:s?.toString()||"",onValueChange:f=>r(Number(f)),disabled:v,clearable:!1,search:!1,options:e.map(f=>{const c=d==="hours"&&l(f,g,q)||d==="minutes"&&l(p,f,q)||d==="seconds"&&l(p,g,f);return{label:I(f),value:f.toString(),disabled:c}})})})]})),De=(e,s)=>{l(e,s,0)||(H(e),T(s),N(0),P(e,s,0))},ge=()=>{const e=[];if(a==="compact")return t.jsx(Ee.TimeGridView,{HOURS:D,MINUTES:y,hours:p,minutes:g,disabled:v,isTimeDisabled:l,onTimeSelect:De,ref:W,color:O});if(x){const s=typeof u=="string"?void 0:J("hours");a==="wheel"?e.push(t.jsx(_.TimeColumnwheel,{ref:U,items:D,value:p,onChange:de,timeLabel:s,isItemDisabled:r=>l(r,g,q),disabled:v,color:O},"hours")):a==="select"&&e.push(t.jsx(Q,{items:D,value:p,onChange:de,timeLabel:s,type:"hours"},"hours"))}if(L){const s=typeof u=="string"?void 0:J("minutes");a==="wheel"?e.push(t.jsx(_.TimeColumnwheel,{ref:G,items:y,value:g,onChange:me,timeLabel:s,itemClassName:x?"border-l":void 0,isItemDisabled:r=>l(p,r,q),disabled:v,color:O},"minutes")):a==="select"&&e.push(t.jsx(Q,{items:y,value:g,onChange:me,timeLabel:s,type:"minutes"},"minutes"))}if(k){const s=typeof u=="string"?void 0:J("seconds");a==="wheel"?e.push(t.jsx(_.TimeColumnwheel,{ref:A,items:R,value:q,onChange:he,timeLabel:s,itemClassName:L||x?"border-l":void 0,isItemDisabled:r=>l(p,g,r),disabled:v,color:O},"seconds")):a==="select"&&e.push(t.jsx(Q,{items:R,value:q,onChange:he,timeLabel:s,type:"seconds"},"seconds"))}return e};if(!ue)return t.jsxs("div",{className:b.cn("flex flex-col gap-2 h-full justify-between",ee),children:[fe,t.jsx("div",{className:b.cn("flex rounded overflow-clip mb-auto",a==="wheel"?"items-end justify-center p-0 h-72":"items-start justify-center"),children:ge()}),ie&&t.jsx(Z.default,{type:"button",variant:"solid",size:"xs",onClick:pe,disabled:v,className:b.cn("rounded-none"),children:ce})]});const xe=t.jsxs("div",{className:b.cn("flex flex-col gap-4 h-full",ee),children:[fe,t.jsx("div",{className:b.cn("flex rounded overflow-clip my-auto mx-auto max-w-sm md:max-w-md lg:max-w-lg relative",a==="wheel"?"items-end justify-center p-0":"items-start justify-center",{"h-72":a==="wheel","w-xs":ue&&(je.isMobile||ae==="drawer")}),children:ge()}),ie&&t.jsx(Z.default,{type:"button",variant:"solid",size:"xs",onClick:pe,disabled:v,className:b.cn("rounded-none"),children:ce})]}),ve=t.jsxs(Z.default,{variant:"ghost",className:"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors",disabled:v,children:[t.jsx(Oe.Clock,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Select time"})]}),qe=t.jsxs(Y.Popover,{open:z,onOpenChange:le,children:[t.jsx(Y.PopoverTrigger,{asChild:!0,disabled:v,children:ve}),t.jsx(Y.PopoverContent,{className:b.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background/50"),children:xe})]}),Ce=t.jsxs(M.Drawer,{open:z,onOpenChange:le,children:[t.jsx(M.DrawerTrigger,{asChild:!0,children:ve}),t.jsxs(M.DrawerContent,{className:b.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background"),children:[t.jsxs(M.DrawerHeader,{className:"sr-only",children:[t.jsx(M.DrawerTitle,{children:"Select time"}),t.jsx(M.DrawerDescription,{children:"Choose a time"})]}),xe]})]}),ye=w;let X;$===!0?X=$e(j):typeof $=="string"&&(X=$);const Me=e=>{const s=e.target.value,r=He(s,j);if(r){H(r.getHours()),T(r.getMinutes()),N(r.getSeconds());const o=we(r,w);h?.(e,o,r),C?.(r,o)}else H(0),T(0),N(0),h?.(e,s,void 0),C?.(void 0,s)};return t.jsx(Ie.default,{...Ne,clearable:!0,value:i||"",placeholder:ye,mask:X,disabled:v,className:"cursor-pointer",onChange:Me,suffixIcon:je.isMobile?Te==="drawer"?Ce:qe:ae==="drawer"?Ce:qe})}exports.TimePicker=ze;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("react");require("@radix-ui/react-slot");require("../../packages/ui/src/components/button.cjs");require("../../packages/ui/src/components/button-group.cjs");require("../../packages/ui/src/components/input.cjs");require("../../packages/ui/src/components/textarea.cjs");require("@radix-ui/react-label");const b=require("../../packages/ui/src/lib/utils.cjs");require("../../packages/ui/src/components/select.cjs");require("../../packages/ui/src/components/combobox.cjs");require("@radix-ui/react-tooltip");const Oe=require("lucide-react");require("react-day-picker");const Y=require("../../packages/ui/src/components/popover.cjs");require("@radix-ui/react-separator");require("../../packages/ui/src/components/switch.cjs");const M=require("../../packages/ui/src/components/drawer.cjs");require("@radix-ui/react-scroll-area");require("../../packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("../../packages/ui/src/components/badge.cjs");require("../../packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("../../packages/ui/src/components/input-otp.cjs");require("../../packages/ui/src/components/radio-group.cjs");require("../../packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("../../packages/ui/src/components/tabs.cjs");require("../../packages/ui/src/components/toggle.cjs");const je=require("react-device-detect"),Z=require("../WheelColumn.cjs"),Fe=require("../TimeGridView.cjs"),E=require("date-fns"),Ie=require("../Select/Select.cjs"),_=require("../Button/Button.cjs"),Ee=require("../Input/Input.cjs"),B=(i,h=1)=>{const C=[];for(let x=0;x<i;x+=h)C.push(x);return C},I=i=>String(i).padStart(2,"0"),we=(i,h="HH:mm")=>!i||!E.isValid(i)?"":E.format(i,h),He=(i,h="HH:mm")=>{if(!i)return;const C=new Date,x=E.parse(i,h,C);if(E.isValid(x))return x};function $e(i){return i.replace(/HH|mm|ss/g,h=>{switch(h){case"HH":case"mm":case"ss":return"99";default:return h}}).replace(/H|m|s/g,()=>"9")}function ze({value:i,onChange:h,onSelect:C,showHours:x=!0,showMinutes:L=!0,showSeconds:k=!1,disabled:v=!1,className:ee,timeLabel:u,mask:$,format:S,mode:a="wheel",hourInterval:se=1,minuteInterval:te=1,secondInterval:re=1,disabledTimes:ne=[],disabledTimeRanges:oe=[],showNowButton:ie=!1,nowButtonLabel:ce="Now",standalone:ue=!0,desktopMode:ae="popover",mobileMode:Te="drawer",color:O="primary",...Ne}){let j,w;typeof S=="string"?(j=S,w=S):S?(j=S.input,w=S.output):(j=k?"HH:mm:ss":"HH:mm",w=k?"HH:mm:ss":"HH:mm");const[p,H]=n.useState(void 0),[g,T]=n.useState(void 0),[q,N]=n.useState(void 0),[z,le]=n.useState(!1);n.useEffect(()=>{if(i){const e=He(i,j);e&&(H(e.getHours()),T(e.getMinutes()),N(e.getSeconds()))}else H(void 0),T(void 0),N(void 0)},[i,j]);const U=n.useRef(null),G=n.useRef(null),A=n.useRef(null),W=n.useRef(null),D=n.useMemo(()=>B(24,se),[se]),y=n.useMemo(()=>B(60,te),[te]),R=n.useMemo(()=>B(60,re),[re]),l=n.useCallback((e,s,r=0)=>{const o=`${I(e??0)}:${I(s??0)}${k?`:${I(r??0)}`:""}`;if(ne.includes(o))return!0;for(const d of oe){const[f,c,m=0]=d.from.split(":").map(Number),[F,ke,Re=0]=d.to.split(":").map(Number),be=(e??0)*3600+(s??0)*60+(r??0),Pe=f*3600+c*60+m,Ve=F*3600+ke*60+Re;if(be>=Pe&&be<=Ve)return!0}return!1},[ne,oe,k]),J=n.useCallback(e=>{if(u)return typeof u=="boolean"?u?e==="hours"?"Hour":e==="minutes"?"Minute":"Second":void 0:typeof u=="string"?u:e==="hours"?u.hours||"Hour":e==="minutes"?u.minutes||"Minute":u.seconds||"Second"},[u]),fe=typeof u=="string"&&t.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase p-2 border-b w-full text-center",children:u},"common-label"),Se=n.useCallback((e,s,r=0)=>{const o=D.reduce((c,m)=>Math.abs(m-e)<Math.abs(c-e)?m:c),d=y.reduce((c,m)=>Math.abs(m-s)<Math.abs(c-s)?m:c),f=R.reduce((c,m)=>Math.abs(m-r)<Math.abs(c-r)?m:c);if(l(o,d,f)){for(const c of D)for(const m of y)for(const F of R)if(!l(c,m,F))return{h:c,m,s:F}}return{h:o,m:d,s:f}},[D,y,R,l]),P=n.useCallback((e,s,r)=>{const o=new Date;o.setHours(e,s,r,0);const d=we(o,w);C?.(o,d)},[w,C]),de=e=>{l(e,g,q)||(H(e),P(e,g??0,q??0))},me=e=>{l(p,e,q)||(T(e),P(p??0,e,q??0))},he=e=>{l(p,g,e)||(N(e),P(p??0,g??0,e))},V=n.useCallback(e=>{if(e.current){const s=e.current.querySelector("[data-selected]");if(s){const r=e.current,o=r.clientHeight,d=s.offsetTop,f=s.clientHeight,c=d-o/2+f/2;r.scrollTo({top:c,behavior:"smooth"})}}},[]),K=n.useCallback(()=>{a==="wheel"?(V(U),V(G),V(A)):a==="compact"&&V(W)},[U,G,A,W,a,V]),pe=()=>{const e=new Date,{h:s,m:r,s:o}=Se(e.getHours(),e.getMinutes(),e.getSeconds());H(s),T(r),N(o),P(s,r,o),setTimeout(()=>K(),100)};n.useEffect(()=>{const e=setTimeout(()=>K(),100);return()=>clearTimeout(e)},[z,a,K]);const Q=n.memo(({items:e,value:s,onChange:r,timeLabel:o,type:d})=>t.jsxs("div",{className:"flex flex-col gap-2",children:[o&&t.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase p-2 border-b w-full text-center",children:o}),t.jsx("div",{className:"p-2",children:t.jsx(Ie.default,{value:s?.toString()||"",onValueChange:f=>r(Number(f)),disabled:v,clearable:!1,search:!1,options:e.map(f=>{const c=d==="hours"&&l(f,g,q)||d==="minutes"&&l(p,f,q)||d==="seconds"&&l(p,g,f);return{label:I(f),value:f.toString(),disabled:c}})})})]})),De=(e,s)=>{l(e,s,0)||(H(e),T(s),N(0),P(e,s,0))},ge=()=>{const e=[];if(a==="compact")return t.jsx(Fe.TimeGridView,{HOURS:D,MINUTES:y,hours:p,minutes:g,disabled:v,isTimeDisabled:l,onTimeSelect:De,ref:W,color:O});if(x){const s=typeof u=="string"?void 0:J("hours");a==="wheel"?e.push(t.jsx(Z.TimeColumnwheel,{ref:U,items:D,value:p,onChange:de,timeLabel:s,isItemDisabled:r=>l(r,g,q),disabled:v,color:O},"hours")):a==="select"&&e.push(t.jsx(Q,{items:D,value:p,onChange:de,timeLabel:s,type:"hours"},"hours"))}if(L){const s=typeof u=="string"?void 0:J("minutes");a==="wheel"?e.push(t.jsx(Z.TimeColumnwheel,{ref:G,items:y,value:g,onChange:me,timeLabel:s,itemClassName:x?"border-l":void 0,isItemDisabled:r=>l(p,r,q),disabled:v,color:O},"minutes")):a==="select"&&e.push(t.jsx(Q,{items:y,value:g,onChange:me,timeLabel:s,type:"minutes"},"minutes"))}if(k){const s=typeof u=="string"?void 0:J("seconds");a==="wheel"?e.push(t.jsx(Z.TimeColumnwheel,{ref:A,items:R,value:q,onChange:he,timeLabel:s,itemClassName:L||x?"border-l":void 0,isItemDisabled:r=>l(p,g,r),disabled:v,color:O},"seconds")):a==="select"&&e.push(t.jsx(Q,{items:R,value:q,onChange:he,timeLabel:s,type:"seconds"},"seconds"))}return e};if(!ue)return t.jsxs("div",{className:b.cn("flex flex-col gap-2 h-full justify-between",ee),children:[fe,t.jsx("div",{className:b.cn("flex rounded overflow-clip mb-auto",a==="wheel"?"items-end justify-center p-0 h-72":"items-start justify-center"),children:ge()}),ie&&t.jsx(_.default,{type:"button",variant:"solid",size:"xs",onClick:pe,disabled:v,className:b.cn("rounded-none"),children:ce})]});const xe=t.jsxs("div",{className:b.cn("flex flex-col gap-4 h-full",ee),children:[fe,t.jsx("div",{className:b.cn("flex rounded overflow-clip my-auto mx-auto max-w-sm md:max-w-md lg:max-w-lg relative",a==="wheel"?"items-end justify-center p-0":"items-start justify-center",{"h-72":a==="wheel","w-xs":ue&&(je.isMobile||ae==="drawer")}),children:ge()}),ie&&t.jsx(_.default,{type:"button",variant:"solid",size:"xs",onClick:pe,disabled:v,className:b.cn("rounded-none"),children:ce})]}),ve=t.jsxs(_.default,{variant:"ghost",className:"!p-1 !leading-0 h-auto rounded hover:bg-accent transition-colors",disabled:v,children:[t.jsx(Oe.Clock,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Select time"})]}),qe=t.jsxs(Y.Popover,{open:z,onOpenChange:le,children:[t.jsx(Y.PopoverTrigger,{asChild:!0,disabled:v,children:ve}),t.jsx(Y.PopoverContent,{className:b.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background/50"),children:xe})]}),Ce=t.jsxs(M.Drawer,{open:z,onOpenChange:le,children:[t.jsx(M.DrawerTrigger,{asChild:!0,children:ve}),t.jsxs(M.DrawerContent,{className:b.cn("w-auto overflow-hidden p-0","backdrop-blur bg-background"),children:[t.jsxs(M.DrawerHeader,{className:"sr-only",children:[t.jsx(M.DrawerTitle,{children:"Select time"}),t.jsx(M.DrawerDescription,{children:"Choose a time"})]}),xe]})]}),ye=w;let X;$===!0?X=$e(j):typeof $=="string"&&(X=$);const Me=e=>{const s=e.target.value,r=He(s,j);if(r){H(r.getHours()),T(r.getMinutes()),N(r.getSeconds());const o=we(r,w);h?.(e,o,r),C?.(r,o)}else H(0),T(0),N(0),h?.(e,s,void 0),C?.(void 0,s)};return t.jsx(Ee.default,{...Ne,clearable:!0,value:i||"",placeholder:ye,mask:X,disabled:v,className:"cursor-pointer",onChange:Me,suffixIcon:je.isMobile?Te==="drawer"?Ce:qe:ae==="drawer"?Ce:qe})}exports.TimePicker=ze;
2
2
  //# sourceMappingURL=TimePicker.cjs.map