@bpmn-io/form-js-editor 1.7.0 → 1.7.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/LICENSE CHANGED
@@ -1,23 +1,23 @@
1
- Copyright (c) 2021-present Camunda Services GmbH
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- this software and associated documentation files (the "Software"), to deal in the
5
- Software without restriction, including without limitation the rights to use, copy,
6
- modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7
- and to permit persons to whom the Software is furnished to do so, subject to the
8
- following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- The source code responsible for displaying the bpmn.io project watermark that
14
- links back to https://bpmn.io as part of rendered diagrams MUST NOT be
15
- removed or changed. When this software is being used in a website or application,
16
- the watermark must stay fully visible and not visually overlapped by other elements.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19
- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20
- PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
1
+ Copyright (c) 2021-present Camunda Services GmbH
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in the
5
+ Software without restriction, including without limitation the rights to use, copy,
6
+ modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7
+ and to permit persons to whom the Software is furnished to do so, subject to the
8
+ following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ The source code responsible for displaying the bpmn.io project watermark that
14
+ links back to https://bpmn.io as part of rendered diagrams MUST NOT be
15
+ removed or changed. When this software is being used in a website or application,
16
+ the watermark must stay fully visible and not visually overlapped by other elements.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
23
23
  OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,152 +1,152 @@
1
- # @bpmn-io/form-js-editor
2
-
3
- An editor to create forms that can be displayed with the [form-js viewer](../form-js-viewer).
4
-
5
-
6
- ## Installation
7
-
8
- ```
9
- npm install @bpmn-io/form-js-editor
10
- ```
11
-
12
-
13
- ## Usage
14
-
15
- ```javascript
16
- import { FormEditor } from '@bpmn-io/form-js-editor';
17
-
18
- const schema = {
19
- components: [
20
- {
21
- key: 'creditor',
22
- label: 'Creditor',
23
- type: 'textfield',
24
- validate: {
25
- required: true
26
- }
27
- }
28
- ]
29
- };
30
-
31
- const formEditor = new FormEditor({
32
- container: document.querySelector('#form-editor')
33
- });
34
-
35
- await formEditor.importSchema(schema);
36
- ```
37
-
38
- Check out [a full example](https://github.com/bpmn-io/form-js-examples).
39
-
40
-
41
- ## Styling
42
-
43
- For proper styling include the necessary stylesheets, and font used:
44
-
45
- ```html
46
- <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,600;1,400&display=swap" rel="stylesheet">
47
-
48
- <link rel="stylesheet" href="https://unpkg.com/@bpmn-io/form-js@0.10.0/dist/assets/form-js.css">
49
- <link rel="stylesheet" href="https://unpkg.com/@bpmn-io/form-js@0.10.0/dist/assets/form-js-editor.css">
50
- ```
51
-
52
-
53
- ## API
54
-
55
- ### `FormEditor`
56
-
57
- Create a new form editor with options `{ container?: HTMLElement }`.
58
-
59
- ```javascript
60
- import { FormEditor } from '@bpmn-io/form-js-editor';
61
-
62
- const formEditor = new FormEditor({
63
- container: document.querySelector('#form-editor')
64
- });
65
- ```
66
-
67
-
68
- ### `FormEditor#importSchema(schema: Schema) => Promise<Result, Error>`
69
-
70
- Display and edit a form represented via a form schema.
71
-
72
- ```javascript
73
- try {
74
- await formEditor.importSchema(schema);
75
- } catch (err) {
76
- console.log('importing form failed', err);
77
- }
78
- ```
79
-
80
-
81
- ### `FormEditor#saveSchema() => Schema`
82
-
83
- Export the form schema.
84
-
85
- ```javascript
86
- const schema = formEditor.saveSchema(schema);
87
-
88
- console.log('exported schema', schema);
89
- ```
90
-
91
-
92
- ### `FormEditor#attachTo(parentNode: HTMLElement) => void`
93
-
94
-
95
- Attach the form editor to a parent node.
96
-
97
-
98
- ### `FormEditor#detach() => void`
99
-
100
-
101
- Detach the form editor from its parent node.
102
-
103
-
104
- ### `FormEditor#on(event, fn) => void`
105
-
106
- Subscribe to an [event](#events).
107
-
108
-
109
- ### `FormEditor#destroy() => void`
110
-
111
- Remove form from editor the document.
112
-
113
- ## Events
114
-
115
- ### `selection.changed :: { selection }`
116
-
117
- ### Properties panel events
118
- - `propertiesPanel.focusin`
119
- - `propertiesPanel.focusout`
120
- - `propertiesPanel.showEntry :: { id }`
121
- - `propertiesPanel.updated :: { formField }`
122
-
123
- ### Form lifecycle events
124
- - `detach`
125
- - `attach`
126
- - `rendered`
127
- - `form.init`
128
- - `form.clear`
129
- - `form.destroy`
130
- - `diagram.clear`
131
- - `diagram.destroy`
132
- - `dragula.created`
133
- - `dragula.destroyed`
134
- - `editorActions.init :: { editorActions }`
135
-
136
- ### Drag events
137
- - `drag.start :: { element, source }`
138
- - `drag.end :: { element }`
139
- - `drag.drop :: { element, target, source, sibling }`
140
- - `drag.hover :: { element, container, source }`
141
- - `drag.out :: { element, container, source }`
142
- - `drag.cancel :: { element, container, source }`
143
-
144
- ### Form field events
145
- - `formField.add :: { formField }`
146
- - `formField.remove :: { formField }`
147
- - `formField.updateId :: { formField, newId }`
148
-
149
-
150
- ## License
151
-
152
- Use under the terms of the [bpmn.io license](http://bpmn.io/license).
1
+ # @bpmn-io/form-js-editor
2
+
3
+ An editor to create forms that can be displayed with the [form-js viewer](../form-js-viewer).
4
+
5
+
6
+ ## Installation
7
+
8
+ ```
9
+ npm install @bpmn-io/form-js-editor
10
+ ```
11
+
12
+
13
+ ## Usage
14
+
15
+ ```javascript
16
+ import { FormEditor } from '@bpmn-io/form-js-editor';
17
+
18
+ const schema = {
19
+ components: [
20
+ {
21
+ key: 'creditor',
22
+ label: 'Creditor',
23
+ type: 'textfield',
24
+ validate: {
25
+ required: true
26
+ }
27
+ }
28
+ ]
29
+ };
30
+
31
+ const formEditor = new FormEditor({
32
+ container: document.querySelector('#form-editor')
33
+ });
34
+
35
+ await formEditor.importSchema(schema);
36
+ ```
37
+
38
+ Check out [a full example](https://github.com/bpmn-io/form-js-examples).
39
+
40
+
41
+ ## Styling
42
+
43
+ For proper styling include the necessary stylesheets, and font used:
44
+
45
+ ```html
46
+ <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,600;1,400&display=swap" rel="stylesheet">
47
+
48
+ <link rel="stylesheet" href="https://unpkg.com/@bpmn-io/form-js@0.10.0/dist/assets/form-js.css">
49
+ <link rel="stylesheet" href="https://unpkg.com/@bpmn-io/form-js@0.10.0/dist/assets/form-js-editor.css">
50
+ ```
51
+
52
+
53
+ ## API
54
+
55
+ ### `FormEditor`
56
+
57
+ Create a new form editor with options `{ container?: HTMLElement }`.
58
+
59
+ ```javascript
60
+ import { FormEditor } from '@bpmn-io/form-js-editor';
61
+
62
+ const formEditor = new FormEditor({
63
+ container: document.querySelector('#form-editor')
64
+ });
65
+ ```
66
+
67
+
68
+ ### `FormEditor#importSchema(schema: Schema) => Promise<Result, Error>`
69
+
70
+ Display and edit a form represented via a form schema.
71
+
72
+ ```javascript
73
+ try {
74
+ await formEditor.importSchema(schema);
75
+ } catch (err) {
76
+ console.log('importing form failed', err);
77
+ }
78
+ ```
79
+
80
+
81
+ ### `FormEditor#saveSchema() => Schema`
82
+
83
+ Export the form schema.
84
+
85
+ ```javascript
86
+ const schema = formEditor.saveSchema(schema);
87
+
88
+ console.log('exported schema', schema);
89
+ ```
90
+
91
+
92
+ ### `FormEditor#attachTo(parentNode: HTMLElement) => void`
93
+
94
+
95
+ Attach the form editor to a parent node.
96
+
97
+
98
+ ### `FormEditor#detach() => void`
99
+
100
+
101
+ Detach the form editor from its parent node.
102
+
103
+
104
+ ### `FormEditor#on(event, fn) => void`
105
+
106
+ Subscribe to an [event](#events).
107
+
108
+
109
+ ### `FormEditor#destroy() => void`
110
+
111
+ Remove form from editor the document.
112
+
113
+ ## Events
114
+
115
+ ### `selection.changed :: { selection }`
116
+
117
+ ### Properties panel events
118
+ - `propertiesPanel.focusin`
119
+ - `propertiesPanel.focusout`
120
+ - `propertiesPanel.showEntry :: { id }`
121
+ - `propertiesPanel.updated :: { formField }`
122
+
123
+ ### Form lifecycle events
124
+ - `detach`
125
+ - `attach`
126
+ - `rendered`
127
+ - `form.init`
128
+ - `form.clear`
129
+ - `form.destroy`
130
+ - `diagram.clear`
131
+ - `diagram.destroy`
132
+ - `dragula.created`
133
+ - `dragula.destroyed`
134
+ - `editorActions.init :: { editorActions }`
135
+
136
+ ### Drag events
137
+ - `drag.start :: { element, source }`
138
+ - `drag.end :: { element }`
139
+ - `drag.drop :: { element, target, source, sibling }`
140
+ - `drag.hover :: { element, container, source }`
141
+ - `drag.out :: { element, container, source }`
142
+ - `drag.cancel :: { element, container, source }`
143
+
144
+ ### Form field events
145
+ - `formField.add :: { formField }`
146
+ - `formField.remove :: { formField }`
147
+ - `formField.updateId :: { formField, newId }`
148
+
149
+
150
+ ## License
151
+
152
+ Use under the terms of the [bpmn.io license](http://bpmn.io/license).
package/dist/index.cjs CHANGED
@@ -1410,6 +1410,7 @@ function PaletteEntry(props) {
1410
1410
  }
1411
1411
  };
1412
1412
  return jsxRuntime.jsxs("button", {
1413
+ type: "button",
1413
1414
  class: "fjs-palette-field fjs-drag-copy fjs-no-drop",
1414
1415
  "data-field-type": type,
1415
1416
  title: `Create ${getIndefiniteArticle(type)} ${label} element`,
@@ -1502,6 +1503,7 @@ function Palette(props) {
1502
1503
  value: searchTerm,
1503
1504
  onInput: handleInput
1504
1505
  }), searchTerm && jsxRuntime.jsx("button", {
1506
+ type: "button",
1505
1507
  title: "Clear content",
1506
1508
  class: "fjs-palette-search-clear",
1507
1509
  onClick: handleClear,
@@ -2252,6 +2254,7 @@ function Element$1(props) {
2252
2254
  field: field
2253
2255
  }), jsxRuntime.jsx(ContextPad, {
2254
2256
  children: selection.isSelected(field) && field.type !== 'default' ? jsxRuntime.jsx("button", {
2257
+ type: "button",
2255
2258
  title: getRemoveButtonTitle(field, formFields),
2256
2259
  class: "fjs-context-pad-item",
2257
2260
  onClick: onRemove,
@@ -9724,7 +9727,7 @@ function Disabled(props) {
9724
9727
  getValue,
9725
9728
  id,
9726
9729
  label: 'Disabled',
9727
- tooltip: 'Field cannot be edited by the end-user, and the data is not submitted.',
9730
+ tooltip: 'Field cannot be edited by the end-user, and the data is not submitted. Takes precedence over read only.',
9728
9731
  inline: true,
9729
9732
  setValue
9730
9733
  });
@@ -10363,11 +10366,10 @@ function Height(props) {
10363
10366
  description,
10364
10367
  editField,
10365
10368
  field,
10366
- id,
10367
- defaultValue = 60 // default value for spacer
10369
+ id
10368
10370
  } = props;
10369
10371
  const debounce = useService('debounce');
10370
- const getValue = e => minDash.get(field, ['height'], defaultValue);
10372
+ const getValue = e => minDash.get(field, ['height'], null);
10371
10373
  const setValue = (value, error) => {
10372
10374
  if (error) {
10373
10375
  return;
@@ -10394,7 +10396,7 @@ function Height(props) {
10394
10396
  */
10395
10397
  const validate$7 = value => {
10396
10398
  if (typeof value !== 'number') {
10397
- return null;
10399
+ return 'A number is required.';
10398
10400
  }
10399
10401
  if (!Number.isInteger(value)) {
10400
10402
  return 'Should be an integer.';
@@ -10407,7 +10409,6 @@ const validate$7 = value => {
10407
10409
  function IFrameHeightEntry(props) {
10408
10410
  return [...HeightEntry({
10409
10411
  ...props,
10410
- defaultValue: 300,
10411
10412
  description: 'Height of the container in pixels.',
10412
10413
  isDefaultVisible: field => field.type === 'iframe'
10413
10414
  })];
@@ -10644,7 +10645,7 @@ function Content(props) {
10644
10645
 
10645
10646
  const description = jsxRuntime.jsxs(jsxRuntime.Fragment, {
10646
10647
  children: ["Supports HTML, styling, and templating. Styles are automatically scoped to the HTML component. ", jsxRuntime.jsx("a", {
10647
- href: "https://docs.camunda.io/docs/components/modeler/forms/form-element-library/forms-element-library-html/",
10648
+ href: "https://docs.camunda.io/docs/next/components/modeler/forms/form-element-library/forms-element-library-html/",
10648
10649
  target: "_blank",
10649
10650
  children: "Learn more"
10650
10651
  })]
@@ -11601,15 +11602,20 @@ function ReadonlyEntry(props) {
11601
11602
  editField,
11602
11603
  field
11603
11604
  } = props;
11605
+ const {
11606
+ disabled
11607
+ } = field;
11604
11608
  const entries = [];
11605
- entries.push({
11606
- id: 'readonly',
11607
- component: Readonly,
11608
- editField: editField,
11609
- field: field,
11610
- isEdited: isEdited$6,
11611
- isDefaultVisible: field => INPUTS.includes(field.type)
11612
- });
11609
+ if (!disabled) {
11610
+ entries.push({
11611
+ id: 'readonly',
11612
+ component: Readonly,
11613
+ editField: editField,
11614
+ field: field,
11615
+ isEdited: isEdited$6,
11616
+ isDefaultVisible: field => INPUTS.includes(field.type)
11617
+ });
11618
+ }
11613
11619
  return entries;
11614
11620
  }
11615
11621
  function Readonly(props) {