@jsonforms/core 3.2.1 → 3.3.0-alpha.0

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.
@@ -71,6 +71,13 @@ export declare const uiTypeIs: (expected: string) => Tester;
71
71
  * @param {any} optionValue the expected value of the option
72
72
  */
73
73
  export declare const optionIs: (optionName: string, optionValue: any) => Tester;
74
+ /**
75
+ * Checks whether the given UI schema has an option with the given
76
+ * name. If no options property is set, returns false.
77
+ *
78
+ * @param {string} optionName the name of the option to check
79
+ */
80
+ export declare const hasOption: (optionName: string) => Tester;
74
81
  /**
75
82
  * Only applicable for Controls.
76
83
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonforms/core",
3
- "version": "3.2.1",
3
+ "version": "3.3.0-alpha.0",
4
4
  "description": "Core module of JSON Forms",
5
5
  "repository": "https://github.com/eclipsesource/jsonforms",
6
6
  "bugs": "https://github.com/eclipsesource/jsonforms/issues",
@@ -68,7 +68,7 @@
68
68
  "@typescript-eslint/parser": "^5.54.1",
69
69
  "ava": "~2.4.0",
70
70
  "document-register-element": "^1.14.3",
71
- "eslint": "^7.32.0",
71
+ "eslint": "^8.56.0",
72
72
  "eslint-config-prettier": "^8.7.0",
73
73
  "eslint-plugin-import": "^2.27.5",
74
74
  "eslint-plugin-prettier": "^4.2.1",
@@ -31,6 +31,7 @@ import isArray from 'lodash/isArray';
31
31
  import reduce from 'lodash/reduce';
32
32
  import toPairs from 'lodash/toPairs';
33
33
  import includes from 'lodash/includes';
34
+ import isUndefined from 'lodash/isUndefined';
34
35
  import type {
35
36
  Categorization,
36
37
  ControlElement,
@@ -215,6 +216,23 @@ export const optionIs =
215
216
  return !isEmpty(options) && options[optionName] === optionValue;
216
217
  };
217
218
 
219
+ /**
220
+ * Checks whether the given UI schema has an option with the given
221
+ * name. If no options property is set, returns false.
222
+ *
223
+ * @param {string} optionName the name of the option to check
224
+ */
225
+ export const hasOption =
226
+ (optionName: string): Tester =>
227
+ (uischema: UISchemaElement): boolean => {
228
+ if (isEmpty(uischema)) {
229
+ return false;
230
+ }
231
+
232
+ const options = uischema.options;
233
+ return !isEmpty(options) && !isUndefined(options[optionName]);
234
+ };
235
+
218
236
  /**
219
237
  * Only applicable for Controls.
220
238
  *