@codebards/ik-embeddable-form 0.0.2715012971-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 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
- snapshot[key] = value;
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[`${key}_label`] = label;
135
+ if (label) snapshot[`${snakeKey}_label`] = label;
132
136
  });
133
137
  return snapshot;
134
138
  }
@@ -1303,14 +1307,6 @@ var IKEmbeddableFormBundle = function(exports) {
1303
1307
  function clearPrefillCookies() {
1304
1308
  clearContactPrefillCookies();
1305
1309
  }
1306
- function getPrefillFromCookies() {
1307
- const prefill = {};
1308
- const experience = getCookie("ik_experience");
1309
- const domain = getCookie("ik_domain");
1310
- if (experience) prefill.experience = experience;
1311
- if (domain) prefill.domain = domain;
1312
- return prefill;
1313
- }
1314
1310
  function isClarityLoaded() {
1315
1311
  return typeof window !== "undefined" && typeof window.clarity === "function";
1316
1312
  }
@@ -1446,11 +1442,6 @@ var IKEmbeddableFormBundle = function(exports) {
1446
1442
  const vCountryCode = geo.countryCode || vCountryFromCookie && countryNameToCode(vCountryFromCookie) || "";
1447
1443
  persistVisitorCountryCookieIfAbsent(geo.countryName);
1448
1444
  clearContactPrefillCookies();
1449
- const cookiePrefill = getPrefillFromCookies();
1450
- openConfig.prefilledValues = {
1451
- ...cookiePrefill,
1452
- ...openConfig.prefilledValues
1453
- };
1454
1445
  const pageUrl = resolveWorkflowPageUrl(openConfig.pageUrl);
1455
1446
  const browser = getBrowserDetails();
1456
1447
  contextInstance = {
@@ -2029,8 +2020,8 @@ var IKEmbeddableFormBundle = function(exports) {
2029
2020
  return this.config;
2030
2021
  }
2031
2022
  /**
2032
- * Allowlisted snapshot of the values captured so far, with `<field>_label`
2033
- * 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.
2034
2025
  *
2035
2026
  * This is the supported replacement for scraping the DOM: the profile fields
2036
2027
  * live in a shadow root and are unmounted once the user proceeds, so
@@ -20983,6 +20974,8 @@ ${intlTelStyles}`;
20983
20974
  * the fields render inside a shadow root and are unmounted as the user
20984
20975
  * advances, so this stays readable after submission and after the form closes.
20985
20976
  *
20977
+ * Keys are snake_case, with `<field>_label` companions for select fields:
20978
+ *
20986
20979
  * IKForm.getFormData().domain // 'backend-engineer'
20987
20980
  * IKForm.getFormData().domain_label // 'Backend Engineer'
20988
20981
  */