mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-05 03:52:59 +00:00
These are all the files from the Tabler react repos, made to work with laravel and webpack.
This commit is contained in:
74
resources/js/ComponentDemo/react-element-to-jsx-string/formatter/formatProp.js
vendored
Normal file
74
resources/js/ComponentDemo/react-element-to-jsx-string/formatter/formatProp.js
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true,
|
||||
});
|
||||
|
||||
var _spacer = require("./spacer");
|
||||
|
||||
var _spacer2 = _interopRequireDefault(_spacer);
|
||||
|
||||
var _formatPropValue = require("./formatPropValue");
|
||||
|
||||
var _formatPropValue2 = _interopRequireDefault(_formatPropValue);
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : { default: obj };
|
||||
}
|
||||
|
||||
exports.default = function(
|
||||
name,
|
||||
hasValue,
|
||||
value,
|
||||
hasDefaultValue,
|
||||
defaultValue,
|
||||
inline,
|
||||
lvl,
|
||||
options
|
||||
) {
|
||||
if (!hasValue && !hasDefaultValue) {
|
||||
throw new Error(
|
||||
'The prop "' +
|
||||
name +
|
||||
'" has no value and no default: could not be formatted'
|
||||
);
|
||||
}
|
||||
|
||||
var usedValue = hasValue ? value : defaultValue;
|
||||
|
||||
var useBooleanShorthandSyntax = options.useBooleanShorthandSyntax,
|
||||
tabStop = options.tabStop;
|
||||
|
||||
var formattedPropValue = (0, _formatPropValue2.default)(
|
||||
usedValue,
|
||||
inline,
|
||||
lvl,
|
||||
options
|
||||
);
|
||||
|
||||
var attributeFormattedInline = " ";
|
||||
var attributeFormattedMultiline =
|
||||
"\n" + (0, _spacer2.default)(lvl + 1, tabStop);
|
||||
var isMultilineAttribute = formattedPropValue.includes("\n");
|
||||
|
||||
if (
|
||||
useBooleanShorthandSyntax &&
|
||||
formattedPropValue === "{false}" &&
|
||||
!hasDefaultValue
|
||||
) {
|
||||
// If a boolean is false and not different from it's default, we do not render the attribute
|
||||
attributeFormattedInline = "";
|
||||
attributeFormattedMultiline = "";
|
||||
} else if (useBooleanShorthandSyntax && formattedPropValue === "{true}") {
|
||||
attributeFormattedInline += "" + name;
|
||||
attributeFormattedMultiline += "" + name;
|
||||
} else {
|
||||
attributeFormattedInline += name + "=" + formattedPropValue;
|
||||
attributeFormattedMultiline += name + "=" + formattedPropValue;
|
||||
}
|
||||
|
||||
return {
|
||||
attributeFormattedInline: attributeFormattedInline,
|
||||
attributeFormattedMultiline: attributeFormattedMultiline,
|
||||
isMultilineAttribute: isMultilineAttribute,
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=formatProp.js.map
|
Reference in New Issue
Block a user