@ekzo-dev/bootstrap-addons 5.3.4 → 5.3.5
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekzo-dev/bootstrap-addons",
|
|
3
3
|
"description": "Aurelia Bootstrap additional component",
|
|
4
|
-
"version": "5.3.
|
|
4
|
+
"version": "5.3.5",
|
|
5
5
|
"homepage": "https://github.com/ekzo-dev/aurelia-components/tree/main/packages/bootstrap-addons",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"@types/json-schema": "^7.0.14",
|
|
17
17
|
"@js-temporal/polyfill": "^0.5.1",
|
|
18
18
|
"ajv": "^8.17.1",
|
|
19
|
-
"ajv-formats": "^3.0.1"
|
|
19
|
+
"ajv-formats": "^3.0.1",
|
|
20
|
+
"json-schema-library": "^10.2.1"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
23
|
"aurelia": "^2.0.0-beta.25",
|
|
@@ -20,12 +20,12 @@ import type {
|
|
|
20
20
|
import { coerceBoolean } from '@ekzo-dev/toolkit';
|
|
21
21
|
import { JsonEditor } from '@ekzo-dev/vanilla-jsoneditor';
|
|
22
22
|
import { faUpRightAndDownLeftFromCenter } from '@fortawesome/free-solid-svg-icons/faUpRightAndDownLeftFromCenter';
|
|
23
|
-
import Ajv, { ErrorObject, Options } from 'ajv';
|
|
23
|
+
import Ajv, { ErrorObject, Options, ValidateFunction } from 'ajv';
|
|
24
24
|
import Ajv2019 from 'ajv/dist/2019';
|
|
25
25
|
import Ajv2020 from 'ajv/dist/2020';
|
|
26
26
|
import addFormats from 'ajv-formats';
|
|
27
27
|
import { bindable, BindingMode, customElement } from 'aurelia';
|
|
28
|
-
import {
|
|
28
|
+
import { parsePath } from 'immutable-json-patch';
|
|
29
29
|
|
|
30
30
|
const patternMap: Record<string, string> = {
|
|
31
31
|
'^[A-Za-z_][-A-Za-z0-9._]*$': '^[A-Za-z_][\\-A-Za-z0-9._]*$',
|
|
@@ -76,12 +76,13 @@ export class BsJsonInput {
|
|
|
76
76
|
|
|
77
77
|
onRenderValue = (props: RenderValueProps): RenderValueComponentDescription[] => {
|
|
78
78
|
let result: RenderValueComponentDescription[] | null;
|
|
79
|
-
const { jsonSchema } = this;
|
|
79
|
+
// const { jsonSchema } = this;
|
|
80
80
|
const { editorModule } = this.editorComponent;
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
// TODO: this does not support bundled schemas and complex refs. So need to make own implementation later
|
|
83
|
+
// if (jsonSchema && typeof jsonSchema === 'object') {
|
|
84
|
+
// result = editorModule.renderJSONSchemaEnum(props, jsonSchema, this.#getSchemaDefinitions(jsonSchema));
|
|
85
|
+
// }
|
|
85
86
|
|
|
86
87
|
return result ?? editorModule.renderValue(props);
|
|
87
88
|
};
|
|
@@ -156,15 +157,17 @@ export class BsJsonInput {
|
|
|
156
157
|
const ajv = rawThis.#initAjv(jsonSchema.$schema as string, ajvOptions);
|
|
157
158
|
|
|
158
159
|
addFormats(ajv);
|
|
159
|
-
|
|
160
|
+
let validate: ValidateFunction;
|
|
160
161
|
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
try {
|
|
163
|
+
validate = ajv.compile(rawJsonSchema);
|
|
164
|
+
} catch (e) {
|
|
165
|
+
console.error('Validator compilation error.', e);
|
|
163
166
|
}
|
|
164
167
|
|
|
165
168
|
return (json: unknown): ValidationError[] => {
|
|
166
169
|
// do not validate empty documents
|
|
167
|
-
if (json === undefined) return [];
|
|
170
|
+
if (json === undefined || !validate) return [];
|
|
168
171
|
|
|
169
172
|
validate(json);
|
|
170
173
|
|
|
@@ -236,7 +239,7 @@ export class BsJsonInput {
|
|
|
236
239
|
this.input.setCustomValidity(errors?.length ? message : '');
|
|
237
240
|
|
|
238
241
|
return (errors || []).map((error) => ({
|
|
239
|
-
path: parsePath(json
|
|
242
|
+
path: parsePath(json, error.instancePath),
|
|
240
243
|
message: error.message || 'Unknown error',
|
|
241
244
|
severity: 'warning' as ValidationSeverity,
|
|
242
245
|
}));
|