@ekzo-dev/bootstrap-addons 5.3.10 → 5.3.12
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.12",
|
|
5
5
|
"homepage": "https://github.com/ekzo-dev/aurelia-components/tree/main/packages/bootstrap-addons",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@ekzo-dev/bootstrap": "~5.3.0",
|
|
13
|
-
"@ekzo-dev/vanilla-jsoneditor": "
|
|
13
|
+
"@ekzo-dev/vanilla-jsoneditor": "~3.11.0",
|
|
14
14
|
"@ekzo-dev/toolkit": "^1.2.4",
|
|
15
|
-
"@fortawesome/free-solid-svg-icons": "^
|
|
15
|
+
"@fortawesome/free-solid-svg-icons": "^7.0.1",
|
|
16
16
|
"@types/json-schema": "^7.0.14",
|
|
17
17
|
"@js-temporal/polyfill": "^0.5.1",
|
|
18
18
|
"ajv": "^8.17.1",
|
|
19
19
|
"ajv-formats": "^3.0.1",
|
|
20
|
-
"json-schema-library": "^10.5.
|
|
20
|
+
"json-schema-library": "^10.5.2"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"aurelia": "^2.0.0-rc.0",
|
|
24
24
|
"bootstrap": "~5.3.7",
|
|
25
25
|
"@popperjs/core": "^2.11.8",
|
|
26
|
-
"vanilla-jsoneditor": "~3.
|
|
26
|
+
"vanilla-jsoneditor": "~3.11.0",
|
|
27
27
|
"immutable-json-patch": "^6.0.1"
|
|
28
28
|
},
|
|
29
29
|
"main": "src/index.ts",
|
|
@@ -23,20 +23,20 @@ type DurationLabels = {
|
|
|
23
23
|
export class BsDurationInput extends BaseField implements EventListenerObject {
|
|
24
24
|
@bindable({ mode: BindingMode.twoWay })
|
|
25
25
|
get value(): string {
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
hours,
|
|
34
|
-
minutes,
|
|
35
|
-
seconds,
|
|
36
|
-
}).toString();
|
|
26
|
+
const { duration } = this;
|
|
27
|
+
|
|
28
|
+
if (Object.values(duration).every((v) => v == null || v.toString() === '')) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return Temporal.Duration.from(duration).toString();
|
|
37
33
|
}
|
|
38
34
|
set value(value: unknown) {
|
|
39
|
-
|
|
35
|
+
if (value == null || value === '') {
|
|
36
|
+
this.duration = {};
|
|
37
|
+
} else {
|
|
38
|
+
this._parseDuration(value.toString());
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
@bindable()
|
|
@@ -97,15 +97,9 @@ export class BsDurationInput extends BaseField implements EventListenerObject {
|
|
|
97
97
|
this.controls.item(0).focus();
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
private _parseDuration(value:
|
|
101
|
-
if (value == null || value === '') {
|
|
102
|
-
this.duration = {};
|
|
103
|
-
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
100
|
+
private _parseDuration(value: string) {
|
|
107
101
|
try {
|
|
108
|
-
const duration = Temporal.Duration.from(value
|
|
102
|
+
const duration = Temporal.Duration.from(value);
|
|
109
103
|
|
|
110
104
|
this.duration = {
|
|
111
105
|
years: duration.years,
|
|
@@ -17,16 +17,17 @@ import type {
|
|
|
17
17
|
Validator,
|
|
18
18
|
} from 'vanilla-jsoneditor';
|
|
19
19
|
|
|
20
|
+
import { ProxyObservable } from '@aurelia/runtime';
|
|
20
21
|
import { coerceBoolean } from '@ekzo-dev/toolkit';
|
|
21
22
|
import { JsonEditor } from '@ekzo-dev/vanilla-jsoneditor';
|
|
22
23
|
import { faUpRightAndDownLeftFromCenter } from '@fortawesome/free-solid-svg-icons/faUpRightAndDownLeftFromCenter';
|
|
23
|
-
import Ajv, { ErrorObject, Options
|
|
24
|
+
import Ajv, { ErrorObject, Options } from 'ajv';
|
|
24
25
|
import Ajv2019 from 'ajv/dist/2019';
|
|
25
26
|
import Ajv2020 from 'ajv/dist/2020';
|
|
26
27
|
import addFormats from 'ajv-formats';
|
|
27
28
|
import { bindable, BindingMode, customElement } from 'aurelia';
|
|
28
29
|
import { parsePath } from 'immutable-json-patch';
|
|
29
|
-
import { compileSchema, JsonError,
|
|
30
|
+
import { CompileOptions, compileSchema, JsonError, SchemaNode } from 'json-schema-library';
|
|
30
31
|
|
|
31
32
|
const patternMap: Record<string, string> = {
|
|
32
33
|
'^[A-Za-z_][-A-Za-z0-9._]*$': '^[A-Za-z_][\\-A-Za-z0-9._]*$',
|
|
@@ -48,11 +49,11 @@ export class BsJsonInput {
|
|
|
48
49
|
@bindable(coerceBoolean)
|
|
49
50
|
disabled: boolean = false;
|
|
50
51
|
|
|
51
|
-
@bindable({ set: (v) => (v === '' || v === true || v === 'true' ? true : v) })
|
|
52
|
-
jsonSchema?: JSONSchema | boolean;
|
|
52
|
+
@bindable({ set: (v: BsJsonInput['jsonSchema'] | string) => (v === '' || v === true || v === 'true' ? true : v) })
|
|
53
|
+
jsonSchema?: JSONSchema | SchemaNode | boolean;
|
|
53
54
|
|
|
54
55
|
@bindable()
|
|
55
|
-
|
|
56
|
+
validatorOptions?: CompileOptions;
|
|
56
57
|
|
|
57
58
|
@bindable()
|
|
58
59
|
jsonEditorOptions: JSONEditorPropsOptional = {};
|
|
@@ -148,52 +149,24 @@ export class BsJsonInput {
|
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
get validator(): Validator | undefined {
|
|
151
|
-
const { schemaVersion, disabled,
|
|
152
|
-
|
|
153
|
-
const rawThis = this['__raw__'] as BsJsonInput;
|
|
154
|
-
// use jsonSchema from raw object to pass original (non-proxied) object to AJV
|
|
155
|
-
const { jsonSchema: rawJsonSchema } = rawThis;
|
|
152
|
+
const { schemaVersion, disabled, jsonSchema } = this;
|
|
153
|
+
const rawThis = ProxyObservable.getRaw<BsJsonInput>(this);
|
|
156
154
|
|
|
157
|
-
if (
|
|
158
|
-
const ajv = rawThis.#initAjv(jsonSchema.$schema as string, ajvOptions);
|
|
155
|
+
if (disabled) return;
|
|
159
156
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
let schema: SchemaNode;
|
|
163
|
-
|
|
164
|
-
try {
|
|
165
|
-
schema = compileSchema(rawJsonSchema as JsonSchema);
|
|
166
|
-
} catch (e) {
|
|
167
|
-
console.error('json-schema-library validator compilation error', e);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
try {
|
|
171
|
-
validate = ajv.compile(rawJsonSchema);
|
|
172
|
-
} catch (e) {
|
|
173
|
-
console.error('AJV validator compilation error', e);
|
|
174
|
-
}
|
|
157
|
+
if (jsonSchema && typeof jsonSchema === 'object') {
|
|
158
|
+
const schema = rawThis.#initJsonSchemaLibrary();
|
|
175
159
|
|
|
176
160
|
return (json: unknown): ValidationError[] => {
|
|
177
161
|
// do not validate empty documents
|
|
178
|
-
if (json === undefined) return [];
|
|
162
|
+
if (json === undefined || !schema) return [];
|
|
179
163
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (schema) {
|
|
183
|
-
const { errors } = schema.validate(json);
|
|
184
|
-
|
|
185
|
-
allErrors = rawThis.#processErrors(errors, json);
|
|
186
|
-
}
|
|
164
|
+
const { errors } = schema.validate(json);
|
|
187
165
|
|
|
188
|
-
|
|
189
|
-
validate(json);
|
|
190
|
-
allErrors = allErrors.concat(rawThis.#processErrorsAjv(validate.errors, json));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return allErrors;
|
|
166
|
+
return rawThis.#processErrors(errors, json);
|
|
194
167
|
};
|
|
195
|
-
} else if (schemaVersion != null
|
|
196
|
-
const ajv = rawThis.#initAjv(schemaVersion
|
|
168
|
+
} else if (schemaVersion != null) {
|
|
169
|
+
const ajv = rawThis.#initAjv(schemaVersion);
|
|
197
170
|
|
|
198
171
|
return (json: unknown): ValidationError[] => {
|
|
199
172
|
// do not validate empty documents
|
|
@@ -216,7 +189,7 @@ export class BsJsonInput {
|
|
|
216
189
|
}
|
|
217
190
|
}
|
|
218
191
|
|
|
219
|
-
#initAjv($schema: string
|
|
192
|
+
#initAjv($schema: string): Ajv {
|
|
220
193
|
// some regexp's in 2019-09/2020-12 meta-schemas are not compatible with 'v' flag, so update them
|
|
221
194
|
const regExp = (pattern: string) => new RegExp(patternMap[pattern] ?? pattern, 'v');
|
|
222
195
|
|
|
@@ -228,7 +201,7 @@ export class BsJsonInput {
|
|
|
228
201
|
code: {
|
|
229
202
|
regExp,
|
|
230
203
|
},
|
|
231
|
-
|
|
204
|
+
allErrors: true,
|
|
232
205
|
};
|
|
233
206
|
let ajv: Ajv;
|
|
234
207
|
|
|
@@ -245,9 +218,28 @@ export class BsJsonInput {
|
|
|
245
218
|
ajv = new Ajv(options);
|
|
246
219
|
}
|
|
247
220
|
|
|
221
|
+
addFormats(ajv);
|
|
222
|
+
|
|
248
223
|
return ajv;
|
|
249
224
|
}
|
|
250
225
|
|
|
226
|
+
#initJsonSchemaLibrary(): SchemaNode | undefined {
|
|
227
|
+
const { jsonSchema } = this;
|
|
228
|
+
|
|
229
|
+
// already a SchemaNode
|
|
230
|
+
if ((jsonSchema as SchemaNode).evaluationPath) {
|
|
231
|
+
return jsonSchema as SchemaNode;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
return compileSchema(jsonSchema as JSONSchema, this.validatorOptions);
|
|
236
|
+
} catch (e) {
|
|
237
|
+
console.error('json-schema-library validator compilation error', e);
|
|
238
|
+
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
251
243
|
#getSchemaDefinitions(schema: JSONSchema): JSONSchemaDefinitions {
|
|
252
244
|
return (schema.$defs ?? schema.definitions) as JSONSchemaDefinitions;
|
|
253
245
|
}
|
|
@@ -272,7 +264,7 @@ export class BsJsonInput {
|
|
|
272
264
|
return (errors || []).map((error) => ({
|
|
273
265
|
path: parsePath(json, error.data.pointer),
|
|
274
266
|
message: error.message || 'Unknown error',
|
|
275
|
-
severity: '
|
|
267
|
+
severity: 'warning' as ValidationSeverity,
|
|
276
268
|
}));
|
|
277
269
|
}
|
|
278
270
|
}
|