lsp-uikit 1.5.14 → 1.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsxs as t,jsx as e}from"react/jsx-runtime";import{format as
|
|
2
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import{format as o}from"date-fns";import*as r from"react";import{LuCalendarFold as a}from"react-icons/lu";import{cn as m}from"../../lib/utils/cn.js";import{Button as s}from"../button/button.js";import"copy-to-clipboard";import"lucide-react";import"../tooltip/tooltip.js";import{Calendar as i}from"../calendar/calendar.js";import{Popover as l,PopoverTrigger as c,PopoverContent as n}from"../popover/popover.js";import{Text as p}from"../text/text.js";import{ru as d}from"date-fns/locale";const f=f=>{const{selectedDate:u,className:j,triggerClassName:y,onApply:x}=f,[g,h]=r.useState();r.useEffect(()=>{h(u?new Date(u):void 0)},[u]);return t(l,{children:[t(c,{render:e(s,{variant:"secondary",className:m("w-[240px] justify-start text-left font-normal",!g&&"text-muted-foreground",y)}),children:[e(a,{className:"mr-1 h-4 w-4"}),g?o(g,"PPP"):e(p,{children:"Выберите дату"})]}),e(n,{className:m("w-auto p-0",j),align:"start",children:e(i,{mode:"single",selected:g,locale:d,onSelect:t=>{h(t),x?.(t?o(t,"yyyy-MM-dd"):void 0)}})})]})};export{f as DatePicker};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{differenceInCalendarDays as o,parseISO as t,format as n,subDays as a}from"date-fns";import{LuCalendarFold as i}from"react-icons/lu";import{cn as l}from"../../lib/utils/cn.js";import{Button as s}from"../button/button.js";import{Calendar as d}from"../calendar/calendar.js";import{Popover as m,PopoverTrigger as c,PopoverContent as f,PopoverClose as y}from"../popover/popover.js";const u="yyyy-MM-dd",
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{differenceInCalendarDays as o,parseISO as t,format as n,subDays as a}from"date-fns";import{LuCalendarFold as i}from"react-icons/lu";import{cn as l}from"../../lib/utils/cn.js";import{Button as s}from"../button/button.js";import{Calendar as d}from"../calendar/calendar.js";import{Popover as m,PopoverTrigger as c,PopoverContent as f,PopoverClose as y}from"../popover/popover.js";import{ru as p}from"date-fns/locale";const u="yyyy-MM-dd",h=e=>{if(e?.from&&e?.to)return Math.max(0,o(t(e.to),t(e.from)))+1},v=o=>{const{className:h,datesRange:v,withDatesMacroses:M,triggerClassName:g,render:w,align:N="start",onApply:x,onChange:k,...C}=o,j=(e=>{if(e?.from||e?.to)return{from:e?.from?t(e.from):void 0,to:e?.to?t(e.to):void 0}})(v),b=e=>{const r=new Date;let o=new Date(r);"week"===e&&(o=a(r,6)),"month"===e&&(o=a(r,29)),"year"===e&&(o=a(r,364));const t={from:n(o,u),to:n(r,u)};k(t),x?.(t)};return e("div",{className:l("grid gap-2",h),children:r(m,{children:[r(c,{render:w??e(s,{id:"date",variant:"secondary",className:l("justify-start text-left font-normal",!v&&"text-muted-foreground",g)}),children:[e(i,{}),j?.from?j.to?`${n(j.from,"dd MMM yyyy")} - ${n(j.to,"dd MMM yyyy")}`:n(j.from,"dd MMM yyyy"):"Укажите даты"]}),e(f,{className:"w-fit p-0",align:N,children:r("div",{className:"flex w-full flex-col",children:[M&&r("div",{className:"flex w-full items-center gap-2 p-3",children:[e(y,{render:e(s,{size:"sm",variant:"secondary",onClick:()=>b("week")}),children:"7 дней"}),e(y,{render:e(s,{size:"sm",variant:"secondary",onClick:()=>b("month")}),children:"30 дней"}),e(y,{render:e(s,{size:"sm",variant:"secondary",onClick:()=>b("year")}),children:"Год"})]}),e(d,{...C,mode:"range",locale:p,defaultMonth:j?.from,selected:j,onSelect:e=>{k((e=>{if(e?.from||e?.to)return{from:e?.from?n(e.from,u):void 0,to:e?.to?n(e.to,u):void 0}})(e))},numberOfMonths:2}),r("div",{className:"flex w-full gap-3 p-3",children:[e(y,{render:e(s,{className:"w-full",onClick:()=>{k(void 0),x?.(void 0)},variant:"outline",size:"sm"}),children:"Сбросить период"}),e(y,{render:e(s,{variant:"default_invert",disabled:!j?.from||!j.to,className:"w-full",onClick:()=>{x?.(v)},size:"sm"}),children:"Применить"})]})]})})]})})};export{v as DateRangePicker,h as getSelectedDaysCount};
|