@forgedevstack/bear 1.0.5 → 1.0.6

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 (114) hide show
  1. package/dist/components/Calendar/Calendar.cjs +1 -1
  2. package/dist/components/Calendar/Calendar.const.cjs +1 -1
  3. package/dist/components/Calendar/Calendar.const.d.ts +1 -0
  4. package/dist/components/Calendar/Calendar.const.js +6 -5
  5. package/dist/components/Calendar/Calendar.helpers.cjs +1 -1
  6. package/dist/components/Calendar/Calendar.helpers.js +4 -4
  7. package/dist/components/Calendar/Calendar.js +128 -128
  8. package/dist/components/Cascader/Cascader.cjs +1 -0
  9. package/dist/components/Cascader/Cascader.const.cjs +1 -0
  10. package/dist/components/Cascader/Cascader.const.d.ts +33 -0
  11. package/dist/components/Cascader/Cascader.const.js +21 -0
  12. package/dist/components/Cascader/Cascader.d.ts +17 -0
  13. package/dist/components/Cascader/Cascader.js +227 -0
  14. package/dist/components/Cascader/Cascader.types.d.ts +94 -0
  15. package/dist/components/Cascader/index.d.ts +2 -0
  16. package/dist/components/CommandPalette/CommandPalette.cjs +1 -0
  17. package/dist/components/CommandPalette/CommandPalette.const.cjs +1 -0
  18. package/dist/components/CommandPalette/CommandPalette.const.d.ts +25 -0
  19. package/dist/components/CommandPalette/CommandPalette.const.js +13 -0
  20. package/dist/components/CommandPalette/CommandPalette.d.ts +18 -0
  21. package/dist/components/CommandPalette/CommandPalette.js +190 -0
  22. package/dist/components/CommandPalette/CommandPalette.types.d.ts +90 -0
  23. package/dist/components/CommandPalette/CommandPalette.utils.cjs +1 -0
  24. package/dist/components/CommandPalette/CommandPalette.utils.d.ts +17 -0
  25. package/dist/components/CommandPalette/CommandPalette.utils.js +63 -0
  26. package/dist/components/CommandPalette/index.d.ts +2 -0
  27. package/dist/components/CreditInput/CreditInput.cjs +1 -0
  28. package/dist/components/CreditInput/CreditInput.const.cjs +1 -0
  29. package/dist/components/CreditInput/CreditInput.const.d.ts +37 -0
  30. package/dist/components/CreditInput/CreditInput.const.js +66 -0
  31. package/dist/components/CreditInput/CreditInput.d.ts +15 -0
  32. package/dist/components/CreditInput/CreditInput.js +214 -0
  33. package/dist/components/CreditInput/CreditInput.types.d.ts +93 -0
  34. package/dist/components/CreditInput/CreditInput.utils.cjs +1 -0
  35. package/dist/components/CreditInput/CreditInput.utils.d.ts +48 -0
  36. package/dist/components/CreditInput/CreditInput.utils.js +79 -0
  37. package/dist/components/CreditInput/index.d.ts +2 -0
  38. package/dist/components/DatePicker/DatePicker.cjs +1 -1
  39. package/dist/components/DatePicker/DatePicker.js +108 -84
  40. package/dist/components/DatePicker/DatePicker.types.d.ts +2 -1
  41. package/dist/components/Drawer/Drawer.cjs +1 -1
  42. package/dist/components/Drawer/Drawer.js +75 -44
  43. package/dist/components/Form/Form.cjs +1 -0
  44. package/dist/components/Form/Form.const.cjs +1 -0
  45. package/dist/components/Form/Form.const.d.ts +33 -0
  46. package/dist/components/Form/Form.const.js +27 -0
  47. package/dist/components/Form/Form.context.cjs +1 -0
  48. package/dist/components/Form/Form.context.d.ts +13 -0
  49. package/dist/components/Form/Form.context.js +12 -0
  50. package/dist/components/Form/Form.d.ts +18 -0
  51. package/dist/components/Form/Form.js +230 -0
  52. package/dist/components/Form/Form.types.d.ts +166 -0
  53. package/dist/components/Form/Form.utils.cjs +1 -0
  54. package/dist/components/Form/Form.utils.d.ts +17 -0
  55. package/dist/components/Form/Form.utils.js +31 -0
  56. package/dist/components/Form/index.d.ts +3 -0
  57. package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -0
  58. package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -0
  59. package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +25 -0
  60. package/dist/components/NotificationCenter/NotificationCenter.const.js +28 -0
  61. package/dist/components/NotificationCenter/NotificationCenter.d.ts +15 -0
  62. package/dist/components/NotificationCenter/NotificationCenter.js +223 -0
  63. package/dist/components/NotificationCenter/NotificationCenter.types.d.ts +117 -0
  64. package/dist/components/NotificationCenter/NotificationCenter.utils.cjs +1 -0
  65. package/dist/components/NotificationCenter/NotificationCenter.utils.d.ts +11 -0
  66. package/dist/components/NotificationCenter/NotificationCenter.utils.js +19 -0
  67. package/dist/components/NotificationCenter/index.d.ts +2 -0
  68. package/dist/components/PhoneInput/PhoneInput.cjs +1 -0
  69. package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -0
  70. package/dist/components/PhoneInput/PhoneInput.const.d.ts +33 -0
  71. package/dist/components/PhoneInput/PhoneInput.const.js +82 -0
  72. package/dist/components/PhoneInput/PhoneInput.d.ts +16 -0
  73. package/dist/components/PhoneInput/PhoneInput.js +194 -0
  74. package/dist/components/PhoneInput/PhoneInput.types.d.ts +108 -0
  75. package/dist/components/PhoneInput/PhoneInput.utils.cjs +1 -0
  76. package/dist/components/PhoneInput/PhoneInput.utils.d.ts +25 -0
  77. package/dist/components/PhoneInput/PhoneInput.utils.js +39 -0
  78. package/dist/components/PhoneInput/index.d.ts +2 -0
  79. package/dist/components/SignPad/SignPad.cjs +1 -1
  80. package/dist/components/SignPad/SignPad.js +56 -56
  81. package/dist/components/TimePicker/TimePicker.cjs +1 -1
  82. package/dist/components/TimePicker/TimePicker.constants.cjs +1 -1
  83. package/dist/components/TimePicker/TimePicker.constants.d.ts +22 -1
  84. package/dist/components/TimePicker/TimePicker.constants.js +36 -19
  85. package/dist/components/TimePicker/TimePicker.js +97 -131
  86. package/dist/components/TimePicker/TimePicker.types.d.ts +47 -6
  87. package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.cjs +1 -0
  88. package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.d.ts +3 -0
  89. package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.js +81 -0
  90. package/dist/components/TimePicker/components/TimePickerColumnsDropdown/index.d.ts +1 -0
  91. package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -0
  92. package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.d.ts +3 -0
  93. package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +84 -0
  94. package/dist/components/TimePicker/components/TimePickerDialDropdown/index.d.ts +1 -0
  95. package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -0
  96. package/dist/components/TimePicker/helpers/ClockFaceSvg.d.ts +18 -0
  97. package/dist/components/TimePicker/helpers/ClockFaceSvg.js +67 -0
  98. package/dist/components/TimePicker/helpers/index.d.ts +2 -0
  99. package/dist/components/TimePicker/index.d.ts +1 -1
  100. package/dist/components/index.cjs +1 -1
  101. package/dist/components/index.d.ts +12 -2
  102. package/dist/components/index.js +139 -126
  103. package/dist/index.cjs +1 -1
  104. package/dist/index.js +247 -234
  105. package/dist/styles.css +1 -1
  106. package/package.json +1 -1
  107. package/dist/components/DateTimePicker/DateTimePicker.cjs +0 -1
  108. package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -3
  109. package/dist/components/DateTimePicker/DateTimePicker.js +0 -178
  110. package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +0 -26
  111. package/dist/components/DateTimePicker/DateTimePicker.utils.cjs +0 -1
  112. package/dist/components/DateTimePicker/DateTimePicker.utils.d.ts +0 -2
  113. package/dist/components/DateTimePicker/DateTimePicker.utils.js +0 -16
  114. package/dist/components/DateTimePicker/index.d.ts +0 -2
@@ -0,0 +1,90 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Command item interface
4
+ */
5
+ export interface CommandItem {
6
+ /** Unique identifier */
7
+ id: string;
8
+ /** Display label */
9
+ label: string;
10
+ /** Optional description */
11
+ description?: string;
12
+ /** Optional icon */
13
+ icon?: ReactNode;
14
+ /** Keyboard shortcut (e.g., 'Ctrl+K') */
15
+ shortcut?: string;
16
+ /** Category/group name */
17
+ category?: string;
18
+ /** Handler when command is selected */
19
+ onSelect: () => void;
20
+ /** Whether the command is disabled */
21
+ disabled?: boolean;
22
+ /** Keywords for search (in addition to label) */
23
+ keywords?: string[];
24
+ /** Custom metadata */
25
+ metadata?: Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Command group interface
29
+ */
30
+ export interface CommandGroup {
31
+ /** Group name */
32
+ name: string;
33
+ /** Commands in this group */
34
+ commands: CommandItem[];
35
+ }
36
+ /**
37
+ * CommandPalette translations
38
+ */
39
+ export interface CommandPaletteTranslations {
40
+ placeholder: string;
41
+ noResults: string;
42
+ recentCommands: string;
43
+ allCommands: string;
44
+ closeHint: string;
45
+ }
46
+ /**
47
+ * CommandPalette component props
48
+ */
49
+ export interface CommandPaletteProps {
50
+ /** Available commands */
51
+ commands: CommandItem[];
52
+ /** Whether the palette is open */
53
+ open?: boolean;
54
+ /** Callback when open state changes */
55
+ onOpenChange?: (open: boolean) => void;
56
+ /** Placeholder text */
57
+ placeholder?: string;
58
+ /** Whether to show recent commands */
59
+ showRecent?: boolean;
60
+ /** Maximum recent commands to show */
61
+ maxRecent?: number;
62
+ /** Recent command IDs */
63
+ recentIds?: string[];
64
+ /** Callback when recent commands change */
65
+ onRecentChange?: (ids: string[]) => void;
66
+ /** Whether to group commands by category */
67
+ groupByCategory?: boolean;
68
+ /** Custom filter function */
69
+ filterFn?: (command: CommandItem, query: string) => boolean;
70
+ /** Trigger keyboard shortcut */
71
+ triggerKey?: string;
72
+ /** Custom class name */
73
+ className?: string;
74
+ /** Test ID */
75
+ testId?: string;
76
+ /** Translation strings */
77
+ translations?: Partial<CommandPaletteTranslations>;
78
+ /** Custom search icon */
79
+ icon?: ReactNode;
80
+ /** Footer content */
81
+ footer?: ReactNode;
82
+ }
83
+ /**
84
+ * CommandItem component props
85
+ */
86
+ export interface CommandItemComponentProps {
87
+ command: CommandItem;
88
+ isHighlighted: boolean;
89
+ onSelect: () => void;
90
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=(t,r)=>{var e,a;const s=r.toLowerCase();return[t.label.toLowerCase(),((e=t.description)==null?void 0:e.toLowerCase())||"",...((a=t.keywords)==null?void 0:a.map(o=>o.toLowerCase()))||[]].some(o=>o.includes(s))},u=t=>{const r={},s=[];t.forEach(e=>{e.category?(r[e.category]||(r[e.category]=[]),r[e.category].push(e)):s.push(e)});const c=Object.entries(r).map(([e,a])=>({name:e,commands:a}));return s.length>0&&c.push({name:"Other",commands:s}),c},l=t=>t.split("+").map(r=>{switch(r.toLowerCase()){case"ctrl":case"control":return"⌃";case"cmd":case"command":case"meta":return"⌘";case"alt":case"option":return"⌥";case"shift":return"⇧";case"enter":case"return":return"↵";case"backspace":return"⌫";case"delete":return"⌦";case"escape":case"esc":return"esc";case"tab":return"⇥";case"space":return"␣";case"up":return"↑";case"down":return"↓";case"left":return"←";case"right":return"→";default:return r.toUpperCase()}});exports.defaultFilterFn=n;exports.formatShortcut=l;exports.groupCommandsByCategory=u;
@@ -0,0 +1,17 @@
1
+ import { CommandItem, CommandGroup } from './CommandPalette.types';
2
+ /**
3
+ * Default filter function
4
+ */
5
+ export declare const defaultFilterFn: (command: CommandItem, query: string) => boolean;
6
+ /**
7
+ * Group commands by category
8
+ */
9
+ export declare const groupCommandsByCategory: (commands: CommandItem[]) => CommandGroup[];
10
+ /**
11
+ * Parse keyboard shortcut for display
12
+ */
13
+ export declare const formatShortcut: (shortcut: string) => string[];
14
+ /**
15
+ * Get flat list of commands from groups
16
+ */
17
+ export declare const flattenGroups: (groups: CommandGroup[]) => CommandItem[];
@@ -0,0 +1,63 @@
1
+ const n = (t, r) => {
2
+ var e, a;
3
+ const s = r.toLowerCase();
4
+ return [
5
+ t.label.toLowerCase(),
6
+ ((e = t.description) == null ? void 0 : e.toLowerCase()) || "",
7
+ ...((a = t.keywords) == null ? void 0 : a.map((o) => o.toLowerCase())) || []
8
+ ].some((o) => o.includes(s));
9
+ }, u = (t) => {
10
+ const r = {}, s = [];
11
+ t.forEach((e) => {
12
+ e.category ? (r[e.category] || (r[e.category] = []), r[e.category].push(e)) : s.push(e);
13
+ });
14
+ const c = Object.entries(r).map(([e, a]) => ({
15
+ name: e,
16
+ commands: a
17
+ }));
18
+ return s.length > 0 && c.push({ name: "Other", commands: s }), c;
19
+ }, p = (t) => t.split("+").map((r) => {
20
+ switch (r.toLowerCase()) {
21
+ case "ctrl":
22
+ case "control":
23
+ return "⌃";
24
+ case "cmd":
25
+ case "command":
26
+ case "meta":
27
+ return "⌘";
28
+ case "alt":
29
+ case "option":
30
+ return "⌥";
31
+ case "shift":
32
+ return "⇧";
33
+ case "enter":
34
+ case "return":
35
+ return "↵";
36
+ case "backspace":
37
+ return "⌫";
38
+ case "delete":
39
+ return "⌦";
40
+ case "escape":
41
+ case "esc":
42
+ return "esc";
43
+ case "tab":
44
+ return "⇥";
45
+ case "space":
46
+ return "␣";
47
+ case "up":
48
+ return "↑";
49
+ case "down":
50
+ return "↓";
51
+ case "left":
52
+ return "←";
53
+ case "right":
54
+ return "→";
55
+ default:
56
+ return r.toUpperCase();
57
+ }
58
+ });
59
+ export {
60
+ n as defaultFilterFn,
61
+ p as formatShortcut,
62
+ u as groupCommandsByCategory
63
+ };
@@ -0,0 +1,2 @@
1
+ export { CommandPalette } from './CommandPalette';
2
+ export type { CommandPaletteProps, CommandItem, CommandGroup, CommandPaletteTranslations, } from './CommandPalette.types';
@@ -0,0 +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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={cardNumber:"Card Number",expiry:"Expiry",cvv:"CVV",name:"Cardholder Name",cardNumberPlaceholder:"1234 5678 9012 3456",expiryPlaceholder:"MM/YY",cvvPlaceholder:"123",namePlaceholder:"John Doe",invalidCard:"Invalid card number",invalidExpiry:"Invalid expiry date",invalidCvv:"Invalid CVV"},r={sm:"bear-py-1.5 bear-px-3 bear-text-sm",md:"bear-py-2 bear-px-4 bear-text-sm",lg:"bear-py-2.5 bear-px-5 bear-text-base"},a={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-300 dark:bear-border-zinc-500"},n={visa:/^4/,mastercard:/^(5[1-5]|2[2-7])/,amex:/^3[47]/,discover:/^(6011|65|64[4-9])/,diners:/^(36|38|30[0-5])/,jcb:/^35/,unionpay:/^62/,unknown:/.*/},d={visa:[13,16,19],mastercard:[16],amex:[15],discover:[16,19],diners:[14,16,19],jcb:[16,19],unionpay:[16,17,18,19],unknown:[16]},i={visa:3,mastercard:3,amex:4,discover:3,diners:3,jcb:3,unionpay:3,unknown:3},b={visa:[4,4,4,4,3],mastercard:[4,4,4,4],amex:[4,6,5],discover:[4,4,4,4,3],diners:[4,6,4,4,1],jcb:[4,4,4,4,3],unionpay:[4,4,4,4,3],unknown:[4,4,4,4]};exports.CARD_FORMATS=b;exports.CARD_NUMBER_LENGTHS=d;exports.CARD_PATTERNS=n;exports.CREDIT_INPUT_DEFAULT_TRANSLATIONS=e;exports.CREDIT_INPUT_SIZE_CLASSES=r;exports.CREDIT_INPUT_VARIANT_CLASSES=a;exports.CVV_LENGTHS=i;
@@ -0,0 +1,37 @@
1
+ import { CreditInputTranslations, CardType } from './CreditInput.types';
2
+ /**
3
+ * Default translations
4
+ */
5
+ export declare const CREDIT_INPUT_DEFAULT_TRANSLATIONS: CreditInputTranslations;
6
+ /**
7
+ * Size classes
8
+ */
9
+ export declare const CREDIT_INPUT_SIZE_CLASSES: {
10
+ readonly sm: "bear-py-1.5 bear-px-3 bear-text-sm";
11
+ readonly md: "bear-py-2 bear-px-4 bear-text-sm";
12
+ readonly lg: "bear-py-2.5 bear-px-5 bear-text-base";
13
+ };
14
+ /**
15
+ * Variant classes (light/dark)
16
+ */
17
+ export declare const CREDIT_INPUT_VARIANT_CLASSES: {
18
+ readonly default: "bear-bg-white dark:bear-bg-zinc-800 bear-border-zinc-300 dark:bear-border-zinc-600";
19
+ readonly filled: "bear-bg-zinc-100 dark:bear-bg-zinc-700 bear-border-transparent";
20
+ readonly outline: "bear-bg-transparent bear-border-zinc-300 dark:bear-border-zinc-500";
21
+ };
22
+ /**
23
+ * Card type patterns (regex for detection)
24
+ */
25
+ export declare const CARD_PATTERNS: Record<CardType, RegExp>;
26
+ /**
27
+ * Card number lengths by type
28
+ */
29
+ export declare const CARD_NUMBER_LENGTHS: Record<CardType, number[]>;
30
+ /**
31
+ * CVV lengths by card type
32
+ */
33
+ export declare const CVV_LENGTHS: Record<CardType, number>;
34
+ /**
35
+ * Card format patterns (spacing)
36
+ */
37
+ export declare const CARD_FORMATS: Record<CardType, number[]>;
@@ -0,0 +1,66 @@
1
+ const r = {
2
+ cardNumber: "Card Number",
3
+ expiry: "Expiry",
4
+ cvv: "CVV",
5
+ name: "Cardholder Name",
6
+ cardNumberPlaceholder: "1234 5678 9012 3456",
7
+ expiryPlaceholder: "MM/YY",
8
+ cvvPlaceholder: "123",
9
+ namePlaceholder: "John Doe",
10
+ invalidCard: "Invalid card number",
11
+ invalidExpiry: "Invalid expiry date",
12
+ invalidCvv: "Invalid CVV"
13
+ }, e = {
14
+ sm: "bear-py-1.5 bear-px-3 bear-text-sm",
15
+ md: "bear-py-2 bear-px-4 bear-text-sm",
16
+ lg: "bear-py-2.5 bear-px-5 bear-text-base"
17
+ }, a = {
18
+ default: "bear-bg-white dark:bear-bg-zinc-800 bear-border-zinc-300 dark:bear-border-zinc-600",
19
+ filled: "bear-bg-zinc-100 dark:bear-bg-zinc-700 bear-border-transparent",
20
+ outline: "bear-bg-transparent bear-border-zinc-300 dark:bear-border-zinc-500"
21
+ }, n = {
22
+ visa: /^4/,
23
+ mastercard: /^(5[1-5]|2[2-7])/,
24
+ amex: /^3[47]/,
25
+ discover: /^(6011|65|64[4-9])/,
26
+ diners: /^(36|38|30[0-5])/,
27
+ jcb: /^35/,
28
+ unionpay: /^62/,
29
+ unknown: /.*/
30
+ }, d = {
31
+ visa: [13, 16, 19],
32
+ mastercard: [16],
33
+ amex: [15],
34
+ discover: [16, 19],
35
+ diners: [14, 16, 19],
36
+ jcb: [16, 19],
37
+ unionpay: [16, 17, 18, 19],
38
+ unknown: [16]
39
+ }, i = {
40
+ visa: 3,
41
+ mastercard: 3,
42
+ amex: 4,
43
+ discover: 3,
44
+ diners: 3,
45
+ jcb: 3,
46
+ unionpay: 3,
47
+ unknown: 3
48
+ }, b = {
49
+ visa: [4, 4, 4, 4, 3],
50
+ mastercard: [4, 4, 4, 4],
51
+ amex: [4, 6, 5],
52
+ discover: [4, 4, 4, 4, 3],
53
+ diners: [4, 6, 4, 4, 1],
54
+ jcb: [4, 4, 4, 4, 3],
55
+ unionpay: [4, 4, 4, 4, 3],
56
+ unknown: [4, 4, 4, 4]
57
+ };
58
+ export {
59
+ b as CARD_FORMATS,
60
+ d as CARD_NUMBER_LENGTHS,
61
+ n as CARD_PATTERNS,
62
+ r as CREDIT_INPUT_DEFAULT_TRANSLATIONS,
63
+ e as CREDIT_INPUT_SIZE_CLASSES,
64
+ a as CREDIT_INPUT_VARIANT_CLASSES,
65
+ i as CVV_LENGTHS
66
+ };
@@ -0,0 +1,15 @@
1
+ import { FC } from 'react';
2
+ import { CreditInputProps } from './CreditInput.types';
3
+ /**
4
+ * CreditInput - Credit card input with formatting and validation
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * <CreditInput
9
+ * value={cardValue}
10
+ * onChange={setCardValue}
11
+ * showName={true}
12
+ * />
13
+ * ```
14
+ */
15
+ export declare const CreditInput: FC<CreditInputProps>;
@@ -0,0 +1,214 @@
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";
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";
6
+ const V = {
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: [
9
+ /* @__PURE__ */ r("circle", { cx: "9", cy: "12", r: "5", opacity: ".8", fill: "#eb001b" }),
10
+ /* @__PURE__ */ r("circle", { cx: "15", cy: "12", r: "5", opacity: ".8", fill: "#f79e1b" })
11
+ ] }),
12
+ amex: /* @__PURE__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "#2e77bc", children: [
13
+ /* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }),
14
+ /* @__PURE__ */ r("text", { x: "12", y: "14", textAnchor: "middle", fontSize: "6", fill: "white", fontWeight: "bold", children: "AMEX" })
15
+ ] }),
16
+ discover: /* @__PURE__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "#ff6600", children: [
17
+ /* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }),
18
+ /* @__PURE__ */ r("circle", { cx: "15", cy: "12", r: "3", fill: "white" })
19
+ ] }),
20
+ diners: /* @__PURE__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", fill: "#0079be", children: [
21
+ /* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }),
22
+ /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "4", fill: "white" })
23
+ ] }),
24
+ jcb: /* @__PURE__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", children: [
25
+ /* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2", fill: "#0e4c96" }),
26
+ /* @__PURE__ */ r("text", { x: "12", y: "14", textAnchor: "middle", fontSize: "5", fill: "white", fontWeight: "bold", children: "JCB" })
27
+ ] }),
28
+ unionpay: /* @__PURE__ */ a("svg", { viewBox: "0 0 24 24", className: "bear-w-8 bear-h-5", children: [
29
+ /* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2", fill: "#d9222a" }),
30
+ /* @__PURE__ */ r("text", { x: "12", y: "14", textAnchor: "middle", fontSize: "4", fill: "white", fontWeight: "bold", children: "UnionPay" })
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: [
33
+ /* @__PURE__ */ r("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }),
34
+ /* @__PURE__ */ r("line", { x1: "2", y1: "10", x2: "22", y2: "10" })
35
+ ] })
36
+ }, be = ({
37
+ value: e,
38
+ onChange: m,
39
+ mode: W = "single",
40
+ showName: g = !1,
41
+ size: Y = "md",
42
+ variant: $ = "default",
43
+ disabled: n = !1,
44
+ required: O = !1,
45
+ label: B,
46
+ helperText: I,
47
+ error: b,
48
+ acceptedCards: N,
49
+ validateOnInput: M = !0,
50
+ className: F,
51
+ testId: J,
52
+ translations: k,
53
+ icon: T
54
+ }) => {
55
+ const [x, E] = d((e == null ? void 0 : e.number) || ""), [f, S] = d(
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(() => ({
58
+ ...Q,
59
+ ...k
60
+ }), [k]);
61
+ U(() => {
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
+ }, [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]);
68
+ U(() => {
69
+ j();
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;
77
+ return H;
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) => {
86
+ A(c.target.value);
87
+ }, []), s = t(
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
+ ee[Y]
90
+ ), h = t(
91
+ "bear-flex bear-items-center bear-rounded-lg bear-border bear-transition-colors",
92
+ re[$],
93
+ b || Object.keys(_).length > 0 ? "bear-border-red-500" : "focus-within:bear-border-pink-500",
94
+ n && "bear-opacity-50 bear-cursor-not-allowed"
95
+ );
96
+ return /* @__PURE__ */ a(
97
+ "div",
98
+ {
99
+ className: t("Bear-CreditInput", F),
100
+ "data-testid": J,
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: [
103
+ B,
104
+ O && /* @__PURE__ */ r("span", { className: "bear-text-red-500 bear-ml-0.5", children: "*" })
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
+ ),
121
+ /* @__PURE__ */ r(
122
+ "input",
123
+ {
124
+ type: "text",
125
+ inputMode: "numeric",
126
+ autoComplete: "cc-exp",
127
+ value: f,
128
+ onChange: v,
129
+ placeholder: i.expiryPlaceholder,
130
+ disabled: n,
131
+ className: t("Bear-CreditInput__expiry bear-w-16 bear-text-center", s)
132
+ }
133
+ ),
134
+ /* @__PURE__ */ r(
135
+ "input",
136
+ {
137
+ type: "text",
138
+ inputMode: "numeric",
139
+ autoComplete: "cc-csc",
140
+ value: C,
141
+ onChange: R,
142
+ placeholder: i.cvvPlaceholder,
143
+ disabled: n,
144
+ className: t("Bear-CreditInput__cvv bear-w-12 bear-text-center bear-pr-3", s)
145
+ }
146
+ )
147
+ ] }) : /* @__PURE__ */ a("div", { className: "Bear-CreditInput__split bear-space-y-3", children: [
148
+ /* @__PURE__ */ a("div", { className: h, children: [
149
+ /* @__PURE__ */ r("div", { className: "Bear-CreditInput__icon bear-pl-3 bear-pr-1", children: T ?? V[y] }),
150
+ /* @__PURE__ */ r(
151
+ "input",
152
+ {
153
+ type: "text",
154
+ inputMode: "numeric",
155
+ autoComplete: "cc-number",
156
+ value: x,
157
+ onChange: D,
158
+ placeholder: i.cardNumberPlaceholder,
159
+ disabled: n,
160
+ className: t("Bear-CreditInput__number bear-flex-1", s)
161
+ }
162
+ )
163
+ ] }),
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
+ "input",
167
+ {
168
+ type: "text",
169
+ inputMode: "numeric",
170
+ autoComplete: "cc-exp",
171
+ value: f,
172
+ onChange: v,
173
+ placeholder: i.expiryPlaceholder,
174
+ disabled: n,
175
+ className: t("Bear-CreditInput__expiry bear-w-full", s)
176
+ }
177
+ ) }),
178
+ /* @__PURE__ */ r("div", { className: t(h, "bear-w-24"), children: /* @__PURE__ */ r(
179
+ "input",
180
+ {
181
+ type: "text",
182
+ inputMode: "numeric",
183
+ autoComplete: "cc-csc",
184
+ value: C,
185
+ onChange: R,
186
+ placeholder: i.cvvPlaceholder,
187
+ disabled: n,
188
+ className: t("Bear-CreditInput__cvv bear-w-full bear-text-center", s)
189
+ }
190
+ ) })
191
+ ] }),
192
+ g && /* @__PURE__ */ r("div", { className: h, children: /* @__PURE__ */ r(
193
+ "input",
194
+ {
195
+ type: "text",
196
+ autoComplete: "cc-name",
197
+ value: w,
198
+ onChange: X,
199
+ placeholder: i.namePlaceholder,
200
+ disabled: n,
201
+ className: t("Bear-CreditInput__name bear-w-full", s)
202
+ }
203
+ ) })
204
+ ] }),
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 })
208
+ ]
209
+ }
210
+ );
211
+ };
212
+ export {
213
+ be as CreditInput
214
+ };
@@ -0,0 +1,93 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Credit card types
4
+ */
5
+ export type CardType = 'visa' | 'mastercard' | 'amex' | 'discover' | 'diners' | 'jcb' | 'unionpay' | 'unknown';
6
+ /**
7
+ * Credit card value
8
+ */
9
+ export interface CreditCardValue {
10
+ /** Card number (formatted) */
11
+ number: string;
12
+ /** Card number (raw digits only) */
13
+ rawNumber: string;
14
+ /** Expiry month */
15
+ expiryMonth: string;
16
+ /** Expiry year */
17
+ expiryYear: string;
18
+ /** CVV/CVC code */
19
+ cvv: string;
20
+ /** Cardholder name */
21
+ name?: string;
22
+ /** Detected card type */
23
+ cardType: CardType;
24
+ /** Whether the card number is valid (Luhn check) */
25
+ isValid: boolean;
26
+ }
27
+ /**
28
+ * CreditInput size variants
29
+ */
30
+ export type CreditInputSize = 'sm' | 'md' | 'lg';
31
+ /**
32
+ * CreditInput variant styles
33
+ */
34
+ export type CreditInputVariant = 'default' | 'filled' | 'outline';
35
+ /**
36
+ * CreditInput display mode
37
+ */
38
+ export type CreditInputMode = 'single' | 'split';
39
+ /**
40
+ * CreditInput translations
41
+ */
42
+ export interface CreditInputTranslations {
43
+ cardNumber: string;
44
+ expiry: string;
45
+ cvv: string;
46
+ name: string;
47
+ cardNumberPlaceholder: string;
48
+ expiryPlaceholder: string;
49
+ cvvPlaceholder: string;
50
+ namePlaceholder: string;
51
+ invalidCard: string;
52
+ invalidExpiry: string;
53
+ invalidCvv: string;
54
+ }
55
+ /**
56
+ * CreditInput component props
57
+ */
58
+ export interface CreditInputProps {
59
+ /** Current credit card value */
60
+ value?: Partial<CreditCardValue>;
61
+ /** Callback when value changes */
62
+ onChange?: (value: CreditCardValue) => void;
63
+ /** Display mode */
64
+ mode?: CreditInputMode;
65
+ /** Whether to show cardholder name field */
66
+ showName?: boolean;
67
+ /** Size variant */
68
+ size?: CreditInputSize;
69
+ /** Style variant */
70
+ variant?: CreditInputVariant;
71
+ /** Whether input is disabled */
72
+ disabled?: boolean;
73
+ /** Whether input is required */
74
+ required?: boolean;
75
+ /** Label text */
76
+ label?: string;
77
+ /** Helper text */
78
+ helperText?: string;
79
+ /** Error message */
80
+ error?: string;
81
+ /** Accepted card types */
82
+ acceptedCards?: CardType[];
83
+ /** Whether to validate on input */
84
+ validateOnInput?: boolean;
85
+ /** Custom class name */
86
+ className?: string;
87
+ /** Test ID */
88
+ testId?: string;
89
+ /** Translation strings */
90
+ translations?: Partial<CreditInputTranslations>;
91
+ /** Custom card icon */
92
+ icon?: ReactNode;
93
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./CreditInput.const.cjs"),l=e=>{const t=e.replace(/\D/g,""),n=["amex","diners","discover","jcb","unionpay","mastercard","visa"];for(const r of n)if(i.CARD_PATTERNS[r].test(t))return r;return"unknown"},u=(e,t)=>{const n=e.replace(/\D/g,""),r=i.CARD_FORMATS[t]||i.CARD_FORMATS.unknown;let a="",s=0;for(const o of r){if(s>=n.length)break;a&&(a+=" "),a+=n.slice(s,s+o),s+=o}return a},N=e=>{const t=e.replace(/\D/g,"");if(t.length===0)return"";if(t.length===1)return parseInt(t)>1?`0${t}/`:t;if(t.length===2)return parseInt(t)>12?`0${t[0]}/${t[1]}`:`${t}/`;const n=t.slice(0,2),r=t.slice(2,4);return`${n}/${r}`},d=e=>{const t=e.split("/");return{month:t[0]||"",year:t[1]||""}},g=e=>{const t=e.replace(/\D/g,"");if(t.length===0)return!1;let n=0,r=!1;for(let a=t.length-1;a>=0;a--){let s=parseInt(t[a],10);r&&(s*=2,s>9&&(s-=9)),n+=s,r=!r}return n%10===0},p=(e,t)=>{const n=e.replace(/\D/g,"");return(i.CARD_NUMBER_LENGTHS[t]||i.CARD_NUMBER_LENGTHS.unknown).includes(n.length)},f=(e,t)=>{const n=e.replace(/\D/g,""),r=i.CVV_LENGTHS[t]||i.CVV_LENGTHS.unknown;return n.length===r},h=(e,t)=>{const n=parseInt(e,10),r=parseInt(t,10);if(isNaN(n)||isNaN(r)||n<1||n>12)return!1;const a=new Date,s=a.getFullYear()%100,o=a.getMonth()+1;return!(r<s||r===s&&n<o)},y=(e,t,n,r)=>{const a=e.replace(/\D/g,""),s=l(a),{month:o,year:c}=d(t),C=g(a)&&p(a,s),v=h(o,c),m=f(n,s);return{number:u(a,s),rawNumber:a,expiryMonth:o,expiryYear:c,cvv:n.replace(/\D/g,""),name:r,cardType:s,isValid:C&&v&&m}},E=e=>i.CVV_LENGTHS[e]||i.CVV_LENGTHS.unknown,L=e=>{const t=i.CARD_NUMBER_LENGTHS[e]||i.CARD_NUMBER_LENGTHS.unknown;return Math.max(...t)};exports.createCreditCardValue=y;exports.detectCardType=l;exports.formatCardNumber=u;exports.formatExpiry=N;exports.getMaxCardLength=L;exports.getMaxCvvLength=E;exports.parseExpiry=d;exports.validateCardLength=p;exports.validateCvvLength=f;exports.validateExpiry=h;exports.validateLuhn=g;