Compare commits
4
Commits
fb123afb95
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2c272e7a3 | ||
|
|
00031119ac | ||
|
|
1dc206c4b4 | ||
|
|
fb701301d8 |
@@ -156,6 +156,20 @@ export enum XResourceIDs {
|
|||||||
//
|
//
|
||||||
submit,
|
submit,
|
||||||
|
|
||||||
|
//
|
||||||
|
print,
|
||||||
|
export_png,
|
||||||
|
export_svg,
|
||||||
|
export_csv,
|
||||||
|
zoom_in,
|
||||||
|
zoom_out,
|
||||||
|
zoom_selection,
|
||||||
|
x_axis,
|
||||||
|
y_axis,
|
||||||
|
xy_axis,
|
||||||
|
pan,
|
||||||
|
full_screen,
|
||||||
|
|
||||||
//
|
//
|
||||||
//#region Pagination ...
|
//#region Pagination ...
|
||||||
first,
|
first,
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ export function parseXColor(color: XColorIdentifier): XColorDescribtor {
|
|||||||
const brightnessLevel: XColorBrightnessLevel = strColor.includes('tint')
|
const brightnessLevel: XColorBrightnessLevel = strColor.includes('tint')
|
||||||
? XColorBrightnessLevel.Tint
|
? XColorBrightnessLevel.Tint
|
||||||
: strColor.includes('shade')
|
: strColor.includes('shade')
|
||||||
? XColorBrightnessLevel.Shade
|
? XColorBrightnessLevel.Shade
|
||||||
: XColorBrightnessLevel.Regular;
|
: XColorBrightnessLevel.Regular;
|
||||||
const name = strColor
|
const name = strColor
|
||||||
.replace('-', '')
|
.replace('-', '')
|
||||||
.replace('contrast', '')
|
.replace('contrast', '')
|
||||||
@@ -409,8 +409,8 @@ export function stringToRGBA(value: string): XRGBAColor {
|
|||||||
value = value.includes('rgba')
|
value = value.includes('rgba')
|
||||||
? value.replace('rgba', '')
|
? value.replace('rgba', '')
|
||||||
: value.includes('rgb')
|
: value.includes('rgb')
|
||||||
? value.replace('rgb', '')
|
? value.replace('rgb', '')
|
||||||
: value;
|
: value;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Replace paranteses ...
|
// Replace paranteses ...
|
||||||
@@ -890,14 +890,14 @@ export function stringToHsva(colorString: string = ''): XHSVAColor {
|
|||||||
const type = isHEX(colorString)
|
const type = isHEX(colorString)
|
||||||
? 'hex'
|
? 'hex'
|
||||||
: isRGBA(colorString)
|
: isRGBA(colorString)
|
||||||
? 'rgba'
|
? 'rgba'
|
||||||
: isRGB(colorString)
|
: isRGB(colorString)
|
||||||
? 'rgb'
|
? 'rgb'
|
||||||
: isHSVA(colorString)
|
: isHSVA(colorString)
|
||||||
? 'hsva'
|
? 'hsva'
|
||||||
: isHSLA(colorString)
|
: isHSLA(colorString)
|
||||||
? 'hsla'
|
? 'hsla'
|
||||||
: 'unknown';
|
: 'unknown';
|
||||||
|
|
||||||
//
|
//
|
||||||
// get result value based on input type ...
|
// get result value based on input type ...
|
||||||
@@ -1179,3 +1179,37 @@ export function formatColor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Specified Color Identifier Value ...
|
||||||
|
*
|
||||||
|
* @param color Color Identifier ...
|
||||||
|
*
|
||||||
|
* @returns an string value which represent color ...
|
||||||
|
*/
|
||||||
|
export function getXColorValue(color: XColorIdentifier) {
|
||||||
|
//
|
||||||
|
let result = '';
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!isNullOrUndefined(color)) {
|
||||||
|
//
|
||||||
|
const descriptor = parseXColor(color);
|
||||||
|
if (!isNullOrUndefined(descriptor)) {
|
||||||
|
//
|
||||||
|
var colorCssVarName = getXColorCssVariableName(
|
||||||
|
descriptor.name,
|
||||||
|
descriptor.isContrast,
|
||||||
|
descriptor.brightnessLevel,
|
||||||
|
);
|
||||||
|
if (!isNullOrEmptyString(colorCssVarName)) {
|
||||||
|
//
|
||||||
|
const computedStyle = getComputedStyle(document.documentElement);
|
||||||
|
result = computedStyle.getPropertyValue(colorCssVarName.trim()).trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
import { Type } from '@angular/core';
|
import { Type } from '@angular/core';
|
||||||
import { isSameDate } from './x-date-time.tools';
|
import { isSameDate } from './x-date-time.tools';
|
||||||
import { countChild, hasChild, lastItem, onlyUniques } from './x-array.tools';
|
import { countChild, hasChild, lastItem, onlyUniques } from './x-array.tools';
|
||||||
|
import { toXString } from './x-type-convert.tools';
|
||||||
|
|
||||||
//
|
//
|
||||||
//#region Object Tools ...
|
//#region Object Tools ...
|
||||||
@@ -260,7 +261,7 @@ export function mergeAll<T>(
|
|||||||
*/
|
*/
|
||||||
export function toPartialObject<T>(
|
export function toPartialObject<T>(
|
||||||
source: T,
|
source: T,
|
||||||
modelKeys: Array<Partial<keyof T>>
|
modelKeys: Array<Partial<keyof T>>,
|
||||||
) {
|
) {
|
||||||
//
|
//
|
||||||
if (!source || !hasChild(modelKeys)) {
|
if (!source || !hasChild(modelKeys)) {
|
||||||
@@ -313,7 +314,7 @@ export function getFieldNames<T>(object: T): XModelFieldTypeIndex<T> {
|
|||||||
{},
|
{},
|
||||||
...(Object.keys(object).map((k) => {
|
...(Object.keys(object).map((k) => {
|
||||||
return assign({}, { key: k, value: k });
|
return assign({}, { key: k, value: k });
|
||||||
}) as XModelFieldTypeIndex<T>[])
|
}) as XModelFieldTypeIndex<T>[]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,7 +367,7 @@ export function setPropertyValue<T>(
|
|||||||
object: T,
|
object: T,
|
||||||
propertyPath: string,
|
propertyPath: string,
|
||||||
value?: any,
|
value?: any,
|
||||||
forceCreate?: boolean
|
forceCreate?: boolean,
|
||||||
) {
|
) {
|
||||||
//
|
//
|
||||||
if (!object || isNullOrEmptyString(propertyPath)) {
|
if (!object || isNullOrEmptyString(propertyPath)) {
|
||||||
@@ -410,7 +411,7 @@ export function getPropertyPaths<T = any>(
|
|||||||
object: T,
|
object: T,
|
||||||
prefix?: string,
|
prefix?: string,
|
||||||
extractSchema: boolean = false,
|
extractSchema: boolean = false,
|
||||||
containsChildsObjectHeaders: boolean = false
|
containsChildsObjectHeaders: boolean = false,
|
||||||
) {
|
) {
|
||||||
//
|
//
|
||||||
// Create empty result Array ...
|
// Create empty result Array ...
|
||||||
@@ -483,7 +484,7 @@ export function getPropertyPaths<T = any>(
|
|||||||
(value as any[])[0],
|
(value as any[])[0],
|
||||||
`${keyPath}.0`,
|
`${keyPath}.0`,
|
||||||
extractSchema,
|
extractSchema,
|
||||||
containsChildsObjectHeaders
|
containsChildsObjectHeaders,
|
||||||
)
|
)
|
||||||
: //
|
: //
|
||||||
// for Object Values retrieve all including keys ...
|
// for Object Values retrieve all including keys ...
|
||||||
@@ -491,7 +492,7 @@ export function getPropertyPaths<T = any>(
|
|||||||
value,
|
value,
|
||||||
keyPath,
|
keyPath,
|
||||||
extractSchema,
|
extractSchema,
|
||||||
containsChildsObjectHeaders
|
containsChildsObjectHeaders,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
@@ -501,7 +502,7 @@ export function getPropertyPaths<T = any>(
|
|||||||
value,
|
value,
|
||||||
keyPath,
|
keyPath,
|
||||||
extractSchema,
|
extractSchema,
|
||||||
containsChildsObjectHeaders
|
containsChildsObjectHeaders,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,7 +545,7 @@ export function getSchemaPaths<T = any>(object: T) {
|
|||||||
export function generateObjectFromPaths<T = any>(
|
export function generateObjectFromPaths<T = any>(
|
||||||
paths: string[],
|
paths: string[],
|
||||||
assginPropertyName: boolean = false,
|
assginPropertyName: boolean = false,
|
||||||
defaultValue: any = null
|
defaultValue: any = null,
|
||||||
): XDeep<T> {
|
): XDeep<T> {
|
||||||
//
|
//
|
||||||
// Check paths contains childs ...
|
// Check paths contains childs ...
|
||||||
@@ -605,7 +606,7 @@ export function generateObjectFromPaths<T = any>(
|
|||||||
export function generatePartialObjectFromPaths<T = any>(
|
export function generatePartialObjectFromPaths<T = any>(
|
||||||
paths: string[],
|
paths: string[],
|
||||||
assginPropertyName: boolean = false,
|
assginPropertyName: boolean = false,
|
||||||
defaultValue: any = null
|
defaultValue: any = null,
|
||||||
): XDeepPartial<T> {
|
): XDeepPartial<T> {
|
||||||
//
|
//
|
||||||
// Check paths contains childs ...
|
// Check paths contains childs ...
|
||||||
@@ -665,7 +666,7 @@ export function generatePartialObjectFromPaths<T = any>(
|
|||||||
*/
|
*/
|
||||||
export function getSchema<T = any>(
|
export function getSchema<T = any>(
|
||||||
object: T,
|
object: T,
|
||||||
defaultValue: any = null
|
defaultValue: any = null,
|
||||||
): XDeep<T> {
|
): XDeep<T> {
|
||||||
//
|
//
|
||||||
const paths = getSchemaPaths(object);
|
const paths = getSchemaPaths(object);
|
||||||
@@ -684,7 +685,7 @@ export function getSchema<T = any>(
|
|||||||
*/
|
*/
|
||||||
export function getPartialSchema<T = any>(
|
export function getPartialSchema<T = any>(
|
||||||
object: T,
|
object: T,
|
||||||
defaultValue: any = null
|
defaultValue: any = null,
|
||||||
): XDeepPartial<T> {
|
): XDeepPartial<T> {
|
||||||
//
|
//
|
||||||
const paths = getSchemaPaths(object);
|
const paths = getSchemaPaths(object);
|
||||||
@@ -773,10 +774,10 @@ export function isSameType(source: any, dest: any, forceMemberTypes = false) {
|
|||||||
|
|
||||||
//
|
//
|
||||||
const isAllSourceKeyExistsInDestKeys = sourceKeys.every((k) =>
|
const isAllSourceKeyExistsInDestKeys = sourceKeys.every((k) =>
|
||||||
destKeys.includes(k)
|
destKeys.includes(k),
|
||||||
);
|
);
|
||||||
const isAllDestKeyExistsInSourceKeys = destKeys.every((k) =>
|
const isAllDestKeyExistsInSourceKeys = destKeys.every((k) =>
|
||||||
sourceKeys.includes(k)
|
sourceKeys.includes(k),
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -819,7 +820,7 @@ export function isSameType(source: any, dest: any, forceMemberTypes = false) {
|
|||||||
export function isSameArray(
|
export function isSameArray(
|
||||||
source: any[],
|
source: any[],
|
||||||
dest: any[],
|
dest: any[],
|
||||||
forceCheckType?: boolean
|
forceCheckType?: boolean,
|
||||||
): boolean {
|
): boolean {
|
||||||
//
|
//
|
||||||
if (!source || !dest) {
|
if (!source || !dest) {
|
||||||
@@ -877,7 +878,7 @@ export function isSameArray(
|
|||||||
export function isSameObject(
|
export function isSameObject(
|
||||||
source: object,
|
source: object,
|
||||||
dest: object,
|
dest: object,
|
||||||
forceCheckType?: boolean
|
forceCheckType?: boolean,
|
||||||
): boolean {
|
): boolean {
|
||||||
//
|
//
|
||||||
if (!source || !dest) {
|
if (!source || !dest) {
|
||||||
@@ -935,9 +936,7 @@ export function isSameObject(
|
|||||||
*/
|
*/
|
||||||
export function isOfType<T>(value: any, keys: (keyof T)[]): value is T {
|
export function isOfType<T>(value: any, keys: (keyof T)[]): value is T {
|
||||||
return (
|
return (
|
||||||
typeof value === "object" &&
|
typeof value === 'object' && value !== null && keys.every((k) => k in value)
|
||||||
value !== null &&
|
|
||||||
keys.every(k => k in value)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -949,9 +948,9 @@ export function isOfType<T>(value: any, keys: (keyof T)[]): value is T {
|
|||||||
*/
|
*/
|
||||||
export function typeGuard<T>(keys: (keyof T)[]) {
|
export function typeGuard<T>(keys: (keyof T)[]) {
|
||||||
return (value: any): value is T =>
|
return (value: any): value is T =>
|
||||||
typeof value === "object" &&
|
typeof value === 'object' &&
|
||||||
value !== null &&
|
value !== null &&
|
||||||
keys.every(k => k in value);
|
keys.every((k) => k in value);
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@@ -1004,6 +1003,46 @@ export function getVal(T: Object, value: number | string) {
|
|||||||
export function toObject(T: Object) {
|
export function toObject(T: Object) {
|
||||||
return Object.assign({}, T);
|
return Object.assign({}, T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic Tools Function to Check A Value inside enum Values or not ...
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* @param values
|
||||||
|
* @param forceExact
|
||||||
|
*/
|
||||||
|
export function isValueInEnum<TValue>(
|
||||||
|
value: TValue,
|
||||||
|
values: Object,
|
||||||
|
forceExact: boolean = true,
|
||||||
|
) {
|
||||||
|
//
|
||||||
|
let result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (
|
||||||
|
!isNullOrUndefined(value) &&
|
||||||
|
!isNullOrUndefined(values) &&
|
||||||
|
!isNullOrEmptyString(toXString(value))
|
||||||
|
) {
|
||||||
|
//
|
||||||
|
const tVals = Object.values(values).map((tv) => tv as TValue);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = tVals.includes(value);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Includes ...
|
||||||
|
if (!forceExact && !result) {
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
tVals.findIndex((t) => toXString(value).includes(toXString(t))) >= 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1037,7 +1076,7 @@ export function getComponentName<T>(component: Type<T>): string | null {
|
|||||||
*/
|
*/
|
||||||
export function isXKeyOf<T extends object>(
|
export function isXKeyOf<T extends object>(
|
||||||
obj: T,
|
obj: T,
|
||||||
key: PropertyKey
|
key: PropertyKey,
|
||||||
): key is keyof T {
|
): key is keyof T {
|
||||||
return key in obj;
|
return key in obj;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user