@idonatedev/idonate-sdk 1.2.0-dev17 → 1.2.0-dev19

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.
@@ -5,6 +5,8 @@ exports.formatExpiryInput = formatExpiryInput;
5
5
  exports.withTimeout = withTimeout;
6
6
  exports.getConnectedBorderRadius = getConnectedBorderRadius;
7
7
  exports.addFocusHandlers = addFocusHandlers;
8
+ exports.createFieldLabel = createFieldLabel;
9
+ exports.wrapFieldWithLabel = wrapFieldWithLabel;
8
10
  exports.createFieldContainer = createFieldContainer;
9
11
  exports.createInputElement = createInputElement;
10
12
  exports.validateRoutingNumber = validateRoutingNumber;
@@ -15,6 +17,7 @@ exports.validateInstitutionNumber = validateInstitutionNumber;
15
17
  exports.validateTransitNumber = validateTransitNumber;
16
18
  exports.validateCanadianAccountNumber = validateCanadianAccountNumber;
17
19
  exports.formatCanadianRoutingNumber = formatCanadianRoutingNumber;
20
+ exports.cssLengthToPixels = cssLengthToPixels;
18
21
  function parseExpiryDate(value) {
19
22
  const parts = value.split('/');
20
23
  if (parts.length !== 2)
@@ -91,6 +94,43 @@ function addFocusHandlers(element, styles, position, onFocus, onBlur) {
91
94
  onBlur === null || onBlur === void 0 ? void 0 : onBlur();
92
95
  });
93
96
  }
97
+ function createFieldLabel(text, forId, styles) {
98
+ const label = document.createElement('label');
99
+ label.htmlFor = forId;
100
+ label.textContent = text;
101
+ label.style.display = styles.label.show ? 'block' : 'none';
102
+ label.style.fontSize = styles.label.fontSize;
103
+ label.style.fontWeight = styles.label.fontWeight;
104
+ label.style.fontFamily = styles.label.fontFamily;
105
+ label.style.color = styles.label.color;
106
+ label.style.marginBottom = styles.label.marginBottom;
107
+ return label;
108
+ }
109
+ function wrapFieldWithLabel(field, labelText, styles) {
110
+ if (!styles.label.show)
111
+ return field;
112
+ const wrapper = document.createElement('div');
113
+ wrapper.style.display = 'flex';
114
+ wrapper.style.flexDirection = 'column';
115
+ if (field.style.flex) {
116
+ wrapper.style.flex = field.style.flex;
117
+ field.style.flex = '';
118
+ }
119
+ if (field.style.minWidth) {
120
+ wrapper.style.minWidth = field.style.minWidth;
121
+ }
122
+ if (field.style.maxWidth) {
123
+ wrapper.style.maxWidth = field.style.maxWidth;
124
+ }
125
+ if (field.style.flexBasis) {
126
+ wrapper.style.flexBasis = field.style.flexBasis;
127
+ field.style.flexBasis = '';
128
+ }
129
+ const label = createFieldLabel(labelText, field.id, styles);
130
+ wrapper.appendChild(label);
131
+ wrapper.appendChild(field);
132
+ return wrapper;
133
+ }
94
134
  function createFieldContainer(id, flex, minWidth, maxWidth) {
95
135
  const div = document.createElement('div');
96
136
  div.id = id;
@@ -175,3 +215,19 @@ function formatCanadianRoutingNumber(institutionNumber, transitNumber) {
175
215
  const transit = transitNumber.replace(/\D/g, '').padStart(5, '0');
176
216
  return '0' + institution + transit;
177
217
  }
218
+ function cssLengthToPixels(value) {
219
+ const num = parseFloat(value);
220
+ if (isNaN(num)) {
221
+ console.warn(`[cssLengthToPixels] Cannot parse "${value}", defaulting to 14px`);
222
+ return 14;
223
+ }
224
+ if (value.endsWith('rem'))
225
+ return num * 16;
226
+ if (value.endsWith('pt'))
227
+ return num * 1.333;
228
+ if (value.endsWith('px') || !value.match(/[a-z%]/i))
229
+ return num;
230
+ console.warn(`[cssLengthToPixels] Unsupported unit in "${value}". ` +
231
+ `Only px, rem, and pt are supported. Using ${num}px as approximation.`);
232
+ return num;
233
+ }
@@ -21,6 +21,15 @@ export interface TokenizerContainer {
21
21
  enableTestMode?: boolean;
22
22
  layout?: 'single-line' | 'two-line' | 'responsive';
23
23
  responsiveBreakpoint?: number;
24
+ placeholders?: {
25
+ cardNumber?: string;
26
+ expiry?: string;
27
+ expiryMonth?: string;
28
+ expiryYear?: string;
29
+ cvv?: string;
30
+ routingNumber?: string;
31
+ accountNumber?: string;
32
+ };
24
33
  }
25
34
  export interface TokenizerStylingComplete {
26
35
  input: {
@@ -59,6 +68,14 @@ export interface TokenizerStylingComplete {
59
68
  fontSize: string;
60
69
  textAlign: string;
61
70
  };
71
+ label: {
72
+ show: boolean;
73
+ fontSize: string;
74
+ fontWeight: string;
75
+ fontFamily: string;
76
+ color: string;
77
+ marginBottom: string;
78
+ };
62
79
  }
63
80
  type DeepPartial<T> = T extends object ? {
64
81
  [P in keyof T]?: DeepPartial<T[P]>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idonatedev/idonate-sdk",
3
3
  "author": "iDonate",
4
- "version": "1.2.0-dev17",
4
+ "version": "1.2.0-dev19",
5
5
  "sideEffects": false,
6
6
  "description": "iDonate Web SDK",
7
7
  "engines": {