Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function prefixer(property: string, value: string): Rule[] {
const rules = prefix({[property]: value})
const rulesArray: Rule[] = []
const propertyNames = Object.keys(rules)
// Convert rules object to an array
for (let i = 0; i < propertyNames.length; i++) {
const propertyName = propertyNames[i]
// Add a dash in front of the prefixes
const prefixedProp = propertyName.match(prefixRegex)
? `-${propertyName}`
: propertyName
const prop = decamelize(prefixedProp)
const values = rules[propertyName]
// Handle prefixed values
if (Array.isArray(values)) {
for (let j = 0; j < values.length; j++) {
validateValueType(originalVal, originalKey);
}
const propValPair = `${hyphenate(
originalKey,
)}:${((originalVal: any): string)}`;
const key = `${pseudo}${propValPair}`;
const cachedId = cache.cache[key];
if (cachedId !== void 0) {
// cache hit
classString += " " + cachedId;
continue;
} else {
// cache miss
let block = "";
const prefixed = prefix({[originalKey]: originalVal});
for (const prefixedKey in prefixed) {
const prefixedVal = prefixed[prefixedKey];
const prefixedValType = typeof prefixedVal;
if (prefixedValType === "string" || prefixedValType === "number") {
const prefixedPair = `${hyphenate(prefixedKey)}:${prefixedVal}`;
if (prefixedPair !== propValPair) {
block += `${prefixedPair};`;
}
} else if (Array.isArray(prefixedVal)) {
const hyphenated = hyphenate(prefixedKey);
for (let i = 0; i < prefixedVal.length; i++) {
const prefixedPair = `${hyphenated}:${prefixedVal[i]}`;
if (prefixedPair !== propValPair) {
block += `${prefixedPair};`;
}
}
render() {
const {
component: Component = DefaultComponent,
elRef,
style: propStyle,
className,
...otherProps
} = this.props;
const {props, style} = parseStyleProps({
...otherProps,
});
const cleanedProps = cleanProps(props);
const inlineStyle = prefix({...style, ...propStyle});
return (
);
}
}
getRenderProps() {
const { height, distance, ptrVisibility, refresh, loading, reset } = this.localState;
const { pullTxt, releaseTxt, loadingTxt } = this.props;
const { barProps, rate } = this.getProgressbarProps();
const ptrTranslate = this.getTransformStyle(0, distance - height);
const contentTranslate = this.getTransformStyle(0, distance);
const vPullToRefresh = this.applyArgs('pull-to-refresh', this.classNames({ refresh, loading, reset }));
const ptrStyle = prefix({
transform: ptrTranslate,
WebkitTransform: ptrTranslate,
visibility: ptrVisibility
});
const contentStyle = prefix({
transform: contentTranslate,
WebkitTransform: contentTranslate
});
return {
ptrStyle,
contentStyle,
vPullToRefresh,
barProps,
rate,
refresh,
pullTxt,
}
default: {
const cacheKey = key + value + descendants + media
const cached = cache[cacheKey]
if (cached) {
Object.assign(rules, cached)
break
}
let className = createClassName(key, value, descendants, media)
if (rules[className]) {
break
}
if (!unitless[key]) {
value = normalizeValue(value)
}
const declaration = prefix({ [key]: value })
let rule = createRule(className, declaration, descendants, media)
if (opts.i18n) {
const originalProp = key
const originalValue = value
key = toI18n(i18n.properties, originalProp)
value = toI18n(i18n.values, originalValue)
if (key !== null || value !== null) {
key = key || originalProp
value = value || originalValue
const i18nClassName = createClassName(
key,
value,
descendants,
media
)
getRenderProps() {
const { height, distance, ptrVisibility, refresh, loading, reset } = this.localState;
const { pullTxt, releaseTxt, loadingTxt } = this.props;
const { barProps, rate } = this.getProgressbarProps();
const ptrTranslate = this.getTransformStyle(0, distance - height);
const contentTranslate = this.getTransformStyle(0, distance);
const vPullToRefresh = this.applyArgs('pull-to-refresh', this.classNames({ refresh, loading, reset }));
const ptrStyle = prefix({
transform: ptrTranslate,
WebkitTransform: ptrTranslate,
visibility: ptrVisibility
});
const contentStyle = prefix({
transform: contentTranslate,
WebkitTransform: contentTranslate
});
return {
ptrStyle,
contentStyle,
vPullToRefresh,
barProps,
rate,
refresh,
pullTxt,
releaseTxt,
loadingTxt
};
}
render() {
constructor(props, context) {
super(props, context);
this.running = false;
this.needUpdateItemSource = null;
this.state = {
items: [],
start: false,
style: prefix({ transform: this.getTransformStyle(0, 0) })
};
this.handleStep = (delta) => {
const itemHeight = parseFloat(this.getItemHeight());
const itemsOneRolling = this.props.itemsOneRolling;
this.setState({
style: prefix({
transform: this.getTransformStyle(0, -delta * itemHeight * itemsOneRolling)
})
});
};
this.handleDelta = (progress) => {
const easing = this.props.easing;
return easing(progress);
};
this.handleComplete = () => {
this.running = false;
this.handleComplete = () => {
this.running = false;
if (this.needUpdateItemSource !== null) {
const items = this.convertItems(this.needUpdateItemSource || []);
this.needUpdateItemSource = null;
this.setState({
start: false,
style: prefix({ transform: this.getTransformStyle(0, 0) }),
items
}, this.startAnimation);
}
else {
const items = this.getNewSortedItems(this.state.items);
this.setState({
start: false,
style: prefix({ transform: this.getTransformStyle(0, 0) }),
items
}, this.startAnimation);
}
};
this.startAnimation = () => {
private getRenderProps() {
const { height, distance, ptrVisibility, refresh, loading, reset } = this.localState;
const { pullTxt, releaseTxt, loadingTxt } = this.props;
const { barProps, rate } = this.getProgressbarProps();
const ptrTranslate = this.getTransformStyle(0, distance - height);
const contentTranslate = this.getTransformStyle(0, distance);
const vPullToRefresh = this.applyArgs('pull-to-refresh', this.classNames({ refresh, loading, reset }));
const ptrStyle = prefix({
transform: ptrTranslate,
WebkitTransform: ptrTranslate,
visibility: ptrVisibility
});
const contentStyle = prefix({
transform: contentTranslate,
WebkitTransform: contentTranslate
});
return {
ptrStyle,
contentStyle,
vPullToRefresh,
barProps,
rate,