@ohhwells/bridge 0.1.65-next.184 → 0.1.65-next.185
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/index.cjs +25 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6969,14 +6969,23 @@ function setFormViewState(form, formKey, state, initialText) {
|
|
|
6969
6969
|
success.style.display = state === "success" ? "" : "none";
|
|
6970
6970
|
}
|
|
6971
6971
|
var BOUND_ATTR = "data-ohw-form-bound";
|
|
6972
|
+
var publishedFormContext = {
|
|
6973
|
+
apiUrl: "",
|
|
6974
|
+
subdomain: "",
|
|
6975
|
+
content: {}
|
|
6976
|
+
};
|
|
6972
6977
|
function bindPublishedForms(apiUrl, subdomain, content = {}) {
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6978
|
+
publishedFormContext = { apiUrl, subdomain, content };
|
|
6979
|
+
if (document.documentElement.hasAttribute(BOUND_ATTR)) return;
|
|
6980
|
+
document.documentElement.setAttribute(BOUND_ATTR, "");
|
|
6981
|
+
document.addEventListener(
|
|
6982
|
+
"submit",
|
|
6983
|
+
async (e) => {
|
|
6984
|
+
const target = e.target;
|
|
6985
|
+
const form = target?.closest(FORM_SELECTOR);
|
|
6986
|
+
if (!form || !(form instanceof HTMLFormElement)) return;
|
|
6987
|
+
const formKey = formKeyOf(form);
|
|
6988
|
+
if (!formKey) return;
|
|
6980
6989
|
e.preventDefault();
|
|
6981
6990
|
clearSubmitError(form);
|
|
6982
6991
|
const submitButton = form.querySelector(
|
|
@@ -6984,7 +6993,8 @@ function bindPublishedForms(apiUrl, subdomain, content = {}) {
|
|
|
6984
6993
|
);
|
|
6985
6994
|
if (submitButton) submitButton.disabled = true;
|
|
6986
6995
|
try {
|
|
6987
|
-
const
|
|
6996
|
+
const { apiUrl: api, subdomain: site, content: latest } = publishedFormContext;
|
|
6997
|
+
const response = await fetch(`${api}/api/public/sites/${site}/forms/submissions`, {
|
|
6988
6998
|
method: "POST",
|
|
6989
6999
|
headers: { "Content-Type": "application/json" },
|
|
6990
7000
|
body: JSON.stringify({
|
|
@@ -6994,13 +7004,14 @@ function bindPublishedForms(apiUrl, subdomain, content = {}) {
|
|
|
6994
7004
|
})
|
|
6995
7005
|
});
|
|
6996
7006
|
if (!response.ok) throw new Error(`submit failed: ${response.status}`);
|
|
6997
|
-
showSuccess(form,
|
|
7007
|
+
showSuccess(form, latest[formSuccessKey(formKey)]);
|
|
6998
7008
|
} catch {
|
|
6999
7009
|
showSubmitError(form);
|
|
7000
7010
|
if (submitButton) submitButton.disabled = false;
|
|
7001
7011
|
}
|
|
7002
|
-
}
|
|
7003
|
-
|
|
7012
|
+
},
|
|
7013
|
+
true
|
|
7014
|
+
);
|
|
7004
7015
|
}
|
|
7005
7016
|
|
|
7006
7017
|
// src/lib/form-fields.ts
|
|
@@ -16914,6 +16925,9 @@ function OhhwellsBridge() {
|
|
|
16914
16925
|
reconcileSocialsFromContent(content);
|
|
16915
16926
|
applySocialsDisplayFromContent(content);
|
|
16916
16927
|
document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
|
|
16928
|
+
if (!form.querySelector("[data-ohw-form-success]")) {
|
|
16929
|
+
reconcileFieldsFromContent(form, content);
|
|
16930
|
+
}
|
|
16917
16931
|
listFieldWrappers(form).forEach(syncRequiredMark);
|
|
16918
16932
|
});
|
|
16919
16933
|
} finally {
|