@codebards/ik-embeddable-form 0.0.2717298569-qa → 0.0.2717408259-qa
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/dist/embed.js +10 -4
- package/dist/embed.js.map +1 -1
- package/package.json +1 -1
package/dist/embed.js
CHANGED
|
@@ -119,6 +119,9 @@ var IKEmbeddableFormBundle = function(exports) {
|
|
|
119
119
|
function isPrimitive$1(value) {
|
|
120
120
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
121
121
|
}
|
|
122
|
+
function toSnakeCase(key) {
|
|
123
|
+
return key.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
|
|
124
|
+
}
|
|
122
125
|
function buildFormValues(formData, labels = {}, fields = ANALYTICS_VALUE_FIELDS) {
|
|
123
126
|
const snapshot = {};
|
|
124
127
|
fields.forEach((key) => {
|
|
@@ -126,9 +129,10 @@ var IKEmbeddableFormBundle = function(exports) {
|
|
|
126
129
|
const value = formData[key];
|
|
127
130
|
if (value === void 0 || value === null || value === "") return;
|
|
128
131
|
if (!isPrimitive$1(value)) return;
|
|
129
|
-
|
|
132
|
+
const snakeKey = toSnakeCase(key);
|
|
133
|
+
snapshot[snakeKey] = value;
|
|
130
134
|
const label = (_a = labels[key]) == null ? void 0 : _a[String(value)];
|
|
131
|
-
if (label) snapshot[`${
|
|
135
|
+
if (label) snapshot[`${snakeKey}_label`] = label;
|
|
132
136
|
});
|
|
133
137
|
return snapshot;
|
|
134
138
|
}
|
|
@@ -2016,8 +2020,8 @@ var IKEmbeddableFormBundle = function(exports) {
|
|
|
2016
2020
|
return this.config;
|
|
2017
2021
|
}
|
|
2018
2022
|
/**
|
|
2019
|
-
* Allowlisted snapshot of the values captured so far,
|
|
2020
|
-
* companions for select fields.
|
|
2023
|
+
* Allowlisted snapshot of the values captured so far, keyed in snake_case,
|
|
2024
|
+
* with `<field>_label` companions for select fields.
|
|
2021
2025
|
*
|
|
2022
2026
|
* This is the supported replacement for scraping the DOM: the profile fields
|
|
2023
2027
|
* live in a shadow root and are unmounted once the user proceeds, so
|
|
@@ -20970,6 +20974,8 @@ ${intlTelStyles}`;
|
|
|
20970
20974
|
* the fields render inside a shadow root and are unmounted as the user
|
|
20971
20975
|
* advances, so this stays readable after submission and after the form closes.
|
|
20972
20976
|
*
|
|
20977
|
+
* Keys are snake_case, with `<field>_label` companions for select fields:
|
|
20978
|
+
*
|
|
20973
20979
|
* IKForm.getFormData().domain // 'backend-engineer'
|
|
20974
20980
|
* IKForm.getFormData().domain_label // 'Backend Engineer'
|
|
20975
20981
|
*/
|