@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.
40 lines (37 loc) • 1.53 kB
JavaScript
import { __rest, __assign } from 'tslib';
import { createElement } from 'preact';
import { defaultSeedToken } from '../../../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 ? defaultSeedToken : _b, forwardRef = _a.forwardRef, rest = __rest(_a, ["children", "style", "theme", "forwardRef"]);
var presetStyles = typeof factoryStyles === 'function' ? factoryStyles(theme) : factoryStyles;
var combinedStyles = __assign(__assign({}, presetStyles), style);
var props = __assign(__assign({}, rest), { style: combinedStyles, ref: forwardRef });
var component = createElement(element, props, children);
return component;
};
}
export { createStyledComponent };
//# sourceMappingURL=styledFactory.js.map