@antv/t8
Version:
T8 is a text visualization solution for unstructured data within the AntV technology stack, and it is a declarative JSON Schema syntax that can be used to describe the content of data interpretation reports.
42 lines (38 loc) • 1.58 kB
JavaScript
;
var tslib = require('tslib');
var preact = require('preact');
var index = require('../../../theme/seed/index.js');
/**
* Universal component factory function
* Creates pre-styled components with consistent behavior
*
* @param options - Component factory options
* @returns A new pre-styled component
*
* @example
* // Create a simple div container component
* const Container = createStyledComponent({
* element: 'div',
* styleFactory: getContainerStyle,
* forwardRef: true
* });
*
* // Create a fixed-style mark component
* const Bold = createStyledComponent({
* element: 'strong'
* });
*/
function createStyledComponent(options) {
var element = options.element, _a = options.factoryStyles, factoryStyles = _a === void 0 ? {} : _a;
// Component without size parameter
return function Component(_a) {
var children = _a.children, style = _a.style, _b = _a.theme, theme = _b === void 0 ? index.defaultSeedToken : _b, forwardRef = _a.forwardRef, rest = tslib.__rest(_a, ["children", "style", "theme", "forwardRef"]);
var presetStyles = typeof factoryStyles === 'function' ? factoryStyles(theme) : factoryStyles;
var combinedStyles = tslib.__assign(tslib.__assign({}, presetStyles), style);
var props = tslib.__assign(tslib.__assign({}, rest), { style: combinedStyles, ref: forwardRef });
var component = preact.createElement(element, props, children);
return component;
};
}
exports.createStyledComponent = createStyledComponent;
//# sourceMappingURL=styledFactory.js.map