@forgedevstack/bear 1.1.8 → 1.2.0
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.
- package/README.md +4 -4
- package/dist/components/AlertDialog/AlertDialog.cjs +1 -1
- package/dist/components/AlertDialog/AlertDialog.const.cjs +1 -1
- package/dist/components/AlertDialog/AlertDialog.const.d.ts +2 -2
- package/dist/components/AlertDialog/AlertDialog.const.js +4 -4
- package/dist/components/AlertDialog/AlertDialog.js +76 -62
- package/dist/components/BearLogo/BearLogo.d.ts +2 -7
- package/dist/components/BearLogo/BearLogo.types.d.ts +15 -0
- package/dist/components/BearLogo/EmberLogo.d.ts +1 -8
- package/dist/components/BearLogo/index.d.ts +1 -2
- package/dist/components/Biometric/Biometric.cjs +1 -0
- package/dist/components/Biometric/Biometric.d.ts +3 -0
- package/dist/components/Biometric/Biometric.js +123 -0
- package/dist/components/Biometric/Biometric.types.d.ts +35 -0
- package/dist/components/Biometric/BiometricIcon.cjs +1 -0
- package/dist/components/Biometric/BiometricIcon.d.ts +3 -0
- package/dist/components/Biometric/BiometricIcon.js +45 -0
- package/dist/components/Biometric/index.d.ts +3 -0
- package/dist/components/Biometric/useBiometric.cjs +1 -0
- package/dist/components/Biometric/useBiometric.d.ts +2 -0
- package/dist/components/Biometric/useBiometric.js +21 -0
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.js +3 -2
- package/dist/components/CloseButton/CloseButton.cjs +1 -0
- package/dist/components/CloseButton/CloseButton.d.ts +4 -0
- package/dist/components/CloseButton/CloseButton.js +60 -0
- package/dist/components/CloseButton/CloseButton.types.d.ts +15 -0
- package/dist/components/CloseButton/index.d.ts +2 -0
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +12 -11
- package/dist/components/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.const.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.const.js +12 -13
- package/dist/components/DateRangePicker/DateRangePicker.js +107 -81
- package/dist/components/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/Dropdown/Dropdown.js +48 -44
- package/dist/components/Icon/icons/commerce.cjs +1 -0
- package/dist/components/Icon/icons/commerce.d.ts +25 -0
- package/dist/components/Icon/icons/commerce.js +124 -0
- package/dist/components/Icon/icons/device.cjs +1 -0
- package/dist/components/Icon/icons/device.d.ts +27 -0
- package/dist/components/Icon/icons/device.js +122 -0
- package/dist/components/Icon/icons/file.cjs +1 -0
- package/dist/components/Icon/icons/file.d.ts +25 -0
- package/dist/components/Icon/icons/file.js +120 -0
- package/dist/components/Icon/icons/social.cjs +1 -0
- package/dist/components/Icon/icons/social.d.ts +24 -0
- package/dist/components/Icon/icons/social.js +89 -0
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.d.ts +93 -56
- package/dist/components/Icon/index.js +38 -26
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +153 -101
- package/dist/components/Input/Input.types.d.ts +8 -2
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/Overlay/Overlay.cjs +1 -0
- package/dist/components/Overlay/Overlay.d.ts +4 -0
- package/dist/components/Overlay/Overlay.js +38 -0
- package/dist/components/Overlay/Overlay.types.d.ts +23 -0
- package/dist/components/Overlay/index.d.ts +2 -0
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.js +76 -76
- package/dist/components/Portal/Portal.cjs +1 -0
- package/dist/components/Portal/Portal.d.ts +11 -0
- package/dist/components/Portal/Portal.js +12 -0
- package/dist/components/Portal/index.d.ts +2 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +41 -38
- package/dist/components/Tabs/TabList.cjs +1 -0
- package/dist/components/Tabs/TabList.d.ts +3 -0
- package/dist/components/Tabs/TabList.js +69 -0
- package/dist/components/Tabs/TabPanel.cjs +1 -0
- package/dist/components/Tabs/TabPanel.d.ts +3 -0
- package/dist/components/Tabs/TabPanel.js +13 -0
- package/dist/components/Tabs/Tabs.cjs +1 -1
- package/dist/components/Tabs/Tabs.d.ts +2 -27
- package/dist/components/Tabs/Tabs.js +42 -61
- package/dist/components/Tabs/Tabs.types.d.ts +4 -0
- package/dist/components/Tabs/index.d.ts +3 -1
- package/dist/components/ThemeIcon/ThemeIcon.cjs +1 -0
- package/dist/components/ThemeIcon/ThemeIcon.d.ts +4 -0
- package/dist/components/ThemeIcon/ThemeIcon.js +54 -0
- package/dist/components/ThemeIcon/ThemeIcon.types.d.ts +22 -0
- package/dist/components/ThemeIcon/index.d.ts +2 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.cjs +1 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +6 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +22 -0
- package/dist/components/VisuallyHidden/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +15 -2
- package/dist/components/index.js +329 -312
- package/dist/hooks/bearStyled.cjs +1 -1
- package/dist/hooks/bearStyled.d.ts +31 -9
- package/dist/hooks/bearStyled.js +17 -12
- package/dist/hooks/useMediaQuery/useMediaQuery.d.ts +9 -1
- package/dist/hooks/useResponsive.cjs +1 -1
- package/dist/hooks/useResponsive.d.ts +2 -17
- package/dist/hooks/useResponsive.js +47 -41
- package/dist/index.cjs +1 -1
- package/dist/index.js +408 -391
- package/dist/styles/_effects.css +9 -0
- package/dist/styles.css +1 -1
- package/dist/types/theme.types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),D=require("../../utils/cn.cjs"),he=require("../../hooks/useBearStyles.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const v=require("../Icon/index.cjs"),s=require("./Calendar.const.cjs"),l=require("./Calendar.utils.cjs"),xe=require("./Calendar.helpers.cjs"),ke=G=>{const{viewDate:w,value:E=null,onSelect:C,onViewChange:n,minDate:N,maxDate:_,disabledDates:M=[],highlightedDates:R=[],weekdayLabels:S=s.DEFAULT_WEEKDAYS,firstDayOfWeek:k=s.NUMBER.ZERO,showWeekNumbers:ye=!1,slots:r={},clearable:K=!0,onClear:u,showTodayButton:Z=!0,onToday:h,bis:X,style:J,inline:O=!1,className:Q}=G,b=w.getFullYear(),P=he.useBearStyles(X,J),d=w.getMonth(),$=i.useMemo(()=>new Date,[]),g=i.useCallback(()=>{n==null||n(new Date(b-s.NUMBER.ONE,d,s.NUMBER.ONE))},[b,d,n]),L=i.useCallback(()=>{n==null||n(new Date(b,d-s.NUMBER.ONE,s.NUMBER.ONE))},[b,d,n]),W=i.useCallback(()=>{n==null||n(new Date(b,d+s.NUMBER.ONE,s.NUMBER.ONE))},[b,d,n]),z=i.useCallback(()=>{n==null||n(new Date(b+s.NUMBER.ONE,d,s.NUMBER.ONE))},[b,d,n]),p=L,B=W,V={onPrevYear:g,onPrevMonth:L,onNextMonth:W,onNextYear:z},ee=i.useCallback(t=>N&&t<N||_&&t>_?!0:M.some(a=>l.isSameDay(a,t)),[N,_,M]),re=i.useCallback(t=>R.some(a=>l.isSameDay(a,t)),[R]),ae=i.useMemo(()=>l.buildCalendarGrid(b,d,k),[b,d,k]),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),D=require("../../utils/cn.cjs"),he=require("../../hooks/useBearStyles.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");require("../../context/BearProvider.cjs");const v=require("../Icon/index.cjs"),s=require("./Calendar.const.cjs"),l=require("./Calendar.utils.cjs"),xe=require("./Calendar.helpers.cjs"),ke=G=>{const{viewDate:w,value:E=null,onSelect:C,onViewChange:n,minDate:N,maxDate:_,disabledDates:M=[],highlightedDates:R=[],weekdayLabels:S=s.DEFAULT_WEEKDAYS,firstDayOfWeek:k=s.NUMBER.ZERO,showWeekNumbers:ye=!1,slots:r={},clearable:K=!0,onClear:u,showTodayButton:Z=!0,onToday:h,bis:X,style:J,inline:O=!1,className:Q}=G,b=w.getFullYear(),P=he.useBearStyles(X,J),d=w.getMonth(),$=i.useMemo(()=>new Date,[]),g=i.useCallback(()=>{n==null||n(new Date(b-s.NUMBER.ONE,d,s.NUMBER.ONE))},[b,d,n]),L=i.useCallback(()=>{n==null||n(new Date(b,d-s.NUMBER.ONE,s.NUMBER.ONE))},[b,d,n]),W=i.useCallback(()=>{n==null||n(new Date(b,d+s.NUMBER.ONE,s.NUMBER.ONE))},[b,d,n]),z=i.useCallback(()=>{n==null||n(new Date(b+s.NUMBER.ONE,d,s.NUMBER.ONE))},[b,d,n]),p=L,B=W,V={onPrevYear:g,onPrevMonth:L,onNextMonth:W,onNextYear:z},ee=i.useCallback(t=>N&&t<N||_&&t>_?!0:M.some(a=>l.isSameDay(a,t)),[N,_,M]),re=i.useCallback(t=>R.some(a=>l.isSameDay(a,t)),[R]),ae=i.useMemo(()=>l.buildCalendarGrid(b,d,k),[b,d,k]),q=i.useMemo(()=>l.reorderWeekdays(S,k),[S,k]),T=s.MONTHS[d],f=E!=null,te=O?"Bear-Calendar Bear-Calendar--inline bear-block bear-w-full bear-bg-white dark:bear-bg-zinc-900 bear-rounded-xl bear-shadow-none bear-border bear-border-zinc-200 dark:bear-border-zinc-700 bear-p-4 bear-text-zinc-900 dark:bear-text-zinc-100":"Bear-Calendar Bear-Calendar--dropdown bear-mt-2 bear-bg-white dark:bear-bg-zinc-900 bear-rounded-xl bear-shadow-xl bear-border bear-border-zinc-200 dark:bear-border-zinc-700 bear-p-4 bear-w-80 bear-text-zinc-900 dark:bear-text-zinc-100",U=O?void 0:{zIndex:s.CALENDAR_DROPDOWN_Z_INDEX},ne=()=>{if(r.header)return r.header({month:T,year:b,onPrev:p,onNext:B,nav:V});const t=r.navPrevYear,a=r.navPrev,o=r.navNext,c=r.navNextYear,y=r.headerLabel||xe.DefaultHeaderLabel;return e.jsxs("div",{className:"Bear-Calendar__header bear-flex bear-items-center bear-justify-between bear-gap-1 bear-mb-4",children:[e.jsxs("div",{className:"Bear-Calendar__nav-left bear-flex bear-items-center bear-gap-0.5",children:[t?t({onClick:g}):e.jsx("button",{type:"button",onClick:g,className:"Bear-Calendar__nav-btn bear-p-1.5 bear-rounded bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800 bear-transition-colors","aria-label":"Previous year",children:e.jsx(v.ChevronsLeftIcon,{size:16})}),a?a({onClick:p}):e.jsx("button",{type:"button",onClick:p,className:"Bear-Calendar__nav-btn bear-p-1.5 bear-rounded bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800 bear-transition-colors","aria-label":"Previous month",children:e.jsx(v.ChevronLeftIcon,{size:16})})]}),y({month:T,year:b}),e.jsxs("div",{className:"Bear-Calendar__nav-right bear-flex bear-items-center bear-gap-0.5",children:[o?o({onClick:B}):e.jsx("button",{type:"button",onClick:B,className:"Bear-Calendar__nav-btn bear-p-1.5 bear-rounded bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800 bear-transition-colors","aria-label":"Next month",children:e.jsx(v.ChevronRightIcon,{size:16})}),c?c({onClick:z}):e.jsx("button",{type:"button",onClick:z,className:"Bear-Calendar__nav-btn bear-p-1.5 bear-rounded bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800 bear-transition-colors","aria-label":"Next year",children:e.jsx(v.ChevronsRightIcon,{size:16})})]})]})},oe=()=>{if(r.weekdays)return r.weekdays({days:q});const t=r.weekday;return e.jsx("div",{className:"Bear-Calendar__weekdays bear-grid bear-grid-cols-7 bear-gap-1 bear-mb-2",children:q.map(a=>t?e.jsx("div",{children:t({label:a})},a):e.jsx("div",{className:D.cn("Bear-Calendar__weekday bear-text-center bear-text-xs bear-font-medium bear-uppercase bear-text-zinc-500 dark:bear-text-zinc-400",s.WEEKEND_LABELS.includes(a)&&"bear-text-red-500"),children:a},a))})},se=(t,a)=>{const{date:o,isCurrentMonth:c}=t,y=o.getDate(),ce=o.getDay(),le=l.isWeekendDay(ce),x=l.isSameDay(E,o),j=l.isSameDay($,o),m=ee(o),H=re(o),F=()=>{m||C==null||C(o)},ue={date:o,day:y,isCurrentMonth:c,isSelected:x,isToday:j,isDisabled:m,isHighlighted:H,onClick:F};return r.day?e.jsx("span",{children:r.day(ue)},a):e.jsx("button",{type:"button",onClick:F,disabled:m,className:D.cn("Bear-Calendar__day bear-w-8 bear-h-8 bear-rounded-full bear-text-sm bear-font-medium bear-transition-colors bear-flex bear-items-center bear-justify-center",x&&"Bear-Calendar__day--selected bear-bg-pink-500 bear-text-white hover:bear-bg-pink-600",!x&&j&&"Bear-Calendar__day--today bear-ring-2 bear-ring-pink-500/50 bear-bg-transparent",!x&&!j&&(c?le?"Bear-Calendar__day--weekend bear-text-red-500 dark:bear-text-red-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800":"bear-text-zinc-700 dark:bear-text-zinc-300 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800":"Bear-Calendar__day--other bear-text-zinc-500 dark:bear-text-zinc-600 hover:bear-bg-zinc-50 dark:hover:bear-bg-zinc-800/50"),H&&!x&&"Bear-Calendar__day--highlighted bear-bg-pink-500/15",m&&"Bear-Calendar__day--disabled bear-opacity-40 bear-cursor-not-allowed"),children:y},a)},be=()=>{const t=ae.map((a,o)=>se(a,o));return r.daysGrid?r.daysGrid({children:t,className:"Bear-Calendar__grid bear-grid bear-grid-cols-7 bear-gap-1"}):e.jsx("div",{className:"Bear-Calendar__grid bear-grid bear-grid-cols-7 bear-gap-1",children:t})},de=()=>{const t=K&&f&&u,a=Z&&h;if(!t&&!a)return null;if(r.footer){const o=r.clearButton,c=r.todayButton;return r.footer({children:e.jsxs("div",{className:"Bear-Calendar__footer bear-flex bear-justify-between bear-gap-2 bear-mt-4 bear-pt-3 bear-border-t bear-border-zinc-200 dark:bear-border-zinc-700",children:[t&&o?o({onClick:u,hasSelection:f}):t?e.jsx("button",{type:"button",onClick:u,className:"Bear-Calendar__clear-btn bear-text-sm bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-text-zinc-700 dark:hover:bear-text-zinc-200 bear-transition-colors",children:"Clear"}):e.jsx("span",{}),a&&c?c({onClick:h}):a?e.jsx("button",{type:"button",onClick:h,className:"Bear-Calendar__today-btn bear-text-sm bear-text-pink-600 dark:bear-text-pink-400 hover:bear-text-pink-700 dark:hover:bear-text-pink-300 bear-font-medium",children:"Today"}):null]})})}return r.clearButton&&r.todayButton?e.jsxs("div",{className:"Bear-Calendar__footer bear-flex bear-justify-between bear-gap-2 bear-mt-4 bear-pt-3 bear-border-t bear-border-zinc-200 dark:bear-border-zinc-700",children:[t&&r.clearButton({onClick:u,hasSelection:f}),a&&r.todayButton({onClick:h})]}):e.jsxs("div",{className:"Bear-Calendar__footer bear-flex bear-justify-between bear-gap-2 bear-mt-4 bear-pt-3 bear-border-t bear-border-zinc-200 dark:bear-border-zinc-700",children:[t?e.jsx("button",{type:"button",onClick:u,className:"Bear-Calendar__clear-btn bear-text-sm bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-text-zinc-700 dark:hover:bear-text-zinc-200 bear-transition-colors",children:"Clear"}):e.jsx("span",{}),a?e.jsx("button",{type:"button",onClick:h,className:"Bear-Calendar__today-btn bear-text-sm bear-text-pink-400 hover:bear-text-pink-300 bear-font-medium bear-transition-colors",children:"Today"}):null]})},Y=e.jsxs(e.Fragment,{children:[ne(),oe(),be(),de()]}),I=D.cn(te,Q),A=Object.keys(P).length?P:void 0,ie=U?{...A,...U}:A;return r.root?r.root({children:Y,className:I}):e.jsx("div",{className:I,style:ie,children:Y})};exports.Calendar=ke;
|
|
@@ -3,11 +3,12 @@ import { useMemo as D, useCallback as l } from "react";
|
|
|
3
3
|
import { cn as E } from "../../utils/cn.js";
|
|
4
4
|
import { useBearStyles as ke } from "../../hooks/useBearStyles.js";
|
|
5
5
|
import "../../hooks/useBearComponent/useBearComponent.js";
|
|
6
|
+
import "../../context/BearProvider.js";
|
|
6
7
|
import { ChevronsLeftIcon as ye, ChevronLeftIcon as xe, ChevronRightIcon as ve, ChevronsRightIcon as pe } from "../Icon/index.js";
|
|
7
8
|
import { DEFAULT_WEEKDAYS as ze, NUMBER as i, CALENDAR_DROPDOWN_Z_INDEX as Ce, MONTHS as _e, WEEKEND_LABELS as ge } from "./Calendar.const.js";
|
|
8
9
|
import { isSameDay as v, buildCalendarGrid as Ne, reorderWeekdays as fe, isWeekendDay as Be } from "./Calendar.utils.js";
|
|
9
10
|
import { DefaultHeaderLabel as we } from "./Calendar.helpers.js";
|
|
10
|
-
const
|
|
11
|
+
const Re = (Z) => {
|
|
11
12
|
const {
|
|
12
13
|
viewDate: O,
|
|
13
14
|
value: P = null,
|
|
@@ -183,5 +184,5 @@ const Ie = (Z) => {
|
|
|
183
184
|
return e.root ? e.root({ children: H, className: F }) : /* @__PURE__ */ t("div", { className: F, style: se, children: H });
|
|
184
185
|
};
|
|
185
186
|
export {
|
|
186
|
-
|
|
187
|
+
Re as Calendar
|
|
187
188
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("../../utils/cn.cjs");require("react");const t={xs:{btn:"bear-w-5 bear-h-5",icon:10},sm:{btn:"bear-w-7 bear-h-7",icon:14},md:{btn:"bear-w-8 bear-h-8",icon:16},lg:{btn:"bear-w-10 bear-h-10",icon:18},xl:{btn:"bear-w-12 bear-h-12",icon:20}},d=({onClick:n,size:a="md",disabled:o=!1,"aria-label":i="Close",className:b,testId:s})=>{const{btn:l,icon:r}=t[a]??t.md;return e.jsx("button",{type:"button",onClick:n,disabled:o,"aria-label":i,"data-testid":s,className:c.cn("Bear-CloseButton","bear-inline-flex bear-items-center bear-justify-center bear-rounded-md","bear-text-gray-400 dark:bear-text-zinc-500","hover:bear-text-gray-600 dark:hover:bear-text-white","hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700","bear-transition-colors bear-cursor-pointer","disabled:bear-opacity-40 disabled:bear-cursor-not-allowed",l,b),children:e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})};exports.CloseButton=d;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as e, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { cn as d } from "../../utils/cn.js";
|
|
3
|
+
import "react";
|
|
4
|
+
const t = {
|
|
5
|
+
xs: { btn: "bear-w-5 bear-h-5", icon: 10 },
|
|
6
|
+
sm: { btn: "bear-w-7 bear-h-7", icon: 14 },
|
|
7
|
+
md: { btn: "bear-w-8 bear-h-8", icon: 16 },
|
|
8
|
+
lg: { btn: "bear-w-10 bear-h-10", icon: 18 },
|
|
9
|
+
xl: { btn: "bear-w-12 bear-h-12", icon: 20 }
|
|
10
|
+
}, u = ({
|
|
11
|
+
onClick: a,
|
|
12
|
+
size: o = "md",
|
|
13
|
+
disabled: n = !1,
|
|
14
|
+
"aria-label": b = "Close",
|
|
15
|
+
className: i,
|
|
16
|
+
testId: s
|
|
17
|
+
}) => {
|
|
18
|
+
const { btn: l, icon: r } = t[o] ?? t.md;
|
|
19
|
+
return /* @__PURE__ */ e(
|
|
20
|
+
"button",
|
|
21
|
+
{
|
|
22
|
+
type: "button",
|
|
23
|
+
onClick: a,
|
|
24
|
+
disabled: n,
|
|
25
|
+
"aria-label": b,
|
|
26
|
+
"data-testid": s,
|
|
27
|
+
className: d(
|
|
28
|
+
"Bear-CloseButton",
|
|
29
|
+
"bear-inline-flex bear-items-center bear-justify-center bear-rounded-md",
|
|
30
|
+
"bear-text-gray-400 dark:bear-text-zinc-500",
|
|
31
|
+
"hover:bear-text-gray-600 dark:hover:bear-text-white",
|
|
32
|
+
"hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700",
|
|
33
|
+
"bear-transition-colors bear-cursor-pointer",
|
|
34
|
+
"disabled:bear-opacity-40 disabled:bear-cursor-not-allowed",
|
|
35
|
+
l,
|
|
36
|
+
i
|
|
37
|
+
),
|
|
38
|
+
children: /* @__PURE__ */ c(
|
|
39
|
+
"svg",
|
|
40
|
+
{
|
|
41
|
+
width: r,
|
|
42
|
+
height: r,
|
|
43
|
+
viewBox: "0 0 24 24",
|
|
44
|
+
fill: "none",
|
|
45
|
+
stroke: "currentColor",
|
|
46
|
+
strokeWidth: "2",
|
|
47
|
+
strokeLinecap: "round",
|
|
48
|
+
strokeLinejoin: "round",
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
51
|
+
/* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
u as CloseButton
|
|
60
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BearSize } from '../../types';
|
|
2
|
+
export interface CloseButtonProps {
|
|
3
|
+
/** Click handler */
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
/** Button size */
|
|
6
|
+
size?: BearSize;
|
|
7
|
+
/** Disabled state */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Accessible label */
|
|
10
|
+
'aria-label'?: string;
|
|
11
|
+
/** Additional class name */
|
|
12
|
+
className?: string;
|
|
13
|
+
/** Test ID */
|
|
14
|
+
testId?: string;
|
|
15
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),a=require("react"),J=require("react-dom"),K=require("../Calendar/Calendar.cjs"),D=require("../../utils/cn.cjs"),Q=require("../../hooks/useBearStyles.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const U=require("./DatePicker.utils.cjs"),X=({value:c,onChange:t,minDate:y,maxDate:j,disabled:b=!1,placeholder:z="Select date",label:p,error:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),a=require("react"),J=require("react-dom"),K=require("../Calendar/Calendar.cjs"),D=require("../../utils/cn.cjs"),Q=require("../../hooks/useBearStyles.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");require("../../context/BearProvider.cjs");const U=require("./DatePicker.utils.cjs"),X=({value:c,onChange:t,minDate:y,maxDate:j,disabled:b=!1,placeholder:z="Select date",label:p,error:i,helperText:m,format:B="MM/DD/YYYY",clearable:P=!0,className:_,style:h,bis:v,showWeekNumbers:S=!1,disabledDates:q=[],highlightedDates:N=[],slots:g,weekdayLabels:R,firstDayOfWeek:V=0,size:H="md",variant:M="default",icon:O})=>{const[o,n]=a.useState(!1),[E,L]=a.useState(c??new Date),[x,Y]=a.useState({top:0,left:0}),k=a.useRef(null),d=a.useRef(null),w=Q.useBearStyles(v,h);a.useEffect(()=>{if(o&&d.current){const e=d.current.getBoundingClientRect(),l=8,s=360,G=window.innerHeight-e.bottom<s&&e.top>s;Y({top:G?e.top-s-l:e.bottom+l,left:e.left})}},[o]),a.useEffect(()=>{const e=l=>{var u,f;const s=l.target;(u=k.current)!=null&&u.contains(s)||(f=s.closest)!=null&&f.call(s,"[data-bear-datepicker-calendar]")||n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const T=a.useCallback(e=>{t==null||t(e),n(!1)},[t]),A=a.useCallback(()=>{t==null||t(null),n(!1)},[t]),I=a.useCallback(e=>{L(e)},[]),W={sm:"bear-py-1.5 bear-px-3 bear-text-sm",md:"bear-py-2 bear-px-4",lg:"bear-py-2.5 bear-px-5 bear-text-lg"},F={default:"bear-bg-white dark:bear-bg-zinc-800 bear-border-zinc-300 dark:bear-border-zinc-600",filled:"bear-bg-zinc-100 dark:bear-bg-zinc-700 bear-border-transparent",outline:"bear-bg-transparent bear-border-zinc-400 dark:bear-border-zinc-500"};return r.jsxs("div",{ref:k,className:D.cn("Bear-DatePicker bear-relative",_),style:Object.keys(w).length?w:void 0,children:[p&&r.jsx("label",{className:"Bear-DatePicker__label bear-block bear-text-sm bear-font-medium bear-text-zinc-700 dark:bear-text-zinc-300 bear-mb-1.5",children:p}),r.jsxs("button",{ref:d,type:"button",onClick:()=>!b&&n(!o),disabled:b,className:D.cn("Bear-DatePicker__trigger bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-text-left bear-transition-colors",W[H],F[M],i?"bear-border-red-500":"focus:bear-border-pink-500",b&&"bear-opacity-50 bear-cursor-not-allowed",c?"bear-text-zinc-900 dark:bear-text-white":"bear-text-zinc-500"),children:[r.jsx("span",{className:"Bear-DatePicker__value",children:c?U.formatDate(c,B):z}),r.jsx("span",{className:"Bear-DatePicker__icon",children:O??r.jsx("svg",{className:"bear-w-5 bear-h-5 bear-text-zinc-400 bear-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})})]}),i&&r.jsx("p",{className:"Bear-DatePicker__error bear-mt-1 bear-text-xs bear-text-red-400",children:i}),m&&!i&&r.jsx("p",{className:"Bear-DatePicker__helper bear-mt-1 bear-text-xs bear-text-zinc-500",children:m}),o&&typeof document<"u"&&J.createPortal(r.jsx("div",{"data-bear-datepicker-calendar":!0,className:"Bear-DatePicker__dropdown bear-fixed bear-z-[9999]",style:{top:x.top,left:x.left},children:r.jsx(K.Calendar,{viewDate:E,onViewChange:I,value:c??null,onSelect:T,minDate:y,maxDate:j,disabledDates:q,highlightedDates:N,slots:g,weekdayLabels:R,firstDayOfWeek:V,showWeekNumbers:S,clearable:P,onClear:A,showTodayButton:!0,onToday:()=>{t==null||t(new Date),n(!1)}})}),document.body)]})};exports.DatePicker=X;
|
|
@@ -5,8 +5,9 @@ import { Calendar as Z } from "../Calendar/Calendar.js";
|
|
|
5
5
|
import { cn as B } from "../../utils/cn.js";
|
|
6
6
|
import { useBearStyles as $ } from "../../hooks/useBearStyles.js";
|
|
7
7
|
import "../../hooks/useBearComponent/useBearComponent.js";
|
|
8
|
+
import "../../context/BearProvider.js";
|
|
8
9
|
import { formatDate as C } from "./DatePicker.utils.js";
|
|
9
|
-
const
|
|
10
|
+
const le = ({
|
|
10
11
|
value: o,
|
|
11
12
|
onChange: t,
|
|
12
13
|
minDate: _,
|
|
@@ -31,19 +32,19 @@ const ie = ({
|
|
|
31
32
|
variant: A = "default",
|
|
32
33
|
icon: I
|
|
33
34
|
}) => {
|
|
34
|
-
const [
|
|
35
|
+
const [i, s] = p(!1), [T, W] = p(o ?? /* @__PURE__ */ new Date()), [w, q] = p({ top: 0, left: 0 }), x = y(null), b = y(null), D = $(j, V);
|
|
35
36
|
h(() => {
|
|
36
|
-
if (
|
|
37
|
-
const e = b.current.getBoundingClientRect(),
|
|
37
|
+
if (i && b.current) {
|
|
38
|
+
const e = b.current.getBoundingClientRect(), c = 8, a = 360, U = window.innerHeight - e.bottom < a && e.top > a;
|
|
38
39
|
q({
|
|
39
|
-
top: U ? e.top - a -
|
|
40
|
+
top: U ? e.top - a - c : e.bottom + c,
|
|
40
41
|
left: e.left
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
|
-
}, [
|
|
44
|
-
const e = (
|
|
44
|
+
}, [i]), h(() => {
|
|
45
|
+
const e = (c) => {
|
|
45
46
|
var d, m;
|
|
46
|
-
const a =
|
|
47
|
+
const a = c.target;
|
|
47
48
|
(d = x.current) != null && d.contains(a) || (m = a.closest) != null && m.call(a, "[data-bear-datepicker-calendar]") || s(!1);
|
|
48
49
|
};
|
|
49
50
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
@@ -69,7 +70,7 @@ const ie = ({
|
|
|
69
70
|
{
|
|
70
71
|
ref: b,
|
|
71
72
|
type: "button",
|
|
72
|
-
onClick: () => !l && s(!
|
|
73
|
+
onClick: () => !l && s(!i),
|
|
73
74
|
disabled: l,
|
|
74
75
|
className: B(
|
|
75
76
|
"Bear-DatePicker__trigger bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-text-left bear-transition-colors",
|
|
@@ -87,7 +88,7 @@ const ie = ({
|
|
|
87
88
|
),
|
|
88
89
|
n && /* @__PURE__ */ r("p", { className: "Bear-DatePicker__error bear-mt-1 bear-text-xs bear-text-red-400", children: n }),
|
|
89
90
|
k && !n && /* @__PURE__ */ r("p", { className: "Bear-DatePicker__helper bear-mt-1 bear-text-xs bear-text-zinc-500", children: k }),
|
|
90
|
-
|
|
91
|
+
i && typeof document < "u" && X(
|
|
91
92
|
/* @__PURE__ */ r(
|
|
92
93
|
"div",
|
|
93
94
|
{
|
|
@@ -124,5 +125,5 @@ const ie = ({
|
|
|
124
125
|
] });
|
|
125
126
|
};
|
|
126
127
|
export {
|
|
127
|
-
|
|
128
|
+
le as DatePicker
|
|
128
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),X=require("react-dom"),h=require("../../utils/cn.cjs"),r=require("./DateRangePicker.const.cjs"),b=require("./DateRangePicker.utils.cjs"),O=({year:E,month:d,range:a,onDayClick:k,onNav:L,minDate:u,maxDate:A})=>{const C=b.getCalendarDays(E,d),x=new Date;return x.setHours(0,0,0,0),e.jsxs("div",{className:"bear-w-64",children:[e.jsxs("div",{className:r.CALENDAR_HEADER_CLASSES,children:[e.jsx("button",{type:"button",onClick:()=>L(-1),className:r.NAV_BTN_CLASSES,"aria-label":"Previous month",children:e.jsx("svg",{className:"bear-w-4 bear-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsxs("span",{className:"bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white",children:[r.MONTH_LABELS[d]," ",E]}),e.jsx("button",{type:"button",onClick:()=>L(1),className:r.NAV_BTN_CLASSES,"aria-label":"Next month",children:e.jsx("svg",{className:"bear-w-4 bear-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),e.jsx("div",{className:"bear-grid bear-grid-cols-7 bear-gap-0.5 bear-mb-1",children:r.DAY_LABELS.map(n=>e.jsx("div",{className:"bear-text-xs bear-text-center bear-font-medium bear-text-gray-400 dark:bear-text-zinc-500 bear-py-1",children:n},n))}),e.jsx("div",{className:"bear-grid bear-grid-cols-7 bear-gap-0.5",children:C.map((n,_)=>{if(!n)return e.jsx("div",{},`e-${_}`);const p=u&&n<u||A&&n>A,i=b.isSameDay(n,a.start)||b.isSameDay(n,a.end),S=b.isInRange(n,a.start,a.end),D=b.isSameDay(n,x);return e.jsx("button",{type:"button",disabled:!!p,onClick:()=>k(n),className:h.cn(r.DAY_BASE_CLASSES,p?r.DAY_DISABLED_CLASSES:r.DAY_HOVER_CLASSES,i&&r.DAY_SELECTED_CLASSES,!i&&S&&r.DAY_IN_RANGE_CLASSES,!i&&!S&&D&&r.DAY_TODAY_CLASSES,!i&&!S&&!p&&"bear-text-gray-700 dark:bear-text-zinc-300"),children:n.getDate()},n.getTime())})})]})},ee=E=>{const{value:d,onChange:a,label:k,placeholder:L="Select date range",disabled:u=!1,clearable:A=!0,minDate:C,maxDate:x,presets:n,showPresets:_=!0,size:p="md",error:i,helperText:S,className:D,testId:I,...q}=E,[N,w]=s.useState(!1),[P,V]=s.useState({top:0,left:0}),[c,f]=s.useState(d??{start:null,end:null}),[T,j]=s.useState("start"),B=s.useRef(null),R=s.useRef(null),Y=s.useRef(null),M=new Date,[m,$]=s.useState(M.getMonth()),[g,G]=s.useState(M.getFullYear()),W=m===11?0:m+1,F=m===11?g+1:g;s.useEffect(()=>{d&&f(d)},[d]),s.useEffect(()=>{if(N&&R.current){const t=R.current.getBoundingClientRect(),o=8,l=400,U=window.innerHeight-t.bottom<l&&t.top>l;V({top:U?t.top-l-o:t.bottom+o,left:t.left})}},[N]),s.useEffect(()=>{const t=o=>{var v,y;const l=o.target;(v=B.current)!=null&&v.contains(l)||(y=Y.current)!=null&&y.contains(l)||w(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const H=s.useCallback(t=>{if(T==="start")f({start:t,end:null}),j("end");else{const o=t>=(c.start??t)?{start:c.start,end:t}:{start:t,end:c.start};f(o),j("start"),a==null||a(o)}},[T,c.start,a]),Z=s.useCallback(t=>{f(t),a==null||a(t),w(!1),j("start")},[a]),J=s.useCallback(()=>{const t={start:null,end:null};f(t),a==null||a(t),j("start")},[a]),K=s.useCallback(t=>{let o=m+t,l=g;o<0&&(o=11,l--),o>11&&(o=0,l++),$(o),G(l)},[m,g]),z=n??(_?r.getDefaultPresets():[]),Q=c.start?`${b.formatDate(c.start)}${c.end?` – ${b.formatDate(c.end)}`:""}`:L;return e.jsxs("div",{ref:B,className:h.cn(r.ROOT_CLASSES,D),"data-testid":I,...q,children:[k&&e.jsx("label",{className:r.LABEL_CLASSES,children:k}),e.jsxs("button",{ref:R,type:"button",disabled:u,onClick:()=>!u&&w(!N),className:h.cn(r.TRIGGER_CLASSES,r.SIZE_CLASSES[p],u&&"bear-opacity-50 bear-cursor-not-allowed"),children:[e.jsx("span",{className:h.cn(!c.start&&"bear-text-gray-400 dark:bear-text-zinc-500"),children:Q}),e.jsx("svg",{className:"bear-w-4 bear-h-4 bear-ml-2 bear-text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})]}),N&&typeof document<"u"&&X.createPortal(e.jsx("div",{ref:Y,"data-bear-daterangepicker-dropdown":!0,className:h.cn("bear-fixed bear-z-[9999] bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-xl bear-shadow-xl bear-p-4"),style:{top:P.top,left:P.left},children:e.jsxs("div",{className:"bear-flex bear-gap-4",children:[z.length>0&&e.jsxs("div",{className:"bear-border-r bear-border-gray-200 dark:bear-border-zinc-700 bear-pr-3 bear-space-y-1 bear-min-w-[120px]",children:[z.map(t=>e.jsx("button",{type:"button",onClick:()=>Z(t.range()),className:r.PRESET_BTN_CLASSES,children:t.label},t.label)),A&&c.start&&e.jsx("button",{type:"button",onClick:J,className:h.cn(r.PRESET_BTN_CLASSES,"bear-text-red-500"),children:"Clear"})]}),e.jsx(O,{year:g,month:m,range:c,onDayClick:H,onNav:K,minDate:C,maxDate:x}),e.jsx(O,{year:F,month:W,range:c,onDayClick:H,onNav:()=>{},minDate:C,maxDate:x})]})}),document.body),i&&e.jsx("p",{className:r.ERROR_CLASSES,children:i}),!i&&S&&e.jsx("p",{className:r.HELPER_CLASSES,children:S})]})};exports.DateRangePicker=ee;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=7,b=6,S=["Su","Mo","Tu","We","Th","Fr","Sa"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],E={sm:"bear-py-1.5 bear-px-3 bear-text-sm",md:"bear-py-2 bear-px-4 bear-text-base",lg:"bear-py-2.5 bear-px-5 bear-text-lg"},o="Bear-DateRangePicker bear-relative bear-inline-block",A="bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none",s="bear-flex bear-items-center bear-justify-between bear-mb-2",_="bear-p-1 bear-rounded hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-text-gray-500 dark:bear-text-zinc-400",L="bear-w-8 bear-h-8 bear-text-sm bear-rounded-full bear-transition-colors bear-cursor-pointer",c="bear-bg-pink-500 bear-text-white",D="bear-bg-pink-100 dark:bear-bg-pink-900/30 bear-text-pink-800 dark:bear-text-pink-200",i="hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700",g="bear-text-gray-300 dark:bear-text-zinc-600 bear-cursor-not-allowed",l="bear-ring-1 bear-ring-pink-400",d="bear-w-full bear-text-left bear-px-3 bear-py-1.5 bear-text-sm bear-rounded bear-transition-colors hover:bear-bg-pink-50 dark:hover:bear-bg-pink-900/20 bear-text-gray-700 dark:bear-text-zinc-300",u="Bear-DateRangePicker__label bear-block bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-zinc-300 bear-mb-1.5",C="bear-mt-1 bear-text-xs bear-text-red-500",x="bear-mt-1 bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500",R=()=>{const e=new Date;return e.setHours(0,0,0,0),[{label:"Today",range:()=>({start:new Date(e),end:new Date(e)})},{label:"Last 7 days",range:()=>{const r=new Date(e);return r.setDate(r.getDate()-6),{start:r,end:new Date(e)}}},{label:"Last 30 days",range:()=>{const r=new Date(e);return r.setDate(r.getDate()-29),{start:r,end:new Date(e)}}},{label:"This month",range:()=>({start:new Date(e.getFullYear(),e.getMonth(),1),end:new Date(e)})},{label:"Last month",range:()=>{const r=new Date(e.getFullYear(),e.getMonth()-1,1),t=new Date(e.getFullYear(),e.getMonth(),0);return{start:r,end:t}}}]};exports.CALENDAR_HEADER_CLASSES=s;exports.CALENDAR_ROWS=b;exports.DAYS_IN_WEEK=a;exports.DAY_BASE_CLASSES=L;exports.DAY_DISABLED_CLASSES=g;exports.DAY_HOVER_CLASSES=i;exports.DAY_IN_RANGE_CLASSES=D;exports.DAY_LABELS=S;exports.DAY_SELECTED_CLASSES=c;exports.DAY_TODAY_CLASSES=l;exports.ERROR_CLASSES=C;exports.HELPER_CLASSES=x;exports.LABEL_CLASSES=u;exports.MONTH_LABELS=n;exports.NAV_BTN_CLASSES=_;exports.PRESET_BTN_CLASSES=d;exports.ROOT_CLASSES=o;exports.SIZE_CLASSES=E;exports.TRIGGER_CLASSES=A;exports.getDefaultPresets=R;
|
|
@@ -15,7 +15,7 @@ const t = 7, b = 6, n = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], o = [
|
|
|
15
15
|
sm: "bear-py-1.5 bear-px-3 bear-text-sm",
|
|
16
16
|
md: "bear-py-2 bear-px-4 bear-text-base",
|
|
17
17
|
lg: "bear-py-2.5 bear-px-5 bear-text-lg"
|
|
18
|
-
}, S = "Bear-DateRangePicker bear-relative bear-inline-block", c = "bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none", i = "bear-
|
|
18
|
+
}, S = "Bear-DateRangePicker bear-relative bear-inline-block", c = "bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none", i = "bear-flex bear-items-center bear-justify-between bear-mb-2", g = "bear-p-1 bear-rounded hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-text-gray-500 dark:bear-text-zinc-400", l = "bear-w-8 bear-h-8 bear-text-sm bear-rounded-full bear-transition-colors bear-cursor-pointer", A = "bear-bg-pink-500 bear-text-white", E = "bear-bg-pink-100 dark:bear-bg-pink-900/30 bear-text-pink-800 dark:bear-text-pink-200", d = "hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700", x = "bear-text-gray-300 dark:bear-text-zinc-600 bear-cursor-not-allowed", D = "bear-ring-1 bear-ring-pink-400", u = "bear-w-full bear-text-left bear-px-3 bear-py-1.5 bear-text-sm bear-rounded bear-transition-colors hover:bear-bg-pink-50 dark:hover:bear-bg-pink-900/20 bear-text-gray-700 dark:bear-text-zinc-300", _ = "Bear-DateRangePicker__label bear-block bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-zinc-300 bear-mb-1.5", L = "bear-mt-1 bear-text-xs bear-text-red-500", k = "bear-mt-1 bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500", y = () => {
|
|
19
19
|
const e = /* @__PURE__ */ new Date();
|
|
20
20
|
return e.setHours(0, 0, 0, 0), [
|
|
21
21
|
{
|
|
@@ -50,25 +50,24 @@ const t = 7, b = 6, n = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], o = [
|
|
|
50
50
|
];
|
|
51
51
|
};
|
|
52
52
|
export {
|
|
53
|
-
|
|
53
|
+
i as CALENDAR_HEADER_CLASSES,
|
|
54
54
|
b as CALENDAR_ROWS,
|
|
55
55
|
t as DAYS_IN_WEEK,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
l as DAY_BASE_CLASSES,
|
|
57
|
+
x as DAY_DISABLED_CLASSES,
|
|
58
|
+
d as DAY_HOVER_CLASSES,
|
|
59
59
|
E as DAY_IN_RANGE_CLASSES,
|
|
60
60
|
n as DAY_LABELS,
|
|
61
61
|
A as DAY_SELECTED_CLASSES,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
k as
|
|
65
|
-
|
|
66
|
-
L as LABEL_CLASSES,
|
|
62
|
+
D as DAY_TODAY_CLASSES,
|
|
63
|
+
L as ERROR_CLASSES,
|
|
64
|
+
k as HELPER_CLASSES,
|
|
65
|
+
_ as LABEL_CLASSES,
|
|
67
66
|
o as MONTH_LABELS,
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
g as NAV_BTN_CLASSES,
|
|
68
|
+
u as PRESET_BTN_CLASSES,
|
|
70
69
|
S as ROOT_CLASSES,
|
|
71
70
|
s as SIZE_CLASSES,
|
|
72
71
|
c as TRIGGER_CLASSES,
|
|
73
|
-
|
|
72
|
+
y as getDefaultPresets
|
|
74
73
|
};
|
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/* @__PURE__ */
|
|
12
|
-
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as P, useEffect as T, useCallback as v } from "react";
|
|
3
|
+
import { createPortal as se } from "react-dom";
|
|
4
|
+
import { cn as p } from "../../utils/cn.js";
|
|
5
|
+
import { getDefaultPresets as oe, LABEL_CLASSES as le, SIZE_CLASSES as ce, TRIGGER_CLASSES as ie, PRESET_BTN_CLASSES as $, ERROR_CLASSES as de, HELPER_CLASSES as be, ROOT_CLASSES as me, CALENDAR_HEADER_CLASSES as ue, NAV_BTN_CLASSES as G, MONTH_LABELS as pe, DAY_LABELS as he, DAY_TODAY_CLASSES as Se, DAY_IN_RANGE_CLASSES as fe, DAY_SELECTED_CLASSES as ge, DAY_DISABLED_CLASSES as Ee, DAY_HOVER_CLASSES as Le, DAY_BASE_CLASSES as ke } from "./DateRangePicker.const.js";
|
|
6
|
+
import { formatDate as W, getCalendarDays as Ae, isSameDay as Y, isInRange as Ne } from "./DateRangePicker.utils.js";
|
|
7
|
+
const F = ({ year: E, month: c, range: r, onDayClick: L, onNav: k, minDate: d, maxDate: A }) => {
|
|
8
|
+
const N = Ae(E, c), h = /* @__PURE__ */ new Date();
|
|
9
|
+
return h.setHours(0, 0, 0, 0), /* @__PURE__ */ i("div", { className: "bear-w-64", children: [
|
|
10
|
+
/* @__PURE__ */ i("div", { className: ue, children: [
|
|
11
|
+
/* @__PURE__ */ t("button", { type: "button", onClick: () => k(-1), className: G, "aria-label": "Previous month", children: /* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }) }),
|
|
12
|
+
/* @__PURE__ */ i("span", { className: "bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white", children: [
|
|
13
|
+
pe[c],
|
|
13
14
|
" ",
|
|
14
|
-
|
|
15
|
+
E
|
|
15
16
|
] }),
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
+
/* @__PURE__ */ t("button", { type: "button", onClick: () => k(1), className: G, "aria-label": "Next month", children: /* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) }) })
|
|
17
18
|
] }),
|
|
18
|
-
/* @__PURE__ */
|
|
19
|
-
/* @__PURE__ */
|
|
20
|
-
if (!a) return /* @__PURE__ */
|
|
21
|
-
const S =
|
|
22
|
-
return /* @__PURE__ */
|
|
19
|
+
/* @__PURE__ */ t("div", { className: "bear-grid bear-grid-cols-7 bear-gap-0.5 bear-mb-1", children: he.map((a) => /* @__PURE__ */ t("div", { className: "bear-text-xs bear-text-center bear-font-medium bear-text-gray-400 dark:bear-text-zinc-500 bear-py-1", children: a }, a)) }),
|
|
20
|
+
/* @__PURE__ */ t("div", { className: "bear-grid bear-grid-cols-7 bear-gap-0.5", children: N.map((a, x) => {
|
|
21
|
+
if (!a) return /* @__PURE__ */ t("div", {}, `e-${x}`);
|
|
22
|
+
const S = d && a < d || A && a > A, l = Y(a, r.start) || Y(a, r.end), b = Ne(a, r.start, r.end), _ = Y(a, h);
|
|
23
|
+
return /* @__PURE__ */ t(
|
|
23
24
|
"button",
|
|
24
25
|
{
|
|
25
26
|
type: "button",
|
|
26
27
|
disabled: !!S,
|
|
27
|
-
onClick: () =>
|
|
28
|
-
className:
|
|
29
|
-
|
|
30
|
-
S ?
|
|
31
|
-
l &&
|
|
32
|
-
!l &&
|
|
33
|
-
!l && !
|
|
34
|
-
!l && !
|
|
28
|
+
onClick: () => L(a),
|
|
29
|
+
className: p(
|
|
30
|
+
ke,
|
|
31
|
+
S ? Ee : Le,
|
|
32
|
+
l && ge,
|
|
33
|
+
!l && b && fe,
|
|
34
|
+
!l && !b && _ && Se,
|
|
35
|
+
!l && !b && !S && "bear-text-gray-700 dark:bear-text-zinc-300"
|
|
35
36
|
),
|
|
36
37
|
children: a.getDate()
|
|
37
38
|
},
|
|
@@ -39,77 +40,102 @@ const H = ({ year: L, month: o, range: r, onDayClick: A, onNav: N, minDate: i, m
|
|
|
39
40
|
);
|
|
40
41
|
}) })
|
|
41
42
|
] });
|
|
42
|
-
},
|
|
43
|
+
}, Re = (E) => {
|
|
43
44
|
const {
|
|
44
|
-
value:
|
|
45
|
+
value: c,
|
|
45
46
|
onChange: r,
|
|
46
|
-
label:
|
|
47
|
-
placeholder:
|
|
48
|
-
disabled:
|
|
49
|
-
clearable:
|
|
50
|
-
minDate:
|
|
51
|
-
maxDate:
|
|
47
|
+
label: L,
|
|
48
|
+
placeholder: k = "Select date range",
|
|
49
|
+
disabled: d = !1,
|
|
50
|
+
clearable: A = !0,
|
|
51
|
+
minDate: N,
|
|
52
|
+
maxDate: h,
|
|
52
53
|
presets: a,
|
|
53
|
-
showPresets:
|
|
54
|
+
showPresets: x = !0,
|
|
54
55
|
size: S = "md",
|
|
55
56
|
error: l,
|
|
56
|
-
helperText:
|
|
57
|
-
className:
|
|
58
|
-
testId:
|
|
59
|
-
...
|
|
60
|
-
} =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, [
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
helperText: b,
|
|
58
|
+
className: _,
|
|
59
|
+
testId: Z,
|
|
60
|
+
...q
|
|
61
|
+
} = E, [w, D] = u(!1), [H, J] = u({ top: 0, left: 0 }), [s, f] = u(c ?? { start: null, end: null }), [M, C] = u("start"), z = P(null), R = P(null), O = P(null), I = /* @__PURE__ */ new Date(), [m, K] = u(I.getMonth()), [g, Q] = u(I.getFullYear()), U = m === 11 ? 0 : m + 1, X = m === 11 ? g + 1 : g;
|
|
62
|
+
T(() => {
|
|
63
|
+
c && f(c);
|
|
64
|
+
}, [c]), T(() => {
|
|
65
|
+
if (w && R.current) {
|
|
66
|
+
const e = R.current.getBoundingClientRect(), n = 8, o = 400, ne = window.innerHeight - e.bottom < o && e.top > o;
|
|
67
|
+
J({
|
|
68
|
+
top: ne ? e.top - o - n : e.bottom + n,
|
|
69
|
+
left: e.left
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}, [w]), T(() => {
|
|
73
|
+
const e = (n) => {
|
|
74
|
+
var y, B;
|
|
75
|
+
const o = n.target;
|
|
76
|
+
(y = z.current) != null && y.contains(o) || (B = O.current) != null && B.contains(o) || D(!1);
|
|
66
77
|
};
|
|
67
|
-
return document.addEventListener("mousedown",
|
|
78
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
68
79
|
}, []);
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
|
|
80
|
+
const j = v((e) => {
|
|
81
|
+
if (M === "start")
|
|
82
|
+
f({ start: e, end: null }), C("end");
|
|
72
83
|
else {
|
|
73
|
-
const n =
|
|
74
|
-
|
|
84
|
+
const n = e >= (s.start ?? e) ? { start: s.start, end: e } : { start: e, end: s.start };
|
|
85
|
+
f(n), C("start"), r == null || r(n);
|
|
75
86
|
}
|
|
76
|
-
}, [
|
|
77
|
-
|
|
78
|
-
}, [r]),
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
}, [r]),
|
|
82
|
-
let n =
|
|
83
|
-
n < 0 && (n = 11,
|
|
84
|
-
}, [
|
|
85
|
-
return /* @__PURE__ */
|
|
86
|
-
|
|
87
|
-
/* @__PURE__ */
|
|
87
|
+
}, [M, s.start, r]), ee = v((e) => {
|
|
88
|
+
f(e), r == null || r(e), D(!1), C("start");
|
|
89
|
+
}, [r]), te = v(() => {
|
|
90
|
+
const e = { start: null, end: null };
|
|
91
|
+
f(e), r == null || r(e), C("start");
|
|
92
|
+
}, [r]), re = v((e) => {
|
|
93
|
+
let n = m + e, o = g;
|
|
94
|
+
n < 0 && (n = 11, o--), n > 11 && (n = 0, o++), K(n), Q(o);
|
|
95
|
+
}, [m, g]), V = a ?? (x ? oe() : []), ae = s.start ? `${W(s.start)}${s.end ? ` – ${W(s.end)}` : ""}` : k;
|
|
96
|
+
return /* @__PURE__ */ i("div", { ref: z, className: p(me, _), "data-testid": Z, ...q, children: [
|
|
97
|
+
L && /* @__PURE__ */ t("label", { className: le, children: L }),
|
|
98
|
+
/* @__PURE__ */ i(
|
|
88
99
|
"button",
|
|
89
100
|
{
|
|
101
|
+
ref: R,
|
|
90
102
|
type: "button",
|
|
91
|
-
disabled:
|
|
92
|
-
onClick: () => !
|
|
93
|
-
className:
|
|
103
|
+
disabled: d,
|
|
104
|
+
onClick: () => !d && D(!w),
|
|
105
|
+
className: p(ie, ce[S], d && "bear-opacity-50 bear-cursor-not-allowed"),
|
|
94
106
|
children: [
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
107
|
+
/* @__PURE__ */ t("span", { className: p(!s.start && "bear-text-gray-400 dark:bear-text-zinc-500"), children: ae }),
|
|
108
|
+
/* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4 bear-ml-2 bear-text-gray-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }) })
|
|
97
109
|
]
|
|
98
110
|
}
|
|
99
111
|
),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
w && typeof document < "u" && se(
|
|
113
|
+
/* @__PURE__ */ t(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
ref: O,
|
|
117
|
+
"data-bear-daterangepicker-dropdown": !0,
|
|
118
|
+
className: p(
|
|
119
|
+
"bear-fixed bear-z-[9999] bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-xl bear-shadow-xl bear-p-4"
|
|
120
|
+
),
|
|
121
|
+
style: { top: H.top, left: H.left },
|
|
122
|
+
children: /* @__PURE__ */ i("div", { className: "bear-flex bear-gap-4", children: [
|
|
123
|
+
V.length > 0 && /* @__PURE__ */ i("div", { className: "bear-border-r bear-border-gray-200 dark:bear-border-zinc-700 bear-pr-3 bear-space-y-1 bear-min-w-[120px]", children: [
|
|
124
|
+
V.map((e) => /* @__PURE__ */ t("button", { type: "button", onClick: () => ee(e.range()), className: $, children: e.label }, e.label)),
|
|
125
|
+
A && s.start && /* @__PURE__ */ t("button", { type: "button", onClick: te, className: p($, "bear-text-red-500"), children: "Clear" })
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ t(F, { year: g, month: m, range: s, onDayClick: j, onNav: re, minDate: N, maxDate: h }),
|
|
128
|
+
/* @__PURE__ */ t(F, { year: X, month: U, range: s, onDayClick: j, onNav: () => {
|
|
129
|
+
}, minDate: N, maxDate: h })
|
|
130
|
+
] })
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
document.body
|
|
134
|
+
),
|
|
135
|
+
l && /* @__PURE__ */ t("p", { className: de, children: l }),
|
|
136
|
+
!l && b && /* @__PURE__ */ t("p", { className: be, children: b })
|
|
111
137
|
] });
|
|
112
138
|
};
|
|
113
139
|
export {
|
|
114
|
-
|
|
140
|
+
Re as DateRangePicker
|
|
115
141
|
};
|