@bpmn-io/form-js-editor 0.11.1 → 0.12.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/assets/form-js-editor.css +180 -54
- package/dist/assets/properties-panel.css +1016 -1016
- package/dist/index.cjs +714 -397
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +696 -366
- package/dist/index.es.js.map +1 -1
- package/dist/types/FormEditor.d.ts +2 -2
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/features/palette/components/Palette.d.ts +9 -0
- package/dist/types/features/properties-panel/entries/SelectEntries.d.ts +9 -0
- package/dist/types/features/properties-panel/entries/factories/index.d.ts +1 -0
- package/dist/types/features/properties-panel/entries/factories/simpleBoolEntryFactory.d.ts +9 -0
- package/dist/types/features/properties-panel/entries/index.d.ts +1 -0
- package/dist/types/render/EditorFormFields.d.ts +3 -0
- package/dist/types/render/components/Util.d.ts +3 -0
- package/dist/types/render/components/editor-form-fields/EditorText.d.ts +8 -0
- package/dist/types/render/components/editor-form-fields/index.d.ts +2 -0
- package/dist/types/render/components/icons/index.d.ts +1 -0
- package/dist/types/render/index.d.ts +2 -2
- package/dist/types/render/util/Cursor.d.ts +3 -0
- package/dist/types/{src/types.d.ts → types.d.ts} +0 -0
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var formJsViewer = require('@bpmn-io/form-js-viewer');
|
|
6
4
|
var Ids = require('ids');
|
|
7
5
|
var minDash = require('min-dash');
|
|
6
|
+
var classnames = require('classnames');
|
|
7
|
+
var jsxRuntime = require('preact/jsx-runtime');
|
|
8
8
|
var preact = require('preact');
|
|
9
9
|
var hooks$1 = require('preact/hooks');
|
|
10
10
|
var dragula = require('dragula');
|
|
11
|
-
var jsxRuntime = require('preact/jsx-runtime');
|
|
12
11
|
var React = require('preact/compat');
|
|
13
12
|
var minDom = require('min-dom');
|
|
14
13
|
var arrayMove = require('array-move');
|
|
15
|
-
var classnames = require('classnames');
|
|
16
14
|
var FeelEditor = require('@bpmn-io/feel-editor');
|
|
17
15
|
var Big = require('big.js');
|
|
18
16
|
|
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
var Ids__default = /*#__PURE__*/_interopDefaultLegacy(Ids);
|
|
22
|
-
var dragula__default = /*#__PURE__*/_interopDefaultLegacy(dragula);
|
|
23
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
24
|
-
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
25
|
-
var FeelEditor__default = /*#__PURE__*/_interopDefaultLegacy(FeelEditor);
|
|
26
|
-
var Big__default = /*#__PURE__*/_interopDefaultLegacy(Big);
|
|
27
|
-
|
|
28
17
|
var FN_REF = '__fn';
|
|
29
18
|
var DEFAULT_PRIORITY$2 = 1000;
|
|
30
19
|
var slice = Array.prototype.slice;
|
|
@@ -683,9 +672,98 @@ var importModule = {
|
|
|
683
672
|
importer: ['type', Importer]
|
|
684
673
|
};
|
|
685
674
|
|
|
675
|
+
function editorFormFieldClasses(type, {
|
|
676
|
+
disabled = false
|
|
677
|
+
} = {}) {
|
|
678
|
+
if (!type) {
|
|
679
|
+
throw new Error('type required');
|
|
680
|
+
}
|
|
681
|
+
return classnames('fjs-form-field', `fjs-form-field-${type}`, {
|
|
682
|
+
'fjs-disabled': disabled
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
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); }
|
|
687
|
+
var CloseIcon = (({
|
|
688
|
+
styles = {},
|
|
689
|
+
...props
|
|
690
|
+
}) => /*#__PURE__*/React.createElement("svg", _extends$2({
|
|
691
|
+
width: "16",
|
|
692
|
+
height: "16",
|
|
693
|
+
fill: "currentColor",
|
|
694
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
695
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
696
|
+
fillRule: "evenodd",
|
|
697
|
+
clipRule: "evenodd",
|
|
698
|
+
d: "M12 4.7l-.7-.7L8 7.3 4.7 4l-.7.7L7.3 8 4 11.3l.7.7L8 8.7l3.3 3.3.7-.7L8.7 8 12 4.7z"
|
|
699
|
+
})));
|
|
700
|
+
|
|
701
|
+
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); }
|
|
702
|
+
var SearchIcon = (({
|
|
703
|
+
styles = {},
|
|
704
|
+
...props
|
|
705
|
+
}) => /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
706
|
+
width: "15",
|
|
707
|
+
height: "15",
|
|
708
|
+
fill: "none",
|
|
709
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
710
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
711
|
+
d: "M14.5 13.793l-3.776-3.776a5.508 5.508 0 10-.707.707l3.776 3.776.707-.707zM2 6.5a4.5 4.5 0 119 0 4.5 4.5 0 01-9 0z",
|
|
712
|
+
fill: "currentColor"
|
|
713
|
+
})));
|
|
714
|
+
|
|
715
|
+
function EditorText(props) {
|
|
716
|
+
const {
|
|
717
|
+
type,
|
|
718
|
+
text = ''
|
|
719
|
+
} = props.field;
|
|
720
|
+
const Icon = formJsViewer.iconsByType('text');
|
|
721
|
+
if (!text) {
|
|
722
|
+
return jsxRuntime.jsx("div", {
|
|
723
|
+
class: editorFormFieldClasses(type),
|
|
724
|
+
children: jsxRuntime.jsxs("div", {
|
|
725
|
+
class: "fjs-form-field-placeholder",
|
|
726
|
+
children: [jsxRuntime.jsx(Icon, {
|
|
727
|
+
viewBox: "0 0 54 54"
|
|
728
|
+
}), "Text view is empty"]
|
|
729
|
+
})
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
if (formJsViewer.isExpression(text)) {
|
|
733
|
+
return jsxRuntime.jsx("div", {
|
|
734
|
+
class: editorFormFieldClasses(type),
|
|
735
|
+
children: jsxRuntime.jsxs("div", {
|
|
736
|
+
class: "fjs-form-field-placeholder",
|
|
737
|
+
children: [jsxRuntime.jsx(Icon, {
|
|
738
|
+
viewBox: "0 0 54 54"
|
|
739
|
+
}), "Text view is populated by an expression"]
|
|
740
|
+
})
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
return jsxRuntime.jsx(formJsViewer.Text, {
|
|
744
|
+
...props,
|
|
745
|
+
disableLinks: true
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
EditorText.create = formJsViewer.Text.create;
|
|
749
|
+
EditorText.type = formJsViewer.Text.type;
|
|
750
|
+
EditorText.keyed = formJsViewer.Text.keyed;
|
|
751
|
+
|
|
752
|
+
const editorFormFields = [EditorText];
|
|
753
|
+
|
|
754
|
+
class EditorFormFields extends formJsViewer.FormFields {
|
|
755
|
+
constructor() {
|
|
756
|
+
super();
|
|
757
|
+
editorFormFields.forEach(formField => {
|
|
758
|
+
this.register(formField.type, formField);
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
686
763
|
const DragAndDropContext = preact.createContext({
|
|
687
764
|
drake: null
|
|
688
765
|
});
|
|
766
|
+
var DragAndDropContext$1 = DragAndDropContext;
|
|
689
767
|
|
|
690
768
|
/**
|
|
691
769
|
* @param {string} type
|
|
@@ -697,11 +775,12 @@ function getService$1(type, strict) {}
|
|
|
697
775
|
const FormEditorContext = preact.createContext({
|
|
698
776
|
getService: getService$1
|
|
699
777
|
});
|
|
778
|
+
var FormEditorContext$1 = FormEditorContext;
|
|
700
779
|
|
|
701
780
|
function useService$1 (type, strict) {
|
|
702
781
|
const {
|
|
703
782
|
getService
|
|
704
|
-
} = hooks$1.useContext(FormEditorContext);
|
|
783
|
+
} = hooks$1.useContext(FormEditorContext$1);
|
|
705
784
|
return getService(type, strict);
|
|
706
785
|
}
|
|
707
786
|
|
|
@@ -709,14 +788,157 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
709
788
|
var ListDeleteIcon = (({
|
|
710
789
|
styles = {},
|
|
711
790
|
...props
|
|
712
|
-
}) => /*#__PURE__*/
|
|
791
|
+
}) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
713
792
|
xmlns: "http://www.w3.org/2000/svg",
|
|
714
793
|
width: "11",
|
|
715
794
|
height: "14"
|
|
716
|
-
}, props), /*#__PURE__*/
|
|
795
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
717
796
|
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"
|
|
718
797
|
})));
|
|
719
798
|
|
|
799
|
+
const PALETTE_ENTRIES = formJsViewer.formFields.filter(f => f.type !== 'default').map(f => {
|
|
800
|
+
return {
|
|
801
|
+
label: f.label,
|
|
802
|
+
type: f.type,
|
|
803
|
+
group: f.group
|
|
804
|
+
};
|
|
805
|
+
});
|
|
806
|
+
const PALETTE_GROUPS = [{
|
|
807
|
+
label: 'Basic input',
|
|
808
|
+
id: 'basic-input'
|
|
809
|
+
}, {
|
|
810
|
+
label: 'Selection',
|
|
811
|
+
id: 'selection'
|
|
812
|
+
}, {
|
|
813
|
+
label: 'Presentation',
|
|
814
|
+
id: 'presentation'
|
|
815
|
+
}, {
|
|
816
|
+
label: 'Action',
|
|
817
|
+
id: 'action'
|
|
818
|
+
}];
|
|
819
|
+
function Palette(props) {
|
|
820
|
+
const [entries, setEntries] = hooks$1.useState(PALETTE_ENTRIES);
|
|
821
|
+
const [searchTerm, setSearchTerm] = hooks$1.useState('');
|
|
822
|
+
const inputRef = hooks$1.useRef();
|
|
823
|
+
const groups = groupEntries(entries);
|
|
824
|
+
|
|
825
|
+
// filter entries on search change
|
|
826
|
+
hooks$1.useEffect(() => {
|
|
827
|
+
const filter = entry => {
|
|
828
|
+
if (!searchTerm) {
|
|
829
|
+
return true;
|
|
830
|
+
}
|
|
831
|
+
const search = entry.label.toLowerCase();
|
|
832
|
+
return searchTerm.toLowerCase().split(/\s/g).every(term => search.includes(term));
|
|
833
|
+
};
|
|
834
|
+
const entries = PALETTE_ENTRIES.filter(filter);
|
|
835
|
+
setEntries(entries);
|
|
836
|
+
}, [searchTerm]);
|
|
837
|
+
const handleInput = hooks$1.useCallback(event => {
|
|
838
|
+
setSearchTerm(() => event.target.value);
|
|
839
|
+
}, [setSearchTerm]);
|
|
840
|
+
const handleClear = hooks$1.useCallback(event => {
|
|
841
|
+
setSearchTerm('');
|
|
842
|
+
inputRef.current.focus();
|
|
843
|
+
}, [inputRef, setSearchTerm]);
|
|
844
|
+
return jsxRuntime.jsxs("div", {
|
|
845
|
+
class: "fjs-palette",
|
|
846
|
+
children: [jsxRuntime.jsx("div", {
|
|
847
|
+
class: "fjs-palette-header",
|
|
848
|
+
title: "Components",
|
|
849
|
+
children: "Components"
|
|
850
|
+
}), jsxRuntime.jsxs("div", {
|
|
851
|
+
class: "fjs-palette-search-container",
|
|
852
|
+
children: [jsxRuntime.jsx("span", {
|
|
853
|
+
class: "fjs-palette-search-icon",
|
|
854
|
+
children: jsxRuntime.jsx(SearchIcon, {})
|
|
855
|
+
}), jsxRuntime.jsx("input", {
|
|
856
|
+
class: "fjs-palette-search",
|
|
857
|
+
ref: inputRef,
|
|
858
|
+
type: "text",
|
|
859
|
+
placeholder: "Search components",
|
|
860
|
+
value: searchTerm,
|
|
861
|
+
onInput: handleInput
|
|
862
|
+
}), searchTerm && jsxRuntime.jsx("button", {
|
|
863
|
+
title: "Clear content",
|
|
864
|
+
class: "fjs-palette-search-clear",
|
|
865
|
+
onClick: handleClear,
|
|
866
|
+
children: jsxRuntime.jsx(CloseIcon, {})
|
|
867
|
+
})]
|
|
868
|
+
}), jsxRuntime.jsxs("div", {
|
|
869
|
+
class: "fjs-palette-entries",
|
|
870
|
+
children: [groups.map(({
|
|
871
|
+
label,
|
|
872
|
+
entries,
|
|
873
|
+
id
|
|
874
|
+
}) => jsxRuntime.jsxs("div", {
|
|
875
|
+
class: "fjs-palette-group",
|
|
876
|
+
"data-group-id": id,
|
|
877
|
+
children: [jsxRuntime.jsx("span", {
|
|
878
|
+
class: "fjs-palette-group-title",
|
|
879
|
+
children: label
|
|
880
|
+
}), jsxRuntime.jsx("div", {
|
|
881
|
+
class: "fjs-palette-fields fjs-drag-container fjs-no-drop",
|
|
882
|
+
children: entries.map(({
|
|
883
|
+
label,
|
|
884
|
+
type
|
|
885
|
+
}) => {
|
|
886
|
+
const Icon = formJsViewer.iconsByType(type);
|
|
887
|
+
return jsxRuntime.jsxs("div", {
|
|
888
|
+
class: "fjs-palette-field fjs-drag-copy fjs-no-drop",
|
|
889
|
+
"data-field-type": type,
|
|
890
|
+
title: `Create a ${label} element`,
|
|
891
|
+
children: [Icon ? jsxRuntime.jsx(Icon, {
|
|
892
|
+
class: "fjs-palette-field-icon",
|
|
893
|
+
width: "36",
|
|
894
|
+
height: "36",
|
|
895
|
+
viewBox: "0 0 54 54"
|
|
896
|
+
}) : null, jsxRuntime.jsx("span", {
|
|
897
|
+
class: "fjs-palette-field-text",
|
|
898
|
+
children: label
|
|
899
|
+
})]
|
|
900
|
+
});
|
|
901
|
+
})
|
|
902
|
+
})]
|
|
903
|
+
})), groups.length == 0 && jsxRuntime.jsx("div", {
|
|
904
|
+
class: "fjs-palette-no-entries",
|
|
905
|
+
children: "No components found."
|
|
906
|
+
})]
|
|
907
|
+
})]
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// helpers ///////
|
|
912
|
+
|
|
913
|
+
function groupEntries(entries) {
|
|
914
|
+
const groups = PALETTE_GROUPS.map(group => {
|
|
915
|
+
return {
|
|
916
|
+
...group,
|
|
917
|
+
entries: []
|
|
918
|
+
};
|
|
919
|
+
});
|
|
920
|
+
const getGroup = id => groups.find(group => id === group.id);
|
|
921
|
+
entries.forEach(entry => {
|
|
922
|
+
const {
|
|
923
|
+
group
|
|
924
|
+
} = entry;
|
|
925
|
+
getGroup(group).entries.push(entry);
|
|
926
|
+
});
|
|
927
|
+
return groups.filter(g => g.entries.length);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
const CURSOR_CLS_PATTERN = /^fjs-cursor-.*$/;
|
|
931
|
+
function set(mode) {
|
|
932
|
+
const classes = minDom.classes(document.body);
|
|
933
|
+
classes.removeMatching(CURSOR_CLS_PATTERN);
|
|
934
|
+
if (mode) {
|
|
935
|
+
classes.add('fjs-cursor-' + mode);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
function unset() {
|
|
939
|
+
set(null);
|
|
940
|
+
}
|
|
941
|
+
|
|
720
942
|
function ContextPad(props) {
|
|
721
943
|
if (!props.children) {
|
|
722
944
|
return null;
|
|
@@ -840,8 +1062,11 @@ function FormEditor$1(props) {
|
|
|
840
1062
|
drake
|
|
841
1063
|
};
|
|
842
1064
|
hooks$1.useEffect(() => {
|
|
1065
|
+
const handleDragEvent = (type, context) => {
|
|
1066
|
+
return eventBus.fire(type, context);
|
|
1067
|
+
};
|
|
843
1068
|
const createDragulaInstance = () => {
|
|
844
|
-
const dragulaInstance =
|
|
1069
|
+
const dragulaInstance = dragula({
|
|
845
1070
|
isContainer(el) {
|
|
846
1071
|
return el.classList.contains('fjs-drag-container');
|
|
847
1072
|
},
|
|
@@ -854,6 +1079,56 @@ function FormEditor$1(props) {
|
|
|
854
1079
|
slideFactorX: 10,
|
|
855
1080
|
slideFactorY: 5
|
|
856
1081
|
});
|
|
1082
|
+
|
|
1083
|
+
// bind life cycle events
|
|
1084
|
+
dragulaInstance.on('drag', (element, source) => {
|
|
1085
|
+
handleDragEvent('drag.start', {
|
|
1086
|
+
element,
|
|
1087
|
+
source
|
|
1088
|
+
});
|
|
1089
|
+
});
|
|
1090
|
+
dragulaInstance.on('dragend', element => {
|
|
1091
|
+
handleDragEvent('drag.end', {
|
|
1092
|
+
element
|
|
1093
|
+
});
|
|
1094
|
+
});
|
|
1095
|
+
dragulaInstance.on('drop', (element, target, source, sibling) => {
|
|
1096
|
+
handleDragEvent('drag.drop', {
|
|
1097
|
+
element,
|
|
1098
|
+
target,
|
|
1099
|
+
source,
|
|
1100
|
+
sibling
|
|
1101
|
+
});
|
|
1102
|
+
});
|
|
1103
|
+
dragulaInstance.on('over', (element, container, source) => {
|
|
1104
|
+
handleDragEvent('drag.hover', {
|
|
1105
|
+
element,
|
|
1106
|
+
container,
|
|
1107
|
+
source
|
|
1108
|
+
});
|
|
1109
|
+
});
|
|
1110
|
+
dragulaInstance.on('out', (element, container, source) => {
|
|
1111
|
+
handleDragEvent('drag.out', {
|
|
1112
|
+
element,
|
|
1113
|
+
container,
|
|
1114
|
+
source
|
|
1115
|
+
});
|
|
1116
|
+
});
|
|
1117
|
+
dragulaInstance.on('cancel', (element, container, source) => {
|
|
1118
|
+
handleDragEvent('drag.cancel', {
|
|
1119
|
+
element,
|
|
1120
|
+
container,
|
|
1121
|
+
source
|
|
1122
|
+
});
|
|
1123
|
+
});
|
|
1124
|
+
|
|
1125
|
+
// set custom styling
|
|
1126
|
+
dragulaInstance.on('drag', () => {
|
|
1127
|
+
set('grabbing');
|
|
1128
|
+
});
|
|
1129
|
+
dragulaInstance.on('dragend', () => {
|
|
1130
|
+
unset();
|
|
1131
|
+
});
|
|
857
1132
|
dragulaInstance.on('drop', (el, target, source, sibling) => {
|
|
858
1133
|
dragulaInstance.remove();
|
|
859
1134
|
if (!target) {
|
|
@@ -910,9 +1185,7 @@ function FormEditor$1(props) {
|
|
|
910
1185
|
const formContext = {
|
|
911
1186
|
getService(type, strict = true) {
|
|
912
1187
|
// TODO(philippfromme): clean up
|
|
913
|
-
if (type === '
|
|
914
|
-
return new Map();
|
|
915
|
-
} else if (type === 'form') {
|
|
1188
|
+
if (type === 'form') {
|
|
916
1189
|
return {
|
|
917
1190
|
_getState() {
|
|
918
1191
|
return {
|
|
@@ -950,7 +1223,7 @@ function FormEditor$1(props) {
|
|
|
950
1223
|
}, [propertiesPanelRef, propertiesPanel, hasDefaultPropertiesPanel]);
|
|
951
1224
|
return jsxRuntime.jsxs("div", {
|
|
952
1225
|
class: "fjs-form-editor",
|
|
953
|
-
children: [jsxRuntime.jsxs(DragAndDropContext.Provider, {
|
|
1226
|
+
children: [jsxRuntime.jsxs(DragAndDropContext$1.Provider, {
|
|
954
1227
|
value: dragAndDropContext,
|
|
955
1228
|
children: [hasDefaultPalette && jsxRuntime.jsx("div", {
|
|
956
1229
|
class: "fjs-editor-palette-container",
|
|
@@ -988,14 +1261,32 @@ function getFormFieldIndex(parent, formField) {
|
|
|
988
1261
|
function CreatePreview(props) {
|
|
989
1262
|
const {
|
|
990
1263
|
drake
|
|
991
|
-
} = hooks$1.useContext(DragAndDropContext);
|
|
1264
|
+
} = hooks$1.useContext(DragAndDropContext$1);
|
|
992
1265
|
function handleCloned(clone, original, type) {
|
|
993
1266
|
const fieldType = clone.dataset.fieldType;
|
|
994
|
-
const Icon = formJsViewer.iconsByType
|
|
1267
|
+
const Icon = formJsViewer.iconsByType(fieldType);
|
|
1268
|
+
const {
|
|
1269
|
+
label
|
|
1270
|
+
} = findPaletteEntry(fieldType);
|
|
995
1271
|
if (fieldType) {
|
|
996
1272
|
clone.innerHTML = '';
|
|
997
1273
|
clone.class = 'gu-mirror';
|
|
998
|
-
|
|
1274
|
+
if (original.classList.contains('fjs-palette-field')) {
|
|
1275
|
+
preact.render(jsxRuntime.jsxs("div", {
|
|
1276
|
+
class: "fjs-palette-field",
|
|
1277
|
+
children: [jsxRuntime.jsx(Icon, {
|
|
1278
|
+
class: "fjs-palette-field-icon",
|
|
1279
|
+
width: "36",
|
|
1280
|
+
height: "36",
|
|
1281
|
+
viewBox: "0 0 54 54"
|
|
1282
|
+
}), jsxRuntime.jsx("span", {
|
|
1283
|
+
class: "fjs-palette-field-text",
|
|
1284
|
+
children: label
|
|
1285
|
+
})]
|
|
1286
|
+
}), clone);
|
|
1287
|
+
} else {
|
|
1288
|
+
preact.render(jsxRuntime.jsx(Icon, {}), clone);
|
|
1289
|
+
}
|
|
999
1290
|
}
|
|
1000
1291
|
}
|
|
1001
1292
|
hooks$1.useEffect(() => {
|
|
@@ -1016,6 +1307,9 @@ function defaultPalette(paletteConfig) {
|
|
|
1016
1307
|
function defaultPropertiesPanel(propertiesPanelConfig) {
|
|
1017
1308
|
return !(propertiesPanelConfig && propertiesPanelConfig.parent);
|
|
1018
1309
|
}
|
|
1310
|
+
function findPaletteEntry(type) {
|
|
1311
|
+
return PALETTE_ENTRIES.find(entry => entry.type === type);
|
|
1312
|
+
}
|
|
1019
1313
|
|
|
1020
1314
|
class Renderer {
|
|
1021
1315
|
constructor(renderConfig, eventBus, formEditor, injector) {
|
|
@@ -1041,7 +1335,7 @@ class Renderer {
|
|
|
1041
1335
|
}
|
|
1042
1336
|
return jsxRuntime.jsx("div", {
|
|
1043
1337
|
class: `fjs-container fjs-editor-container ${compact ? 'fjs-editor-compact' : ''}`,
|
|
1044
|
-
children: jsxRuntime.jsx(FormEditorContext.Provider, {
|
|
1338
|
+
children: jsxRuntime.jsx(FormEditorContext$1.Provider, {
|
|
1045
1339
|
value: formEditorContext,
|
|
1046
1340
|
children: jsxRuntime.jsx(FormEditor$1, {})
|
|
1047
1341
|
})
|
|
@@ -1059,7 +1353,7 @@ Renderer.$inject = ['config.renderer', 'eventBus', 'formEditor', 'injector'];
|
|
|
1059
1353
|
|
|
1060
1354
|
var renderModule = {
|
|
1061
1355
|
__init__: ['formFields', 'renderer'],
|
|
1062
|
-
formFields: ['type',
|
|
1356
|
+
formFields: ['type', EditorFormFields],
|
|
1063
1357
|
renderer: ['type', Renderer]
|
|
1064
1358
|
};
|
|
1065
1359
|
|
|
@@ -2910,79 +3204,6 @@ var SelectionModule = {
|
|
|
2910
3204
|
selectionBehavior: ['type', SelectionBehavior]
|
|
2911
3205
|
};
|
|
2912
3206
|
|
|
2913
|
-
const types = [{
|
|
2914
|
-
label: 'Text field',
|
|
2915
|
-
type: 'textfield'
|
|
2916
|
-
}, {
|
|
2917
|
-
label: 'Text area',
|
|
2918
|
-
type: 'textarea'
|
|
2919
|
-
}, {
|
|
2920
|
-
label: 'Number',
|
|
2921
|
-
type: 'number'
|
|
2922
|
-
}, {
|
|
2923
|
-
label: 'Datetime',
|
|
2924
|
-
type: 'datetime'
|
|
2925
|
-
}, {
|
|
2926
|
-
label: 'Checkbox',
|
|
2927
|
-
type: 'checkbox'
|
|
2928
|
-
}, {
|
|
2929
|
-
label: 'Checklist',
|
|
2930
|
-
type: 'checklist'
|
|
2931
|
-
}, {
|
|
2932
|
-
label: 'Taglist',
|
|
2933
|
-
type: 'taglist'
|
|
2934
|
-
}, {
|
|
2935
|
-
label: 'Radio',
|
|
2936
|
-
type: 'radio'
|
|
2937
|
-
}, {
|
|
2938
|
-
label: 'Select',
|
|
2939
|
-
type: 'select'
|
|
2940
|
-
}, {
|
|
2941
|
-
label: 'Text view',
|
|
2942
|
-
type: 'text'
|
|
2943
|
-
}, {
|
|
2944
|
-
label: 'Image view',
|
|
2945
|
-
type: 'image'
|
|
2946
|
-
}, {
|
|
2947
|
-
label: 'Button',
|
|
2948
|
-
type: 'button'
|
|
2949
|
-
}];
|
|
2950
|
-
function Palette(props) {
|
|
2951
|
-
return jsxRuntime.jsxs("div", {
|
|
2952
|
-
class: "fjs-palette",
|
|
2953
|
-
children: [jsxRuntime.jsxs("div", {
|
|
2954
|
-
class: "fjs-palette-header",
|
|
2955
|
-
title: "Form elements library",
|
|
2956
|
-
children: [jsxRuntime.jsx("span", {
|
|
2957
|
-
class: "fjs-hide-compact",
|
|
2958
|
-
children: "FORM ELEMENTS "
|
|
2959
|
-
}), "LIBRARY"]
|
|
2960
|
-
}), jsxRuntime.jsx("div", {
|
|
2961
|
-
class: "fjs-palette-fields fjs-drag-container fjs-no-drop",
|
|
2962
|
-
children: types.map(({
|
|
2963
|
-
label,
|
|
2964
|
-
type
|
|
2965
|
-
}) => {
|
|
2966
|
-
const Icon = formJsViewer.iconsByType[type];
|
|
2967
|
-
return jsxRuntime.jsxs("div", {
|
|
2968
|
-
class: "fjs-palette-field fjs-drag-copy fjs-no-drop",
|
|
2969
|
-
"data-field-type": type,
|
|
2970
|
-
title: `Create a ${label} element`,
|
|
2971
|
-
children: [Icon ? jsxRuntime.jsx(Icon, {
|
|
2972
|
-
class: "fjs-palette-field-icon",
|
|
2973
|
-
width: "36",
|
|
2974
|
-
height: "36",
|
|
2975
|
-
viewBox: "0 0 54 54"
|
|
2976
|
-
}) : null, jsxRuntime.jsx("span", {
|
|
2977
|
-
class: "fjs-palette-field-text",
|
|
2978
|
-
children: label
|
|
2979
|
-
})]
|
|
2980
|
-
});
|
|
2981
|
-
})
|
|
2982
|
-
})]
|
|
2983
|
-
});
|
|
2984
|
-
}
|
|
2985
|
-
|
|
2986
3207
|
class PaletteRenderer {
|
|
2987
3208
|
constructor(paletteConfig, eventBus) {
|
|
2988
3209
|
const {
|
|
@@ -3204,19 +3425,19 @@ const ErrorsContext = preact.createContext({
|
|
|
3204
3425
|
errors: {}
|
|
3205
3426
|
});
|
|
3206
3427
|
|
|
3207
|
-
/**
|
|
3208
|
-
* @typedef {Function} <propertiesPanel.showEntry> callback
|
|
3209
|
-
*
|
|
3210
|
-
* @example
|
|
3211
|
-
*
|
|
3212
|
-
* useEvent('propertiesPanel.showEntry', ({ focus = false, ...rest }) => {
|
|
3213
|
-
* // ...
|
|
3214
|
-
* });
|
|
3215
|
-
*
|
|
3216
|
-
* @param {Object} context
|
|
3217
|
-
* @param {boolean} [context.focus]
|
|
3218
|
-
*
|
|
3219
|
-
* @returns void
|
|
3428
|
+
/**
|
|
3429
|
+
* @typedef {Function} <propertiesPanel.showEntry> callback
|
|
3430
|
+
*
|
|
3431
|
+
* @example
|
|
3432
|
+
*
|
|
3433
|
+
* useEvent('propertiesPanel.showEntry', ({ focus = false, ...rest }) => {
|
|
3434
|
+
* // ...
|
|
3435
|
+
* });
|
|
3436
|
+
*
|
|
3437
|
+
* @param {Object} context
|
|
3438
|
+
* @param {boolean} [context.focus]
|
|
3439
|
+
*
|
|
3440
|
+
* @returns void
|
|
3220
3441
|
*/
|
|
3221
3442
|
const EventContext = preact.createContext({
|
|
3222
3443
|
eventBus: null
|
|
@@ -3228,20 +3449,20 @@ const LayoutContext = preact.createContext({
|
|
|
3228
3449
|
setLayoutForKey: () => {}
|
|
3229
3450
|
});
|
|
3230
3451
|
|
|
3231
|
-
/**
|
|
3232
|
-
* Accesses the global DescriptionContext and returns a description for a given id and element.
|
|
3233
|
-
*
|
|
3234
|
-
* @example
|
|
3235
|
-
* ```jsx
|
|
3236
|
-
* function TextField(props) {
|
|
3237
|
-
* const description = useDescriptionContext('input1', element);
|
|
3238
|
-
* }
|
|
3239
|
-
* ```
|
|
3240
|
-
*
|
|
3241
|
-
* @param {string} id
|
|
3242
|
-
* @param {object} element
|
|
3243
|
-
*
|
|
3244
|
-
* @returns {string}
|
|
3452
|
+
/**
|
|
3453
|
+
* Accesses the global DescriptionContext and returns a description for a given id and element.
|
|
3454
|
+
*
|
|
3455
|
+
* @example
|
|
3456
|
+
* ```jsx
|
|
3457
|
+
* function TextField(props) {
|
|
3458
|
+
* const description = useDescriptionContext('input1', element);
|
|
3459
|
+
* }
|
|
3460
|
+
* ```
|
|
3461
|
+
*
|
|
3462
|
+
* @param {string} id
|
|
3463
|
+
* @param {object} element
|
|
3464
|
+
*
|
|
3465
|
+
* @returns {string}
|
|
3245
3466
|
*/
|
|
3246
3467
|
function useDescriptionContext(id, element) {
|
|
3247
3468
|
const {
|
|
@@ -3256,11 +3477,11 @@ function useError(id) {
|
|
|
3256
3477
|
return errors[id];
|
|
3257
3478
|
}
|
|
3258
3479
|
|
|
3259
|
-
/**
|
|
3260
|
-
* Subscribe to an event immediately. Update subscription after inputs changed.
|
|
3261
|
-
*
|
|
3262
|
-
* @param {string} event
|
|
3263
|
-
* @param {Function} callback
|
|
3480
|
+
/**
|
|
3481
|
+
* Subscribe to an event immediately. Update subscription after inputs changed.
|
|
3482
|
+
*
|
|
3483
|
+
* @param {string} event
|
|
3484
|
+
* @param {Function} callback
|
|
3264
3485
|
*/
|
|
3265
3486
|
function useEvent(event, callback, eventBus) {
|
|
3266
3487
|
const eventContext = hooks$1.useContext(EventContext);
|
|
@@ -3290,20 +3511,20 @@ function useEvent(event, callback, eventBus) {
|
|
|
3290
3511
|
}, [callback, event, eventBus]);
|
|
3291
3512
|
}
|
|
3292
3513
|
|
|
3293
|
-
/**
|
|
3294
|
-
* Creates a state that persists in the global LayoutContext.
|
|
3295
|
-
*
|
|
3296
|
-
* @example
|
|
3297
|
-
* ```jsx
|
|
3298
|
-
* function Group(props) {
|
|
3299
|
-
* const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
|
|
3300
|
-
* }
|
|
3301
|
-
* ```
|
|
3302
|
-
*
|
|
3303
|
-
* @param {(string|number)[]} path
|
|
3304
|
-
* @param {any} [defaultValue]
|
|
3305
|
-
*
|
|
3306
|
-
* @returns {[ any, Function ]}
|
|
3514
|
+
/**
|
|
3515
|
+
* Creates a state that persists in the global LayoutContext.
|
|
3516
|
+
*
|
|
3517
|
+
* @example
|
|
3518
|
+
* ```jsx
|
|
3519
|
+
* function Group(props) {
|
|
3520
|
+
* const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
|
|
3521
|
+
* }
|
|
3522
|
+
* ```
|
|
3523
|
+
*
|
|
3524
|
+
* @param {(string|number)[]} path
|
|
3525
|
+
* @param {any} [defaultValue]
|
|
3526
|
+
*
|
|
3527
|
+
* @returns {[ any, Function ]}
|
|
3307
3528
|
*/
|
|
3308
3529
|
function useLayoutState(path, defaultValue) {
|
|
3309
3530
|
const {
|
|
@@ -3322,11 +3543,11 @@ function useLayoutState(path, defaultValue) {
|
|
|
3322
3543
|
return [value, setState];
|
|
3323
3544
|
}
|
|
3324
3545
|
|
|
3325
|
-
/**
|
|
3326
|
-
* @pinussilvestrus: we need to introduce our own hook to persist the previous
|
|
3327
|
-
* state on updates.
|
|
3328
|
-
*
|
|
3329
|
-
* cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
|
|
3546
|
+
/**
|
|
3547
|
+
* @pinussilvestrus: we need to introduce our own hook to persist the previous
|
|
3548
|
+
* state on updates.
|
|
3549
|
+
*
|
|
3550
|
+
* cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
|
|
3330
3551
|
*/
|
|
3331
3552
|
|
|
3332
3553
|
function usePrevious(value) {
|
|
@@ -3337,12 +3558,12 @@ function usePrevious(value) {
|
|
|
3337
3558
|
return ref.current;
|
|
3338
3559
|
}
|
|
3339
3560
|
|
|
3340
|
-
/**
|
|
3341
|
-
* Subscribe to `propertiesPanel.showEntry`.
|
|
3342
|
-
*
|
|
3343
|
-
* @param {string} id
|
|
3344
|
-
*
|
|
3345
|
-
* @returns {import('preact').Ref}
|
|
3561
|
+
/**
|
|
3562
|
+
* Subscribe to `propertiesPanel.showEntry`.
|
|
3563
|
+
*
|
|
3564
|
+
* @param {string} id
|
|
3565
|
+
*
|
|
3566
|
+
* @returns {import('preact').Ref}
|
|
3346
3567
|
*/
|
|
3347
3568
|
function useShowEntryEvent(id) {
|
|
3348
3569
|
const {
|
|
@@ -3373,20 +3594,20 @@ function useShowEntryEvent(id) {
|
|
|
3373
3594
|
return ref;
|
|
3374
3595
|
}
|
|
3375
3596
|
|
|
3376
|
-
/**
|
|
3377
|
-
* @callback setSticky
|
|
3378
|
-
* @param {boolean} value
|
|
3597
|
+
/**
|
|
3598
|
+
* @callback setSticky
|
|
3599
|
+
* @param {boolean} value
|
|
3379
3600
|
*/
|
|
3380
3601
|
|
|
3381
|
-
/**
|
|
3382
|
-
* Use IntersectionObserver to identify when DOM element is in sticky mode.
|
|
3383
|
-
* If sticky is observered setSticky(true) will be called.
|
|
3384
|
-
* If sticky mode is left, setSticky(false) will be called.
|
|
3385
|
-
*
|
|
3386
|
-
*
|
|
3387
|
-
* @param {Object} ref
|
|
3388
|
-
* @param {string} scrollContainerSelector
|
|
3389
|
-
* @param {setSticky} setSticky
|
|
3602
|
+
/**
|
|
3603
|
+
* Use IntersectionObserver to identify when DOM element is in sticky mode.
|
|
3604
|
+
* If sticky is observered setSticky(true) will be called.
|
|
3605
|
+
* If sticky mode is left, setSticky(false) will be called.
|
|
3606
|
+
*
|
|
3607
|
+
*
|
|
3608
|
+
* @param {Object} ref
|
|
3609
|
+
* @param {string} scrollContainerSelector
|
|
3610
|
+
* @param {setSticky} setSticky
|
|
3390
3611
|
*/
|
|
3391
3612
|
function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky) {
|
|
3392
3613
|
hooks$1.useEffect(() => {
|
|
@@ -3425,19 +3646,19 @@ function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky)
|
|
|
3425
3646
|
}, [ref, scrollContainerSelector, setSticky]);
|
|
3426
3647
|
}
|
|
3427
3648
|
|
|
3428
|
-
/**
|
|
3429
|
-
* Creates a static function reference with changing body.
|
|
3430
|
-
* This is necessary when external libraries require a callback function
|
|
3431
|
-
* that has references to state variables.
|
|
3432
|
-
*
|
|
3433
|
-
* Usage:
|
|
3434
|
-
* const callback = useStaticCallback((val) => {val === currentState});
|
|
3435
|
-
*
|
|
3436
|
-
* The `callback` reference is static and can be safely used in external
|
|
3437
|
-
* libraries or as a prop that does not cause rerendering of children.
|
|
3438
|
-
*
|
|
3439
|
-
* @param {Function} callback function with changing reference
|
|
3440
|
-
* @returns {Function} static function reference
|
|
3649
|
+
/**
|
|
3650
|
+
* Creates a static function reference with changing body.
|
|
3651
|
+
* This is necessary when external libraries require a callback function
|
|
3652
|
+
* that has references to state variables.
|
|
3653
|
+
*
|
|
3654
|
+
* Usage:
|
|
3655
|
+
* const callback = useStaticCallback((val) => {val === currentState});
|
|
3656
|
+
*
|
|
3657
|
+
* The `callback` reference is static and can be safely used in external
|
|
3658
|
+
* libraries or as a prop that does not cause rerendering of children.
|
|
3659
|
+
*
|
|
3660
|
+
* @param {Function} callback function with changing reference
|
|
3661
|
+
* @returns {Function} static function reference
|
|
3441
3662
|
*/
|
|
3442
3663
|
function useStaticCallback(callback) {
|
|
3443
3664
|
const callbackRef = hooks$1.useRef(callback);
|
|
@@ -3487,7 +3708,7 @@ function Group(props) {
|
|
|
3487
3708
|
"data-group-id": 'group-' + id,
|
|
3488
3709
|
ref: groupRef,
|
|
3489
3710
|
children: [jsxRuntime.jsxs("div", {
|
|
3490
|
-
class:
|
|
3711
|
+
class: classnames('bio-properties-panel-group-header', edited ? '' : 'empty', open ? 'open' : '', sticky && open ? 'sticky' : ''),
|
|
3491
3712
|
onClick: toggleOpen,
|
|
3492
3713
|
children: [jsxRuntime.jsx("div", {
|
|
3493
3714
|
title: label,
|
|
@@ -3504,7 +3725,7 @@ function Group(props) {
|
|
|
3504
3725
|
})]
|
|
3505
3726
|
})]
|
|
3506
3727
|
}), jsxRuntime.jsx("div", {
|
|
3507
|
-
class:
|
|
3728
|
+
class: classnames('bio-properties-panel-group-entries', open ? 'open' : ''),
|
|
3508
3729
|
children: jsxRuntime.jsx(LayoutContext.Provider, {
|
|
3509
3730
|
value: propertiesPanelContext,
|
|
3510
3731
|
children: entries.map(entry => {
|
|
@@ -3529,13 +3750,13 @@ function DataMarker() {
|
|
|
3529
3750
|
});
|
|
3530
3751
|
}
|
|
3531
3752
|
|
|
3532
|
-
/**
|
|
3533
|
-
* @typedef { {
|
|
3534
|
-
* text: (element: object) => string,
|
|
3535
|
-
* icon?: (element: Object) => import('preact').Component
|
|
3536
|
-
* } } PlaceholderDefinition
|
|
3537
|
-
*
|
|
3538
|
-
* @param { PlaceholderDefinition } props
|
|
3753
|
+
/**
|
|
3754
|
+
* @typedef { {
|
|
3755
|
+
* text: (element: object) => string,
|
|
3756
|
+
* icon?: (element: Object) => import('preact').Component
|
|
3757
|
+
* } } PlaceholderDefinition
|
|
3758
|
+
*
|
|
3759
|
+
* @param { PlaceholderDefinition } props
|
|
3539
3760
|
*/
|
|
3540
3761
|
function Placeholder(props) {
|
|
3541
3762
|
const {
|
|
@@ -3560,72 +3781,72 @@ const DEFAULT_LAYOUT = {
|
|
|
3560
3781
|
};
|
|
3561
3782
|
const DEFAULT_DESCRIPTION = {};
|
|
3562
3783
|
|
|
3563
|
-
/**
|
|
3564
|
-
* @typedef { {
|
|
3565
|
-
* component: import('preact').Component,
|
|
3566
|
-
* id: String,
|
|
3567
|
-
* isEdited?: Function
|
|
3568
|
-
* } } EntryDefinition
|
|
3569
|
-
*
|
|
3570
|
-
* @typedef { {
|
|
3571
|
-
* autoFocusEntry: String,
|
|
3572
|
-
* autoOpen?: Boolean,
|
|
3573
|
-
* entries: Array<EntryDefinition>,
|
|
3574
|
-
* id: String,
|
|
3575
|
-
* label: String,
|
|
3576
|
-
* remove: (event: MouseEvent) => void
|
|
3577
|
-
* } } ListItemDefinition
|
|
3578
|
-
*
|
|
3579
|
-
* @typedef { {
|
|
3580
|
-
* add: (event: MouseEvent) => void,
|
|
3581
|
-
* component: import('preact').Component,
|
|
3582
|
-
* element: Object,
|
|
3583
|
-
* id: String,
|
|
3584
|
-
* items: Array<ListItemDefinition>,
|
|
3585
|
-
* label: String,
|
|
3586
|
-
* shouldSort?: Boolean,
|
|
3587
|
-
* shouldOpen?: Boolean
|
|
3588
|
-
* } } ListGroupDefinition
|
|
3589
|
-
*
|
|
3590
|
-
* @typedef { {
|
|
3591
|
-
* component?: import('preact').Component,
|
|
3592
|
-
* entries: Array<EntryDefinition>,
|
|
3593
|
-
* id: String,
|
|
3594
|
-
* label: String,
|
|
3595
|
-
* shouldOpen?: Boolean
|
|
3596
|
-
* } } GroupDefinition
|
|
3597
|
-
*
|
|
3598
|
-
* @typedef { {
|
|
3599
|
-
* [id: String]: GetDescriptionFunction
|
|
3600
|
-
* } } DescriptionConfig
|
|
3601
|
-
*
|
|
3602
|
-
* @callback { {
|
|
3603
|
-
* @param {string} id
|
|
3604
|
-
* @param {Object} element
|
|
3605
|
-
* @returns {string}
|
|
3606
|
-
* } } GetDescriptionFunction
|
|
3607
|
-
*
|
|
3608
|
-
* @typedef { {
|
|
3609
|
-
* getEmpty: (element: object) => import('./components/Placeholder').PlaceholderDefinition,
|
|
3610
|
-
* getMultiple: (element: Object) => import('./components/Placeholder').PlaceholderDefinition
|
|
3611
|
-
* } } PlaceholderProvider
|
|
3612
|
-
*
|
|
3784
|
+
/**
|
|
3785
|
+
* @typedef { {
|
|
3786
|
+
* component: import('preact').Component,
|
|
3787
|
+
* id: String,
|
|
3788
|
+
* isEdited?: Function
|
|
3789
|
+
* } } EntryDefinition
|
|
3790
|
+
*
|
|
3791
|
+
* @typedef { {
|
|
3792
|
+
* autoFocusEntry: String,
|
|
3793
|
+
* autoOpen?: Boolean,
|
|
3794
|
+
* entries: Array<EntryDefinition>,
|
|
3795
|
+
* id: String,
|
|
3796
|
+
* label: String,
|
|
3797
|
+
* remove: (event: MouseEvent) => void
|
|
3798
|
+
* } } ListItemDefinition
|
|
3799
|
+
*
|
|
3800
|
+
* @typedef { {
|
|
3801
|
+
* add: (event: MouseEvent) => void,
|
|
3802
|
+
* component: import('preact').Component,
|
|
3803
|
+
* element: Object,
|
|
3804
|
+
* id: String,
|
|
3805
|
+
* items: Array<ListItemDefinition>,
|
|
3806
|
+
* label: String,
|
|
3807
|
+
* shouldSort?: Boolean,
|
|
3808
|
+
* shouldOpen?: Boolean
|
|
3809
|
+
* } } ListGroupDefinition
|
|
3810
|
+
*
|
|
3811
|
+
* @typedef { {
|
|
3812
|
+
* component?: import('preact').Component,
|
|
3813
|
+
* entries: Array<EntryDefinition>,
|
|
3814
|
+
* id: String,
|
|
3815
|
+
* label: String,
|
|
3816
|
+
* shouldOpen?: Boolean
|
|
3817
|
+
* } } GroupDefinition
|
|
3818
|
+
*
|
|
3819
|
+
* @typedef { {
|
|
3820
|
+
* [id: String]: GetDescriptionFunction
|
|
3821
|
+
* } } DescriptionConfig
|
|
3822
|
+
*
|
|
3823
|
+
* @callback { {
|
|
3824
|
+
* @param {string} id
|
|
3825
|
+
* @param {Object} element
|
|
3826
|
+
* @returns {string}
|
|
3827
|
+
* } } GetDescriptionFunction
|
|
3828
|
+
*
|
|
3829
|
+
* @typedef { {
|
|
3830
|
+
* getEmpty: (element: object) => import('./components/Placeholder').PlaceholderDefinition,
|
|
3831
|
+
* getMultiple: (element: Object) => import('./components/Placeholder').PlaceholderDefinition
|
|
3832
|
+
* } } PlaceholderProvider
|
|
3833
|
+
*
|
|
3613
3834
|
*/
|
|
3614
3835
|
|
|
3615
|
-
/**
|
|
3616
|
-
* A basic properties panel component. Describes *how* content will be rendered, accepts
|
|
3617
|
-
* data from implementor to describe *what* will be rendered.
|
|
3618
|
-
*
|
|
3619
|
-
* @param {Object} props
|
|
3620
|
-
* @param {Object|Array} props.element
|
|
3621
|
-
* @param {import('./components/Header').HeaderProvider} props.headerProvider
|
|
3622
|
-
* @param {PlaceholderProvider} [props.placeholderProvider]
|
|
3623
|
-
* @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
|
|
3624
|
-
* @param {Object} [props.layoutConfig]
|
|
3625
|
-
* @param {Function} [props.layoutChanged]
|
|
3626
|
-
* @param {DescriptionConfig} [props.descriptionConfig]
|
|
3627
|
-
* @param {Function} [props.descriptionLoaded]
|
|
3628
|
-
* @param {Object} [props.eventBus]
|
|
3836
|
+
/**
|
|
3837
|
+
* A basic properties panel component. Describes *how* content will be rendered, accepts
|
|
3838
|
+
* data from implementor to describe *what* will be rendered.
|
|
3839
|
+
*
|
|
3840
|
+
* @param {Object} props
|
|
3841
|
+
* @param {Object|Array} props.element
|
|
3842
|
+
* @param {import('./components/Header').HeaderProvider} props.headerProvider
|
|
3843
|
+
* @param {PlaceholderProvider} [props.placeholderProvider]
|
|
3844
|
+
* @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
|
|
3845
|
+
* @param {Object} [props.layoutConfig]
|
|
3846
|
+
* @param {Function} [props.layoutChanged]
|
|
3847
|
+
* @param {DescriptionConfig} [props.descriptionConfig]
|
|
3848
|
+
* @param {Function} [props.descriptionLoaded]
|
|
3849
|
+
* @param {Object} [props.eventBus]
|
|
3629
3850
|
*/
|
|
3630
3851
|
function PropertiesPanel(props) {
|
|
3631
3852
|
const {
|
|
@@ -3713,7 +3934,7 @@ function PropertiesPanel(props) {
|
|
|
3713
3934
|
children: jsxRuntime.jsx(EventContext.Provider, {
|
|
3714
3935
|
value: eventContext,
|
|
3715
3936
|
children: jsxRuntime.jsxs("div", {
|
|
3716
|
-
class:
|
|
3937
|
+
class: classnames('bio-properties-panel', layout.open ? 'open' : ''),
|
|
3717
3938
|
children: [jsxRuntime.jsx(Header, {
|
|
3718
3939
|
element: element,
|
|
3719
3940
|
headerProvider: headerProvider
|
|
@@ -3781,13 +4002,13 @@ function CollapsibleEntry(props) {
|
|
|
3781
4002
|
const placeholderLabel = '<empty>';
|
|
3782
4003
|
return jsxRuntime.jsxs("div", {
|
|
3783
4004
|
"data-entry-id": id,
|
|
3784
|
-
class:
|
|
4005
|
+
class: classnames('bio-properties-panel-collapsible-entry', open ? 'open' : ''),
|
|
3785
4006
|
children: [jsxRuntime.jsxs("div", {
|
|
3786
4007
|
class: "bio-properties-panel-collapsible-entry-header",
|
|
3787
4008
|
onClick: toggleOpen,
|
|
3788
4009
|
children: [jsxRuntime.jsx("div", {
|
|
3789
4010
|
title: label || placeholderLabel,
|
|
3790
|
-
class:
|
|
4011
|
+
class: classnames('bio-properties-panel-collapsible-entry-header-title', !label && 'empty'),
|
|
3791
4012
|
children: label || placeholderLabel
|
|
3792
4013
|
}), jsxRuntime.jsx("button", {
|
|
3793
4014
|
title: "Toggle list item",
|
|
@@ -3802,7 +4023,7 @@ function CollapsibleEntry(props) {
|
|
|
3802
4023
|
children: jsxRuntime.jsx(DeleteIcon, {})
|
|
3803
4024
|
}) : null]
|
|
3804
4025
|
}), jsxRuntime.jsx("div", {
|
|
3805
|
-
class:
|
|
4026
|
+
class: classnames('bio-properties-panel-collapsible-entry-entries', open ? 'open' : ''),
|
|
3806
4027
|
children: jsxRuntime.jsx(LayoutContext.Provider, {
|
|
3807
4028
|
value: propertiesPanelContext,
|
|
3808
4029
|
children: entries.map(entry => {
|
|
@@ -3850,8 +4071,8 @@ function ListItem(props) {
|
|
|
3850
4071
|
}
|
|
3851
4072
|
const noop$2 = () => {};
|
|
3852
4073
|
|
|
3853
|
-
/**
|
|
3854
|
-
* @param {import('../PropertiesPanel').ListGroupDefinition} props
|
|
4074
|
+
/**
|
|
4075
|
+
* @param {import('../PropertiesPanel').ListGroupDefinition} props
|
|
3855
4076
|
*/
|
|
3856
4077
|
function ListGroup(props) {
|
|
3857
4078
|
const {
|
|
@@ -3956,7 +4177,7 @@ function ListGroup(props) {
|
|
|
3956
4177
|
"data-group-id": 'group-' + id,
|
|
3957
4178
|
ref: groupRef,
|
|
3958
4179
|
children: [jsxRuntime.jsxs("div", {
|
|
3959
|
-
class:
|
|
4180
|
+
class: classnames('bio-properties-panel-group-header', hasItems ? '' : 'empty', hasItems && open ? 'open' : '', sticky && open ? 'sticky' : ''),
|
|
3960
4181
|
onClick: hasItems ? toggleOpen : noop$2,
|
|
3961
4182
|
children: [jsxRuntime.jsx("div", {
|
|
3962
4183
|
title: label,
|
|
@@ -3985,7 +4206,7 @@ function ListGroup(props) {
|
|
|
3985
4206
|
}) : null]
|
|
3986
4207
|
})]
|
|
3987
4208
|
}), jsxRuntime.jsx("div", {
|
|
3988
|
-
class:
|
|
4209
|
+
class: classnames('bio-properties-panel-list', open && hasItems ? 'open' : ''),
|
|
3989
4210
|
children: jsxRuntime.jsx(LayoutContext.Provider, {
|
|
3990
4211
|
value: propertiesPanelContext,
|
|
3991
4212
|
children: ordering.map((o, index) => {
|
|
@@ -4014,8 +4235,8 @@ function ListGroup(props) {
|
|
|
4014
4235
|
|
|
4015
4236
|
// helpers ////////////////////
|
|
4016
4237
|
|
|
4017
|
-
/**
|
|
4018
|
-
* Sorts given items alphanumeric by label
|
|
4238
|
+
/**
|
|
4239
|
+
* Sorts given items alphanumeric by label
|
|
4019
4240
|
*/
|
|
4020
4241
|
function sortItems(items) {
|
|
4021
4242
|
return minDash.sortBy(items, i => i.label.toLowerCase());
|
|
@@ -4089,17 +4310,17 @@ function Checkbox(props) {
|
|
|
4089
4310
|
});
|
|
4090
4311
|
}
|
|
4091
4312
|
|
|
4092
|
-
/**
|
|
4093
|
-
* @param {Object} props
|
|
4094
|
-
* @param {Object} props.element
|
|
4095
|
-
* @param {String} props.id
|
|
4096
|
-
* @param {String} props.description
|
|
4097
|
-
* @param {String} props.label
|
|
4098
|
-
* @param {Function} props.getValue
|
|
4099
|
-
* @param {Function} props.setValue
|
|
4100
|
-
* @param {Function} props.onFocus
|
|
4101
|
-
* @param {Function} props.onBlur
|
|
4102
|
-
* @param {boolean} [props.disabled]
|
|
4313
|
+
/**
|
|
4314
|
+
* @param {Object} props
|
|
4315
|
+
* @param {Object} props.element
|
|
4316
|
+
* @param {String} props.id
|
|
4317
|
+
* @param {String} props.description
|
|
4318
|
+
* @param {String} props.label
|
|
4319
|
+
* @param {Function} props.getValue
|
|
4320
|
+
* @param {Function} props.setValue
|
|
4321
|
+
* @param {Function} props.onFocus
|
|
4322
|
+
* @param {Function} props.onBlur
|
|
4323
|
+
* @param {boolean} [props.disabled]
|
|
4103
4324
|
*/
|
|
4104
4325
|
function CheckboxEntry(props) {
|
|
4105
4326
|
const {
|
|
@@ -4187,10 +4408,10 @@ const CodeEditor = React.forwardRef((props, ref) => {
|
|
|
4187
4408
|
hooks$1.useEffect(() => {
|
|
4188
4409
|
let editor;
|
|
4189
4410
|
|
|
4190
|
-
/* Trigger FEEL toggle when
|
|
4191
|
-
*
|
|
4192
|
-
* - `backspace` is pressed
|
|
4193
|
-
* - AND the cursor is at the beginning of the input
|
|
4411
|
+
/* Trigger FEEL toggle when
|
|
4412
|
+
*
|
|
4413
|
+
* - `backspace` is pressed
|
|
4414
|
+
* - AND the cursor is at the beginning of the input
|
|
4194
4415
|
*/
|
|
4195
4416
|
const onKeyDown = e => {
|
|
4196
4417
|
if (e.key !== 'Backspace' || !editor) {
|
|
@@ -4202,7 +4423,7 @@ const CodeEditor = React.forwardRef((props, ref) => {
|
|
|
4202
4423
|
onFeelToggle();
|
|
4203
4424
|
}
|
|
4204
4425
|
};
|
|
4205
|
-
editor = new
|
|
4426
|
+
editor = new FeelEditor({
|
|
4206
4427
|
container: inputRef.current,
|
|
4207
4428
|
onChange: handleInput,
|
|
4208
4429
|
onKeyDown: onKeyDown,
|
|
@@ -4238,10 +4459,10 @@ const CodeEditor = React.forwardRef((props, ref) => {
|
|
|
4238
4459
|
ref.current.focus();
|
|
4239
4460
|
};
|
|
4240
4461
|
return jsxRuntime.jsx("div", {
|
|
4241
|
-
class:
|
|
4462
|
+
class: classnames('bio-properties-panel-feel-editor-container', disabled ? 'disabled' : null),
|
|
4242
4463
|
children: jsxRuntime.jsx("div", {
|
|
4243
4464
|
name: props.name,
|
|
4244
|
-
class:
|
|
4465
|
+
class: classnames('bio-properties-panel-input', localValue ? 'edited' : null),
|
|
4245
4466
|
ref: inputRef,
|
|
4246
4467
|
onClick: handleClick
|
|
4247
4468
|
})
|
|
@@ -4261,10 +4482,10 @@ function FeelIndicator(props) {
|
|
|
4261
4482
|
}
|
|
4262
4483
|
const noop$1 = () => {};
|
|
4263
4484
|
|
|
4264
|
-
/**
|
|
4265
|
-
* @param {Object} props
|
|
4266
|
-
* @param {Object} props.label
|
|
4267
|
-
* @param {String} props.feel
|
|
4485
|
+
/**
|
|
4486
|
+
* @param {Object} props
|
|
4487
|
+
* @param {Object} props.label
|
|
4488
|
+
* @param {String} props.feel
|
|
4268
4489
|
*/
|
|
4269
4490
|
function FeelIcon(props) {
|
|
4270
4491
|
const {
|
|
@@ -4285,7 +4506,7 @@ function FeelIcon(props) {
|
|
|
4285
4506
|
}
|
|
4286
4507
|
};
|
|
4287
4508
|
return jsxRuntime.jsx("button", {
|
|
4288
|
-
class:
|
|
4509
|
+
class: classnames('bio-properties-panel-feel-icon', active ? 'active' : null, feel === 'required' ? 'required' : 'optional'),
|
|
4289
4510
|
onClick: handleClick,
|
|
4290
4511
|
disabled: feel === 'required' || disabled,
|
|
4291
4512
|
title: label + (feel === 'required' ? feelRequiredLabel : feelOptionalLabel),
|
|
@@ -4538,17 +4759,17 @@ const OptionalFeelTextArea = React.forwardRef((props, ref) => {
|
|
|
4538
4759
|
});
|
|
4539
4760
|
});
|
|
4540
4761
|
|
|
4541
|
-
/**
|
|
4542
|
-
* @param {Object} props
|
|
4543
|
-
* @param {Object} props.element
|
|
4544
|
-
* @param {String} props.id
|
|
4545
|
-
* @param {String} props.description
|
|
4546
|
-
* @param {Boolean} props.debounce
|
|
4547
|
-
* @param {Boolean} props.disabled
|
|
4548
|
-
* @param {String} props.label
|
|
4549
|
-
* @param {Function} props.getValue
|
|
4550
|
-
* @param {Function} props.setValue
|
|
4551
|
-
* @param {Function} props.validate
|
|
4762
|
+
/**
|
|
4763
|
+
* @param {Object} props
|
|
4764
|
+
* @param {Object} props.element
|
|
4765
|
+
* @param {String} props.id
|
|
4766
|
+
* @param {String} props.description
|
|
4767
|
+
* @param {Boolean} props.debounce
|
|
4768
|
+
* @param {Boolean} props.disabled
|
|
4769
|
+
* @param {String} props.label
|
|
4770
|
+
* @param {Function} props.getValue
|
|
4771
|
+
* @param {Function} props.setValue
|
|
4772
|
+
* @param {Function} props.validate
|
|
4552
4773
|
*/
|
|
4553
4774
|
function FeelEntry(props) {
|
|
4554
4775
|
const {
|
|
@@ -4604,7 +4825,7 @@ function FeelEntry(props) {
|
|
|
4604
4825
|
const temporaryError = useError(id);
|
|
4605
4826
|
const error = localError || temporaryError || validationError;
|
|
4606
4827
|
return jsxRuntime.jsxs("div", {
|
|
4607
|
-
class:
|
|
4828
|
+
class: classnames(props.class, 'bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
4608
4829
|
"data-entry-id": id,
|
|
4609
4830
|
children: [jsxRuntime.jsx(FeelTextfield, {
|
|
4610
4831
|
debounce: debounce,
|
|
@@ -4633,19 +4854,19 @@ function FeelEntry(props) {
|
|
|
4633
4854
|
});
|
|
4634
4855
|
}
|
|
4635
4856
|
|
|
4636
|
-
/**
|
|
4637
|
-
* @param {Object} props
|
|
4638
|
-
* @param {Object} props.element
|
|
4639
|
-
* @param {String} props.id
|
|
4640
|
-
* @param {String} props.description
|
|
4641
|
-
* @param {Boolean} props.debounce
|
|
4642
|
-
* @param {Boolean} props.disabled
|
|
4643
|
-
* @param {String} props.label
|
|
4644
|
-
* @param {Function} props.getValue
|
|
4645
|
-
* @param {Function} props.setValue
|
|
4646
|
-
* @param {Function} props.onFocus
|
|
4647
|
-
* @param {Function} props.onBlur
|
|
4648
|
-
* @param {Function} props.validate
|
|
4857
|
+
/**
|
|
4858
|
+
* @param {Object} props
|
|
4859
|
+
* @param {Object} props.element
|
|
4860
|
+
* @param {String} props.id
|
|
4861
|
+
* @param {String} props.description
|
|
4862
|
+
* @param {Boolean} props.debounce
|
|
4863
|
+
* @param {Boolean} props.disabled
|
|
4864
|
+
* @param {String} props.label
|
|
4865
|
+
* @param {Function} props.getValue
|
|
4866
|
+
* @param {Function} props.setValue
|
|
4867
|
+
* @param {Function} props.onFocus
|
|
4868
|
+
* @param {Function} props.onBlur
|
|
4869
|
+
* @param {Function} props.validate
|
|
4649
4870
|
*/
|
|
4650
4871
|
function FeelTextArea(props) {
|
|
4651
4872
|
return jsxRuntime.jsx(FeelEntry, {
|
|
@@ -4724,21 +4945,22 @@ function NumberField(props) {
|
|
|
4724
4945
|
});
|
|
4725
4946
|
}
|
|
4726
4947
|
|
|
4727
|
-
/**
|
|
4728
|
-
* @param {Object} props
|
|
4729
|
-
* @param {Boolean} props.debounce
|
|
4730
|
-
* @param {String} props.description
|
|
4731
|
-
* @param {Boolean} props.disabled
|
|
4732
|
-
* @param {Object} props.element
|
|
4733
|
-
* @param {Function} props.getValue
|
|
4734
|
-
* @param {String} props.id
|
|
4735
|
-
* @param {String} props.label
|
|
4736
|
-
* @param {String} props.max
|
|
4737
|
-
* @param {String} props.min
|
|
4738
|
-
* @param {Function} props.setValue
|
|
4739
|
-
* @param {Function} props.onFocus
|
|
4740
|
-
* @param {Function} props.onBlur
|
|
4741
|
-
* @param {String} props.step
|
|
4948
|
+
/**
|
|
4949
|
+
* @param {Object} props
|
|
4950
|
+
* @param {Boolean} props.debounce
|
|
4951
|
+
* @param {String} props.description
|
|
4952
|
+
* @param {Boolean} props.disabled
|
|
4953
|
+
* @param {Object} props.element
|
|
4954
|
+
* @param {Function} props.getValue
|
|
4955
|
+
* @param {String} props.id
|
|
4956
|
+
* @param {String} props.label
|
|
4957
|
+
* @param {String} props.max
|
|
4958
|
+
* @param {String} props.min
|
|
4959
|
+
* @param {Function} props.setValue
|
|
4960
|
+
* @param {Function} props.onFocus
|
|
4961
|
+
* @param {Function} props.onBlur
|
|
4962
|
+
* @param {String} props.step
|
|
4963
|
+
* @param {Function} props.validate
|
|
4742
4964
|
*/
|
|
4743
4965
|
function NumberFieldEntry(props) {
|
|
4744
4966
|
const {
|
|
@@ -4754,25 +4976,55 @@ function NumberFieldEntry(props) {
|
|
|
4754
4976
|
setValue,
|
|
4755
4977
|
step,
|
|
4756
4978
|
onFocus,
|
|
4757
|
-
onBlur
|
|
4979
|
+
onBlur,
|
|
4980
|
+
validate
|
|
4758
4981
|
} = props;
|
|
4759
|
-
const
|
|
4982
|
+
const [cachedInvalidValue, setCachedInvalidValue] = hooks$1.useState(null);
|
|
4983
|
+
const globalError = useError(id);
|
|
4984
|
+
const [localError, setLocalError] = hooks$1.useState(null);
|
|
4985
|
+
let value = getValue(element);
|
|
4986
|
+
const previousValue = usePrevious(value);
|
|
4987
|
+
hooks$1.useEffect(() => {
|
|
4988
|
+
if (minDash.isFunction(validate)) {
|
|
4989
|
+
const newValidationError = validate(value) || null;
|
|
4990
|
+
setLocalError(newValidationError);
|
|
4991
|
+
}
|
|
4992
|
+
}, [value]);
|
|
4993
|
+
const onInput = newValue => {
|
|
4994
|
+
let newValidationError = null;
|
|
4995
|
+
if (minDash.isFunction(validate)) {
|
|
4996
|
+
newValidationError = validate(newValue) || null;
|
|
4997
|
+
}
|
|
4998
|
+
if (newValidationError) {
|
|
4999
|
+
setCachedInvalidValue(newValue);
|
|
5000
|
+
} else {
|
|
5001
|
+
setValue(newValue);
|
|
5002
|
+
}
|
|
5003
|
+
setLocalError(newValidationError);
|
|
5004
|
+
};
|
|
5005
|
+
if (previousValue === value && localError) {
|
|
5006
|
+
value = cachedInvalidValue;
|
|
5007
|
+
}
|
|
5008
|
+
const error = globalError || localError;
|
|
4760
5009
|
return jsxRuntime.jsxs("div", {
|
|
4761
|
-
class:
|
|
5010
|
+
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
4762
5011
|
"data-entry-id": id,
|
|
4763
5012
|
children: [jsxRuntime.jsx(NumberField, {
|
|
4764
5013
|
debounce: debounce,
|
|
4765
5014
|
disabled: disabled,
|
|
4766
5015
|
id: id,
|
|
4767
5016
|
label: label,
|
|
4768
|
-
onInput: setValue,
|
|
4769
5017
|
onFocus: onFocus,
|
|
4770
5018
|
onBlur: onBlur,
|
|
5019
|
+
onInput: onInput,
|
|
4771
5020
|
max: max,
|
|
4772
5021
|
min: min,
|
|
4773
5022
|
step: step,
|
|
4774
5023
|
value: value
|
|
4775
|
-
}, element), jsxRuntime.jsx(
|
|
5024
|
+
}, element), error && jsxRuntime.jsx("div", {
|
|
5025
|
+
class: "bio-properties-panel-error",
|
|
5026
|
+
children: error
|
|
5027
|
+
}), jsxRuntime.jsx(Description$1, {
|
|
4776
5028
|
forId: id,
|
|
4777
5029
|
element: element,
|
|
4778
5030
|
value: description
|
|
@@ -4794,7 +5046,7 @@ function Select(props) {
|
|
|
4794
5046
|
label,
|
|
4795
5047
|
onChange,
|
|
4796
5048
|
options = [],
|
|
4797
|
-
value,
|
|
5049
|
+
value = '',
|
|
4798
5050
|
disabled,
|
|
4799
5051
|
onFocus,
|
|
4800
5052
|
onBlur
|
|
@@ -4843,18 +5095,18 @@ function Select(props) {
|
|
|
4843
5095
|
});
|
|
4844
5096
|
}
|
|
4845
5097
|
|
|
4846
|
-
/**
|
|
4847
|
-
* @param {object} props
|
|
4848
|
-
* @param {object} props.element
|
|
4849
|
-
* @param {string} props.id
|
|
4850
|
-
* @param {string} [props.description]
|
|
4851
|
-
* @param {string} props.label
|
|
4852
|
-
* @param {Function} props.getValue
|
|
4853
|
-
* @param {Function} props.setValue
|
|
4854
|
-
* @param {Function} props.onFocus
|
|
4855
|
-
* @param {Function} props.onBlur
|
|
4856
|
-
* @param {Function} props.getOptions
|
|
4857
|
-
* @param {boolean} [props.disabled]
|
|
5098
|
+
/**
|
|
5099
|
+
* @param {object} props
|
|
5100
|
+
* @param {object} props.element
|
|
5101
|
+
* @param {string} props.id
|
|
5102
|
+
* @param {string} [props.description]
|
|
5103
|
+
* @param {string} props.label
|
|
5104
|
+
* @param {Function} props.getValue
|
|
5105
|
+
* @param {Function} props.setValue
|
|
5106
|
+
* @param {Function} props.onFocus
|
|
5107
|
+
* @param {Function} props.onBlur
|
|
5108
|
+
* @param {Function} props.getOptions
|
|
5109
|
+
* @param {boolean} [props.disabled]
|
|
4858
5110
|
*/
|
|
4859
5111
|
function SelectEntry(props) {
|
|
4860
5112
|
const {
|
|
@@ -4873,7 +5125,7 @@ function SelectEntry(props) {
|
|
|
4873
5125
|
const options = getOptions(element);
|
|
4874
5126
|
const error = useError(id);
|
|
4875
5127
|
return jsxRuntime.jsxs("div", {
|
|
4876
|
-
class:
|
|
5128
|
+
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
4877
5129
|
"data-entry-id": id,
|
|
4878
5130
|
children: [jsxRuntime.jsx(Select, {
|
|
4879
5131
|
id: id,
|
|
@@ -4944,7 +5196,7 @@ function TextArea(props) {
|
|
|
4944
5196
|
id: prefixId$2(id),
|
|
4945
5197
|
name: id,
|
|
4946
5198
|
spellCheck: "false",
|
|
4947
|
-
class:
|
|
5199
|
+
class: classnames('bio-properties-panel-input', monospace ? 'bio-properties-panel-input-monospace' : ''),
|
|
4948
5200
|
onInput: handleInput,
|
|
4949
5201
|
onFocus: onFocus,
|
|
4950
5202
|
onBlur: onBlur,
|
|
@@ -4956,20 +5208,20 @@ function TextArea(props) {
|
|
|
4956
5208
|
});
|
|
4957
5209
|
}
|
|
4958
5210
|
|
|
4959
|
-
/**
|
|
4960
|
-
* @param {object} props
|
|
4961
|
-
* @param {object} props.element
|
|
4962
|
-
* @param {string} props.id
|
|
4963
|
-
* @param {string} props.description
|
|
4964
|
-
* @param {boolean} props.debounce
|
|
4965
|
-
* @param {string} props.label
|
|
4966
|
-
* @param {Function} props.getValue
|
|
4967
|
-
* @param {Function} props.setValue
|
|
4968
|
-
* @param {Function} props.onFocus
|
|
4969
|
-
* @param {Function} props.onBlur
|
|
4970
|
-
* @param {number} props.rows
|
|
4971
|
-
* @param {boolean} props.monospace
|
|
4972
|
-
* @param {boolean} [props.disabled]
|
|
5211
|
+
/**
|
|
5212
|
+
* @param {object} props
|
|
5213
|
+
* @param {object} props.element
|
|
5214
|
+
* @param {string} props.id
|
|
5215
|
+
* @param {string} props.description
|
|
5216
|
+
* @param {boolean} props.debounce
|
|
5217
|
+
* @param {string} props.label
|
|
5218
|
+
* @param {Function} props.getValue
|
|
5219
|
+
* @param {Function} props.setValue
|
|
5220
|
+
* @param {Function} props.onFocus
|
|
5221
|
+
* @param {Function} props.onBlur
|
|
5222
|
+
* @param {number} props.rows
|
|
5223
|
+
* @param {boolean} props.monospace
|
|
5224
|
+
* @param {boolean} [props.disabled]
|
|
4973
5225
|
*/
|
|
4974
5226
|
function TextAreaEntry(props) {
|
|
4975
5227
|
const {
|
|
@@ -4989,7 +5241,7 @@ function TextAreaEntry(props) {
|
|
|
4989
5241
|
const value = getValue(element);
|
|
4990
5242
|
const error = useError(id);
|
|
4991
5243
|
return jsxRuntime.jsxs("div", {
|
|
4992
|
-
class:
|
|
5244
|
+
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
4993
5245
|
"data-entry-id": id,
|
|
4994
5246
|
children: [jsxRuntime.jsx(TextArea, {
|
|
4995
5247
|
id: id,
|
|
@@ -5072,19 +5324,19 @@ function Textfield(props) {
|
|
|
5072
5324
|
});
|
|
5073
5325
|
}
|
|
5074
5326
|
|
|
5075
|
-
/**
|
|
5076
|
-
* @param {Object} props
|
|
5077
|
-
* @param {Object} props.element
|
|
5078
|
-
* @param {String} props.id
|
|
5079
|
-
* @param {String} props.description
|
|
5080
|
-
* @param {Boolean} props.debounce
|
|
5081
|
-
* @param {Boolean} props.disabled
|
|
5082
|
-
* @param {String} props.label
|
|
5083
|
-
* @param {Function} props.getValue
|
|
5084
|
-
* @param {Function} props.setValue
|
|
5085
|
-
* @param {Function} props.onFocus
|
|
5086
|
-
* @param {Function} props.onBlur
|
|
5087
|
-
* @param {Function} props.validate
|
|
5327
|
+
/**
|
|
5328
|
+
* @param {Object} props
|
|
5329
|
+
* @param {Object} props.element
|
|
5330
|
+
* @param {String} props.id
|
|
5331
|
+
* @param {String} props.description
|
|
5332
|
+
* @param {Boolean} props.debounce
|
|
5333
|
+
* @param {Boolean} props.disabled
|
|
5334
|
+
* @param {String} props.label
|
|
5335
|
+
* @param {Function} props.getValue
|
|
5336
|
+
* @param {Function} props.setValue
|
|
5337
|
+
* @param {Function} props.onFocus
|
|
5338
|
+
* @param {Function} props.onBlur
|
|
5339
|
+
* @param {Function} props.validate
|
|
5088
5340
|
*/
|
|
5089
5341
|
function TextfieldEntry(props) {
|
|
5090
5342
|
const {
|
|
@@ -5128,7 +5380,7 @@ function TextfieldEntry(props) {
|
|
|
5128
5380
|
}
|
|
5129
5381
|
const error = globalError || localError;
|
|
5130
5382
|
return jsxRuntime.jsxs("div", {
|
|
5131
|
-
class:
|
|
5383
|
+
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
5132
5384
|
"data-entry-id": id,
|
|
5133
5385
|
children: [jsxRuntime.jsx(Textfield, {
|
|
5134
5386
|
debounce: debounce,
|
|
@@ -5169,6 +5421,7 @@ function getService(type, strict) {}
|
|
|
5169
5421
|
const PropertiesPanelContext = preact.createContext({
|
|
5170
5422
|
getService
|
|
5171
5423
|
});
|
|
5424
|
+
var FormPropertiesPanelContext = PropertiesPanelContext;
|
|
5172
5425
|
|
|
5173
5426
|
function arrayAdd(array, index, item) {
|
|
5174
5427
|
const copy = [...array];
|
|
@@ -5176,7 +5429,7 @@ function arrayAdd(array, index, item) {
|
|
|
5176
5429
|
return copy;
|
|
5177
5430
|
}
|
|
5178
5431
|
function countDecimals(number) {
|
|
5179
|
-
const num =
|
|
5432
|
+
const num = Big(number);
|
|
5180
5433
|
if (num.toString() === num.toFixed(0)) return 0;
|
|
5181
5434
|
return num.toFixed().split('.')[1].length || 0;
|
|
5182
5435
|
}
|
|
@@ -5234,7 +5487,7 @@ const PropertiesPanelHeaderProvider = {
|
|
|
5234
5487
|
const {
|
|
5235
5488
|
type
|
|
5236
5489
|
} = field;
|
|
5237
|
-
const Icon = formJsViewer.iconsByType
|
|
5490
|
+
const Icon = formJsViewer.iconsByType(type);
|
|
5238
5491
|
if (Icon) {
|
|
5239
5492
|
return () => jsxRuntime.jsx(Icon, {
|
|
5240
5493
|
width: "36",
|
|
@@ -5320,7 +5573,7 @@ function Action(props) {
|
|
|
5320
5573
|
function useService (type, strict) {
|
|
5321
5574
|
const {
|
|
5322
5575
|
getService
|
|
5323
|
-
} = hooks$1.useContext(
|
|
5576
|
+
} = hooks$1.useContext(FormPropertiesPanelContext);
|
|
5324
5577
|
return getService(type, strict);
|
|
5325
5578
|
}
|
|
5326
5579
|
|
|
@@ -5594,7 +5847,7 @@ function DefaultValueNumber(props) {
|
|
|
5594
5847
|
if (!isValidNumber(value)) return;
|
|
5595
5848
|
|
|
5596
5849
|
// Enforces decimal notation so that we do not submit defaults in exponent form
|
|
5597
|
-
return serializeToString ?
|
|
5850
|
+
return serializeToString ? Big(value).toFixed() : value;
|
|
5598
5851
|
};
|
|
5599
5852
|
const setValue = value => {
|
|
5600
5853
|
let newValue;
|
|
@@ -5935,6 +6188,46 @@ const SimpleStringComponent = props => {
|
|
|
5935
6188
|
});
|
|
5936
6189
|
};
|
|
5937
6190
|
|
|
6191
|
+
function simpleBoolEntryFactory(options) {
|
|
6192
|
+
const {
|
|
6193
|
+
id,
|
|
6194
|
+
label,
|
|
6195
|
+
path,
|
|
6196
|
+
props
|
|
6197
|
+
} = options;
|
|
6198
|
+
const {
|
|
6199
|
+
editField,
|
|
6200
|
+
field
|
|
6201
|
+
} = props;
|
|
6202
|
+
return {
|
|
6203
|
+
id,
|
|
6204
|
+
label,
|
|
6205
|
+
path,
|
|
6206
|
+
field,
|
|
6207
|
+
editField,
|
|
6208
|
+
component: SimpleBoolComponent,
|
|
6209
|
+
isEdited: isEdited$7
|
|
6210
|
+
};
|
|
6211
|
+
}
|
|
6212
|
+
const SimpleBoolComponent = props => {
|
|
6213
|
+
const {
|
|
6214
|
+
id,
|
|
6215
|
+
label,
|
|
6216
|
+
path,
|
|
6217
|
+
field,
|
|
6218
|
+
editField
|
|
6219
|
+
} = props;
|
|
6220
|
+
const getValue = () => minDash.get(field, path, '');
|
|
6221
|
+
const setValue = value => editField(field, path, value);
|
|
6222
|
+
return CheckboxEntry({
|
|
6223
|
+
element: field,
|
|
6224
|
+
getValue,
|
|
6225
|
+
id,
|
|
6226
|
+
label,
|
|
6227
|
+
setValue
|
|
6228
|
+
});
|
|
6229
|
+
};
|
|
6230
|
+
|
|
5938
6231
|
function LabelEntry(props) {
|
|
5939
6232
|
const {
|
|
5940
6233
|
field
|
|
@@ -6114,11 +6407,15 @@ function NumberDecimalDigits(props) {
|
|
|
6114
6407
|
debounce,
|
|
6115
6408
|
label: 'Decimal digits',
|
|
6116
6409
|
element: field,
|
|
6117
|
-
|
|
6118
|
-
step: 1,
|
|
6410
|
+
step: 'any',
|
|
6119
6411
|
getValue,
|
|
6120
6412
|
id,
|
|
6121
|
-
setValue
|
|
6413
|
+
setValue,
|
|
6414
|
+
validate: value => {
|
|
6415
|
+
if (value === undefined || value === null) return;
|
|
6416
|
+
if (value < 0) return 'Should be greater than or equal to zero.';
|
|
6417
|
+
if (!Number.isInteger(value)) return 'Should be an integer.';
|
|
6418
|
+
}
|
|
6122
6419
|
});
|
|
6123
6420
|
}
|
|
6124
6421
|
function NumberArrowStep(props) {
|
|
@@ -6153,10 +6450,10 @@ function NumberArrowStep(props) {
|
|
|
6153
6450
|
validate: value => {
|
|
6154
6451
|
if (value === undefined || value === null) return;
|
|
6155
6452
|
if (!isValidNumber(value)) return 'Should be a valid number.';
|
|
6156
|
-
if (
|
|
6453
|
+
if (Big(value).cmp(0) <= 0) return 'Should be greater than zero.';
|
|
6157
6454
|
if (decimalDigitsSet) {
|
|
6158
|
-
const minimumValue =
|
|
6159
|
-
if (
|
|
6455
|
+
const minimumValue = Big(`1e-${decimalDigits}`);
|
|
6456
|
+
if (Big(value).cmp(minimumValue) < 0) return `Should be at least ${minimumValue.toString()}.`;
|
|
6160
6457
|
if (countDecimals(value) > decimalDigits) return `Should not contain more than ${decimalDigits} decimal digits.`;
|
|
6161
6458
|
}
|
|
6162
6459
|
}
|
|
@@ -6200,7 +6497,7 @@ function SerializeToString(props) {
|
|
|
6200
6497
|
const setValue = value => {
|
|
6201
6498
|
// Whenever changing the formatting, make sure to change the default value type along with it
|
|
6202
6499
|
if (defaultValue || defaultValue === 0) {
|
|
6203
|
-
editField(field, ['defaultValue'], value ?
|
|
6500
|
+
editField(field, ['defaultValue'], value ? Big(defaultValue).toFixed() : Number(defaultValue));
|
|
6204
6501
|
}
|
|
6205
6502
|
return editField(field, path, value);
|
|
6206
6503
|
};
|
|
@@ -6208,7 +6505,7 @@ function SerializeToString(props) {
|
|
|
6208
6505
|
element: field,
|
|
6209
6506
|
getValue,
|
|
6210
6507
|
id,
|
|
6211
|
-
label: '
|
|
6508
|
+
label: 'Output as string',
|
|
6212
6509
|
description: 'Allows arbitrary precision values',
|
|
6213
6510
|
setValue
|
|
6214
6511
|
});
|
|
@@ -6451,6 +6748,25 @@ function TimeFormatSelect(props) {
|
|
|
6451
6748
|
});
|
|
6452
6749
|
}
|
|
6453
6750
|
|
|
6751
|
+
function SelectEntries(props) {
|
|
6752
|
+
const {
|
|
6753
|
+
field
|
|
6754
|
+
} = props;
|
|
6755
|
+
const {
|
|
6756
|
+
type
|
|
6757
|
+
} = field;
|
|
6758
|
+
if (type !== 'select') {
|
|
6759
|
+
return [];
|
|
6760
|
+
}
|
|
6761
|
+
const entries = [simpleBoolEntryFactory({
|
|
6762
|
+
id: 'searchable',
|
|
6763
|
+
path: ['searchable'],
|
|
6764
|
+
label: 'Searchable',
|
|
6765
|
+
props
|
|
6766
|
+
})];
|
|
6767
|
+
return entries;
|
|
6768
|
+
}
|
|
6769
|
+
|
|
6454
6770
|
function ValueEntry(props) {
|
|
6455
6771
|
const {
|
|
6456
6772
|
editField,
|
|
@@ -6980,6 +7296,9 @@ function GeneralGroup(field, editField) {
|
|
|
6980
7296
|
}), ...AltTextEntry({
|
|
6981
7297
|
field,
|
|
6982
7298
|
editField
|
|
7299
|
+
}), ...SelectEntries({
|
|
7300
|
+
field,
|
|
7301
|
+
editField
|
|
6983
7302
|
}), ...DisabledEntry({
|
|
6984
7303
|
field,
|
|
6985
7304
|
editField
|
|
@@ -7026,7 +7345,7 @@ function ConstraintsGroup(field, editField) {
|
|
|
7026
7345
|
|
|
7027
7346
|
const VALIDATION_TYPE_OPTIONS = {
|
|
7028
7347
|
custom: {
|
|
7029
|
-
value:
|
|
7348
|
+
value: '',
|
|
7030
7349
|
label: 'Custom'
|
|
7031
7350
|
},
|
|
7032
7351
|
email: {
|
|
@@ -7043,7 +7362,7 @@ function ValidationGroup(field, editField) {
|
|
|
7043
7362
|
type
|
|
7044
7363
|
} = field;
|
|
7045
7364
|
const validate = minDash.get(field, ['validate'], {});
|
|
7046
|
-
const isCustomValidation = [undefined, VALIDATION_TYPE_OPTIONS.custom.value].includes(validate
|
|
7365
|
+
const isCustomValidation = [undefined, VALIDATION_TYPE_OPTIONS.custom.value].includes(validate.validationType);
|
|
7047
7366
|
if (!(INPUTS.includes(type) && type !== 'checkbox' && type !== 'checklist' && type !== 'taglist')) {
|
|
7048
7367
|
return null;
|
|
7049
7368
|
}
|
|
@@ -7191,7 +7510,7 @@ function Pattern(props) {
|
|
|
7191
7510
|
element: field,
|
|
7192
7511
|
getValue: getValue('pattern'),
|
|
7193
7512
|
id,
|
|
7194
|
-
label: '
|
|
7513
|
+
label: 'Custom regular expression',
|
|
7195
7514
|
setValue: onChange('pattern')
|
|
7196
7515
|
});
|
|
7197
7516
|
}
|
|
@@ -7247,7 +7566,7 @@ function ValidationType(props) {
|
|
|
7247
7566
|
element: field,
|
|
7248
7567
|
getValue: getValue('validationType'),
|
|
7249
7568
|
id,
|
|
7250
|
-
label: '
|
|
7569
|
+
label: 'Validation pattern',
|
|
7251
7570
|
setValue,
|
|
7252
7571
|
getOptions: () => Object.values(VALIDATION_TYPE_OPTIONS)
|
|
7253
7572
|
});
|
|
@@ -7493,7 +7812,7 @@ function FormPropertiesPanel(props) {
|
|
|
7493
7812
|
"data-field": selectedFormField && selectedFormField.id,
|
|
7494
7813
|
onFocusCapture: onFocus,
|
|
7495
7814
|
onBlurCapture: onBlur,
|
|
7496
|
-
children: jsxRuntime.jsx(
|
|
7815
|
+
children: jsxRuntime.jsx(FormPropertiesPanelContext.Provider, {
|
|
7497
7816
|
value: propertiesPanelContext,
|
|
7498
7817
|
children: jsxRuntime.jsx(PropertiesPanel, {
|
|
7499
7818
|
element: selectedFormField,
|
|
@@ -7576,7 +7895,7 @@ var PropertiesPanelModule = {
|
|
|
7576
7895
|
propertiesPanel: ['type', PropertiesPanelRenderer]
|
|
7577
7896
|
};
|
|
7578
7897
|
|
|
7579
|
-
const ids = new
|
|
7898
|
+
const ids = new Ids([32, 36, 1]);
|
|
7580
7899
|
|
|
7581
7900
|
/**
|
|
7582
7901
|
* @typedef { import('./types').Injector } Injector
|
|
@@ -7882,9 +8201,7 @@ function createFormEditor(options) {
|
|
|
7882
8201
|
|
|
7883
8202
|
Object.defineProperty(exports, 'schemaVersion', {
|
|
7884
8203
|
enumerable: true,
|
|
7885
|
-
get: function () {
|
|
7886
|
-
return formJsViewer.schemaVersion;
|
|
7887
|
-
}
|
|
8204
|
+
get: function () { return formJsViewer.schemaVersion; }
|
|
7888
8205
|
});
|
|
7889
8206
|
exports.FormEditor = FormEditor;
|
|
7890
8207
|
exports.createFormEditor = createFormEditor;
|