@forgedevstack/bear 1.2.0 → 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.
Files changed (178) hide show
  1. package/README.md +4 -0
  2. package/dist/components/Autocomplete/Autocomplete.cjs +1 -1
  3. package/dist/components/Autocomplete/Autocomplete.const.cjs +1 -0
  4. package/dist/components/Autocomplete/Autocomplete.const.d.ts +1 -0
  5. package/dist/components/Autocomplete/Autocomplete.const.js +4 -0
  6. package/dist/components/Autocomplete/Autocomplete.js +110 -72
  7. package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
  8. package/dist/components/BottomSheet/BottomSheet.js +74 -53
  9. package/dist/components/BottomSheet/BottomSheet.types.d.ts +2 -0
  10. package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
  11. package/dist/components/Breadcrumbs/Breadcrumbs.js +126 -46
  12. package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +11 -4
  13. package/dist/components/Breadcrumbs/index.d.ts +1 -1
  14. package/dist/components/Cascader/Cascader.cjs +1 -1
  15. package/dist/components/Cascader/Cascader.const.cjs +1 -1
  16. package/dist/components/Cascader/Cascader.const.d.ts +1 -1
  17. package/dist/components/Cascader/Cascader.const.js +1 -1
  18. package/dist/components/Cascader/Cascader.js +109 -146
  19. package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.cjs +1 -0
  20. package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.d.ts +3 -0
  21. package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.js +50 -0
  22. package/dist/components/Cascader/components/CascaderPanel/index.d.ts +1 -0
  23. package/dist/components/Chart/BarChart.cjs +1 -0
  24. package/dist/components/Chart/BarChart.d.ts +3 -0
  25. package/dist/components/Chart/BarChart.js +65 -0
  26. package/dist/components/Chart/Chart.cjs +1 -1
  27. package/dist/components/Chart/Chart.const.cjs +1 -1
  28. package/dist/components/Chart/Chart.const.d.ts +7 -0
  29. package/dist/components/Chart/Chart.const.js +12 -2
  30. package/dist/components/Chart/Chart.d.ts +1 -13
  31. package/dist/components/Chart/Chart.js +18 -204
  32. package/dist/components/Chart/Chart.types.d.ts +7 -1
  33. package/dist/components/Chart/LineChart.cjs +1 -0
  34. package/dist/components/Chart/LineChart.d.ts +3 -0
  35. package/dist/components/Chart/LineChart.js +73 -0
  36. package/dist/components/Chart/PieChart.cjs +1 -0
  37. package/dist/components/Chart/PieChart.d.ts +3 -0
  38. package/dist/components/Chart/PieChart.js +110 -0
  39. package/dist/components/Chart/index.d.ts +4 -1
  40. package/dist/components/ColorPicker/ColorPicker.cjs +1 -1
  41. package/dist/components/ColorPicker/ColorPicker.const.cjs +1 -1
  42. package/dist/components/ColorPicker/ColorPicker.const.d.ts +4 -2
  43. package/dist/components/ColorPicker/ColorPicker.const.js +8 -6
  44. package/dist/components/ColorPicker/ColorPicker.js +135 -73
  45. package/dist/components/ColorPicker/ColorPicker.utils.cjs +1 -0
  46. package/dist/components/ColorPicker/ColorPicker.utils.d.ts +17 -0
  47. package/dist/components/ColorPicker/ColorPicker.utils.js +43 -0
  48. package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -1
  49. package/dist/components/CountdownTimer/CountdownTimer.const.cjs +1 -1
  50. package/dist/components/CountdownTimer/CountdownTimer.const.d.ts +2 -0
  51. package/dist/components/CountdownTimer/CountdownTimer.const.js +29 -17
  52. package/dist/components/CountdownTimer/CountdownTimer.js +91 -61
  53. package/dist/components/CountdownTimer/CountdownTimer.types.d.ts +11 -2
  54. package/dist/components/CreditInput/CreditInput.cjs +1 -1
  55. package/dist/components/CreditInput/CreditInput.js +80 -78
  56. package/dist/components/DateRangePicker/DateRangePicker.cjs +1 -1
  57. package/dist/components/DateRangePicker/DateRangePicker.js +89 -84
  58. package/dist/components/DiffSquares/DiffSquares.cjs +1 -0
  59. package/dist/components/DiffSquares/DiffSquares.const.cjs +1 -0
  60. package/dist/components/DiffSquares/DiffSquares.const.d.ts +3 -0
  61. package/dist/components/DiffSquares/DiffSquares.const.js +6 -0
  62. package/dist/components/DiffSquares/DiffSquares.d.ts +3 -0
  63. package/dist/components/DiffSquares/DiffSquares.js +70 -0
  64. package/dist/components/DiffSquares/DiffSquares.types.d.ts +23 -0
  65. package/dist/components/DiffSquares/DiffSquares.utils.cjs +1 -0
  66. package/dist/components/DiffSquares/DiffSquares.utils.d.ts +3 -0
  67. package/dist/components/DiffSquares/DiffSquares.utils.js +12 -0
  68. package/dist/components/DiffSquares/index.d.ts +2 -0
  69. package/dist/components/Drawer/Drawer.cjs +1 -1
  70. package/dist/components/Drawer/Drawer.js +41 -41
  71. package/dist/components/Dropdown/Dropdown.cjs +1 -1
  72. package/dist/components/Dropdown/Dropdown.const.cjs +1 -0
  73. package/dist/components/Dropdown/Dropdown.const.d.ts +7 -0
  74. package/dist/components/Dropdown/Dropdown.const.js +10 -0
  75. package/dist/components/Dropdown/Dropdown.d.ts +0 -1
  76. package/dist/components/Dropdown/Dropdown.js +102 -92
  77. package/dist/components/Dropdown/Dropdown.types.d.ts +2 -0
  78. package/dist/components/Gauge/Gauge.cjs +1 -1
  79. package/dist/components/Gauge/Gauge.js +61 -50
  80. package/dist/components/Gauge/Gauge.types.d.ts +2 -0
  81. package/dist/components/HoverCard/HoverCard.cjs +6 -6
  82. package/dist/components/HoverCard/HoverCard.js +72 -54
  83. package/dist/components/Icon/icons/status.js +1 -1
  84. package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
  85. package/dist/components/MentionsInput/MentionsInput.js +106 -83
  86. package/dist/components/Menu/Menu.cjs +1 -1
  87. package/dist/components/Menu/Menu.js +91 -80
  88. package/dist/components/Modal/Modal.cjs +1 -1
  89. package/dist/components/Modal/Modal.const.cjs +1 -1
  90. package/dist/components/Modal/Modal.const.d.ts +1 -1
  91. package/dist/components/Modal/Modal.const.js +1 -1
  92. package/dist/components/Modal/Modal.js +50 -44
  93. package/dist/components/Modal/Modal.types.d.ts +6 -0
  94. package/dist/components/MultiSelect/MultiSelect.cjs +1 -1
  95. package/dist/components/MultiSelect/MultiSelect.js +123 -78
  96. package/dist/components/NavigableSelect/NavigableSelect.cjs +1 -1
  97. package/dist/components/NavigableSelect/NavigableSelect.const.cjs +1 -1
  98. package/dist/components/NavigableSelect/NavigableSelect.const.d.ts +1 -1
  99. package/dist/components/NavigableSelect/NavigableSelect.const.js +1 -1
  100. package/dist/components/NavigableSelect/NavigableSelect.js +167 -143
  101. package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -1
  102. package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -1
  103. package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +1 -1
  104. package/dist/components/NotificationCenter/NotificationCenter.const.js +1 -1
  105. package/dist/components/NotificationCenter/NotificationCenter.js +87 -81
  106. package/dist/components/OTPInput/OTPInput.cjs +1 -1
  107. package/dist/components/OTPInput/OTPInput.const.cjs +1 -0
  108. package/dist/components/OTPInput/OTPInput.const.d.ts +6 -0
  109. package/dist/components/OTPInput/OTPInput.const.js +14 -0
  110. package/dist/components/OTPInput/OTPInput.js +99 -65
  111. package/dist/components/OTPInput/OTPInput.types.d.ts +7 -0
  112. package/dist/components/PhoneInput/PhoneInput.cjs +1 -1
  113. package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -1
  114. package/dist/components/PhoneInput/PhoneInput.const.d.ts +1 -1
  115. package/dist/components/PhoneInput/PhoneInput.const.js +1 -1
  116. package/dist/components/PhoneInput/PhoneInput.js +88 -83
  117. package/dist/components/Popconfirm/Popconfirm.cjs +1 -1
  118. package/dist/components/Popconfirm/Popconfirm.const.cjs +1 -1
  119. package/dist/components/Popconfirm/Popconfirm.const.d.ts +1 -3
  120. package/dist/components/Popconfirm/Popconfirm.const.js +12 -18
  121. package/dist/components/Popconfirm/Popconfirm.js +71 -51
  122. package/dist/components/Popover/Popover.cjs +1 -1
  123. package/dist/components/Popover/Popover.js +36 -31
  124. package/dist/components/Portal/Portal.cjs +1 -1
  125. package/dist/components/Portal/Portal.d.ts +0 -3
  126. package/dist/components/Portal/Portal.js +4 -10
  127. package/dist/components/Select/Select.cjs +1 -1
  128. package/dist/components/Select/Select.js +71 -51
  129. package/dist/components/Stepper/Stepper.cjs +1 -1
  130. package/dist/components/Stepper/Stepper.const.cjs +1 -1
  131. package/dist/components/Stepper/Stepper.const.d.ts +3 -2
  132. package/dist/components/Stepper/Stepper.const.js +15 -14
  133. package/dist/components/Stepper/Stepper.d.ts +0 -7
  134. package/dist/components/Stepper/Stepper.js +164 -117
  135. package/dist/components/Stepper/Stepper.types.d.ts +3 -0
  136. package/dist/components/Tabs/TabList.cjs +1 -1
  137. package/dist/components/Tabs/TabList.js +72 -57
  138. package/dist/components/Tabs/Tabs.types.d.ts +4 -2
  139. package/dist/components/Tabs/index.d.ts +2 -2
  140. package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -1
  141. package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +26 -26
  142. package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -1
  143. package/dist/components/TimePicker/helpers/ClockFaceSvg.js +17 -17
  144. package/dist/components/Toast/Toast.cjs +1 -1
  145. package/dist/components/Toast/Toast.js +86 -82
  146. package/dist/components/Toast/Toast.types.d.ts +2 -0
  147. package/dist/components/Tooltip/Tooltip.cjs +1 -1
  148. package/dist/components/Tooltip/Tooltip.js +52 -44
  149. package/dist/components/TreeSelect/TreeSelect.cjs +1 -1
  150. package/dist/components/TreeSelect/TreeSelect.const.cjs +1 -1
  151. package/dist/components/TreeSelect/TreeSelect.const.d.ts +1 -1
  152. package/dist/components/TreeSelect/TreeSelect.const.js +3 -3
  153. package/dist/components/TreeSelect/TreeSelect.js +120 -88
  154. package/dist/components/Watermark/Watermark.cjs +1 -1
  155. package/dist/components/Watermark/Watermark.const.cjs +1 -1
  156. package/dist/components/Watermark/Watermark.const.d.ts +6 -3
  157. package/dist/components/Watermark/Watermark.const.js +13 -11
  158. package/dist/components/Watermark/Watermark.js +87 -61
  159. package/dist/components/Watermark/Watermark.types.d.ts +2 -0
  160. package/dist/components/index.cjs +1 -1
  161. package/dist/components/index.d.ts +5 -3
  162. package/dist/components/index.js +292 -286
  163. package/dist/hooks/index.cjs +1 -1
  164. package/dist/hooks/index.d.ts +1 -1
  165. package/dist/hooks/index.js +55 -54
  166. package/dist/hooks/useClickOutside.cjs +1 -1
  167. package/dist/hooks/useClickOutside.d.ts +4 -11
  168. package/dist/hooks/useClickOutside.js +26 -7
  169. package/dist/index.cjs +1 -1
  170. package/dist/index.js +386 -379
  171. package/dist/styles/_effects.css +17 -0
  172. package/dist/styles.css +1 -1
  173. package/dist/utils/maxVisible.utils.cjs +1 -0
  174. package/dist/utils/maxVisible.utils.d.ts +12 -0
  175. package/dist/utils/maxVisible.utils.js +15 -0
  176. package/package.json +1 -1
  177. package/dist/components/HoverCard/HoverCard.utils.cjs +0 -1
  178. 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"),c=require("../../utils/cn.cjs"),w=require("./CreditInput.const.cjs"),d=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:h,mode:U="single",showName:y=!1,size:O="md",variant:V="default",disabled:n=!1,required:W=!1,label:_,helperText:I,error:b,acceptedCards:f,validateOnInput:B=!0,className:Y,testId:$,translations:S,icon:k})=>{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(()=>({...w.CREDIT_INPUT_DEFAULT_TRANSLATIONS,...S}),[S]);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 a=d.createCreditCardValue(p,m,C,y?j:void 0);h==null||h(a)},[p,m,C,j,y,h]);t.useEffect(()=>{L()},[L]);const R=t.useCallback(a=>{const i=a.target.value.replace(/\D/g,""),o=d.detectCardType(i);P(o);const J=d.getMaxCardLength(o),X=i.slice(0,J),Z=d.formatCardNumber(X,o);M(Z),B&&f&&!f.includes(o)&&o!=="unknown"?A(N=>({...N,number:s.invalidCard})):A(N=>{const{number:K,...G}=N;return G})},[f,B,s.invalidCard]),v=t.useCallback(a=>{const i=d.formatExpiry(a.target.value);T(i)},[]),D=t.useCallback(a=>{const i=a.target.value.replace(/\D/g,""),o=d.getMaxCvvLength(u);E(i.slice(0,o))},[u]),F=t.useCallback(a=>{z(a.target.value)},[]),l=c.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",w.CREDIT_INPUT_SIZE_CLASSES[O]),x=c.cn("bear-flex bear-items-center bear-rounded-lg bear-border bear-transition-colors",w.CREDIT_INPUT_VARIANT_CLASSES[V],b||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:c.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:c.cn("Bear-CreditInput__single",x),children:[e.jsx("div",{className:"Bear-CreditInput__icon bear-pl-3 bear-pr-1",children:k??q[u]}),e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-number",value:p,onChange:R,placeholder:s.cardNumberPlaceholder,disabled:n,className:c.cn("Bear-CreditInput__number bear-flex-1",l)}),e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-exp",value:m,onChange:v,placeholder:s.expiryPlaceholder,disabled:n,className:c.cn("Bear-CreditInput__expiry bear-w-16 bear-text-center",l)}),e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-csc",value:C,onChange:D,placeholder:s.cvvPlaceholder,disabled:n,className:c.cn("Bear-CreditInput__cvv bear-w-12 bear-text-center bear-pr-3",l)})]}):e.jsxs("div",{className:"Bear-CreditInput__split bear-space-y-3",children:[e.jsxs("div",{className:x,children:[e.jsx("div",{className:"Bear-CreditInput__icon bear-pl-3 bear-pr-1",children:k??q[u]}),e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-number",value:p,onChange:R,placeholder:s.cardNumberPlaceholder,disabled:n,className:c.cn("Bear-CreditInput__number bear-flex-1",l)})]}),e.jsxs("div",{className:"bear-flex bear-gap-3",children:[e.jsx("div",{className:c.cn(x,"bear-flex-1"),children:e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-exp",value:m,onChange:v,placeholder:s.expiryPlaceholder,disabled:n,className:c.cn("Bear-CreditInput__expiry bear-w-full",l)})}),e.jsx("div",{className:c.cn(x,"bear-w-24"),children:e.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"cc-csc",value:C,onChange:D,placeholder:s.cvvPlaceholder,disabled:n,className:c.cn("Bear-CreditInput__cvv bear-w-full bear-text-center",l)})})]}),y&&e.jsx("div",{className:x,children:e.jsx("input",{type:"text",autoComplete:"cc-name",value:j,onChange:F,placeholder:s.namePlaceholder,disabled:n,className:c.cn("Bear-CreditInput__name bear-w-full",l)})})]}),b&&e.jsx("p",{className:"Bear-CreditInput__error bear-mt-1 bear-text-xs bear-text-red-400",children:b}),Object.values(g).map((a,i)=>e.jsx("p",{className:"Bear-CreditInput__error bear-mt-1 bear-text-xs bear-text-red-400",children:a},i)),I&&!b&&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
+ "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 a, jsx as r } from "react/jsx-runtime";
2
- import { useState as d, useMemo as K, useEffect as U, useCallback as p } from "react";
3
- import { cn as t } from "../../utils/cn.js";
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 oe } from "./CreditInput.utils.js";
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__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "currentColor", children: [
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__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "#2e77bc", children: [
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__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "#ff6600", children: [
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__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "#0079be", children: [
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__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", children: [
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__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", children: [
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__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
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
- }, be = ({
36
+ }, pe = ({
37
37
  value: e,
38
- onChange: m,
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: b,
48
- acceptedCards: N,
49
- validateOnInput: M = !0,
47
+ error: p,
48
+ acceptedCards: w,
49
+ validateOnInput: k = !0,
50
50
  className: F,
51
51
  testId: J,
52
- translations: k,
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) || ""), [w, A] = d((e == null ? void 0 : e.name) || ""), [y, P] = d("unknown"), [_, L] = d({}), i = K(() => ({
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
- ...k
60
- }), [k]);
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 = p(() => {
65
- const c = te(x, f, C, g ? w : void 0);
66
- m == null || m(c);
67
- }, [x, f, C, w, g, m]);
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 D = p((c) => {
72
- const o = c.target.value.replace(/\D/g, ""), l = ae(o);
73
- P(l);
74
- const Z = ce(l), q = o.slice(0, Z), G = ie(q, l);
75
- E(G), M && N && !N.includes(l) && l !== "unknown" ? L((u) => ({ ...u, number: i.invalidCard })) : L((u) => {
76
- const { number: se, ...H } = u;
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
- }, [N, M, i.invalidCard]), v = p((c) => {
80
- const o = ne(c.target.value);
81
- S(o);
82
- }, []), R = p((c) => {
83
- const o = c.target.value.replace(/\D/g, ""), l = oe(y);
84
- z(o.slice(0, l));
85
- }, [y]), X = p((c) => {
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
- }, []), s = t(
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
- ), h = t(
90
+ ), b = a(
91
91
  "bear-flex bear-items-center bear-rounded-lg bear-border bear-transition-colors",
92
92
  re[$],
93
- b || Object.keys(_).length > 0 ? "bear-border-red-500" : "focus-within:bear-border-pink-500",
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__ */ a(
96
+ return /* @__PURE__ */ t(
97
97
  "div",
98
98
  {
99
- className: t("Bear-CreditInput", F),
99
+ className: a("Bear-CreditInput", F),
100
100
  "data-testid": J,
101
101
  children: [
102
- B && /* @__PURE__ */ a("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: [
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__ */ a("div", { className: t("Bear-CreditInput__single", h), children: [
107
- /* @__PURE__ */ r("div", { className: "Bear-CreditInput__icon bear-pl-3 bear-pr-1", children: T ?? V[y] }),
108
- /* @__PURE__ */ r(
109
- "input",
110
- {
111
- type: "text",
112
- inputMode: "numeric",
113
- autoComplete: "cc-number",
114
- value: x,
115
- onChange: D,
116
- placeholder: i.cardNumberPlaceholder,
117
- disabled: n,
118
- className: t("Bear-CreditInput__number bear-flex-1", s)
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: v,
130
+ onChange: D,
129
131
  placeholder: i.expiryPlaceholder,
130
132
  disabled: n,
131
- className: t("Bear-CreditInput__expiry bear-w-16 bear-text-center", s)
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: t("Bear-CreditInput__cvv bear-w-12 bear-text-center bear-pr-3", s)
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__ */ a("div", { className: "Bear-CreditInput__split bear-space-y-3", children: [
148
- /* @__PURE__ */ a("div", { className: h, children: [
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: D,
159
+ onChange: v,
158
160
  placeholder: i.cardNumberPlaceholder,
159
161
  disabled: n,
160
- className: t("Bear-CreditInput__number bear-flex-1", s)
162
+ className: a("Bear-CreditInput__number bear-flex-1", l)
161
163
  }
162
164
  )
163
165
  ] }),
164
- /* @__PURE__ */ a("div", { className: "bear-flex bear-gap-3", children: [
165
- /* @__PURE__ */ r("div", { className: t(h, "bear-flex-1"), children: /* @__PURE__ */ r(
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: v,
174
+ onChange: D,
173
175
  placeholder: i.expiryPlaceholder,
174
176
  disabled: n,
175
- className: t("Bear-CreditInput__expiry bear-w-full", s)
177
+ className: a("Bear-CreditInput__expiry bear-w-full", l)
176
178
  }
177
179
  ) }),
178
- /* @__PURE__ */ r("div", { className: t(h, "bear-w-24"), children: /* @__PURE__ */ r(
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: t("Bear-CreditInput__cvv bear-w-full bear-text-center", s)
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: h, children: /* @__PURE__ */ r(
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: w,
199
+ value: N,
198
200
  onChange: X,
199
201
  placeholder: i.namePlaceholder,
200
202
  disabled: n,
201
- className: t("Bear-CreditInput__name bear-w-full", s)
203
+ className: a("Bear-CreditInput__name bear-w-full", l)
202
204
  }
203
205
  ) })
204
206
  ] }),
205
- b && /* @__PURE__ */ r("p", { className: "Bear-CreditInput__error bear-mt-1 bear-text-xs bear-text-red-400", children: b }),
206
- Object.values(_).map((c, o) => /* @__PURE__ */ r("p", { className: "Bear-CreditInput__error bear-mt-1 bear-text-xs bear-text-red-400", children: c }, o)),
207
- I && !b && 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 })
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
- be as CreditInput
215
+ pe as CreditInput
214
216
  };
@@ -1 +1 @@
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
+ "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;