@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.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',
|
|
@@ -7022,6 +7023,8 @@ var slice = Array.prototype.slice;
|
|
|
7022
7023
|
* var sum = eventBus.fire('sum', 1, 2);
|
|
7023
7024
|
* console.log(sum); // 3
|
|
7024
7025
|
* ```
|
|
7026
|
+
*
|
|
7027
|
+
* @template [EventMap=null]
|
|
7025
7028
|
*/
|
|
7026
7029
|
function EventBus() {
|
|
7027
7030
|
/**
|
|
@@ -7035,6 +7038,8 @@ function EventBus() {
|
|
|
7035
7038
|
}
|
|
7036
7039
|
|
|
7037
7040
|
/**
|
|
7041
|
+
* @overlord
|
|
7042
|
+
*
|
|
7038
7043
|
* Register an event listener for events with the given name.
|
|
7039
7044
|
*
|
|
7040
7045
|
* The callback will be invoked with `event, ...additionalArguments`
|
|
@@ -7053,6 +7058,25 @@ function EventBus() {
|
|
|
7053
7058
|
* @param {EventBusEventCallback<T>} callback
|
|
7054
7059
|
* @param {any} [that] callback context
|
|
7055
7060
|
*/
|
|
7061
|
+
/**
|
|
7062
|
+
* Register an event listener for events with the given name.
|
|
7063
|
+
*
|
|
7064
|
+
* The callback will be invoked with `event, ...additionalArguments`
|
|
7065
|
+
* that have been passed to {@link EventBus#fire}.
|
|
7066
|
+
*
|
|
7067
|
+
* Returning false from a listener will prevent the events default action
|
|
7068
|
+
* (if any is specified). To stop an event from being processed further in
|
|
7069
|
+
* other listeners execute {@link Event#stopPropagation}.
|
|
7070
|
+
*
|
|
7071
|
+
* Returning anything but `undefined` from a listener will stop the listener propagation.
|
|
7072
|
+
*
|
|
7073
|
+
* @template {keyof EventMap} EventName
|
|
7074
|
+
*
|
|
7075
|
+
* @param {EventName} events to subscribe to
|
|
7076
|
+
* @param {number} [priority=1000] listen priority
|
|
7077
|
+
* @param {EventBusEventCallback<EventMap[EventName]>} callback
|
|
7078
|
+
* @param {any} [that] callback context
|
|
7079
|
+
*/
|
|
7056
7080
|
EventBus.prototype.on = function (events, priority, callback, that) {
|
|
7057
7081
|
events = minDash.isArray(events) ? events : [events];
|
|
7058
7082
|
if (minDash.isFunction(priority)) {
|
|
@@ -7083,6 +7107,8 @@ EventBus.prototype.on = function (events, priority, callback, that) {
|
|
|
7083
7107
|
};
|
|
7084
7108
|
|
|
7085
7109
|
/**
|
|
7110
|
+
* @overlord
|
|
7111
|
+
*
|
|
7086
7112
|
* Register an event listener that is called only once.
|
|
7087
7113
|
*
|
|
7088
7114
|
* @template T
|
|
@@ -7092,6 +7118,16 @@ EventBus.prototype.on = function (events, priority, callback, that) {
|
|
|
7092
7118
|
* @param {EventBusEventCallback<T>} callback
|
|
7093
7119
|
* @param {any} [that] callback context
|
|
7094
7120
|
*/
|
|
7121
|
+
/**
|
|
7122
|
+
* Register an event listener that is called only once.
|
|
7123
|
+
*
|
|
7124
|
+
* @template {keyof EventMap} EventName
|
|
7125
|
+
*
|
|
7126
|
+
* @param {EventName} events to subscribe to
|
|
7127
|
+
* @param {number} [priority=1000] listen priority
|
|
7128
|
+
* @param {EventBusEventCallback<EventMap[EventName]>} callback
|
|
7129
|
+
* @param {any} [that] callback context
|
|
7130
|
+
*/
|
|
7095
7131
|
EventBus.prototype.once = function (events, priority, callback, that) {
|
|
7096
7132
|
var self = this;
|
|
7097
7133
|
if (minDash.isFunction(priority)) {
|