boxwood 0.67.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +20 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -474,8 +474,28 @@ i18n.load = function () {
|
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
+
function component(fn, styles) {
|
|
478
|
+
function execute(a, b) {
|
|
479
|
+
if (typeof a === "string" || Array.isArray(a)) {
|
|
480
|
+
return fn({}, a)
|
|
481
|
+
}
|
|
482
|
+
return fn(a, b || [])
|
|
483
|
+
}
|
|
484
|
+
return function (a, b) {
|
|
485
|
+
const tree = execute(a, b)
|
|
486
|
+
if (styles) {
|
|
487
|
+
if (Array.isArray(tree)) {
|
|
488
|
+
return tree.concat(styles.css)
|
|
489
|
+
}
|
|
490
|
+
return [tree, styles.css]
|
|
491
|
+
}
|
|
492
|
+
return tree
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
477
496
|
module.exports = {
|
|
478
497
|
compile,
|
|
498
|
+
component,
|
|
479
499
|
classes,
|
|
480
500
|
doctype,
|
|
481
501
|
escape: escapeHTML,
|