@bpmn-io/form-js-viewer 1.7.2 → 1.7.3

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,189 +1,189 @@
1
- # @bpmn-io/form-js-viewer
2
-
3
- This library exports a form viewer for viewing and submitting forms. Use [our editor](../form-js-editor) to create and edit forms.
4
-
5
-
6
- ## Installation
7
-
8
- ```
9
- npm install @bpmn-io/form-js-viewer
10
- ```
11
-
12
-
13
- ## Usage
14
-
15
- ```javascript
16
- import { Form } from '@bpmn-io/form-js-viewer';
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 data = {
32
- creditor: 'John Doe Company'
33
- };
34
-
35
- const form = new Form({
36
- container: document.querySelector('#form')
37
- });
38
-
39
- await form.importSchema(schema, data);
40
-
41
- // add event listeners
42
- form.on('submit', event => {
43
- console.log('Form <submit>', event);
44
- });
45
-
46
- // provide a priority to event listeners
47
- form.on('changed', 500, event => {
48
- console.log('Form <changed>', event);
49
- });
50
- ```
51
-
52
- Check out [a full example](https://github.com/bpmn-io/form-js-examples).
53
-
54
-
55
- ## Styling
56
-
57
- For proper styling include the `form-js.css` stylesheet and font used:
58
-
59
- ```html
60
- <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,600;1,400&display=swap" rel="stylesheet">
61
-
62
- <link href="https://unpkg.com/@bpmn-io/form-js/dist/assets/form-js.css" rel="stylesheet">
63
- ```
64
-
65
-
66
- ## API
67
-
68
- ### `Form`
69
-
70
- Create a new form with options `{ container?: HTMLElement }`.
71
-
72
- ```javascript
73
- import { Form } from '@bpmn-io/form-js-viewer';
74
-
75
- const form = new Form({
76
- container: document.querySelector('#form')
77
- });
78
- ```
79
-
80
-
81
- ### `Form#importSchema(schema: Schema, data?: Data) => Promise<Result, Error>`
82
-
83
- Display a form represented via a form schema and the optional data.
84
-
85
- ```javascript
86
- try {
87
- await form.importSchema(schema);
88
- } catch (err) {
89
- console.log('importing form failed', err);
90
- }
91
- ```
92
-
93
-
94
- ### `Form#submit() => { data: Data, errors: Errors }`
95
-
96
- Submit a form programatically.
97
-
98
- ```javascript
99
- const {
100
- data,
101
- errors
102
- } = form.submit();
103
-
104
- if (Object.keys(errors).length) {
105
- console.error('Form submitted with errors', errors);
106
- }
107
- ```
108
-
109
-
110
- ### `Form#validate() => Errors`
111
-
112
- Validate a form programatically.
113
-
114
- ```javascript
115
- const errors = form.validate();
116
-
117
- if (Object.keys(errors).length) {
118
- console.error('Form has errors', errors);
119
- }
120
- ```
121
-
122
-
123
- ### `Form#reset() => void`
124
-
125
- Reset a form programatically.
126
-
127
-
128
- ### `Form#setProperty(key, value) => void`
129
-
130
- Set a form property such as `readOnly`.
131
-
132
-
133
- ### `Form#attachTo(parentNode: HTMLElement) => void`
134
-
135
-
136
- Attach the form to a parent node.
137
-
138
-
139
- ### `Form#detach() => void`
140
-
141
-
142
- Detach the form from its parent node.
143
-
144
-
145
- ### `Form#on(event, fn) => void`
146
-
147
- Subscribe to an [event](#events).
148
-
149
-
150
- ### `Form#destroy() => void`
151
-
152
- Remove form from the document.
153
-
154
-
155
- ## Events
156
-
157
- ### `changed :: { data, errors }`
158
- Fired off every time there is a form state change.
159
-
160
- ### `submit :: { data, errors }`
161
- Fired off on form submission.
162
-
163
- ### `import.done :: { error, warnings }`
164
- Fired whenever a schema has finished importing, whether it succeeds or fails.
165
-
166
- ### Layouting events
167
- - `form.layoutCleared`
168
- - `form.layoutCalculated :: { rows }`
169
-
170
- ### Lifecycle Events
171
- - `detach`
172
- - `attach`
173
- - `form.init`
174
- - `form.clear`
175
- - `form.destroy`
176
- - `diagram.clear`
177
- - `diagram.destroy`
178
-
179
- ### Formfield events
180
- - `formField.add :: { formField }`
181
- - `formField.remove :: { formField }`
182
- - `formField.focus :: { formField }`
183
- - `formField.blur :: { formField }`
184
- - `formField.search :: { formField, value }`
185
-
186
-
187
- ## License
188
-
189
- Use under the terms of the [bpmn.io license](http://bpmn.io/license).
1
+ # @bpmn-io/form-js-viewer
2
+
3
+ This library exports a form viewer for viewing and submitting forms. Use [our editor](../form-js-editor) to create and edit forms.
4
+
5
+
6
+ ## Installation
7
+
8
+ ```
9
+ npm install @bpmn-io/form-js-viewer
10
+ ```
11
+
12
+
13
+ ## Usage
14
+
15
+ ```javascript
16
+ import { Form } from '@bpmn-io/form-js-viewer';
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 data = {
32
+ creditor: 'John Doe Company'
33
+ };
34
+
35
+ const form = new Form({
36
+ container: document.querySelector('#form')
37
+ });
38
+
39
+ await form.importSchema(schema, data);
40
+
41
+ // add event listeners
42
+ form.on('submit', event => {
43
+ console.log('Form <submit>', event);
44
+ });
45
+
46
+ // provide a priority to event listeners
47
+ form.on('changed', 500, event => {
48
+ console.log('Form <changed>', event);
49
+ });
50
+ ```
51
+
52
+ Check out [a full example](https://github.com/bpmn-io/form-js-examples).
53
+
54
+
55
+ ## Styling
56
+
57
+ For proper styling include the `form-js.css` stylesheet and font used:
58
+
59
+ ```html
60
+ <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,600;1,400&display=swap" rel="stylesheet">
61
+
62
+ <link href="https://unpkg.com/@bpmn-io/form-js/dist/assets/form-js.css" rel="stylesheet">
63
+ ```
64
+
65
+
66
+ ## API
67
+
68
+ ### `Form`
69
+
70
+ Create a new form with options `{ container?: HTMLElement }`.
71
+
72
+ ```javascript
73
+ import { Form } from '@bpmn-io/form-js-viewer';
74
+
75
+ const form = new Form({
76
+ container: document.querySelector('#form')
77
+ });
78
+ ```
79
+
80
+
81
+ ### `Form#importSchema(schema: Schema, data?: Data) => Promise<Result, Error>`
82
+
83
+ Display a form represented via a form schema and the optional data.
84
+
85
+ ```javascript
86
+ try {
87
+ await form.importSchema(schema);
88
+ } catch (err) {
89
+ console.log('importing form failed', err);
90
+ }
91
+ ```
92
+
93
+
94
+ ### `Form#submit() => { data: Data, errors: Errors }`
95
+
96
+ Submit a form programatically.
97
+
98
+ ```javascript
99
+ const {
100
+ data,
101
+ errors
102
+ } = form.submit();
103
+
104
+ if (Object.keys(errors).length) {
105
+ console.error('Form submitted with errors', errors);
106
+ }
107
+ ```
108
+
109
+
110
+ ### `Form#validate() => Errors`
111
+
112
+ Validate a form programatically.
113
+
114
+ ```javascript
115
+ const errors = form.validate();
116
+
117
+ if (Object.keys(errors).length) {
118
+ console.error('Form has errors', errors);
119
+ }
120
+ ```
121
+
122
+
123
+ ### `Form#reset() => void`
124
+
125
+ Reset a form programatically.
126
+
127
+
128
+ ### `Form#setProperty(key, value) => void`
129
+
130
+ Set a form property such as `readOnly`.
131
+
132
+
133
+ ### `Form#attachTo(parentNode: HTMLElement) => void`
134
+
135
+
136
+ Attach the form to a parent node.
137
+
138
+
139
+ ### `Form#detach() => void`
140
+
141
+
142
+ Detach the form from its parent node.
143
+
144
+
145
+ ### `Form#on(event, fn) => void`
146
+
147
+ Subscribe to an [event](#events).
148
+
149
+
150
+ ### `Form#destroy() => void`
151
+
152
+ Remove form from the document.
153
+
154
+
155
+ ## Events
156
+
157
+ ### `changed :: { data, errors }`
158
+ Fired off every time there is a form state change.
159
+
160
+ ### `submit :: { data, errors }`
161
+ Fired off on form submission.
162
+
163
+ ### `import.done :: { error, warnings }`
164
+ Fired whenever a schema has finished importing, whether it succeeds or fails.
165
+
166
+ ### Layouting events
167
+ - `form.layoutCleared`
168
+ - `form.layoutCalculated :: { rows }`
169
+
170
+ ### Lifecycle Events
171
+ - `detach`
172
+ - `attach`
173
+ - `form.init`
174
+ - `form.clear`
175
+ - `form.destroy`
176
+ - `diagram.clear`
177
+ - `diagram.destroy`
178
+
179
+ ### Formfield events
180
+ - `formField.add :: { formField }`
181
+ - `formField.remove :: { formField }`
182
+ - `formField.focus :: { formField }`
183
+ - `formField.blur :: { formField }`
184
+ - `formField.search :: { formField, value }`
185
+
186
+
187
+ ## License
188
+
189
+ Use under the terms of the [bpmn.io license](http://bpmn.io/license).
package/dist/index.cjs CHANGED
@@ -6644,9 +6644,9 @@ class RepeatRenderManager {
6644
6644
  };
6645
6645
  const parentExpressionContextInfo = hooks.useContext(LocalExpressionContext);
6646
6646
  return jsxRuntime.jsx(jsxRuntime.Fragment, {
6647
- children: displayValues.map((value, index) => jsxRuntime.jsx(RepetitionScaffold, {
6648
- index: index,
6649
- value: value,
6647
+ children: displayValues.map((itemValue, itemIndex) => jsxRuntime.jsx(RepetitionScaffold, {
6648
+ itemIndex: itemIndex,
6649
+ itemValue: itemValue,
6650
6650
  parentExpressionContextInfo: parentExpressionContextInfo,
6651
6651
  repeaterField: repeaterField,
6652
6652
  RowsRenderer: RowsRenderer,
@@ -6654,7 +6654,7 @@ class RepeatRenderManager {
6654
6654
  onDeleteItem: onDeleteItem,
6655
6655
  showRemove: showRemove,
6656
6656
  ...restProps
6657
- }, index))
6657
+ }, itemIndex))
6658
6658
  });
6659
6659
  }
6660
6660
  RepeatFooter(props) {
@@ -6751,8 +6751,8 @@ class RepeatRenderManager {
6751
6751
  * Individual repetition of a repeated field and context scaffolding.
6752
6752
  *
6753
6753
  * @param {Object} props
6754
- * @param {number} props.index
6755
- * @param {Object} props.value
6754
+ * @param {number} props.itemIndex
6755
+ * @param {Object} props.itemValue
6756
6756
  * @param {Object} props.parentExpressionContextInfo
6757
6757
  * @param {Object} props.repeaterField
6758
6758
  * @param {Function} props.RowsRenderer
@@ -6763,8 +6763,8 @@ class RepeatRenderManager {
6763
6763
 
6764
6764
  const RepetitionScaffold = props => {
6765
6765
  const {
6766
- index,
6767
- value,
6766
+ itemIndex,
6767
+ itemValue,
6768
6768
  parentExpressionContextInfo,
6769
6769
  repeaterField,
6770
6770
  RowsRenderer,
@@ -6777,15 +6777,15 @@ const RepetitionScaffold = props => {
6777
6777
  ...restProps,
6778
6778
  indexes: {
6779
6779
  ...(indexes || {}),
6780
- [repeaterField.id]: index
6780
+ [repeaterField.id]: itemIndex
6781
6781
  }
6782
- }), [index, indexes, repeaterField.id, restProps]);
6782
+ }), [itemIndex, indexes, repeaterField.id, restProps]);
6783
6783
  const localExpressionContextInfo = hooks.useMemo(() => ({
6784
6784
  data: parentExpressionContextInfo.data,
6785
- this: value,
6785
+ this: itemValue,
6786
6786
  parent: buildExpressionContext(parentExpressionContextInfo),
6787
- i: [...parentExpressionContextInfo.i, index + 1]
6788
- }), [index, parentExpressionContextInfo, value]);
6787
+ i: [...parentExpressionContextInfo.i, itemIndex + 1]
6788
+ }), [itemIndex, parentExpressionContextInfo, itemValue]);
6789
6789
  return !showRemove ? jsxRuntime.jsx(LocalExpressionContext.Provider, {
6790
6790
  value: localExpressionContextInfo,
6791
6791
  children: jsxRuntime.jsx(RowsRenderer, {
@@ -6804,8 +6804,8 @@ const RepetitionScaffold = props => {
6804
6804
  }), jsxRuntime.jsx("button", {
6805
6805
  type: "button",
6806
6806
  class: "fjs-repeat-row-remove",
6807
- "aria-label": `Remove list item ${index + 1}`,
6808
- onClick: () => onDeleteItem(index),
6807
+ "aria-label": `Remove list item ${itemIndex + 1}`,
6808
+ onClick: () => onDeleteItem(itemIndex),
6809
6809
  children: jsxRuntime.jsx("div", {
6810
6810
  class: "fjs-repeat-row-remove-icon-container",
6811
6811
  children: jsxRuntime.jsx(DeleteSvg, {})