@forgedevstack/bear 1.1.9 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- 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/Autocomplete/Autocomplete.cjs +1 -1
- package/dist/components/Autocomplete/Autocomplete.const.cjs +1 -0
- package/dist/components/Autocomplete/Autocomplete.const.d.ts +1 -0
- package/dist/components/Autocomplete/Autocomplete.const.js +4 -0
- package/dist/components/Autocomplete/Autocomplete.js +110 -72
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +74 -53
- package/dist/components/BottomSheet/BottomSheet.types.d.ts +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +126 -46
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +11 -4
- package/dist/components/Breadcrumbs/index.d.ts +1 -1
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.js +3 -2
- package/dist/components/Cascader/Cascader.cjs +1 -1
- package/dist/components/Cascader/Cascader.const.cjs +1 -1
- package/dist/components/Cascader/Cascader.const.d.ts +1 -1
- package/dist/components/Cascader/Cascader.const.js +1 -1
- package/dist/components/Cascader/Cascader.js +109 -146
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.cjs +1 -0
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.d.ts +3 -0
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.js +50 -0
- package/dist/components/Cascader/components/CascaderPanel/index.d.ts +1 -0
- package/dist/components/Chart/BarChart.cjs +1 -0
- package/dist/components/Chart/BarChart.d.ts +3 -0
- package/dist/components/Chart/BarChart.js +65 -0
- package/dist/components/Chart/Chart.cjs +1 -1
- package/dist/components/Chart/Chart.const.cjs +1 -1
- package/dist/components/Chart/Chart.const.d.ts +7 -0
- package/dist/components/Chart/Chart.const.js +12 -2
- package/dist/components/Chart/Chart.d.ts +1 -13
- package/dist/components/Chart/Chart.js +18 -204
- package/dist/components/Chart/Chart.types.d.ts +7 -1
- package/dist/components/Chart/LineChart.cjs +1 -0
- package/dist/components/Chart/LineChart.d.ts +3 -0
- package/dist/components/Chart/LineChart.js +73 -0
- package/dist/components/Chart/PieChart.cjs +1 -0
- package/dist/components/Chart/PieChart.d.ts +3 -0
- package/dist/components/Chart/PieChart.js +110 -0
- package/dist/components/Chart/index.d.ts +4 -1
- 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/ColorPicker/ColorPicker.cjs +1 -1
- package/dist/components/ColorPicker/ColorPicker.const.cjs +1 -1
- package/dist/components/ColorPicker/ColorPicker.const.d.ts +4 -2
- package/dist/components/ColorPicker/ColorPicker.const.js +8 -6
- package/dist/components/ColorPicker/ColorPicker.js +135 -73
- package/dist/components/ColorPicker/ColorPicker.utils.cjs +1 -0
- package/dist/components/ColorPicker/ColorPicker.utils.d.ts +17 -0
- package/dist/components/ColorPicker/ColorPicker.utils.js +43 -0
- package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.const.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.const.d.ts +2 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.js +29 -17
- package/dist/components/CountdownTimer/CountdownTimer.js +91 -61
- package/dist/components/CountdownTimer/CountdownTimer.types.d.ts +11 -2
- package/dist/components/CreditInput/CreditInput.cjs +1 -1
- package/dist/components/CreditInput/CreditInput.js +80 -78
- 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.js +89 -84
- package/dist/components/DiffSquares/DiffSquares.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.const.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.const.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.const.js +6 -0
- package/dist/components/DiffSquares/DiffSquares.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.js +70 -0
- package/dist/components/DiffSquares/DiffSquares.types.d.ts +23 -0
- package/dist/components/DiffSquares/DiffSquares.utils.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.utils.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.utils.js +12 -0
- package/dist/components/DiffSquares/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +41 -41
- package/dist/components/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/Dropdown/Dropdown.const.cjs +1 -0
- package/dist/components/Dropdown/Dropdown.const.d.ts +7 -0
- package/dist/components/Dropdown/Dropdown.const.js +10 -0
- package/dist/components/Dropdown/Dropdown.d.ts +0 -1
- package/dist/components/Dropdown/Dropdown.js +102 -92
- package/dist/components/Dropdown/Dropdown.types.d.ts +2 -0
- package/dist/components/Gauge/Gauge.cjs +1 -1
- package/dist/components/Gauge/Gauge.js +61 -50
- package/dist/components/Gauge/Gauge.types.d.ts +2 -0
- package/dist/components/HoverCard/HoverCard.cjs +6 -6
- package/dist/components/HoverCard/HoverCard.js +72 -54
- 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/icons/status.js +1 -1
- 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/MentionsInput/MentionsInput.cjs +1 -1
- package/dist/components/MentionsInput/MentionsInput.js +106 -83
- package/dist/components/Menu/Menu.cjs +1 -1
- package/dist/components/Menu/Menu.js +91 -80
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.const.cjs +1 -1
- package/dist/components/Modal/Modal.const.d.ts +1 -1
- package/dist/components/Modal/Modal.const.js +1 -1
- package/dist/components/Modal/Modal.js +50 -44
- package/dist/components/Modal/Modal.types.d.ts +6 -0
- package/dist/components/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +123 -78
- package/dist/components/NavigableSelect/NavigableSelect.cjs +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.cjs +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.d.ts +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.js +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.js +167 -143
- package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.js +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.js +87 -81
- package/dist/components/OTPInput/OTPInput.cjs +1 -1
- package/dist/components/OTPInput/OTPInput.const.cjs +1 -0
- package/dist/components/OTPInput/OTPInput.const.d.ts +6 -0
- package/dist/components/OTPInput/OTPInput.const.js +14 -0
- package/dist/components/OTPInput/OTPInput.js +99 -65
- package/dist/components/OTPInput/OTPInput.types.d.ts +7 -0
- 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/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.d.ts +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.js +1 -1
- package/dist/components/PhoneInput/PhoneInput.js +88 -83
- package/dist/components/Popconfirm/Popconfirm.cjs +1 -1
- package/dist/components/Popconfirm/Popconfirm.const.cjs +1 -1
- package/dist/components/Popconfirm/Popconfirm.const.d.ts +1 -3
- package/dist/components/Popconfirm/Popconfirm.const.js +12 -18
- package/dist/components/Popconfirm/Popconfirm.js +71 -51
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.js +36 -31
- package/dist/components/Portal/Portal.cjs +1 -0
- package/dist/components/Portal/Portal.d.ts +8 -0
- package/dist/components/Portal/Portal.js +6 -0
- package/dist/components/Portal/index.d.ts +2 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +71 -51
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.d.ts +3 -2
- package/dist/components/Stepper/Stepper.const.js +15 -14
- package/dist/components/Stepper/Stepper.d.ts +0 -7
- package/dist/components/Stepper/Stepper.js +164 -117
- package/dist/components/Stepper/Stepper.types.d.ts +3 -0
- package/dist/components/Tabs/TabList.cjs +1 -1
- package/dist/components/Tabs/TabList.js +72 -57
- package/dist/components/Tabs/Tabs.types.d.ts +4 -2
- package/dist/components/Tabs/index.d.ts +2 -2
- 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/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -1
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +26 -26
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -1
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +17 -17
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.js +86 -82
- package/dist/components/Toast/Toast.types.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.js +52 -44
- package/dist/components/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.d.ts +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.js +3 -3
- package/dist/components/TreeSelect/TreeSelect.js +120 -88
- 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/Watermark/Watermark.cjs +1 -1
- package/dist/components/Watermark/Watermark.const.cjs +1 -1
- package/dist/components/Watermark/Watermark.const.d.ts +6 -3
- package/dist/components/Watermark/Watermark.const.js +13 -11
- package/dist/components/Watermark/Watermark.js +87 -61
- package/dist/components/Watermark/Watermark.types.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +15 -3
- package/dist/components/index.js +296 -280
- 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/index.cjs +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +55 -54
- package/dist/hooks/useClickOutside.cjs +1 -1
- package/dist/hooks/useClickOutside.d.ts +4 -11
- package/dist/hooks/useClickOutside.js +26 -7
- 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 +383 -366
- package/dist/styles/_effects.css +26 -0
- package/dist/styles.css +1 -1
- package/dist/types/theme.types.d.ts +1 -0
- package/dist/utils/maxVisible.utils.cjs +1 -0
- package/dist/utils/maxVisible.utils.d.ts +12 -0
- package/dist/utils/maxVisible.utils.js +15 -0
- package/package.json +1 -1
- package/dist/components/HoverCard/HoverCard.utils.cjs +0 -1
- package/dist/components/HoverCard/HoverCard.utils.js +0 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("../../utils/cn.cjs"),N=require("./CreditInput.const.cjs"),x=require("./CreditInput.utils.cjs"),q={visa:e.jsx("svg",{viewBox:"0 0 24 24",className:"bear-w-8 bear-h-5",fill:"currentColor",children:e.jsx("path",{d:"M9.5 8.5l-1.8 7h-1.4l1.8-7h1.4zm6.5 4.5c0-1.1-.9-1.5-1.8-1.9-.6-.2-1-.4-1-.7 0-.2.2-.5.7-.5.5 0 .9.1 1.2.3l.2-1.2c-.3-.1-.9-.3-1.6-.3-1.7 0-2.9.9-2.9 2.2 0 1 .9 1.5 1.5 1.8.7.3 1 .5 1 .8 0 .4-.6.6-1.1.6-.6 0-1.1-.1-1.5-.3l-.2 1.2c.4.2 1 .3 1.7.3 1.8 0 2.9-.9 2.9-2.3h-.1zm2.7-4.5l-1.4 7h-1.3l.1-.5c-.4.4-.9.6-1.5.6-1.3 0-2.2-1.1-2.2-2.5 0-1.7 1.2-3.1 2.9-3.1.5 0 1 .1 1.4.4l.1-.4h1.3l-.4 2.5zm-2.1 2.3c0-.9-.5-1.5-1.2-1.5-.9 0-1.6.9-1.6 1.9 0 .8.5 1.4 1.2 1.4.9 0 1.6-.8 1.6-1.8z"})}),mastercard:e.jsxs("svg",{viewBox:"0 0 24 24",className:"bear-w-8 bear-h-5",fill:"currentColor",children:[e.jsx("circle",{cx:"9",cy:"12",r:"5",opacity:".8",fill:"#eb001b"}),e.jsx("circle",{cx:"15",cy:"12",r:"5",opacity:".8",fill:"#f79e1b"})]}),amex:e.jsxs("svg",{viewBox:"0 0 24 24",className:"bear-w-8 bear-h-5",fill:"#2e77bc",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"12",rx:"2"}),e.jsx("text",{x:"12",y:"14",textAnchor:"middle",fontSize:"6",fill:"white",fontWeight:"bold",children:"AMEX"})]}),discover:e.jsxs("svg",{viewBox:"0 0 24 24",className:"bear-w-8 bear-h-5",fill:"#ff6600",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"12",rx:"2"}),e.jsx("circle",{cx:"15",cy:"12",r:"3",fill:"white"})]}),diners:e.jsxs("svg",{viewBox:"0 0 24 24",className:"bear-w-8 bear-h-5",fill:"#0079be",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"12",rx:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"4",fill:"white"})]}),jcb:e.jsxs("svg",{viewBox:"0 0 24 24",className:"bear-w-8 bear-h-5",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"12",rx:"2",fill:"#0e4c96"}),e.jsx("text",{x:"12",y:"14",textAnchor:"middle",fontSize:"5",fill:"white",fontWeight:"bold",children:"JCB"})]}),unionpay:e.jsxs("svg",{viewBox:"0 0 24 24",className:"bear-w-8 bear-h-5",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"12",rx:"2",fill:"#d9222a"}),e.jsx("text",{x:"12",y:"14",textAnchor:"middle",fontSize:"4",fill:"white",fontWeight:"bold",children:"UnionPay"})]}),unknown:e.jsxs("svg",{viewBox:"0 0 24 24",className:"bear-w-8 bear-h-5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"12",rx:"2"}),e.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"})]})},H=({value:r,onChange:b,mode:U="single",showName:f=!1,size:O="md",variant:V="default",disabled:n=!1,required:W=!1,label:_,helperText:I,error:h,acceptedCards:y,validateOnInput:B=!0,className:Y,testId:$,translations:k,icon:S})=>{const[p,M]=t.useState((r==null?void 0:r.number)||""),[m,T]=t.useState(r!=null&&r.expiryMonth&&(r!=null&&r.expiryYear)?`${r.expiryMonth}/${r.expiryYear}`:""),[C,E]=t.useState((r==null?void 0:r.cvv)||""),[j,z]=t.useState((r==null?void 0:r.name)||""),[u,P]=t.useState("unknown"),[g,A]=t.useState({}),s=t.useMemo(()=>({...N.CREDIT_INPUT_DEFAULT_TRANSLATIONS,...k}),[k]);t.useEffect(()=>{(r==null?void 0:r.number)!==void 0&&M(r.number),r!=null&&r.expiryMonth&&(r!=null&&r.expiryYear)&&T(`${r.expiryMonth}/${r.expiryYear}`),(r==null?void 0:r.cvv)!==void 0&&E(r.cvv),(r==null?void 0:r.name)!==void 0&&z(r.name),(r==null?void 0:r.cardType)!==void 0&&P(r.cardType)},[r]);const L=t.useCallback(()=>{const c=x.createCreditCardValue(p,m,C,f?j:void 0);b==null||b(c)},[p,m,C,j,f,b]);t.useEffect(()=>{L()},[L]);const v=t.useCallback(c=>{const i=c.target.value.replace(/\D/g,""),o=x.detectCardType(i);P(o);const J=x.getMaxCardLength(o),X=i.slice(0,J),Z=x.formatCardNumber(X,o);M(Z),B&&y&&!y.includes(o)&&o!=="unknown"?A(w=>({...w,number:s.invalidCard})):A(w=>{const{number:K,...G}=w;return G})},[y,B,s.invalidCard]),R=t.useCallback(c=>{const i=x.formatExpiry(c.target.value);T(i)},[]),D=t.useCallback(c=>{const i=c.target.value.replace(/\D/g,""),o=x.getMaxCvvLength(u);E(i.slice(0,o))},[u]),F=t.useCallback(c=>{z(c.target.value)},[]),l=a.cn("bear-bg-transparent bear-border-0 bear-outline-none bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-400 dark:placeholder:bear-text-zinc-500",N.CREDIT_INPUT_SIZE_CLASSES[O]),d=a.cn("bear-flex bear-items-center bear-rounded-lg bear-border bear-transition-colors",N.CREDIT_INPUT_VARIANT_CLASSES[V],h||Object.keys(g).length>0?"bear-border-red-500":"focus-within:bear-border-pink-500",n&&"bear-opacity-50 bear-cursor-not-allowed");return e.jsxs("div",{className:a.cn("Bear-CreditInput",Y),"data-testid":$,children:[_&&e.jsxs("label",{className:"Bear-CreditInput__label bear-block bear-text-sm bear-font-medium bear-text-zinc-700 dark:bear-text-zinc-300 bear-mb-1.5",children:[_,W&&e.jsx("span",{className:"bear-text-red-500 bear-ml-0.5",children:"*"})]}),U==="single"?e.jsxs("div",{className:a.cn("Bear-CreditInput__single bear-flex bear-flex-wrap bear-items-center bear-gap-2 sm:bear-gap-0",d),children:[e.jsxs("div",{className:"Bear-CreditInput__row-main bear-flex bear-min-w-0 bear-flex-1 bear-basis-full sm:bear-basis-0 sm:bear-flex-1 bear-items-center",children:[e.jsx("div",{className:"Bear-CreditInput__icon bear-pl-3 bear-pr-1 bear-shrink-0",children:S??q[u]}),e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-number",value:p,onChange:v,placeholder:s.cardNumberPlaceholder,disabled:n,className:a.cn("Bear-CreditInput__number bear-min-w-0 bear-flex-1",l)})]}),e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-exp",value:m,onChange:R,placeholder:s.expiryPlaceholder,disabled:n,className:a.cn("Bear-CreditInput__expiry bear-w-20 sm:bear-w-16 bear-text-center bear-shrink-0",l)}),e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-csc",value:C,onChange:D,placeholder:s.cvvPlaceholder,disabled:n,className:a.cn("Bear-CreditInput__cvv bear-w-14 sm:bear-w-12 bear-text-center bear-pr-3 bear-shrink-0",l)})]}):e.jsxs("div",{className:"Bear-CreditInput__split bear-space-y-3",children:[e.jsxs("div",{className:d,children:[e.jsx("div",{className:"Bear-CreditInput__icon bear-pl-3 bear-pr-1",children:S??q[u]}),e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-number",value:p,onChange:v,placeholder:s.cardNumberPlaceholder,disabled:n,className:a.cn("Bear-CreditInput__number bear-flex-1",l)})]}),e.jsxs("div",{className:"bear-flex bear-gap-3",children:[e.jsx("div",{className:a.cn(d,"bear-flex-1"),children:e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-exp",value:m,onChange:R,placeholder:s.expiryPlaceholder,disabled:n,className:a.cn("Bear-CreditInput__expiry bear-w-full",l)})}),e.jsx("div",{className:a.cn(d,"bear-w-24"),children:e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-csc",value:C,onChange:D,placeholder:s.cvvPlaceholder,disabled:n,className:a.cn("Bear-CreditInput__cvv bear-w-full bear-text-center",l)})})]}),f&&e.jsx("div",{className:d,children:e.jsx("input",{type:"text",autoComplete:"cc-name",value:j,onChange:F,placeholder:s.namePlaceholder,disabled:n,className:a.cn("Bear-CreditInput__name bear-w-full",l)})})]}),h&&e.jsx("p",{className:"Bear-CreditInput__error bear-mt-1 bear-text-xs bear-text-red-400",children:h}),Object.values(g).map((c,i)=>e.jsx("p",{className:"Bear-CreditInput__error bear-mt-1 bear-text-xs bear-text-red-400",children:c},i)),I&&!h&&Object.keys(g).length===0&&e.jsx("p",{className:"Bear-CreditInput__helper bear-mt-1 bear-text-xs bear-text-zinc-500 dark:bear-text-zinc-400",children:I})]})};exports.CreditInput=H;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as d, useMemo as K, useEffect as U, useCallback as
|
|
3
|
-
import { cn as
|
|
1
|
+
import { jsxs as t, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useMemo as K, useEffect as U, useCallback as m } from "react";
|
|
3
|
+
import { cn as a } from "../../utils/cn.js";
|
|
4
4
|
import { CREDIT_INPUT_DEFAULT_TRANSLATIONS as Q, CREDIT_INPUT_SIZE_CLASSES as ee, CREDIT_INPUT_VARIANT_CLASSES as re } from "./CreditInput.const.js";
|
|
5
|
-
import { createCreditCardValue as te, detectCardType as ae, getMaxCardLength as ce, formatCardNumber as ie, formatExpiry as ne, getMaxCvvLength as
|
|
5
|
+
import { createCreditCardValue as te, detectCardType as ae, getMaxCardLength as ce, formatCardNumber as ie, formatExpiry as ne, getMaxCvvLength as se } from "./CreditInput.utils.js";
|
|
6
6
|
const V = {
|
|
7
7
|
visa: /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "currentColor", children: /* @__PURE__ */ r("path", { d: "M9.5 8.5l-1.8 7h-1.4l1.8-7h1.4zm6.5 4.5c0-1.1-.9-1.5-1.8-1.9-.6-.2-1-.4-1-.7 0-.2.2-.5.7-.5.5 0 .9.1 1.2.3l.2-1.2c-.3-.1-.9-.3-1.6-.3-1.7 0-2.9.9-2.9 2.2 0 1 .9 1.5 1.5 1.8.7.3 1 .5 1 .8 0 .4-.6.6-1.1.6-.6 0-1.1-.1-1.5-.3l-.2 1.2c.4.2 1 .3 1.7.3 1.8 0 2.9-.9 2.9-2.3h-.1zm2.7-4.5l-1.4 7h-1.3l.1-.5c-.4.4-.9.6-1.5.6-1.3 0-2.2-1.1-2.2-2.5 0-1.7 1.2-3.1 2.9-3.1.5 0 1 .1 1.4.4l.1-.4h1.3l-.4 2.5zm-2.1 2.3c0-.9-.5-1.5-1.2-1.5-.9 0-1.6.9-1.6 1.9 0 .8.5 1.4 1.2 1.4.9 0 1.6-.8 1.6-1.8z" }) }),
|
|
8
|
-
mastercard: /* @__PURE__ */
|
|
8
|
+
mastercard: /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "currentColor", children: [
|
|
9
9
|
/* @__PURE__ */ r("circle", { cx: "9", cy: "12", r: "5", opacity: ".8", fill: "#eb001b" }),
|
|
10
10
|
/* @__PURE__ */ r("circle", { cx: "15", cy: "12", r: "5", opacity: ".8", fill: "#f79e1b" })
|
|
11
11
|
] }),
|
|
12
|
-
amex: /* @__PURE__ */
|
|
12
|
+
amex: /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "#2e77bc", children: [
|
|
13
13
|
/* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }),
|
|
14
14
|
/* @__PURE__ */ r("text", { x: "12", y: "14", textAnchor: "middle", fontSize: "6", fill: "white", fontWeight: "bold", children: "AMEX" })
|
|
15
15
|
] }),
|
|
16
|
-
discover: /* @__PURE__ */
|
|
16
|
+
discover: /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "#ff6600", children: [
|
|
17
17
|
/* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }),
|
|
18
18
|
/* @__PURE__ */ r("circle", { cx: "15", cy: "12", r: "3", fill: "white" })
|
|
19
19
|
] }),
|
|
20
|
-
diners: /* @__PURE__ */
|
|
20
|
+
diners: /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "#0079be", children: [
|
|
21
21
|
/* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }),
|
|
22
22
|
/* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "4", fill: "white" })
|
|
23
23
|
] }),
|
|
24
|
-
jcb: /* @__PURE__ */
|
|
24
|
+
jcb: /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", children: [
|
|
25
25
|
/* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2", fill: "#0e4c96" }),
|
|
26
26
|
/* @__PURE__ */ r("text", { x: "12", y: "14", textAnchor: "middle", fontSize: "5", fill: "white", fontWeight: "bold", children: "JCB" })
|
|
27
27
|
] }),
|
|
28
|
-
unionpay: /* @__PURE__ */
|
|
28
|
+
unionpay: /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", children: [
|
|
29
29
|
/* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2", fill: "#d9222a" }),
|
|
30
30
|
/* @__PURE__ */ r("text", { x: "12", y: "14", textAnchor: "middle", fontSize: "4", fill: "white", fontWeight: "bold", children: "UnionPay" })
|
|
31
31
|
] }),
|
|
32
|
-
unknown: /* @__PURE__ */
|
|
32
|
+
unknown: /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
33
33
|
/* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }),
|
|
34
34
|
/* @__PURE__ */ r("line", { x1: "2", y1: "10", x2: "22", y2: "10" })
|
|
35
35
|
] })
|
|
36
|
-
},
|
|
36
|
+
}, pe = ({
|
|
37
37
|
value: e,
|
|
38
|
-
onChange:
|
|
38
|
+
onChange: h,
|
|
39
39
|
mode: W = "single",
|
|
40
40
|
showName: g = !1,
|
|
41
41
|
size: Y = "md",
|
|
@@ -44,80 +44,82 @@ const V = {
|
|
|
44
44
|
required: O = !1,
|
|
45
45
|
label: B,
|
|
46
46
|
helperText: I,
|
|
47
|
-
error:
|
|
48
|
-
acceptedCards:
|
|
49
|
-
validateOnInput:
|
|
47
|
+
error: p,
|
|
48
|
+
acceptedCards: w,
|
|
49
|
+
validateOnInput: k = !0,
|
|
50
50
|
className: F,
|
|
51
51
|
testId: J,
|
|
52
|
-
translations:
|
|
52
|
+
translations: M,
|
|
53
53
|
icon: T
|
|
54
54
|
}) => {
|
|
55
55
|
const [x, E] = d((e == null ? void 0 : e.number) || ""), [f, S] = d(
|
|
56
56
|
e != null && e.expiryMonth && (e != null && e.expiryYear) ? `${e.expiryMonth}/${e.expiryYear}` : ""
|
|
57
|
-
), [C, z] = d((e == null ? void 0 : e.cvv) || ""), [
|
|
57
|
+
), [C, z] = d((e == null ? void 0 : e.cvv) || ""), [N, A] = d((e == null ? void 0 : e.name) || ""), [y, P] = d("unknown"), [_, L] = d({}), i = K(() => ({
|
|
58
58
|
...Q,
|
|
59
|
-
...
|
|
60
|
-
}), [
|
|
59
|
+
...M
|
|
60
|
+
}), [M]);
|
|
61
61
|
U(() => {
|
|
62
62
|
(e == null ? void 0 : e.number) !== void 0 && E(e.number), e != null && e.expiryMonth && (e != null && e.expiryYear) && S(`${e.expiryMonth}/${e.expiryYear}`), (e == null ? void 0 : e.cvv) !== void 0 && z(e.cvv), (e == null ? void 0 : e.name) !== void 0 && A(e.name), (e == null ? void 0 : e.cardType) !== void 0 && P(e.cardType);
|
|
63
63
|
}, [e]);
|
|
64
|
-
const j =
|
|
65
|
-
const c = te(x, f, C, g ?
|
|
66
|
-
|
|
67
|
-
}, [x, f, C,
|
|
64
|
+
const j = m(() => {
|
|
65
|
+
const c = te(x, f, C, g ? N : void 0);
|
|
66
|
+
h == null || h(c);
|
|
67
|
+
}, [x, f, C, N, g, h]);
|
|
68
68
|
U(() => {
|
|
69
69
|
j();
|
|
70
70
|
}, [j]);
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
P(
|
|
74
|
-
const Z = ce(
|
|
75
|
-
E(G),
|
|
76
|
-
const { number:
|
|
71
|
+
const v = m((c) => {
|
|
72
|
+
const s = c.target.value.replace(/\D/g, ""), o = ae(s);
|
|
73
|
+
P(o);
|
|
74
|
+
const Z = ce(o), q = s.slice(0, Z), G = ie(q, o);
|
|
75
|
+
E(G), k && w && !w.includes(o) && o !== "unknown" ? L((u) => ({ ...u, number: i.invalidCard })) : L((u) => {
|
|
76
|
+
const { number: le, ...H } = u;
|
|
77
77
|
return H;
|
|
78
78
|
});
|
|
79
|
-
}, [
|
|
80
|
-
const
|
|
81
|
-
S(
|
|
82
|
-
}, []), R =
|
|
83
|
-
const
|
|
84
|
-
z(
|
|
85
|
-
}, [y]), X =
|
|
79
|
+
}, [w, k, i.invalidCard]), D = m((c) => {
|
|
80
|
+
const s = ne(c.target.value);
|
|
81
|
+
S(s);
|
|
82
|
+
}, []), R = m((c) => {
|
|
83
|
+
const s = c.target.value.replace(/\D/g, ""), o = se(y);
|
|
84
|
+
z(s.slice(0, o));
|
|
85
|
+
}, [y]), X = m((c) => {
|
|
86
86
|
A(c.target.value);
|
|
87
|
-
}, []),
|
|
87
|
+
}, []), l = a(
|
|
88
88
|
"bear-bg-transparent bear-border-0 bear-outline-none bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-400 dark:placeholder:bear-text-zinc-500",
|
|
89
89
|
ee[Y]
|
|
90
|
-
),
|
|
90
|
+
), b = a(
|
|
91
91
|
"bear-flex bear-items-center bear-rounded-lg bear-border bear-transition-colors",
|
|
92
92
|
re[$],
|
|
93
|
-
|
|
93
|
+
p || Object.keys(_).length > 0 ? "bear-border-red-500" : "focus-within:bear-border-pink-500",
|
|
94
94
|
n && "bear-opacity-50 bear-cursor-not-allowed"
|
|
95
95
|
);
|
|
96
|
-
return /* @__PURE__ */
|
|
96
|
+
return /* @__PURE__ */ t(
|
|
97
97
|
"div",
|
|
98
98
|
{
|
|
99
|
-
className:
|
|
99
|
+
className: a("Bear-CreditInput", F),
|
|
100
100
|
"data-testid": J,
|
|
101
101
|
children: [
|
|
102
|
-
B && /* @__PURE__ */
|
|
102
|
+
B && /* @__PURE__ */ t("label", { className: "Bear-CreditInput__label bear-block bear-text-sm bear-font-medium bear-text-zinc-700 dark:bear-text-zinc-300 bear-mb-1.5", children: [
|
|
103
103
|
B,
|
|
104
104
|
O && /* @__PURE__ */ r("span", { className: "bear-text-red-500 bear-ml-0.5", children: "*" })
|
|
105
105
|
] }),
|
|
106
|
-
W === "single" ? /* @__PURE__ */
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
W === "single" ? /* @__PURE__ */ t("div", { className: a("Bear-CreditInput__single bear-flex bear-flex-wrap bear-items-center bear-gap-2 sm:bear-gap-0", b), children: [
|
|
107
|
+
/* @__PURE__ */ t("div", { className: "Bear-CreditInput__row-main bear-flex bear-min-w-0 bear-flex-1 bear-basis-full sm:bear-basis-0 sm:bear-flex-1 bear-items-center", children: [
|
|
108
|
+
/* @__PURE__ */ r("div", { className: "Bear-CreditInput__icon bear-pl-3 bear-pr-1 bear-shrink-0", children: T ?? V[y] }),
|
|
109
|
+
/* @__PURE__ */ r(
|
|
110
|
+
"input",
|
|
111
|
+
{
|
|
112
|
+
type: "text",
|
|
113
|
+
inputMode: "numeric",
|
|
114
|
+
autoComplete: "cc-number",
|
|
115
|
+
value: x,
|
|
116
|
+
onChange: v,
|
|
117
|
+
placeholder: i.cardNumberPlaceholder,
|
|
118
|
+
disabled: n,
|
|
119
|
+
className: a("Bear-CreditInput__number bear-min-w-0 bear-flex-1", l)
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] }),
|
|
121
123
|
/* @__PURE__ */ r(
|
|
122
124
|
"input",
|
|
123
125
|
{
|
|
@@ -125,10 +127,10 @@ const V = {
|
|
|
125
127
|
inputMode: "numeric",
|
|
126
128
|
autoComplete: "cc-exp",
|
|
127
129
|
value: f,
|
|
128
|
-
onChange:
|
|
130
|
+
onChange: D,
|
|
129
131
|
placeholder: i.expiryPlaceholder,
|
|
130
132
|
disabled: n,
|
|
131
|
-
className:
|
|
133
|
+
className: a("Bear-CreditInput__expiry bear-w-20 sm:bear-w-16 bear-text-center bear-shrink-0", l)
|
|
132
134
|
}
|
|
133
135
|
),
|
|
134
136
|
/* @__PURE__ */ r(
|
|
@@ -141,11 +143,11 @@ const V = {
|
|
|
141
143
|
onChange: R,
|
|
142
144
|
placeholder: i.cvvPlaceholder,
|
|
143
145
|
disabled: n,
|
|
144
|
-
className:
|
|
146
|
+
className: a("Bear-CreditInput__cvv bear-w-14 sm:bear-w-12 bear-text-center bear-pr-3 bear-shrink-0", l)
|
|
145
147
|
}
|
|
146
148
|
)
|
|
147
|
-
] }) : /* @__PURE__ */
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
+
] }) : /* @__PURE__ */ t("div", { className: "Bear-CreditInput__split bear-space-y-3", children: [
|
|
150
|
+
/* @__PURE__ */ t("div", { className: b, children: [
|
|
149
151
|
/* @__PURE__ */ r("div", { className: "Bear-CreditInput__icon bear-pl-3 bear-pr-1", children: T ?? V[y] }),
|
|
150
152
|
/* @__PURE__ */ r(
|
|
151
153
|
"input",
|
|
@@ -154,28 +156,28 @@ const V = {
|
|
|
154
156
|
inputMode: "numeric",
|
|
155
157
|
autoComplete: "cc-number",
|
|
156
158
|
value: x,
|
|
157
|
-
onChange:
|
|
159
|
+
onChange: v,
|
|
158
160
|
placeholder: i.cardNumberPlaceholder,
|
|
159
161
|
disabled: n,
|
|
160
|
-
className:
|
|
162
|
+
className: a("Bear-CreditInput__number bear-flex-1", l)
|
|
161
163
|
}
|
|
162
164
|
)
|
|
163
165
|
] }),
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
/* @__PURE__ */ r("div", { className:
|
|
166
|
+
/* @__PURE__ */ t("div", { className: "bear-flex bear-gap-3", children: [
|
|
167
|
+
/* @__PURE__ */ r("div", { className: a(b, "bear-flex-1"), children: /* @__PURE__ */ r(
|
|
166
168
|
"input",
|
|
167
169
|
{
|
|
168
170
|
type: "text",
|
|
169
171
|
inputMode: "numeric",
|
|
170
172
|
autoComplete: "cc-exp",
|
|
171
173
|
value: f,
|
|
172
|
-
onChange:
|
|
174
|
+
onChange: D,
|
|
173
175
|
placeholder: i.expiryPlaceholder,
|
|
174
176
|
disabled: n,
|
|
175
|
-
className:
|
|
177
|
+
className: a("Bear-CreditInput__expiry bear-w-full", l)
|
|
176
178
|
}
|
|
177
179
|
) }),
|
|
178
|
-
/* @__PURE__ */ r("div", { className:
|
|
180
|
+
/* @__PURE__ */ r("div", { className: a(b, "bear-w-24"), children: /* @__PURE__ */ r(
|
|
179
181
|
"input",
|
|
180
182
|
{
|
|
181
183
|
type: "text",
|
|
@@ -185,30 +187,30 @@ const V = {
|
|
|
185
187
|
onChange: R,
|
|
186
188
|
placeholder: i.cvvPlaceholder,
|
|
187
189
|
disabled: n,
|
|
188
|
-
className:
|
|
190
|
+
className: a("Bear-CreditInput__cvv bear-w-full bear-text-center", l)
|
|
189
191
|
}
|
|
190
192
|
) })
|
|
191
193
|
] }),
|
|
192
|
-
g && /* @__PURE__ */ r("div", { className:
|
|
194
|
+
g && /* @__PURE__ */ r("div", { className: b, children: /* @__PURE__ */ r(
|
|
193
195
|
"input",
|
|
194
196
|
{
|
|
195
197
|
type: "text",
|
|
196
198
|
autoComplete: "cc-name",
|
|
197
|
-
value:
|
|
199
|
+
value: N,
|
|
198
200
|
onChange: X,
|
|
199
201
|
placeholder: i.namePlaceholder,
|
|
200
202
|
disabled: n,
|
|
201
|
-
className:
|
|
203
|
+
className: a("Bear-CreditInput__name bear-w-full", l)
|
|
202
204
|
}
|
|
203
205
|
) })
|
|
204
206
|
] }),
|
|
205
|
-
|
|
206
|
-
Object.values(_).map((c,
|
|
207
|
-
I && !
|
|
207
|
+
p && /* @__PURE__ */ r("p", { className: "Bear-CreditInput__error bear-mt-1 bear-text-xs bear-text-red-400", children: p }),
|
|
208
|
+
Object.values(_).map((c, s) => /* @__PURE__ */ r("p", { className: "Bear-CreditInput__error bear-mt-1 bear-text-xs bear-text-red-400", children: c }, s)),
|
|
209
|
+
I && !p && Object.keys(_).length === 0 && /* @__PURE__ */ r("p", { className: "Bear-CreditInput__helper bear-mt-1 bear-text-xs bear-text-zinc-500 dark:bear-text-zinc-400", children: I })
|
|
208
210
|
]
|
|
209
211
|
}
|
|
210
212
|
);
|
|
211
213
|
};
|
|
212
214
|
export {
|
|
213
|
-
|
|
215
|
+
pe as CreditInput
|
|
214
216
|
};
|
|
@@ -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"),s=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),te=require("react-dom"),x=require("../../utils/cn.cjs"),r=require("./DateRangePicker.const.cjs"),u=require("./DateRangePicker.utils.cjs"),I=({year:L,month:b,range:a,onDayClick:k,onNav:A,minDate:S,maxDate:v})=>{const C=u.getCalendarDays(L,b),p=new Date;return p.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:()=>A(-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[b]," ",L]}),e.jsx("button",{type:"button",onClick:()=>A(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 f=S&&n<S||v&&n>v,i=u.isSameDay(n,a.start)||u.isSameDay(n,a.end),m=u.isInRange(n,a.start,a.end),D=u.isSameDay(n,p);return e.jsx("button",{type:"button",disabled:!!f,onClick:()=>k(n),className:x.cn(r.DAY_BASE_CLASSES,f?r.DAY_DISABLED_CLASSES:r.DAY_HOVER_CLASSES,i&&r.DAY_SELECTED_CLASSES,!i&&m&&r.DAY_IN_RANGE_CLASSES,!i&&!m&&D&&r.DAY_TODAY_CLASSES,!i&&!m&&!f&&"bear-text-gray-700 dark:bear-text-zinc-300"),children:n.getDate()},n.getTime())})})]})},re=L=>{const{value:b,onChange:a,label:k,placeholder:A="Select date range",disabled:S=!1,clearable:v=!0,minDate:C,maxDate:p,presets:n,showPresets:_=!0,size:f="md",error:i,helperText:m,className:D,testId:q,...V}=L,[N,R]=s.useState(!1),[M,W]=s.useState({top:0,left:0}),[c,E]=s.useState(b??{start:null,end:null}),[T,j]=s.useState("start"),B=s.useRef(null),y=s.useRef(null),Y=s.useRef(null),z=new Date,[h,$]=s.useState(z.getMonth()),[g,G]=s.useState(z.getFullYear()),F=h===11?0:h+1,Z=h===11?g+1:g;s.useEffect(()=>{b&&E(b)},[b]),s.useEffect(()=>{if(!N||!y.current)return;const t=8,o=420,l=()=>{const d=y.current.getBoundingClientRect(),w=window.innerHeight;let P=w-d.bottom<o&&d.top>o?d.top-o-t:d.bottom+t;P=Math.max(8,Math.min(P,w-o-8));const X=Math.min(640,window.innerWidth-16);let ee=Math.max(8,Math.min(d.left,window.innerWidth-X-8));W({top:P,left:ee})};return l(),window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0)}},[N]),s.useEffect(()=>{const t=o=>{var d,w;const l=o.target;(d=B.current)!=null&&d.contains(l)||(w=Y.current)!=null&&w.contains(l)||R(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const H=s.useCallback(t=>{if(T==="start")E({start:t,end:null}),j("end");else{const o=t>=(c.start??t)?{start:c.start,end:t}:{start:t,end:c.start};E(o),j("start"),a==null||a(o)}},[T,c.start,a]),J=s.useCallback(t=>{E(t),a==null||a(t),R(!1),j("start")},[a]),K=s.useCallback(()=>{const t={start:null,end:null};E(t),a==null||a(t),j("start")},[a]),Q=s.useCallback(t=>{let o=h+t,l=g;o<0&&(o=11,l--),o>11&&(o=0,l++),$(o),G(l)},[h,g]),O=n??(_?r.getDefaultPresets():[]),U=c.start?`${u.formatDate(c.start)}${c.end?` – ${u.formatDate(c.end)}`:""}`:A;return e.jsxs("div",{ref:B,className:x.cn(r.ROOT_CLASSES,D),"data-testid":q,...V,children:[k&&e.jsx("label",{className:r.LABEL_CLASSES,children:k}),e.jsxs("button",{ref:y,type:"button",disabled:S,onClick:()=>!S&&R(!N),className:x.cn(r.TRIGGER_CLASSES,r.SIZE_CLASSES[f],S&&"bear-opacity-50 bear-cursor-not-allowed"),children:[e.jsx("span",{className:x.cn(!c.start&&"bear-text-gray-400 dark:bear-text-zinc-500"),children:U}),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"&&te.createPortal(e.jsx("div",{ref:Y,"data-bear-daterangepicker-dropdown":!0,className:x.cn("bear-fixed bear-z-[10000] bear-max-w-[calc(100vw-16px)] 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 bear-overflow-x-auto"),style:{top:M.top,left:M.left},children:e.jsxs("div",{className:"bear-flex bear-gap-4",children:[O.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:[O.map(t=>e.jsx("button",{type:"button",onClick:()=>J(t.range()),className:r.PRESET_BTN_CLASSES,children:t.label},t.label)),v&&c.start&&e.jsx("button",{type:"button",onClick:K,className:x.cn(r.PRESET_BTN_CLASSES,"bear-text-red-500"),children:"Clear"})]}),e.jsx(I,{year:g,month:h,range:c,onDayClick:H,onNav:Q,minDate:C,maxDate:p}),e.jsx(I,{year:Z,month:F,range:c,onDayClick:H,onNav:()=>{},minDate:C,maxDate:p})]})}),document.body),i&&e.jsx("p",{className:r.ERROR_CLASSES,children:i}),!i&&m&&e.jsx("p",{className:r.HELPER_CLASSES,children:m})]})};exports.DateRangePicker=re;
|