@bpmn-io/form-js-viewer 0.10.0 → 0.11.0

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.es.js CHANGED
@@ -602,7 +602,7 @@ class Validator {
602
602
  if (type === 'number') {
603
603
  const {
604
604
  decimalDigits,
605
- step
605
+ increment
606
606
  } = field;
607
607
  if (value === 'NaN') {
608
608
  errors = [...errors, 'Value is not a number.'];
@@ -610,13 +610,13 @@ class Validator {
610
610
  if (decimalDigits >= 0 && countDecimals(value) > decimalDigits) {
611
611
  errors = [...errors, 'Value is expected to ' + (decimalDigits === 0 ? 'be an integer' : `have at most ${decimalDigits} decimal digit${decimalDigits > 1 ? 's' : ''}`) + '.'];
612
612
  }
613
- if (step) {
613
+ if (increment) {
614
614
  const bigValue = Big(value);
615
- const bigStep = Big(step);
616
- const offset = bigValue.mod(bigStep);
615
+ const bigIncrement = Big(increment);
616
+ const offset = bigValue.mod(bigIncrement);
617
617
  if (offset.cmp(0) !== 0) {
618
618
  const previousValue = bigValue.minus(offset);
619
- const nextValue = previousValue.plus(bigStep);
619
+ const nextValue = previousValue.plus(bigIncrement);
620
620
  errors = [...errors, `Please select a valid value, the two nearest valid values are ${previousValue} and ${nextValue}.`];
621
621
  }
622
622
  }
@@ -631,10 +631,10 @@ class Validator {
631
631
  if (validate.required && (isNil(value) || value === '')) {
632
632
  errors = [...errors, 'Field is required.'];
633
633
  }
634
- if ('min' in validate && value && value < validate.min) {
634
+ if ('min' in validate && (value || value === 0) && value < validate.min) {
635
635
  errors = [...errors, `Field must have minimum value of ${validate.min}.`];
636
636
  }
637
- if ('max' in validate && value && value > validate.max) {
637
+ if ('max' in validate && (value || value === 0) && value > validate.max) {
638
638
  errors = [...errors, `Field must have maximum value of ${validate.max}.`];
639
639
  }
640
640
  if ('minLength' in validate && value && value.trim().length < validate.minLength) {
@@ -1860,7 +1860,7 @@ var CalendarIcon = (({
1860
1860
  fillRule: "evenodd",
1861
1861
  clipRule: "evenodd",
1862
1862
  d: "M19 2H9V0H7v2H2a2 2 0 00-2 2v24a2 2 0 002 2h24a2 2 0 002-2V4a2 2 0 00-2-2h-5V0h-2v2zM7 7V4H2v5h24V4h-5v3h-2V4H9v3H7zm-5 4v17h24V11H2z",
1863
- fill: "#000"
1863
+ fill: "currentColor"
1864
1864
  })));
1865
1865
 
1866
1866
  function InputAdorner(props) {
@@ -1925,10 +1925,6 @@ function Datepicker(props) {
1925
1925
 
1926
1926
  // setup flatpickr instance
1927
1927
  useEffect(() => {
1928
- if (disabled) {
1929
- setFlatpickrInstance(null);
1930
- return;
1931
- }
1932
1928
  let config = {
1933
1929
  allowInput: true,
1934
1930
  dateFormat: 'm/d/Y',
@@ -1961,7 +1957,7 @@ function Datepicker(props) {
1961
1957
  // flatpicker logic that was lost when setting allowInput to true
1962
1958
  instance.config.onOpen = [() => instance.calendarContainer.addEventListener('focusout', onCalendarFocusOut), () => instance.calendarContainer.addEventListener('mousedown', onCalendarMouseDown)];
1963
1959
  instance.config.onClose = [() => instance.calendarContainer.removeEventListener('focusout', onCalendarFocusOut), () => instance.calendarContainer.removeEventListener('mousedown', onCalendarMouseDown)];
1964
- }, [disabled, disallowPassedDates]);
1960
+ }, [disallowPassedDates]);
1965
1961
 
1966
1962
  // onChange is updated dynamically, so not to re-render the flatpicker every time it changes
1967
1963
  useEffect(() => {
@@ -2050,12 +2046,12 @@ var ClockIcon = (({
2050
2046
  xmlns: "http://www.w3.org/2000/svg"
2051
2047
  }, props), /*#__PURE__*/React.createElement("path", {
2052
2048
  d: "M13 14.41L18.59 20 20 18.59l-5-5.01V5h-2v9.41z",
2053
- fill: "#000"
2049
+ fill: "currentColor"
2054
2050
  }), /*#__PURE__*/React.createElement("path", {
2055
2051
  fillRule: "evenodd",
2056
2052
  clipRule: "evenodd",
2057
2053
  d: "M6.222 25.64A14 14 0 1021.778 2.36 14 14 0 006.222 25.64zM7.333 4.023a12 12 0 1113.334 19.955A12 12 0 017.333 4.022z",
2058
- fill: "#000"
2054
+ fill: "currentColor"
2059
2055
  })));
2060
2056
 
2061
2057
  function useKeyDownAction(targetKey, action, listenerElement = window) {
@@ -2147,6 +2143,7 @@ function DropdownList(props) {
2147
2143
  ref: dropdownContainer,
2148
2144
  tabIndex: -1,
2149
2145
  class: "fjs-dropdownlist",
2146
+ onMouseDown: e => e.preventDefault(),
2150
2147
  style: {
2151
2148
  maxHeight: height,
2152
2149
  scrollBehavior: smoothScrolling ? 'smooth' : 'auto'
@@ -2158,10 +2155,7 @@ function DropdownList(props) {
2158
2155
  }),
2159
2156
  onMouseMove: mouseControl ? undefined : e => onMouseMovedInKeyboardMode(e, i),
2160
2157
  onMouseEnter: mouseControl ? () => setFocusedValueIndex(i) : undefined,
2161
- onMouseDown: e => {
2162
- e.preventDefault();
2163
- onValueSelected(v);
2164
- },
2158
+ onMouseDown: e => onValueSelected(v),
2165
2159
  children: getLabel(v)
2166
2160
  });
2167
2161
  }), !values.length && jsx("div", {
@@ -2361,31 +2355,29 @@ function Datetime(props) {
2361
2355
  date,
2362
2356
  time
2363
2357
  } = getNullDateTime();
2364
- if (!disabled) {
2365
- switch (subtype) {
2366
- case DATETIME_SUBTYPES.DATE:
2367
- {
2368
- date = new Date(Date.parse(value));
2369
- break;
2370
- }
2371
- case DATETIME_SUBTYPES.TIME:
2372
- {
2373
- time = parseIsoTime(value);
2374
- break;
2375
- }
2376
- case DATETIME_SUBTYPES.DATETIME:
2377
- {
2378
- date = new Date(Date.parse(value));
2379
- time = isValidDate(date) ? 60 * date.getHours() + date.getMinutes() : null;
2380
- break;
2381
- }
2382
- }
2358
+ switch (subtype) {
2359
+ case DATETIME_SUBTYPES.DATE:
2360
+ {
2361
+ date = new Date(Date.parse(value));
2362
+ break;
2363
+ }
2364
+ case DATETIME_SUBTYPES.TIME:
2365
+ {
2366
+ time = parseIsoTime(value);
2367
+ break;
2368
+ }
2369
+ case DATETIME_SUBTYPES.DATETIME:
2370
+ {
2371
+ date = new Date(Date.parse(value));
2372
+ time = isValidDate(date) ? 60 * date.getHours() + date.getMinutes() : null;
2373
+ break;
2374
+ }
2383
2375
  }
2384
2376
  setDateTime({
2385
2377
  date,
2386
2378
  time
2387
2379
  });
2388
- }, [subtype, value, disabled]);
2380
+ }, [subtype, value]);
2389
2381
  const computeAndSetState = useCallback(({
2390
2382
  date,
2391
2383
  time
@@ -2775,6 +2767,7 @@ function Numberfield(props) {
2775
2767
  }), [stringValueCache, value, field]);
2776
2768
  const displayValue = useMemo(() => {
2777
2769
  if (value === 'NaN') return 'NaN';
2770
+ if (stringValueCache === '-') return '-';
2778
2771
  return cacheValueMatchesState ? stringValueCache : value || value === 0 ? Big(value).toFixed() : '';
2779
2772
  }, [stringValueCache, value, cacheValueMatchesState]);
2780
2773
  const arrowIncrementValue = useMemo(() => {
@@ -2794,6 +2787,10 @@ function Numberfield(props) {
2794
2787
 
2795
2788
  // treat commas as dots
2796
2789
  stringValue = stringValue.replaceAll(',', '.');
2790
+ if (stringValue === '-') {
2791
+ setStringValueCache('-');
2792
+ return;
2793
+ }
2797
2794
  if (isNaN(Number(stringValue))) {
2798
2795
  setStringValueCache('NaN');
2799
2796
  onChange({
@@ -2898,6 +2895,7 @@ function Numberfield(props) {
2898
2895
  }),
2899
2896
  children: [jsx("button", {
2900
2897
  class: "fjs-number-arrow-up",
2898
+ type: "button",
2901
2899
  onClick: () => increment(),
2902
2900
  tabIndex: -1,
2903
2901
  children: "\u02C4"
@@ -2905,6 +2903,7 @@ function Numberfield(props) {
2905
2903
  class: "fjs-number-arrow-separator"
2906
2904
  }), jsx("button", {
2907
2905
  class: "fjs-number-arrow-down",
2906
+ type: "button",
2908
2907
  onClick: () => decrement(),
2909
2908
  tabIndex: -1,
2910
2909
  children: "\u02C5"
@@ -3322,18 +3321,18 @@ var ChecklistIcon = (({
3322
3321
  styles = {},
3323
3322
  ...props
3324
3323
  }) => /*#__PURE__*/React.createElement("svg", _extends$b({
3324
+ xmlns: "http://www.w3.org/2000/svg",
3325
3325
  width: "54",
3326
3326
  height: "54",
3327
- fill: "none",
3328
- xmlns: "http://www.w3.org/2000/svg"
3327
+ fill: "none"
3329
3328
  }, props), /*#__PURE__*/React.createElement("path", {
3330
3329
  fillRule: "evenodd",
3331
3330
  clipRule: "evenodd",
3332
- d: "M19 24h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zm6 18h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zm6-30h-6v6h6V8zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2V8a2 2 0 00-2-2h-6z",
3333
- fill: "#22242A"
3331
+ d: "M18 12h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zM18 36h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6zM18 24h-6v6h6v-6zm-6-2a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-6a2 2 0 00-2-2h-6z",
3332
+ fill: "#161616"
3334
3333
  }), /*#__PURE__*/React.createElement("path", {
3335
- d: "M26 26a1 1 0 011-1h15a1 1 0 011 1v2a1 1 0 01-1 1H27a1 1 0 01-1-1v-2zm0 16a1 1 0 011-1h15a1 1 0 011 1v2a1 1 0 01-1 1H27a1 1 0 01-1-1v-2zm0-32a1 1 0 011-1h15a1 1 0 011 1v2a1 1 0 01-1 1H27a1 1 0 01-1-1v-2z",
3336
- fill: "#22242A"
3334
+ d: "M23 14.5a1 1 0 011-1h19a1 1 0 011 1v1a1 1 0 01-1 1H24a1 1 0 01-1-1v-1zM23 26.5a1 1 0 011-1h19a1 1 0 011 1v1a1 1 0 01-1 1H24a1 1 0 01-1-1v-1zM23 38.5a1 1 0 011-1h19a1 1 0 011 1v1a1 1 0 01-1 1H24a1 1 0 01-1-1v-1z",
3335
+ fill: "#161616"
3337
3336
  })));
3338
3337
 
3339
3338
  function _extends$a() { _extends$a = 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$a.apply(this, arguments); }