@ekzo-dev/toolkit
Advanced tools
Comparing version 1.0.3 to 1.1.0
{ | ||
"name": "@ekzo-dev/toolkit", | ||
"description": "Aurelia toolkit", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"homepage": "https://github.com/ekzo-dev/aurelia-components/tree/main/packages/toolkit", | ||
@@ -12,7 +12,7 @@ "repository": { | ||
"dependencies": { | ||
"date-fns": "^2.28.0", | ||
"libphonenumber-js": "^1.9.44" | ||
"date-fns": "^2.30.0", | ||
"libphonenumber-js": "^1.10.49" | ||
}, | ||
"devDependencies": { | ||
"@types/json-schema": "^7.0.9" | ||
"@types/json-schema": "^7.0.14" | ||
}, | ||
@@ -24,7 +24,6 @@ "main": "src/index.ts", | ||
"scripts": { | ||
"lint:js": "eslint src test --ext .js,.ts", | ||
"lint:css": "sass-lint -c .sass-lint.yml \"src/**/*.scss\"", | ||
"lint:html": "htmlhint -c .htmlhintrc src", | ||
"lint": "npm run lint:js && npm run lint:html && npm run lint:css", | ||
"pretest": "npm run lint", | ||
"lint:js": "eslint src --ext .js,.ts", | ||
"lint:css": "stylelint \"**/*.*css\" --allow-empty-input", | ||
"lint:html": "prettier \"**/*.html\" --no-error-on-unmatched-pattern", | ||
"lint:all": "npm run lint:js && npm run lint:html && npm run lint:css", | ||
"start": "webpack serve", | ||
@@ -57,4 +56,3 @@ "build": "rimraf dist && webpack --env production", | ||
"access": "public" | ||
}, | ||
"gitHead": "54e2370ee2738599645041aed166960f1f814306" | ||
} | ||
} |
@@ -174,2 +174,3 @@ import { bindable, BindingMode, customAttribute } from 'aurelia'; | ||
const elementDragging: HTMLElement = document.querySelector('[moving]'); | ||
if (elementDragging !== this.element) { | ||
@@ -184,2 +185,3 @@ if (elementDragging.getAttribute('hidden') === null && this.hide) { | ||
this.element.classList.add('over'); | ||
if (this.canDrop && this.addClass) { | ||
@@ -207,6 +209,9 @@ this.element.classList.add(this.addClass); | ||
const elementDragging: HTMLElement = document.querySelector('[moving]'); | ||
if (elementDragging !== this.element) { | ||
this.dragCounter--; | ||
if (this.dragCounter === 0) { | ||
this.element.classList.remove('over'); | ||
if (this.canDrop && this.addClass) { | ||
@@ -230,5 +235,7 @@ this.element.classList.remove(this.addClass); | ||
const dragPayload = event.dataTransfer.getData('input/plain'); | ||
if (JSON.stringify(this.payload) !== dragPayload) { | ||
if (this.dropHandler) { | ||
const event = { drop: this.payload, drag: JSON.parse(dragPayload) }; | ||
this.dropHandler(event); | ||
@@ -235,0 +242,0 @@ } |
@@ -1,3 +0,2 @@ | ||
import { customAttribute, bindable } from 'aurelia'; | ||
import { bindable, customAttribute } from 'aurelia'; | ||
import { AsYouType, CountryCode } from 'libphonenumber-js'; | ||
@@ -4,0 +3,0 @@ |
/** | ||
* Аналог ф-ии dig в Ruby для поиска ключей в многомерных объектах | ||
*/ | ||
export function dig(target: Record<string, any>, ...keys: (string | Function)[]): any { | ||
export function dig( | ||
target: Record<string, any>, | ||
...keys: (string | ((param: Record<string, any>) => Record<string, any>))[] | ||
): any { | ||
let digged = target; | ||
@@ -11,2 +14,3 @@ | ||
} | ||
if (typeof key === 'function') { | ||
@@ -13,0 +17,0 @@ digged = key(digged); |
export * from './attributes/drag-n-drop'; | ||
export * from './attributes/phone-input/phone-input'; | ||
export * from './value-converters/view-changed'; | ||
export * from './value-converters/to-integer'; | ||
export * from './value-converters/iterable'; | ||
export * from './helpers'; | ||
export * from './value-converters/false-as-null'; | ||
export * from './value-converters/format/boolean'; | ||
export * from './value-converters/format/datetime'; | ||
export * from './value-converters/format/filesize'; | ||
export * from './value-converters/format/datetime'; | ||
export * from './value-converters/format/boolean'; | ||
export * from './value-converters/format/json-schema-node'; | ||
export * from './value-converters/format/phone'; | ||
export * from './value-converters/format/json-schema-node'; | ||
export * from './helpers'; | ||
export * from './value-converters/iterable'; | ||
export * from './value-converters/to-integer'; | ||
export * from './value-converters/view-changed'; |
@@ -5,13 +5,11 @@ import { valueConverter } from 'aurelia'; | ||
export class FormatFilesize { | ||
toView(value) { | ||
toView(value: number) { | ||
if (value === undefined || value === null) return value; | ||
const units = ['б', 'кб', 'мб', 'гб', 'тб', 'пб', 'еб', 'зб', 'YB']; | ||
let bytes = value; | ||
const exponent = Math.min(Math.floor(Math.log(value) / Math.log(1000)), units.length - 1); | ||
const bytes = (value / Math.pow(1000, exponent)).toFixed(2); | ||
const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(1000)), units.length - 1); | ||
bytes = (bytes / Math.pow(1000, exponent)).toFixed(2); | ||
return `${bytes} ${units[exponent]}`; | ||
} | ||
} |
@@ -0,7 +1,9 @@ | ||
import type { JSONSchema7 } from 'json-schema'; | ||
import { valueConverter } from 'aurelia'; | ||
import type { JSONSchema7 } from 'json-schema'; | ||
import { FormatBoolean } from './boolean'; | ||
import { FormatDatetime } from './datetime'; | ||
import { FormatFilesize } from './filesize'; | ||
import { FormatPhone } from './phone'; | ||
import { FormatFilesize } from './filesize'; | ||
@@ -14,3 +16,5 @@ @valueConverter('formatJsonSchemaNode') | ||
return new FormatBoolean().toView(value); | ||
case 'string': | ||
case 'integer': | ||
@@ -22,2 +26,3 @@ if ( | ||
const node = definition.anyOf.find((item: JSONSchema7) => item.const === value); | ||
if (node) { | ||
@@ -30,7 +35,11 @@ return (node as JSONSchema7).title; | ||
case 'datetime': | ||
case 'date': | ||
case 'time': | ||
return new FormatDatetime().toView(value, definition.format); | ||
case 'tel': | ||
return new FormatPhone().toView(value); | ||
case 'filesize': | ||
@@ -37,0 +46,0 @@ return new FormatFilesize().toView(value); |
import { valueConverter } from 'aurelia'; | ||
import { parsePhoneNumberFromString, CountryCode } from 'libphonenumber-js'; | ||
import { CountryCode, parsePhoneNumberFromString } from 'libphonenumber-js'; | ||
@@ -4,0 +4,0 @@ @valueConverter('formatPhone') |
@@ -9,4 +9,5 @@ import { valueConverter } from 'aurelia'; | ||
} | ||
return value; | ||
} | ||
} |
@@ -7,4 +7,5 @@ import { valueConverter } from 'aurelia'; | ||
callback(value); | ||
return value; | ||
} | ||
} |
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
456
23589
18
Updateddate-fns@^2.30.0
Updatedlibphonenumber-js@^1.10.49