@bpmn-io/form-js-viewer 1.21.3 → 1.23.1
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 +22 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +24 -20
- package/dist/index.es.js.map +1 -1
- package/dist/types/features/expressionLanguage/FeelersTemplating.d.ts +13 -13
- package/dist/types/render/components/util/numberFieldUtil.d.ts +1 -0
- package/package.json +8 -8
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ids } from 'ids';
|
|
2
|
-
import { isString, get, isNil, isObject, some, isNumber, set, findIndex, isArray,
|
|
2
|
+
import { isString, get, isNil, isObject, some, isNumber, set, isDefined, findIndex, isArray, values, uniqueBy, isFunction, bind, assign, groupBy, isUndefined } from 'min-dash';
|
|
3
3
|
import Big from 'big.js';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'preact/jsx-runtime';
|
|
@@ -13,7 +13,7 @@ import { createPortal } from 'preact/compat';
|
|
|
13
13
|
import DOMPurify from 'dompurify';
|
|
14
14
|
import { Injector } from 'didi';
|
|
15
15
|
import { parseExpression, parseUnaryTests, evaluate, unaryTest } from '@bpmn-io/feelin';
|
|
16
|
-
import { evaluate as evaluate$1,
|
|
16
|
+
import { evaluate as evaluate$1, parseToSimpleTree } from 'feelers';
|
|
17
17
|
import { marked } from 'marked';
|
|
18
18
|
|
|
19
19
|
const getFlavouredFeelVariableNames = (feelString, feelFlavour = 'expression', options = {}) => {
|
|
@@ -356,7 +356,7 @@ class FeelersTemplating {
|
|
|
356
356
|
* @param {Object} options
|
|
357
357
|
* @param {boolean} [options.debug = false]
|
|
358
358
|
* @param {boolean} [options.strict = false]
|
|
359
|
-
* @param {
|
|
359
|
+
* @param {(error: Error) => string} [options.buildDebugString]
|
|
360
360
|
* @param {Function} [options.sanitizer]
|
|
361
361
|
*
|
|
362
362
|
* @returns
|
|
@@ -383,20 +383,19 @@ class FeelersTemplating {
|
|
|
383
383
|
*/
|
|
384
384
|
|
|
385
385
|
/**
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
386
|
+
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
387
|
+
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
388
|
+
* @name _extractExpressionsWithDepth
|
|
389
|
+
* @param {string} template - A feelers template string.
|
|
390
|
+
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
394
|
+
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
395
|
+
*/
|
|
396
396
|
_extractExpressionsWithDepth(template) {
|
|
397
397
|
// build simplified feelers syntax tree
|
|
398
|
-
const
|
|
399
|
-
const tree = buildSimpleTree(parseTree, template);
|
|
398
|
+
const tree = parseToSimpleTree(template);
|
|
400
399
|
return function _traverse(n, depth = 0) {
|
|
401
400
|
if (['Feel', 'FeelBlock'].includes(n.name)) {
|
|
402
401
|
return [{
|
|
@@ -3810,6 +3809,11 @@ function willKeyProduceValidNumber(key, previousValue, caretIndex, selectionWidt
|
|
|
3810
3809
|
function isNullEquivalentValue(value) {
|
|
3811
3810
|
return value === undefined || value === null || value === '';
|
|
3812
3811
|
}
|
|
3812
|
+
function serializeToInputString(value) {
|
|
3813
|
+
if (value === undefined || value === null) return '';
|
|
3814
|
+
if (typeof value !== 'string' && typeof value !== 'number') return '';
|
|
3815
|
+
return value.toString();
|
|
3816
|
+
}
|
|
3813
3817
|
|
|
3814
3818
|
const type$d = 'number';
|
|
3815
3819
|
function Numberfield(props) {
|
|
@@ -3893,7 +3897,7 @@ function Numberfield(props) {
|
|
|
3893
3897
|
const outerValueChanged = previousValue != value;
|
|
3894
3898
|
const outerValueEqualsCache = sanitize(value) === sanitize(cachedValue);
|
|
3895
3899
|
if (outerValueChanged && !outerValueEqualsCache) {
|
|
3896
|
-
setValue(value
|
|
3900
|
+
setValue(serializeToInputString(value));
|
|
3897
3901
|
}
|
|
3898
3902
|
|
|
3899
3903
|
// caches the value an increment/decrement operation will be based on
|
|
@@ -4221,7 +4225,7 @@ function SearchableSelect(props) {
|
|
|
4221
4225
|
onChange: props.onChange
|
|
4222
4226
|
});
|
|
4223
4227
|
const getLabelCorrelation = useGetLabelCorrelation(options);
|
|
4224
|
-
const label = useMemo(() => value
|
|
4228
|
+
const label = useMemo(() => isDefined(value) ? getLabelCorrelation(value) : undefined, [value, getLabelCorrelation]);
|
|
4225
4229
|
|
|
4226
4230
|
// whenever we change the underlying value, set the label to it
|
|
4227
4231
|
useEffect(() => {
|
|
@@ -4239,7 +4243,7 @@ function SearchableSelect(props) {
|
|
|
4239
4243
|
const pickOption = useCallback(option => {
|
|
4240
4244
|
setFilter(option && option.label || '');
|
|
4241
4245
|
props.onChange({
|
|
4242
|
-
value: option
|
|
4246
|
+
value: option?.value ?? null
|
|
4243
4247
|
});
|
|
4244
4248
|
}, [props]);
|
|
4245
4249
|
const displayState = useMemo(() => {
|
|
@@ -4386,10 +4390,10 @@ function SimpleSelect(props) {
|
|
|
4386
4390
|
onChange: props.onChange
|
|
4387
4391
|
});
|
|
4388
4392
|
const getLabelCorrelation = useGetLabelCorrelation(options);
|
|
4389
|
-
const valueLabel = useMemo(() => value
|
|
4393
|
+
const valueLabel = useMemo(() => isDefined(value) ? getLabelCorrelation(value) : undefined, [value, getLabelCorrelation]);
|
|
4390
4394
|
const pickOption = useCallback(option => {
|
|
4391
4395
|
props.onChange({
|
|
4392
|
-
value: option
|
|
4396
|
+
value: option?.value ?? null
|
|
4393
4397
|
});
|
|
4394
4398
|
}, [props]);
|
|
4395
4399
|
const displayState = useMemo(() => {
|