-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* extra attributes by @Kobe-Wulteputte Adding missing properties to au2 branch * fixes and additional properties * minor refactoring and id property added Co-authored-by: Alexandr Todorov <Alexandr.Todorov@technosoft.nl>
- Loading branch information
1 parent
6834427
commit 44ecd0f
Showing
6 changed files
with
147 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,42 @@ | ||
import { ResizeHandles, ResizeHandleType } from './models'; | ||
|
||
export function number(a: unknown): number { | ||
return Number(a); | ||
} | ||
|
||
export function booleanAttr(val: unknown): boolean { | ||
return val || val === '' ? true : false; | ||
} | ||
|
||
function onlyUnique(value: any, index: number, self: any) { | ||
return self.indexOf(value) === index; | ||
} | ||
|
||
export function handlesAttr(handles: unknown): ResizeHandleType[] { | ||
const isStringParam = typeof handles === 'string' || handles instanceof String; | ||
const isArrayParam = Array.isArray(handles); | ||
const isStringOrArray = isStringParam || isArrayParam; | ||
const handlesArray: ResizeHandleType[] = []; | ||
|
||
if (handles && isStringOrArray && handles.length > 0) { | ||
let allEntries: string[]; | ||
|
||
if (isStringParam) { | ||
allEntries = handles.replace(/\s/g,'').split(','); | ||
} else { | ||
allEntries = handles; | ||
} | ||
|
||
// remove duplicates | ||
allEntries = allEntries.filter(onlyUnique); | ||
|
||
// add only ResizeHandleType items | ||
allEntries.forEach(child => { | ||
if (child in ResizeHandles) { | ||
handlesArray.push(child as ResizeHandleType); | ||
} | ||
}); | ||
} | ||
|
||
return handlesArray; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export enum ResizeHandles { | ||
n = 'n', | ||
ne = 'ne', | ||
e = 'e', | ||
se = 'se', | ||
s = 's', | ||
sw = 'sw', | ||
w = 'w', | ||
nw = 'nw' | ||
} | ||
|
||
export type ResizeHandleType = ResizeHandles.n | ResizeHandles.ne | ResizeHandles.e | ResizeHandles.se | | ||
ResizeHandles.s | ResizeHandles.sw | ResizeHandles.w | ResizeHandles.nw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters