@form-eng/core 1.1.1 → 1.2.0
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.mts +157 -42
- package/dist/index.d.ts +157 -42
- package/dist/index.js +207 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +192 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
package/dist/index.js
CHANGED
|
@@ -36,9 +36,11 @@ __export(index_exports, {
|
|
|
36
36
|
CheckValidDropdownOptions: () => CheckValidDropdownOptions,
|
|
37
37
|
ComponentTypes: () => ComponentTypes,
|
|
38
38
|
ConfirmInputsModal: () => ConfirmInputsModal_default,
|
|
39
|
+
DocumentLinksStrings: () => DocumentLinksStrings,
|
|
39
40
|
ExecuteComputedValue: () => ExecuteComputedValue,
|
|
40
41
|
FIELD_PARENT_PREFIX: () => FIELD_PARENT_PREFIX,
|
|
41
42
|
FieldArray: () => FieldArray,
|
|
43
|
+
FieldClassName: () => FieldClassName,
|
|
42
44
|
FieldWrapper: () => FieldWrapper,
|
|
43
45
|
FormConstants: () => FormConstants,
|
|
44
46
|
FormDevTools: () => FormDevTools,
|
|
@@ -50,11 +52,13 @@ __export(index_exports, {
|
|
|
50
52
|
GetComputedValuesOnCreate: () => GetComputedValuesOnCreate,
|
|
51
53
|
GetComputedValuesOnDirtyFields: () => GetComputedValuesOnDirtyFields,
|
|
52
54
|
GetConfirmInputModalProps: () => GetConfirmInputModalProps,
|
|
55
|
+
GetFieldDataTestId: () => GetFieldDataTestId,
|
|
53
56
|
GetFieldsToRender: () => GetFieldsToRender,
|
|
54
57
|
InitOnCreateFormState: () => InitOnCreateFormState,
|
|
55
58
|
InitOnEditFormState: () => InitOnEditFormState,
|
|
56
59
|
InjectedFieldProvider: () => InjectedFieldProvider,
|
|
57
60
|
IsExpandVisible: () => IsExpandVisible,
|
|
61
|
+
MAX_FILE_SIZE_MB_DEFAULT: () => MAX_FILE_SIZE_MB_DEFAULT,
|
|
58
62
|
RenderField: () => RenderField_default,
|
|
59
63
|
RulesEngineActionType: () => RulesEngineActionType,
|
|
60
64
|
RulesEngineProvider: () => RulesEngineProvider,
|
|
@@ -82,6 +86,7 @@ __export(index_exports, {
|
|
|
82
86
|
detectDependencyCycles: () => detectDependencyCycles,
|
|
83
87
|
detectSelfDependencies: () => detectSelfDependencies,
|
|
84
88
|
disableRuleTracing: () => disableRuleTracing,
|
|
89
|
+
ellipsifyText: () => ellipsifyText,
|
|
85
90
|
enableRuleTracing: () => enableRuleTracing,
|
|
86
91
|
evaluateAffectedFields: () => evaluateAffectedFields,
|
|
87
92
|
evaluateAllRules: () => evaluateAllRules,
|
|
@@ -89,12 +94,19 @@ __export(index_exports, {
|
|
|
89
94
|
evaluateExpression: () => evaluateExpression,
|
|
90
95
|
executeValueFunction: () => executeValueFunction,
|
|
91
96
|
extractConditionDependencies: () => extractConditionDependencies,
|
|
97
|
+
extractDigits: () => extractDigits,
|
|
92
98
|
extractExpressionDependencies: () => extractExpressionDependencies,
|
|
93
99
|
extractFunctionDependencies: () => extractFunctionDependencies,
|
|
94
100
|
flushRenderCycle: () => flushRenderCycle,
|
|
101
|
+
formatDateRange: () => formatDateRange,
|
|
102
|
+
formatDateTime: () => formatDateTime,
|
|
103
|
+
formatDateTimeValue: () => formatDateTimeValue,
|
|
104
|
+
formatPhone: () => formatPhone,
|
|
95
105
|
fromRjsfSchema: () => fromRjsfSchema,
|
|
96
106
|
getAllValidatorMetadata: () => getAllValidatorMetadata,
|
|
97
107
|
getCurrentLocale: () => getCurrentLocale,
|
|
108
|
+
getFieldState: () => getFieldState,
|
|
109
|
+
getFileNames: () => getFileNames,
|
|
98
110
|
getLastRenderedFields: () => getLastRenderedFields,
|
|
99
111
|
getLocaleString: () => getLocaleString,
|
|
100
112
|
getRenderCounts: () => getRenderCounts,
|
|
@@ -634,7 +646,27 @@ function resetValueFunctionRegistry() {
|
|
|
634
646
|
}
|
|
635
647
|
|
|
636
648
|
// src/helpers/ExpressionEngine.ts
|
|
649
|
+
var import_expr_eval = require("expr-eval");
|
|
650
|
+
var _parser = new import_expr_eval.Parser();
|
|
651
|
+
var _origAdd = _parser.binaryOps["+"];
|
|
652
|
+
_parser.binaryOps["+"] = (a, b) => {
|
|
653
|
+
if (typeof a === "string" || typeof b === "string") return String(a) + String(b);
|
|
654
|
+
return _origAdd(a, b);
|
|
655
|
+
};
|
|
656
|
+
_parser.consts["NaN"] = NaN;
|
|
637
657
|
function evaluateExpression(expression, values, fieldName, parentEntity, currentUserId) {
|
|
658
|
+
const singleFnMatch = /^\s*\$fn\.([a-zA-Z_][a-zA-Z0-9_]*)\(\)\s*$/.exec(expression);
|
|
659
|
+
if (singleFnMatch) {
|
|
660
|
+
const fn = getValueFunction(singleFnMatch[1]);
|
|
661
|
+
if (!fn) return void 0;
|
|
662
|
+
return fn({
|
|
663
|
+
fieldName: fieldName ?? "",
|
|
664
|
+
fieldValue: fieldName ? values[fieldName] : void 0,
|
|
665
|
+
values,
|
|
666
|
+
parentEntity,
|
|
667
|
+
currentUserId
|
|
668
|
+
});
|
|
669
|
+
}
|
|
638
670
|
let resolved = expression.replace(
|
|
639
671
|
/\$fn\.([a-zA-Z_][a-zA-Z0-9_]*)\(\)/g,
|
|
640
672
|
(_, fnName) => {
|
|
@@ -647,48 +679,35 @@ function evaluateExpression(expression, values, fieldName, parentEntity, current
|
|
|
647
679
|
parentEntity,
|
|
648
680
|
currentUserId
|
|
649
681
|
});
|
|
650
|
-
if (result === null || result === void 0) return "
|
|
682
|
+
if (result === null || result === void 0) return "NaN";
|
|
651
683
|
if (typeof result === "string") return JSON.stringify(result);
|
|
652
|
-
if (result instanceof Date) return
|
|
684
|
+
if (result instanceof Date) return String(result.getTime());
|
|
653
685
|
return String(result);
|
|
654
686
|
}
|
|
655
|
-
return "
|
|
687
|
+
return "NaN";
|
|
656
688
|
}
|
|
657
689
|
);
|
|
690
|
+
const serializeValue = (value) => {
|
|
691
|
+
if (value === null || value === void 0) return "NaN";
|
|
692
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
693
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
694
|
+
if (value instanceof Date) return String(value.getTime());
|
|
695
|
+
return String(value);
|
|
696
|
+
};
|
|
658
697
|
resolved = resolved.replace(
|
|
659
698
|
/\$parent\.([a-zA-Z_][a-zA-Z0-9_.]*)/g,
|
|
660
|
-
(_, fieldPath) => {
|
|
661
|
-
const value = getNestedValue2(parentEntity ?? {}, fieldPath);
|
|
662
|
-
if (value === null || value === void 0) return "undefined";
|
|
663
|
-
if (typeof value === "string") return JSON.stringify(value);
|
|
664
|
-
return String(value);
|
|
665
|
-
}
|
|
699
|
+
(_, fieldPath) => serializeValue(getNestedValue2(parentEntity ?? {}, fieldPath))
|
|
666
700
|
);
|
|
667
701
|
resolved = resolved.replace(
|
|
668
702
|
/\$root\.([a-zA-Z_][a-zA-Z0-9_.]*)/g,
|
|
669
|
-
(_, fieldPath) =>
|
|
670
|
-
const value = getNestedValue2(values, fieldPath);
|
|
671
|
-
if (value === null || value === void 0) return "undefined";
|
|
672
|
-
if (typeof value === "string") return JSON.stringify(value);
|
|
673
|
-
return String(value);
|
|
674
|
-
}
|
|
703
|
+
(_, fieldPath) => serializeValue(getNestedValue2(values, fieldPath))
|
|
675
704
|
);
|
|
676
705
|
resolved = resolved.replace(
|
|
677
706
|
/\$values\.([a-zA-Z_][a-zA-Z0-9_.]*)/g,
|
|
678
|
-
(_, fieldPath) =>
|
|
679
|
-
const value = getNestedValue2(values, fieldPath);
|
|
680
|
-
if (value === null || value === void 0) return "undefined";
|
|
681
|
-
if (typeof value === "string") return JSON.stringify(value);
|
|
682
|
-
return String(value);
|
|
683
|
-
}
|
|
707
|
+
(_, fieldPath) => serializeValue(getNestedValue2(values, fieldPath))
|
|
684
708
|
);
|
|
685
709
|
try {
|
|
686
|
-
|
|
687
|
-
"Math",
|
|
688
|
-
"Date",
|
|
689
|
-
`"use strict"; return (${resolved});`
|
|
690
|
-
);
|
|
691
|
-
return safeEval(Math, Date);
|
|
710
|
+
return _parser.evaluate(resolved, {});
|
|
692
711
|
} catch {
|
|
693
712
|
return void 0;
|
|
694
713
|
}
|
|
@@ -1794,7 +1813,7 @@ var FieldArray = (props) => {
|
|
|
1794
1813
|
|
|
1795
1814
|
// src/components/InlineForm.tsx
|
|
1796
1815
|
var import_react11 = __toESM(require("react"));
|
|
1797
|
-
var
|
|
1816
|
+
var import_react_hook_form5 = require("react-hook-form");
|
|
1798
1817
|
|
|
1799
1818
|
// src/hooks/useFormAnalytics.ts
|
|
1800
1819
|
var import_react5 = require("react");
|
|
@@ -1990,6 +2009,7 @@ var RenderField = (props) => {
|
|
|
1990
2009
|
readOnly,
|
|
1991
2010
|
disabled,
|
|
1992
2011
|
options,
|
|
2012
|
+
optionsLoading,
|
|
1993
2013
|
validate,
|
|
1994
2014
|
parentEntityId,
|
|
1995
2015
|
parentEntityType,
|
|
@@ -2084,6 +2104,7 @@ var RenderField = (props) => {
|
|
|
2084
2104
|
savePending,
|
|
2085
2105
|
config,
|
|
2086
2106
|
options,
|
|
2107
|
+
optionsLoading,
|
|
2087
2108
|
label,
|
|
2088
2109
|
type,
|
|
2089
2110
|
description,
|
|
@@ -2116,6 +2137,7 @@ var RenderField = (props) => {
|
|
|
2116
2137
|
readOnly,
|
|
2117
2138
|
disabled,
|
|
2118
2139
|
options,
|
|
2140
|
+
optionsLoading,
|
|
2119
2141
|
softHidden,
|
|
2120
2142
|
renderLabel,
|
|
2121
2143
|
renderError,
|
|
@@ -2256,6 +2278,7 @@ var ConfirmInputsModal_default = ConfirmInputsModal;
|
|
|
2256
2278
|
|
|
2257
2279
|
// src/components/InlineFormFields.tsx
|
|
2258
2280
|
var import_react10 = __toESM(require("react"));
|
|
2281
|
+
var import_react_hook_form4 = require("react-hook-form");
|
|
2259
2282
|
|
|
2260
2283
|
// src/components/FormErrorBoundary.tsx
|
|
2261
2284
|
var import_react9 = __toESM(require("react"));
|
|
@@ -2315,6 +2338,33 @@ var FormFields = (props) => {
|
|
|
2315
2338
|
renderStatus,
|
|
2316
2339
|
analytics
|
|
2317
2340
|
} = props;
|
|
2341
|
+
const [asyncOptions, setAsyncOptions] = import_react10.default.useState({});
|
|
2342
|
+
const [asyncOptionsLoading, setAsyncOptionsLoading] = import_react10.default.useState({});
|
|
2343
|
+
const asyncCacheKeyRef = import_react10.default.useRef({});
|
|
2344
|
+
const { getValues } = (0, import_react_hook_form4.useFormContext)();
|
|
2345
|
+
import_react10.default.useEffect(() => {
|
|
2346
|
+
if (!fields) return;
|
|
2347
|
+
Object.entries(fields).forEach(([fieldId, fieldConfig]) => {
|
|
2348
|
+
if (!fieldConfig.loadOptions) return;
|
|
2349
|
+
const depValues = (fieldConfig.optionsDependsOn ?? []).reduce(
|
|
2350
|
+
(acc, dep) => {
|
|
2351
|
+
acc[dep] = getValues(dep);
|
|
2352
|
+
return acc;
|
|
2353
|
+
},
|
|
2354
|
+
{}
|
|
2355
|
+
);
|
|
2356
|
+
const cacheKey = JSON.stringify(depValues);
|
|
2357
|
+
if (asyncCacheKeyRef.current[fieldId] === cacheKey) return;
|
|
2358
|
+
asyncCacheKeyRef.current[fieldId] = cacheKey;
|
|
2359
|
+
setAsyncOptionsLoading((prev) => ({ ...prev, [fieldId]: true }));
|
|
2360
|
+
fieldConfig.loadOptions({ fieldId, values: getValues() }).then((options) => {
|
|
2361
|
+
setAsyncOptions((prev) => ({ ...prev, [fieldId]: options }));
|
|
2362
|
+
}).catch(() => {
|
|
2363
|
+
}).finally(() => {
|
|
2364
|
+
setAsyncOptionsLoading((prev) => ({ ...prev, [fieldId]: false }));
|
|
2365
|
+
});
|
|
2366
|
+
});
|
|
2367
|
+
});
|
|
2318
2368
|
const collapsedClass = !isExpanded && (expandEnabled || expandEnabled === void 0) ? "collapsed" : "";
|
|
2319
2369
|
const fieldsToRender = GetFieldsToRender(fieldRenderLimit ?? 0, fieldOrder ?? [], formState?.fieldStates);
|
|
2320
2370
|
const loadingKey = `${programName}-${entityType}-${entityId}-form-loaded`;
|
|
@@ -2342,7 +2392,8 @@ var FormFields = (props) => {
|
|
|
2342
2392
|
hidden: fieldState.hidden,
|
|
2343
2393
|
required: fieldState.required,
|
|
2344
2394
|
readOnly: fieldState.readOnly,
|
|
2345
|
-
options: fieldState.options,
|
|
2395
|
+
options: asyncOptions[fieldName] ?? fieldState.options,
|
|
2396
|
+
optionsLoading: asyncOptionsLoading[fieldName] ?? false,
|
|
2346
2397
|
validate: fieldState.validate,
|
|
2347
2398
|
parentEntityId,
|
|
2348
2399
|
parentEntityType,
|
|
@@ -2400,9 +2451,13 @@ var FormEngine = (props) => {
|
|
|
2400
2451
|
renderDialog,
|
|
2401
2452
|
renderSaveButton,
|
|
2402
2453
|
formErrors,
|
|
2454
|
+
fieldErrors,
|
|
2403
2455
|
renderLabel,
|
|
2404
2456
|
renderError,
|
|
2405
|
-
renderStatus
|
|
2457
|
+
renderStatus,
|
|
2458
|
+
onSubmit: onSubmitProp,
|
|
2459
|
+
onSubmitError,
|
|
2460
|
+
renderSubmitButton
|
|
2406
2461
|
} = props;
|
|
2407
2462
|
const fields = formConfig?.fields ?? props.fieldConfigs ?? {};
|
|
2408
2463
|
const formSettings = formConfig?.settings;
|
|
@@ -2422,7 +2477,7 @@ var FormEngine = (props) => {
|
|
|
2422
2477
|
const [inputFieldsConfirmed, setInputFieldsConfirmed] = import_react11.default.useState(true);
|
|
2423
2478
|
const [filterText, setFilterText] = import_react11.default.useState();
|
|
2424
2479
|
const [statusMessage, setStatusMessage] = import_react11.default.useState("");
|
|
2425
|
-
const formMethods = (0,
|
|
2480
|
+
const formMethods = (0, import_react_hook_form5.useForm)({ mode: "onChange", defaultValues });
|
|
2426
2481
|
const { reset, resetField, handleSubmit, trigger, setValue, getValues, setError, clearErrors, formState } = formMethods;
|
|
2427
2482
|
const rulesStateRef = import_react11.default.useRef(rulesState);
|
|
2428
2483
|
const formStateRef = import_react11.default.useRef({ ...formState });
|
|
@@ -2438,6 +2493,12 @@ var FormEngine = (props) => {
|
|
|
2438
2493
|
import_react11.default.useEffect(() => {
|
|
2439
2494
|
initForm(defaultValues);
|
|
2440
2495
|
}, [areAllFieldsReadonly]);
|
|
2496
|
+
import_react11.default.useEffect(() => {
|
|
2497
|
+
if (!fieldErrors) return;
|
|
2498
|
+
Object.entries(fieldErrors).forEach(([fieldName, message]) => {
|
|
2499
|
+
setError(fieldName, { type: "server", message });
|
|
2500
|
+
});
|
|
2501
|
+
}, [fieldErrors]);
|
|
2441
2502
|
const initForm = (entityData) => {
|
|
2442
2503
|
const { formState: loadedState, initEntityData } = isCreate ? InitOnCreateFormState(configName, fields, entityData, parentEntity ?? {}, currentUserId ?? "", setValue, initFormState) : InitOnEditFormState(configName, fields, entityData, areAllFieldsReadonly ?? false, initFormState);
|
|
2443
2504
|
setExpandEnabled(IsExpandVisible(loadedState.fieldStates, effectiveExpandCutoff));
|
|
@@ -2583,6 +2644,26 @@ var FormEngine = (props) => {
|
|
|
2583
2644
|
}
|
|
2584
2645
|
});
|
|
2585
2646
|
};
|
|
2647
|
+
const handleFormSubmit = import_react11.default.useCallback(() => {
|
|
2648
|
+
if (!onSubmitProp) return;
|
|
2649
|
+
const cfg = rulesStateRef.current.configs[configName];
|
|
2650
|
+
if (cfg?.fieldStates) {
|
|
2651
|
+
Object.keys(cfg.fieldStates).forEach((fieldName) => {
|
|
2652
|
+
if (cfg.fieldStates[fieldName]?.hidden) clearErrors(fieldName);
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2655
|
+
trigger().then((valid) => {
|
|
2656
|
+
if (!valid) {
|
|
2657
|
+
setIsExpanded(true);
|
|
2658
|
+
(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : setTimeout)(() => focusFirstError());
|
|
2659
|
+
onSubmitError?.(formStateRef.current.errors);
|
|
2660
|
+
} else {
|
|
2661
|
+
const values = formMethods.getValues();
|
|
2662
|
+
Promise.resolve(onSubmitProp(values)).catch(() => {
|
|
2663
|
+
});
|
|
2664
|
+
}
|
|
2665
|
+
});
|
|
2666
|
+
}, [onSubmitProp, onSubmitError, configName, trigger, clearErrors]);
|
|
2586
2667
|
const onFilterChange = import_react11.default.useCallback((value) => {
|
|
2587
2668
|
if (filterTimeoutRef.current) clearTimeout(filterTimeoutRef.current);
|
|
2588
2669
|
filterTimeoutRef.current = setTimeout(() => setFilterText(value), 500);
|
|
@@ -2601,7 +2682,7 @@ var FormEngine = (props) => {
|
|
|
2601
2682
|
confirmInputModalProps.current = void 0;
|
|
2602
2683
|
};
|
|
2603
2684
|
const cutoff = expandEnabled && !isExpanded ? effectiveExpandCutoff ?? FormConstants.defaultExpandCutoffCount : void 0;
|
|
2604
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_hook_form5.FormProvider, { ...formMethods, formState: { ...formMethods.formState, isDirty, isValid, dirtyFields, errors, isSubmitting, isSubmitSuccessful }, children: [
|
|
2605
2686
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "status", "aria-live": "polite", className: "sr-only", style: { position: "absolute", width: "1px", height: "1px", padding: 0, margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", border: 0 }, "data-testid": "form-status-live-region", children: statusMessage }),
|
|
2606
2687
|
enableFilter && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "fe-filter", children: renderFilterInput ? renderFilterInput({ onChange: onFilterChange }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { type: "text", placeholder: FormStrings.filterFields, "aria-label": FormStrings.filterFields, onChange: (e) => onFilterChange(e.target.value), className: "fe-filter-input" }) }),
|
|
2607
2688
|
formErrors && formErrors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "form-errors", role: "alert", style: { color: "var(--fe-error-color, #d13438)", padding: "8px", marginBottom: "8px" }, children: formErrors.map((err, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "form-error-item", children: err }, i)) }),
|
|
@@ -2638,7 +2719,8 @@ var FormEngine = (props) => {
|
|
|
2638
2719
|
reset();
|
|
2639
2720
|
initForm(defaultValues);
|
|
2640
2721
|
}, disabled: !isDirty || isSubmitting, children: FormStrings.cancel })
|
|
2641
|
-
] }))
|
|
2722
|
+
] })),
|
|
2723
|
+
onSubmitProp && (renderSubmitButton ? renderSubmitButton({ onSubmit: handleFormSubmit, isDirty, isValid, isSubmitting }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "fe-submit-actions", style: { marginTop: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "submit-button", onClick: handleFormSubmit, disabled: isSubmitting, children: FormStrings.save }) }))
|
|
2642
2724
|
] }),
|
|
2643
2725
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2644
2726
|
ConfirmInputsModal_default,
|
|
@@ -4267,6 +4349,86 @@ function useBeforeUnload(shouldWarn, message, onAbandonment) {
|
|
|
4267
4349
|
}, [shouldWarn, message]);
|
|
4268
4350
|
}
|
|
4269
4351
|
|
|
4352
|
+
// src/helpers/FieldUtils.ts
|
|
4353
|
+
var GetFieldDataTestId = (fieldName, programName, entityType, entityId) => {
|
|
4354
|
+
return `${programName}-${entityType}-${entityId}-${fieldName}`;
|
|
4355
|
+
};
|
|
4356
|
+
var FieldClassName = (className, error) => {
|
|
4357
|
+
return error ? `${className} error` : className;
|
|
4358
|
+
};
|
|
4359
|
+
function getFieldState(props) {
|
|
4360
|
+
if (props.error) return "error";
|
|
4361
|
+
if (props.required) return "required";
|
|
4362
|
+
if (props.readOnly) return "readonly";
|
|
4363
|
+
if (props.disabled) return "disabled";
|
|
4364
|
+
return void 0;
|
|
4365
|
+
}
|
|
4366
|
+
function formatDateTime(dateStr, options) {
|
|
4367
|
+
if (!dateStr) return "";
|
|
4368
|
+
const date = new Date(dateStr);
|
|
4369
|
+
if (isNaN(date.getTime())) return dateStr;
|
|
4370
|
+
if (options?.hideTimestamp) {
|
|
4371
|
+
return date.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
|
|
4372
|
+
}
|
|
4373
|
+
return date.toLocaleString(void 0, { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" });
|
|
4374
|
+
}
|
|
4375
|
+
function formatDateTimeValue(value) {
|
|
4376
|
+
if (!value) return "";
|
|
4377
|
+
try {
|
|
4378
|
+
return formatDateTime(value);
|
|
4379
|
+
} catch {
|
|
4380
|
+
return String(value);
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
function formatDateRange(value) {
|
|
4384
|
+
if (!value) return "";
|
|
4385
|
+
const v = value;
|
|
4386
|
+
if (!v.start && !v.end) return "";
|
|
4387
|
+
if (v.start && v.end) return `${v.start} \u2013 ${v.end}`;
|
|
4388
|
+
return v.start || v.end;
|
|
4389
|
+
}
|
|
4390
|
+
function getFileNames(value) {
|
|
4391
|
+
if (!value) return "";
|
|
4392
|
+
if (Array.isArray(value)) return value.map((f) => f.name).join(", ");
|
|
4393
|
+
return value.name ?? "";
|
|
4394
|
+
}
|
|
4395
|
+
function extractDigits(value) {
|
|
4396
|
+
return value.replace(/\D/g, "");
|
|
4397
|
+
}
|
|
4398
|
+
function formatPhone(digits, format) {
|
|
4399
|
+
if (format === "raw") return digits;
|
|
4400
|
+
if (format === "international") {
|
|
4401
|
+
const d2 = digits.slice(0, 12);
|
|
4402
|
+
if (d2.length === 0) return "";
|
|
4403
|
+
if (d2.length <= 1) return `+${d2}`;
|
|
4404
|
+
if (d2.length <= 4) return `+${d2[0]} ${d2.slice(1)}`;
|
|
4405
|
+
if (d2.length <= 7) return `+${d2[0]} ${d2.slice(1, 4)} ${d2.slice(4)}`;
|
|
4406
|
+
return `+${d2[0]} ${d2.slice(1, 4)} ${d2.slice(4, 7)} ${d2.slice(7)}`;
|
|
4407
|
+
}
|
|
4408
|
+
const d = digits.slice(0, 10);
|
|
4409
|
+
if (d.length === 0) return "";
|
|
4410
|
+
if (d.length <= 3) return `(${d}`;
|
|
4411
|
+
if (d.length <= 6) return `(${d.slice(0, 3)}) ${d.slice(3)}`;
|
|
4412
|
+
return `(${d.slice(0, 3)}) ${d.slice(3, 6)}-${d.slice(6)}`;
|
|
4413
|
+
}
|
|
4414
|
+
function ellipsifyText(value, maxChars) {
|
|
4415
|
+
if (!value || value.length <= maxChars) return value ?? "";
|
|
4416
|
+
const cutoff = maxChars - 3;
|
|
4417
|
+
return `${value.substring(0, cutoff)}...`;
|
|
4418
|
+
}
|
|
4419
|
+
var MAX_FILE_SIZE_MB_DEFAULT = 10;
|
|
4420
|
+
var DocumentLinksStrings = {
|
|
4421
|
+
link: "Link",
|
|
4422
|
+
addLink: "Add Link",
|
|
4423
|
+
addAnotherLink: "Add Another Link",
|
|
4424
|
+
deleteLink: "Delete Link",
|
|
4425
|
+
confirmDeleteLink: "Are you sure you want to delete",
|
|
4426
|
+
delete: "Delete",
|
|
4427
|
+
cancel: "Cancel",
|
|
4428
|
+
saveChanges: "Save Changes",
|
|
4429
|
+
save: "Save"
|
|
4430
|
+
};
|
|
4431
|
+
|
|
4270
4432
|
// src/helpers/RuleTracer.ts
|
|
4271
4433
|
var traceEnabled = false;
|
|
4272
4434
|
var traceLog = [];
|
|
@@ -4303,9 +4465,11 @@ function isRuleTracingEnabled() {
|
|
|
4303
4465
|
CheckValidDropdownOptions,
|
|
4304
4466
|
ComponentTypes,
|
|
4305
4467
|
ConfirmInputsModal,
|
|
4468
|
+
DocumentLinksStrings,
|
|
4306
4469
|
ExecuteComputedValue,
|
|
4307
4470
|
FIELD_PARENT_PREFIX,
|
|
4308
4471
|
FieldArray,
|
|
4472
|
+
FieldClassName,
|
|
4309
4473
|
FieldWrapper,
|
|
4310
4474
|
FormConstants,
|
|
4311
4475
|
FormDevTools,
|
|
@@ -4317,11 +4481,13 @@ function isRuleTracingEnabled() {
|
|
|
4317
4481
|
GetComputedValuesOnCreate,
|
|
4318
4482
|
GetComputedValuesOnDirtyFields,
|
|
4319
4483
|
GetConfirmInputModalProps,
|
|
4484
|
+
GetFieldDataTestId,
|
|
4320
4485
|
GetFieldsToRender,
|
|
4321
4486
|
InitOnCreateFormState,
|
|
4322
4487
|
InitOnEditFormState,
|
|
4323
4488
|
InjectedFieldProvider,
|
|
4324
4489
|
IsExpandVisible,
|
|
4490
|
+
MAX_FILE_SIZE_MB_DEFAULT,
|
|
4325
4491
|
RenderField,
|
|
4326
4492
|
RulesEngineActionType,
|
|
4327
4493
|
RulesEngineProvider,
|
|
@@ -4349,6 +4515,7 @@ function isRuleTracingEnabled() {
|
|
|
4349
4515
|
detectDependencyCycles,
|
|
4350
4516
|
detectSelfDependencies,
|
|
4351
4517
|
disableRuleTracing,
|
|
4518
|
+
ellipsifyText,
|
|
4352
4519
|
enableRuleTracing,
|
|
4353
4520
|
evaluateAffectedFields,
|
|
4354
4521
|
evaluateAllRules,
|
|
@@ -4356,12 +4523,19 @@ function isRuleTracingEnabled() {
|
|
|
4356
4523
|
evaluateExpression,
|
|
4357
4524
|
executeValueFunction,
|
|
4358
4525
|
extractConditionDependencies,
|
|
4526
|
+
extractDigits,
|
|
4359
4527
|
extractExpressionDependencies,
|
|
4360
4528
|
extractFunctionDependencies,
|
|
4361
4529
|
flushRenderCycle,
|
|
4530
|
+
formatDateRange,
|
|
4531
|
+
formatDateTime,
|
|
4532
|
+
formatDateTimeValue,
|
|
4533
|
+
formatPhone,
|
|
4362
4534
|
fromRjsfSchema,
|
|
4363
4535
|
getAllValidatorMetadata,
|
|
4364
4536
|
getCurrentLocale,
|
|
4537
|
+
getFieldState,
|
|
4538
|
+
getFileNames,
|
|
4365
4539
|
getLastRenderedFields,
|
|
4366
4540
|
getLocaleString,
|
|
4367
4541
|
getRenderCounts,
|