updated approach to deps, mod loading, main entrypoints

This commit is contained in:
Stewart Allen 2022-02-20 12:56:43 -05:00
commit 19522665b2
21 changed files with 299 additions and 321 deletions

View file

@ -2,35 +2,12 @@
"use strict";
(function() {
gapp.register("moto.webui", [
gapp.register('moto.webui', [
"moto.license", // dep: moto.license
"add.array", // dep: add.array
]);
"moto.license", // dep: moto.license
"add.array", // dep: add.array
let moto = self.moto = self.moto || {};
if (moto.webui) return;
// window ui helpers
Object.assign(self, {
$: (id) => {
return document.getElementById(id);
},
$d: (id, v) => {
$(id).style.display = v;
},
$h: (id, h) => {
$(id).innerHTML = h;
},
estop: (evt) => {
evt.stopPropagation();
evt.preventDefault();
}
});
], (root, exports) => {
let nextid = 1;
@ -92,7 +69,7 @@ function build(data, context) {
}
// core html builder funtions
let h = self.h = moto.webui = {
let h = exports({
bind: (el, data, opt = {}) => {
let ctx = [];
let html = build(data, ctx).join('');
@ -120,7 +97,29 @@ let h = self.h = moto.webui = {
}
return { type, attr, innr };
}
};
});
// window ui helpers
gapp.overlay(root, {
$: (id) => {
return document.getElementById(id);
},
$d: (id, v) => {
$(id).style.display = v;
},
$h: (id, h) => {
$(id).innerHTML = h;
},
h,
estop: (evt) => {
evt.stopPropagation();
evt.preventDefault();
}
});
// add common element types
["a", "i", "div", "span", "label", "input", "button", "svg"].forEach(type => {
@ -129,4 +128,4 @@ let h = self.h = moto.webui = {
}
});
})();
});