@bpmn-io/form-js-viewer 1.8.1 → 1.8.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.cjs +25 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +26 -25
- package/dist/index.es.js.map +1 -1
- package/dist/types/render/components/form-fields/ExpressionField.d.ts +1 -0
- package/dist/types/render/components/util/dateTimeUtil.d.ts +6 -0
- package/dist/types/render/hooks/index.d.ts +0 -1
- package/package.json +3 -2
- package/dist/types/render/hooks/useEffectOnChange.d.ts +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1320,17 +1320,6 @@ function useFlushDebounce(func) {
|
|
|
1320
1320
|
return [debounceFunc, flushFunc];
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
|
-
function useEffectOnChange(value, callback, dependencies = []) {
|
|
1324
|
-
const previousValue = usePrevious(value);
|
|
1325
|
-
React.useEffect(() => {
|
|
1326
|
-
if (value !== previousValue) {
|
|
1327
|
-
callback();
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1331
|
-
}, [value, ...dependencies]);
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
1323
|
/**
|
|
1335
1324
|
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
1336
1325
|
* Memoised to minimize re-renders
|
|
@@ -1521,6 +1510,18 @@ function formatTimezoneOffset(minutes) {
|
|
|
1521
1510
|
function isInvalidDateString(value) {
|
|
1522
1511
|
return isNaN(new Date(Date.parse(value)).getTime());
|
|
1523
1512
|
}
|
|
1513
|
+
function getNullDateTime() {
|
|
1514
|
+
return {
|
|
1515
|
+
date: new Date(Date.parse(null)),
|
|
1516
|
+
time: null
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
function isValidDate(date) {
|
|
1520
|
+
return date && !isNaN(date.getTime());
|
|
1521
|
+
}
|
|
1522
|
+
function isValidTime(time) {
|
|
1523
|
+
return !isNaN(parseInt(time));
|
|
1524
|
+
}
|
|
1524
1525
|
function _getSignedPaddedHours(minutes) {
|
|
1525
1526
|
if (minutes > 0) {
|
|
1526
1527
|
return '-' + _getZeroPaddedString(Math.floor(minutes / 60));
|
|
@@ -2011,7 +2012,8 @@ function FormField(props) {
|
|
|
2011
2012
|
};
|
|
2012
2013
|
}, [eventBus, viewerCommands]);
|
|
2013
2014
|
hooks.useEffect(() => {
|
|
2014
|
-
|
|
2015
|
+
const hasInitialValue = initialValue && !isEqual(initialValue, []);
|
|
2016
|
+
if (initialValidationTrigger && hasInitialValue) {
|
|
2015
2017
|
setInitialValidationTrigger(false);
|
|
2016
2018
|
viewerCommands.updateFieldValidation(field, initialValue, indexes);
|
|
2017
2019
|
}
|
|
@@ -2815,14 +2817,8 @@ function Datetime(props) {
|
|
|
2815
2817
|
formId
|
|
2816
2818
|
} = hooks.useContext(FormContext);
|
|
2817
2819
|
const dateTimeGroupRef = hooks.useRef();
|
|
2818
|
-
const getNullDateTime = () => ({
|
|
2819
|
-
date: new Date(Date.parse(null)),
|
|
2820
|
-
time: null
|
|
2821
|
-
});
|
|
2822
2820
|
const [dateTime, setDateTime] = hooks.useState(getNullDateTime());
|
|
2823
2821
|
const [dateTimeUpdateRequest, setDateTimeUpdateRequest] = hooks.useState(null);
|
|
2824
|
-
const isValidDate = date => date && !isNaN(date.getTime());
|
|
2825
|
-
const isValidTime = time => !isNaN(parseInt(time));
|
|
2826
2822
|
const useDatePicker = hooks.useMemo(() => subtype === DATETIME_SUBTYPES.DATE || subtype === DATETIME_SUBTYPES.DATETIME, [subtype]);
|
|
2827
2823
|
const useTimePicker = hooks.useMemo(() => subtype === DATETIME_SUBTYPES.TIME || subtype === DATETIME_SUBTYPES.DATETIME, [subtype]);
|
|
2828
2824
|
const onDateTimeBlur = hooks.useCallback(e => {
|
|
@@ -2877,11 +2873,14 @@ function Datetime(props) {
|
|
|
2877
2873
|
} else if (subtype === DATETIME_SUBTYPES.DATETIME && isValidDate(date) && isValidTime(time)) {
|
|
2878
2874
|
newDateTimeValue = serializeDateTime(date, time, timeSerializingFormat);
|
|
2879
2875
|
}
|
|
2876
|
+
if (value === newDateTimeValue) {
|
|
2877
|
+
return;
|
|
2878
|
+
}
|
|
2880
2879
|
onChange({
|
|
2881
2880
|
value: newDateTimeValue,
|
|
2882
2881
|
field
|
|
2883
2882
|
});
|
|
2884
|
-
}, [field, onChange, subtype, timeSerializingFormat]);
|
|
2883
|
+
}, [value, field, onChange, subtype, timeSerializingFormat]);
|
|
2885
2884
|
hooks.useEffect(() => {
|
|
2886
2885
|
if (dateTimeUpdateRequest) {
|
|
2887
2886
|
if (dateTimeUpdateRequest.refreshOnly) {
|
|
@@ -4948,7 +4947,7 @@ function Html(props) {
|
|
|
4948
4947
|
Html.config = {
|
|
4949
4948
|
type: type$4,
|
|
4950
4949
|
keyed: false,
|
|
4951
|
-
label: 'HTML',
|
|
4950
|
+
label: 'HTML view',
|
|
4952
4951
|
group: 'presentation',
|
|
4953
4952
|
create: (options = {}) => ({
|
|
4954
4953
|
content: '',
|
|
@@ -4960,7 +4959,8 @@ const type$3 = 'expression';
|
|
|
4960
4959
|
function ExpressionField(props) {
|
|
4961
4960
|
const {
|
|
4962
4961
|
field,
|
|
4963
|
-
onChange
|
|
4962
|
+
onChange,
|
|
4963
|
+
value
|
|
4964
4964
|
} = props;
|
|
4965
4965
|
const {
|
|
4966
4966
|
computeOn,
|
|
@@ -4975,12 +4975,12 @@ function ExpressionField(props) {
|
|
|
4975
4975
|
value: evaluationMemo
|
|
4976
4976
|
});
|
|
4977
4977
|
}, [field, evaluationMemo, onChange]);
|
|
4978
|
-
|
|
4979
|
-
if (computeOn !== 'change') {
|
|
4978
|
+
hooks.useEffect(() => {
|
|
4979
|
+
if (computeOn !== 'change' || evaluationMemo === value) {
|
|
4980
4980
|
return;
|
|
4981
4981
|
}
|
|
4982
4982
|
sendValue();
|
|
4983
|
-
}, [computeOn, sendValue]);
|
|
4983
|
+
}, [computeOn, evaluationMemo, sendValue, value]);
|
|
4984
4984
|
hooks.useEffect(() => {
|
|
4985
4985
|
if (computeOn === 'presubmit') {
|
|
4986
4986
|
eventBus.on('presubmit', sendValue);
|
|
@@ -4994,6 +4994,7 @@ ExpressionField.config = {
|
|
|
4994
4994
|
label: 'Expression',
|
|
4995
4995
|
group: 'basic-input',
|
|
4996
4996
|
keyed: true,
|
|
4997
|
+
emptyValue: null,
|
|
4997
4998
|
escapeGridRender: true,
|
|
4998
4999
|
create: (options = {}) => ({
|
|
4999
5000
|
computeOn: 'change',
|