@xploreu/components 0.4.53 → 0.4.54

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 (41) hide show
  1. package/dist/chunk-3Y7VD44E.js +2 -0
  2. package/dist/chunk-3Y7VD44E.js.map +1 -0
  3. package/dist/chunk-6PLUIDII.js +2 -0
  4. package/dist/chunk-6PLUIDII.js.map +1 -0
  5. package/dist/{chunk-7EXEQDMX.js → chunk-GFBYUG2T.js} +2 -2
  6. package/dist/{chunk-7EXEQDMX.js.map → chunk-GFBYUG2T.js.map} +1 -1
  7. package/dist/chunk-KQW7T6SG.js +2 -0
  8. package/dist/chunk-KQW7T6SG.js.map +1 -0
  9. package/dist/chunk-SCARBOBW.js +2 -0
  10. package/dist/chunk-SCARBOBW.js.map +1 -0
  11. package/dist/composites/combobox-chip-outside.js +1 -1
  12. package/dist/composites/index.js +1 -1
  13. package/dist/form/form.d.ts +1 -1
  14. package/dist/primitives/index.js +1 -1
  15. package/dist/primitives/tabs.d.ts +1 -1
  16. package/dist/primitives/tabs.js +1 -1
  17. package/dist/ui/button.d.ts +2 -2
  18. package/dist/ui/date-multiple-picker.d.ts +5 -2
  19. package/dist/ui/date-multiple-picker.js +1 -1
  20. package/dist/ui/date-picker.d.ts +11 -3
  21. package/dist/ui/date-picker.js +1 -1
  22. package/dist/ui/date-range-picker.d.ts +6 -2
  23. package/dist/ui/date-range-picker.js +1 -1
  24. package/dist/ui/index.d.ts +1 -1
  25. package/dist/ui/index.js +1 -1
  26. package/dist/ui/input-group.d.ts +2 -2
  27. package/dist/ui/input-new.d.ts +1 -1
  28. package/dist/ui/input.d.ts +1 -1
  29. package/dist/ui/label.d.ts +2 -2
  30. package/dist/ui/switch.d.ts +2 -2
  31. package/dist/ui/tabs.js +1 -1
  32. package/dist/ui/textarea.d.ts +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-6OC5NZB6.js +0 -2
  35. package/dist/chunk-6OC5NZB6.js.map +0 -1
  36. package/dist/chunk-C3CQJ5EA.js +0 -2
  37. package/dist/chunk-C3CQJ5EA.js.map +0 -1
  38. package/dist/chunk-EXNOSFZ7.js +0 -2
  39. package/dist/chunk-EXNOSFZ7.js.map +0 -1
  40. package/dist/chunk-I3A5MC57.js +0 -2
  41. package/dist/chunk-I3A5MC57.js.map +0 -1
@@ -1,2 +0,0 @@
1
- import {a as a$3}from'./chunk-PC5CKARI.js';import {a as a$1,b,c}from'./chunk-NGSCUYDU.js';import {b as b$1}from'./chunk-DIXFDLPZ.js';import {a as a$2}from'./chunk-2ECH6S6R.js';import {b as b$2,e}from'./chunk-JLZNZFOO.js';import*as a from'react';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {format}from'date-fns';import {ChevronDown}from'lucide-react';import'react-day-picker';import {cn}from'@xploreu/lib/cn';import {jsxs,jsx}from'react/jsx-runtime';function Z({className:P,value:M,onValueChange:i,defaultValue:N,required:d,disabled:p,placeholder:k="Pick dates",disabledDates:w,dateFormat:j="LLL dd, y",chipDateFormat:S="d MMM",maxVisible:l,...B}){let R=a.useCallback(e=>{d?e?.length&&i?.(e):i?.(e);},[i,d]),[t,u]=useControlledState({value:M,defaultValue:N,onChange:R}),[z,F]=a.useState(t?.[0]||new Date),[O,T]=a.useState(false),s=!!t?.length,m=a.useMemo(()=>t?[...t].sort((e,n)=>e.getTime()-n.getTime()):[],[t]),V=a.useCallback(e=>{let n=t?.filter(L=>L.getTime()!==e.getTime());d&&!n?.length||u(n);},[t,u,d]),I=l!==void 0?m.slice(0,l):m,b$3=l!==void 0?m.length-l:0;return jsxs("div",{className:"flex flex-col gap-2 w-full",children:[jsxs(a$1,{open:p?false:O,onOpenChange:T,children:[jsx(b,{className:"w-full",render:jsxs(b$1,{className:cn("group h-9 w-full justify-between rounded-xp-card-base border px-3 text-body-medium-3 transition-colors","border-border-primary bg-bg-primary text-text-secondary hover:bg-bg-primary-hover",s&&"border-border-brand bg-bg-brand-primary text-text-brand-secondary","data-[popup-open]:border-border-brand data-[popup-open]:bg-bg-brand-primary data-[popup-open]:text-text-brand-secondary","disabled:pointer-events-none disabled:opacity-50",P),variant:null,size:null,disabled:p,children:[jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[jsx(a$2,{className:cn("size-4 shrink-0",s?"text-fg-brand-primary":"text-fg-quaternary")}),jsx("span",{className:"truncate",children:s?`${t.length} ${t.length===1?"date":"dates"} selected`:k})]}),jsx(ChevronDown,{className:cn("size-4 shrink-0 transition-transform group-data-[popup-open]:rotate-180",s?"text-fg-brand-primary":"text-fg-quaternary")})]})}),jsx(c,{className:"w-auto border-0 rounded-[20px] p-xp-none bg-transparent",style:{background:"linear-gradient(180deg, rgba(46, 51, 90, 0) 0%, rgba(28, 27, 51, 0.04) 100%), radial-gradient(146.13% 118.42% at 50% -15.5%, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 99.59%)",backdropFilter:"blur(20px)",boxShadow:"0px 30px 60px 0px #0000001A"},children:jsx(a$3,{autoFocus:true,disabled:w,mode:"multiple",month:z,selected:t,onMonthChange:F,onSelect:e=>{d&&!e?.length||u(e);},...B})})]}),s&&jsxs("div",{className:"flex flex-wrap gap-2",children:[I.map(e$1=>jsxs(b$2,{color:"brand",size:"lg",className:"ring-1 ring-border-brand text-body-medium-3",children:[format(e$1,S),!p&&jsx(e,{className:"text-fg-quaternary",onClick:n=>{n.stopPropagation(),V(e$1);}})]},e$1.toISOString())),b$3>0&&jsxs(b$2,{color:"brand",size:"lg",className:"ring-1 ring-border-brand text-body-medium-3",children:["+",b$3]})]})]})}export{Z as a};//# sourceMappingURL=chunk-C3CQJ5EA.js.map
2
- //# sourceMappingURL=chunk-C3CQJ5EA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ui/date-multiple-picker.tsx"],"names":["DateMultiplePicker","className","valueProp","onValueChange","defaultValue","required","disabled","placeholder","disabledDates","dateFormat","chipDateFormat","maxVisible","props","handleValueChange","val","value","setValue","useControlledState","currentMonth","setCurrentMonth","isOpen","setIsOpen","hasValue","sortedValue","a","b","handleRemoveDate","dateToRemove","newValue","d","visibleChips","overflowCount","jsxs","Popover","jsx","PopoverTrigger","Button","cn","calendar_icon_default","ChevronDown","PopoverPopup","Calendar","Badge","format","BadgeButton","e"],"mappings":"keAqCA,SAASA,CAAAA,CAAmB,CAC1B,SAAA,CAAAC,CAAAA,CACA,MAAOC,CAAAA,CACP,aAAA,CAAAC,EACA,YAAA,CAAAC,CAAAA,CACA,SAAAC,CAAAA,CACA,QAAA,CAAAC,EACA,WAAA,CAAAC,CAAAA,CAAc,aACd,aAAA,CAAAC,CAAAA,CACA,WAAAC,CAAAA,CAAa,WAAA,CACb,eAAAC,CAAAA,CAAiB,OAAA,CACjB,WAAAC,CAAAA,CACA,GAAGC,CACL,CAAA,CAA4B,CAC1B,IAAMC,CAAAA,CAA0B,CAAA,CAAA,WAAA,CAC7BC,GAA4B,CACvBT,CAAAA,CACES,GAAK,MAAA,EAAQX,CAAAA,GAAgBW,CAAG,CAAA,CAEpCX,CAAAA,GAAgBW,CAAG,EAEvB,CAAA,CACA,CAACX,CAAAA,CAAeE,CAAQ,CAC1B,CAAA,CAEM,CAACU,EAAOC,CAAQ,CAAA,CAAIC,mBAAuC,CAC/D,KAAA,CAAOf,EACP,YAAA,CAAAE,CAAAA,CACA,SAAUS,CACZ,CAAC,EAEK,CAACK,CAAAA,CAAcC,CAAe,CAAA,CAAU,CAAA,CAAA,QAAA,CAA2BJ,IAAQ,CAAC,CAAA,EAAK,IAAI,IAAM,CAAA,CAC3F,CAACK,CAAAA,CAAQC,CAAS,EAAU,CAAA,CAAA,QAAA,CAAS,KAAK,EAE1CC,CAAAA,CAAW,CAAC,CAACP,CAAAA,EAAO,MAAA,CAEpBQ,EAAoB,CAAA,CAAA,OAAA,CAAQ,IAC3BR,EACE,CAAC,GAAGA,CAAK,CAAA,CAAE,IAAA,CAAK,CAACS,CAAAA,CAAGC,CAAAA,GAAMD,EAAE,OAAA,EAAQ,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ACN,KAAK,IAAA,CACL,SAAA,CAAU,8CACX,QAAA,CAAA,CAAA,GAAA,CACGX,GAAAA,CAAAA,CACJ,CAAA,CAAA,CAEJ,CAAA,CAAA,CAEJ,CAEJ","file":"chunk-C3CQJ5EA.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport { format } from \"date-fns\"\r\nimport { ChevronDown } from \"lucide-react\"\r\nimport { type Matcher } from \"react-day-picker\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\n\r\nimport { CalendarIcon } from \"../icons\"\r\nimport { Button } from \"./button\"\r\nimport { Calendar, type CalendarProps } from \"./calendar\"\r\nimport { Popover, PopoverPopup, PopoverTrigger } from \"./popover\"\r\nimport { Badge, BadgeButton } from \"./badge\"\r\n\r\nexport type DateMultiplePickerProps = {\r\n className?: string\r\n value?: Date[]\r\n defaultValue?: Date[]\r\n required?: boolean\r\n disabled?: boolean\r\n placeholder?: string\r\n disabledDates?: Matcher | Matcher[] | undefined\r\n dateFormat?: string\r\n chipDateFormat?: string\r\n /** Maximum number of chips to show outside before collapsing the rest into a \"+N\" chip. */\r\n maxVisible?: number\r\n} & ({\r\n required: true\r\n onValueChange?: (value: Date[]) => void\r\n} | {\r\n required?: false\r\n onValueChange?: (value: Date[] | undefined) => void\r\n}) & Omit<CalendarProps, \"mode\" | \"selected\" | \"onSelect\" | \"month\" | \"onMonthChange\">\r\n\r\nfunction DateMultiplePicker({\r\n className,\r\n value: valueProp,\r\n onValueChange,\r\n defaultValue,\r\n required,\r\n disabled,\r\n placeholder = \"Pick dates\",\r\n disabledDates,\r\n dateFormat = \"LLL dd, y\",\r\n chipDateFormat = \"d MMM\",\r\n maxVisible,\r\n ...props\r\n}: DateMultiplePickerProps) {\r\n const handleValueChange = React.useCallback(\r\n (val: Date[] | undefined) => {\r\n if (required) {\r\n if (val?.length) onValueChange?.(val)\r\n } else {\r\n onValueChange?.(val)\r\n }\r\n },\r\n [onValueChange, required],\r\n )\r\n\r\n const [value, setValue] = useControlledState<Date[] | undefined>({\r\n value: valueProp,\r\n defaultValue,\r\n onChange: handleValueChange,\r\n })\r\n\r\n const [currentMonth, setCurrentMonth] = React.useState<Date | undefined>(value?.[0] || new Date())\r\n const [isOpen, setIsOpen] = React.useState(false)\r\n\r\n const hasValue = !!value?.length\r\n\r\n const sortedValue = React.useMemo(() => {\r\n if (!value) return []\r\n return [...value].sort((a, b) => a.getTime() - b.getTime())\r\n }, [value])\r\n\r\n const handleRemoveDate = React.useCallback(\r\n (dateToRemove: Date) => {\r\n const newValue = value?.filter((d) => d.getTime() !== dateToRemove.getTime())\r\n if (required && !newValue?.length) return\r\n setValue(newValue)\r\n },\r\n [value, setValue, required],\r\n )\r\n\r\n const visibleChips = maxVisible !== undefined ? sortedValue.slice(0, maxVisible) : sortedValue\r\n const overflowCount = maxVisible !== undefined ? sortedValue.length - maxVisible : 0\r\n\r\n return (\r\n <div className=\"flex flex-col gap-2 w-full\">\r\n <Popover open={disabled ? false : isOpen} onOpenChange={setIsOpen}>\r\n <PopoverTrigger\r\n className=\"w-full\"\r\n render={\r\n <Button\r\n className={cn(\r\n \"group h-9 w-full justify-between rounded-xp-card-base border px-3 text-body-medium-3 transition-colors\",\r\n \"border-border-primary bg-bg-primary text-text-secondary hover:bg-bg-primary-hover\",\r\n hasValue &&\r\n \"border-border-brand bg-bg-brand-primary text-text-brand-secondary\",\r\n \"data-[popup-open]:border-border-brand data-[popup-open]:bg-bg-brand-primary data-[popup-open]:text-text-brand-secondary\",\r\n \"disabled:pointer-events-none disabled:opacity-50\",\r\n className,\r\n )}\r\n variant={null}\r\n size={null}\r\n disabled={disabled}\r\n >\r\n <span className=\"flex min-w-0 items-center gap-2\">\r\n <CalendarIcon\r\n className={cn(\r\n \"size-4 shrink-0\",\r\n hasValue ? \"text-fg-brand-primary\" : \"text-fg-quaternary\",\r\n )}\r\n />\r\n <span className=\"truncate\">\r\n {hasValue\r\n ? `${value.length} ${value.length === 1 ? \"date\" : \"dates\"} selected`\r\n : placeholder}\r\n </span>\r\n </span>\r\n <ChevronDown\r\n className={cn(\r\n \"size-4 shrink-0 transition-transform group-data-[popup-open]:rotate-180\",\r\n hasValue ? \"text-fg-brand-primary\" : \"text-fg-quaternary\",\r\n )}\r\n />\r\n </Button>\r\n }\r\n />\r\n <PopoverPopup\r\n className=\"w-auto border-0 rounded-[20px] p-xp-none bg-transparent\"\r\n style={{\r\n background:\r\n \"linear-gradient(180deg, rgba(46, 51, 90, 0) 0%, rgba(28, 27, 51, 0.04) 100%), radial-gradient(146.13% 118.42% at 50% -15.5%, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 99.59%)\",\r\n backdropFilter: \"blur(20px)\",\r\n boxShadow: \"0px 30px 60px 0px #0000001A\",\r\n }}\r\n >\r\n <Calendar\r\n autoFocus\r\n disabled={disabledDates}\r\n mode=\"multiple\"\r\n month={currentMonth}\r\n selected={value}\r\n onMonthChange={setCurrentMonth}\r\n onSelect={(val) => {\r\n if (required && !val?.length) return\r\n setValue(val)\r\n }}\r\n {...props}\r\n />\r\n </PopoverPopup>\r\n </Popover>\r\n\r\n {hasValue && (\r\n <div className=\"flex flex-wrap gap-2\">\r\n {visibleChips.map((d) => (\r\n <Badge\r\n key={d.toISOString()}\r\n color=\"brand\"\r\n size=\"lg\"\r\n className=\"ring-1 ring-border-brand text-body-medium-3\"\r\n >\r\n {format(d, chipDateFormat)}\r\n {!disabled && (\r\n <BadgeButton\r\n className=\"text-fg-quaternary\"\r\n onClick={(e) => {\r\n e.stopPropagation()\r\n handleRemoveDate(d)\r\n }}\r\n />\r\n )}\r\n </Badge>\r\n ))}\r\n {overflowCount > 0 && (\r\n <Badge\r\n color=\"brand\"\r\n size=\"lg\"\r\n className=\"ring-1 ring-border-brand text-body-medium-3\"\r\n >\r\n +{overflowCount}\r\n </Badge>\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n )\r\n}\r\n\r\nexport { DateMultiplePicker }"]}
@@ -1,2 +0,0 @@
1
- import {a as a$2}from'./chunk-PC5CKARI.js';import {a,b,c}from'./chunk-NGSCUYDU.js';import {b as b$1}from'./chunk-DIXFDLPZ.js';import {a as a$1}from'./chunk-2ECH6S6R.js';import*as t from'react';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {format}from'date-fns';import {ChevronDown}from'lucide-react';import'react-day-picker';import {cn}from'@xploreu/lib/cn';import {jsxs,jsx}from'react/jsx-runtime';function E({className:h,value:x,onValueChange:o,defaultValue:y,required:n,disabled:i,placeholder:v="Pick a date",disabledDates:P,dateFormat:C="LLL dd, y",...D}){let k=t.useCallback(e=>{n?e&&o?.(e):o?.(e);},[o,n]),[r,w]=useControlledState({value:x,defaultValue:y,onChange:k}),[N,M]=t.useState(r||new Date),[S,l]=t.useState(false),d=!!r;return jsxs(a,{open:i?false:S,onOpenChange:l,children:[jsx(b,{className:"w-full",render:jsxs(b$1,{className:cn("group h-9 w-full justify-between rounded-xp-card-base border px-3 text-body-medium-3 transition-colors","border-border-primary bg-bg-primary text-text-secondary hover:bg-bg-primary-hover",d&&"border-border-brand bg-bg-brand-primary text-text-brand-secondary","data-[popup-open]:border-border-brand data-[popup-open]:bg-bg-brand-primary data-[popup-open]:text-text-brand-secondary","disabled:pointer-events-none disabled:opacity-50",h),variant:null,size:null,disabled:i,children:[jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[jsx(a$1,{className:cn("size-4 shrink-0",d?"text-fg-brand-primary":"text-fg-quaternary")}),jsx("span",{className:"truncate",children:r?format(r,C):v})]}),jsx(ChevronDown,{className:cn("size-4 shrink-0 transition-transform group-data-[popup-open]:rotate-180",d?"text-fg-brand-primary":"text-fg-quaternary")})]})}),jsx(c,{className:"w-auto border-0 rounded-[20px] p-xp-none bg-transparent",style:{background:"linear-gradient(180deg, rgba(46, 51, 90, 0) 0%, rgba(28, 27, 51, 0.04) 100%), radial-gradient(146.13% 118.42% at 50% -15.5%, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 99.59%)",backdropFilter:"blur(20px)",boxShadow:"0px 30px 60px 0px #0000001A"},children:jsx(a$2,{autoFocus:true,disabled:P,mode:"single",month:N,selected:r,onMonthChange:M,onSelect:e=>{n&&!e||(w(e),l(false));},...D})})]})}export{E as a};//# sourceMappingURL=chunk-EXNOSFZ7.js.map
2
- //# sourceMappingURL=chunk-EXNOSFZ7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ui/date-picker.tsx"],"names":["DatePicker","className","valueProp","onValueChange","defaultValue","required","disabled","placeholder","disabledDates","dateFormat","props","handleValueChange","val","value","setValue","useControlledState","currentMonth","setCurrentMonth","isOpen","setIsOpen","hasValue","jsxs","Popover","jsx","PopoverTrigger","Button","cn","calendar_icon_default","format","ChevronDown","PopoverPopup","Calendar"],"mappings":"8aAiCA,SAASA,EAAW,CAClB,SAAA,CAAAC,CAAAA,CACA,KAAA,CAAOC,CAAAA,CACP,aAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,WAAA,CAAAC,EAAc,aAAA,CACd,aAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CAAa,WAAA,CACb,GAAGC,CACL,CAAA,CAAoB,CAClB,IAAMC,CAAAA,CAA0B,CAAA,CAAA,WAAA,CAC7BC,CAAAA,EAA0B,CACrBP,CAAAA,CACEO,CAAAA,EAAKT,CAAAA,GAAgBS,CAAG,CAAA,CAE5BT,CAAAA,GAAgBS,CAAG,EAEvB,CAAA,CACA,CAACT,CAAAA,CAAeE,CAAQ,CAC1B,EAEM,CAACQ,CAAAA,CAAOC,CAAQ,CAAA,CAAIC,kBAAAA,CAAqC,CAC7D,KAAA,CAAOb,CAAAA,CACP,YAAA,CAAAE,CAAAA,CACA,QAAA,CAAUO,CACZ,CAAC,CAAA,CAEK,CAACK,CAAAA,CAAcC,CAAe,CAA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AW,6BACb,CAAA,CAEA,QAAA,CAAAP,GAAAA,CAACQ,GAAAA,CAAA,CACC,SAAA,CAAS,KACT,QAAA,CAAUvB,CAAAA,CACV,IAAA,CAAK,QAAA,CACL,KAAA,CAAOQ,CAAAA,CACP,QAAA,CAAUH,CAAAA,CACV,aAAA,CAAeI,CAAAA,CACf,QAAA,CAAWL,CAAAA,EAAQ,CACbP,CAAAA,EAAY,CAACO,CAAAA,GACjBE,CAAAA,CAASF,CAAG,CAAA,CACZO,CAAAA,CAAU,KAAK,CAAA,EACjB,CAAA,CACC,GAAGT,CAAAA,CACN,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"chunk-EXNOSFZ7.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport { format } from \"date-fns\"\r\nimport { ChevronDown } from \"lucide-react\"\r\nimport { type Matcher } from \"react-day-picker\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\n\r\nimport { CalendarIcon } from \"../icons\"\r\nimport { Button } from \"./button\"\r\nimport { Calendar, type CalendarProps } from \"./calendar\"\r\nimport { Popover, PopoverPopup, PopoverTrigger } from \"./popover\"\r\n\r\nexport type DatePickerProps = {\r\n className?: string\r\n value?: Date\r\n defaultValue?: Date\r\n required?: boolean\r\n disabled?: boolean\r\n placeholder?: string\r\n disabledDates?: Matcher | Matcher[] | undefined\r\n dateFormat?: string\r\n} & ({\r\n required: true\r\n onValueChange?: (value: Date) => void\r\n} | {\r\n required?: false\r\n onValueChange?: (value: Date | undefined) => void\r\n}) & Omit<CalendarProps, \"mode\" | \"selected\" | \"onSelect\" | \"month\" | \"onMonthChange\">\r\n\r\nfunction DatePicker({\r\n className,\r\n value: valueProp,\r\n onValueChange,\r\n defaultValue,\r\n required,\r\n disabled,\r\n placeholder = \"Pick a date\",\r\n disabledDates,\r\n dateFormat = \"LLL dd, y\",\r\n ...props\r\n}: DatePickerProps) {\r\n const handleValueChange = React.useCallback(\r\n (val: Date | undefined) => {\r\n if (required) {\r\n if (val) onValueChange?.(val)\r\n } else {\r\n onValueChange?.(val)\r\n }\r\n },\r\n [onValueChange, required],\r\n )\r\n\r\n const [value, setValue] = useControlledState<Date | undefined>({\r\n value: valueProp,\r\n defaultValue,\r\n onChange: handleValueChange,\r\n })\r\n\r\n const [currentMonth, setCurrentMonth] = React.useState<Date | undefined>(value || new Date())\r\n const [isOpen, setIsOpen] = React.useState(false)\r\n\r\n const hasValue = !!value\r\n\r\n return (\r\n <Popover open={disabled ? false : isOpen} onOpenChange={setIsOpen}>\r\n <PopoverTrigger\r\n className=\"w-full\"\r\n render={\r\n <Button\r\n className={cn(\r\n \"group h-9 w-full justify-between rounded-xp-card-base border px-3 text-body-medium-3 transition-colors\",\r\n \"border-border-primary bg-bg-primary text-text-secondary hover:bg-bg-primary-hover\",\r\n hasValue &&\r\n \"border-border-brand bg-bg-brand-primary text-text-brand-secondary\",\r\n \"data-[popup-open]:border-border-brand data-[popup-open]:bg-bg-brand-primary data-[popup-open]:text-text-brand-secondary\",\r\n \"disabled:pointer-events-none disabled:opacity-50\",\r\n className,\r\n )}\r\n variant={null}\r\n size={null}\r\n disabled={disabled}\r\n >\r\n <span className=\"flex min-w-0 items-center gap-2\">\r\n <CalendarIcon\r\n className={cn(\r\n \"size-4 shrink-0\",\r\n hasValue ? \"text-fg-brand-primary\" : \"text-fg-quaternary\",\r\n )}\r\n />\r\n <span className=\"truncate\">\r\n {value ? format(value, dateFormat) : placeholder}\r\n </span>\r\n </span>\r\n <ChevronDown\r\n className={cn(\r\n \"size-4 shrink-0 transition-transform group-data-[popup-open]:rotate-180\",\r\n hasValue ? \"text-fg-brand-primary\" : \"text-fg-quaternary\",\r\n )}\r\n />\r\n </Button>\r\n }\r\n />\r\n <PopoverPopup\r\n className=\"w-auto border-0 rounded-[20px] p-xp-none bg-transparent\"\r\n style={{\r\n background:\r\n \"linear-gradient(180deg, rgba(46, 51, 90, 0) 0%, rgba(28, 27, 51, 0.04) 100%), radial-gradient(146.13% 118.42% at 50% -15.5%, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 99.59%)\",\r\n backdropFilter: \"blur(20px)\",\r\n boxShadow: \"0px 30px 60px 0px #0000001A\",\r\n }}\r\n >\r\n <Calendar\r\n autoFocus\r\n disabled={disabledDates}\r\n mode=\"single\"\r\n month={currentMonth}\r\n selected={value}\r\n onMonthChange={setCurrentMonth}\r\n onSelect={(val) => {\r\n if (required && !val) return\r\n setValue(val)\r\n setIsOpen(false)\r\n }}\r\n {...props}\r\n />\r\n </PopoverPopup>\r\n </Popover>\r\n )\r\n}\r\n\r\nexport { DatePicker }\r\n"]}
@@ -1,2 +0,0 @@
1
- import {a as a$2}from'./chunk-PC5CKARI.js';import {a,b,c}from'./chunk-NGSCUYDU.js';import {b as b$1}from'./chunk-DIXFDLPZ.js';import {a as a$1}from'./chunk-2ECH6S6R.js';import u from'react';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {format,endOfWeek,startOfWeek,endOfMonth,startOfMonth,subMonths,endOfYear,startOfYear,subYears}from'date-fns';import {ChevronDown}from'lucide-react';import'react-day-picker';import {cn}from'@xploreu/lib/cn';import {jsxs,jsx}from'react/jsx-runtime';var N=[{label:"Today",value:"today",getDateRange:()=>{let e=new Date;return {from:e,to:e}}},{value:"last-7-days",label:"Last 7 days",getDateRange:()=>({from:new Date(Date.now()-8640*60*1e3),to:new Date})},{label:"This Week",value:"this-week",getDateRange:()=>{let e=new Date;return {from:startOfWeek(e,{weekStartsOn:1}),to:endOfWeek(e,{weekStartsOn:1})}}},{label:"This Month",value:"this-month",getDateRange:()=>{let e=new Date;return {from:startOfMonth(e),to:endOfMonth(e)}}},{label:"Last 3 Months",value:"last-3-months",getDateRange:()=>{let e=new Date;return {from:subMonths(e,3),to:e}}},{label:"Last 6 Months",value:"last-6-months",getDateRange:()=>{let e=new Date;return {from:subMonths(e,6),to:e}}},{label:"This Year",value:"this-year",getDateRange:()=>{let e=new Date;return {from:startOfYear(e),to:endOfYear(e)}}},{label:"Last Year",value:"last-year",getDateRange:()=>{let e=subYears(new Date,1);return {from:startOfYear(e),to:endOfYear(e)}}},{label:"Custom Range",value:"custom-range",getDateRange:()=>{}}];function ne({className:e,value:P,onValueChange:p,defaultValue:V,required:d,disabled:b$2,placeholder:S="Pick a date",options:D=true,disabledDates:Y}){let T=u.useCallback(t=>{p?.(t);},[p,d]),[a$3,v]=useControlledState({value:P,defaultValue:V,onChange:T}),[q,h]=u.useState(a$3?.from||new Date),[z,B]=u.useState(false),[F,y]=u.useState("days"),f=!!a$3?.from,s=(t,n)=>!t||!n?false:t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),W=t=>{if(!a$3?.from||!a$3?.to)return false;if(t.value==="custom-range")return N.every(o=>{if(o.value==="custom-range")return true;let l=o.getDateRange();return !l?.from||!l?.to?true:!(s(a$3.from,l.from)&&s(a$3.to,l.to))});let n=t.getDateRange();return !n?.from||!n?.to?false:s(a$3.from,n.from)&&s(a$3.to,n.to)};return jsxs(a,{open:b$2?false:z,onOpenChange:B,children:[jsx(b,{render:jsxs(b$1,{className:cn("group h-9 w-full justify-between rounded-xp-card-base border px-3 text-body-medium-3 transition-colors","border-border-primary bg-bg-primary text-text-secondary hover:bg-bg-primary-hover",f&&"border-border-brand bg-bg-brand-primary text-text-brand-secondary","data-[popup-open]:border-border-brand data-[popup-open]:bg-bg-brand-primary data-[popup-open]:text-text-brand-secondary","disabled:pointer-events-none disabled:opacity-50",e),variant:null,size:null,disabled:b$2,children:[jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[jsx(a$1,{className:cn("size-4 shrink-0",f?"text-fg-brand-primary":"text-fg-quaternary")}),jsx("span",{className:"truncate",children:a$3?.from?a$3.to?`${format(a$3.from,"LLL dd, y")} - ${format(a$3.to,"LLL dd, y")}`:format(a$3.from,"LLL dd, y"):S})]}),jsx(ChevronDown,{className:cn("size-4 shrink-0 transition-transform group-data-[popup-open]:rotate-180",f?"text-fg-brand-primary":"text-fg-quaternary")})]})}),jsxs(c,{className:cn("w-auto border-0",D?"rounded-2xl p-xp-lg flex gap-6":"p-xp-none bg-transparent"),children:[D&&jsx("div",{className:"flex flex-col gap-xp-md w-[135px]",children:N.map(t=>{let n=W(t);return jsx(b$1,{className:"justify-start px-xp-xl",variant:n?"tertiary-accent":null,onClick:()=>{let o=t.getDateRange();o&&(v(o),y("days"),h(o.from));},children:t.label},t.value)})}),jsx(a$2,{autoFocus:true,disabled:Y,mode:"range",month:q,navView:F,numberOfMonths:2,selected:a$3,onMonthChange:h,onNavViewChange:y,onSelect:t=>{d&&!t||v(t);}})]})]})}export{ne as a};//# sourceMappingURL=chunk-I3A5MC57.js.map
2
- //# sourceMappingURL=chunk-I3A5MC57.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ui/date-range-picker.tsx"],"names":["dateRangeOptions","t","now","startOfWeek","endOfWeek","startOfMonth","endOfMonth","subMonths","startOfYear","endOfYear","ly","subYears","DateRangePicker","className","valueProp","onValueChangeProp","defaultValue","required","disabled","placeholder","options","disabledDates","onValueChange","React","value","setValue","useControlledState","currentMonth","setCurrentMonth","isOpen","setIsOpen","navView","setNavView","hasValue","isSameDay","date1","date2","isOptionActive","option","opt","optRange","optionRange","jsxs","Popover","jsx","PopoverTrigger","Button","cn","calendar_icon_default","format","ChevronDown","PopoverPopup","active","dateRange","Calendar","val"],"mappings":"kgBAmDA,IAAMA,CAAAA,CAAsC,CAC1C,CACE,KAAA,CAAO,OAAA,CACP,KAAA,CAAO,OAAA,CACP,aAAc,IAAM,CAAE,IAAMC,CAAAA,CAAI,IAAI,IAAA,CAAQ,OAAO,CAAE,IAAA,CAAMA,EAAG,EAAA,CAAIA,CAAE,CAAE,CACxE,EACA,CACE,KAAA,CAAO,aAAA,CACP,KAAA,CAAO,cACP,YAAA,CAAc,KAAO,CACnB,IAAA,CAAM,IAAI,KAAK,IAAA,C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AAAA,CAAS,iBAAA,CAAoB,IAAA,CACtC,QAAS,IAAM,CACb,IAAMC,CAAAA,CAAYf,EAAO,YAAA,EAAa,CAClCe,CAAAA,GACF5B,CAAAA,CAAS4B,CAAS,CAAA,CAClBrB,CAAAA,CAAW,MAAM,CAAA,CACjBJ,EAAgByB,CAAAA,CAAU,IAAI,CAAA,EAElC,CAAA,CAEC,SAAAf,CAAAA,CAAO,KAAA,CAAA,CAZHA,CAAAA,CAAO,KAad,CAEJ,CAAC,CAAA,CACH,CAAA,CAEFM,GAAAA,CAACU,IAAA,CACC,SAAA,CAAS,IAAA,CACT,QAAA,CAAUjC,EACV,IAAA,CAAK,OAAA,CACL,KAAA,CAAOM,CAAAA,CACP,QAASI,CAAAA,CACT,cAAA,CAAgB,CAAA,CAChB,QAAA,CAAUP,IACV,aAAA,CAAeI,CAAAA,CACf,eAAA,CAAiBI,CAAAA,CACjB,SAAWuB,CAAAA,EAAQ,CACbtC,CAAAA,EAAY,CAACsC,GACjB9B,CAAAA,CAAS8B,CAAG,EACd,CAAA,CACF,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-I3A5MC57.js","sourcesContent":["\"use client\"\r\n\r\nimport React from \"react\"\r\n\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport {\r\n endOfMonth,\r\n endOfWeek,\r\n endOfYear,\r\n format,\r\n startOfMonth,\r\n startOfWeek,\r\n startOfYear,\r\n subMonths,\r\n subYears,\r\n} from \"date-fns\"\r\nimport { ChevronDown } from \"lucide-react\"\r\nimport { type DateRange, type Matcher } from \"react-day-picker\"\r\n\r\nexport type { DateRange }\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\n\r\nimport { Button } from \"./button\"\r\nimport { Calendar, type NavView } from \"./calendar\"\r\nimport { CalendarIcon } from \"../icons\"\r\nimport { Popover, PopoverPopup, PopoverTrigger } from \"./popover\"\r\n\r\nexport type DateRangePickerProps = {\r\n className?: string\r\n value?: DateRange\r\n defaultValue?: DateRange\r\n required?: boolean\r\n disabled?: boolean\r\n placeholder?: string\r\n options?: boolean\r\n disabledDates?: Matcher | Matcher[] | undefined\r\n} & ({\r\n required: true\r\n onValueChange?: (value: DateRange) => void\r\n} | {\r\n required?: false\r\n onValueChange?: (value: DateRange | undefined) => void\r\n})\r\n\r\ntype DateRangeOption = {\r\n label: string\r\n value: string\r\n getDateRange: () => DateRange | undefined\r\n}\r\n\r\nconst dateRangeOptions: DateRangeOption[] = [\r\n {\r\n label: \"Today\",\r\n value: \"today\",\r\n getDateRange: () => { const t = new Date(); return { from: t, to: t } },\r\n },\r\n {\r\n value: \"last-7-days\",\r\n label: \"Last 7 days\",\r\n getDateRange: () => ({\r\n from: new Date(Date.now() - 6 * 24 * 60 * 60 * 1000), // 6 days in milliseconds\r\n to: new Date(),\r\n }),\r\n },\r\n {\r\n label: \"This Week\",\r\n value: \"this-week\",\r\n getDateRange: () => {\r\n const now = new Date()\r\n return { from: startOfWeek(now, { weekStartsOn: 1 }), to: endOfWeek(now, { weekStartsOn: 1 }) }\r\n },\r\n },\r\n {\r\n label: \"This Month\",\r\n value: \"this-month\",\r\n getDateRange: () => { const now = new Date(); return { from: startOfMonth(now), to: endOfMonth(now) } },\r\n },\r\n {\r\n label: \"Last 3 Months\",\r\n value: \"last-3-months\",\r\n getDateRange: () => { const now = new Date(); return { from: subMonths(now, 3), to: now } },\r\n },\r\n {\r\n label: \"Last 6 Months\",\r\n value: \"last-6-months\",\r\n getDateRange: () => { const now = new Date(); return { from: subMonths(now, 6), to: now } },\r\n },\r\n {\r\n label: \"This Year\",\r\n value: \"this-year\",\r\n getDateRange: () => { const now = new Date(); return { from: startOfYear(now), to: endOfYear(now) } },\r\n },\r\n {\r\n label: \"Last Year\",\r\n value: \"last-year\",\r\n getDateRange: () => { const ly = subYears(new Date(), 1); return { from: startOfYear(ly), to: endOfYear(ly) } },\r\n },\r\n {\r\n label: \"Custom Range\",\r\n value: \"custom-range\",\r\n getDateRange: () => undefined,\r\n },\r\n]\r\n\r\nfunction DateRangePicker({\r\n className,\r\n value: valueProp,\r\n onValueChange: onValueChangeProp,\r\n defaultValue,\r\n required,\r\n disabled,\r\n placeholder = \"Pick a date\",\r\n options = true,\r\n disabledDates,\r\n}: DateRangePickerProps) {\r\n const onValueChange = React.useCallback(\r\n (value: DateRange | undefined) => {\r\n if (required) onValueChangeProp?.(value as DateRange)\r\n else onValueChangeProp?.(value)\r\n },\r\n [onValueChangeProp, required],\r\n )\r\n\r\n const [value, setValue] = useControlledState<DateRange | undefined>({\r\n value: valueProp,\r\n defaultValue,\r\n onChange: onValueChange,\r\n })\r\n\r\n const [currentMonth, setCurrentMonth] = React.useState<Date | undefined>(value?.from || new Date())\r\n const [isOpen, setIsOpen] = React.useState(false)\r\n const [navView, setNavView] = React.useState<NavView>(\"days\")\r\n\r\n const hasValue = !!value?.from\r\n\r\n const isSameDay = (date1?: Date, date2?: Date): boolean => {\r\n if (!date1 || !date2) return false\r\n return (\r\n date1.getFullYear() === date2.getFullYear() &&\r\n date1.getMonth() === date2.getMonth() &&\r\n date1.getDate() === date2.getDate()\r\n )\r\n }\r\n\r\n const isOptionActive = (option: DateRangeOption): boolean => {\r\n if (!value?.from || !value?.to) return false\r\n if (option.value === \"custom-range\") {\r\n return dateRangeOptions.every((opt) => {\r\n if (opt.value === \"custom-range\") return true\r\n const optRange = opt.getDateRange()\r\n if (!optRange?.from || !optRange?.to) return true\r\n return !(isSameDay(value.from, optRange.from) && isSameDay(value.to, optRange.to))\r\n })\r\n }\r\n const optionRange = option.getDateRange()\r\n if (!optionRange?.from || !optionRange?.to) return false\r\n return isSameDay(value.from, optionRange.from) && isSameDay(value.to, optionRange.to)\r\n }\r\n\r\n return (\r\n <Popover open={disabled ? false : isOpen} onOpenChange={setIsOpen}>\r\n <PopoverTrigger\r\n render={\r\n <Button\r\n className={cn(\r\n \"group h-9 w-full justify-between rounded-xp-card-base border px-3 text-body-medium-3 transition-colors\",\r\n \"border-border-primary bg-bg-primary text-text-secondary hover:bg-bg-primary-hover\",\r\n hasValue &&\r\n \"border-border-brand bg-bg-brand-primary text-text-brand-secondary\",\r\n \"data-[popup-open]:border-border-brand data-[popup-open]:bg-bg-brand-primary data-[popup-open]:text-text-brand-secondary\",\r\n \"disabled:pointer-events-none disabled:opacity-50\",\r\n className,\r\n )}\r\n variant={null}\r\n size={null}\r\n disabled={disabled}\r\n >\r\n <span className=\"flex min-w-0 items-center gap-2\">\r\n <CalendarIcon\r\n className={cn(\r\n \"size-4 shrink-0\",\r\n hasValue ? \"text-fg-brand-primary\" : \"text-fg-quaternary\",\r\n )}\r\n />\r\n <span className=\"truncate\">\r\n {value?.from\r\n ? value.to\r\n ? `${format(value.from, \"LLL dd, y\")} - ${format(value.to, \"LLL dd, y\")}`\r\n : format(value.from, \"LLL dd, y\")\r\n : placeholder}\r\n </span>\r\n </span>\r\n <ChevronDown\r\n className={cn(\r\n \"size-4 shrink-0 transition-transform group-data-[popup-open]:rotate-180\",\r\n hasValue ? \"text-fg-brand-primary\" : \"text-fg-quaternary\",\r\n )}\r\n />\r\n </Button>\r\n }\r\n />\r\n <PopoverPopup\r\n className={cn(\r\n \"w-auto border-0\",\r\n options ? \"rounded-2xl p-xp-lg flex gap-6\" : \"p-xp-none bg-transparent\",\r\n )}\r\n >\r\n {options && (\r\n <div className=\"flex flex-col gap-xp-md w-[135px]\">\r\n {dateRangeOptions.map((option) => {\r\n const active = isOptionActive(option)\r\n return (\r\n <Button\r\n key={option.value}\r\n className=\"justify-start px-xp-xl\"\r\n variant={active ? \"tertiary-accent\" : null}\r\n onClick={() => {\r\n const dateRange = option.getDateRange()\r\n if (dateRange) {\r\n setValue(dateRange)\r\n setNavView(\"days\")\r\n setCurrentMonth(dateRange.from)\r\n }\r\n }}\r\n >\r\n {option.label}\r\n </Button>\r\n )\r\n })}\r\n </div>\r\n )}\r\n <Calendar\r\n autoFocus\r\n disabled={disabledDates}\r\n mode=\"range\"\r\n month={currentMonth}\r\n navView={navView}\r\n numberOfMonths={2}\r\n selected={value}\r\n onMonthChange={setCurrentMonth}\r\n onNavViewChange={setNavView}\r\n onSelect={(val) => {\r\n if (required && !val) return\r\n setValue(val)\r\n }}\r\n />\r\n </PopoverPopup>\r\n </Popover>\r\n )\r\n}\r\n\r\nexport { DateRangePicker }\r\n"]}