@bpmn-io/form-js-editor 1.8.8 → 1.9.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/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/dist/index.cjs CHANGED
@@ -9030,83 +9030,64 @@ function hasIntegerPathSegment(path) {
9030
9030
  return path.split('.').some(segment => /^\d+$/.test(segment));
9031
9031
  }
9032
9032
 
9033
- function useService(type, strict) {
9033
+ const headerlessTypes = ['spacer', 'separator', 'expression', 'html'];
9034
+ function getPropertiesPanelHeaderProvider(options = {}) {
9034
9035
  const {
9035
- getService
9036
- } = hooks.useContext(FormPropertiesPanelContext);
9037
- return getService(type, strict);
9038
- }
9039
-
9040
- /**
9041
- * Retrieve list of variables from the form schema.
9042
- *
9043
- * @returns { string[] } list of variables used in form schema
9044
- */
9045
- function useVariables() {
9046
- const form = useService('formEditor');
9047
- const schema = form.getSchema();
9048
- return formJsViewer.getSchemaVariables(schema);
9036
+ getDocumentationRef,
9037
+ formFields
9038
+ } = options;
9039
+ return {
9040
+ getElementLabel: field => {
9041
+ const {
9042
+ type
9043
+ } = field;
9044
+ if (headerlessTypes.includes(type)) {
9045
+ return '';
9046
+ }
9047
+ if (type === 'text') {
9048
+ return textToLabel(field.text);
9049
+ }
9050
+ if (type === 'image') {
9051
+ return field.alt;
9052
+ }
9053
+ if (type === 'default') {
9054
+ return field.id;
9055
+ }
9056
+ return field.label;
9057
+ },
9058
+ getElementIcon: field => {
9059
+ const {
9060
+ type
9061
+ } = field;
9062
+ const fieldDefinition = formFields.get(type).config;
9063
+ const Icon = fieldDefinition.icon || formJsViewer.iconsByType(type);
9064
+ if (Icon) {
9065
+ return () => jsxRuntime.jsx(Icon, {
9066
+ width: "36",
9067
+ height: "36",
9068
+ viewBox: "0 0 54 54"
9069
+ });
9070
+ } else if (fieldDefinition.iconUrl) {
9071
+ return getPaletteIcon({
9072
+ iconUrl: fieldDefinition.iconUrl,
9073
+ label: fieldDefinition.label
9074
+ });
9075
+ }
9076
+ },
9077
+ getTypeLabel: field => {
9078
+ const {
9079
+ type
9080
+ } = field;
9081
+ if (type === 'default') {
9082
+ return 'Form';
9083
+ }
9084
+ const fieldDefinition = formFields.get(type).config;
9085
+ return fieldDefinition.label || type;
9086
+ },
9087
+ getDocumentationRef
9088
+ };
9049
9089
  }
9050
9090
 
9051
- const headerlessTypes = ['spacer', 'separator', 'expression', 'html'];
9052
- const PropertiesPanelHeaderProvider = {
9053
- getElementLabel: field => {
9054
- const {
9055
- type
9056
- } = field;
9057
- if (headerlessTypes.includes(type)) {
9058
- return '';
9059
- }
9060
- if (type === 'text') {
9061
- return textToLabel(field.text);
9062
- }
9063
- if (type === 'image') {
9064
- return field.alt;
9065
- }
9066
- if (type === 'default') {
9067
- return field.id;
9068
- }
9069
- return field.label;
9070
- },
9071
- getElementIcon: field => {
9072
- const {
9073
- type
9074
- } = field;
9075
-
9076
- // @Note: We know that we are inside the properties panel context,
9077
- // so we can savely use the hook here.
9078
- // eslint-disable-next-line react-hooks/rules-of-hooks
9079
- const fieldDefinition = useService('formFields').get(type).config;
9080
- const Icon = fieldDefinition.icon || formJsViewer.iconsByType(type);
9081
- if (Icon) {
9082
- return () => jsxRuntime.jsx(Icon, {
9083
- width: "36",
9084
- height: "36",
9085
- viewBox: "0 0 54 54"
9086
- });
9087
- } else if (fieldDefinition.iconUrl) {
9088
- return getPaletteIcon({
9089
- iconUrl: fieldDefinition.iconUrl,
9090
- label: fieldDefinition.label
9091
- });
9092
- }
9093
- },
9094
- getTypeLabel: field => {
9095
- const {
9096
- type
9097
- } = field;
9098
- if (type === 'default') {
9099
- return 'Form';
9100
- }
9101
-
9102
- // @Note: We know that we are inside the properties panel context,
9103
- // so we can savely use the hook here.
9104
- // eslint-disable-next-line react-hooks/rules-of-hooks
9105
- const fieldDefinition = useService('formFields').get(type).config;
9106
- return fieldDefinition.label || type;
9107
- }
9108
- };
9109
-
9110
9091
  /**
9111
9092
  * Provide placeholders for empty and multiple state.
9112
9093
  */
@@ -9123,6 +9104,7 @@ const PropertiesPanelPlaceholderProvider = {
9123
9104
  }
9124
9105
  };
9125
9106
 
9107
+ const EMPTY = {};
9126
9108
  function PropertiesPanel(props) {
9127
9109
  const {
9128
9110
  eventBus,
@@ -9132,7 +9114,7 @@ function PropertiesPanel(props) {
9132
9114
  const formEditor = injector.get('formEditor');
9133
9115
  const modeling = injector.get('modeling');
9134
9116
  const selectionModule = injector.get('selection');
9135
- const propertiesPanelConfig = injector.get('config.propertiesPanel') || {};
9117
+ const propertiesPanelConfig = injector.get('config.propertiesPanel') || EMPTY;
9136
9118
  const {
9137
9119
  feelPopupContainer
9138
9120
  } = propertiesPanelConfig;
@@ -9186,6 +9168,11 @@ function PropertiesPanel(props) {
9186
9168
  return updater(groups);
9187
9169
  }, []);
9188
9170
  }, [providers, selectedFormField, editField]);
9171
+ const formFields = getService('formFields');
9172
+ const PropertiesPanelHeaderProvider = hooks.useMemo(() => getPropertiesPanelHeaderProvider({
9173
+ getDocumentationRef: propertiesPanelConfig.getDocumentationRef,
9174
+ formFields
9175
+ }), [formFields, propertiesPanelConfig]);
9189
9176
  return jsxRuntime.jsx("div", {
9190
9177
  class: "fjs-properties-panel",
9191
9178
  "data-field": selectedFormField && selectedFormField.id,
@@ -9359,6 +9346,24 @@ function Action(props) {
9359
9346
  });
9360
9347
  }
9361
9348
 
9349
+ function useService(type, strict) {
9350
+ const {
9351
+ getService
9352
+ } = hooks.useContext(FormPropertiesPanelContext);
9353
+ return getService(type, strict);
9354
+ }
9355
+
9356
+ /**
9357
+ * Retrieve list of variables from the form schema.
9358
+ *
9359
+ * @returns { string[] } list of variables used in form schema
9360
+ */
9361
+ function useVariables() {
9362
+ const form = useService('formEditor');
9363
+ const schema = form.getSchema();
9364
+ return formJsViewer.getSchemaVariables(schema);
9365
+ }
9366
+
9362
9367
  function AltTextEntry(props) {
9363
9368
  const {
9364
9369
  editField,