1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.default = void 0;
|
5 | exports.jsx = jsx;
|
6 | exports.jsx2 = jsx2;
|
7 | exports.resolveVariants = void 0;
|
8 | exports.varsToStyles = varsToStyles;
|
9 |
|
10 | var _react = require("react");
|
11 |
|
12 | exports.F = _react.Fragment;
|
13 | const _excluded = ["css", "className"];
|
14 |
|
15 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
16 |
|
17 | const resolveVariants = variants => !variants ? '' : variants.filter(Boolean).join(' ');
|
18 |
|
19 | exports.resolveVariants = resolveVariants;
|
20 |
|
21 | function varsToStyles(props, vars) {
|
22 | if (!vars || !vars.length) return props.style;
|
23 | const style = Object.assign({}, props.style);
|
24 | vars.forEach(([id, value, unit = '']) => {
|
25 | const result = typeof value === 'function' ? value(props) : value;
|
26 | style[`--${id}`] = `${result}${unit}`;
|
27 | });
|
28 | return style;
|
29 | }
|
30 |
|
31 | function jsx2(fn, type, props, ...args) {
|
32 | if (props && props.css) {
|
33 | const {
|
34 | css,
|
35 | className
|
36 | } = props,
|
37 | childProps = _objectWithoutPropertiesLoose(props, _excluded);
|
38 |
|
39 | const componentClassName = css[0].cls2 || css[0].cls1;
|
40 | childProps.style = varsToStyles(childProps, css[1]);
|
41 | childProps.className = `${className ? `${className} ${componentClassName}` : componentClassName} ${resolveVariants(css[2])}`;
|
42 | props = childProps;
|
43 | }
|
44 |
|
45 | return fn(type, props, ...args);
|
46 | }
|
47 |
|
48 | function jsx(type, props, ...children) {
|
49 | return jsx2(_react.createElement, type, props, ...children);
|
50 | }
|
51 |
|
52 | jsx.F = _react.Fragment;
|
53 | jsx.jsx2 = jsx2;
|
54 |
|
55 |
|
56 |
|
57 | var _default = jsx;
|
58 | exports.default = _default; |
\ | No newline at end of file |