@ekzo-dev/toolkit
Advanced tools
Comparing version 1.2.3 to 1.2.4
{ | ||
"name": "@ekzo-dev/toolkit", | ||
"description": "Aurelia toolkit", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"homepage": "https://github.com/ekzo-dev/aurelia-components/tree/main/packages/toolkit", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -5,4 +5,4 @@ import { valueConverter } from 'aurelia'; | ||
export class FormatBoolean { | ||
toView(value, trueText = 'Да', falseText = 'Нет') { | ||
if (value === undefined || value === null) return value; | ||
toView(value: boolean | null | undefined, trueText = 'Да', falseText = 'Нет'): string | null | undefined { | ||
if (value == null) return value as undefined; | ||
@@ -9,0 +9,0 @@ return value ? trueText : falseText; |
@@ -15,3 +15,3 @@ import { valueConverter } from 'aurelia'; | ||
toView(value, pattern, empty = null) { | ||
toView(value, pattern, empty = null): string { | ||
if (!value) return empty ?? value; | ||
@@ -18,0 +18,0 @@ pattern = this.patterns[pattern] || pattern; |
@@ -1,2 +0,2 @@ | ||
import type { JSONSchema7 } from 'json-schema'; | ||
import type { JSONSchema7, JSONSchema7Type } from 'json-schema'; | ||
@@ -12,6 +12,6 @@ import { valueConverter } from 'aurelia'; | ||
export class FormatJsonSchemaNode { | ||
toView(value: any, definition: JSONSchema7) { | ||
toView(value: JSONSchema7Type, definition: JSONSchema7) { | ||
switch (definition.type) { | ||
case 'boolean': | ||
return new FormatBoolean().toView(value); | ||
return new FormatBoolean().toView(value as boolean); | ||
@@ -21,7 +21,4 @@ case 'string': | ||
case 'integer': | ||
if ( | ||
definition.enum && | ||
definition.anyOf?.every((item: JSONSchema7) => item.title != null && item.const != null) | ||
) { | ||
const node = definition.anyOf.find((item: JSONSchema7) => item.const === value); | ||
if (definition.enum && definition.anyOf) { | ||
const node = definition.anyOf[definition.enum.indexOf(value)]; | ||
@@ -42,6 +39,6 @@ if (node) { | ||
case 'tel': | ||
return new FormatPhone().toView(value); | ||
return new FormatPhone().toView(value as string); | ||
case 'filesize': | ||
return new FormatFilesize().toView(value); | ||
return new FormatFilesize().toView(value as number); | ||
} | ||
@@ -48,0 +45,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25144
493