@bpmn-io/form-js-viewer 1.8.3 → 1.8.5
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/README.md +177 -189
- package/dist/assets/form-js-base.css +47 -39
- package/dist/assets/form-js.css +11 -26
- package/dist/index.cjs +450 -292
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +447 -293
- package/dist/index.es.js.map +1 -1
- package/dist/types/Form.d.ts +9 -13
- package/dist/types/core/FormFieldInstanceRegistry.d.ts +15 -0
- package/dist/types/core/Validator.d.ts +16 -1
- package/dist/types/core/index.d.ts +2 -0
- package/dist/types/features/expressionField/ExpressionLoopPreventer.d.ts +18 -0
- package/dist/types/features/expressionField/index.d.ts +6 -0
- package/dist/types/features/expressionLanguage/FeelersTemplating.d.ts +4 -4
- package/dist/types/features/index.d.ts +2 -0
- package/dist/types/features/viewerCommands/ViewerCommands.d.ts +6 -0
- package/dist/types/features/viewerCommands/cmd/UpdateFieldInstanceValidationHandler.d.ts +10 -0
- package/dist/types/features/viewerCommands/cmd/UpdateFieldValidationHandler.d.ts +3 -0
- package/dist/types/types.d.ts +34 -36
- package/dist/types/util/expressions.d.ts +17 -0
- package/dist/types/util/index.d.ts +1 -0
- package/dist/types/util/simple.d.ts +1 -7
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -10,6 +10,7 @@ import flatpickr from 'flatpickr';
|
|
|
10
10
|
import * as React from 'preact/compat';
|
|
11
11
|
import { createPortal } from 'preact/compat';
|
|
12
12
|
import DOMPurify from 'dompurify';
|
|
13
|
+
import { isEqual as isEqual$1 } from 'lodash';
|
|
13
14
|
import { Injector } from 'didi';
|
|
14
15
|
import { parseExpression, parseUnaryTests, evaluate, unaryTest } from 'feelin';
|
|
15
16
|
import { evaluate as evaluate$1, parser, buildSimpleTree } from 'feelers';
|
|
@@ -352,10 +353,10 @@ class FeelersTemplating {
|
|
|
352
353
|
}
|
|
353
354
|
|
|
354
355
|
/**
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
* @typedef {Object} ExpressionWithDepth
|
|
357
|
+
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
358
|
+
* @property {string} expression - The extracted expression
|
|
359
|
+
*/
|
|
359
360
|
|
|
360
361
|
/**
|
|
361
362
|
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
@@ -720,6 +721,20 @@ function generateIdForType(type) {
|
|
|
720
721
|
function clone(data, replacer) {
|
|
721
722
|
return JSON.parse(JSON.stringify(data, replacer));
|
|
722
723
|
}
|
|
724
|
+
function runRecursively(formField, fn) {
|
|
725
|
+
const components = formField.components || [];
|
|
726
|
+
components.forEach((component, _) => {
|
|
727
|
+
runRecursively(component, fn);
|
|
728
|
+
});
|
|
729
|
+
fn(formField);
|
|
730
|
+
}
|
|
731
|
+
function wrapObjectKeysWithUnderscores(obj) {
|
|
732
|
+
const newObj = {};
|
|
733
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
734
|
+
newObj[`_${key}_`] = value;
|
|
735
|
+
}
|
|
736
|
+
return newObj;
|
|
737
|
+
}
|
|
723
738
|
|
|
724
739
|
/**
|
|
725
740
|
* Transform a LocalExpressionContext object into a usable FEEL context.
|
|
@@ -736,25 +751,24 @@ function buildExpressionContext(context) {
|
|
|
736
751
|
return {
|
|
737
752
|
...specialContextKeys,
|
|
738
753
|
...data,
|
|
739
|
-
...
|
|
754
|
+
...wrapObjectKeysWithUnderscores(specialContextKeys)
|
|
740
755
|
};
|
|
741
756
|
}
|
|
742
|
-
function runRecursively(formField, fn) {
|
|
743
|
-
const components = formField.components || [];
|
|
744
|
-
components.forEach((component, index) => {
|
|
745
|
-
runRecursively(component, fn);
|
|
746
|
-
});
|
|
747
|
-
fn(formField);
|
|
748
|
-
}
|
|
749
757
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
758
|
+
/**
|
|
759
|
+
* Evaluate a string based on the expressionLanguage and context information.
|
|
760
|
+
* If the string is not an expression, it is returned as is.
|
|
761
|
+
*
|
|
762
|
+
* @param {any} expressionLanguage - The expression language to use.
|
|
763
|
+
* @param {string} value - The string to evaluate.
|
|
764
|
+
* @param {Object} expressionContextInfo - The context information to use.
|
|
765
|
+
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
766
|
+
*/
|
|
767
|
+
function runExpressionEvaluation(expressionLanguage, value, expressionContextInfo) {
|
|
768
|
+
if (expressionLanguage && expressionLanguage.isExpression(value)) {
|
|
769
|
+
return expressionLanguage.evaluate(value, buildExpressionContext(expressionContextInfo));
|
|
756
770
|
}
|
|
757
|
-
return
|
|
771
|
+
return value;
|
|
758
772
|
}
|
|
759
773
|
|
|
760
774
|
/**
|
|
@@ -887,12 +901,7 @@ function _isAllowedValue(value) {
|
|
|
887
901
|
function useExpressionEvaluation(value) {
|
|
888
902
|
const expressionLanguage = useService('expressionLanguage');
|
|
889
903
|
const expressionContextInfo = useContext(LocalExpressionContext);
|
|
890
|
-
return useMemo(() =>
|
|
891
|
-
if (expressionLanguage && expressionLanguage.isExpression(value)) {
|
|
892
|
-
return expressionLanguage.evaluate(value, buildExpressionContext(expressionContextInfo));
|
|
893
|
-
}
|
|
894
|
-
return value;
|
|
895
|
-
}, [expressionLanguage, expressionContextInfo, value]);
|
|
904
|
+
return useMemo(() => runExpressionEvaluation(expressionLanguage, value, expressionContextInfo), [expressionLanguage, expressionContextInfo, value]);
|
|
896
905
|
}
|
|
897
906
|
|
|
898
907
|
/**
|
|
@@ -1009,11 +1018,11 @@ const getDOMPurifyConfig = sanitizeStyleTags => {
|
|
|
1009
1018
|
};
|
|
1010
1019
|
};
|
|
1011
1020
|
|
|
1012
|
-
/**
|
|
1013
|
-
* A custom hook to build up security attributes from form configuration.
|
|
1014
|
-
*
|
|
1015
|
-
* @param {Object} security - The security configuration.
|
|
1016
|
-
* @returns {Array} - Returns a tuple with sandbox and allow attributes.
|
|
1021
|
+
/**
|
|
1022
|
+
* A custom hook to build up security attributes from form configuration.
|
|
1023
|
+
*
|
|
1024
|
+
* @param {Object} security - The security configuration.
|
|
1025
|
+
* @returns {Array} - Returns a tuple with sandbox and allow attributes.
|
|
1017
1026
|
*/
|
|
1018
1027
|
function useSecurityAttributesMap(security) {
|
|
1019
1028
|
const securityMemoized = useDeepCompareMemoize(security);
|
|
@@ -1769,7 +1778,6 @@ function Checkbox(props) {
|
|
|
1769
1778
|
target
|
|
1770
1779
|
}) => {
|
|
1771
1780
|
props.onChange({
|
|
1772
|
-
field,
|
|
1773
1781
|
value: target.checked
|
|
1774
1782
|
});
|
|
1775
1783
|
};
|
|
@@ -1848,7 +1856,6 @@ function Checklist(props) {
|
|
|
1848
1856
|
const toggleCheckbox = toggledValue => {
|
|
1849
1857
|
const newValues = hasEqualValue(toggledValue, values) ? values.filter(value => !isEqual(value, toggledValue)) : [...values, toggledValue];
|
|
1850
1858
|
props.onChange({
|
|
1851
|
-
field,
|
|
1852
1859
|
value: newValues
|
|
1853
1860
|
});
|
|
1854
1861
|
};
|
|
@@ -1936,10 +1943,11 @@ function FormField(props) {
|
|
|
1936
1943
|
const {
|
|
1937
1944
|
field,
|
|
1938
1945
|
indexes,
|
|
1939
|
-
onChange
|
|
1946
|
+
onChange: _onChange
|
|
1940
1947
|
} = props;
|
|
1941
1948
|
const formFields = useService('formFields'),
|
|
1942
1949
|
viewerCommands = useService('viewerCommands', false),
|
|
1950
|
+
formFieldInstanceRegistry = useService('formFieldInstanceRegistry', false),
|
|
1943
1951
|
pathRegistry = useService('pathRegistry'),
|
|
1944
1952
|
eventBus = useService('eventBus'),
|
|
1945
1953
|
form = useService('form');
|
|
@@ -1966,6 +1974,7 @@ function FormField(props) {
|
|
|
1966
1974
|
throw new Error(`cannot render field <${field.type}>`);
|
|
1967
1975
|
}
|
|
1968
1976
|
const fieldConfig = FormFieldComponent.config;
|
|
1977
|
+
const localExpressionContext = useContext(LocalExpressionContext);
|
|
1969
1978
|
const valuePath = useMemo(() => pathRegistry.getValuePath(field, {
|
|
1970
1979
|
indexes
|
|
1971
1980
|
}), [field, indexes, pathRegistry]);
|
|
@@ -1975,6 +1984,23 @@ function FormField(props) {
|
|
|
1975
1984
|
|
|
1976
1985
|
// add precedence: global readonly > form field disabled
|
|
1977
1986
|
const disabled = !properties.readOnly && (properties.disabled || field.disabled || false);
|
|
1987
|
+
const hidden = useCondition(field.conditional && field.conditional.hide || null);
|
|
1988
|
+
const fieldInstance = useMemo(() => ({
|
|
1989
|
+
id: field.id,
|
|
1990
|
+
expressionContextInfo: localExpressionContext,
|
|
1991
|
+
valuePath,
|
|
1992
|
+
indexes
|
|
1993
|
+
}), [field.id, valuePath, localExpressionContext, indexes]);
|
|
1994
|
+
|
|
1995
|
+
// register form field instance
|
|
1996
|
+
useEffect(() => {
|
|
1997
|
+
if (formFieldInstanceRegistry && !hidden) {
|
|
1998
|
+
const instanceId = formFieldInstanceRegistry.add(fieldInstance);
|
|
1999
|
+
return () => {
|
|
2000
|
+
formFieldInstanceRegistry.remove(instanceId);
|
|
2001
|
+
};
|
|
2002
|
+
}
|
|
2003
|
+
}, [fieldInstance, formFieldInstanceRegistry, hidden]);
|
|
1978
2004
|
|
|
1979
2005
|
// ensures the initial validation behavior can be re-triggered upon form reset
|
|
1980
2006
|
useEffect(() => {
|
|
@@ -1995,35 +2021,33 @@ function FormField(props) {
|
|
|
1995
2021
|
const hasInitialValue = initialValue && !isEqual(initialValue, []);
|
|
1996
2022
|
if (initialValidationTrigger && hasInitialValue) {
|
|
1997
2023
|
setInitialValidationTrigger(false);
|
|
1998
|
-
viewerCommands.
|
|
2024
|
+
viewerCommands.updateFieldInstanceValidation(fieldInstance, initialValue);
|
|
1999
2025
|
}
|
|
2000
|
-
}, [
|
|
2026
|
+
}, [fieldInstance, initialValidationTrigger, initialValue, viewerCommands]);
|
|
2001
2027
|
const onBlur = useCallback(() => {
|
|
2002
2028
|
const value = get(data, valuePath);
|
|
2003
2029
|
if (initialValidationTrigger) {
|
|
2004
2030
|
setInitialValidationTrigger(false);
|
|
2005
|
-
viewerCommands.
|
|
2031
|
+
viewerCommands.updateFieldInstanceValidation(fieldInstance, value);
|
|
2006
2032
|
}
|
|
2007
2033
|
eventBus.fire('formField.blur', {
|
|
2008
2034
|
formField: field
|
|
2009
2035
|
});
|
|
2010
|
-
}, [eventBus, field,
|
|
2036
|
+
}, [data, eventBus, field, fieldInstance, initialValidationTrigger, valuePath, viewerCommands]);
|
|
2011
2037
|
const onFocus = useCallback(() => {
|
|
2012
2038
|
eventBus.fire('formField.focus', {
|
|
2013
2039
|
formField: field
|
|
2014
2040
|
});
|
|
2015
2041
|
}, [eventBus, field]);
|
|
2016
|
-
const
|
|
2017
|
-
const onChangeIndexed = useCallback(update => {
|
|
2018
|
-
// any data change will trigger validation
|
|
2042
|
+
const onChange = useCallback(update => {
|
|
2019
2043
|
setInitialValidationTrigger(false);
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
}
|
|
2026
|
-
}, [
|
|
2044
|
+
_onChange({
|
|
2045
|
+
field,
|
|
2046
|
+
indexes,
|
|
2047
|
+
fieldInstance,
|
|
2048
|
+
...update
|
|
2049
|
+
});
|
|
2050
|
+
}, [_onChange, field, fieldInstance, indexes]);
|
|
2027
2051
|
if (hidden) {
|
|
2028
2052
|
return jsx(Hidden, {
|
|
2029
2053
|
field: field
|
|
@@ -2036,11 +2060,12 @@ function FormField(props) {
|
|
|
2036
2060
|
disabled: disabled,
|
|
2037
2061
|
errors: fieldErrors,
|
|
2038
2062
|
domId: domId,
|
|
2039
|
-
onChange: disabled || readonly ? noop$1 :
|
|
2063
|
+
onChange: disabled || readonly ? noop$1 : onChange,
|
|
2040
2064
|
onBlur: disabled || readonly ? noop$1 : onBlur,
|
|
2041
2065
|
onFocus: disabled || readonly ? noop$1 : onFocus,
|
|
2042
2066
|
readonly: readonly,
|
|
2043
|
-
value: value
|
|
2067
|
+
value: value,
|
|
2068
|
+
fieldInstance: fieldInstance
|
|
2044
2069
|
});
|
|
2045
2070
|
if (fieldConfig.escapeGridRender) {
|
|
2046
2071
|
return formFieldElement;
|
|
@@ -2158,7 +2183,7 @@ function RowsRenderer(props) {
|
|
|
2158
2183
|
Row
|
|
2159
2184
|
} = useContext(FormRenderContext);
|
|
2160
2185
|
return jsxs(Fragment, {
|
|
2161
|
-
children: [
|
|
2186
|
+
children: [' ', rows.map(row => {
|
|
2162
2187
|
const {
|
|
2163
2188
|
components = []
|
|
2164
2189
|
} = row;
|
|
@@ -2184,7 +2209,7 @@ function RowsRenderer(props) {
|
|
|
2184
2209
|
});
|
|
2185
2210
|
})
|
|
2186
2211
|
});
|
|
2187
|
-
}),
|
|
2212
|
+
}), ' ']
|
|
2188
2213
|
});
|
|
2189
2214
|
}
|
|
2190
2215
|
|
|
@@ -2314,23 +2339,23 @@ function InputAdorner(props) {
|
|
|
2314
2339
|
'fjs-disabled': disabled,
|
|
2315
2340
|
'fjs-readonly': readonly
|
|
2316
2341
|
}, {
|
|
2317
|
-
|
|
2342
|
+
hasErrors: hasErrors
|
|
2318
2343
|
}),
|
|
2319
2344
|
ref: rootRef,
|
|
2320
2345
|
children: [pre && jsxs("span", {
|
|
2321
2346
|
class: "fjs-input-adornment border-right border-radius-left",
|
|
2322
2347
|
onClick: onAdornmentClick,
|
|
2323
|
-
children: [
|
|
2348
|
+
children: [' ', isString(pre) ? jsx("span", {
|
|
2324
2349
|
class: "fjs-input-adornment-text",
|
|
2325
2350
|
children: pre
|
|
2326
|
-
}) : pre,
|
|
2351
|
+
}) : pre, ' ']
|
|
2327
2352
|
}), children, post && jsxs("span", {
|
|
2328
2353
|
class: "fjs-input-adornment border-left border-radius-right",
|
|
2329
2354
|
onClick: onAdornmentClick,
|
|
2330
|
-
children: [
|
|
2355
|
+
children: [' ', isString(post) ? jsx("span", {
|
|
2331
2356
|
class: "fjs-input-adornment-text",
|
|
2332
2357
|
children: post
|
|
2333
|
-
}) : post,
|
|
2358
|
+
}) : post, ' ']
|
|
2334
2359
|
})]
|
|
2335
2360
|
});
|
|
2336
2361
|
}
|
|
@@ -2379,7 +2404,9 @@ function Datepicker(props) {
|
|
|
2379
2404
|
clickOpens: false,
|
|
2380
2405
|
// TODO: support dates prior to 1900 (https://github.com/bpmn-io/form-js/issues/533)
|
|
2381
2406
|
minDate: disallowPassedDates ? 'today' : '01/01/1900',
|
|
2382
|
-
errorHandler: () => {
|
|
2407
|
+
errorHandler: () => {
|
|
2408
|
+
/* do nothing, we expect the values to sometimes be erronous and we don't want warnings polluting the console */
|
|
2409
|
+
}
|
|
2383
2410
|
};
|
|
2384
2411
|
const instance = flatpickr(dateInputRef.current, config);
|
|
2385
2412
|
setFlatpickrInstance(instance);
|
|
@@ -2484,7 +2511,7 @@ function Datepicker(props) {
|
|
|
2484
2511
|
});
|
|
2485
2512
|
}
|
|
2486
2513
|
|
|
2487
|
-
var _path$v, _path2$
|
|
2514
|
+
var _path$v, _path2$4;
|
|
2488
2515
|
function _extends$w() { _extends$w = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$w.apply(this, arguments); }
|
|
2489
2516
|
var SvgClock = function SvgClock(props) {
|
|
2490
2517
|
return /*#__PURE__*/React.createElement("svg", _extends$w({
|
|
@@ -2496,7 +2523,7 @@ var SvgClock = function SvgClock(props) {
|
|
|
2496
2523
|
}, props), _path$v || (_path$v = /*#__PURE__*/React.createElement("path", {
|
|
2497
2524
|
fill: "currentColor",
|
|
2498
2525
|
d: "M13 14.41 18.59 20 20 18.59l-5-5.01V5h-2v9.41Z"
|
|
2499
|
-
})), _path2$
|
|
2526
|
+
})), _path2$4 || (_path2$4 = /*#__PURE__*/React.createElement("path", {
|
|
2500
2527
|
fill: "currentColor",
|
|
2501
2528
|
fillRule: "evenodd",
|
|
2502
2529
|
d: "M6.222 25.64A14 14 0 1 0 21.778 2.36 14 14 0 0 0 6.222 25.64ZM7.333 4.023a12 12 0 1 1 13.334 19.955A12 12 0 0 1 7.333 4.022Z",
|
|
@@ -2587,7 +2614,7 @@ function DropdownList(props) {
|
|
|
2587
2614
|
children: [values.length > 0 && values.map((v, i) => {
|
|
2588
2615
|
return jsx("div", {
|
|
2589
2616
|
class: classNames('fjs-dropdownlist-item', {
|
|
2590
|
-
|
|
2617
|
+
focused: focusedValueIndex === i
|
|
2591
2618
|
}),
|
|
2592
2619
|
onMouseMove: mouseControl ? undefined : e => onMouseMovedInKeyboardMode(e, i),
|
|
2593
2620
|
onMouseEnter: mouseControl ? () => setFocusedValueIndex(i) : undefined,
|
|
@@ -2739,11 +2766,9 @@ function Timepicker(props) {
|
|
|
2739
2766
|
disabled: disabled,
|
|
2740
2767
|
readOnly: readonly,
|
|
2741
2768
|
placeholder: use24h ? 'hh:mm' : 'hh:mm ?m',
|
|
2742
|
-
autoComplete: "off"
|
|
2743
|
-
|
|
2744
|
-
// @ts-ignore
|
|
2745
|
-
,
|
|
2769
|
+
autoComplete: "off",
|
|
2746
2770
|
onInput: e => {
|
|
2771
|
+
// @ts-expect-error
|
|
2747
2772
|
setRawValue(e.target.value);
|
|
2748
2773
|
useDropdown && setDropdownIsOpen(false);
|
|
2749
2774
|
},
|
|
@@ -3142,7 +3167,7 @@ var SvgChecklist = function SvgChecklist(props) {
|
|
|
3142
3167
|
};
|
|
3143
3168
|
var ChecklistIcon = SvgChecklist;
|
|
3144
3169
|
|
|
3145
|
-
var _path$r, _path2$
|
|
3170
|
+
var _path$r, _path2$3, _path3;
|
|
3146
3171
|
function _extends$s() { _extends$s = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$s.apply(this, arguments); }
|
|
3147
3172
|
var SvgDatetime = function SvgDatetime(props) {
|
|
3148
3173
|
return /*#__PURE__*/React.createElement("svg", _extends$s({
|
|
@@ -3153,7 +3178,7 @@ var SvgDatetime = function SvgDatetime(props) {
|
|
|
3153
3178
|
}, props), _path$r || (_path$r = /*#__PURE__*/React.createElement("path", {
|
|
3154
3179
|
fillRule: "evenodd",
|
|
3155
3180
|
d: "M37.908 13.418h-5.004v-2.354h-1.766v2.354H21.13v-2.354h-1.766v2.354H14.36a2.07 2.07 0 0 0-2.06 2.06v23.549a2.07 2.07 0 0 0 2.06 2.06h6.77v-1.766h-6.358a.707.707 0 0 1-.706-.706V15.89c0-.39.316-.707.706-.707h4.592v2.355h1.766v-2.355h10.008v2.355h1.766v-2.355h4.592a.71.71 0 0 1 .707.707v6.358h1.765v-6.77c0-1.133-.927-2.06-2.06-2.06z"
|
|
3156
|
-
})), _path2$
|
|
3181
|
+
})), _path2$3 || (_path2$3 = /*#__PURE__*/React.createElement("path", {
|
|
3157
3182
|
d: "m35.13 37.603 1.237-1.237-3.468-3.475v-5.926h-1.754v6.654l3.984 3.984Z"
|
|
3158
3183
|
})), _path3 || (_path3 = /*#__PURE__*/React.createElement("path", {
|
|
3159
3184
|
fillRule: "evenodd",
|
|
@@ -3162,7 +3187,7 @@ var SvgDatetime = function SvgDatetime(props) {
|
|
|
3162
3187
|
};
|
|
3163
3188
|
var DatetimeIcon = SvgDatetime;
|
|
3164
3189
|
|
|
3165
|
-
var _path$q, _path2$
|
|
3190
|
+
var _path$q, _path2$2;
|
|
3166
3191
|
function _extends$r() { _extends$r = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$r.apply(this, arguments); }
|
|
3167
3192
|
var SvgTaglist = function SvgTaglist(props) {
|
|
3168
3193
|
return /*#__PURE__*/React.createElement("svg", _extends$r({
|
|
@@ -3173,7 +3198,7 @@ var SvgTaglist = function SvgTaglist(props) {
|
|
|
3173
3198
|
}, props), _path$q || (_path$q = /*#__PURE__*/React.createElement("path", {
|
|
3174
3199
|
fillRule: "evenodd",
|
|
3175
3200
|
d: "M45 16a3 3 0 0 1 3 3v16a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3V19a3 3 0 0 1 3-3h36Zm0 2H9a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h36a1 1 0 0 0 1-1V19a1 1 0 0 0-1-1Z"
|
|
3176
|
-
})), _path2$
|
|
3201
|
+
})), _path2$2 || (_path2$2 = /*#__PURE__*/React.createElement("path", {
|
|
3177
3202
|
d: "M11 22a1 1 0 0 1 1-1h19a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H12a1 1 0 0 1-1-1V22Z"
|
|
3178
3203
|
})));
|
|
3179
3204
|
};
|
|
@@ -3215,10 +3240,12 @@ var SvgGroup = function SvgGroup(props) {
|
|
|
3215
3240
|
xmlns: "http://www.w3.org/2000/svg",
|
|
3216
3241
|
width: 54,
|
|
3217
3242
|
height: 54,
|
|
3218
|
-
fill: "
|
|
3243
|
+
fill: "none"
|
|
3219
3244
|
}, props), _path$p || (_path$p = /*#__PURE__*/React.createElement("path", {
|
|
3245
|
+
fill: "#000",
|
|
3220
3246
|
fillRule: "evenodd",
|
|
3221
|
-
d: "
|
|
3247
|
+
d: "M4.05 42.132v1.164c0 .693.604 1.254 1.35 1.254h1.35v-2.507h-2.7v.09Zm0-2.328h2.7v-2.328h-2.7v2.328Zm0-4.656h2.7V32.82h-2.7v2.328Zm0-4.656h2.7v-2.328h-2.7v2.328Zm0-4.656h2.7v-2.328h-2.7v2.328Zm0-4.656h2.7v-2.328h-2.7v2.328Zm0-4.656h2.7v-2.328h-2.7v2.328Zm0-4.656v.09h2.7V9.45H5.4c-.746 0-1.35.561-1.35 1.254v1.164Zm5.4-2.418v2.507h2.7V9.45h-2.7Zm5.4 0v2.507h2.7V9.45h-2.7Zm5.4 0v2.507h2.7V9.45h-2.7Zm5.4 0v2.507h2.7V9.45h-2.7Zm5.4 0v2.507h2.7V9.45h-2.7Zm5.4 0v2.507h2.7V9.45h-2.7Zm5.4 0v2.507h2.7V9.45h-2.7Zm5.4 0v2.507h2.7v-1.253c0-.693-.604-1.254-1.35-1.254h-1.35Zm2.7 4.746h-2.7v2.328h2.7v-2.328Zm0 4.656h-2.7v2.328h2.7v-2.328Zm0 4.656h-2.7v2.328h2.7v-2.328Zm0 4.656h-2.7v2.328h2.7v-2.328Zm0 4.656h-2.7v2.328h2.7V32.82Zm0 4.656h-2.7v2.328h2.7v-2.328Zm0 4.656v-.09h-2.7v2.508h1.35c.746 0 1.35-.561 1.35-1.254v-1.164Zm-5.4 2.418v-2.507h-2.7v2.507h2.7Zm-5.4 0v-2.507h-2.7v2.507h2.7Zm-5.4 0v-2.507h-2.7v2.507h2.7Zm-5.4 0v-2.507h-2.7v2.507h2.7Zm-5.4 0v-2.507h-2.7v2.507h2.7Zm-5.4 0v-2.507h-2.7v2.507h2.7Zm-5.4 0v-2.507h-2.7v2.507h2.7Z",
|
|
3248
|
+
clipRule: "evenodd"
|
|
3222
3249
|
})));
|
|
3223
3250
|
};
|
|
3224
3251
|
var GroupIcon = SvgGroup;
|
|
@@ -3308,7 +3335,7 @@ var SvgDynamicList = function SvgDynamicList(props) {
|
|
|
3308
3335
|
}, props), _path$j || (_path$j = /*#__PURE__*/React.createElement("path", {
|
|
3309
3336
|
fill: "currentColor",
|
|
3310
3337
|
fillRule: "evenodd",
|
|
3311
|
-
d: "M2.7 43.296v1.254c0 .746.604 1.35 1.35 1.35h1.275v-1.795c.049.14.075.29.075.445v-1.254h-.075V43.2H4.05c.177 0 .347.034.502.096H2.7Zm2.7-2.507v-2.507H2.7v2.507h2.7Zm0-5.014v-2.507H2.7v2.507h2.7Zm0-5.014v-2.507H2.7v2.507h2.7Zm0-5.015V23.24H2.7v2.507h2.7Zm0-5.014v-2.507H2.7v2.507h2.7Zm0-5.014V13.21H2.7v2.507h2.7Zm-2.7-5.014h1.852a1.346 1.346 0 0 1-.502.096h1.275v-.096H5.4V9.45c0 .156-.026.306-.075.445V8.1H4.05A1.35 1.35 0 0 0 2.7 9.45v1.254Zm5.175.096h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1-2.7v1.795a1.348 1.348 0 0 1-.075-.445v1.254h.075v.096h1.
|
|
3338
|
+
d: "M2.7 43.296v1.254c0 .746.604 1.35 1.35 1.35h1.275v-1.795c.049.14.075.29.075.445v-1.254h-.075V43.2H4.05c.177 0 .347.034.502.096H2.7Zm2.7-2.507v-2.507H2.7v2.507h2.7Zm0-5.014v-2.507H2.7v2.507h2.7Zm0-5.014v-2.507H2.7v2.507h2.7Zm0-5.015V23.24H2.7v2.507h2.7Zm0-5.014v-2.507H2.7v2.507h2.7Zm0-5.014V13.21H2.7v2.507h2.7Zm-2.7-5.014h1.852a1.346 1.346 0 0 1-.502.096h1.275v-.096H5.4V9.45c0 .156-.026.306-.075.445V8.1H4.05A1.35 1.35 0 0 0 2.7 9.45v1.254Zm5.175.096h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1 0h2.55V8.1h-2.55v2.7Zm5.1-2.7v1.795a1.348 1.348 0 0 1-.075-.445v1.254h.075v.096h1.275a1.35 1.35 0 0 1-.502-.096H51.3V9.45a1.35 1.35 0 0 0-1.35-1.35h-1.275Zm-.075 5.11v2.508h2.7V13.21h-2.7Zm0 5.015v2.507h2.7v-2.507h-2.7Zm0 5.014v2.507h2.7V23.24h-2.7Zm0 5.015v2.507h2.7v-2.507h-2.7Zm0 5.014v2.507h2.7v-2.507h-2.7Zm0 5.014v2.507h2.7v-2.507h-2.7Zm2.7 5.014h-1.852a1.35 1.35 0 0 1 .502-.096h-1.275v.096H48.6v1.254c0-.156.026-.305.075-.445V45.9h1.275a1.35 1.35 0 0 0 1.35-1.35v-1.254Zm-5.175-.096h-2.55v2.7h2.55v-2.7Zm-5.1 0h-2.55v2.7h2.55v-2.7Zm-5.1 0h-2.55v2.7h2.55v-2.7Zm-5.1 0h-2.55v2.7h2.55v-2.7Zm-5.1 0h-2.55v2.7h2.55v-2.7Zm-5.1 0h-2.55v2.7h2.55v-2.7Zm-5.1 0h-2.55v2.7h2.55v-2.7Zm-5.1 0h-2.55v2.7h2.55v-2.7ZM16.2 17.55a4.05 4.05 0 0 1 4.05 4.05v1.35A4.05 4.05 0 0 1 16.2 27h-1.35a4.05 4.05 0 0 1-4.05-4.05V21.6a4.05 4.05 0 0 1 4.05-4.05h1.35Zm0 2.7h-1.35a1.35 1.35 0 0 0-1.35 1.35v1.35c0 .746.604 1.35 1.35 1.35h1.35a1.35 1.35 0 0 0 1.35-1.35V21.6a1.35 1.35 0 0 0-1.35-1.35Zm27 1.35a4.05 4.05 0 0 0-4.05-4.05H29.7a4.05 4.05 0 0 0-4.05 4.05v1.35A4.05 4.05 0 0 0 29.7 27h9.45a4.05 4.05 0 0 0 4.05-4.05V21.6Zm-13.5-1.35h9.45c.746 0 1.35.604 1.35 1.35v1.35a1.35 1.35 0 0 1-1.35 1.35H29.7a1.35 1.35 0 0 1-1.35-1.35V21.6c0-.746.604-1.35 1.35-1.35ZM43.2 37.8a4.05 4.05 0 0 0-4.05-4.05H29.7a4.05 4.05 0 0 0-4.05 4.05v1.35h2.7V37.8c0-.746.604-1.35 1.35-1.35h9.45c.746 0 1.35.604 1.35 1.35v1.35h2.7V37.8Zm-27-4.05a4.05 4.05 0 0 1 4.05 4.05v1.35h-2.7V37.8a1.35 1.35 0 0 0-1.35-1.35h-1.35a1.35 1.35 0 0 0-1.35 1.35v1.35h-2.7V37.8a4.05 4.05 0 0 1 4.05-4.05h1.35Z",
|
|
3312
3339
|
clipRule: "evenodd"
|
|
3313
3340
|
})));
|
|
3314
3341
|
};
|
|
@@ -3392,7 +3419,7 @@ var SvgTextarea = function SvgTextarea(props) {
|
|
|
3392
3419
|
};
|
|
3393
3420
|
var TextareaIcon = SvgTextarea;
|
|
3394
3421
|
|
|
3395
|
-
var _path$d
|
|
3422
|
+
var _path$d;
|
|
3396
3423
|
function _extends$d() { _extends$d = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$d.apply(this, arguments); }
|
|
3397
3424
|
var SvgIFrame = function SvgIFrame(props) {
|
|
3398
3425
|
return /*#__PURE__*/React.createElement("svg", _extends$d({
|
|
@@ -3401,12 +3428,9 @@ var SvgIFrame = function SvgIFrame(props) {
|
|
|
3401
3428
|
height: 54,
|
|
3402
3429
|
fill: "none"
|
|
3403
3430
|
}, props), _path$d || (_path$d = /*#__PURE__*/React.createElement("path", {
|
|
3404
|
-
fill: "
|
|
3405
|
-
d: "M34.467 37.3 41 31l-6.533-6.3-1.32 1.273L38.36 31l-5.213 5.027 1.32 1.273ZM19.533 24.7 13 31l6.533 6.3 1.32-1.273L15.64 31l5.214-5.027-1.32-1.273Zm4.127 14.832 1.805.468 4.875-17.532L28.535 22 23.66 39.532Z"
|
|
3406
|
-
})), _path2$2 || (_path2$2 = /*#__PURE__*/React.createElement("path", {
|
|
3407
|
-
fill: "currentcolor",
|
|
3431
|
+
fill: "currentColor",
|
|
3408
3432
|
fillRule: "evenodd",
|
|
3409
|
-
d: "
|
|
3433
|
+
d: "M45.658 9.45c1.625 0 2.942 1.36 2.942 3.039V22.95h-1.961v-4.383H7.36V41.51c0 .56.44 1.013.98 1.013H27v2.026H8.342c-1.625 0-2.942-1.36-2.942-3.039V12.489c0-1.678 1.317-3.039 2.942-3.039h37.316Zm0 2.026H8.342c-.542 0-.98.454-.98 1.013v4.052h39.277v-4.052c0-.56-.44-1.013-.98-1.013ZM31.05 35.775A8.768 8.768 0 0 1 39.825 27a8.768 8.768 0 0 1 8.775 8.775 8.768 8.768 0 0 1-8.775 8.775 8.768 8.768 0 0 1-8.775-8.775Zm12.388-.516h3.097c-.206-2.581-1.858-4.646-4.026-5.678.62 1.548.93 3.613.93 5.678Zm-5.162 2.065c.207 3.303 1.136 4.955 1.549 5.161.413-.206 1.239-1.858 1.445-5.161h-2.994Zm1.446-8.26c-.31.207-1.342 2.272-1.446 6.195h2.994c-.103-3.923-1.135-5.988-1.548-6.194Zm-3.51 6.195c.103-2.065.31-4.13.929-5.678-2.168 1.032-3.82 3.097-4.026 5.678h3.097Zm0 2.065h-2.89c.515 2.064 1.96 3.82 3.819 4.645-.516-1.342-.826-2.994-.93-4.645Zm7.226 0c-.103 1.755-.413 3.303-.929 4.645 1.858-.826 3.304-2.58 3.923-4.645h-2.994Z",
|
|
3410
3434
|
clipRule: "evenodd"
|
|
3411
3435
|
})));
|
|
3412
3436
|
};
|
|
@@ -3777,7 +3801,7 @@ function Numberfield(props) {
|
|
|
3777
3801
|
'fjs-disabled': disabled,
|
|
3778
3802
|
'fjs-readonly': readonly
|
|
3779
3803
|
}, {
|
|
3780
|
-
|
|
3804
|
+
hasErrors: errors.length
|
|
3781
3805
|
}),
|
|
3782
3806
|
children: [jsx("input", {
|
|
3783
3807
|
ref: inputRef,
|
|
@@ -3789,7 +3813,6 @@ function Numberfield(props) {
|
|
|
3789
3813
|
onKeyPress: onKeyPress,
|
|
3790
3814
|
onBlur: onInputBlur,
|
|
3791
3815
|
onFocus: onInputFocus
|
|
3792
|
-
|
|
3793
3816
|
// @ts-ignore
|
|
3794
3817
|
,
|
|
3795
3818
|
onInput: e => setValue(e.target.value, true),
|
|
@@ -3878,7 +3901,6 @@ function Radio(props) {
|
|
|
3878
3901
|
} = validate;
|
|
3879
3902
|
const onChange = v => {
|
|
3880
3903
|
props.onChange({
|
|
3881
|
-
field,
|
|
3882
3904
|
value: v
|
|
3883
3905
|
});
|
|
3884
3906
|
};
|
|
@@ -4026,10 +4048,9 @@ function SearchableSelect(props) {
|
|
|
4026
4048
|
const setValue = useCallback(option => {
|
|
4027
4049
|
setFilter(option && option.label || '');
|
|
4028
4050
|
props.onChange({
|
|
4029
|
-
value: option && option.value || null
|
|
4030
|
-
field
|
|
4051
|
+
value: option && option.value || null
|
|
4031
4052
|
});
|
|
4032
|
-
}, [
|
|
4053
|
+
}, [props]);
|
|
4033
4054
|
const displayState = useMemo(() => {
|
|
4034
4055
|
const ds = {};
|
|
4035
4056
|
ds.componentReady = !disabled && !readonly && loadState === LOAD_STATES.LOADED;
|
|
@@ -4098,10 +4119,10 @@ function SearchableSelect(props) {
|
|
|
4098
4119
|
return jsxs(Fragment, {
|
|
4099
4120
|
children: [jsxs("div", {
|
|
4100
4121
|
class: classNames('fjs-input-group', {
|
|
4101
|
-
|
|
4102
|
-
|
|
4122
|
+
disabled: disabled,
|
|
4123
|
+
readonly: readonly
|
|
4103
4124
|
}, {
|
|
4104
|
-
|
|
4125
|
+
hasErrors: errors.length
|
|
4105
4126
|
}),
|
|
4106
4127
|
children: [jsx("input", {
|
|
4107
4128
|
disabled: disabled,
|
|
@@ -4125,7 +4146,7 @@ function SearchableSelect(props) {
|
|
|
4125
4146
|
setValue(null);
|
|
4126
4147
|
e.preventDefault();
|
|
4127
4148
|
},
|
|
4128
|
-
children: [jsx(XMarkIcon, {}),
|
|
4149
|
+
children: [jsx(XMarkIcon, {}), ' ']
|
|
4129
4150
|
}), jsx("span", {
|
|
4130
4151
|
class: "fjs-select-arrow",
|
|
4131
4152
|
onMouseDown: e => onAngelMouseDown(e),
|
|
@@ -4175,10 +4196,9 @@ function SimpleSelect(props) {
|
|
|
4175
4196
|
const valueLabel = useMemo(() => value && getLabelCorrelation(value), [value, getLabelCorrelation]);
|
|
4176
4197
|
const setValue = useCallback(option => {
|
|
4177
4198
|
props.onChange({
|
|
4178
|
-
value: option && option.value || null
|
|
4179
|
-
field
|
|
4199
|
+
value: option && option.value || null
|
|
4180
4200
|
});
|
|
4181
|
-
}, [
|
|
4201
|
+
}, [props]);
|
|
4182
4202
|
const displayState = useMemo(() => {
|
|
4183
4203
|
const ds = {};
|
|
4184
4204
|
ds.componentReady = !disabled && !readonly && loadState === LOAD_STATES.LOADED;
|
|
@@ -4219,7 +4239,7 @@ function SimpleSelect(props) {
|
|
|
4219
4239
|
disabled,
|
|
4220
4240
|
readonly
|
|
4221
4241
|
}, {
|
|
4222
|
-
|
|
4242
|
+
hasErrors: errors.length
|
|
4223
4243
|
}),
|
|
4224
4244
|
onFocus: onInputFocus,
|
|
4225
4245
|
onBlur: onInputBlur,
|
|
@@ -4516,15 +4536,13 @@ function Taglist(props) {
|
|
|
4516
4536
|
return;
|
|
4517
4537
|
}
|
|
4518
4538
|
props.onChange({
|
|
4519
|
-
value: [...values, value]
|
|
4520
|
-
field
|
|
4539
|
+
value: [...values, value]
|
|
4521
4540
|
});
|
|
4522
4541
|
};
|
|
4523
4542
|
const deselectValue = value => {
|
|
4524
4543
|
const newValues = values.filter(v => !isEqual(v, value));
|
|
4525
4544
|
props.onChange({
|
|
4526
|
-
value: newValues
|
|
4527
|
-
field
|
|
4545
|
+
value: newValues
|
|
4528
4546
|
});
|
|
4529
4547
|
};
|
|
4530
4548
|
const onInputChange = ({
|
|
@@ -4949,18 +4967,20 @@ function ExpressionField(props) {
|
|
|
4949
4967
|
const evaluation = useExpressionEvaluation(expression);
|
|
4950
4968
|
const evaluationMemo = useDeepCompareMemoize(evaluation);
|
|
4951
4969
|
const eventBus = useService('eventBus');
|
|
4970
|
+
const expressionLoopPreventer = useService('expressionLoopPreventer');
|
|
4952
4971
|
const sendValue = useCallback(() => {
|
|
4953
4972
|
onChange && onChange({
|
|
4954
4973
|
field,
|
|
4955
|
-
value: evaluationMemo
|
|
4974
|
+
value: evaluationMemo,
|
|
4975
|
+
shouldNotRecompute: true
|
|
4956
4976
|
});
|
|
4957
4977
|
}, [field, evaluationMemo, onChange]);
|
|
4958
4978
|
useEffect(() => {
|
|
4959
|
-
if (computeOn !== 'change' || evaluationMemo
|
|
4979
|
+
if (computeOn !== 'change' || isEqual$1(evaluationMemo, value) || !expressionLoopPreventer.registerExpressionExecution(this)) {
|
|
4960
4980
|
return;
|
|
4961
4981
|
}
|
|
4962
4982
|
sendValue();
|
|
4963
|
-
}
|
|
4983
|
+
});
|
|
4964
4984
|
useEffect(() => {
|
|
4965
4985
|
if (computeOn === 'presubmit') {
|
|
4966
4986
|
eventBus.on('presubmit', sendValue);
|
|
@@ -5011,7 +5031,6 @@ function Textfield(props) {
|
|
|
5011
5031
|
target
|
|
5012
5032
|
}) => {
|
|
5013
5033
|
props.onChange({
|
|
5014
|
-
field,
|
|
5015
5034
|
value: target.value
|
|
5016
5035
|
});
|
|
5017
5036
|
});
|
|
@@ -5111,7 +5130,6 @@ function Textarea(props) {
|
|
|
5111
5130
|
target
|
|
5112
5131
|
}) => {
|
|
5113
5132
|
props.onChange({
|
|
5114
|
-
field,
|
|
5115
5133
|
value: target.value
|
|
5116
5134
|
});
|
|
5117
5135
|
});
|
|
@@ -5625,7 +5643,7 @@ function Lightbox(props) {
|
|
|
5625
5643
|
style: "margin: 15px 20px 15px 10px; align-self: center; color: var(--cds-icon-primary, #404040)",
|
|
5626
5644
|
children: jsx(Logo, {})
|
|
5627
5645
|
}), jsxs("span", {
|
|
5628
|
-
children: ["Web-based tooling for BPMN, DMN, and forms powered by
|
|
5646
|
+
children: ["Web-based tooling for BPMN, DMN, and forms powered by", ' ', jsx("a", {
|
|
5629
5647
|
href: "https://bpmn.io",
|
|
5630
5648
|
target: "_blank",
|
|
5631
5649
|
rel: "noopener",
|
|
@@ -5715,7 +5733,12 @@ function FormComponent(props) {
|
|
|
5715
5733
|
});
|
|
5716
5734
|
}
|
|
5717
5735
|
|
|
5718
|
-
const formFields = [
|
|
5736
|
+
const formFields = [/* Input */
|
|
5737
|
+
Textfield, Textarea, Numberfield, Datetime, ExpressionField, /* Selection */
|
|
5738
|
+
Checkbox, Checklist, Radio, Select, Taglist, /* Presentation */
|
|
5739
|
+
Text, Image, Table, Html, Spacer, Separator, /* Containers */
|
|
5740
|
+
Group, DynamicList, IFrame, /* Other */
|
|
5741
|
+
Button, Default];
|
|
5719
5742
|
|
|
5720
5743
|
class FormFields {
|
|
5721
5744
|
constructor() {
|
|
@@ -5885,8 +5908,7 @@ class ConditionChecker {
|
|
|
5885
5908
|
const {
|
|
5886
5909
|
getFilterPath = (field, indexes) => this._pathRegistry.getValuePath(field, {
|
|
5887
5910
|
indexes
|
|
5888
|
-
})
|
|
5889
|
-
leafNodeDeletionOnly = false
|
|
5911
|
+
})
|
|
5890
5912
|
} = options;
|
|
5891
5913
|
const _applyConditionsWithinScope = (rootField, scopeContext, startHidden = false) => {
|
|
5892
5914
|
const {
|
|
@@ -5917,7 +5939,7 @@ class ConditionChecker {
|
|
|
5917
5939
|
context.isHidden = startHidden || context.isHidden || conditional && this._checkHideCondition(conditional, localExpressionContext);
|
|
5918
5940
|
|
|
5919
5941
|
// if a field is repeatable and visible, we need to implement custom recursion on its children
|
|
5920
|
-
if (isRepeatable &&
|
|
5942
|
+
if (isRepeatable && !context.isHidden) {
|
|
5921
5943
|
// prevent the regular recursion behavior of executeRecursivelyOnFields
|
|
5922
5944
|
context.preventRecursion = true;
|
|
5923
5945
|
const repeaterValuePath = this._pathRegistry.getValuePath(field, {
|
|
@@ -5949,7 +5971,7 @@ class ConditionChecker {
|
|
|
5949
5971
|
}
|
|
5950
5972
|
|
|
5951
5973
|
// if we have a hidden repeatable field, and the data structure allows, we clear it directly at the root and stop recursion
|
|
5952
|
-
if (context.isHidden &&
|
|
5974
|
+
if (context.isHidden && isRepeatable) {
|
|
5953
5975
|
context.preventRecursion = true;
|
|
5954
5976
|
this._cleanlyClearDataAtPath(getFilterPath(field, indexes), workingData);
|
|
5955
5977
|
}
|
|
@@ -6039,6 +6061,49 @@ const ExpressionLanguageModule = {
|
|
|
6039
6061
|
conditionChecker: ['type', ConditionChecker]
|
|
6040
6062
|
};
|
|
6041
6063
|
|
|
6064
|
+
class ExpressionLoopPreventer {
|
|
6065
|
+
constructor(eventBus) {
|
|
6066
|
+
this._computedExpressions = [];
|
|
6067
|
+
eventBus.on('field.updated', ({
|
|
6068
|
+
shouldNotRecompute
|
|
6069
|
+
}) => {
|
|
6070
|
+
if (shouldNotRecompute) {
|
|
6071
|
+
return;
|
|
6072
|
+
}
|
|
6073
|
+
this.reset();
|
|
6074
|
+
});
|
|
6075
|
+
eventBus.on('import.done', this.reset.bind(this));
|
|
6076
|
+
eventBus.on('reset', this.reset.bind(this));
|
|
6077
|
+
}
|
|
6078
|
+
|
|
6079
|
+
/**
|
|
6080
|
+
* Checks if the expression field has already been computed, and registers it if not.
|
|
6081
|
+
*
|
|
6082
|
+
* @param {any} expressionField
|
|
6083
|
+
* @returns {boolean} - whether the expression field has already been computed within the current cycle
|
|
6084
|
+
*/
|
|
6085
|
+
registerExpressionExecution(expressionField) {
|
|
6086
|
+
if (this._computedExpressions.includes(expressionField)) {
|
|
6087
|
+
return false;
|
|
6088
|
+
}
|
|
6089
|
+
this._computedExpressions.push(expressionField);
|
|
6090
|
+
return true;
|
|
6091
|
+
}
|
|
6092
|
+
|
|
6093
|
+
/**
|
|
6094
|
+
* Resets the list of computed expressions.
|
|
6095
|
+
*/
|
|
6096
|
+
reset() {
|
|
6097
|
+
this._computedExpressions = [];
|
|
6098
|
+
}
|
|
6099
|
+
}
|
|
6100
|
+
ExpressionLoopPreventer.$inject = ['eventBus'];
|
|
6101
|
+
|
|
6102
|
+
const ExpressionFieldModule = {
|
|
6103
|
+
__init__: ['expressionLoopPreventer'],
|
|
6104
|
+
expressionLoopPreventer: ['type', ExpressionLoopPreventer]
|
|
6105
|
+
};
|
|
6106
|
+
|
|
6042
6107
|
class MarkdownRenderer {
|
|
6043
6108
|
/**
|
|
6044
6109
|
* Render markdown to HTML.
|
|
@@ -6533,6 +6598,9 @@ var commandModule = {
|
|
|
6533
6598
|
commandStack: ['type', CommandStack]
|
|
6534
6599
|
};
|
|
6535
6600
|
|
|
6601
|
+
/**
|
|
6602
|
+
* @deprecated
|
|
6603
|
+
*/
|
|
6536
6604
|
class UpdateFieldValidationHandler {
|
|
6537
6605
|
constructor(form, validator) {
|
|
6538
6606
|
this._form = form;
|
|
@@ -6562,6 +6630,38 @@ class UpdateFieldValidationHandler {
|
|
|
6562
6630
|
}
|
|
6563
6631
|
UpdateFieldValidationHandler.$inject = ['form', 'validator'];
|
|
6564
6632
|
|
|
6633
|
+
class UpdateFieldInstanceValidationHandler {
|
|
6634
|
+
constructor(form, validator) {
|
|
6635
|
+
this._form = form;
|
|
6636
|
+
this._validator = validator;
|
|
6637
|
+
}
|
|
6638
|
+
execute(context) {
|
|
6639
|
+
const {
|
|
6640
|
+
fieldInstance,
|
|
6641
|
+
value
|
|
6642
|
+
} = context;
|
|
6643
|
+
const {
|
|
6644
|
+
id,
|
|
6645
|
+
indexes
|
|
6646
|
+
} = fieldInstance;
|
|
6647
|
+
const {
|
|
6648
|
+
errors
|
|
6649
|
+
} = this._form._getState();
|
|
6650
|
+
context.oldErrors = clone(errors);
|
|
6651
|
+
const fieldErrors = this._validator.validateFieldInstance(fieldInstance, value);
|
|
6652
|
+
const updatedErrors = set(errors, [id, ...Object.values(indexes || {})], fieldErrors.length ? fieldErrors : undefined);
|
|
6653
|
+
this._form._setState({
|
|
6654
|
+
errors: updatedErrors
|
|
6655
|
+
});
|
|
6656
|
+
}
|
|
6657
|
+
revert(context) {
|
|
6658
|
+
this._form._setState({
|
|
6659
|
+
errors: context.oldErrors
|
|
6660
|
+
});
|
|
6661
|
+
}
|
|
6662
|
+
}
|
|
6663
|
+
UpdateFieldInstanceValidationHandler.$inject = ['form', 'validator'];
|
|
6664
|
+
|
|
6565
6665
|
class ViewerCommands {
|
|
6566
6666
|
constructor(commandStack, eventBus) {
|
|
6567
6667
|
this._commandStack = commandStack;
|
|
@@ -6576,9 +6676,14 @@ class ViewerCommands {
|
|
|
6576
6676
|
}
|
|
6577
6677
|
getHandlers() {
|
|
6578
6678
|
return {
|
|
6579
|
-
'formField.validation.update': UpdateFieldValidationHandler
|
|
6679
|
+
'formField.validation.update': UpdateFieldValidationHandler,
|
|
6680
|
+
'formFieldInstance.validation.update': UpdateFieldInstanceValidationHandler
|
|
6580
6681
|
};
|
|
6581
6682
|
}
|
|
6683
|
+
|
|
6684
|
+
/**
|
|
6685
|
+
* @deprecated
|
|
6686
|
+
*/
|
|
6582
6687
|
updateFieldValidation(field, value, indexes) {
|
|
6583
6688
|
const context = {
|
|
6584
6689
|
field,
|
|
@@ -6587,6 +6692,13 @@ class ViewerCommands {
|
|
|
6587
6692
|
};
|
|
6588
6693
|
this._commandStack.execute('formField.validation.update', context);
|
|
6589
6694
|
}
|
|
6695
|
+
updateFieldInstanceValidation(fieldInstance, value) {
|
|
6696
|
+
const context = {
|
|
6697
|
+
fieldInstance,
|
|
6698
|
+
value
|
|
6699
|
+
};
|
|
6700
|
+
this._commandStack.execute('formFieldInstance.validation.update', context);
|
|
6701
|
+
}
|
|
6590
6702
|
}
|
|
6591
6703
|
ViewerCommands.$inject = ['commandStack', 'eventBus'];
|
|
6592
6704
|
|
|
@@ -6771,9 +6883,7 @@ class RepeatRenderManager {
|
|
|
6771
6883
|
updatedValues.push(newItem);
|
|
6772
6884
|
shouldScroll.current = true;
|
|
6773
6885
|
props.onChange({
|
|
6774
|
-
|
|
6775
|
-
value: updatedValues,
|
|
6776
|
-
indexes
|
|
6886
|
+
value: updatedValues
|
|
6777
6887
|
});
|
|
6778
6888
|
setSharedRepeatState(state => ({
|
|
6779
6889
|
...state,
|
|
@@ -7432,11 +7542,18 @@ const EMAIL_PATTERN = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-
|
|
|
7432
7542
|
const PHONE_PATTERN = /(\+|00)(297|93|244|1264|358|355|376|971|54|374|1684|1268|61|43|994|257|32|229|226|880|359|973|1242|387|590|375|501|1441|591|55|1246|673|975|267|236|1|61|41|56|86|225|237|243|242|682|57|269|238|506|53|5999|61|1345|357|420|49|253|1767|45|1809|1829|1849|213|593|20|291|212|34|372|251|358|679|500|33|298|691|241|44|995|44|233|350|224|590|220|245|240|30|1473|299|502|594|1671|592|852|504|385|509|36|62|44|91|246|353|98|964|354|972|39|1876|44|962|81|76|77|254|996|855|686|1869|82|383|965|856|961|231|218|1758|423|94|266|370|352|371|853|590|212|377|373|261|960|52|692|389|223|356|95|382|976|1670|258|222|1664|596|230|265|60|262|264|687|227|672|234|505|683|31|47|977|674|64|968|92|507|64|51|63|680|675|48|1787|1939|850|351|595|970|689|974|262|40|7|250|966|249|221|65|500|4779|677|232|503|378|252|508|381|211|239|597|421|386|46|268|1721|248|963|1649|235|228|66|992|690|993|670|676|1868|216|90|688|886|255|256|380|598|1|998|3906698|379|1784|58|1284|1340|84|678|681|685|967|27|260|263)(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\d{4,20}$/;
|
|
7433
7543
|
const VALIDATE_FEEL_PROPERTIES = ['min', 'max', 'minLength', 'maxLength'];
|
|
7434
7544
|
class Validator {
|
|
7435
|
-
constructor(expressionLanguage, conditionChecker, form) {
|
|
7545
|
+
constructor(expressionLanguage, conditionChecker, form, formFieldRegistry) {
|
|
7436
7546
|
this._expressionLanguage = expressionLanguage;
|
|
7437
7547
|
this._conditionChecker = conditionChecker;
|
|
7438
7548
|
this._form = form;
|
|
7549
|
+
this._formFieldRegistry = formFieldRegistry;
|
|
7439
7550
|
}
|
|
7551
|
+
|
|
7552
|
+
/**
|
|
7553
|
+
* Validate against a field definition, does not support proper expression evaluation.
|
|
7554
|
+
*
|
|
7555
|
+
* @deprecated use validateFieldInstance instead
|
|
7556
|
+
*/
|
|
7440
7557
|
validateField(field, value) {
|
|
7441
7558
|
const {
|
|
7442
7559
|
type,
|
|
@@ -7444,72 +7561,121 @@ class Validator {
|
|
|
7444
7561
|
} = field;
|
|
7445
7562
|
let errors = [];
|
|
7446
7563
|
if (type === 'number') {
|
|
7447
|
-
|
|
7448
|
-
decimalDigits,
|
|
7449
|
-
increment
|
|
7450
|
-
} = field;
|
|
7451
|
-
if (value === 'NaN') {
|
|
7452
|
-
errors = [...errors, 'Value is not a number.'];
|
|
7453
|
-
} else if (value) {
|
|
7454
|
-
if (decimalDigits >= 0 && countDecimals(value) > decimalDigits) {
|
|
7455
|
-
errors = [...errors, 'Value is expected to ' + (decimalDigits === 0 ? 'be an integer' : `have at most ${decimalDigits} decimal digit${decimalDigits > 1 ? 's' : ''}`) + '.'];
|
|
7456
|
-
}
|
|
7457
|
-
if (increment) {
|
|
7458
|
-
const bigValue = Big(value);
|
|
7459
|
-
const bigIncrement = Big(increment);
|
|
7460
|
-
const offset = bigValue.mod(bigIncrement);
|
|
7461
|
-
if (offset.cmp(0) !== 0) {
|
|
7462
|
-
const previousValue = bigValue.minus(offset);
|
|
7463
|
-
const nextValue = previousValue.plus(bigIncrement);
|
|
7464
|
-
errors = [...errors, `Please select a valid value, the two nearest valid values are ${previousValue} and ${nextValue}.`];
|
|
7465
|
-
}
|
|
7466
|
-
}
|
|
7467
|
-
}
|
|
7564
|
+
errors = [...errors, ...runNumberValidation(field, value)];
|
|
7468
7565
|
}
|
|
7469
7566
|
if (!validate) {
|
|
7470
7567
|
return errors;
|
|
7471
7568
|
}
|
|
7472
|
-
const evaluatedValidation =
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
}
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
if (
|
|
7497
|
-
errors = [...errors,
|
|
7569
|
+
const evaluatedValidation = oldEvaluateFEELValues(validate, this._expressionLanguage, this._conditionChecker, this._form);
|
|
7570
|
+
errors = [...errors, ...runPresetValidation(field, evaluatedValidation, value)];
|
|
7571
|
+
return errors;
|
|
7572
|
+
}
|
|
7573
|
+
|
|
7574
|
+
/**
|
|
7575
|
+
* Validate a field instance.
|
|
7576
|
+
*
|
|
7577
|
+
* @param {Object} fieldInstance
|
|
7578
|
+
* @param {string} value
|
|
7579
|
+
*
|
|
7580
|
+
* @returns {Array<string>}
|
|
7581
|
+
*/
|
|
7582
|
+
validateFieldInstance(fieldInstance, value) {
|
|
7583
|
+
const {
|
|
7584
|
+
id,
|
|
7585
|
+
expressionContextInfo
|
|
7586
|
+
} = fieldInstance;
|
|
7587
|
+
const field = this._formFieldRegistry.get(id);
|
|
7588
|
+
const {
|
|
7589
|
+
type,
|
|
7590
|
+
validate
|
|
7591
|
+
} = field;
|
|
7592
|
+
let errors = [];
|
|
7593
|
+
if (type === 'number') {
|
|
7594
|
+
errors = [...errors, ...runNumberValidation(field, value)];
|
|
7498
7595
|
}
|
|
7499
|
-
if (
|
|
7500
|
-
|
|
7596
|
+
if (!validate) {
|
|
7597
|
+
return errors;
|
|
7501
7598
|
}
|
|
7599
|
+
const evaluatedValidation = evaluateFEELValues(validate, this._expressionLanguage, expressionContextInfo);
|
|
7600
|
+
errors = [...errors, ...runPresetValidation(field, evaluatedValidation, value)];
|
|
7502
7601
|
return errors;
|
|
7503
7602
|
}
|
|
7504
7603
|
}
|
|
7505
|
-
Validator.$inject = ['expressionLanguage', 'conditionChecker', 'form'];
|
|
7604
|
+
Validator.$inject = ['expressionLanguage', 'conditionChecker', 'form', 'formFieldRegistry'];
|
|
7506
7605
|
|
|
7507
7606
|
// helpers //////////
|
|
7508
7607
|
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7608
|
+
function runNumberValidation(field, value) {
|
|
7609
|
+
const {
|
|
7610
|
+
decimalDigits,
|
|
7611
|
+
increment
|
|
7612
|
+
} = field;
|
|
7613
|
+
const errors = [];
|
|
7614
|
+
if (value === 'NaN') {
|
|
7615
|
+
errors.push('Value is not a number.');
|
|
7616
|
+
} else if (value) {
|
|
7617
|
+
if (decimalDigits >= 0 && countDecimals(value) > decimalDigits) {
|
|
7618
|
+
errors.push('Value is expected to ' + (decimalDigits === 0 ? 'be an integer' : `have at most ${decimalDigits} decimal digit${decimalDigits > 1 ? 's' : ''}`) + '.');
|
|
7619
|
+
}
|
|
7620
|
+
if (increment) {
|
|
7621
|
+
const bigValue = Big(value);
|
|
7622
|
+
const bigIncrement = Big(increment);
|
|
7623
|
+
const offset = bigValue.mod(bigIncrement);
|
|
7624
|
+
if (offset.cmp(0) !== 0) {
|
|
7625
|
+
const previousValue = bigValue.minus(offset);
|
|
7626
|
+
const nextValue = previousValue.plus(bigIncrement);
|
|
7627
|
+
errors.push(`Please select a valid value, the two nearest valid values are ${previousValue} and ${nextValue}.`);
|
|
7628
|
+
}
|
|
7629
|
+
}
|
|
7630
|
+
}
|
|
7631
|
+
return errors;
|
|
7632
|
+
}
|
|
7633
|
+
function runPresetValidation(field, validation, value) {
|
|
7634
|
+
const errors = [];
|
|
7635
|
+
if (validation.pattern && value && !new RegExp(validation.pattern).test(value)) {
|
|
7636
|
+
errors.push(`Field must match pattern ${validation.pattern}.`);
|
|
7637
|
+
}
|
|
7638
|
+
if (validation.required) {
|
|
7639
|
+
const isUncheckedCheckbox = field.type === 'checkbox' && value === false;
|
|
7640
|
+
const isUnsetValue = isNil(value) || value === '';
|
|
7641
|
+
const isEmptyMultiselect = Array.isArray(value) && value.length === 0;
|
|
7642
|
+
if (isUncheckedCheckbox || isUnsetValue || isEmptyMultiselect) {
|
|
7643
|
+
errors.push('Field is required.');
|
|
7644
|
+
}
|
|
7645
|
+
}
|
|
7646
|
+
if ('min' in validation && (value || value === 0) && value < validation.min) {
|
|
7647
|
+
errors.push(`Field must have minimum value of ${validation.min}.`);
|
|
7648
|
+
}
|
|
7649
|
+
if ('max' in validation && (value || value === 0) && value > validation.max) {
|
|
7650
|
+
errors.push(`Field must have maximum value of ${validation.max}.`);
|
|
7651
|
+
}
|
|
7652
|
+
if ('minLength' in validation && value && value.trim().length < validation.minLength) {
|
|
7653
|
+
errors.push(`Field must have minimum length of ${validation.minLength}.`);
|
|
7654
|
+
}
|
|
7655
|
+
if ('maxLength' in validation && value && value.trim().length > validation.maxLength) {
|
|
7656
|
+
errors.push(`Field must have maximum length of ${validation.maxLength}.`);
|
|
7657
|
+
}
|
|
7658
|
+
if ('validationType' in validation && value && validation.validationType === 'phone' && !PHONE_PATTERN.test(value)) {
|
|
7659
|
+
errors.push('Field must be a valid international phone number. (e.g. +4930664040900)');
|
|
7660
|
+
}
|
|
7661
|
+
if ('validationType' in validation && value && validation.validationType === 'email' && !EMAIL_PATTERN.test(value)) {
|
|
7662
|
+
errors.push('Field must be a valid email.');
|
|
7663
|
+
}
|
|
7664
|
+
return errors;
|
|
7665
|
+
}
|
|
7666
|
+
function evaluateFEELValues(validate, expressionLanguage, expressionContextInfo) {
|
|
7667
|
+
const evaluatedValidate = {
|
|
7668
|
+
...validate
|
|
7669
|
+
};
|
|
7670
|
+
VALIDATE_FEEL_PROPERTIES.forEach(property => {
|
|
7671
|
+
const path = property.split('.');
|
|
7672
|
+
const value = get(evaluatedValidate, path);
|
|
7673
|
+
const evaluatedValue = runExpressionEvaluation(expressionLanguage, value, expressionContextInfo);
|
|
7674
|
+
set(evaluatedValidate, path, evaluatedValue === null ? undefined : evaluatedValue);
|
|
7675
|
+
});
|
|
7676
|
+
return evaluatedValidate;
|
|
7677
|
+
}
|
|
7678
|
+
function oldEvaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
|
|
7513
7679
|
const evaluatedValidate = {
|
|
7514
7680
|
...validate
|
|
7515
7681
|
};
|
|
@@ -8213,6 +8379,66 @@ class FormFieldRegistry {
|
|
|
8213
8379
|
}
|
|
8214
8380
|
FormFieldRegistry.$inject = ['eventBus'];
|
|
8215
8381
|
|
|
8382
|
+
class FormFieldInstanceRegistry {
|
|
8383
|
+
constructor(eventBus, formFieldRegistry, formFields) {
|
|
8384
|
+
this._eventBus = eventBus;
|
|
8385
|
+
this._formFieldRegistry = formFieldRegistry;
|
|
8386
|
+
this._formFields = formFields;
|
|
8387
|
+
this._formFieldInstances = {};
|
|
8388
|
+
eventBus.on('form.clear', () => this.clear());
|
|
8389
|
+
}
|
|
8390
|
+
add(instance) {
|
|
8391
|
+
const {
|
|
8392
|
+
id,
|
|
8393
|
+
expressionContextInfo,
|
|
8394
|
+
valuePath,
|
|
8395
|
+
indexes
|
|
8396
|
+
} = instance;
|
|
8397
|
+
const instanceId = [id, ...Object.values(indexes || {})].join('_');
|
|
8398
|
+
if (this._formFieldInstances[instanceId]) {
|
|
8399
|
+
throw new Error('this form field instance is already registered');
|
|
8400
|
+
}
|
|
8401
|
+
this._formFieldInstances[instanceId] = {
|
|
8402
|
+
id,
|
|
8403
|
+
instanceId,
|
|
8404
|
+
expressionContextInfo,
|
|
8405
|
+
valuePath,
|
|
8406
|
+
indexes
|
|
8407
|
+
};
|
|
8408
|
+
return instanceId;
|
|
8409
|
+
}
|
|
8410
|
+
remove(instanceId) {
|
|
8411
|
+
if (!this._formFieldInstances[instanceId]) {
|
|
8412
|
+
return;
|
|
8413
|
+
}
|
|
8414
|
+
delete this._formFieldInstances[instanceId];
|
|
8415
|
+
}
|
|
8416
|
+
getAll() {
|
|
8417
|
+
return Object.values(this._formFieldInstances);
|
|
8418
|
+
}
|
|
8419
|
+
getAllKeyed() {
|
|
8420
|
+
return this.getAll().filter(({
|
|
8421
|
+
id
|
|
8422
|
+
}) => {
|
|
8423
|
+
const formFieldDefinition = this._formFieldRegistry.get(id);
|
|
8424
|
+
if (!formFieldDefinition) {
|
|
8425
|
+
return false;
|
|
8426
|
+
}
|
|
8427
|
+
const {
|
|
8428
|
+
type
|
|
8429
|
+
} = formFieldDefinition;
|
|
8430
|
+
const {
|
|
8431
|
+
config
|
|
8432
|
+
} = this._formFields.get(type);
|
|
8433
|
+
return config.keyed;
|
|
8434
|
+
});
|
|
8435
|
+
}
|
|
8436
|
+
clear() {
|
|
8437
|
+
this._formFieldInstances = {};
|
|
8438
|
+
}
|
|
8439
|
+
}
|
|
8440
|
+
FormFieldInstanceRegistry.$inject = ['eventBus', 'formFieldRegistry', 'formFields'];
|
|
8441
|
+
|
|
8216
8442
|
function Renderer(config, eventBus, form, injector) {
|
|
8217
8443
|
const App = () => {
|
|
8218
8444
|
const [state, setState] = useState(form._getState());
|
|
@@ -8277,6 +8503,7 @@ const CoreModule = {
|
|
|
8277
8503
|
importer: ['type', Importer],
|
|
8278
8504
|
fieldFactory: ['type', FieldFactory],
|
|
8279
8505
|
formFieldRegistry: ['type', FormFieldRegistry],
|
|
8506
|
+
formFieldInstanceRegistry: ['type', FormFieldInstanceRegistry],
|
|
8280
8507
|
pathRegistry: ['type', PathRegistry],
|
|
8281
8508
|
formLayouter: ['type', FormLayouter],
|
|
8282
8509
|
validator: ['type', Validator]
|
|
@@ -8451,73 +8678,40 @@ class Form {
|
|
|
8451
8678
|
* @returns {Errors}
|
|
8452
8679
|
*/
|
|
8453
8680
|
validate() {
|
|
8454
|
-
const
|
|
8455
|
-
|
|
8456
|
-
pathRegistry = this.get('pathRegistry'),
|
|
8681
|
+
const formFieldRegistry = this.get('formFieldRegistry'),
|
|
8682
|
+
formFieldInstanceRegistry = this.get('formFieldInstanceRegistry'),
|
|
8457
8683
|
validator = this.get('validator');
|
|
8458
8684
|
const {
|
|
8459
8685
|
data
|
|
8460
8686
|
} = this._getState();
|
|
8461
|
-
const
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
disabled,
|
|
8465
|
-
type,
|
|
8466
|
-
isRepeating
|
|
8467
|
-
} = field;
|
|
8687
|
+
const errors = {};
|
|
8688
|
+
const getErrorPath = (id, indexes) => [id, ...Object.values(indexes || {})];
|
|
8689
|
+
formFieldInstanceRegistry.getAllKeyed().forEach(fieldInstance => {
|
|
8468
8690
|
const {
|
|
8469
|
-
|
|
8470
|
-
|
|
8691
|
+
id,
|
|
8692
|
+
valuePath,
|
|
8693
|
+
indexes
|
|
8694
|
+
} = fieldInstance;
|
|
8695
|
+
const field = formFieldRegistry.get(id);
|
|
8471
8696
|
|
|
8472
8697
|
// (1) Skip disabled fields
|
|
8473
|
-
if (disabled) {
|
|
8698
|
+
if (field.disabled) {
|
|
8474
8699
|
return;
|
|
8475
8700
|
}
|
|
8476
8701
|
|
|
8477
|
-
// (2) Validate the field
|
|
8478
|
-
const
|
|
8479
|
-
|
|
8480
|
-
});
|
|
8481
|
-
const valueData = get(data, valuePath);
|
|
8482
|
-
const fieldErrors = validator.validateField(field, valueData);
|
|
8702
|
+
// (2) Validate the field instance
|
|
8703
|
+
const value = get(data, valuePath);
|
|
8704
|
+
const fieldErrors = validator.validateFieldInstance(fieldInstance, value);
|
|
8483
8705
|
if (fieldErrors.length) {
|
|
8484
|
-
set(errors, getErrorPath(field, indexes), fieldErrors);
|
|
8485
|
-
}
|
|
8486
|
-
|
|
8487
|
-
// (3) Process parents
|
|
8488
|
-
if (!Array.isArray(field.components)) {
|
|
8489
|
-
return;
|
|
8706
|
+
set(errors, getErrorPath(field.id, indexes), fieldErrors);
|
|
8490
8707
|
}
|
|
8491
|
-
|
|
8492
|
-
// (4a) Recurse repeatable parents both across the indexes of repetition and the children
|
|
8493
|
-
if (fieldConfig.repeatable && isRepeating) {
|
|
8494
|
-
if (!Array.isArray(valueData)) {
|
|
8495
|
-
return;
|
|
8496
|
-
}
|
|
8497
|
-
valueData.forEach((_, index) => {
|
|
8498
|
-
field.components.forEach(component => {
|
|
8499
|
-
validateFieldRecursively(errors, component, {
|
|
8500
|
-
...indexes,
|
|
8501
|
-
[field.id]: index
|
|
8502
|
-
});
|
|
8503
|
-
});
|
|
8504
|
-
});
|
|
8505
|
-
return;
|
|
8506
|
-
}
|
|
8507
|
-
|
|
8508
|
-
// (4b) Recurse non-repeatable parents only across the children
|
|
8509
|
-
field.components.forEach(component => validateFieldRecursively(errors, component, indexes));
|
|
8510
|
-
}
|
|
8511
|
-
const workingErrors = {};
|
|
8512
|
-
validateFieldRecursively(workingErrors, formFieldRegistry.getForm());
|
|
8513
|
-
const filteredErrors = this._applyConditions(workingErrors, data, {
|
|
8514
|
-
getFilterPath: getErrorPath,
|
|
8515
|
-
leafNodeDeletionOnly: true
|
|
8516
8708
|
});
|
|
8517
8709
|
this._setState({
|
|
8518
|
-
errors
|
|
8710
|
+
errors
|
|
8519
8711
|
});
|
|
8520
|
-
|
|
8712
|
+
|
|
8713
|
+
// @ts-ignore
|
|
8714
|
+
return errors;
|
|
8521
8715
|
}
|
|
8522
8716
|
|
|
8523
8717
|
/**
|
|
@@ -8612,26 +8806,27 @@ class Form {
|
|
|
8612
8806
|
/**
|
|
8613
8807
|
* @internal
|
|
8614
8808
|
*
|
|
8615
|
-
* @param { {
|
|
8809
|
+
* @param { { fieldInstance: any, value: any } } update
|
|
8616
8810
|
*/
|
|
8617
8811
|
_update(update) {
|
|
8618
8812
|
const {
|
|
8619
|
-
|
|
8620
|
-
indexes,
|
|
8813
|
+
fieldInstance,
|
|
8621
8814
|
value
|
|
8622
8815
|
} = update;
|
|
8816
|
+
const {
|
|
8817
|
+
id,
|
|
8818
|
+
valuePath,
|
|
8819
|
+
indexes
|
|
8820
|
+
} = fieldInstance;
|
|
8623
8821
|
const {
|
|
8624
8822
|
data,
|
|
8625
8823
|
errors
|
|
8626
8824
|
} = this._getState();
|
|
8627
|
-
const validator = this.get('validator')
|
|
8628
|
-
|
|
8629
|
-
const fieldErrors = validator.validateField(field, value);
|
|
8630
|
-
const valuePath = pathRegistry.getValuePath(field, {
|
|
8631
|
-
indexes
|
|
8632
|
-
});
|
|
8825
|
+
const validator = this.get('validator');
|
|
8826
|
+
const fieldErrors = validator.validateFieldInstance(fieldInstance, value);
|
|
8633
8827
|
set(data, valuePath, value);
|
|
8634
|
-
set(errors, [
|
|
8828
|
+
set(errors, [id, ...Object.values(indexes || {})], fieldErrors.length ? fieldErrors : undefined);
|
|
8829
|
+
this._emit('field.updated', update);
|
|
8635
8830
|
this._setState({
|
|
8636
8831
|
data: clone(data),
|
|
8637
8832
|
errors: clone(errors)
|
|
@@ -8657,10 +8852,10 @@ class Form {
|
|
|
8657
8852
|
}
|
|
8658
8853
|
|
|
8659
8854
|
/**
|
|
8660
|
-
|
|
8661
|
-
|
|
8855
|
+
* @internal
|
|
8856
|
+
*/
|
|
8662
8857
|
_getModules() {
|
|
8663
|
-
return [ExpressionLanguageModule, MarkdownRendererModule, ViewerCommandsModule, RepeatRenderModule];
|
|
8858
|
+
return [ExpressionLanguageModule, ExpressionFieldModule, MarkdownRendererModule, ViewerCommandsModule, RepeatRenderModule];
|
|
8664
8859
|
}
|
|
8665
8860
|
|
|
8666
8861
|
/**
|
|
@@ -8675,65 +8870,24 @@ class Form {
|
|
|
8675
8870
|
*/
|
|
8676
8871
|
_getSubmitData() {
|
|
8677
8872
|
const formFieldRegistry = this.get('formFieldRegistry');
|
|
8678
|
-
const
|
|
8679
|
-
const pathRegistry = this.get('pathRegistry');
|
|
8873
|
+
const formFieldInstanceRegistry = this.get('formFieldInstanceRegistry');
|
|
8680
8874
|
const formData = this._getState().data;
|
|
8681
|
-
|
|
8875
|
+
const submitData = {};
|
|
8876
|
+
formFieldInstanceRegistry.getAllKeyed().forEach(formFieldInstance => {
|
|
8682
8877
|
const {
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
} =
|
|
8878
|
+
id,
|
|
8879
|
+
valuePath
|
|
8880
|
+
} = formFieldInstance;
|
|
8686
8881
|
const {
|
|
8687
|
-
|
|
8688
|
-
} =
|
|
8689
|
-
|
|
8690
|
-
// (1) Process keyed fields
|
|
8691
|
-
if (!disabled && fieldConfig.keyed) {
|
|
8692
|
-
const valuePath = pathRegistry.getValuePath(formField, {
|
|
8693
|
-
indexes
|
|
8694
|
-
});
|
|
8695
|
-
const value = get(formData, valuePath);
|
|
8696
|
-
set(submitData, valuePath, value);
|
|
8697
|
-
}
|
|
8698
|
-
|
|
8699
|
-
// (2) Process parents
|
|
8700
|
-
if (!Array.isArray(formField.components)) {
|
|
8701
|
-
return;
|
|
8702
|
-
}
|
|
8703
|
-
|
|
8704
|
-
// (3a) Recurse repeatable parents both across the indexes of repetition and the children
|
|
8705
|
-
if (fieldConfig.repeatable && formField.isRepeating) {
|
|
8706
|
-
const valueData = get(formData, pathRegistry.getValuePath(formField, {
|
|
8707
|
-
indexes
|
|
8708
|
-
}));
|
|
8709
|
-
if (!Array.isArray(valueData)) {
|
|
8710
|
-
return;
|
|
8711
|
-
}
|
|
8712
|
-
valueData.forEach((_, index) => {
|
|
8713
|
-
formField.components.forEach(component => {
|
|
8714
|
-
collectSubmitDataRecursively(submitData, component, {
|
|
8715
|
-
...indexes,
|
|
8716
|
-
[formField.id]: index
|
|
8717
|
-
});
|
|
8718
|
-
});
|
|
8719
|
-
});
|
|
8882
|
+
disabled
|
|
8883
|
+
} = formFieldRegistry.get(id);
|
|
8884
|
+
if (disabled) {
|
|
8720
8885
|
return;
|
|
8721
8886
|
}
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
const workingSubmitData = {};
|
|
8727
|
-
collectSubmitDataRecursively(workingSubmitData, formFieldRegistry.getForm(), {});
|
|
8728
|
-
return this._applyConditions(workingSubmitData, formData);
|
|
8729
|
-
}
|
|
8730
|
-
|
|
8731
|
-
/**
|
|
8732
|
-
* @internal
|
|
8733
|
-
*/
|
|
8734
|
-
_applyConditions(toFilter, data, options = {}) {
|
|
8735
|
-
const conditionChecker = this.get('conditionChecker');
|
|
8736
|
-
return conditionChecker.applyConditions(toFilter, data, options);
|
|
8887
|
+
const value = get(formData, valuePath);
|
|
8888
|
+
set(submitData, valuePath, value);
|
|
8889
|
+
});
|
|
8890
|
+
return submitData;
|
|
8737
8891
|
}
|
|
8738
8892
|
|
|
8739
8893
|
/**
|
|
@@ -8828,16 +8982,16 @@ class Form {
|
|
|
8828
8982
|
|
|
8829
8983
|
const schemaVersion = 16;
|
|
8830
8984
|
|
|
8831
|
-
/**
|
|
8832
|
-
* @typedef { import('./types').CreateFormOptions } CreateFormOptions
|
|
8985
|
+
/**
|
|
8986
|
+
* @typedef { import('./types').CreateFormOptions } CreateFormOptions
|
|
8833
8987
|
*/
|
|
8834
8988
|
|
|
8835
|
-
/**
|
|
8836
|
-
* Create a form.
|
|
8837
|
-
*
|
|
8838
|
-
* @param {CreateFormOptions} options
|
|
8839
|
-
*
|
|
8840
|
-
* @return {Promise<Form>}
|
|
8989
|
+
/**
|
|
8990
|
+
* Create a form.
|
|
8991
|
+
*
|
|
8992
|
+
* @param {CreateFormOptions} options
|
|
8993
|
+
*
|
|
8994
|
+
* @return {Promise<Form>}
|
|
8841
8995
|
*/
|
|
8842
8996
|
function createForm(options) {
|
|
8843
8997
|
const {
|
|
@@ -8851,5 +9005,5 @@ function createForm(options) {
|
|
|
8851
9005
|
});
|
|
8852
9006
|
}
|
|
8853
9007
|
|
|
8854
|
-
export { ALLOW_ATTRIBUTE, Button, Checkbox, Checklist, ConditionChecker, DATETIME_SUBTYPES, DATETIME_SUBTYPES_LABELS, DATETIME_SUBTYPE_PATH, DATE_DISALLOW_PAST_PATH, DATE_LABEL_PATH, Datetime, Default, Description, DynamicList, Errors, ExpressionField, ExpressionLanguageModule, FeelExpressionLanguage, FeelersTemplating, FieldFactory, Form, FormComponent, FormContext, FormField, FormFieldRegistry, FormFields, FormLayouter, FormRenderContext, Group, Html, IFrame, Image, Importer, Label, LocalExpressionContext, MINUTES_IN_DAY, MarkdownRenderer, MarkdownRendererModule, Numberfield, OPTIONS_SOURCES, OPTIONS_SOURCES_DEFAULTS, OPTIONS_SOURCES_LABELS, OPTIONS_SOURCES_PATHS, OPTIONS_SOURCE_DEFAULT, PathRegistry, Radio, RenderModule, RepeatRenderManager, RepeatRenderModule, SANDBOX_ATTRIBUTE, SECURITY_ATTRIBUTES_DEFINITIONS, Select, Separator, Spacer, TIME_INTERVAL_PATH, TIME_LABEL_PATH, TIME_SERIALISINGFORMAT_LABELS, TIME_SERIALISING_FORMATS, TIME_SERIALISING_FORMAT_PATH, TIME_USE24H_PATH, Table, Taglist, Text, Textarea, Textfield, ViewerCommands, ViewerCommandsModule, buildExpressionContext, clone, createForm, createFormContainer, createInjector, escapeHTML, formFields, generateIdForType, generateIndexForType, getAncestryList, getOptionsSource, getSchemaVariables, getScrollContainer, hasEqualValue, iconsByType, isRequired, pathParse, pathsEqual, runRecursively, sanitizeDateTimePickerValue, sanitizeHTML, sanitizeIFrameSource, sanitizeImageSource, sanitizeMultiSelectValue, sanitizeSingleSelectValue, schemaVersion, useExpressionEvaluation, useSingleLineTemplateEvaluation, useTemplateEvaluation, wrapCSSStyles };
|
|
9008
|
+
export { ALLOW_ATTRIBUTE, Button, Checkbox, Checklist, ConditionChecker, DATETIME_SUBTYPES, DATETIME_SUBTYPES_LABELS, DATETIME_SUBTYPE_PATH, DATE_DISALLOW_PAST_PATH, DATE_LABEL_PATH, Datetime, Default, Description, DynamicList, Errors, ExpressionField, ExpressionFieldModule, ExpressionLanguageModule, ExpressionLoopPreventer, FeelExpressionLanguage, FeelersTemplating, FieldFactory, Form, FormComponent, FormContext, FormField, FormFieldRegistry, FormFields, FormLayouter, FormRenderContext, Group, Html, IFrame, Image, Importer, Label, LocalExpressionContext, MINUTES_IN_DAY, MarkdownRenderer, MarkdownRendererModule, Numberfield, OPTIONS_SOURCES, OPTIONS_SOURCES_DEFAULTS, OPTIONS_SOURCES_LABELS, OPTIONS_SOURCES_PATHS, OPTIONS_SOURCE_DEFAULT, PathRegistry, Radio, RenderModule, RepeatRenderManager, RepeatRenderModule, SANDBOX_ATTRIBUTE, SECURITY_ATTRIBUTES_DEFINITIONS, Select, Separator, Spacer, TIME_INTERVAL_PATH, TIME_LABEL_PATH, TIME_SERIALISINGFORMAT_LABELS, TIME_SERIALISING_FORMATS, TIME_SERIALISING_FORMAT_PATH, TIME_USE24H_PATH, Table, Taglist, Text, Textarea, Textfield, ViewerCommands, ViewerCommandsModule, buildExpressionContext, clone, createForm, createFormContainer, createInjector, escapeHTML, formFields, generateIdForType, generateIndexForType, getAncestryList, getOptionsSource, getSchemaVariables, getScrollContainer, hasEqualValue, iconsByType, isRequired, pathParse, pathsEqual, runExpressionEvaluation, runRecursively, sanitizeDateTimePickerValue, sanitizeHTML, sanitizeIFrameSource, sanitizeImageSource, sanitizeMultiSelectValue, sanitizeSingleSelectValue, schemaVersion, useExpressionEvaluation, useSingleLineTemplateEvaluation, useTemplateEvaluation, wrapCSSStyles, wrapObjectKeysWithUnderscores };
|
|
8855
9009
|
//# sourceMappingURL=index.es.js.map
|