@c2n/core 0.0.6
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/LICENSE +21 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/controllers/breakpoints-observer.d.ts +15 -0
- package/dist/controllers/breakpoints-observer.d.ts.map +1 -0
- package/dist/controllers/breakpoints-observer.js +36 -0
- package/dist/controllers/breakpoints-observer.js.map +1 -0
- package/dist/controllers/context-consumer.d.ts +25 -0
- package/dist/controllers/context-consumer.d.ts.map +1 -0
- package/dist/controllers/context-consumer.js +69 -0
- package/dist/controllers/context-consumer.js.map +1 -0
- package/dist/css-helper.d.ts +3 -0
- package/dist/css-helper.d.ts.map +1 -0
- package/dist/css-helper.js +8 -0
- package/dist/css-helper.js.map +1 -0
- package/dist/dom-helper.d.ts +9 -0
- package/dist/dom-helper.d.ts.map +1 -0
- package/dist/dom-helper.js +66 -0
- package/dist/dom-helper.js.map +1 -0
- package/dist/lit-helper.d.ts +5 -0
- package/dist/lit-helper.d.ts.map +1 -0
- package/dist/lit-helper.js +9 -0
- package/dist/lit-helper.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Nguyen Thai Vinh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/lit-html/development/directive.d.ts","../../../node_modules/@types/trusted-types/lib/index.d.ts","../../../node_modules/lit-html/development/lit-html.d.ts","../../../node_modules/lit-html/development/directives/class-map.d.ts","../src/css-helper.ts","../../../node_modules/lit-html/development/is-server.d.ts","../src/dom-helper.ts","../src/lit-helper.ts","../../../node_modules/@lit/reactive-element/development/css-tag.d.ts","../../../node_modules/@lit/reactive-element/development/reactive-controller.d.ts","../../../node_modules/@lit/reactive-element/development/reactive-element.d.ts","../src/controllers/breakpoints-observer.ts","../../../node_modules/@lit/context/development/lib/create-context.d.ts","../../../node_modules/@lit/context/development/lib/context-request-event.d.ts","../../../node_modules/@lit/context/development/lib/controllers/context-consumer.d.ts","../../../node_modules/@lit/context/development/lib/value-notifier.d.ts","../../../node_modules/@lit/context/development/lib/controllers/context-provider.d.ts","../../../node_modules/@lit/context/development/lib/context-root.d.ts","../../../node_modules/@lit/context/development/lib/decorators/provide.d.ts","../../../node_modules/@lit/context/development/lib/decorators/consume.d.ts","../../../node_modules/@lit/context/development/index.d.ts","../src/controllers/context-consumer.ts"],"fileIdsList":[[60,61,62,64,65,66,67],[60],[58,60],[58,60,61,63],[61],[56,57],[50],[48,50],[48,49],[58],[58,68],[51],[53]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},{"version":"00cb63103f9670f8094c238a4a7e252c8b4c06ba371fea5c44add7e41b7247e4","impliedFormat":99},{"version":"15fe687c59d62741b4494d5e623d497d55eb38966ecf5bea7f36e48fc3fbe15e","impliedFormat":1},{"version":"e09db3291e6b440f7debed2227d8357e80c95987a0d0d67ac17521d8f7b11bdb","impliedFormat":99},{"version":"9e77270468dc77ee3f0182f377a6022b37cce590cab79205c497cfb964ee2d20","impliedFormat":99},{"version":"f320b8514d20e37f6b957334b715d79c9781baf54fda8f9192c1dc38e16d449b","signature":"bb7529605ce5ea3a70da2155f39510884954a39abd51cf787eb8a303f1e3ca5d"},{"version":"1bcd560deed90a43c51b08aa18f7f55229f2e30974ab5ed1b7bb5721be379013","impliedFormat":99},{"version":"79e2949c398e6b285aa318b8d7d2ff3d7a321af1d88545e8470759993bd4530b","signature":"6add2e1b34a99ef0864067f4d7126c60320743d9b73236022b0b5ef7e217a6d1"},{"version":"b0d5c84d6c99925a32b5c22858aa9832a57e120dabfe585cf0f39fe45835361b","signature":"239d82781d59e4dbefe31427f44154f2b616ee2ca8b34194bc7a75660df831e6"},{"version":"74012d464fbc5354ca3a7d5e71bee43b17da01a853c8ff10971bbe3680c76f40","impliedFormat":99},{"version":"5e30131b6a5587fe666926ad1d9807e733c0a597ed12d682669fcaa331aea576","impliedFormat":99},{"version":"a0f82d2f9450bd147a8c137798d9501bd49b7c9e118f75b07b76709ff39b6b55","affectsGlobalScope":true,"impliedFormat":99},{"version":"361aaaeedfa37b1da60c8017b07a9968062968f71561c479bc83944063f5804d","signature":"cc8929ab4c4e9be68dd16405c46e97463b36038700f49d070e2d24ee4139c87c"},{"version":"7455f2d44bbd248413e4ab8c3ff847413d9ce327967dba66f0b51880f60fb653","impliedFormat":99},{"version":"9dd82c87281e106bdcb227550251fcc6b55a6eb555152bec5c6ce408345ffc57","affectsGlobalScope":true,"impliedFormat":99},{"version":"38df32d74f5cb92d08a7ace088d631e65fd4ae41fd1098ef74ad8efab03763ac","impliedFormat":99},{"version":"ff169075cb4df455eaa1dc4972416ae6981adca96429ed698a306da3d5a2e241","impliedFormat":99},{"version":"5dd01302b91c8fb2aea381396623c5463c47a41c1b5d675672a075c5d8aa164c","affectsGlobalScope":true,"impliedFormat":99},{"version":"f3731eb0da8be50797a04467e9021082654c55d6cbabaf17a9d505c0ff3033cc","impliedFormat":99},{"version":"6146b370459b8f7e81f61b7dd9022fb06509cc20d34514dc782c9ce538fd8ec9","impliedFormat":99},{"version":"a585baba6d92b7f5052a11c3a5d0bcc73657180bb6066cf70e1b4664df4e8363","impliedFormat":99},{"version":"1aacab8ad3bd52a3a508b9c07bb341d680448fc9ee45591708ded8113c1be517","impliedFormat":99},{"version":"d719146ac4cda335a8e970ba5918cf154be98b83c6f4b3acb4c02f6617cd92f6","signature":"75f5083114303492bddf59e3b81debed86d2a422666bb2d7c69513ad64a61a26"}],"root":[52,54,55,59,69],"options":{"allowImportingTsExtensions":false,"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":false,"experimentalDecorators":true,"inlineSources":true,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"tsBuildInfoFile":"./.tsbuildinfo","useDefineForClassFields":false,"verbatimModuleSyntax":true},"referencedMap":[[68,1],[61,2],[62,3],[64,4],[67,3],[66,3],[63,5],[58,6],[48,7],[51,8],[50,9],[59,10],[69,11],[52,12],[54,13]],"latestChangedDtsFile":"./controllers/context-consumer.d.ts","version":"6.0.3"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from '@lit/reactive-element';
|
|
2
|
+
export type Callback = (isInitial?: boolean) => void;
|
|
3
|
+
export declare class BreakpointsObserver implements ReactiveController {
|
|
4
|
+
private host;
|
|
5
|
+
private mediaQueries;
|
|
6
|
+
private callback;
|
|
7
|
+
private mqls;
|
|
8
|
+
previousBreakpoint: string;
|
|
9
|
+
currentBreakpoint: string;
|
|
10
|
+
constructor(host: ReactiveControllerHost, mediaQueries: string[], callback: Callback);
|
|
11
|
+
hostConnected(): void;
|
|
12
|
+
hostDisconnected(): void;
|
|
13
|
+
handleMediaChange: (event: MediaQueryListEvent) => void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=breakpoints-observer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breakpoints-observer.d.ts","sourceRoot":"","sources":["../../src/controllers/breakpoints-observer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAEvF,MAAM,MAAM,QAAQ,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;AAEpD,qBAAa,mBAAoB,YAAW,kBAAkB;IAO1D,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,QAAQ;IARlB,OAAO,CAAC,IAAI,CAAuB;IAEnC,kBAAkB,EAAE,MAAM,CAAK;IAC/B,iBAAiB,EAAE,MAAM,CAAK;gBAGpB,IAAI,EAAE,sBAAsB,EAC5B,YAAY,EAAE,MAAM,EAAE,EACtB,QAAQ,EAAE,QAAQ;IAK5B,aAAa,IAAI,IAAI;IAcrB,gBAAgB,IAAI,IAAI;IAIxB,iBAAiB,GAAI,OAAO,mBAAmB,UAO9C;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class BreakpointsObserver {
|
|
2
|
+
constructor(host, mediaQueries, callback) {
|
|
3
|
+
this.host = host;
|
|
4
|
+
this.mediaQueries = mediaQueries;
|
|
5
|
+
this.callback = callback;
|
|
6
|
+
this.mqls = [];
|
|
7
|
+
this.previousBreakpoint = '';
|
|
8
|
+
this.currentBreakpoint = '';
|
|
9
|
+
this.handleMediaChange = (event) => {
|
|
10
|
+
if (event.matches) {
|
|
11
|
+
this.previousBreakpoint = this.currentBreakpoint;
|
|
12
|
+
this.currentBreakpoint = event.media;
|
|
13
|
+
this.callback();
|
|
14
|
+
this.host.requestUpdate();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
this.host.addController(this);
|
|
18
|
+
}
|
|
19
|
+
hostConnected() {
|
|
20
|
+
window.requestAnimationFrame(() => {
|
|
21
|
+
this.mediaQueries.forEach((query) => {
|
|
22
|
+
const mql = window.matchMedia(query);
|
|
23
|
+
if (mql.matches) {
|
|
24
|
+
this.currentBreakpoint = query;
|
|
25
|
+
this.callback(true);
|
|
26
|
+
}
|
|
27
|
+
mql.addEventListener('change', this.handleMediaChange);
|
|
28
|
+
this.mqls.push(mql);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
hostDisconnected() {
|
|
33
|
+
this.mqls.forEach((item) => item.removeEventListener('change', this.handleMediaChange));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=breakpoints-observer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breakpoints-observer.js","sourceRoot":"","sources":["../../src/controllers/breakpoints-observer.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,mBAAmB;IAM9B,YACU,IAA4B,EAC5B,YAAsB,EACtB,QAAkB;QAFlB,SAAI,GAAJ,IAAI,CAAwB;QAC5B,iBAAY,GAAZ,YAAY,CAAU;QACtB,aAAQ,GAAR,QAAQ,CAAU;QARpB,SAAI,GAAqB,EAAE,CAAA;QAEnC,uBAAkB,GAAW,EAAE,CAAA;QAC/B,sBAAiB,GAAW,EAAE,CAAA;QA4B9B,sBAAiB,GAAG,CAAC,KAA0B,EAAE,EAAE;YACjD,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,CAAA;gBAChD,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,KAAK,CAAA;gBACpC,IAAI,CAAC,QAAQ,EAAE,CAAA;gBACf,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAA;YAC3B,CAAC;QACH,CAAC,CAAA;QA5BC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IAED,aAAa;QACX,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE;YAChC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBAClC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;gBACpC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;oBAChB,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAA;oBAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;gBACrB,CAAC;gBACD,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;gBACtD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACrB,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACzF,CAAC;CAUF","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from '@lit/reactive-element'\n\nexport type Callback = (isInitial?: boolean) => void\n\nexport class BreakpointsObserver implements ReactiveController {\n private mqls: MediaQueryList[] = []\n\n previousBreakpoint: string = ''\n currentBreakpoint: string = ''\n\n constructor(\n private host: ReactiveControllerHost,\n private mediaQueries: string[],\n private callback: Callback,\n ) {\n this.host.addController(this)\n }\n\n hostConnected(): void {\n window.requestAnimationFrame(() => {\n this.mediaQueries.forEach((query) => {\n const mql = window.matchMedia(query)\n if (mql.matches) {\n this.currentBreakpoint = query\n this.callback(true)\n }\n mql.addEventListener('change', this.handleMediaChange)\n this.mqls.push(mql)\n })\n })\n }\n\n hostDisconnected(): void {\n this.mqls.forEach((item) => item.removeEventListener('change', this.handleMediaChange))\n }\n\n handleMediaChange = (event: MediaQueryListEvent) => {\n if (event.matches) {\n this.previousBreakpoint = this.currentBreakpoint\n this.currentBreakpoint = event.media\n this.callback()\n this.host.requestUpdate()\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Context, ContextType } from '@lit/context';
|
|
2
|
+
import type { ReactiveController, ReactiveControllerHost } from '@lit/reactive-element';
|
|
3
|
+
export interface Options<C extends Context<unknown, unknown>> {
|
|
4
|
+
context: C;
|
|
5
|
+
callback?: (value: ContextType<C>, dispose?: () => void) => void;
|
|
6
|
+
subscribe?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class ContextConsumer<C extends Context<unknown, unknown>, HostElement extends ReactiveControllerHost & HTMLElement> implements ReactiveController {
|
|
9
|
+
protected host: HostElement;
|
|
10
|
+
private context;
|
|
11
|
+
private callback?;
|
|
12
|
+
private subscribe;
|
|
13
|
+
private provided;
|
|
14
|
+
value?: ContextType<C>;
|
|
15
|
+
constructor(host: HostElement, options: Options<C>);
|
|
16
|
+
/** @deprecated Use new ContextConsumer(host, options) */
|
|
17
|
+
constructor(host: HostElement, context: C, callback?: (value: ContextType<C>, dispose?: () => void) => void, subscribe?: boolean);
|
|
18
|
+
private unsubscribe?;
|
|
19
|
+
applyContext(): void;
|
|
20
|
+
unApplyContext(): void;
|
|
21
|
+
hostDisconnected(): void;
|
|
22
|
+
private dispatchRequest;
|
|
23
|
+
private _callback;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=context-consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-consumer.d.ts","sourceRoot":"","sources":["../../src/controllers/context-consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAEvF,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1D,OAAO,EAAE,CAAC,CAAA;IACV,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;IAChE,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,qBAAa,eAAe,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,SAAS,sBAAsB,GAAG,WAAW,CAAE,YAAW,kBAAkB;IACvJ,SAAS,CAAC,IAAI,EAAE,WAAW,CAAA;IAC3B,OAAO,CAAC,OAAO,CAAG;IAClB,OAAO,CAAC,QAAQ,CAAC,CAAuD;IACxE,OAAO,CAAC,SAAS,CAAQ;IAEzB,OAAO,CAAC,QAAQ,CAAQ;IAExB,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAY;gBAEtB,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAClD,yDAAyD;gBAC7C,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,EAAE,SAAS,CAAC,EAAE,OAAO;IAkBhI,OAAO,CAAC,WAAW,CAAC,CAAY;IAEhC,YAAY,IAAI,IAAI;IAIpB,cAAc;IAOd,gBAAgB,IAAI,IAAI;IAIxB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,SAAS,CA8BhB;CACF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ContextEvent } from '@lit/context';
|
|
2
|
+
export class ContextConsumer {
|
|
3
|
+
constructor(host, contextOrOptions, callback, subscribe) {
|
|
4
|
+
this.subscribe = false;
|
|
5
|
+
this.provided = false;
|
|
6
|
+
this.value = undefined;
|
|
7
|
+
// This function must have stable identity to properly dedupe in ContextRoot
|
|
8
|
+
// if this element connects multiple times.
|
|
9
|
+
this._callback = (value, unsubscribe) => {
|
|
10
|
+
// some providers will pass an unsubscribe function indicating they may provide future values
|
|
11
|
+
if (this.unsubscribe) {
|
|
12
|
+
// if the unsubscribe function changes this implies we have changed provider
|
|
13
|
+
if (this.unsubscribe !== unsubscribe) {
|
|
14
|
+
// cleanup the old provider
|
|
15
|
+
this.provided = false;
|
|
16
|
+
this.unsubscribe();
|
|
17
|
+
}
|
|
18
|
+
// if we don't support subscription, immediately unsubscribe
|
|
19
|
+
if (!this.subscribe) {
|
|
20
|
+
this.unsubscribe();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// store the value so that it can be retrieved from the controller
|
|
24
|
+
this.value = value;
|
|
25
|
+
// schedule an update in case this value is used in a template
|
|
26
|
+
this.host.requestUpdate();
|
|
27
|
+
// only invoke callback if we are either expecting updates or have not yet
|
|
28
|
+
// been provided a value
|
|
29
|
+
if (!this.provided || this.subscribe) {
|
|
30
|
+
this.provided = true;
|
|
31
|
+
if (this.callback) {
|
|
32
|
+
this.callback(value, unsubscribe);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
this.unsubscribe = unsubscribe;
|
|
36
|
+
};
|
|
37
|
+
this.host = host;
|
|
38
|
+
// This is a potentially fragile duck-type. It means a context object can't
|
|
39
|
+
// have a property name context and be used in positional argument form.
|
|
40
|
+
if (contextOrOptions.context !== undefined) {
|
|
41
|
+
const options = contextOrOptions;
|
|
42
|
+
this.context = options.context;
|
|
43
|
+
this.callback = options.callback;
|
|
44
|
+
this.subscribe = options.subscribe ?? false;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.context = contextOrOptions;
|
|
48
|
+
this.callback = callback;
|
|
49
|
+
this.subscribe = subscribe ?? false;
|
|
50
|
+
}
|
|
51
|
+
this.host.addController(this);
|
|
52
|
+
}
|
|
53
|
+
applyContext() {
|
|
54
|
+
this.dispatchRequest();
|
|
55
|
+
}
|
|
56
|
+
unApplyContext() {
|
|
57
|
+
if (this.unsubscribe) {
|
|
58
|
+
this.unsubscribe();
|
|
59
|
+
this.unsubscribe = undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
hostDisconnected() {
|
|
63
|
+
this.unApplyContext();
|
|
64
|
+
}
|
|
65
|
+
dispatchRequest() {
|
|
66
|
+
this.host.dispatchEvent(new ContextEvent(this.context, this.host, this._callback, this.subscribe));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=context-consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-consumer.js","sourceRoot":"","sources":["../../src/controllers/context-consumer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAS3C,MAAM,OAAO,eAAe;IAa1B,YAAY,IAAiB,EAAE,gBAAgC,EAAE,QAAgE,EAAE,SAAmB;QAT9I,cAAS,GAAG,KAAK,CAAA;QAEjB,aAAQ,GAAG,KAAK,CAAA;QAExB,UAAK,GAAoB,SAAS,CAAA;QA2ClC,4EAA4E;QAC5E,2CAA2C;QACnC,cAAS,GAAoC,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;YAC1E,6FAA6F;YAC7F,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,4EAA4E;gBAC5E,IAAI,IAAI,CAAC,WAAW,KAAK,WAAW,EAAE,CAAC;oBACrC,2BAA2B;oBAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;oBACrB,IAAI,CAAC,WAAW,EAAE,CAAA;gBACpB,CAAC;gBACD,4DAA4D;gBAC5D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;oBACpB,IAAI,CAAC,WAAW,EAAE,CAAA;gBACpB,CAAC;YACH,CAAC;YAED,kEAAkE;YAClE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;YAClB,8DAA8D;YAC9D,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAA;YAEzB,0EAA0E;YAC1E,wBAAwB;YACxB,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACrC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;gBACpB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAClB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;gBACnC,CAAC;YACH,CAAC;YAED,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAChC,CAAC,CAAA;QArEC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,2EAA2E;QAC3E,wEAAwE;QACxE,IAAK,gBAA+B,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC3D,MAAM,OAAO,GAAG,gBAA8B,CAAA;YAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;YAC9B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;YAChC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAA;QAC7C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,gBAAqB,CAAA;YACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;YACxB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,KAAK,CAAA;QACrC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IAID,YAAY;QACV,IAAI,CAAC,eAAe,EAAE,CAAA;IACxB,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,EAAE,CAAA;YAClB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;QAC9B,CAAC;IACH,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;IACpG,CAAC;CAmCF","sourcesContent":["import type { ContextCallback, Context, ContextType } from '@lit/context'\nimport { ContextEvent } from '@lit/context'\nimport type { ReactiveController, ReactiveControllerHost } from '@lit/reactive-element'\n\nexport interface Options<C extends Context<unknown, unknown>> {\n context: C\n callback?: (value: ContextType<C>, dispose?: () => void) => void\n subscribe?: boolean\n}\n\nexport class ContextConsumer<C extends Context<unknown, unknown>, HostElement extends ReactiveControllerHost & HTMLElement> implements ReactiveController {\n protected host: HostElement\n private context: C\n private callback?: (value: ContextType<C>, dispose?: () => void) => void\n private subscribe = false\n\n private provided = false\n\n value?: ContextType<C> = undefined\n\n constructor(host: HostElement, options: Options<C>)\n /** @deprecated Use new ContextConsumer(host, options) */\n constructor(host: HostElement, context: C, callback?: (value: ContextType<C>, dispose?: () => void) => void, subscribe?: boolean)\n constructor(host: HostElement, contextOrOptions: C | Options<C>, callback?: (value: ContextType<C>, dispose?: () => void) => void, subscribe?: boolean) {\n this.host = host\n // This is a potentially fragile duck-type. It means a context object can't\n // have a property name context and be used in positional argument form.\n if ((contextOrOptions as Options<C>).context !== undefined) {\n const options = contextOrOptions as Options<C>\n this.context = options.context\n this.callback = options.callback\n this.subscribe = options.subscribe ?? false\n } else {\n this.context = contextOrOptions as C\n this.callback = callback\n this.subscribe = subscribe ?? false\n }\n this.host.addController(this)\n }\n\n private unsubscribe?: () => void\n\n applyContext(): void {\n this.dispatchRequest()\n }\n\n unApplyContext() {\n if (this.unsubscribe) {\n this.unsubscribe()\n this.unsubscribe = undefined\n }\n }\n\n hostDisconnected(): void {\n this.unApplyContext()\n }\n\n private dispatchRequest() {\n this.host.dispatchEvent(new ContextEvent(this.context, this.host, this._callback, this.subscribe))\n }\n\n // This function must have stable identity to properly dedupe in ContextRoot\n // if this element connects multiple times.\n private _callback: ContextCallback<ContextType<C>> = (value, unsubscribe) => {\n // some providers will pass an unsubscribe function indicating they may provide future values\n if (this.unsubscribe) {\n // if the unsubscribe function changes this implies we have changed provider\n if (this.unsubscribe !== unsubscribe) {\n // cleanup the old provider\n this.provided = false\n this.unsubscribe()\n }\n // if we don't support subscription, immediately unsubscribe\n if (!this.subscribe) {\n this.unsubscribe()\n }\n }\n\n // store the value so that it can be retrieved from the controller\n this.value = value\n // schedule an update in case this value is used in a template\n this.host.requestUpdate()\n\n // only invoke callback if we are either expecting updates or have not yet\n // been provided a value\n if (!this.provided || this.subscribe) {\n this.provided = true\n if (this.callback) {\n this.callback(value, unsubscribe)\n }\n }\n\n this.unsubscribe = unsubscribe\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-helper.d.ts","sourceRoot":"","sources":["../src/css-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAEjE,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,QAM7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-helper.js","sourceRoot":"","sources":["../src/css-helper.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU,CAAC,MAAmB,EAAE,GAAc;IAC5D,IAAI,CAAC,MAAM,EAAE,SAAS;QAAE,OAAM;IAE9B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IAC5C,CAAC;AACH,CAAC","sourcesContent":["import type { ClassInfo } from 'lit-html/directives/class-map.js'\n\nexport function addClasses(target: HTMLElement, cls: ClassInfo) {\n if (!target?.classList) return\n\n for (const item of Object.keys(cls)) {\n target.classList.toggle(item, !!cls[item])\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const Breakpoints: {
|
|
2
|
+
Phone: string;
|
|
3
|
+
Tablet: string;
|
|
4
|
+
Desktop: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function redispatchEvent(host: HTMLElement, event: Event): boolean;
|
|
7
|
+
export declare function smartFixedPosition(fixed: boolean): void;
|
|
8
|
+
export declare function convertToUnit(str: string | number | null | undefined, unit?: string): string | undefined;
|
|
9
|
+
//# sourceMappingURL=dom-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-helper.d.ts","sourceRoot":"","sources":["../src/dom-helper.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;;;;CAIvB,CAAA;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,WAW9D;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,QAkChD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,SAAO,GAAG,MAAM,GAAG,SAAS,CAUtG"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isServer } from 'lit-html/is-server.js';
|
|
2
|
+
export const Breakpoints = {
|
|
3
|
+
Phone: '(max-width: 599.98px)',
|
|
4
|
+
Tablet: '(min-width: 600px) and (max-width: 959.98px)',
|
|
5
|
+
Desktop: '(min-width: 960px)',
|
|
6
|
+
};
|
|
7
|
+
export function redispatchEvent(host, event) {
|
|
8
|
+
if (event.bubbles) {
|
|
9
|
+
event.stopPropagation();
|
|
10
|
+
}
|
|
11
|
+
const copy = Reflect.construct(event.constructor, [event.type, event]);
|
|
12
|
+
const dispatched = host.dispatchEvent(copy);
|
|
13
|
+
if (!dispatched) {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
}
|
|
16
|
+
return dispatched;
|
|
17
|
+
}
|
|
18
|
+
export function smartFixedPosition(fixed) {
|
|
19
|
+
if (isServer)
|
|
20
|
+
return;
|
|
21
|
+
const el = document.documentElement;
|
|
22
|
+
const scrollbarWidth = window.innerWidth - document.documentElement.offsetWidth;
|
|
23
|
+
if (fixed) {
|
|
24
|
+
el.style.setProperty('--c2n-body-scroll-x', convertToUnit(-el.scrollLeft));
|
|
25
|
+
el.style.setProperty('--c2n-body-scroll-y', convertToUnit(-el.scrollTop));
|
|
26
|
+
el.style.setProperty('--c2n-scrollbar-offset', convertToUnit(scrollbarWidth));
|
|
27
|
+
el.style.setProperty('overflow', 'hidden');
|
|
28
|
+
el.style.setProperty('padding-inline-end', 'var(--c2n-scrollbar-offset)');
|
|
29
|
+
el.style.setProperty('position', 'fixed');
|
|
30
|
+
el.style.setProperty('top', 'var(--c2n-body-scroll-y)');
|
|
31
|
+
el.style.setProperty('left', 'var(--c2n-body-scroll-x)');
|
|
32
|
+
el.style.setProperty('width', '100%');
|
|
33
|
+
el.style.setProperty('height', '100%');
|
|
34
|
+
}
|
|
35
|
+
else if (el.style.getPropertyValue('--c2n-body-scroll-x')) {
|
|
36
|
+
const x = parseFloat(el.style.getPropertyValue('--c2n-body-scroll-x'));
|
|
37
|
+
const y = parseFloat(el.style.getPropertyValue('--c2n-body-scroll-y'));
|
|
38
|
+
el.style.removeProperty('overflow');
|
|
39
|
+
el.style.removeProperty('padding-inline-end');
|
|
40
|
+
el.style.removeProperty('position');
|
|
41
|
+
el.style.removeProperty('top');
|
|
42
|
+
el.style.removeProperty('left');
|
|
43
|
+
el.style.removeProperty('width');
|
|
44
|
+
el.style.removeProperty('height');
|
|
45
|
+
el.style.removeProperty('--c2n-body-scroll-x');
|
|
46
|
+
el.style.removeProperty('--c2n-body-scroll-y');
|
|
47
|
+
el.style.removeProperty('--c2n-scrollbar-offset');
|
|
48
|
+
el.scrollLeft = -x;
|
|
49
|
+
el.scrollTop = -y;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function convertToUnit(str, unit = 'px') {
|
|
53
|
+
if (str == null || str === '') {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
else if (isNaN(+str)) {
|
|
57
|
+
return String(str);
|
|
58
|
+
}
|
|
59
|
+
else if (!isFinite(+str)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return `${Number(str)}${unit}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=dom-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-helper.js","sourceRoot":"","sources":["../src/dom-helper.ts"],"names":[],"mappings":"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","sourcesContent":["import { isServer } from 'lit-html/is-server.js'\n\nexport const Breakpoints = {\n Phone: '(max-width: 599.98px)',\n Tablet: '(min-width: 600px) and (max-width: 959.98px)',\n Desktop: '(min-width: 960px)',\n}\n\nexport function redispatchEvent(host: HTMLElement, event: Event) {\n if (event.bubbles) {\n event.stopPropagation()\n }\n\n const copy = Reflect.construct(event.constructor, [event.type, event])\n const dispatched = host.dispatchEvent(copy)\n if (!dispatched) {\n event.preventDefault()\n }\n return dispatched\n}\n\nexport function smartFixedPosition(fixed: boolean) {\n if (isServer) return\n const el = document.documentElement\n const scrollbarWidth = window.innerWidth - document.documentElement.offsetWidth\n if (fixed) {\n el.style.setProperty('--c2n-body-scroll-x', convertToUnit(-el.scrollLeft)!)\n el.style.setProperty('--c2n-body-scroll-y', convertToUnit(-el.scrollTop)!)\n el.style.setProperty('--c2n-scrollbar-offset', convertToUnit(scrollbarWidth)!)\n\n el.style.setProperty('overflow', 'hidden')\n el.style.setProperty('padding-inline-end', 'var(--c2n-scrollbar-offset)')\n el.style.setProperty('position', 'fixed')\n el.style.setProperty('top', 'var(--c2n-body-scroll-y)')\n el.style.setProperty('left', 'var(--c2n-body-scroll-x)')\n el.style.setProperty('width', '100%')\n el.style.setProperty('height', '100%')\n } else if (el.style.getPropertyValue('--c2n-body-scroll-x')) {\n const x = parseFloat(el.style.getPropertyValue('--c2n-body-scroll-x'))\n const y = parseFloat(el.style.getPropertyValue('--c2n-body-scroll-y'))\n\n el.style.removeProperty('overflow')\n el.style.removeProperty('padding-inline-end')\n el.style.removeProperty('position')\n el.style.removeProperty('top')\n el.style.removeProperty('left')\n el.style.removeProperty('width')\n el.style.removeProperty('height')\n\n el.style.removeProperty('--c2n-body-scroll-x')\n el.style.removeProperty('--c2n-body-scroll-y')\n el.style.removeProperty('--c2n-scrollbar-offset')\n el.scrollLeft = -x\n el.scrollTop = -y\n }\n}\n\nexport function convertToUnit(str: string | number | null | undefined, unit = 'px'): string | undefined {\n if (str == null || str === '') {\n return undefined\n } else if (isNaN(+str!)) {\n return String(str)\n } else if (!isFinite(+str!)) {\n return undefined\n } else {\n return `${Number(str)}${unit}`\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-helper.d.ts","sourceRoot":"","sources":["../src/lit-helper.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB;yBACZ,MAAM,EAAE;2BAGN,MAAM;CAG9B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-helper.js","sourceRoot":"","sources":["../src/lit-helper.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,WAAW,EAAE,CAAC,KAAe,EAAE,EAAE;QAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACpD,CAAC;IACD,aAAa,EAAE,CAAC,KAAa,EAAE,EAAE;QAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACtC,CAAC;CACF,CAAA","sourcesContent":["export const arrayPropertyConverter = {\n toAttribute: (value: string[]) => {\n return Array.isArray(value) ? value.join(';') : ''\n },\n fromAttribute: (value: string) => {\n return value ? value.split(';') : []\n },\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@c2n/core",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "tsc -p tsconfig.json -w",
|
|
6
|
+
"build": "tsc -p tsconfig.json"
|
|
7
|
+
},
|
|
8
|
+
"author": "code2nguyen@gmail.com",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
"./css-helper.js": {
|
|
12
|
+
"types": "./dist/css-helper.d.ts",
|
|
13
|
+
"default": "./dist/css-helper.js"
|
|
14
|
+
},
|
|
15
|
+
"./dom-helper.js": {
|
|
16
|
+
"types": "./dist/dom-helper.d.ts",
|
|
17
|
+
"default": "./dist/dom-helper.js"
|
|
18
|
+
},
|
|
19
|
+
"./lit-helper.js": {
|
|
20
|
+
"types": "./dist/lit-helper.d.ts",
|
|
21
|
+
"default": "./dist/lit-helper.js"
|
|
22
|
+
},
|
|
23
|
+
"./controllers/context-consumer.js": {
|
|
24
|
+
"types": "./dist/controllers/context-consumer.d.ts",
|
|
25
|
+
"default": "./dist/controllers/context-consumer.js"
|
|
26
|
+
},
|
|
27
|
+
"./controllers/breakpoints-observer.js": {
|
|
28
|
+
"types": "./dist/controllers/breakpoints-observer.d.ts",
|
|
29
|
+
"default": "./dist/controllers/breakpoints-observer.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"registry": "https://registry.npmjs.org",
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/code2nguyen/web-components.git"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@c2n/config": "*"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "2921054bc75299da66dad11c1e374246ff88a51e"
|
|
48
|
+
}
|