@bpmn-io/form-js-viewer 1.8.0 → 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 +60 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +61 -25
- package/dist/index.es.js.map +1 -1
- package/dist/types/Form.d.ts +1 -0
- 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/dist/types/util/injector.d.ts +1 -1
- package/package.json +4 -3
- package/dist/types/render/hooks/useEffectOnChange.d.ts +0 -1
package/dist/index.es.js
CHANGED
|
@@ -8,7 +8,7 @@ import { createContext, createElement, Fragment as Fragment$1, render } from 'pr
|
|
|
8
8
|
import isEqual from 'lodash/isEqual';
|
|
9
9
|
import flatpickr from 'flatpickr';
|
|
10
10
|
import * as React from 'preact/compat';
|
|
11
|
-
import {
|
|
11
|
+
import { createPortal } from 'preact/compat';
|
|
12
12
|
import DOMPurify from 'dompurify';
|
|
13
13
|
import { Injector } from 'didi';
|
|
14
14
|
import { parseExpression, parseUnaryTests, evaluate, unaryTest } from 'feelin';
|
|
@@ -1300,17 +1300,6 @@ function useFlushDebounce(func) {
|
|
|
1300
1300
|
return [debounceFunc, flushFunc];
|
|
1301
1301
|
}
|
|
1302
1302
|
|
|
1303
|
-
function useEffectOnChange(value, callback, dependencies = []) {
|
|
1304
|
-
const previousValue = usePrevious(value);
|
|
1305
|
-
useEffect$1(() => {
|
|
1306
|
-
if (value !== previousValue) {
|
|
1307
|
-
callback();
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1311
|
-
}, [value, ...dependencies]);
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
1303
|
/**
|
|
1315
1304
|
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
1316
1305
|
* Memoised to minimize re-renders
|
|
@@ -1501,6 +1490,18 @@ function formatTimezoneOffset(minutes) {
|
|
|
1501
1490
|
function isInvalidDateString(value) {
|
|
1502
1491
|
return isNaN(new Date(Date.parse(value)).getTime());
|
|
1503
1492
|
}
|
|
1493
|
+
function getNullDateTime() {
|
|
1494
|
+
return {
|
|
1495
|
+
date: new Date(Date.parse(null)),
|
|
1496
|
+
time: null
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
function isValidDate(date) {
|
|
1500
|
+
return date && !isNaN(date.getTime());
|
|
1501
|
+
}
|
|
1502
|
+
function isValidTime(time) {
|
|
1503
|
+
return !isNaN(parseInt(time));
|
|
1504
|
+
}
|
|
1504
1505
|
function _getSignedPaddedHours(minutes) {
|
|
1505
1506
|
if (minutes > 0) {
|
|
1506
1507
|
return '-' + _getZeroPaddedString(Math.floor(minutes / 60));
|
|
@@ -1991,7 +1992,8 @@ function FormField(props) {
|
|
|
1991
1992
|
};
|
|
1992
1993
|
}, [eventBus, viewerCommands]);
|
|
1993
1994
|
useEffect(() => {
|
|
1994
|
-
|
|
1995
|
+
const hasInitialValue = initialValue && !isEqual(initialValue, []);
|
|
1996
|
+
if (initialValidationTrigger && hasInitialValue) {
|
|
1995
1997
|
setInitialValidationTrigger(false);
|
|
1996
1998
|
viewerCommands.updateFieldValidation(field, initialValue, indexes);
|
|
1997
1999
|
}
|
|
@@ -2795,14 +2797,8 @@ function Datetime(props) {
|
|
|
2795
2797
|
formId
|
|
2796
2798
|
} = useContext(FormContext);
|
|
2797
2799
|
const dateTimeGroupRef = useRef();
|
|
2798
|
-
const getNullDateTime = () => ({
|
|
2799
|
-
date: new Date(Date.parse(null)),
|
|
2800
|
-
time: null
|
|
2801
|
-
});
|
|
2802
2800
|
const [dateTime, setDateTime] = useState(getNullDateTime());
|
|
2803
2801
|
const [dateTimeUpdateRequest, setDateTimeUpdateRequest] = useState(null);
|
|
2804
|
-
const isValidDate = date => date && !isNaN(date.getTime());
|
|
2805
|
-
const isValidTime = time => !isNaN(parseInt(time));
|
|
2806
2802
|
const useDatePicker = useMemo(() => subtype === DATETIME_SUBTYPES.DATE || subtype === DATETIME_SUBTYPES.DATETIME, [subtype]);
|
|
2807
2803
|
const useTimePicker = useMemo(() => subtype === DATETIME_SUBTYPES.TIME || subtype === DATETIME_SUBTYPES.DATETIME, [subtype]);
|
|
2808
2804
|
const onDateTimeBlur = useCallback(e => {
|
|
@@ -2857,11 +2853,14 @@ function Datetime(props) {
|
|
|
2857
2853
|
} else if (subtype === DATETIME_SUBTYPES.DATETIME && isValidDate(date) && isValidTime(time)) {
|
|
2858
2854
|
newDateTimeValue = serializeDateTime(date, time, timeSerializingFormat);
|
|
2859
2855
|
}
|
|
2856
|
+
if (value === newDateTimeValue) {
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2860
2859
|
onChange({
|
|
2861
2860
|
value: newDateTimeValue,
|
|
2862
2861
|
field
|
|
2863
2862
|
});
|
|
2864
|
-
}, [field, onChange, subtype, timeSerializingFormat]);
|
|
2863
|
+
}, [value, field, onChange, subtype, timeSerializingFormat]);
|
|
2865
2864
|
useEffect(() => {
|
|
2866
2865
|
if (dateTimeUpdateRequest) {
|
|
2867
2866
|
if (dateTimeUpdateRequest.refreshOnly) {
|
|
@@ -4928,7 +4927,7 @@ function Html(props) {
|
|
|
4928
4927
|
Html.config = {
|
|
4929
4928
|
type: type$4,
|
|
4930
4929
|
keyed: false,
|
|
4931
|
-
label: 'HTML',
|
|
4930
|
+
label: 'HTML view',
|
|
4932
4931
|
group: 'presentation',
|
|
4933
4932
|
create: (options = {}) => ({
|
|
4934
4933
|
content: '',
|
|
@@ -4940,7 +4939,8 @@ const type$3 = 'expression';
|
|
|
4940
4939
|
function ExpressionField(props) {
|
|
4941
4940
|
const {
|
|
4942
4941
|
field,
|
|
4943
|
-
onChange
|
|
4942
|
+
onChange,
|
|
4943
|
+
value
|
|
4944
4944
|
} = props;
|
|
4945
4945
|
const {
|
|
4946
4946
|
computeOn,
|
|
@@ -4955,12 +4955,12 @@ function ExpressionField(props) {
|
|
|
4955
4955
|
value: evaluationMemo
|
|
4956
4956
|
});
|
|
4957
4957
|
}, [field, evaluationMemo, onChange]);
|
|
4958
|
-
|
|
4959
|
-
if (computeOn !== 'change') {
|
|
4958
|
+
useEffect(() => {
|
|
4959
|
+
if (computeOn !== 'change' || evaluationMemo === value) {
|
|
4960
4960
|
return;
|
|
4961
4961
|
}
|
|
4962
4962
|
sendValue();
|
|
4963
|
-
}, [computeOn, sendValue]);
|
|
4963
|
+
}, [computeOn, evaluationMemo, sendValue, value]);
|
|
4964
4964
|
useEffect(() => {
|
|
4965
4965
|
if (computeOn === 'presubmit') {
|
|
4966
4966
|
eventBus.on('presubmit', sendValue);
|
|
@@ -4974,6 +4974,7 @@ ExpressionField.config = {
|
|
|
4974
4974
|
label: 'Expression',
|
|
4975
4975
|
group: 'basic-input',
|
|
4976
4976
|
keyed: true,
|
|
4977
|
+
emptyValue: null,
|
|
4977
4978
|
escapeGridRender: true,
|
|
4978
4979
|
create: (options = {}) => ({
|
|
4979
4980
|
computeOn: 'change',
|
|
@@ -7002,6 +7003,8 @@ var slice = Array.prototype.slice;
|
|
|
7002
7003
|
* var sum = eventBus.fire('sum', 1, 2);
|
|
7003
7004
|
* console.log(sum); // 3
|
|
7004
7005
|
* ```
|
|
7006
|
+
*
|
|
7007
|
+
* @template [EventMap=null]
|
|
7005
7008
|
*/
|
|
7006
7009
|
function EventBus() {
|
|
7007
7010
|
/**
|
|
@@ -7015,6 +7018,8 @@ function EventBus() {
|
|
|
7015
7018
|
}
|
|
7016
7019
|
|
|
7017
7020
|
/**
|
|
7021
|
+
* @overlord
|
|
7022
|
+
*
|
|
7018
7023
|
* Register an event listener for events with the given name.
|
|
7019
7024
|
*
|
|
7020
7025
|
* The callback will be invoked with `event, ...additionalArguments`
|
|
@@ -7033,6 +7038,25 @@ function EventBus() {
|
|
|
7033
7038
|
* @param {EventBusEventCallback<T>} callback
|
|
7034
7039
|
* @param {any} [that] callback context
|
|
7035
7040
|
*/
|
|
7041
|
+
/**
|
|
7042
|
+
* Register an event listener for events with the given name.
|
|
7043
|
+
*
|
|
7044
|
+
* The callback will be invoked with `event, ...additionalArguments`
|
|
7045
|
+
* that have been passed to {@link EventBus#fire}.
|
|
7046
|
+
*
|
|
7047
|
+
* Returning false from a listener will prevent the events default action
|
|
7048
|
+
* (if any is specified). To stop an event from being processed further in
|
|
7049
|
+
* other listeners execute {@link Event#stopPropagation}.
|
|
7050
|
+
*
|
|
7051
|
+
* Returning anything but `undefined` from a listener will stop the listener propagation.
|
|
7052
|
+
*
|
|
7053
|
+
* @template {keyof EventMap} EventName
|
|
7054
|
+
*
|
|
7055
|
+
* @param {EventName} events to subscribe to
|
|
7056
|
+
* @param {number} [priority=1000] listen priority
|
|
7057
|
+
* @param {EventBusEventCallback<EventMap[EventName]>} callback
|
|
7058
|
+
* @param {any} [that] callback context
|
|
7059
|
+
*/
|
|
7036
7060
|
EventBus.prototype.on = function (events, priority, callback, that) {
|
|
7037
7061
|
events = isArray(events) ? events : [events];
|
|
7038
7062
|
if (isFunction(priority)) {
|
|
@@ -7063,6 +7087,8 @@ EventBus.prototype.on = function (events, priority, callback, that) {
|
|
|
7063
7087
|
};
|
|
7064
7088
|
|
|
7065
7089
|
/**
|
|
7090
|
+
* @overlord
|
|
7091
|
+
*
|
|
7066
7092
|
* Register an event listener that is called only once.
|
|
7067
7093
|
*
|
|
7068
7094
|
* @template T
|
|
@@ -7072,6 +7098,16 @@ EventBus.prototype.on = function (events, priority, callback, that) {
|
|
|
7072
7098
|
* @param {EventBusEventCallback<T>} callback
|
|
7073
7099
|
* @param {any} [that] callback context
|
|
7074
7100
|
*/
|
|
7101
|
+
/**
|
|
7102
|
+
* Register an event listener that is called only once.
|
|
7103
|
+
*
|
|
7104
|
+
* @template {keyof EventMap} EventName
|
|
7105
|
+
*
|
|
7106
|
+
* @param {EventName} events to subscribe to
|
|
7107
|
+
* @param {number} [priority=1000] listen priority
|
|
7108
|
+
* @param {EventBusEventCallback<EventMap[EventName]>} callback
|
|
7109
|
+
* @param {any} [that] callback context
|
|
7110
|
+
*/
|
|
7075
7111
|
EventBus.prototype.once = function (events, priority, callback, that) {
|
|
7076
7112
|
var self = this;
|
|
7077
7113
|
if (isFunction(priority)) {
|