@usefillo/react 0.5.0 → 0.5.1
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.js +12 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
createClient,
|
|
8
8
|
isField as isField2,
|
|
9
9
|
normalizeFormSchema,
|
|
10
|
-
normalizeFormTheme
|
|
10
|
+
normalizeFormTheme,
|
|
11
|
+
visibleFields as visibleFields2
|
|
11
12
|
} from "@usefillo/core";
|
|
12
13
|
|
|
13
14
|
// src/context.ts
|
|
@@ -130,7 +131,7 @@ function useCodeFormSync(form, client, onError) {
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
// src/fields.tsx
|
|
133
|
-
import { isField, pipeBlock, validateResponse } from "@usefillo/core";
|
|
134
|
+
import { isField, pipeBlock, validateResponse, visibleFields } from "@usefillo/core";
|
|
134
135
|
import { memo, useEffect as useEffect6, useState as useState5 } from "react";
|
|
135
136
|
|
|
136
137
|
// src/phone.tsx
|
|
@@ -1357,7 +1358,10 @@ function shouldAutoSubmit(field, value, api) {
|
|
|
1357
1358
|
})();
|
|
1358
1359
|
if (!hasDiscreteAnswer) return false;
|
|
1359
1360
|
if (value === api.data[field.id]) return false;
|
|
1360
|
-
|
|
1361
|
+
const nextData = { ...api.data, [field.id]: value };
|
|
1362
|
+
const visible = visibleFields(api.form, nextData);
|
|
1363
|
+
if (visible.length !== 1 || visible[0]?.id !== field.id) return false;
|
|
1364
|
+
return validateResponse(api.form, nextData).ok;
|
|
1361
1365
|
}
|
|
1362
1366
|
function blockHasPiping(block) {
|
|
1363
1367
|
const has = (s) => typeof s === "string" && s.includes("{{");
|
|
@@ -1486,8 +1490,10 @@ function focusFirstInvalid(formEl) {
|
|
|
1486
1490
|
function isAutoSubmitBlock(block) {
|
|
1487
1491
|
return isField2(block) && (block.kind === "select" || block.kind === "dropdown" || block.kind === "checkbox" || block.kind === "rating" || block.kind === "linear_scale");
|
|
1488
1492
|
}
|
|
1489
|
-
function needsExplicitSubmit(
|
|
1490
|
-
|
|
1493
|
+
function needsExplicitSubmit(visible) {
|
|
1494
|
+
if (visible.length === 0) return false;
|
|
1495
|
+
if (visible.length > 1) return true;
|
|
1496
|
+
return !isAutoSubmitBlock(visible[0]);
|
|
1491
1497
|
}
|
|
1492
1498
|
function FilloForm(props) {
|
|
1493
1499
|
const { form, formId } = props;
|
|
@@ -1623,7 +1629,7 @@ function ResolvedForm(props) {
|
|
|
1623
1629
|
}
|
|
1624
1630
|
const multiPage = api.pageCount > 1;
|
|
1625
1631
|
const autoSubmit = settings.submitMode === "auto";
|
|
1626
|
-
const showPrimaryButton = !autoSubmit || !api.isLastPage || needsExplicitSubmit(api.
|
|
1632
|
+
const showPrimaryButton = !autoSubmit || !api.isLastPage || needsExplicitSubmit(visibleFields2(api.form, api.data));
|
|
1627
1633
|
const showFooter = showPrimaryButton || multiPage && !api.isFirstPage;
|
|
1628
1634
|
return /* @__PURE__ */ jsx5(FilloContext.Provider, { value: api, children: /* @__PURE__ */ jsx5(FilloInstanceIdContext.Provider, { value: instanceId, children: /* @__PURE__ */ jsxs5(
|
|
1629
1635
|
"form",
|