alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
30 lines (28 loc) • 900 B
JavaScript
import "../chunks/chunk-U5RRZUYZ.js";
// src/core/View.ts
import { Entry } from "./Entry.js";
import { Type } from "./Type.js";
import { createSelection } from "./pages/CreateSelection.js";
import { assign, entries } from "./util/Objects.js";
function view(selection, component) {
return assign(component, { selection });
}
var View;
((View2) => {
function getSelection(schema, summaryView, defaultSelection) {
let select;
for (const [name, type] of entries(schema)) {
const view2 = Type.meta(type)[summaryView];
if (view2) {
const selection = view2.selection();
select = select ? select.when(name, selection) : Entry.type.when(name, selection);
}
}
return select ? createSelection(select.orElse(defaultSelection)) : createSelection(defaultSelection);
}
View2.getSelection = getSelection;
})(View || (View = {}));
export {
View,
view
};