skyflow-js 1.27.3 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -248,6 +248,9 @@ inputStyles: {
248
248
  padding: '10px 16px',
249
249
  borderRadius: '4px',
250
250
  color: '#1d1d1d',
251
+ '&:hover': { // Hover styles.
252
+ borderColor: 'green'
253
+ },
251
254
  },
252
255
  complete: {
253
256
  color: '#4caf50',
@@ -1333,6 +1336,150 @@ Sample Element state object when env is `PROD`
1333
1336
  value: ''
1334
1337
  }
1335
1338
  ```
1339
+
1340
+ ### Update composable elements
1341
+ You can update composable element properties with the `update` interface.
1342
+
1343
+
1344
+ The `update` interface takes the below object:
1345
+ ```javascript
1346
+ const updateElement = {
1347
+ table: 'string', // Optional. The table this data belongs to.
1348
+ column: 'string', // Optional. The column this data belongs to.
1349
+ inputStyles: {}, // Optional. Styles applied to the form element.
1350
+ labelStyles: {}, // Optional. Styles for the label of the element.
1351
+ errorTextStyles: {}, // Optional. Styles for the errorText of element.
1352
+ label: 'string', // Optional. Label for the form element.
1353
+ placeholder: 'string', // Optional. Placeholder for the form element.
1354
+ validations: [], // Optional. Array of validation rules.
1355
+ };
1356
+ ```
1357
+
1358
+ Only include the properties that you want to update for the specified composable element.
1359
+
1360
+ Properties your provided when you created the element remain the same until you explicitly update them.
1361
+
1362
+ `Note`: You can't update the `type` property of an element.
1363
+
1364
+ ### End to end example
1365
+ ```javascript
1366
+ const containerOptions = { layout: [2, 1] };
1367
+
1368
+ // Create a composable container.
1369
+ const composableContainer = skyflow.container(
1370
+ Skyflow.ContainerType.COMPOSABLE,
1371
+ containerOptions
1372
+ );
1373
+
1374
+ const stylesOptions = {
1375
+ inputStyles: {
1376
+ base: {
1377
+ fontFamily: 'Inter',
1378
+ fontStyle: 'normal',
1379
+ fontWeight: 400,
1380
+ fontSize: '14px',
1381
+ lineHeight: '21px',
1382
+ width: '294px',
1383
+ },
1384
+ },
1385
+ labelStyles: {},
1386
+ errorTextStyles: {
1387
+ base: {},
1388
+ },
1389
+ };
1390
+
1391
+ // Create composable elements.
1392
+ const cardHolderNameElement = composableContainer.create({
1393
+ table: 'pii_fields',
1394
+ column: 'first_name',
1395
+ ...stylesOptions,
1396
+ placeholder: 'Cardholder Name',
1397
+ type: Skyflow.ElementType.CARDHOLDER_NAME,
1398
+ });
1399
+
1400
+
1401
+ const cardNumberElement = composableContainer.create({
1402
+ table: 'pii_fields',
1403
+ column: 'card_number',
1404
+ ...stylesOptions,
1405
+ placeholder: 'Card Number',
1406
+ type: Skyflow.ElementType.CARD_NUMBER,
1407
+ });
1408
+
1409
+ const cvvElement = composableContainer.create({
1410
+ table: 'pii_fields',
1411
+ column: 'cvv',
1412
+ ...stylesOptions,
1413
+ placeholder: 'CVV',
1414
+ type: Skyflow.ElementType.CVV,
1415
+ });
1416
+
1417
+ // Mount the composable container.
1418
+ composableContainer.mount('#compostableContainer'); // Assumes there is a div with id='#composableContainer' in the webpage.
1419
+
1420
+ // ...
1421
+
1422
+ // Update validations property on cvvElement.
1423
+ cvvElement.update({
1424
+ validations: [{
1425
+ type: Skyflow.ValidationRuleType.LENGTH_MATCH_RULE,
1426
+ params: {
1427
+ max: 3,
1428
+ error: 'cvv must be 3 digits',
1429
+ },
1430
+ }]
1431
+ })
1432
+
1433
+ // Update label, placeholder properties on cardHolderNameElement.
1434
+ cardHolderNameElement.update({
1435
+ label: 'CARDHOLDER NAME',
1436
+ placeholder: 'Eg: John'
1437
+ });
1438
+
1439
+ // Update table, column, inputStyles properties on cardNumberElement.
1440
+ cardNumberElement.update({
1441
+ table:'cards',
1442
+ column:'card_number',
1443
+ inputStyles:{
1444
+ base:{
1445
+ color:'blue'
1446
+ }
1447
+ }
1448
+ });
1449
+
1450
+
1451
+ ```
1452
+ ### Set an event listener on a composable container
1453
+ Currently, the SDK supports one event:
1454
+ - `SUBMIT`: Triggered when the `Enter` key is pressed in any container element.
1455
+
1456
+ The handler `function(void) => void` is a callback function you provide that's called when the `SUBMIT' event fires.
1457
+
1458
+ ### Example
1459
+ ```javascript
1460
+ const containerOptions = { layout: [1] }
1461
+
1462
+ // Creating a composable container.
1463
+ const composableContainer = skyflow.container(Skyflow.ContainerType.COMPOSABLE, containerOptions);
1464
+
1465
+ // Creating the element.
1466
+ const cvv = composableContainer.create({
1467
+ table: 'pii_fields',
1468
+ column: 'primary_card.cvv',
1469
+ type: Skyflow.ElementType.CVV,
1470
+ });
1471
+
1472
+ // Mounting the container.
1473
+ composableContainer.mount('#cvvContainer');
1474
+
1475
+ // Subscribing to the `SUBMIT` event, which gets triggered when the user hits `enter` key in any container element input.
1476
+ composableContainer.on(Skyflow.EventName.SUBMIT, ()=> {
1477
+ // Your implementation when the SUBMIT(enter) event occurs.
1478
+ console.log('Submit Event Listener is being Triggered.');
1479
+ });
1480
+ ```
1481
+
1482
+
1336
1483
  ---
1337
1484
  # Securely revealing data client-side
1338
1485
  - [**Retrieving data from the vault**](#retrieving-data-from-the-vault)
@@ -1885,8 +2032,8 @@ cardNumberElement.mount('#collectCardNumber');
1885
2032
  fileElement.mount('#collectFile');
1886
2033
 
1887
2034
  // Collect and upload methods.
1888
- container.collect({});
1889
- container.uploadFiles();
2035
+ collectContainer.collect({});
2036
+ collectContainer.uploadFiles();
1890
2037
 
1891
2038
  ```
1892
2039
  **Sample Response for collect():**