@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
41 lines • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildPropsDecorativeElement = void 0;
const decorativeElement_1 = require("../../components/decorativeElement/types/decorativeElement");
const buildPropsDecorativeElement = (element, styles, extraStyles) => {
const arrayOfDecorativeType = Object.values(decorativeElement_1.DecorativeType);
let result = {};
const decorativeElement = arrayOfDecorativeType.find(item => element?.[item]);
if (!decorativeElement) {
return result;
}
result = {
[decorativeElement]: {
...element?.[decorativeElement],
},
};
// Convert snake_case to camelCase
const toCamelCase = () => {
return decorativeElement.toLowerCase().replace(/_[a-z]/g, match => match[1].toUpperCase());
};
if (styles?.[toCamelCase()]) {
result = {
[decorativeElement]: {
...element?.[decorativeElement],
...styles?.[toCamelCase()],
},
};
}
if (extraStyles && styles?.[toCamelCase()]) {
result = {
[decorativeElement]: {
...styles?.[toCamelCase()],
...extraStyles,
...element?.[decorativeElement],
},
};
}
return result;
};
exports.buildPropsDecorativeElement = buildPropsDecorativeElement;
//# sourceMappingURL=buildPropsDecorativeElement.js.map