@formbox/htmx 0.4.2 → 0.4.3

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.d.ts CHANGED
@@ -472,6 +472,8 @@ export declare type StackTemplateProperties = Omit<TemplateBase<StackProperties>
472
472
  readonly children: string;
473
473
  };
474
474
 
475
+ export declare const SUBMIT_ATTEMPTED_FIELD = "fb[submitAttempted]";
476
+
475
477
  export declare type TabContainerTemplateProperties = Omit<TemplateBase<TabContainerProperties>, "errors" | "header" | "items"> & {
476
478
  readonly header?: string | undefined;
477
479
  readonly errors?: string | undefined;
package/dist/index.js CHANGED
@@ -59459,6 +59459,7 @@ const templateNames = [
59459
59459
  const ACTION_FIELD = "fb[action]";
59460
59460
  const LANGUAGE_FIELD = "fb[language]";
59461
59461
  const PAGE_FIELD = "fb[page]";
59462
+ const SUBMIT_ATTEMPTED_FIELD = "fb[submitAttempted]";
59462
59463
  function valueName(path2, field) {
59463
59464
  return bracketName(["fb", "answer", ...pathParts(path2), field]);
59464
59465
  }
@@ -59956,10 +59957,15 @@ async function processStoreFormDataAsync(store, formData) {
59956
59957
  await applySubmittedState(store, formData);
59957
59958
  const actions = getActions(formData);
59958
59959
  actions.forEach((action2) => applyAction(store, action2));
59959
- if (actions.includes("submit")) {
59960
+ const submitted = actions.includes("submit");
59961
+ if (submitted || readSubmitAttempted(formData)) {
59962
+ const valid = store.validateAll();
59963
+ if (!submitted) {
59964
+ return { submitted: false };
59965
+ }
59960
59966
  return {
59961
59967
  submitted: true,
59962
- valid: store.validateAll()
59968
+ valid
59963
59969
  };
59964
59970
  }
59965
59971
  return { submitted: false };
@@ -61037,6 +61043,9 @@ function readBoolean(path2, formData) {
61037
61043
  function getActions(formData) {
61038
61044
  return formData.getAll(ACTION_FIELD).filter((value) => typeof value === "string");
61039
61045
  }
61046
+ function readSubmitAttempted(formData) {
61047
+ return getLastString(formData, SUBMIT_ATTEMPTED_FIELD) === "true";
61048
+ }
61040
61049
  function getLastString(formData, name) {
61041
61050
  return getStrings(formData, name).at(-1);
61042
61051
  }
@@ -62035,6 +62044,7 @@ function renderHiddenFieldsForStore(store) {
62035
62044
  ...store.footerNodes
62036
62045
  ]);
62037
62046
  return [
62047
+ store.isSubmitAttempted ? `<input type="hidden" name="${SUBMIT_ATTEMPTED_FIELD}" value="true">` : "",
62038
62048
  store.nodes.map(
62039
62049
  (node) => renderHiddenFieldsForNode(node, [], renderedNodes.has(node))
62040
62050
  ).join(""),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formbox/htmx",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Server-rendered HTMX HTML renderer for Formbox FHIR Questionnaires",
5
5
  "private": false,
6
6
  "type": "module",
@@ -32,8 +32,8 @@
32
32
  "react-dom": "^19.2.3",
33
33
  "@formbox/fhir": "0.4.0",
34
34
  "@formbox/renderer": "0.4.0",
35
- "@formbox/strings": "0.4.0",
36
- "@formbox/theme": "0.4.0"
35
+ "@formbox/theme": "0.4.0",
36
+ "@formbox/strings": "0.4.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@playwright/test": "^1.60.0",