@smartface/contx
Advanced tools
Comparing version 2.2.7 to 2.2.8
@@ -7,3 +7,3 @@ "use strict"; | ||
var _color = _interopRequireDefault(require("sf-core/ui/color")); | ||
var _color2 = _interopRequireDefault(require("sf-core/ui/color")); | ||
@@ -16,28 +16,28 @@ var _font = _interopRequireDefault(require("sf-core/ui/font")); | ||
const HexColorValidationRegexp = /^#[0-9A-Fa-f]{6}$/ig; | ||
const HexColorValidationRegexp = /^#[0-9A-Fa-f]{6}$/gi; | ||
const ENUMS = { | ||
imageFillType: 'sf-core/ui/imagefilltype', | ||
textAlignment: 'sf-core/ui/textalignment', | ||
orientation: 'sf-core/ui/page', | ||
type: 'sf-core/ui/mapview', | ||
gradientOrientation: 'sf-core/ui/color', | ||
searchViewStyle: 'sf-core/ui/searchview', | ||
imageFillType: "sf-core/ui/imagefilltype", | ||
textAlignment: "sf-core/ui/textalignment", | ||
orientation: "sf-core/ui/page", | ||
type: "sf-core/ui/mapview", | ||
gradientOrientation: "sf-core/ui/color", | ||
searchViewStyle: "sf-core/ui/searchview", | ||
activityIndicatorViewStyle: "sf-core/ui/activityindicator/ios/activityindicatorviewstyle", | ||
alignSelf: 'sf-core/ui/flexlayout', | ||
alignContent: 'sf-core/ui/flexlayout', | ||
alignItems: 'sf-core/ui/flexlayout', | ||
direction: 'sf-core/ui/flexlayout', | ||
ellipsizeMode: 'sf-core/ui/ellipsizemode', | ||
flexDirection: 'sf-core/ui/flexlayout', | ||
flexWrap: 'sf-core/ui/flexlayout', | ||
justifyContent: 'sf-core/ui/flexlayout', | ||
positionType: 'sf-core/ui/flexlayout', | ||
overflow: 'sf-core/ui/flexlayout', | ||
style: 'sf-core/ui/statusbarstyle', | ||
shimmeringDirection: 'sf-core/ui/shimmerflexlayout', | ||
alignSelf: "sf-core/ui/flexlayout", | ||
alignContent: "sf-core/ui/flexlayout", | ||
alignItems: "sf-core/ui/flexlayout", | ||
direction: "sf-core/ui/flexlayout", | ||
ellipsizeMode: "sf-core/ui/ellipsizemode", | ||
flexDirection: "sf-core/ui/flexlayout", | ||
flexWrap: "sf-core/ui/flexlayout", | ||
justifyContent: "sf-core/ui/flexlayout", | ||
positionType: "sf-core/ui/flexlayout", | ||
overflow: "sf-core/ui/flexlayout", | ||
style: "sf-core/ui/statusbarstyle", | ||
shimmeringDirection: "sf-core/ui/shimmerflexlayout", | ||
ios: { | ||
style: 'sf-core/ui/statusbarstyle' | ||
style: "sf-core/ui/statusbarstyle" | ||
}, | ||
align: 'sf-core/ui/scrollview', | ||
scrollDirection: 'sf-core/ui/layoutmanager' | ||
align: "sf-core/ui/scrollview", | ||
scrollDirection: "sf-core/ui/layoutmanager" | ||
}; | ||
@@ -63,9 +63,9 @@ const ENUMS_META_FIELD = { | ||
const componentObjectProps = { | ||
"android": {}, | ||
"ios": {}, | ||
"layout": {}, | ||
"layoutManager": {} | ||
android: {}, | ||
ios: {}, | ||
layout: {}, | ||
layoutManager: {} | ||
}; | ||
const COLOR_PROPS = ['backgroundColor', 'baseColor', 'borderColor', 'cancelButtonColor', 'color', 'cursorColor', 'errorColor', 'foregroundColor', 'highlightColor', 'hintTextColor', 'itemColor', 'lineColor', 'maxTrackColor', 'minTrackColor', 'rippleColor', 'selectedHintTextColor', 'shadowColor', 'textColor', 'textFieldBackgroundColor', 'thumbColor', 'thumbOffColor', 'thumbOnColor', 'tintColor', 'titleColor', 'toggleOffColor', 'toggleOnColor', 'underlineColor', 'strikethroughColor']; | ||
const IMAGE_PROPS = ['backIndicatorImage', 'backgroundImage', 'closeImage', 'icon', 'iconImage', 'image', 'inactiveImage', 'maxTrackImage', 'minTrackImage', 'thumbImage']; | ||
const COLOR_PROPS = ["backgroundColor", "baseColor", "borderColor", "cancelButtonColor", "color", "cursorColor", "errorColor", "foregroundColor", "highlightColor", "hintTextColor", "itemColor", "lineColor", "maxTrackColor", "minTrackColor", "rippleColor", "selectedHintTextColor", "shadowColor", "textColor", "textFieldBackgroundColor", "thumbColor", "thumbOffColor", "thumbOnColor", "tintColor", "titleColor", "toggleOffColor", "toggleOnColor", "underlineColor", "strikethroughColor"]; | ||
const IMAGE_PROPS = ["backIndicatorImage", "backgroundImage", "closeImage", "icon", "iconImage", "image", "inactiveImage", "maxTrackImage", "minTrackImage", "thumbImage"]; | ||
const GIFIMAGE_PROPS = ["gifImage"]; | ||
@@ -82,5 +82,6 @@ const IMAGE_FILLTYPE_COMMON_PROPS = ["ASPECTFIT", "NORMAL", "STRETCH", "ASPECTFILL"]; | ||
const LAYOUT_PROPS_MAP = { | ||
"layoutHeight": "height", | ||
"layoutWidth": "width" | ||
layoutHeight: "height", | ||
layoutWidth: "width" | ||
}; | ||
const VALID_HEX_COLOR_LENGTHS = [3, 6, 8]; | ||
@@ -98,6 +99,6 @@ function _requireEnum(key) { | ||
* Create a sf-core value | ||
* | ||
* | ||
* @function | ||
* | ||
* @param {string} key | ||
* | ||
* @param {string} key | ||
* @param {string/number} [value] value of property | ||
@@ -153,3 +154,3 @@ * @return {object/string/number} properties. | ||
function createGifImageForDevice(gifImage) { | ||
return require('sf-core/ui/gifimage').createFromFile(`assets://${gifImage}`); | ||
return require("sf-core/ui/gifimage").createFromFile(`assets://${gifImage}`); | ||
} | ||
@@ -179,3 +180,3 @@ | ||
const reRGB = /rgb/i; | ||
const reRGBA = /\d\.\d+|\d+/ig; | ||
const reRGBA = /\d\.\d+|\d+/gi; | ||
return color => { | ||
@@ -188,6 +189,6 @@ reRGBA.lastIndex = reRGB.lastIndex = 0; | ||
// gradient color | ||
res = _color.default.createGradient({ | ||
res = _color2.default.createGradient({ | ||
startColor: createColorForDevice(color.startColor), | ||
endColor: createColorForDevice(color.endColor), | ||
direction: _color.default.GradientDirection[color.direction] | ||
direction: _color2.default.GradientDirection[color.direction] | ||
}); | ||
@@ -205,8 +206,8 @@ } else { | ||
rgba.length === 3 && (rgba[3] = 1); | ||
res = _color.default.create(Number(rgba[3]) * 100, Number(rgba[0]), Number(rgba[1]), Number(rgba[2])); | ||
res = _color2.default.create(Number(rgba[3]) * 100, Number(rgba[0]), Number(rgba[1]), Number(rgba[2])); | ||
} else if (color) { | ||
// hex color | ||
HexColorValidationRegexp.lastIndex = 0; | ||
if (!HexColorValidationRegexp.test(color)) throw new Error(`${color} is invalid value. Please, check your styles`); | ||
res = _color.default.create(color); | ||
if (!HexColorValidationRegexp.test(color) || VALID_HEX_COLOR_LENGTHS.indexOf(color.length - 1) === -1) throw new Error(`${color} is invalid value. Please, check your styles`); | ||
res = _color.default.create(getNormalizedHexColor(color)); | ||
} | ||
@@ -244,2 +245,18 @@ | ||
return _font.default[res || FONT_STYLE.DEFAULT]; | ||
} | ||
function getNormalizedHexColor(_color) { | ||
if (_color.length === 4) { | ||
const color = _color.substring(1); | ||
let resColor = "#"; | ||
for (let i = 0; i < 3; ++i) { | ||
resColor += color[i] + color[i]; | ||
} | ||
return resColor; | ||
} | ||
return _color; | ||
} |
{ | ||
"name": "@smartface/contx", | ||
"version": "2.2.7", | ||
"version": "2.2.8", | ||
"description": "Context Manager", | ||
@@ -5,0 +5,0 @@ "scripts": { |
74229
1681
35