leanweb 1.1.9 → 1.2.2
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/README.md +6 -0
- package/commands/dist.js +5 -0
- package/package.json +16 -16
- package/templates/lib/lw-element.js +16 -25
package/README.md
CHANGED
|
@@ -688,6 +688,12 @@ being notified when a next event is fired.
|
|
|
688
688
|
parameters. `eventName` is the name of the event, and `data` is the payload data
|
|
689
689
|
of the event.
|
|
690
690
|
|
|
691
|
+
### Post dist hook
|
|
692
|
+
|
|
693
|
+
If `post-dist` file is present in the project root directory, it will be called
|
|
694
|
+
after `lw dist` is done. This could be useful to copy `dist/\*` to somewhere
|
|
695
|
+
else.
|
|
696
|
+
|
|
691
697
|
## More examples and tutorials
|
|
692
698
|
|
|
693
699
|
https://leanweb.app
|
package/commands/dist.js
CHANGED
|
@@ -61,5 +61,10 @@ if (args.length >= 3) {
|
|
|
61
61
|
project.resources?.forEach(resource => {
|
|
62
62
|
fse.copySync(`./${utils.dirs.build}/${resource}`, `./${utils.dirs.dist}/${resource}`, { dereference: true });
|
|
63
63
|
});
|
|
64
|
+
|
|
65
|
+
const postDistFile = './post-dist';
|
|
66
|
+
if (fs.existsSync(postDistFile) && fs.statSync(postDistFile).isFile()) {
|
|
67
|
+
await utils.exec(postDistFile);
|
|
68
|
+
}
|
|
64
69
|
});
|
|
65
70
|
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leanweb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Builds framework agnostic web components.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"leanweb": "leanweb.js",
|
|
@@ -20,25 +20,25 @@
|
|
|
20
20
|
"author": "Qian Chen",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.
|
|
24
|
-
"@babel/parser": "^7.
|
|
25
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
26
|
-
"@babel/preset-env": "^7.
|
|
27
|
-
"babel-loader": "^8.2.
|
|
28
|
-
"clean-css": "^5.3.
|
|
23
|
+
"@babel/core": "^7.18.10",
|
|
24
|
+
"@babel/parser": "^7.18.11",
|
|
25
|
+
"@babel/plugin-transform-runtime": "^7.18.10",
|
|
26
|
+
"@babel/preset-env": "^7.18.10",
|
|
27
|
+
"babel-loader": "^8.2.5",
|
|
28
|
+
"clean-css": "^5.3.1",
|
|
29
29
|
"css-loader": "^6.7.1",
|
|
30
|
-
"fs-extra": "^10.0
|
|
31
|
-
"globby": "^13.1.
|
|
30
|
+
"fs-extra": "^10.1.0",
|
|
31
|
+
"globby": "^13.1.2",
|
|
32
32
|
"html-minifier": "^4.0.0",
|
|
33
|
-
"isomorphic-git": "^1.
|
|
33
|
+
"isomorphic-git": "^1.19.1",
|
|
34
34
|
"json5-loader": "^4.0.1",
|
|
35
35
|
"node-watch": "^0.7.3",
|
|
36
|
-
"parse5": "^
|
|
36
|
+
"parse5": "^7.0.0",
|
|
37
37
|
"raw-loader": "^4.0.2",
|
|
38
|
-
"sass": "^1.
|
|
39
|
-
"sass-loader": "^
|
|
40
|
-
"semver": "^7.3.
|
|
41
|
-
"webpack": "^5.
|
|
42
|
-
"webpack-dev-server": "^4.
|
|
38
|
+
"sass": "^1.54.3",
|
|
39
|
+
"sass-loader": "^13.0.2",
|
|
40
|
+
"semver": "^7.3.7",
|
|
41
|
+
"webpack": "^5.74.0",
|
|
42
|
+
"webpack-dev-server": "^4.9.3"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -193,7 +193,7 @@ export default class LWElement extends HTMLElement {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
_bindMethods() {
|
|
196
|
-
const methodNames = ['update'
|
|
196
|
+
const methodNames = ['update'];
|
|
197
197
|
const proto = Object.getPrototypeOf(this);
|
|
198
198
|
methodNames.push(...Object.getOwnPropertyNames(proto).filter(name => hasMethod(proto, name)));
|
|
199
199
|
methodNames.push(...Object.getOwnPropertyNames(this).filter(name => hasMethod(this, name)));
|
|
@@ -284,16 +284,17 @@ export default class LWElement extends HTMLElement {
|
|
|
284
284
|
modelNode.do_not_update = true;
|
|
285
285
|
object[propertyExpr] = modelNode.value * 1;
|
|
286
286
|
} else if (modelNode.type === 'checkbox') {
|
|
287
|
-
if (
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
object[propertyExpr].splice(index, 1);
|
|
287
|
+
if (Array.isArray(object[propertyExpr])) {
|
|
288
|
+
if (modelNode.checked) {
|
|
289
|
+
object[propertyExpr].push(modelNode.value);
|
|
290
|
+
} else {
|
|
291
|
+
const index = object[propertyExpr].indexOf(modelNode.value);
|
|
292
|
+
if (index > -1) {
|
|
293
|
+
object[propertyExpr].splice(index, 1);
|
|
294
|
+
}
|
|
296
295
|
}
|
|
296
|
+
} else {
|
|
297
|
+
object[propertyExpr] = modelNode.checked;
|
|
297
298
|
}
|
|
298
299
|
} else if (modelNode.type === 'select-multiple') {
|
|
299
300
|
if (!Array.isArray(object[propertyExpr])) {
|
|
@@ -326,7 +327,11 @@ export default class LWElement extends HTMLElement {
|
|
|
326
327
|
const interpolation = this.ast[key];
|
|
327
328
|
const parsed = parser.evaluate(interpolation.ast, context, interpolation.loc);
|
|
328
329
|
if (modelNode.type === 'checkbox') {
|
|
329
|
-
|
|
330
|
+
if (Array.isArray(parsed[0])) {
|
|
331
|
+
modelNode.checked = parsed[0].includes?.(modelNode.value);
|
|
332
|
+
} else {
|
|
333
|
+
modelNode.checked = !!parsed[0];
|
|
334
|
+
}
|
|
330
335
|
} else if (modelNode.type === 'radio') {
|
|
331
336
|
modelNode.checked = parsed[0] === modelNode.value;
|
|
332
337
|
} else if (modelNode.type === 'select-multiple') {
|
|
@@ -467,18 +472,4 @@ export default class LWElement extends HTMLElement {
|
|
|
467
472
|
this.update(node);
|
|
468
473
|
});
|
|
469
474
|
}
|
|
470
|
-
|
|
471
|
-
applyStyles(...styles) {
|
|
472
|
-
if (!styles) {
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
styles.forEach(style => {
|
|
476
|
-
if (typeof style !== 'string') {
|
|
477
|
-
style = style.toString();
|
|
478
|
-
}
|
|
479
|
-
const styleNode = document.createElement('style');
|
|
480
|
-
styleNode.innerHTML = style;
|
|
481
|
-
this.shadowRoot.appendChild(styleNode);
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
475
|
}
|