@bpmn-io/form-js-viewer 0.10.0 → 0.10.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.
Files changed (67) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +165 -165
  3. package/dist/assets/form-js.css +611 -620
  4. package/dist/index.cjs +140 -138
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.es.js +140 -138
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/types/Form.d.ts +144 -144
  9. package/dist/types/core/ConditionChecker.d.ts +57 -57
  10. package/dist/types/core/EventBus.d.ts +1 -1
  11. package/dist/types/core/FormFieldRegistry.d.ts +17 -17
  12. package/dist/types/core/Validator.d.ts +7 -7
  13. package/dist/types/core/index.d.ts +18 -18
  14. package/dist/types/import/Importer.d.ts +43 -43
  15. package/dist/types/import/index.d.ts +5 -5
  16. package/dist/types/index.d.ts +18 -18
  17. package/dist/types/render/FormFields.d.ts +5 -5
  18. package/dist/types/render/Renderer.d.ts +23 -23
  19. package/dist/types/render/components/Description.d.ts +1 -1
  20. package/dist/types/render/components/Errors.d.ts +1 -1
  21. package/dist/types/render/components/FormComponent.d.ts +1 -1
  22. package/dist/types/render/components/FormField.d.ts +1 -1
  23. package/dist/types/render/components/Label.d.ts +1 -1
  24. package/dist/types/render/components/PoweredBy.d.ts +1 -1
  25. package/dist/types/render/components/Sanitizer.d.ts +8 -8
  26. package/dist/types/render/components/Util.d.ts +17 -17
  27. package/dist/types/render/components/form-fields/Button.d.ts +11 -11
  28. package/dist/types/render/components/form-fields/Checkbox.d.ts +13 -13
  29. package/dist/types/render/components/form-fields/Checklist.d.ts +12 -12
  30. package/dist/types/render/components/form-fields/Datetime.d.ts +11 -11
  31. package/dist/types/render/components/form-fields/Default.d.ts +9 -9
  32. package/dist/types/render/components/form-fields/Image.d.ts +8 -8
  33. package/dist/types/render/components/form-fields/Number.d.ts +14 -14
  34. package/dist/types/render/components/form-fields/Radio.d.ts +12 -12
  35. package/dist/types/render/components/form-fields/Select.d.ts +12 -12
  36. package/dist/types/render/components/form-fields/Taglist.d.ts +12 -12
  37. package/dist/types/render/components/form-fields/Text.d.ts +10 -10
  38. package/dist/types/render/components/form-fields/Textarea.d.ts +13 -13
  39. package/dist/types/render/components/form-fields/Textfield.d.ts +13 -13
  40. package/dist/types/render/components/form-fields/parts/Datepicker.d.ts +1 -1
  41. package/dist/types/render/components/form-fields/parts/DropdownList.d.ts +1 -1
  42. package/dist/types/render/components/form-fields/parts/InputAdorner.d.ts +1 -1
  43. package/dist/types/render/components/form-fields/parts/Timepicker.d.ts +1 -1
  44. package/dist/types/render/components/icons/index.d.ts +16 -16
  45. package/dist/types/render/components/index.d.ts +17 -17
  46. package/dist/types/render/components/util/dateTimeUtil.d.ts +12 -12
  47. package/dist/types/render/components/util/numberFieldUtil.d.ts +4 -4
  48. package/dist/types/render/components/util/sanitizerUtil.d.ts +3 -3
  49. package/dist/types/render/context/FormContext.d.ts +12 -12
  50. package/dist/types/render/context/FormRenderContext.d.ts +6 -6
  51. package/dist/types/render/context/index.d.ts +2 -2
  52. package/dist/types/render/hooks/useCondition.d.ts +9 -9
  53. package/dist/types/render/hooks/useEvaluation.d.ts +6 -6
  54. package/dist/types/render/hooks/useExpressionValue.d.ts +5 -5
  55. package/dist/types/render/hooks/useKeyDownAction.d.ts +1 -1
  56. package/dist/types/render/hooks/useService.d.ts +1 -1
  57. package/dist/types/render/hooks/useValuesAsync.d.ts +28 -28
  58. package/dist/types/render/index.d.ts +11 -11
  59. package/dist/types/src/types.d.ts +35 -35
  60. package/dist/types/util/constants/DatetimeConstants.d.ts +24 -24
  61. package/dist/types/util/constants/ValuesSourceConstants.d.ts +15 -15
  62. package/dist/types/util/constants/index.d.ts +2 -2
  63. package/dist/types/util/feel.d.ts +15 -15
  64. package/dist/types/util/form.d.ts +6 -6
  65. package/dist/types/util/index.d.ts +25 -25
  66. package/dist/types/util/injector.d.ts +2 -2
  67. package/package.json +2 -2
package/dist/index.es.js CHANGED
@@ -12,9 +12,9 @@ import flatpickr from 'flatpickr';
12
12
  import Markup from 'preact-markup';
13
13
  import { Injector } from 'didi';
14
14
 
15
- /**
16
- * @typedef {object} Condition
17
- * @property {string} [hide]
15
+ /**
16
+ * @typedef {object} Condition
17
+ * @property {string} [hide]
18
18
  */
19
19
 
20
20
  class ConditionChecker {
@@ -23,11 +23,11 @@ class ConditionChecker {
23
23
  this._eventBus = eventBus;
24
24
  }
25
25
 
26
- /**
27
- * For given data, remove properties based on condition.
28
- *
29
- * @param {Object<string, any>} properties
30
- * @param {Object<string, any>} data
26
+ /**
27
+ * For given data, remove properties based on condition.
28
+ *
29
+ * @param {Object<string, any>} properties
30
+ * @param {Object<string, any>} data
31
31
  */
32
32
  applyConditions(properties, data = {}) {
33
33
  const conditions = this._getConditions();
@@ -46,13 +46,13 @@ class ConditionChecker {
46
46
  return newProperties;
47
47
  }
48
48
 
49
- /**
50
- * Check if given condition is met. Returns null for invalid/missing conditions.
51
- *
52
- * @param {string} condition
53
- * @param {import('../types').Data} [data]
54
- *
55
- * @returns {boolean|null}
49
+ /**
50
+ * Check if given condition is met. Returns null for invalid/missing conditions.
51
+ *
52
+ * @param {string} condition
53
+ * @param {import('../types').Data} [data]
54
+ *
55
+ * @returns {boolean|null}
56
56
  */
57
57
  check(condition, data = {}) {
58
58
  if (!condition) {
@@ -73,12 +73,12 @@ class ConditionChecker {
73
73
  }
74
74
  }
75
75
 
76
- /**
77
- * Check if hide condition is met.
78
- *
79
- * @param {Condition} condition
80
- * @param {Object<string, any>} data
81
- * @returns {boolean}
76
+ /**
77
+ * Check if hide condition is met.
78
+ *
79
+ * @param {Condition} condition
80
+ * @param {Object<string, any>} data
81
+ * @returns {boolean}
82
82
  */
83
83
  _checkHideCondition(condition, data) {
84
84
  if (!condition.hide) {
@@ -88,13 +88,13 @@ class ConditionChecker {
88
88
  return result === true;
89
89
  }
90
90
 
91
- /**
92
- * Evaluate an expression.
93
- *
94
- * @param {string} expression
95
- * @param {import('../types').Data} [data]
96
- *
97
- * @returns {any}
91
+ /**
92
+ * Evaluate an expression.
93
+ *
94
+ * @param {string} expression
95
+ * @param {import('../types').Data} [data]
96
+ *
97
+ * @returns {any}
98
98
  */
99
99
  evaluate(expression, data = {}) {
100
100
  if (!expression) {
@@ -703,11 +703,11 @@ class FormFieldRegistry {
703
703
  }
704
704
  FormFieldRegistry.$inject = ['eventBus'];
705
705
 
706
- /**
707
- * Retrieve variable names from given FEEL unary test.
708
- *
709
- * @param {string} unaryTest
710
- * @returns {string[]}
706
+ /**
707
+ * Retrieve variable names from given FEEL unary test.
708
+ *
709
+ * @param {string} unaryTest
710
+ * @returns {string[]}
711
711
  */
712
712
  function getVariableNames(unaryTest) {
713
713
  const tree = parseUnaryTests(unaryTest);
@@ -722,11 +722,11 @@ function getVariableNames(unaryTest) {
722
722
  return Array.from(variables);
723
723
  }
724
724
 
725
- /**
726
- * Retrieve variable names from given FEEL expression.
727
- *
728
- * @param {string} expression
729
- * @returns {string[]}
725
+ /**
726
+ * Retrieve variable names from given FEEL expression.
727
+ *
728
+ * @param {string} expression
729
+ * @returns {string[]}
730
730
  */
731
731
  function getExpressionVariableNames(expression) {
732
732
  const tree = parseExpressions(expression);
@@ -812,10 +812,10 @@ function createInjector(bootstrapModules) {
812
812
  return injector;
813
813
  }
814
814
 
815
- /**
816
- * @param {string?} prefix
817
- *
818
- * @returns Element
815
+ /**
816
+ * @param {string?} prefix
817
+ *
818
+ * @returns Element
819
819
  */
820
820
  function createFormContainer(prefix = 'fjs') {
821
821
  const container = document.createElement('div');
@@ -860,22 +860,22 @@ function generateIdForType(type) {
860
860
  return `${type}${generateIndexForType(type)}`;
861
861
  }
862
862
 
863
- /**
864
- * @template T
865
- * @param {T} data
866
- * @param {(this: any, key: string, value: any) => any} [replacer]
867
- * @return {T}
863
+ /**
864
+ * @template T
865
+ * @param {T} data
866
+ * @param {(this: any, key: string, value: any) => any} [replacer]
867
+ * @return {T}
868
868
  */
869
869
  function clone(data, replacer) {
870
870
  return JSON.parse(JSON.stringify(data, replacer));
871
871
  }
872
872
 
873
- /**
874
- * Parse the schema for input variables a form might make use of
875
- *
876
- * @param {any} schema
877
- *
878
- * @return {string[]}
873
+ /**
874
+ * Parse the schema for input variables a form might make use of
875
+ *
876
+ * @param {any} schema
877
+ *
878
+ * @return {string[]}
879
879
  */
880
880
  function getSchemaVariables(schema) {
881
881
  if (!schema.components) {
@@ -924,25 +924,25 @@ function isExpression$1(value) {
924
924
  }
925
925
 
926
926
  class Importer {
927
- /**
928
- * @constructor
929
- * @param { import('../core').FormFieldRegistry } formFieldRegistry
930
- * @param { import('../render/FormFields').default } formFields
927
+ /**
928
+ * @constructor
929
+ * @param { import('../core').FormFieldRegistry } formFieldRegistry
930
+ * @param { import('../render/FormFields').default } formFields
931
931
  */
932
932
  constructor(formFieldRegistry, formFields) {
933
933
  this._formFieldRegistry = formFieldRegistry;
934
934
  this._formFields = formFields;
935
935
  }
936
936
 
937
- /**
938
- * Import schema adding `id`, `_parent` and `_path`
939
- * information to each field and adding it to the
940
- * form field registry.
941
- *
942
- * @param {any} schema
943
- * @param {any} [data]
944
- *
945
- * @return { { warnings: Array<any>, schema: any, data: any } }
937
+ /**
938
+ * Import schema adding `id`, `_parent` and `_path`
939
+ * information to each field and adding it to the
940
+ * form field registry.
941
+ *
942
+ * @param {any} schema
943
+ * @param {any} [data]
944
+ *
945
+ * @return { { warnings: Array<any>, schema: any, data: any } }
946
946
  */
947
947
  importSchema(schema, data = {}) {
948
948
  // TODO: Add warnings - https://github.com/bpmn-io/form-js/issues/289
@@ -961,11 +961,11 @@ class Importer {
961
961
  }
962
962
  }
963
963
 
964
- /**
965
- * @param {any} formField
966
- * @param {string} [parentId]
967
- *
968
- * @return {any} importedField
964
+ /**
965
+ * @param {any} formField
966
+ * @param {string} [parentId]
967
+ *
968
+ * @return {any} importedField
969
969
  */
970
970
  importFormField(formField, parentId) {
971
971
  const {
@@ -1016,10 +1016,10 @@ class Importer {
1016
1016
  });
1017
1017
  }
1018
1018
 
1019
- /**
1020
- * @param {Object} data
1021
- *
1022
- * @return {Object} initializedData
1019
+ /**
1020
+ * @param {Object} data
1021
+ *
1022
+ * @return {Object} initializedData
1023
1023
  */
1024
1024
  initializeFieldValues(data) {
1025
1025
  return this._formFieldRegistry.getAll().reduce((initializedData, formField) => {
@@ -1069,11 +1069,11 @@ const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u
1069
1069
 
1070
1070
  const FORM_ELEMENT = document.createElement('form');
1071
1071
 
1072
- /**
1073
- * Sanitize a HTML string and return the cleaned, safe version.
1074
- *
1075
- * @param {string} html
1076
- * @return {string}
1072
+ /**
1073
+ * Sanitize a HTML string and return the cleaned, safe version.
1074
+ *
1075
+ * @param {string} html
1076
+ * @return {string}
1077
1077
  */
1078
1078
  function sanitizeHTML(html) {
1079
1079
  const doc = new DOMParser().parseFromString(`<!DOCTYPE html>\n<html><body><div>${html}`, 'text/html');
@@ -1093,15 +1093,15 @@ function sanitizeImageSource(src) {
1093
1093
  return valid ? src : '';
1094
1094
  }
1095
1095
 
1096
- /**
1097
- * Recursively sanitize a HTML node, potentially
1098
- * removing it, its children or attributes.
1099
- *
1100
- * Inspired by https://github.com/developit/snarkdown/issues/70
1101
- * and https://github.com/cure53/DOMPurify. Simplified
1102
- * for our use-case.
1103
- *
1104
- * @param {Element} node
1096
+ /**
1097
+ * Recursively sanitize a HTML node, potentially
1098
+ * removing it, its children or attributes.
1099
+ *
1100
+ * Inspired by https://github.com/developit/snarkdown/issues/70
1101
+ * and https://github.com/cure53/DOMPurify. Simplified
1102
+ * for our use-case.
1103
+ *
1104
+ * @param {Element} node
1105
1105
  */
1106
1106
  function sanitizeNode(node) {
1107
1107
  // allow text nodes
@@ -1145,13 +1145,13 @@ function sanitizeNode(node) {
1145
1145
  }
1146
1146
  }
1147
1147
 
1148
- /**
1149
- * Validates attributes for validity.
1150
- *
1151
- * @param {string} lcTag
1152
- * @param {string} lcName
1153
- * @param {string} value
1154
- * @return {boolean}
1148
+ /**
1149
+ * Validates attributes for validity.
1150
+ *
1151
+ * @param {string} lcTag
1152
+ * @param {string} lcName
1153
+ * @param {string} value
1154
+ * @return {boolean}
1155
1155
  */
1156
1156
  function isValidAttribute(lcTag, lcName, value) {
1157
1157
  // disallow most attributes based on whitelist
@@ -1203,14 +1203,14 @@ function safeMarkdown(markdown) {
1203
1203
  return sanitizeHTML(html);
1204
1204
  }
1205
1205
 
1206
- /**
1207
- * Sanitizes an image source to ensure we only allow for data URI and links
1208
- * that start with http(s).
1209
- *
1210
- * Note: Most browsers anyway do not support script execution in <img> elements.
1211
- *
1212
- * @param {string} src
1213
- * @returns {string}
1206
+ /**
1207
+ * Sanitizes an image source to ensure we only allow for data URI and links
1208
+ * that start with http(s).
1209
+ *
1210
+ * Note: Most browsers anyway do not support script execution in <img> elements.
1211
+ *
1212
+ * @param {string} src
1213
+ * @returns {string}
1214
1214
  */
1215
1215
  function safeImageSource(src) {
1216
1216
  return sanitizeImageSource(src);
@@ -1257,11 +1257,11 @@ const FormRenderContext = createContext({
1257
1257
  }
1258
1258
  });
1259
1259
 
1260
- /**
1261
- * @param {string} type
1262
- * @param {boolean} [strict]
1263
- *
1264
- * @returns {any}
1260
+ /**
1261
+ * @param {string} type
1262
+ * @param {boolean} [strict]
1263
+ *
1264
+ * @returns {any}
1265
1265
  */
1266
1266
  function getService(type, strict) {}
1267
1267
  const FormContext = createContext({
@@ -1390,8 +1390,8 @@ function useService (type, strict) {
1390
1390
  return getService(type, strict);
1391
1391
  }
1392
1392
 
1393
- /**
1394
- * @enum { String }
1393
+ /**
1394
+ * @enum { String }
1395
1395
  */
1396
1396
  const LOAD_STATES = {
1397
1397
  LOADING: 'loading',
@@ -1399,17 +1399,17 @@ const LOAD_STATES = {
1399
1399
  ERROR: 'error'
1400
1400
  };
1401
1401
 
1402
- /**
1403
- * @typedef {Object} ValuesGetter
1404
- * @property {Object[]} values - The values data
1405
- * @property {(LOAD_STATES)} state - The values data's loading state, to use for conditional rendering
1402
+ /**
1403
+ * @typedef {Object} ValuesGetter
1404
+ * @property {Object[]} values - The values data
1405
+ * @property {(LOAD_STATES)} state - The values data's loading state, to use for conditional rendering
1406
1406
  */
1407
1407
 
1408
- /**
1409
- * A hook to load values for single and multiselect components.
1410
- *
1411
- * @param {Object} field - The form field to handle values for
1412
- * @return {ValuesGetter} valuesGetter - A values getter object providing loading state and values
1408
+ /**
1409
+ * A hook to load values for single and multiselect components.
1410
+ *
1411
+ * @param {Object} field - The form field to handle values for
1412
+ * @return {ValuesGetter} valuesGetter - A values getter object providing loading state and values
1413
1413
  */
1414
1414
  function useValuesAsync (field) {
1415
1415
  const {
@@ -1744,13 +1744,13 @@ Checklist.keyed = true;
1744
1744
  Checklist.emptyValue = [];
1745
1745
  Checklist.sanitizeValue = sanitizeMultiSelectValue;
1746
1746
 
1747
- /**
1748
- * Check if condition is met with given variables.
1749
- *
1750
- * @param {string | undefined} condition
1751
- * @param {import('../../types').Data} data
1752
- *
1753
- * @returns {boolean} true if condition is met or no condition or condition checker exists
1747
+ /**
1748
+ * Check if condition is met with given variables.
1749
+ *
1750
+ * @param {string | undefined} condition
1751
+ * @param {import('../../types').Data} data
1752
+ *
1753
+ * @returns {boolean} true if condition is met or no condition or condition checker exists
1754
1754
  */
1755
1755
  function useCondition(condition, data) {
1756
1756
  const initialData = useService('form')._getState().initialData;
@@ -2502,10 +2502,10 @@ Datetime.keyed = true;
2502
2502
  Datetime.emptyValue = null;
2503
2503
  Datetime.sanitizeValue = sanitizeDateTimePickerValue;
2504
2504
 
2505
- /**
2506
- * This file must not be changed or exchanged.
2507
- *
2508
- * @see http://bpmn.io/license for more information.
2505
+ /**
2506
+ * This file must not be changed or exchanged.
2507
+ *
2508
+ * @see http://bpmn.io/license for more information.
2509
2509
  */
2510
2510
  function Logo() {
2511
2511
  return jsxs("svg", {
@@ -2622,10 +2622,10 @@ function FormComponent(props) {
2622
2622
  });
2623
2623
  }
2624
2624
 
2625
- /**
2626
- *
2627
- * @param {string | undefined} expression
2628
- * @param {import('../../types').Data} data
2625
+ /**
2626
+ *
2627
+ * @param {string | undefined} expression
2628
+ * @param {import('../../types').Data} data
2629
2629
  */
2630
2630
  function useEvaluation(expression, data) {
2631
2631
  const initialData = useService('form')._getState().initialData;
@@ -2642,9 +2642,9 @@ function useEvaluation(expression, data) {
2642
2642
  return conditionChecker.evaluate(expression, filteredData);
2643
2643
  }
2644
2644
 
2645
- /**
2646
- *
2647
- * @param {string} value
2645
+ /**
2646
+ *
2647
+ * @param {string} value
2648
2648
  */
2649
2649
  function useExpressionValue(value) {
2650
2650
  const formData = useService('form')._getState().data;
@@ -2898,6 +2898,7 @@ function Numberfield(props) {
2898
2898
  }),
2899
2899
  children: [jsx("button", {
2900
2900
  class: "fjs-number-arrow-up",
2901
+ type: "button",
2901
2902
  onClick: () => increment(),
2902
2903
  tabIndex: -1,
2903
2904
  children: "\u02C4"
@@ -2905,6 +2906,7 @@ function Numberfield(props) {
2905
2906
  class: "fjs-number-arrow-separator"
2906
2907
  }), jsx("button", {
2907
2908
  class: "fjs-number-arrow-down",
2909
+ type: "button",
2908
2910
  onClick: () => decrement(),
2909
2911
  tabIndex: -1,
2910
2912
  children: "\u02C5"