jedison 0.3.3 → 0.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/CHANGELOG.md +8 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +40 -0
- package/dist/esm/jedison.js.map +1 -1
- package/dist/umd/jedison.umd.js +1 -1
- package/dist/umd/jedison.umd.js.map +1 -1
- package/package.json +5 -5
package/dist/esm/jedison.js
CHANGED
|
@@ -3334,6 +3334,45 @@ class EditorNumberInput extends EditorNumber {
|
|
|
3334
3334
|
}
|
|
3335
3335
|
}
|
|
3336
3336
|
}
|
|
3337
|
+
class EditorNumberInputNullable extends EditorNumberInput {
|
|
3338
|
+
static resolves(schema) {
|
|
3339
|
+
const schemaType = getSchemaType(schema);
|
|
3340
|
+
const schemaIsNullable = getSchemaXOption(schema, "nullable");
|
|
3341
|
+
return isSet(schemaIsNullable) && schemaIsNullable === true && isSet(schemaType) && isArray(schemaType) && schemaType.length === 2 && schemaType.includes("null") && (schemaType.includes("number") || schemaType.includes("integer"));
|
|
3342
|
+
}
|
|
3343
|
+
addEventListeners() {
|
|
3344
|
+
this.control.input.addEventListener("change", () => {
|
|
3345
|
+
const value = this.sanitize(this.control.input.value);
|
|
3346
|
+
this.instance.setValue(value, true, "user");
|
|
3347
|
+
});
|
|
3348
|
+
}
|
|
3349
|
+
sanitize(value) {
|
|
3350
|
+
if (value === "") {
|
|
3351
|
+
return null;
|
|
3352
|
+
}
|
|
3353
|
+
const schemaType = getSchemaType(this.instance.schema);
|
|
3354
|
+
if (schemaType.includes("integer")) {
|
|
3355
|
+
return Math.floor(Number(value));
|
|
3356
|
+
} else {
|
|
3357
|
+
return Number(value);
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
refreshUI() {
|
|
3361
|
+
super.refreshUI();
|
|
3362
|
+
const value = this.instance.getValue();
|
|
3363
|
+
if (value === null) {
|
|
3364
|
+
this.control.input.value = "";
|
|
3365
|
+
}
|
|
3366
|
+
if (isNumber(value)) {
|
|
3367
|
+
const schemaType = getSchemaType(this.instance.schema);
|
|
3368
|
+
if (schemaType.includes("integer")) {
|
|
3369
|
+
this.control.input.value = Math.floor(Number(value));
|
|
3370
|
+
} else {
|
|
3371
|
+
this.control.input.value = value;
|
|
3372
|
+
}
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3337
3376
|
class EditorObject extends Editor {
|
|
3338
3377
|
static resolves(schema) {
|
|
3339
3378
|
return getSchemaType(schema) === "object";
|
|
@@ -4450,6 +4489,7 @@ class UiResolver {
|
|
|
4450
4489
|
this.customEditors = options.customEditors ?? [];
|
|
4451
4490
|
this.refParser = options.refParser ?? null;
|
|
4452
4491
|
this.editors = [
|
|
4492
|
+
EditorNumberInputNullable,
|
|
4453
4493
|
EditorMultiple,
|
|
4454
4494
|
EditorIfThenElse,
|
|
4455
4495
|
EditorRadios,
|