@bpmn-io/form-js-editor 0.10.0-alpha.0 → 0.10.0-alpha.2

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
@@ -1,4 +1,4 @@
1
- import { FormFieldRegistry as FormFieldRegistry$1, clone, FormContext, FormRenderContext, FormComponent, FormFields, Default, createFormContainer, createInjector, schemaVersion } from '@bpmn-io/form-js-viewer';
1
+ import { FormFieldRegistry as FormFieldRegistry$1, clone, FormContext, FormRenderContext, FormComponent, FormFields, getSchemaVariables, Default, createFormContainer, createInjector, schemaVersion } from '@bpmn-io/form-js-viewer';
2
2
  export { schemaVersion } from '@bpmn-io/form-js-viewer';
3
3
  import Ids from 'ids';
4
4
  import { isArray, isFunction, isNumber, bind, assign, debounce, forEach, get, isObject, uniqueBy, sortBy, find, set, isUndefined, without, has, isString } from 'min-dash';
@@ -11,6 +11,7 @@ import { matches, closest, event, domify, query } from 'min-dom';
11
11
  import { mutate } from 'array-move';
12
12
  import classnames from 'classnames';
13
13
  import FeelEditor from '@bpmn-io/feel-editor';
14
+ import Big from 'big.js';
14
15
 
15
16
  var FN_REF = '__fn';
16
17
  var DEFAULT_PRIORITY$2 = 1000;
@@ -692,11 +693,11 @@ function useService$1 (type, strict) {
692
693
  return getService(type, strict);
693
694
  }
694
695
 
695
- function _extends$c() { _extends$c = 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$c.apply(this, arguments); }
696
+ function _extends$d() { _extends$d = 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$d.apply(this, arguments); }
696
697
  var ListDeleteIcon = (({
697
698
  styles = {},
698
699
  ...props
699
- }) => /*#__PURE__*/React.createElement("svg", _extends$c({
700
+ }) => /*#__PURE__*/React.createElement("svg", _extends$d({
700
701
  xmlns: "http://www.w3.org/2000/svg",
701
702
  width: "11",
702
703
  height: "14"
@@ -704,11 +705,11 @@ var ListDeleteIcon = (({
704
705
  d: "M10 4v8c0 1.1-.9 2-2 2H3c-1.1 0-2-.9-2-2V4h9zM8 6H3v4.8c0 .66.5 1.2 1.111 1.2H6.89C7.5 12 8 11.46 8 10.8V6zm3-5H8.5l-1-1h-4l-1 1H0v1.5h11V1z"
705
706
  })));
706
707
 
707
- function _extends$b() { _extends$b = 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$b.apply(this, arguments); }
708
+ function _extends$c() { _extends$c = 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$c.apply(this, arguments); }
708
709
  var ButtonIcon = (({
709
710
  styles = {},
710
711
  ...props
711
- }) => /*#__PURE__*/React.createElement("svg", _extends$b({
712
+ }) => /*#__PURE__*/React.createElement("svg", _extends$c({
712
713
  xmlns: "http://www.w3.org/2000/svg",
713
714
  width: "54",
714
715
  height: "54"
@@ -717,11 +718,11 @@ var ButtonIcon = (({
717
718
  d: "M45 17a3 3 0 013 3v14a3 3 0 01-3 3H9a3 3 0 01-3-3V20a3 3 0 013-3h36zm-9 8.889H18v2.222h18V25.89z"
718
719
  })));
719
720
 
720
- 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); }
721
+ function _extends$b() { _extends$b = 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$b.apply(this, arguments); }
721
722
  var CheckboxIcon = (({
722
723
  styles = {},
723
724
  ...props
724
- }) => /*#__PURE__*/React.createElement("svg", _extends$a({
725
+ }) => /*#__PURE__*/React.createElement("svg", _extends$b({
725
726
  xmlns: "http://www.w3.org/2000/svg",
726
727
  width: "54",
727
728
  height: "54"
@@ -729,11 +730,11 @@ var CheckboxIcon = (({
729
730
  d: "M34 18H20a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2V20a2 2 0 00-2-2zm-9 14l-5-5 1.41-1.41L25 29.17l7.59-7.59L34 23l-9 9z"
730
731
  })));
731
732
 
732
- function _extends$9() { _extends$9 = 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$9.apply(this, arguments); }
733
+ 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); }
733
734
  var ChecklistIcon = (({
734
735
  styles = {},
735
736
  ...props
736
- }) => /*#__PURE__*/React.createElement("svg", _extends$9({
737
+ }) => /*#__PURE__*/React.createElement("svg", _extends$a({
737
738
  width: "54",
738
739
  height: "54",
739
740
  fill: "none",
@@ -748,11 +749,11 @@ var ChecklistIcon = (({
748
749
  fill: "#22242A"
749
750
  })));
750
751
 
751
- function _extends$8() { _extends$8 = 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$8.apply(this, arguments); }
752
+ function _extends$9() { _extends$9 = 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$9.apply(this, arguments); }
752
753
  var TaglistIcon = (({
753
754
  styles = {},
754
755
  ...props
755
- }) => /*#__PURE__*/React.createElement("svg", _extends$8({
756
+ }) => /*#__PURE__*/React.createElement("svg", _extends$9({
756
757
  width: "54",
757
758
  height: "54",
758
759
  fill: "none",
@@ -767,11 +768,11 @@ var TaglistIcon = (({
767
768
  fill: "#505562"
768
769
  })));
769
770
 
770
- function _extends$7() { _extends$7 = 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$7.apply(this, arguments); }
771
+ function _extends$8() { _extends$8 = 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$8.apply(this, arguments); }
771
772
  var FormIcon = (({
772
773
  styles = {},
773
774
  ...props
774
- }) => /*#__PURE__*/React.createElement("svg", _extends$7({
775
+ }) => /*#__PURE__*/React.createElement("svg", _extends$8({
775
776
  xmlns: "http://www.w3.org/2000/svg",
776
777
  width: "54",
777
778
  height: "54"
@@ -795,11 +796,11 @@ var FormIcon = (({
795
796
  rx: "1"
796
797
  })));
797
798
 
798
- function _extends$6() { _extends$6 = 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$6.apply(this, arguments); }
799
+ function _extends$7() { _extends$7 = 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$7.apply(this, arguments); }
799
800
  var ColumnsIcon = (({
800
801
  styles = {},
801
802
  ...props
802
- }) => /*#__PURE__*/React.createElement("svg", _extends$6({
803
+ }) => /*#__PURE__*/React.createElement("svg", _extends$7({
803
804
  xmlns: "http://www.w3.org/2000/svg",
804
805
  width: "54",
805
806
  height: "54"
@@ -808,11 +809,11 @@ var ColumnsIcon = (({
808
809
  d: "M8 33v5a1 1 0 001 1h4v2H9a3 3 0 01-3-3v-5h2zm18 6v2H15v-2h11zm13 0v2H28v-2h11zm9-6v5a3 3 0 01-3 3h-4v-2h4a1 1 0 00.993-.883L46 38v-5h2zM8 22v9H6v-9h2zm40 0v9h-2v-9h2zm-35-9v2H9a1 1 0 00-.993.883L8 16v4H6v-4a3 3 0 013-3h4zm32 0a3 3 0 013 3v4h-2v-4a1 1 0 00-.883-.993L45 15h-4v-2h4zm-6 0v2H28v-2h11zm-13 0v2H15v-2h11z"
809
810
  })));
810
811
 
811
- function _extends$5() { _extends$5 = 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$5.apply(this, arguments); }
812
+ function _extends$6() { _extends$6 = 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$6.apply(this, arguments); }
812
813
  var NumberIcon = (({
813
814
  styles = {},
814
815
  ...props
815
- }) => /*#__PURE__*/React.createElement("svg", _extends$5({
816
+ }) => /*#__PURE__*/React.createElement("svg", _extends$6({
816
817
  xmlns: "http://www.w3.org/2000/svg",
817
818
  width: "54",
818
819
  height: "54"
@@ -821,11 +822,11 @@ var NumberIcon = (({
821
822
  d: "M45 16a3 3 0 013 3v16a3 3 0 01-3 3H9a3 3 0 01-3-3V19a3 3 0 013-3h36zm0 2H9a1 1 0 00-1 1v16a1 1 0 001 1h36a1 1 0 001-1V19a1 1 0 00-1-1zM35 28.444h7l-3.5 4-3.5-4zM35 26h7l-3.5-4-3.5 4z"
822
823
  })));
823
824
 
824
- function _extends$4() { _extends$4 = 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$4.apply(this, arguments); }
825
+ function _extends$5() { _extends$5 = 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$5.apply(this, arguments); }
825
826
  var RadioIcon = (({
826
827
  styles = {},
827
828
  ...props
828
- }) => /*#__PURE__*/React.createElement("svg", _extends$4({
829
+ }) => /*#__PURE__*/React.createElement("svg", _extends$5({
829
830
  xmlns: "http://www.w3.org/2000/svg",
830
831
  width: "54",
831
832
  height: "54"
@@ -833,11 +834,11 @@ var RadioIcon = (({
833
834
  d: "M27 22c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
834
835
  })));
835
836
 
836
- function _extends$3() { _extends$3 = 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$3.apply(this, arguments); }
837
+ function _extends$4() { _extends$4 = 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$4.apply(this, arguments); }
837
838
  var SelectIcon = (({
838
839
  styles = {},
839
840
  ...props
840
- }) => /*#__PURE__*/React.createElement("svg", _extends$3({
841
+ }) => /*#__PURE__*/React.createElement("svg", _extends$4({
841
842
  xmlns: "http://www.w3.org/2000/svg",
842
843
  width: "54",
843
844
  height: "54"
@@ -846,11 +847,11 @@ var SelectIcon = (({
846
847
  d: "M45 16a3 3 0 013 3v16a3 3 0 01-3 3H9a3 3 0 01-3-3V19a3 3 0 013-3h36zm0 2H9a1 1 0 00-1 1v16a1 1 0 001 1h36a1 1 0 001-1V19a1 1 0 00-1-1zm-12 7h9l-4.5 6-4.5-6z"
847
848
  })));
848
849
 
849
- function _extends$2() { _extends$2 = 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$2.apply(this, arguments); }
850
+ function _extends$3() { _extends$3 = 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$3.apply(this, arguments); }
850
851
  var TextIcon = (({
851
852
  styles = {},
852
853
  ...props
853
- }) => /*#__PURE__*/React.createElement("svg", _extends$2({
854
+ }) => /*#__PURE__*/React.createElement("svg", _extends$3({
854
855
  xmlns: "http://www.w3.org/2000/svg",
855
856
  width: "54",
856
857
  height: "54"
@@ -858,11 +859,11 @@ var TextIcon = (({
858
859
  d: "M20.58 33.77h-3l-1.18-3.08H11l-1.1 3.08H7l5.27-13.54h2.89zm-5-5.36l-1.86-5-1.83 5zM22 20.23h5.41a15.47 15.47 0 012.4.14 3.42 3.42 0 011.41.55 3.47 3.47 0 011 1.14 3 3 0 01.42 1.58 3.26 3.26 0 01-1.91 2.94 3.63 3.63 0 011.91 1.22 3.28 3.28 0 01.66 2 4 4 0 01-.43 1.8 3.63 3.63 0 01-1.09 1.4 3.89 3.89 0 01-1.83.65q-.69.07-3.3.09H22zm2.73 2.25v3.13h3.8a1.79 1.79 0 001.1-.49 1.41 1.41 0 00.41-1 1.49 1.49 0 00-.35-1 1.54 1.54 0 00-1-.48c-.27 0-1.05-.05-2.34-.05zm0 5.39v3.62h2.57a11.52 11.52 0 001.88-.09 1.65 1.65 0 001-.54 1.6 1.6 0 00.38-1.14 1.75 1.75 0 00-.29-1 1.69 1.69 0 00-.86-.62 9.28 9.28 0 00-2.41-.23zM44.35 28.79l2.65.84a5.94 5.94 0 01-2 3.29A5.74 5.74 0 0141.38 34a5.87 5.87 0 01-4.44-1.84 7.09 7.09 0 01-1.73-5A7.43 7.43 0 0137 21.87 6 6 0 0141.54 20a5.64 5.64 0 014 1.47A5.33 5.33 0 0147 24l-2.7.65a2.8 2.8 0 00-2.86-2.27A3.09 3.09 0 0039 23.42a5.31 5.31 0 00-.93 3.5 5.62 5.62 0 00.93 3.65 3 3 0 002.4 1.09 2.72 2.72 0 001.82-.66 4 4 0 001.13-2.21z"
859
860
  })));
860
861
 
861
- function _extends$1() { _extends$1 = 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$1.apply(this, arguments); }
862
+ function _extends$2() { _extends$2 = 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$2.apply(this, arguments); }
862
863
  var TextfieldIcon = (({
863
864
  styles = {},
864
865
  ...props
865
- }) => /*#__PURE__*/React.createElement("svg", _extends$1({
866
+ }) => /*#__PURE__*/React.createElement("svg", _extends$2({
866
867
  xmlns: "http://www.w3.org/2000/svg",
867
868
  width: "54",
868
869
  height: "54"
@@ -871,11 +872,11 @@ var TextfieldIcon = (({
871
872
  d: "M45 16a3 3 0 013 3v16a3 3 0 01-3 3H9a3 3 0 01-3-3V19a3 3 0 013-3h36zm0 2H9a1 1 0 00-1 1v16a1 1 0 001 1h36a1 1 0 001-1V19a1 1 0 00-1-1zm-32 4v10h-2V22h2z"
872
873
  })));
873
874
 
874
- function _extends() { _extends = 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.apply(this, arguments); }
875
+ function _extends$1() { _extends$1 = 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$1.apply(this, arguments); }
875
876
  var TextareaIcon = (({
876
877
  styles = {},
877
878
  ...props
878
- }) => /*#__PURE__*/React.createElement("svg", _extends({
879
+ }) => /*#__PURE__*/React.createElement("svg", _extends$1({
879
880
  xmlns: "http://www.w3.org/2000/svg",
880
881
  width: "54",
881
882
  height: "54"
@@ -884,11 +885,33 @@ var TextareaIcon = (({
884
885
  d: "M45 13a3 3 0 013 3v22a3 3 0 01-3 3H9a3 3 0 01-3-3V16a3 3 0 013-3h36zm0 2H9a1 1 0 00-1 1v22a1 1 0 001 1h36a1 1 0 001-1V16a1 1 0 00-1-1zm-1.136 15.5l.848.849-6.363 6.363-.849-.848 6.364-6.364zm.264 3.5l.849.849-2.828 2.828-.849-.849L44.128 34zM13 19v10h-2V19h2z"
885
886
  })));
886
887
 
888
+ function _extends() { _extends = 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.apply(this, arguments); }
889
+ var ImageIcon = (({
890
+ styles = {},
891
+ ...props
892
+ }) => /*#__PURE__*/React.createElement("svg", _extends({
893
+ width: "54",
894
+ height: "54",
895
+ fill: "none",
896
+ xmlns: "http://www.w3.org/2000/svg"
897
+ }, props), /*#__PURE__*/React.createElement("path", {
898
+ fillRule: "evenodd",
899
+ clipRule: "evenodd",
900
+ d: "M34.636 21.91A3.818 3.818 0 1127 21.908a3.818 3.818 0 017.636 0zm-2 0A1.818 1.818 0 1129 21.908a1.818 1.818 0 013.636 0z",
901
+ fill: "#000"
902
+ }), /*#__PURE__*/React.createElement("path", {
903
+ fillRule: "evenodd",
904
+ clipRule: "evenodd",
905
+ d: "M15 13a2 2 0 00-2 2v24a2 2 0 002 2h24a2 2 0 002-2V15a2 2 0 00-2-2H15zm24 2H15v12.45l4.71-4.709a1.91 1.91 0 012.702 0l6.695 6.695 2.656-1.77a1.91 1.91 0 012.411.239L39 32.73V15zM15 39v-8.754c.06-.038.116-.083.168-.135l5.893-5.893 6.684 6.685a1.911 1.911 0 002.41.238l2.657-1.77 6.02 6.02c.052.051.108.097.168.135V39H15z",
906
+ fill: "#000"
907
+ })));
908
+
887
909
  const iconsByType = {
888
910
  button: ButtonIcon,
889
911
  checkbox: CheckboxIcon,
890
912
  checklist: ChecklistIcon,
891
913
  columns: ColumnsIcon,
914
+ image: ImageIcon,
892
915
  number: NumberIcon,
893
916
  radio: RadioIcon,
894
917
  select: SelectIcon,
@@ -1528,14 +1551,10 @@ var EditorActionsModule = {
1528
1551
  editorActions: ['type', FormEditorActions]
1529
1552
  };
1530
1553
 
1531
- var KEYCODE_C = 67;
1532
- var KEYCODE_V = 86;
1533
- var KEYCODE_Y$1 = 89;
1534
- var KEYCODE_Z$1 = 90;
1535
- var KEYS_COPY = ['c', 'C', KEYCODE_C];
1536
- var KEYS_PASTE = ['v', 'V', KEYCODE_V];
1537
- var KEYS_REDO$1 = ['y', 'Y', KEYCODE_Y$1];
1538
- var KEYS_UNDO$1 = ['z', 'Z', KEYCODE_Z$1];
1554
+ var KEYS_COPY = ['c', 'C', 'KeyC'];
1555
+ var KEYS_PASTE = ['v', 'V', 'KeyV'];
1556
+ var KEYS_REDO$1 = ['y', 'Y', 'KeyY'];
1557
+ var KEYS_UNDO$1 = ['z', 'Z', 'KeyZ'];
1539
1558
 
1540
1559
  /**
1541
1560
  * Returns true if event was triggered with any modifier
@@ -1565,7 +1584,7 @@ function isCmd(event) {
1565
1584
  */
1566
1585
  function isKey(keys, event) {
1567
1586
  keys = isArray(keys) ? keys : [keys];
1568
- return keys.indexOf(event.key) !== -1 || keys.indexOf(event.keyCode) !== -1;
1587
+ return keys.indexOf(event.key) !== -1 || keys.indexOf(event.code) !== -1;
1569
1588
  }
1570
1589
 
1571
1590
  /**
@@ -1594,7 +1613,7 @@ var DEFAULT_PRIORITY$1 = 1000;
1594
1613
 
1595
1614
  /**
1596
1615
  * A keyboard abstraction that may be activated and
1597
- * deactivated by users at will, consuming key events
1616
+ * deactivated by users at will, consuming global key events
1598
1617
  * and triggering diagram actions.
1599
1618
  *
1600
1619
  * For keys pressed down, keyboard fires `keyboard.keydown` event.
@@ -1661,6 +1680,9 @@ Keyboard.prototype._keyHandler = function (event, type) {
1661
1680
  }
1662
1681
  };
1663
1682
  Keyboard.prototype._isEventIgnored = function (event) {
1683
+ if (event.defaultPrevented) {
1684
+ return true;
1685
+ }
1664
1686
  return isInput(event.target) && this._isModifiedKeyIgnored(event);
1665
1687
  };
1666
1688
  Keyboard.prototype._isModifiedKeyIgnored = function (event) {
@@ -1683,8 +1705,8 @@ Keyboard.prototype.bind = function (node) {
1683
1705
  this._node = node;
1684
1706
 
1685
1707
  // bind key events
1686
- event.bind(node, 'keydown', this._keydownHandler, true);
1687
- event.bind(node, 'keyup', this._keyupHandler, true);
1708
+ event.bind(node, 'keydown', this._keydownHandler);
1709
+ event.bind(node, 'keyup', this._keyupHandler);
1688
1710
  this._fire('bind');
1689
1711
  };
1690
1712
  Keyboard.prototype.getBinding = function () {
@@ -1696,8 +1718,8 @@ Keyboard.prototype.unbind = function () {
1696
1718
  this._fire('unbind');
1697
1719
 
1698
1720
  // unbind key events
1699
- event.unbind(node, 'keydown', this._keydownHandler, true);
1700
- event.unbind(node, 'keyup', this._keyupHandler, true);
1721
+ event.unbind(node, 'keydown', this._keydownHandler);
1722
+ event.unbind(node, 'keyup', this._keyupHandler);
1701
1723
  }
1702
1724
  this._node = null;
1703
1725
  };
@@ -1739,10 +1761,8 @@ function isInput(target) {
1739
1761
  }
1740
1762
 
1741
1763
  var LOW_PRIORITY$1 = 500;
1742
- var KEYCODE_Y = 89;
1743
- var KEYCODE_Z = 90;
1744
- var KEYS_REDO = ['y', 'Y', KEYCODE_Y];
1745
- var KEYS_UNDO = ['z', 'Z', KEYCODE_Z];
1764
+ var KEYS_REDO = ['y', 'Y', 'KeyY'];
1765
+ var KEYS_UNDO = ['z', 'Z', 'KeyZ'];
1746
1766
 
1747
1767
  /**
1748
1768
  * Adds default keyboard bindings.
@@ -3092,6 +3112,9 @@ const types = [{
3092
3112
  }, {
3093
3113
  label: 'Text',
3094
3114
  type: 'text'
3115
+ }, {
3116
+ label: 'Image view',
3117
+ type: 'image'
3095
3118
  }, {
3096
3119
  label: 'Button',
3097
3120
  type: 'button'
@@ -3256,6 +3279,47 @@ ExternalLinkIcon.defaultProps = {
3256
3279
  fill: "none",
3257
3280
  xmlns: "http://www.w3.org/2000/svg"
3258
3281
  };
3282
+ var FeelRequiredIcon = function FeelRequiredIcon(props) {
3283
+ return jsxs("svg", {
3284
+ ...props,
3285
+ children: [jsx("path", {
3286
+ d: "M5.8 7.06V5.95h4.307v1.11H5.8Zm0 3.071v-1.11h4.307v1.11H5.8Z",
3287
+ fill: "currentColor"
3288
+ }), jsx("path", {
3289
+ fillRule: "evenodd",
3290
+ clipRule: "evenodd",
3291
+ d: "M8 3.268A4.732 4.732 0 1 0 12.732 8H14a6 6 0 1 1-6-6v1.268Z",
3292
+ fill: "currentColor"
3293
+ }), jsx("path", {
3294
+ d: "m11.28 6.072-.832-.56 1.016-1.224L10 3.848l.312-.912 1.392.584L11.632 2h1.032l-.072 1.52 1.392-.584.312.912-1.464.44 1.008 1.224-.832.552-.864-1.296-.864 1.304Z",
3295
+ fill: "currentColor"
3296
+ })]
3297
+ });
3298
+ };
3299
+ FeelRequiredIcon.defaultProps = {
3300
+ viewBox: "0 0 16 16",
3301
+ fill: "none",
3302
+ xmlns: "http://www.w3.org/2000/svg"
3303
+ };
3304
+ var FeelOptionalIcon = function FeelOptionalIcon(props) {
3305
+ return jsxs("svg", {
3306
+ ...props,
3307
+ children: [jsx("path", {
3308
+ d: "M5.845 7.04V5.93h4.307v1.11H5.845Zm0 3.07V9h4.307v1.11H5.845Z",
3309
+ fill: "currentColor"
3310
+ }), jsx("path", {
3311
+ fillRule: "evenodd",
3312
+ clipRule: "evenodd",
3313
+ d: "M3.286 8a4.714 4.714 0 1 0 9.428 0 4.714 4.714 0 0 0-9.428 0ZM8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Z",
3314
+ fill: "currentColor"
3315
+ })]
3316
+ });
3317
+ };
3318
+ FeelOptionalIcon.defaultProps = {
3319
+ viewBox: "0 0 16 16",
3320
+ fill: "none",
3321
+ xmlns: "http://www.w3.org/2000/svg"
3322
+ };
3259
3323
  function Header(props) {
3260
3324
  const {
3261
3325
  element,
@@ -4274,7 +4338,7 @@ const useBufferedFocus = function (editor, ref) {
4274
4338
  }
4275
4339
  }, [editor, buffer]);
4276
4340
  };
4277
- forwardRef((props, ref) => {
4341
+ const CodeEditor = forwardRef((props, ref) => {
4278
4342
  const {
4279
4343
  value,
4280
4344
  onInput,
@@ -4355,7 +4419,215 @@ forwardRef((props, ref) => {
4355
4419
  })
4356
4420
  });
4357
4421
  });
4358
- forwardRef((props, ref) => {
4422
+ function FeelIndicator(props) {
4423
+ const {
4424
+ active
4425
+ } = props;
4426
+ if (!active) {
4427
+ return null;
4428
+ }
4429
+ return jsx("span", {
4430
+ class: "bio-properties-panel-feel-indicator",
4431
+ children: "="
4432
+ });
4433
+ }
4434
+ const noop$1 = () => {};
4435
+
4436
+ /**
4437
+ * @param {Object} props
4438
+ * @param {Object} props.label
4439
+ * @param {String} props.feel
4440
+ */
4441
+ function FeelIcon(props) {
4442
+ const {
4443
+ label,
4444
+ feel = false,
4445
+ active,
4446
+ disabled = false,
4447
+ onClick = noop$1
4448
+ } = props;
4449
+ const feelRequiredLabel = ' must be a FEEL expression';
4450
+ const feelOptionalLabel = ' can optionally be a FEEL expression';
4451
+ const handleClick = e => {
4452
+ onClick(e);
4453
+
4454
+ // when pointer event was created from keyboard, keep focus on button
4455
+ if (!e.pointerType) {
4456
+ e.stopPropagation();
4457
+ }
4458
+ };
4459
+ return jsx("button", {
4460
+ class: classnames('bio-properties-panel-feel-icon', active ? 'active' : null, feel === 'required' ? 'required' : 'optional'),
4461
+ onClick: handleClick,
4462
+ disabled: feel === 'required' || disabled,
4463
+ title: label + (feel === 'required' ? feelRequiredLabel : feelOptionalLabel),
4464
+ children: feel === 'required' ? jsx(FeelRequiredIcon, {}) : jsx(FeelOptionalIcon, {})
4465
+ });
4466
+ }
4467
+ const noop = () => {};
4468
+ function FeelTextfield(props) {
4469
+ const {
4470
+ debounce,
4471
+ id,
4472
+ label,
4473
+ onInput,
4474
+ onError,
4475
+ feel,
4476
+ value = '',
4477
+ disabled = false,
4478
+ variables,
4479
+ tooltipContainer,
4480
+ OptionalComponent = OptionalFeelInput
4481
+ } = props;
4482
+ const [localValue, _setLocalValue] = useState(value);
4483
+ const editorRef = useShowEntryEvent(id);
4484
+ const containerRef = useRef();
4485
+ const feelActive = localValue.startsWith('=') || feel === 'required';
4486
+ const feelOnlyValue = localValue.startsWith('=') ? localValue.substring(1) : localValue;
4487
+ const [focus, _setFocus] = useState(undefined);
4488
+ const setFocus = (offset = 0) => {
4489
+ const hasFocus = containerRef.current.contains(document.activeElement);
4490
+
4491
+ // Keep caret position if it is already focused, otherwise focus at the end
4492
+ const position = hasFocus ? document.activeElement.selectionStart : Infinity;
4493
+ _setFocus(position + offset);
4494
+ };
4495
+ const handleInputCallback = useMemo(() => {
4496
+ return debounce(newValue => {
4497
+ onInput(newValue);
4498
+ });
4499
+ }, [onInput, debounce]);
4500
+ const setLocalValue = newValue => {
4501
+ _setLocalValue(newValue);
4502
+ if (!newValue || newValue === '=') {
4503
+ handleInputCallback(undefined);
4504
+ } else {
4505
+ handleInputCallback(newValue);
4506
+ }
4507
+ };
4508
+ const handleFeelToggle = useStaticCallback(() => {
4509
+ if (feel === 'required') {
4510
+ return;
4511
+ }
4512
+ if (!feelActive) {
4513
+ setLocalValue('=' + localValue);
4514
+ } else {
4515
+ setLocalValue(feelOnlyValue);
4516
+ }
4517
+ });
4518
+ const handleLocalInput = newValue => {
4519
+ if (feelActive) {
4520
+ newValue = '=' + newValue;
4521
+ }
4522
+ if (newValue === localValue) {
4523
+ return;
4524
+ }
4525
+ setLocalValue(newValue);
4526
+ if (!feelActive && newValue.startsWith('=')) {
4527
+ // focus is behind `=` sign that will be removed
4528
+ setFocus(-1);
4529
+ }
4530
+ };
4531
+ const handleLint = useStaticCallback(lint => {
4532
+ if (!(lint && lint.length)) {
4533
+ onError(undefined);
4534
+ return;
4535
+ }
4536
+ const error = lint[0];
4537
+ const message = `${error.source}: ${error.message}`;
4538
+ onError(message);
4539
+ });
4540
+ useEffect(() => {
4541
+ if (typeof focus !== 'undefined') {
4542
+ editorRef.current.focus(focus);
4543
+ _setFocus(undefined);
4544
+ }
4545
+ }, [focus]);
4546
+ useEffect(() => {
4547
+ if (value === localValue) {
4548
+ return;
4549
+ }
4550
+
4551
+ // External value change removed content => keep FEEL configuration
4552
+ if (!value) {
4553
+ setLocalValue(feelActive ? '=' : '');
4554
+ return;
4555
+ }
4556
+ setLocalValue(value);
4557
+ }, [value]);
4558
+
4559
+ // copy-paste integration
4560
+ useEffect(() => {
4561
+ const copyHandler = event => {
4562
+ if (!feelActive) {
4563
+ return;
4564
+ }
4565
+ event.clipboardData.setData('application/FEEL', event.clipboardData.getData('text'));
4566
+ };
4567
+ const pasteHandler = event => {
4568
+ if (feelActive) {
4569
+ return;
4570
+ }
4571
+ const data = event.clipboardData.getData('application/FEEL');
4572
+ if (data) {
4573
+ setTimeout(() => {
4574
+ handleFeelToggle();
4575
+ setFocus();
4576
+ });
4577
+ }
4578
+ };
4579
+ containerRef.current.addEventListener('copy', copyHandler);
4580
+ containerRef.current.addEventListener('cut', copyHandler);
4581
+ containerRef.current.addEventListener('paste', pasteHandler);
4582
+ return () => {
4583
+ containerRef.current.removeEventListener('copy', copyHandler);
4584
+ containerRef.current.removeEventListener('cut', copyHandler);
4585
+ containerRef.current.removeEventListener('paste', pasteHandler);
4586
+ };
4587
+ }, [containerRef, feelActive, handleFeelToggle, setFocus]);
4588
+ return jsxs("div", {
4589
+ class: "bio-properties-panel-feel-entry",
4590
+ children: [jsxs("label", {
4591
+ for: prefixId$6(id),
4592
+ class: "bio-properties-panel-label",
4593
+ onClick: () => setFocus(),
4594
+ children: [label, jsx(FeelIcon, {
4595
+ label: label,
4596
+ feel: feel,
4597
+ onClick: handleFeelToggle,
4598
+ active: feelActive
4599
+ })]
4600
+ }), jsxs("div", {
4601
+ class: "bio-properties-panel-feel-container",
4602
+ ref: containerRef,
4603
+ children: [jsx(FeelIndicator, {
4604
+ active: feelActive,
4605
+ disabled: feel !== 'optional' || disabled,
4606
+ onClick: handleFeelToggle
4607
+ }), feelActive ? jsx(CodeEditor, {
4608
+ id: prefixId$6(id),
4609
+ name: id,
4610
+ onInput: handleLocalInput,
4611
+ disabled: disabled,
4612
+ onFeelToggle: () => {
4613
+ handleFeelToggle();
4614
+ setFocus(true);
4615
+ },
4616
+ onLint: handleLint,
4617
+ value: feelOnlyValue,
4618
+ variables: variables,
4619
+ ref: editorRef,
4620
+ tooltipContainer: tooltipContainer
4621
+ }) : jsx(OptionalComponent, {
4622
+ ...props,
4623
+ onInput: handleLocalInput,
4624
+ value: localValue,
4625
+ ref: editorRef
4626
+ })]
4627
+ })]
4628
+ });
4629
+ }
4630
+ const OptionalFeelInput = forwardRef((props, ref) => {
4359
4631
  const {
4360
4632
  id,
4361
4633
  disabled,
@@ -4433,10 +4705,109 @@ forwardRef((props, ref) => {
4433
4705
  onInput: e => onInput(e.target.value),
4434
4706
  onFocus: onFocus,
4435
4707
  onBlur: onBlur,
4436
- value: value || ''
4708
+ value: value || '',
4709
+ "data-gramm": "false"
4437
4710
  });
4438
4711
  });
4439
4712
 
4713
+ /**
4714
+ * @param {Object} props
4715
+ * @param {Object} props.element
4716
+ * @param {String} props.id
4717
+ * @param {String} props.description
4718
+ * @param {Boolean} props.debounce
4719
+ * @param {Boolean} props.disabled
4720
+ * @param {String} props.label
4721
+ * @param {Function} props.getValue
4722
+ * @param {Function} props.setValue
4723
+ * @param {Function} props.validate
4724
+ */
4725
+ function FeelEntry(props) {
4726
+ const {
4727
+ element,
4728
+ id,
4729
+ description,
4730
+ debounce,
4731
+ disabled,
4732
+ feel,
4733
+ label,
4734
+ getValue,
4735
+ setValue,
4736
+ tooltipContainer,
4737
+ validate,
4738
+ show = noop,
4739
+ example,
4740
+ variables,
4741
+ onFocus,
4742
+ onBlur
4743
+ } = props;
4744
+ const [cachedInvalidValue, setCachedInvalidValue] = useState(null);
4745
+ const [validationError, setValidationError] = useState(null);
4746
+ const [localError, setLocalError] = useState(null);
4747
+ let value = getValue(element);
4748
+ const previousValue = usePrevious(value);
4749
+ useEffect(() => {
4750
+ if (isFunction(validate)) {
4751
+ const newValidationError = validate(value) || null;
4752
+ setValidationError(newValidationError);
4753
+ }
4754
+ }, [value]);
4755
+ const onInput = useStaticCallback(newValue => {
4756
+ let newValidationError = null;
4757
+ if (isFunction(validate)) {
4758
+ newValidationError = validate(newValue) || null;
4759
+ }
4760
+ if (newValidationError) {
4761
+ setCachedInvalidValue(newValue);
4762
+ } else {
4763
+ // don't create multiple commandStack entries for the same value
4764
+ if (newValue !== value) {
4765
+ setValue(newValue);
4766
+ }
4767
+ }
4768
+ setValidationError(newValidationError);
4769
+ });
4770
+ const onError = useCallback(err => {
4771
+ setLocalError(err);
4772
+ }, []);
4773
+ if (previousValue === value && validationError) {
4774
+ value = cachedInvalidValue;
4775
+ }
4776
+ const temporaryError = useError(id);
4777
+ const error = localError || temporaryError || validationError;
4778
+ return jsxs("div", {
4779
+ class: classnames(props.class, 'bio-properties-panel-entry', error ? 'has-error' : ''),
4780
+ "data-entry-id": id,
4781
+ children: [jsx(FeelTextfield, {
4782
+ debounce: debounce,
4783
+ disabled: disabled,
4784
+ feel: feel,
4785
+ id: id,
4786
+ label: label,
4787
+ onInput: onInput,
4788
+ onError: onError,
4789
+ onFocus: onFocus,
4790
+ onBlur: onBlur,
4791
+ example: example,
4792
+ show: show,
4793
+ value: value,
4794
+ variables: variables,
4795
+ tooltipContainer: tooltipContainer,
4796
+ OptionalComponent: props.OptionalComponent
4797
+ }, element), error && jsx("div", {
4798
+ class: "bio-properties-panel-error",
4799
+ children: error
4800
+ }), jsx(Description$1, {
4801
+ forId: id,
4802
+ element: element,
4803
+ value: description
4804
+ })]
4805
+ });
4806
+ }
4807
+ function isEdited$6(node) {
4808
+ return node && (!!node.value || node.classList.contains('edited'));
4809
+ }
4810
+
4440
4811
  // helpers /////////////////
4441
4812
 
4442
4813
  function prefixId$6(id) {
@@ -4729,7 +5100,8 @@ function TextArea(props) {
4729
5100
  onBlur: onBlur,
4730
5101
  rows: rows,
4731
5102
  value: localValue,
4732
- disabled: disabled
5103
+ disabled: disabled,
5104
+ "data-gramm": "false"
4733
5105
  })]
4734
5106
  });
4735
5107
  }
@@ -4953,6 +5325,14 @@ function arrayAdd(array, index, item) {
4953
5325
  copy.splice(index, 0, item);
4954
5326
  return copy;
4955
5327
  }
5328
+ function countDecimals(number) {
5329
+ const num = Big(number);
5330
+ if (num.toString() === num.toFixed(0)) return 0;
5331
+ return num.toFixed().split('.')[1].length || 0;
5332
+ }
5333
+ function isValidNumber(value) {
5334
+ return (typeof value === 'number' || typeof value === 'string') && value !== '' && !isNaN(Number(value));
5335
+ }
4956
5336
  function textToLabel(text) {
4957
5337
  if (typeof text != 'string') return null;
4958
5338
  for (const line of text.split('\n')) {
@@ -4974,6 +5354,7 @@ const labelsByType = {
4974
5354
  checklist: 'CHECKLIST',
4975
5355
  columns: 'COLUMNS',
4976
5356
  default: 'FORM',
5357
+ image: 'IMAGE',
4977
5358
  number: 'NUMBER',
4978
5359
  radio: 'RADIO',
4979
5360
  select: 'SELECT',
@@ -4990,6 +5371,9 @@ const PropertiesPanelHeaderProvider = {
4990
5371
  if (type === 'text') {
4991
5372
  return textToLabel(field.text);
4992
5373
  }
5374
+ if (type === 'image') {
5375
+ return field.alt;
5376
+ }
4993
5377
  if (type === 'default') {
4994
5378
  return field.id;
4995
5379
  }
@@ -5089,6 +5473,66 @@ function useService (type, strict) {
5089
5473
  return getService(type, strict);
5090
5474
  }
5091
5475
 
5476
+ /**
5477
+ * Retrieve list of variables from the form schema.
5478
+ *
5479
+ * @returns { string[] } list of variables used in form schema
5480
+ */
5481
+ function useVariables() {
5482
+ const form = useService('formEditor');
5483
+ const schema = form.getSchema();
5484
+ return getSchemaVariables(schema);
5485
+ }
5486
+
5487
+ function AltTextEntry(props) {
5488
+ const {
5489
+ editField,
5490
+ field
5491
+ } = props;
5492
+ const {
5493
+ type
5494
+ } = field;
5495
+ const entries = [];
5496
+ if (type === 'image') {
5497
+ entries.push({
5498
+ id: 'alt',
5499
+ component: AltText,
5500
+ editField: editField,
5501
+ field: field,
5502
+ isEdited: isEdited$6
5503
+ });
5504
+ }
5505
+ return entries;
5506
+ }
5507
+ function AltText(props) {
5508
+ const {
5509
+ editField,
5510
+ field,
5511
+ id
5512
+ } = props;
5513
+ const debounce = useService('debounce');
5514
+ const variables = useVariables().map(name => ({
5515
+ name
5516
+ }));
5517
+ const path = ['alt'];
5518
+ const getValue = () => {
5519
+ return get(field, path, '');
5520
+ };
5521
+ const setValue = value => {
5522
+ return editField(field, path, value);
5523
+ };
5524
+ return FeelEntry({
5525
+ debounce,
5526
+ element: field,
5527
+ feel: 'optional',
5528
+ getValue,
5529
+ id,
5530
+ label: 'Alternative text',
5531
+ setValue,
5532
+ variables
5533
+ });
5534
+ }
5535
+
5092
5536
  function ColumnsEntry(props) {
5093
5537
  const {
5094
5538
  editField,
@@ -5217,7 +5661,7 @@ function DefaultOptionEntry(props) {
5217
5661
  entries.push({
5218
5662
  ...defaultOptions,
5219
5663
  component: DefaultValueNumber,
5220
- isEdited: isEdited$5
5664
+ isEdited: isEdited$1
5221
5665
  });
5222
5666
  }
5223
5667
  if (type === 'radio' || type === 'select') {
@@ -5288,21 +5732,39 @@ function DefaultValueNumber(props) {
5288
5732
  id,
5289
5733
  label
5290
5734
  } = props;
5735
+ const {
5736
+ decimalDigits,
5737
+ serializeToString = false
5738
+ } = field;
5291
5739
  const debounce = useService('debounce');
5292
5740
  const path = ['defaultValue'];
5293
- const getValue = () => {
5294
- return get(field, path, '');
5741
+ const getValue = e => {
5742
+ let value = get(field, path);
5743
+ if (!isValidNumber(value)) return;
5744
+
5745
+ // Enforces decimal notation so that we do not submit defaults in exponent form
5746
+ return serializeToString ? Big(value).toFixed() : value;
5295
5747
  };
5296
5748
  const setValue = value => {
5297
- return editField(field, path, value);
5749
+ let newValue;
5750
+ if (isValidNumber(value)) {
5751
+ newValue = serializeToString ? value : Number(value);
5752
+ }
5753
+ return editField(field, path, newValue);
5298
5754
  };
5299
- return NumberFieldEntry({
5755
+ const decimalDigitsSet = decimalDigits || decimalDigits === 0;
5756
+ return TextfieldEntry({
5300
5757
  debounce,
5758
+ label,
5301
5759
  element: field,
5302
5760
  getValue,
5303
5761
  id,
5304
- label,
5305
- setValue
5762
+ setValue,
5763
+ validate: value => {
5764
+ if (value === undefined || value === null) return;
5765
+ if (!isValidNumber(value)) return 'Should be a valid number';
5766
+ if (decimalDigitsSet && countDecimals(value) > decimalDigits) return `Should not contain more than ${decimalDigits} decimal digits`;
5767
+ }
5306
5768
  });
5307
5769
  }
5308
5770
  function DefaultValueSingleSelect(props) {
@@ -5624,6 +6086,56 @@ function Label$1(props) {
5624
6086
  });
5625
6087
  }
5626
6088
 
6089
+ function SourceEntry(props) {
6090
+ const {
6091
+ editField,
6092
+ field
6093
+ } = props;
6094
+ const {
6095
+ type
6096
+ } = field;
6097
+ const entries = [];
6098
+ if (type === 'image') {
6099
+ entries.push({
6100
+ id: 'source',
6101
+ component: Source,
6102
+ editField: editField,
6103
+ field: field,
6104
+ isEdited: isEdited$6
6105
+ });
6106
+ }
6107
+ return entries;
6108
+ }
6109
+ function Source(props) {
6110
+ const {
6111
+ editField,
6112
+ field,
6113
+ id
6114
+ } = props;
6115
+ const debounce = useService('debounce');
6116
+ const variables = useVariables().map(name => ({
6117
+ name
6118
+ }));
6119
+ const path = ['source'];
6120
+ const getValue = () => {
6121
+ return get(field, path, '');
6122
+ };
6123
+ const setValue = value => {
6124
+ return editField(field, path, value);
6125
+ };
6126
+ return FeelEntry({
6127
+ debounce,
6128
+ description: 'Expression or static value (link/data URI)',
6129
+ element: field,
6130
+ feel: 'optional',
6131
+ getValue,
6132
+ id,
6133
+ label: 'Image source',
6134
+ setValue,
6135
+ variables
6136
+ });
6137
+ }
6138
+
5627
6139
  function TextEntry(props) {
5628
6140
  const {
5629
6141
  editField,
@@ -5670,6 +6182,144 @@ function Text(props) {
5670
6182
  });
5671
6183
  }
5672
6184
 
6185
+ function NumberEntries(props) {
6186
+ const {
6187
+ editField,
6188
+ field,
6189
+ id
6190
+ } = props;
6191
+ const {
6192
+ type
6193
+ } = field;
6194
+ if (type !== 'number') {
6195
+ return [];
6196
+ }
6197
+ const entries = [];
6198
+ entries.push({
6199
+ id: id + '-decimalDigits',
6200
+ component: NumberDecimalDigits,
6201
+ isEdited: isEdited$5,
6202
+ editField,
6203
+ field
6204
+ });
6205
+ entries.push({
6206
+ id: id + '-step',
6207
+ component: NumberArrowStep,
6208
+ isEdited: isEdited$1,
6209
+ editField,
6210
+ field
6211
+ });
6212
+ return entries;
6213
+ }
6214
+ function NumberDecimalDigits(props) {
6215
+ const {
6216
+ editField,
6217
+ field,
6218
+ id
6219
+ } = props;
6220
+ const debounce = useService('debounce');
6221
+ const getValue = e => get(field, ['decimalDigits']);
6222
+ const setValue = value => editField(field, ['decimalDigits'], value);
6223
+ return NumberFieldEntry({
6224
+ debounce,
6225
+ label: 'Decimal digits',
6226
+ element: field,
6227
+ min: 0,
6228
+ step: 1,
6229
+ getValue,
6230
+ id,
6231
+ setValue
6232
+ });
6233
+ }
6234
+ function NumberArrowStep(props) {
6235
+ const {
6236
+ editField,
6237
+ field,
6238
+ id
6239
+ } = props;
6240
+ const {
6241
+ decimalDigits
6242
+ } = field;
6243
+ const debounce = useService('debounce');
6244
+ const getValue = e => {
6245
+ let value = get(field, ['increment']);
6246
+ if (!isValidNumber(value)) return null;
6247
+ return value;
6248
+ };
6249
+ const setValue = value => editField(field, ['increment'], value);
6250
+ const decimalDigitsSet = decimalDigits || decimalDigits === 0;
6251
+ return TextfieldEntry({
6252
+ debounce,
6253
+ label: 'Increment',
6254
+ element: field,
6255
+ getValue,
6256
+ id,
6257
+ setValue,
6258
+ validate: value => {
6259
+ if (value === undefined || value === null) return;
6260
+ if (!isValidNumber(value)) return 'Should be a valid number.';
6261
+ if (Big(value).cmp(0) <= 0) return 'Should be greater than zero.';
6262
+ if (decimalDigitsSet) {
6263
+ const minimumValue = Big(`1e-${decimalDigits}`);
6264
+ if (Big(value).cmp(minimumValue) < 0) return `Should be at least ${minimumValue.toString()}.`;
6265
+ if (countDecimals(value) > decimalDigits) return `Should not contain more than ${decimalDigits} decimal digits.`;
6266
+ }
6267
+ }
6268
+ });
6269
+ }
6270
+
6271
+ function NumberSerializationEntry(props) {
6272
+ const {
6273
+ editField,
6274
+ field,
6275
+ id
6276
+ } = props;
6277
+ const {
6278
+ type
6279
+ } = field;
6280
+ if (type !== 'number') {
6281
+ return [];
6282
+ }
6283
+ const entries = [];
6284
+ entries.push({
6285
+ id: id + '-serialize-to-string',
6286
+ component: SerializeToString,
6287
+ isEdited: isEdited$7,
6288
+ editField,
6289
+ field
6290
+ });
6291
+ return entries;
6292
+ }
6293
+ function SerializeToString(props) {
6294
+ const {
6295
+ editField,
6296
+ field,
6297
+ id
6298
+ } = props;
6299
+ const {
6300
+ defaultValue
6301
+ } = field;
6302
+ const path = ['serializeToString'];
6303
+ const getValue = () => {
6304
+ return get(field, path, '');
6305
+ };
6306
+ const setValue = value => {
6307
+ // Whenever changing the formatting, make sure to change the default value type along with it
6308
+ if (defaultValue || defaultValue === 0) {
6309
+ editField(field, ['defaultValue'], value ? Big(defaultValue).toFixed() : Number(defaultValue));
6310
+ }
6311
+ return editField(field, path, value);
6312
+ };
6313
+ return CheckboxEntry({
6314
+ element: field,
6315
+ getValue,
6316
+ id,
6317
+ label: 'Serialize to string',
6318
+ description: 'Allows arbitrary precision values',
6319
+ setValue
6320
+ });
6321
+ }
6322
+
5673
6323
  function ValueEntry(props) {
5674
6324
  const {
5675
6325
  editField,
@@ -5978,6 +6628,15 @@ function InputValuesKey(props) {
5978
6628
  const path = VALUES_SOURCES_PATHS[VALUES_SOURCES.INPUT];
5979
6629
  const getValue = () => get(field, path, '');
5980
6630
  const setValue = value => editField(field, path, value || '');
6631
+ const validate = value => {
6632
+ if (isUndefined(value) || !value.length) {
6633
+ return 'Must not be empty.';
6634
+ }
6635
+ if (/\s/.test(value)) {
6636
+ return 'Must not contain spaces.';
6637
+ }
6638
+ return null;
6639
+ };
5981
6640
  return TextfieldEntry({
5982
6641
  debounce,
5983
6642
  description,
@@ -5985,7 +6644,8 @@ function InputValuesKey(props) {
5985
6644
  getValue,
5986
6645
  id,
5987
6646
  label,
5988
- setValue
6647
+ setValue,
6648
+ validate
5989
6649
  });
5990
6650
  }
5991
6651
 
@@ -6058,6 +6718,54 @@ function getIndexedEntry(index) {
6058
6718
  return entry;
6059
6719
  }
6060
6720
 
6721
+ function ConditionEntry(props) {
6722
+ const {
6723
+ editField,
6724
+ field
6725
+ } = props;
6726
+ return [{
6727
+ id: 'conditional-hide',
6728
+ component: Condition,
6729
+ editField: editField,
6730
+ field: field,
6731
+ isEdited: isEdited$6
6732
+ }];
6733
+ }
6734
+ function Condition(props) {
6735
+ const {
6736
+ editField,
6737
+ field,
6738
+ id
6739
+ } = props;
6740
+ const debounce = useService('debounce');
6741
+ const variables = useVariables().map(name => ({
6742
+ name
6743
+ }));
6744
+ const path = ['conditional', 'hide'];
6745
+ const getValue = () => {
6746
+ return get(field, path, '');
6747
+ };
6748
+ const setValue = value => {
6749
+ if (!value) {
6750
+ return editField(field, 'conditional', undefined);
6751
+ }
6752
+ return editField(field, 'conditional', {
6753
+ hide: value
6754
+ });
6755
+ };
6756
+ return FeelEntry({
6757
+ debounce,
6758
+ description: 'Condition under which the field is hidden',
6759
+ element: field,
6760
+ feel: 'required',
6761
+ getValue,
6762
+ id,
6763
+ label: 'Hide if',
6764
+ setValue,
6765
+ variables
6766
+ });
6767
+ }
6768
+
6061
6769
  function GeneralGroup(field, editField) {
6062
6770
  const entries = [...IdEntry({
6063
6771
  field,
@@ -6083,6 +6791,15 @@ function GeneralGroup(field, editField) {
6083
6791
  }), ...TextEntry({
6084
6792
  field,
6085
6793
  editField
6794
+ }), ...NumberEntries({
6795
+ field,
6796
+ editField
6797
+ }), ...SourceEntry({
6798
+ field,
6799
+ editField
6800
+ }), ...AltTextEntry({
6801
+ field,
6802
+ editField
6086
6803
  }), ...DisabledEntry({
6087
6804
  field,
6088
6805
  editField
@@ -6094,6 +6811,21 @@ function GeneralGroup(field, editField) {
6094
6811
  };
6095
6812
  }
6096
6813
 
6814
+ function SerializationGroup(field, editField) {
6815
+ const entries = [...NumberSerializationEntry({
6816
+ field,
6817
+ editField
6818
+ })];
6819
+ if (!entries.length) {
6820
+ return null;
6821
+ }
6822
+ return {
6823
+ id: 'serialization',
6824
+ label: 'Serialization',
6825
+ entries
6826
+ };
6827
+ }
6828
+
6097
6829
  const VALIDATION_TYPE_OPTIONS = {
6098
6830
  custom: {
6099
6831
  value: 'custom',
@@ -6458,11 +7190,29 @@ function removeKey(properties, oldKey) {
6458
7190
  }, {});
6459
7191
  }
6460
7192
 
7193
+ function ConditionGroup(field, editField) {
7194
+ const {
7195
+ type
7196
+ } = field;
7197
+ if (type === 'default') {
7198
+ return null;
7199
+ }
7200
+ const entries = [...ConditionEntry({
7201
+ field,
7202
+ editField
7203
+ })];
7204
+ return {
7205
+ id: 'condition',
7206
+ label: 'Condition',
7207
+ entries
7208
+ };
7209
+ }
7210
+
6461
7211
  function getGroups(field, editField) {
6462
7212
  if (!field) {
6463
7213
  return [];
6464
7214
  }
6465
- const groups = [GeneralGroup(field, editField), ...ValuesGroups(field, editField), ValidationGroup(field, editField), CustomValuesGroup(field, editField)];
7215
+ const groups = [GeneralGroup(field, editField), ConditionGroup(field, editField), SerializationGroup(field, editField), ...ValuesGroups(field, editField), ValidationGroup(field, editField), CustomValuesGroup(field, editField)];
6466
7216
 
6467
7217
  // contract: if a group returns null, it should not be displayed at all
6468
7218
  return groups.filter(group => group !== null);