Skip to content

Commit b6c38df

Browse files
Regan WolfromRegan Wolfrom
authored andcommitted
Added host protocol and trailing slash trim
(also README tweaks)
1 parent 9ace083 commit b6c38df

File tree

6 files changed

+45
-15
lines changed

6 files changed

+45
-15
lines changed

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@ FormKiQ Client SDK - JavaScript
33

44
**Note: This Initial Version comes with CommonJS and ES6 versions**
55

6+
## Installation
7+
```sh
8+
npm i formkiq-client-sdk-javascript
9+
```
10+
11+
FormKiQ Client SDK should now be available as part of your *node_modules*.
12+
613
## Instructions for Use (Web/CommonJS)
14+
Note: while these instructions are for including this SDK in a script tag, you can also use the ES6 version for frameworks such as Angular and React JS: ./node_modules/formkiq-client-sdk-javascript/dist/formkiq-client-sdk-es6.js
15+
716

817
```html
9-
<script type="text/javascript" src="./node_modules/formkiq-client-sdk-javascript/dist/cjs/formkiq-client-sdk-cjs.js"></script>
18+
<script type="text/javascript" src="./node_modules/formkiq-client-sdk-javascript/dist/web-cjs/formkiq-client-sdk-cjs.js"></script>
1019
<script type="text/javascript">
1120
1221
let formkiqClient;
1322
window.onload = () => {
1423
1524
// specify Host, Cognito User Pool Id, and Cognito Client Id
1625
formkiqClient = new FormkiqClient(
17-
'{FormKiQHttpApiUrl',
26+
'<ID>.execute-api.<REGION>.amazonaws.com',
1827
'{userPoolId}',
1928
'{clientId}'
2029
);
@@ -33,7 +42,7 @@ FormKiQ Client SDK - JavaScript
3342
</script>
3443
```
3544

36-
## Automatic Handling of Web Forms ("Auto-Wiring")
45+
## Automatic Handling of Web Forms
3746

3847
**Example: [Contact Form](https://github.com/formkiq/formkiq-webform-examples-contact)**
3948

@@ -45,7 +54,9 @@ To add processing to any web form using FormKiQ, add the class "fkq-form" to you
4554
<form class="fkq-form">
4655
```
4756

48-
No action or onsubmit is required or desired, as FormKiQ Web Form Handler will automatically create the submission action. A submit button is expected, to trigger the onsubmit event that the Web Form Handler uses to submit the form:
57+
No action or onsubmit is required or desired, as FormKiQ Web Form Handler will automatically create the submission action.
58+
59+
A submit button is expected, to trigger the onsubmit event that the Web Form Handler uses to submit the form:
4960

5061
```html
5162
<input
@@ -58,10 +69,10 @@ NOTE: You can use any input type, including **text inputs**, **passwords**, **ch
5869

5970
There are two callbacks included in the Web Form Handler:
6071
- **onFormSubmitted**(formName)
61-
- **onFormCompleted**(formName, response)
72+
- **onFormCompleted**(formName, response: {})
6273

63-
Validation has not yet been implemented; a simple implementation is next on our roadmap.
74+
Any input fields that should be required should include a "required" HTML Attribute, and those will prevent the form from submitting. To create custom validation rules, you should submit the form manually using **onsubmit**, and add extra validation in the triggered submit function.
6475

6576
## Submitting a Form Manually
6677

67-
You can also submit the form manually using **formkiqClient.webFormsHandler.submitFormkiqForm(thisForm);**
78+
You can submit the form manually using **formkiqClient.webFormsHandler.submitFormkiqForm(thisForm);**

build/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ To add processing to any web form using FormKiQ, add the class "fkq-form" to you
5454
<form class="fkq-form">
5555
```
5656

57-
No action or onsubmit is required or desired, as FormKiQ Web Form Handler will automatically create the submission action. A submit button is expected, to trigger the onsubmit event that the Web Form Handler uses to submit the form:
57+
No action or onsubmit is required or desired, as FormKiQ Web Form Handler will automatically create the submission action.
58+
59+
A submit button is expected, to trigger the onsubmit event that the Web Form Handler uses to submit the form:
5860

5961
```html
6062
<input
@@ -67,13 +69,13 @@ NOTE: You can use any input type, including **text inputs**, **passwords**, **ch
6769

6870
There are two callbacks included in the Web Form Handler:
6971
- **onFormSubmitted**(formName)
70-
- **onFormCompleted**(formName, response)
72+
- **onFormCompleted**(formName, response: {})
7173

72-
Validation has not yet been implemented; a simple implementation is next on our roadmap.
74+
Any input fields that should be required should include a "required" HTML Attribute, and those will prevent the form from submitting. To create custom validation rules, you should submit the form manually using **onsubmit**, and add extra validation in the triggered submit function.
7375

7476
## Submitting a Form Manually
7577

76-
You can also submit the form manually using **formkiqClient.webFormsHandler.submitFormkiqForm(thisForm);**
78+
You can submit the form manually using **formkiqClient.webFormsHandler.submitFormkiqForm(thisForm);**
7779

7880

7981

build/dist/web-cjs/formkiq-client-sdk-cjs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7860,7 +7860,8 @@ class ApiClient {
78607860

78617861
constructor(host, userPoolId, clientId) {
78627862
if (host) {
7863-
this.host = host;
7863+
host = host.replace('https://', '').replace(/\/+$/, '');
7864+
this.host = host;
78647865
}
78657866
if (userPoolId && clientId) {
78667867
this.buildCognitoClient(userPoolId, clientId);

build/package-lock.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"dependencies": {
2525
"@babel/plugin-transform-runtime": "^7.12.1",
2626
"amazon-cognito-identity-js": "^4.4.0",
27-
"buffer": "^5.6.0"
27+
"buffer": "^5.6.0",
28+
"rollup": "^2.33.3"
2829
},
2930
"devDependencies": {
3031
"@babel/core": "^7.12.3",

build/src/ApiClient.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export class ApiClient {
1616

1717
constructor(host, userPoolId, clientId) {
1818
if (host) {
19-
this.host = host;
19+
host = host.replace('https://', '').replace(/\/+$/, '');
20+
this.host = host;
2021
}
2122
if (userPoolId && clientId) {
2223
this.buildCognitoClient(userPoolId, clientId);

0 commit comments

Comments
 (0)