@c2n/core 0.0.6 → 0.0.7
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/dist/.tsbuildinfo +1 -1
- package/dist/contexts/pager.d.ts +31 -0
- package/dist/contexts/pager.d.ts.map +1 -0
- package/dist/contexts/pager.js +11 -0
- package/dist/contexts/pager.js.map +1 -0
- package/dist/controllers/virtual-scroll.d.ts +45 -0
- package/dist/controllers/virtual-scroll.d.ts.map +1 -0
- package/dist/controllers/virtual-scroll.js +158 -0
- package/dist/controllers/virtual-scroll.js.map +1 -0
- package/dist/data-helper.d.ts +18 -0
- package/dist/data-helper.d.ts.map +1 -0
- package/dist/data-helper.js +48 -0
- package/dist/data-helper.js.map +1 -0
- package/dist/dom-helper.d.ts +6 -0
- package/dist/dom-helper.d.ts.map +1 -1
- package/dist/dom-helper.js +23 -0
- package/dist/dom-helper.js.map +1 -1
- package/dist/element-helper.d.ts +14 -0
- package/dist/element-helper.d.ts.map +1 -0
- package/dist/element-helper.js +71 -0
- package/dist/element-helper.js.map +1 -0
- package/dist/event-helper.d.ts +76 -0
- package/dist/event-helper.d.ts.map +1 -0
- package/dist/event-helper.js +2 -0
- package/dist/event-helper.js.map +1 -0
- package/dist/lit-helper.d.ts +9 -0
- package/dist/lit-helper.d.ts.map +1 -1
- package/dist/lit-helper.js +22 -0
- package/dist/lit-helper.js.map +1 -1
- package/package.json +26 -3
package/dist/.tsbuildinfo
CHANGED
|
@@ -1 +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"}
|
|
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","../src/data-helper.ts","../../../node_modules/lit-html/development/is-server.d.ts","../src/dom-helper.ts","../../../node_modules/@lit/reactive-element/development/decorators/base.d.ts","../../../node_modules/@lit/reactive-element/development/decorators/custom-element.d.ts","../src/element-helper.ts","../src/event-helper.ts","../src/lit-helper.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/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","../../../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/contexts/pager.ts","../src/controllers/breakpoints-observer.ts","../src/controllers/context-consumer.ts","../../../node_modules/lit-element/development/lit-element.d.ts","../../../node_modules/lit/development/index.d.ts","../src/controllers/virtual-scroll.ts"],"fileIdsList":[[61,62,66,68,69,70,71],[61],[61,65],[61,62,65,67],[62],[56],[63,64],[50,65],[50],[48,50],[48,49],[50,54,65,76],[72],[65],[65,72],[77],[51],[54],[57]],"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":"8404c6b0cd89fd85702086ab27d550099cc9ccb1b6670fc6484da5efe71c3c41","signature":"3e18169106207e83a0a2bc59e357d1473584a83a25641474f105ab56fd9490b3"},{"version":"1bcd560deed90a43c51b08aa18f7f55229f2e30974ab5ed1b7bb5721be379013","impliedFormat":99},{"version":"ca2f591a92510b383b9d86cdaabc49be06b9df369b567982041c1a221ea69c39","signature":"523bc35a219d7f85ff3b29a02ff8b8ad4e0685e81448f8395b872981dde6b94e"},{"version":"cdeae34aca6700620ebf3f27cf7d439c3af97595dd6e2729fa4780483add5680","impliedFormat":99},{"version":"3ff87ea3471b51beaf4aa8fd8f4422862b11d343fdbb55bf383e0f8cc195a445","impliedFormat":99},{"version":"2a727ebfeec4238aa97bc98f6c6383534a63b88a74ee99209396f7b0cb5498da","signature":"ef5cc85737cd5632eca69b911eb478f6bd9767f51f28ee3770d22fde05294dea"},{"version":"3e42659da436c840334cf9e989ab14009e5d3f5f62f75633d1d906c57f8634ab","signature":"a1ffd1c477e4c44624597d5a4232a6f4dc42dcda9f9b74ab2ff85f1819a95f18"},{"version":"9a626f36942689d75dc9a3b0f30e4f82218edec7daa65f561ee923fbbd322ddb","signature":"b86fc55138b5ae447f6665eb3dfa633bfacd5714e767caafef8ec437f8ea9008"},{"version":"7455f2d44bbd248413e4ab8c3ff847413d9ce327967dba66f0b51880f60fb653","impliedFormat":99},{"version":"9dd82c87281e106bdcb227550251fcc6b55a6eb555152bec5c6ce408345ffc57","affectsGlobalScope":true,"impliedFormat":99},{"version":"74012d464fbc5354ca3a7d5e71bee43b17da01a853c8ff10971bbe3680c76f40","impliedFormat":99},{"version":"5e30131b6a5587fe666926ad1d9807e733c0a597ed12d682669fcaa331aea576","impliedFormat":99},{"version":"a0f82d2f9450bd147a8c137798d9501bd49b7c9e118f75b07b76709ff39b6b55","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":"375ccf781ce7f845db6d13839e6085e520dac2a024679528229823d402ba1edc","signature":"4d4573b5fe4e0012638e5faaf0d8f77365359ce60cde1b0bafc62f48400a7e3d"},{"version":"361aaaeedfa37b1da60c8017b07a9968062968f71561c479bc83944063f5804d","signature":"cc8929ab4c4e9be68dd16405c46e97463b36038700f49d070e2d24ee4139c87c"},{"version":"d719146ac4cda335a8e970ba5918cf154be98b83c6f4b3acb4c02f6617cd92f6","signature":"75f5083114303492bddf59e3b81debed86d2a422666bb2d7c69513ad64a61a26"},{"version":"9a318e3a8900672b85cd3c8c3a5acf51b88049557a3ae897ccdcf2b85a8f61f9","impliedFormat":99},{"version":"dc08fe04e50bc24d1baded4f33e942222bbdd5d77d6341a93cfe6e4e4586a3be","impliedFormat":99},{"version":"348c8e833a387ff25bdec06826c01c364738982079c2ba1cb390847141721ad1","signature":"a19c051036e9cb67b13b0b536c2ea9c8a8444e8797ece8db8963abd141f05017"}],"root":[52,53,55,[58,60],[73,75],78],"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":[[72,1],[62,2],[66,3],[68,4],[71,3],[70,3],[67,5],[57,6],[65,7],[76,8],[48,9],[51,10],[50,11],[77,12],[73,13],[74,14],[75,15],[78,16],[52,17],[55,18],[58,19]],"latestChangedDtsFile":"./controllers/virtual-scroll.d.ts","version":"6.0.3"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared contract between a paging host — a `c2-table` — and the pager inside it, so neither package has to
|
|
3
|
+
* depend on the other. Enrollment and state travel on separate channels: the pager announces itself with
|
|
4
|
+
* `PAGER_CONNECT_EVENT` when it connects, and from then on the host feeds it through `pagerContext`.
|
|
5
|
+
*/
|
|
6
|
+
/** Fired by a pager when it connects, so a paging host can claim it. Bubbles and is composed; the host stops it. */
|
|
7
|
+
export declare const PAGER_CONNECT_EVENT = "c2-pager-connect";
|
|
8
|
+
export interface PagerConnectEventDetail {
|
|
9
|
+
/** The pager's own page size, adopted by a host that has none of its own. */
|
|
10
|
+
pageSize: number;
|
|
11
|
+
}
|
|
12
|
+
/** What a paging host shares with the pager inside it. */
|
|
13
|
+
export interface PagerContext {
|
|
14
|
+
/** The page on show, 1-based. */
|
|
15
|
+
page: number;
|
|
16
|
+
/** Items per page. */
|
|
17
|
+
pageSize: number;
|
|
18
|
+
/** Total number of items to page through. */
|
|
19
|
+
totalItems: number;
|
|
20
|
+
/** True while the host is loading, so the pager can dim its controls. */
|
|
21
|
+
busy: boolean;
|
|
22
|
+
/** The pager asks for another page; the host clamps it, loads it, and pushes the settled value back. */
|
|
23
|
+
pageChanged(page: number): void;
|
|
24
|
+
/** The pager asks for another page size. */
|
|
25
|
+
pageSizeChanged(pageSize: number): void;
|
|
26
|
+
}
|
|
27
|
+
/** `undefined` when no host is present, so a pager on its own keeps working from its own properties. */
|
|
28
|
+
export declare const pagerContext: {
|
|
29
|
+
__context__: PagerContext | undefined;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=pager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pager.d.ts","sourceRoot":"","sources":["../../src/contexts/pager.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,oHAAoH;AACpH,eAAO,MAAM,mBAAmB,qBAAqB,CAAA;AAErD,MAAM,WAAW,uBAAuB;IACtC,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,0DAA0D;AAC1D,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAA;IAClB,yEAAyE;IACzE,IAAI,EAAE,OAAO,CAAA;IACb,wGAAwG;IACxG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,4CAA4C;IAC5C,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxC;AAED,wGAAwG;AACxG,eAAO,MAAM,YAAY;;CAA8D,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext } from '@lit/context';
|
|
2
|
+
/**
|
|
3
|
+
* Shared contract between a paging host — a `c2-table` — and the pager inside it, so neither package has to
|
|
4
|
+
* depend on the other. Enrollment and state travel on separate channels: the pager announces itself with
|
|
5
|
+
* `PAGER_CONNECT_EVENT` when it connects, and from then on the host feeds it through `pagerContext`.
|
|
6
|
+
*/
|
|
7
|
+
/** Fired by a pager when it connects, so a paging host can claim it. Bubbles and is composed; the host stops it. */
|
|
8
|
+
export const PAGER_CONNECT_EVENT = 'c2-pager-connect';
|
|
9
|
+
/** `undefined` when no host is present, so a pager on its own keeps working from its own properties. */
|
|
10
|
+
export const pagerContext = createContext(Symbol('c2-pager'));
|
|
11
|
+
//# sourceMappingURL=pager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pager.js","sourceRoot":"","sources":["../../src/contexts/pager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C;;;;GAIG;AAEH,oHAAoH;AACpH,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAA;AAuBrD,wGAAwG;AACxG,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAA2B,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA","sourcesContent":["import { createContext } from '@lit/context'\n\n/**\n * Shared contract between a paging host — a `c2-table` — and the pager inside it, so neither package has to\n * depend on the other. Enrollment and state travel on separate channels: the pager announces itself with\n * `PAGER_CONNECT_EVENT` when it connects, and from then on the host feeds it through `pagerContext`.\n */\n\n/** Fired by a pager when it connects, so a paging host can claim it. Bubbles and is composed; the host stops it. */\nexport const PAGER_CONNECT_EVENT = 'c2-pager-connect'\n\nexport interface PagerConnectEventDetail {\n /** The pager's own page size, adopted by a host that has none of its own. */\n pageSize: number\n}\n\n/** What a paging host shares with the pager inside it. */\nexport interface PagerContext {\n /** The page on show, 1-based. */\n page: number\n /** Items per page. */\n pageSize: number\n /** Total number of items to page through. */\n totalItems: number\n /** True while the host is loading, so the pager can dim its controls. */\n busy: boolean\n /** The pager asks for another page; the host clamps it, loads it, and pushes the settled value back. */\n pageChanged(page: number): void\n /** The pager asks for another page size. */\n pageSizeChanged(pageSize: number): void\n}\n\n/** `undefined` when no host is present, so a pager on its own keeps working from its own properties. */\nexport const pagerContext = createContext<PagerContext | undefined>(Symbol('c2-pager'))\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
export interface VirtualScrollRange {
|
|
3
|
+
/** Index of the first item to render. */
|
|
4
|
+
start: number;
|
|
5
|
+
/** Index after the last item to render. */
|
|
6
|
+
end: number;
|
|
7
|
+
/** Height in pixels of the spacer that replaces the items before `start`. */
|
|
8
|
+
paddingTop: number;
|
|
9
|
+
/** Height in pixels of the spacer that replaces the items after `end`. */
|
|
10
|
+
paddingBottom: number;
|
|
11
|
+
}
|
|
12
|
+
export interface VirtualScrollOptions {
|
|
13
|
+
/** The scrolling element. Read on every update, so it may be created by the host's first render. */
|
|
14
|
+
scrollElement: () => HTMLElement | null | undefined;
|
|
15
|
+
/** Total number of items. */
|
|
16
|
+
itemCount: () => number;
|
|
17
|
+
/** Height of a single item in pixels. Uniform: the controller does not measure items. */
|
|
18
|
+
itemHeight: () => number;
|
|
19
|
+
/** Items rendered above and below the viewport. Defaults to 6. */
|
|
20
|
+
overscan?: () => number;
|
|
21
|
+
/** When false the controller reports the full range, so the host renders every item. Defaults to true. */
|
|
22
|
+
enabled?: () => boolean;
|
|
23
|
+
/** Viewport height used before the scroll element has been laid out. Defaults to 480. */
|
|
24
|
+
estimatedViewportHeight?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Windows a long, uniform-height list to the items that are visible in a scrolling element, plus an overscan margin.
|
|
28
|
+
*
|
|
29
|
+
* The host renders `range.start`…`range.end` and two spacers of `range.paddingTop` / `range.paddingBottom` pixels, so
|
|
30
|
+
* the scrollbar keeps the size of the full list. The controller only ever reads layout (`scrollTop`, `clientHeight`),
|
|
31
|
+
* never writes it, and requests a host update when the visible window changes.
|
|
32
|
+
*/
|
|
33
|
+
export declare class VirtualScrollController implements ReactiveController {
|
|
34
|
+
#private;
|
|
35
|
+
constructor(host: ReactiveControllerHost, options: VirtualScrollOptions);
|
|
36
|
+
get range(): VirtualScrollRange;
|
|
37
|
+
get scrollTop(): number;
|
|
38
|
+
hostConnected(): void;
|
|
39
|
+
hostDisconnected(): void;
|
|
40
|
+
/** Called by the host after every render: binds to the scroll element and recomputes the window. */
|
|
41
|
+
hostUpdated(): void;
|
|
42
|
+
/** Scrolls the item at `index` into view, aligning it to the closest edge of the viewport. */
|
|
43
|
+
scrollToIndex(index: number, offsetTop?: number): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=virtual-scroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-scroll.d.ts","sourceRoot":"","sources":["../../src/controllers/virtual-scroll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAA;AAUrE,MAAM,WAAW,kBAAkB;IACjC,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAA;IACb,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAA;IACX,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAA;IAClB,0EAA0E;IAC1E,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,oGAAoG;IACpG,aAAa,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAA;IACnD,6BAA6B;IAC7B,SAAS,EAAE,MAAM,MAAM,CAAA;IACvB,yFAAyF;IACzF,UAAU,EAAE,MAAM,MAAM,CAAA;IACxB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAA;IACvB,0GAA0G;IAC1G,OAAO,CAAC,EAAE,MAAM,OAAO,CAAA;IACvB,yFAAyF;IACzF,uBAAuB,CAAC,EAAE,MAAM,CAAA;CACjC;AAED;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,kBAAkB;;gBAUpD,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,oBAAoB;IAMvE,IAAI,KAAK,IAAI,kBAAkB,CAK9B;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,aAAa;IAOb,gBAAgB;IAMhB,oGAAoG;IACpG,WAAW;IAOX,8FAA8F;IAC9F,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAI;CA8F3C"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _VirtualScrollController_instances, _VirtualScrollController_host, _VirtualScrollController_options, _VirtualScrollController_scrollElement, _VirtualScrollController_resizeObserver, _VirtualScrollController_scrollTop, _VirtualScrollController_viewportHeight, _VirtualScrollController_range, _VirtualScrollController_hasComputed, _VirtualScrollController_attach, _VirtualScrollController_detach, _VirtualScrollController_handleScroll, _VirtualScrollController_measure, _VirtualScrollController_scrollScale, _VirtualScrollController_computeRange;
|
|
13
|
+
/**
|
|
14
|
+
* Browsers silently cap how tall an element may be, and past that cap a spacer stops growing while the scrollbar
|
|
15
|
+
* keeps tracking it. Beyond this many pixels the controller scales the scroll offset instead of spanning the whole
|
|
16
|
+
* list, so the window stays correct at any item count. Value from the same ad-hoc Chrome/Safari/Firefox limit the
|
|
17
|
+
* Lit virtualizer uses.
|
|
18
|
+
*/
|
|
19
|
+
const MAX_SCROLL_HEIGHT = 8200000;
|
|
20
|
+
/**
|
|
21
|
+
* Windows a long, uniform-height list to the items that are visible in a scrolling element, plus an overscan margin.
|
|
22
|
+
*
|
|
23
|
+
* The host renders `range.start`…`range.end` and two spacers of `range.paddingTop` / `range.paddingBottom` pixels, so
|
|
24
|
+
* the scrollbar keeps the size of the full list. The controller only ever reads layout (`scrollTop`, `clientHeight`),
|
|
25
|
+
* never writes it, and requests a host update when the visible window changes.
|
|
26
|
+
*/
|
|
27
|
+
export class VirtualScrollController {
|
|
28
|
+
constructor(host, options) {
|
|
29
|
+
_VirtualScrollController_instances.add(this);
|
|
30
|
+
_VirtualScrollController_host.set(this, void 0);
|
|
31
|
+
_VirtualScrollController_options.set(this, void 0);
|
|
32
|
+
_VirtualScrollController_scrollElement.set(this, null);
|
|
33
|
+
_VirtualScrollController_resizeObserver.set(this, null);
|
|
34
|
+
_VirtualScrollController_scrollTop.set(this, 0);
|
|
35
|
+
_VirtualScrollController_viewportHeight.set(this, 0);
|
|
36
|
+
_VirtualScrollController_range.set(this, { start: 0, end: 0, paddingTop: 0, paddingBottom: 0 });
|
|
37
|
+
_VirtualScrollController_hasComputed.set(this, false);
|
|
38
|
+
_VirtualScrollController_handleScroll.set(this, () => {
|
|
39
|
+
__classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_measure).call(this);
|
|
40
|
+
});
|
|
41
|
+
__classPrivateFieldSet(this, _VirtualScrollController_host, host, "f");
|
|
42
|
+
__classPrivateFieldSet(this, _VirtualScrollController_options, options, "f");
|
|
43
|
+
host.addController(this);
|
|
44
|
+
}
|
|
45
|
+
get range() {
|
|
46
|
+
// Compute on first read so a host that renders before it is attached (server-side rendering, the first paint)
|
|
47
|
+
// still gets a usable window from the estimated viewport height instead of an empty one.
|
|
48
|
+
if (!__classPrivateFieldGet(this, _VirtualScrollController_hasComputed, "f"))
|
|
49
|
+
__classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_computeRange).call(this);
|
|
50
|
+
return __classPrivateFieldGet(this, _VirtualScrollController_range, "f");
|
|
51
|
+
}
|
|
52
|
+
get scrollTop() {
|
|
53
|
+
return __classPrivateFieldGet(this, _VirtualScrollController_scrollTop, "f");
|
|
54
|
+
}
|
|
55
|
+
hostConnected() {
|
|
56
|
+
__classPrivateFieldSet(this, _VirtualScrollController_resizeObserver, __classPrivateFieldGet(this, _VirtualScrollController_resizeObserver, "f") ?? new ResizeObserver(() => __classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_measure).call(this)), "f");
|
|
57
|
+
// Lit does not request an update when an element reconnects, so `hostUpdated` may never run again after the host
|
|
58
|
+
// is moved in the DOM. Re-bind here or scroll events stop reaching a host that is still perfectly alive.
|
|
59
|
+
__classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_attach).call(this, __classPrivateFieldGet(this, _VirtualScrollController_options, "f").scrollElement());
|
|
60
|
+
}
|
|
61
|
+
hostDisconnected() {
|
|
62
|
+
__classPrivateFieldGet(this, _VirtualScrollController_resizeObserver, "f")?.disconnect();
|
|
63
|
+
__classPrivateFieldSet(this, _VirtualScrollController_resizeObserver, null, "f");
|
|
64
|
+
__classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_detach).call(this);
|
|
65
|
+
}
|
|
66
|
+
/** Called by the host after every render: binds to the scroll element and recomputes the window. */
|
|
67
|
+
hostUpdated() {
|
|
68
|
+
__classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_attach).call(this, __classPrivateFieldGet(this, _VirtualScrollController_options, "f").scrollElement());
|
|
69
|
+
// The render that just happened used the window from before this update, so a changed item count or item height
|
|
70
|
+
// leaves stale spacers on screen until the host renders once more.
|
|
71
|
+
if (__classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_computeRange).call(this))
|
|
72
|
+
__classPrivateFieldGet(this, _VirtualScrollController_host, "f").requestUpdate();
|
|
73
|
+
}
|
|
74
|
+
/** Scrolls the item at `index` into view, aligning it to the closest edge of the viewport. */
|
|
75
|
+
scrollToIndex(index, offsetTop = 0) {
|
|
76
|
+
const element = __classPrivateFieldGet(this, _VirtualScrollController_scrollElement, "f");
|
|
77
|
+
if (!element)
|
|
78
|
+
return;
|
|
79
|
+
const itemHeight = __classPrivateFieldGet(this, _VirtualScrollController_options, "f").itemHeight();
|
|
80
|
+
const count = Math.max(0, __classPrivateFieldGet(this, _VirtualScrollController_options, "f").itemCount());
|
|
81
|
+
if (itemHeight <= 0 || count === 0)
|
|
82
|
+
return;
|
|
83
|
+
// Work in the list's own coordinates: `offset` is where the top of the viewport sits in the full list, and
|
|
84
|
+
// `offsetTop` is the part of that viewport a sticky header covers.
|
|
85
|
+
const viewportHeight = element.clientHeight;
|
|
86
|
+
const scale = __classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_scrollScale).call(this, count * itemHeight, viewportHeight);
|
|
87
|
+
const offset = element.scrollTop * scale;
|
|
88
|
+
const top = Math.min(Math.max(index, 0), count - 1) * itemHeight;
|
|
89
|
+
const bottom = top + itemHeight;
|
|
90
|
+
if (top < offset) {
|
|
91
|
+
element.scrollTop = top / scale;
|
|
92
|
+
}
|
|
93
|
+
else if (bottom > offset + viewportHeight - offsetTop) {
|
|
94
|
+
element.scrollTop = (bottom - viewportHeight + offsetTop) / scale;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
_VirtualScrollController_host = new WeakMap(), _VirtualScrollController_options = new WeakMap(), _VirtualScrollController_scrollElement = new WeakMap(), _VirtualScrollController_resizeObserver = new WeakMap(), _VirtualScrollController_scrollTop = new WeakMap(), _VirtualScrollController_viewportHeight = new WeakMap(), _VirtualScrollController_range = new WeakMap(), _VirtualScrollController_hasComputed = new WeakMap(), _VirtualScrollController_handleScroll = new WeakMap(), _VirtualScrollController_instances = new WeakSet(), _VirtualScrollController_attach = function _VirtualScrollController_attach(element) {
|
|
99
|
+
if (element === __classPrivateFieldGet(this, _VirtualScrollController_scrollElement, "f"))
|
|
100
|
+
return;
|
|
101
|
+
__classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_detach).call(this);
|
|
102
|
+
if (!element)
|
|
103
|
+
return;
|
|
104
|
+
__classPrivateFieldSet(this, _VirtualScrollController_scrollElement, element, "f");
|
|
105
|
+
element.addEventListener('scroll', __classPrivateFieldGet(this, _VirtualScrollController_handleScroll, "f"), { passive: true });
|
|
106
|
+
__classPrivateFieldGet(this, _VirtualScrollController_resizeObserver, "f")?.observe(element);
|
|
107
|
+
__classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_measure).call(this);
|
|
108
|
+
}, _VirtualScrollController_detach = function _VirtualScrollController_detach() {
|
|
109
|
+
if (!__classPrivateFieldGet(this, _VirtualScrollController_scrollElement, "f"))
|
|
110
|
+
return;
|
|
111
|
+
__classPrivateFieldGet(this, _VirtualScrollController_scrollElement, "f").removeEventListener('scroll', __classPrivateFieldGet(this, _VirtualScrollController_handleScroll, "f"));
|
|
112
|
+
__classPrivateFieldGet(this, _VirtualScrollController_resizeObserver, "f")?.unobserve(__classPrivateFieldGet(this, _VirtualScrollController_scrollElement, "f"));
|
|
113
|
+
__classPrivateFieldSet(this, _VirtualScrollController_scrollElement, null, "f");
|
|
114
|
+
}, _VirtualScrollController_measure = function _VirtualScrollController_measure() {
|
|
115
|
+
const element = __classPrivateFieldGet(this, _VirtualScrollController_scrollElement, "f");
|
|
116
|
+
if (!element)
|
|
117
|
+
return;
|
|
118
|
+
__classPrivateFieldSet(this, _VirtualScrollController_scrollTop, element.scrollTop, "f");
|
|
119
|
+
__classPrivateFieldSet(this, _VirtualScrollController_viewportHeight, element.clientHeight, "f");
|
|
120
|
+
if (__classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_computeRange).call(this))
|
|
121
|
+
__classPrivateFieldGet(this, _VirtualScrollController_host, "f").requestUpdate();
|
|
122
|
+
}, _VirtualScrollController_scrollScale = function _VirtualScrollController_scrollScale(contentHeight, viewportHeight) {
|
|
123
|
+
if (contentHeight <= MAX_SCROLL_HEIGHT)
|
|
124
|
+
return 1;
|
|
125
|
+
const reachable = MAX_SCROLL_HEIGHT - viewportHeight;
|
|
126
|
+
return reachable > 0 ? (contentHeight - viewportHeight) / reachable : 1;
|
|
127
|
+
}, _VirtualScrollController_computeRange = function _VirtualScrollController_computeRange() {
|
|
128
|
+
__classPrivateFieldSet(this, _VirtualScrollController_hasComputed, true, "f");
|
|
129
|
+
const count = Math.max(0, __classPrivateFieldGet(this, _VirtualScrollController_options, "f").itemCount());
|
|
130
|
+
const itemHeight = __classPrivateFieldGet(this, _VirtualScrollController_options, "f").itemHeight();
|
|
131
|
+
const enabled = __classPrivateFieldGet(this, _VirtualScrollController_options, "f").enabled?.() ?? true;
|
|
132
|
+
let next;
|
|
133
|
+
if (!enabled || count === 0 || itemHeight <= 0) {
|
|
134
|
+
next = { start: 0, end: count, paddingTop: 0, paddingBottom: 0 };
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
const overscan = Math.max(0, __classPrivateFieldGet(this, _VirtualScrollController_options, "f").overscan?.() ?? 6);
|
|
138
|
+
const viewportHeight = __classPrivateFieldGet(this, _VirtualScrollController_viewportHeight, "f") || (__classPrivateFieldGet(this, _VirtualScrollController_options, "f").estimatedViewportHeight ?? 480);
|
|
139
|
+
const contentHeight = count * itemHeight;
|
|
140
|
+
const spannedHeight = Math.min(contentHeight, MAX_SCROLL_HEIGHT);
|
|
141
|
+
// Past the cap the spacers no longer span the whole list, so the real scroll offset is scaled up to the offset
|
|
142
|
+
// the list would have had and the top spacer is shifted to keep the rendered items under the viewport.
|
|
143
|
+
const offset = __classPrivateFieldGet(this, _VirtualScrollController_scrollTop, "f") * __classPrivateFieldGet(this, _VirtualScrollController_instances, "m", _VirtualScrollController_scrollScale).call(this, contentHeight, viewportHeight);
|
|
144
|
+
// The `+ 1` covers the item the viewport starts partway through, which it almost always does.
|
|
145
|
+
const visible = Math.ceil(viewportHeight / itemHeight) + 1 + overscan * 2;
|
|
146
|
+
const start = Math.max(0, Math.floor(offset / itemHeight) - overscan);
|
|
147
|
+
const end = Math.min(count, start + visible);
|
|
148
|
+
const paddingTop = Math.max(0, start * itemHeight - (offset - __classPrivateFieldGet(this, _VirtualScrollController_scrollTop, "f")));
|
|
149
|
+
next = { start, end, paddingTop, paddingBottom: Math.max(0, spannedHeight - paddingTop - (end - start) * itemHeight) };
|
|
150
|
+
}
|
|
151
|
+
const current = __classPrivateFieldGet(this, _VirtualScrollController_range, "f");
|
|
152
|
+
if (current.start === next.start && current.end === next.end && current.paddingTop === next.paddingTop && current.paddingBottom === next.paddingBottom) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
__classPrivateFieldSet(this, _VirtualScrollController_range, next, "f");
|
|
156
|
+
return true;
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=virtual-scroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-scroll.js","sourceRoot":"","sources":["../../src/controllers/virtual-scroll.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA;;;;;GAKG;AACH,MAAM,iBAA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AU,IAAI,MAAA,CAAA;IAClB,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit'\n\n/**\n * Browsers silently cap how tall an element may be, and past that cap a spacer stops growing while the scrollbar\n * keeps tracking it. Beyond this many pixels the controller scales the scroll offset instead of spanning the whole\n * list, so the window stays correct at any item count. Value from the same ad-hoc Chrome/Safari/Firefox limit the\n * Lit virtualizer uses.\n */\nconst MAX_SCROLL_HEIGHT = 8_200_000\n\nexport interface VirtualScrollRange {\n /** Index of the first item to render. */\n start: number\n /** Index after the last item to render. */\n end: number\n /** Height in pixels of the spacer that replaces the items before `start`. */\n paddingTop: number\n /** Height in pixels of the spacer that replaces the items after `end`. */\n paddingBottom: number\n}\n\nexport interface VirtualScrollOptions {\n /** The scrolling element. Read on every update, so it may be created by the host's first render. */\n scrollElement: () => HTMLElement | null | undefined\n /** Total number of items. */\n itemCount: () => number\n /** Height of a single item in pixels. Uniform: the controller does not measure items. */\n itemHeight: () => number\n /** Items rendered above and below the viewport. Defaults to 6. */\n overscan?: () => number\n /** When false the controller reports the full range, so the host renders every item. Defaults to true. */\n enabled?: () => boolean\n /** Viewport height used before the scroll element has been laid out. Defaults to 480. */\n estimatedViewportHeight?: number\n}\n\n/**\n * Windows a long, uniform-height list to the items that are visible in a scrolling element, plus an overscan margin.\n *\n * The host renders `range.start`…`range.end` and two spacers of `range.paddingTop` / `range.paddingBottom` pixels, so\n * the scrollbar keeps the size of the full list. The controller only ever reads layout (`scrollTop`, `clientHeight`),\n * never writes it, and requests a host update when the visible window changes.\n */\nexport class VirtualScrollController implements ReactiveController {\n #host: ReactiveControllerHost\n #options: VirtualScrollOptions\n #scrollElement: HTMLElement | null = null\n #resizeObserver: ResizeObserver | null = null\n #scrollTop = 0\n #viewportHeight = 0\n #range: VirtualScrollRange = { start: 0, end: 0, paddingTop: 0, paddingBottom: 0 }\n #hasComputed = false\n\n constructor(host: ReactiveControllerHost, options: VirtualScrollOptions) {\n this.#host = host\n this.#options = options\n host.addController(this)\n }\n\n get range(): VirtualScrollRange {\n // Compute on first read so a host that renders before it is attached (server-side rendering, the first paint)\n // still gets a usable window from the estimated viewport height instead of an empty one.\n if (!this.#hasComputed) this.#computeRange()\n return this.#range\n }\n\n get scrollTop(): number {\n return this.#scrollTop\n }\n\n hostConnected() {\n this.#resizeObserver ??= new ResizeObserver(() => this.#measure())\n // Lit does not request an update when an element reconnects, so `hostUpdated` may never run again after the host\n // is moved in the DOM. Re-bind here or scroll events stop reaching a host that is still perfectly alive.\n this.#attach(this.#options.scrollElement())\n }\n\n hostDisconnected() {\n this.#resizeObserver?.disconnect()\n this.#resizeObserver = null\n this.#detach()\n }\n\n /** Called by the host after every render: binds to the scroll element and recomputes the window. */\n hostUpdated() {\n this.#attach(this.#options.scrollElement())\n // The render that just happened used the window from before this update, so a changed item count or item height\n // leaves stale spacers on screen until the host renders once more.\n if (this.#computeRange()) this.#host.requestUpdate()\n }\n\n /** Scrolls the item at `index` into view, aligning it to the closest edge of the viewport. */\n scrollToIndex(index: number, offsetTop = 0) {\n const element = this.#scrollElement\n if (!element) return\n const itemHeight = this.#options.itemHeight()\n const count = Math.max(0, this.#options.itemCount())\n if (itemHeight <= 0 || count === 0) return\n\n // Work in the list's own coordinates: `offset` is where the top of the viewport sits in the full list, and\n // `offsetTop` is the part of that viewport a sticky header covers.\n const viewportHeight = element.clientHeight\n const scale = this.#scrollScale(count * itemHeight, viewportHeight)\n const offset = element.scrollTop * scale\n const top = Math.min(Math.max(index, 0), count - 1) * itemHeight\n const bottom = top + itemHeight\n\n if (top < offset) {\n element.scrollTop = top / scale\n } else if (bottom > offset + viewportHeight - offsetTop) {\n element.scrollTop = (bottom - viewportHeight + offsetTop) / scale\n }\n }\n\n #attach(element: HTMLElement | null | undefined) {\n if (element === this.#scrollElement) return\n this.#detach()\n if (!element) return\n this.#scrollElement = element\n element.addEventListener('scroll', this.#handleScroll, { passive: true })\n this.#resizeObserver?.observe(element)\n this.#measure()\n }\n\n #detach() {\n if (!this.#scrollElement) return\n this.#scrollElement.removeEventListener('scroll', this.#handleScroll)\n this.#resizeObserver?.unobserve(this.#scrollElement)\n this.#scrollElement = null\n }\n\n #handleScroll = () => {\n this.#measure()\n }\n\n #measure() {\n const element = this.#scrollElement\n if (!element) return\n this.#scrollTop = element.scrollTop\n this.#viewportHeight = element.clientHeight\n if (this.#computeRange()) this.#host.requestUpdate()\n }\n\n /**\n * Ratio between the height the list would have and the height its spacers can actually reach. 1 — the offset maps\n * straight through — for every list that fits under `MAX_SCROLL_HEIGHT`.\n */\n #scrollScale(contentHeight: number, viewportHeight: number): number {\n if (contentHeight <= MAX_SCROLL_HEIGHT) return 1\n const reachable = MAX_SCROLL_HEIGHT - viewportHeight\n return reachable > 0 ? (contentHeight - viewportHeight) / reachable : 1\n }\n\n /** Recomputes the window; returns true when it changed. */\n #computeRange(): boolean {\n this.#hasComputed = true\n const count = Math.max(0, this.#options.itemCount())\n const itemHeight = this.#options.itemHeight()\n const enabled = this.#options.enabled?.() ?? true\n let next: VirtualScrollRange\n\n if (!enabled || count === 0 || itemHeight <= 0) {\n next = { start: 0, end: count, paddingTop: 0, paddingBottom: 0 }\n } else {\n const overscan = Math.max(0, this.#options.overscan?.() ?? 6)\n const viewportHeight = this.#viewportHeight || (this.#options.estimatedViewportHeight ?? 480)\n const contentHeight = count * itemHeight\n const spannedHeight = Math.min(contentHeight, MAX_SCROLL_HEIGHT)\n // Past the cap the spacers no longer span the whole list, so the real scroll offset is scaled up to the offset\n // the list would have had and the top spacer is shifted to keep the rendered items under the viewport.\n const offset = this.#scrollTop * this.#scrollScale(contentHeight, viewportHeight)\n // The `+ 1` covers the item the viewport starts partway through, which it almost always does.\n const visible = Math.ceil(viewportHeight / itemHeight) + 1 + overscan * 2\n const start = Math.max(0, Math.floor(offset / itemHeight) - overscan)\n const end = Math.min(count, start + visible)\n const paddingTop = Math.max(0, start * itemHeight - (offset - this.#scrollTop))\n next = { start, end, paddingTop, paddingBottom: Math.max(0, spannedHeight - paddingTop - (end - start) * itemHeight) }\n }\n\n const current = this.#range\n if (current.start === next.start && current.end === next.end && current.paddingTop === next.paddingTop && current.paddingBottom === next.paddingBottom) {\n return false\n }\n this.#range = next\n return true\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type SortDirection = 'asc' | 'desc';
|
|
2
|
+
export interface SortEntry {
|
|
3
|
+
field: string;
|
|
4
|
+
direction: SortDirection;
|
|
5
|
+
}
|
|
6
|
+
/** Reads a possibly dotted `field` path out of a record. */
|
|
7
|
+
export declare function getFieldValue(item: unknown, field: string): unknown;
|
|
8
|
+
/**
|
|
9
|
+
* Orders two cell values the way a person expects a column to sort: empties last, numbers and dates by magnitude,
|
|
10
|
+
* everything else by a numeric-aware, case-insensitive locale compare so `item 2` comes before `item 10`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function defaultCompare(a: unknown, b: unknown): number;
|
|
13
|
+
/** `name:asc` ⇄ `SortEntry`, so a single-key sort can be set from markup. */
|
|
14
|
+
export declare const sortEntryConverter: {
|
|
15
|
+
toAttribute: (value: SortEntry | undefined) => string | null;
|
|
16
|
+
fromAttribute: (value: string | null) => SortEntry | undefined;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=data-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-helper.d.ts","sourceRoot":"","sources":["../src/data-helper.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAA;AAE1C,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,aAAa,CAAA;CACzB;AAED,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAUnE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAQ7D;AAED,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB;yBACR,SAAS,GAAG,SAAS;2BACnB,MAAM,GAAG,IAAI,KAAG,SAAS,GAAG,SAAS;CAO7D,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Reads a possibly dotted `field` path out of a record. */
|
|
2
|
+
export function getFieldValue(item, field) {
|
|
3
|
+
if (!item || !field)
|
|
4
|
+
return undefined;
|
|
5
|
+
const record = item;
|
|
6
|
+
if (!field.includes('.'))
|
|
7
|
+
return record[field];
|
|
8
|
+
let current = record;
|
|
9
|
+
for (const part of field.split('.')) {
|
|
10
|
+
if (current === null || current === undefined)
|
|
11
|
+
return undefined;
|
|
12
|
+
current = current[part];
|
|
13
|
+
}
|
|
14
|
+
return current;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Orders two cell values the way a person expects a column to sort: empties last, numbers and dates by magnitude,
|
|
18
|
+
* everything else by a numeric-aware, case-insensitive locale compare so `item 2` comes before `item 10`.
|
|
19
|
+
*/
|
|
20
|
+
export function defaultCompare(a, b) {
|
|
21
|
+
if (a === b)
|
|
22
|
+
return 0;
|
|
23
|
+
if (a === null || a === undefined || a === '')
|
|
24
|
+
return 1;
|
|
25
|
+
if (b === null || b === undefined || b === '')
|
|
26
|
+
return -1;
|
|
27
|
+
if (typeof a === 'number' && typeof b === 'number')
|
|
28
|
+
return a - b;
|
|
29
|
+
if (typeof a === 'boolean' && typeof b === 'boolean')
|
|
30
|
+
return Number(a) - Number(b);
|
|
31
|
+
if (a instanceof Date && b instanceof Date)
|
|
32
|
+
return a.getTime() - b.getTime();
|
|
33
|
+
return String(a).localeCompare(String(b), undefined, { numeric: true, sensitivity: 'base' });
|
|
34
|
+
}
|
|
35
|
+
/** `name:asc` ⇄ `SortEntry`, so a single-key sort can be set from markup. */
|
|
36
|
+
export const sortEntryConverter = {
|
|
37
|
+
toAttribute: (value) => (value?.field ? `${value.field}:${value.direction}` : null),
|
|
38
|
+
fromAttribute: (value) => {
|
|
39
|
+
if (!value)
|
|
40
|
+
return undefined;
|
|
41
|
+
const [field, direction] = value.split(':');
|
|
42
|
+
const name = field?.trim();
|
|
43
|
+
if (!name)
|
|
44
|
+
return undefined;
|
|
45
|
+
return { field: name, direction: direction?.trim() === 'desc' ? 'desc' : 'asc' };
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=data-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-helper.js","sourceRoot":"","sources":["../src/data-helper.ts"],"names":[],"mappings":"AAOA,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,IAAa,EAAE,KAAa;IACxD,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IACrC,MAAM,MAAM,GAAG,IAA+B,CAAA;IAC9C,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9C,IAAI,OAAO,GAAY,MAAM,CAAA;IAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,SAAS,CAAA;QAC/D,OAAO,GAAI,OAAmC,CAAC,IAAI,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,CAAU,EAAE,CAAU;IACnD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAA;IACrB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,CAAC,CAAA;IACvD,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KA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,CAAC,KAAK,EAAE,CAAA;IAClF,CAAC;CACF,CAAA","sourcesContent":["export type SortDirection = 'asc' | 'desc'\n\nexport interface SortEntry {\n field: string\n direction: SortDirection\n}\n\n/** Reads a possibly dotted `field` path out of a record. */\nexport function getFieldValue(item: unknown, field: string): unknown {\n if (!item || !field) return undefined\n const record = item as Record<string, unknown>\n if (!field.includes('.')) return record[field]\n let current: unknown = record\n for (const part of field.split('.')) {\n if (current === null || current === undefined) return undefined\n current = (current as Record<string, unknown>)[part]\n }\n return current\n}\n\n/**\n * Orders two cell values the way a person expects a column to sort: empties last, numbers and dates by magnitude,\n * everything else by a numeric-aware, case-insensitive locale compare so `item 2` comes before `item 10`.\n */\nexport function defaultCompare(a: unknown, b: unknown): number {\n if (a === b) return 0\n if (a === null || a === undefined || a === '') return 1\n if (b === null || b === undefined || b === '') return -1\n if (typeof a === 'number' && typeof b === 'number') return a - b\n if (typeof a === 'boolean' && typeof b === 'boolean') return Number(a) - Number(b)\n if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime()\n return String(a).localeCompare(String(b), undefined, { numeric: true, sensitivity: 'base' })\n}\n\n/** `name:asc` ⇄ `SortEntry`, so a single-key sort can be set from markup. */\nexport const sortEntryConverter = {\n toAttribute: (value: SortEntry | undefined) => (value?.field ? `${value.field}:${value.direction}` : null),\n fromAttribute: (value: string | null): SortEntry | undefined => {\n if (!value) return undefined\n const [field, direction] = value.split(':')\n const name = field?.trim()\n if (!name) return undefined\n return { field: name, direction: direction?.trim() === 'desc' ? 'desc' : 'asc' }\n },\n}\n"]}
|
package/dist/dom-helper.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ export declare const Breakpoints: {
|
|
|
4
4
|
Desktop: string;
|
|
5
5
|
};
|
|
6
6
|
export declare function redispatchEvent(host: HTMLElement, event: Event): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Counted page-scroll lock, shared by every overlay so nested ones restore in the right order: a sheet that opens a
|
|
9
|
+
* modal and closes after it must not hand the page back while the modal is still up. Call the returned function to
|
|
10
|
+
* release; releasing twice is a no-op.
|
|
11
|
+
*/
|
|
12
|
+
export declare function lockPageScroll(): () => void;
|
|
7
13
|
export declare function smartFixedPosition(fixed: boolean): void;
|
|
8
14
|
export declare function convertToUnit(str: string | number | null | undefined, unit?: string): string | undefined;
|
|
9
15
|
//# sourceMappingURL=dom-helper.d.ts.map
|
package/dist/dom-helper.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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;AAKD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,IAAI,CAY3C;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"}
|
package/dist/dom-helper.js
CHANGED
|
@@ -15,6 +15,29 @@ export function redispatchEvent(host, event) {
|
|
|
15
15
|
}
|
|
16
16
|
return dispatched;
|
|
17
17
|
}
|
|
18
|
+
let scrollLocks = 0;
|
|
19
|
+
let previousOverflow = '';
|
|
20
|
+
/**
|
|
21
|
+
* Counted page-scroll lock, shared by every overlay so nested ones restore in the right order: a sheet that opens a
|
|
22
|
+
* modal and closes after it must not hand the page back while the modal is still up. Call the returned function to
|
|
23
|
+
* release; releasing twice is a no-op.
|
|
24
|
+
*/
|
|
25
|
+
export function lockPageScroll() {
|
|
26
|
+
if (isServer)
|
|
27
|
+
return () => { };
|
|
28
|
+
if (scrollLocks++ === 0) {
|
|
29
|
+
previousOverflow = document.documentElement.style.overflow;
|
|
30
|
+
document.documentElement.style.overflow = 'hidden';
|
|
31
|
+
}
|
|
32
|
+
let released = false;
|
|
33
|
+
return () => {
|
|
34
|
+
if (released)
|
|
35
|
+
return;
|
|
36
|
+
released = true;
|
|
37
|
+
if (--scrollLocks === 0)
|
|
38
|
+
document.documentElement.style.overflow = previousOverflow;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
18
41
|
export function smartFixedPosition(fixed) {
|
|
19
42
|
if (isServer)
|
|
20
43
|
return;
|
package/dist/dom-helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-helper.js","sourceRoot":"","sources":["../src/dom-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,uBAAuB;IAC9B,MAAM,EAAE,8CAA8C;IACtD,OAAO,EAAE,oBAAoB;CAC9B,CAAA;AAED,MAAM,UAAU,eAAe,CAAC,IAAiB,EAAE,KAAY;IAC7D,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,KAAK,CAAC,eAAe,EAAE,CAAA;IACzB,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IACtE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K,CAAC,CAAC,GAAI,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;SAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAA;IAClB,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAA;IAChC,CAAC;AACH,CAAC","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"]}
|
|
1
|
+
{"version":3,"file":"dom-helper.js","sourceRoot":"","sources":["../src/dom-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,uBAAuB;IAC9B,MAAM,EAAE,8CAA8C;IACtD,OAAO,EAAE,oBAAoB;CAC9B,CAAA;AAED,MAAM,UAAU,eAAe,CAAC,IAAiB,EAAE,KAAY;IAC7D,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,KAAK,CAAC,eAAe,EAAE,CAAA;IACzB,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IACtE,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,KAAK,CAAC,cAAc,EAAE,CAAA;IACxB,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,IAAI,WAAW,GAAG,CAAC,CAAA;AACnB,IAAI,gBAAgB,GAAG,EAAE,CAAA;AAEzB;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,Q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,CAAC,wBAAwB,CAAC,CAAA;QACjD,EAAE,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA;QAClB,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAuC,EAAE,IAAI,GAAG,IAAI;IAChF,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAA;IAClB,CAAC;SAAM,IAAI,KAAK,CAAC,CAAC,GAAI,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;SAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAA;IAClB,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAA;IAChC,CAAC;AACH,CAAC","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\nlet scrollLocks = 0\nlet previousOverflow = ''\n\n/**\n * Counted page-scroll lock, shared by every overlay so nested ones restore in the right order: a sheet that opens a\n * modal and closes after it must not hand the page back while the modal is still up. Call the returned function to\n * release; releasing twice is a no-op.\n */\nexport function lockPageScroll(): () => void {\n if (isServer) return () => {}\n if (scrollLocks++ === 0) {\n previousOverflow = document.documentElement.style.overflow\n document.documentElement.style.overflow = 'hidden'\n }\n let released = false\n return () => {\n if (released) return\n released = true\n if (--scrollLocks === 0) document.documentElement.style.overflow = previousOverflow\n }\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,14 @@
|
|
|
1
|
+
import { type CustomElementDecorator } from '@lit/reactive-element/decorators/custom-element.js';
|
|
2
|
+
/**
|
|
3
|
+
* `@customElement`, but a duplicate registration warns instead of throwing.
|
|
4
|
+
*
|
|
5
|
+
* `customElements.define` throws `NotSupportedError` when a tag is already taken, which takes down the whole
|
|
6
|
+
* page. That happens for reasons a component library cannot control: two versions of a package in one app, two
|
|
7
|
+
* micro-frontends, a module graph loaded twice, a dev server's hot reload. Keeping the first definition and
|
|
8
|
+
* warning leaves the page working; the element still behaves like whichever copy won the race.
|
|
9
|
+
*
|
|
10
|
+
* It also installs a development warning for camelCase attributes that silently do nothing (see
|
|
11
|
+
* {@link installAttributeCheck}).
|
|
12
|
+
*/
|
|
13
|
+
export declare const customElement: (tagName: string) => CustomElementDecorator;
|
|
14
|
+
//# sourceMappingURL=element-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-helper.d.ts","sourceRoot":"","sources":["../src/element-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,sBAAsB,EAAE,MAAM,oDAAoD,CAAA;AAgEnI;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GACvB,SAAS,MAAM,KAAG,sBAelB,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { customElement as litCustomElement } from '@lit/reactive-element/decorators/custom-element.js';
|
|
2
|
+
const warned = new Set();
|
|
3
|
+
function warnOnce(key, message) {
|
|
4
|
+
if (warned.has(key))
|
|
5
|
+
return;
|
|
6
|
+
warned.add(key);
|
|
7
|
+
console.warn(`[c2n] ${message}`);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Attributes a consumer is likely to write instead of the real one: the lowercased spelling of a camelCase
|
|
11
|
+
* property whose attribute was renamed to kebab-case (`rowkey` for `rowKey`, whose attribute is `row-key`).
|
|
12
|
+
*
|
|
13
|
+
* The lowercased spelling is what a framework produces from a *static* attribute in a template — Angular and
|
|
14
|
+
* plain HTML both do it — and because the component never observes it, the value is silently dropped.
|
|
15
|
+
*/
|
|
16
|
+
function ambiguousAttributes(elementClass) {
|
|
17
|
+
const aliases = new Map();
|
|
18
|
+
for (const [name, declaration] of elementClass.elementProperties ?? []) {
|
|
19
|
+
if (typeof name !== 'string' || declaration.attribute === false)
|
|
20
|
+
continue;
|
|
21
|
+
const attribute = typeof declaration.attribute === 'string' ? declaration.attribute : name.toLowerCase();
|
|
22
|
+
const lowercased = name.toLowerCase();
|
|
23
|
+
if (lowercased !== attribute)
|
|
24
|
+
aliases.set(lowercased, attribute);
|
|
25
|
+
}
|
|
26
|
+
return aliases;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Warns, once per tag and attribute, when an element carries the lowercased spelling of one of its camelCase
|
|
30
|
+
* properties. Installed by {@link customElement} and skipped entirely for components that have none.
|
|
31
|
+
*/
|
|
32
|
+
function installAttributeCheck(tagName, elementClass) {
|
|
33
|
+
const prototype = elementClass.prototype;
|
|
34
|
+
const connected = prototype.connectedCallback;
|
|
35
|
+
let aliases;
|
|
36
|
+
prototype.connectedCallback = function () {
|
|
37
|
+
connected?.call(this);
|
|
38
|
+
// Resolved on the first connect: `elementProperties` is only complete once every decorator has run.
|
|
39
|
+
aliases ?? (aliases = ambiguousAttributes(elementClass));
|
|
40
|
+
if (aliases.size === 0 || !this.hasAttributes())
|
|
41
|
+
return;
|
|
42
|
+
for (const { name } of this.attributes) {
|
|
43
|
+
const attribute = aliases.get(name);
|
|
44
|
+
if (attribute) {
|
|
45
|
+
warnOnce(`${tagName}:${name}`, `<${tagName} ${name}> is not an attribute of this component — did you mean "${attribute}"? The value was ignored.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `@customElement`, but a duplicate registration warns instead of throwing.
|
|
52
|
+
*
|
|
53
|
+
* `customElements.define` throws `NotSupportedError` when a tag is already taken, which takes down the whole
|
|
54
|
+
* page. That happens for reasons a component library cannot control: two versions of a package in one app, two
|
|
55
|
+
* micro-frontends, a module graph loaded twice, a dev server's hot reload. Keeping the first definition and
|
|
56
|
+
* warning leaves the page working; the element still behaves like whichever copy won the race.
|
|
57
|
+
*
|
|
58
|
+
* It also installs a development warning for camelCase attributes that silently do nothing (see
|
|
59
|
+
* {@link installAttributeCheck}).
|
|
60
|
+
*/
|
|
61
|
+
export const customElement = (tagName) => (target, context) => {
|
|
62
|
+
installAttributeCheck(tagName, target);
|
|
63
|
+
if (customElements.get(tagName)) {
|
|
64
|
+
warnOnce(`define:${tagName}`, `<${tagName}> is already registered. The first definition is kept; this one is ignored. Two copies of a @c2n package are loaded — check for duplicate versions in the dependency tree.`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
// `context` is `undefined` under experimental decorators and a `ClassDecoratorContext` under standard ones;
|
|
68
|
+
// Lit's decorator handles both, so it is forwarded exactly as received.
|
|
69
|
+
return litCustomElement(tagName)(target, context);
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=element-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-helper.js","sourceRoot":"","sources":["../src/element-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAA+B,MAAM,oDAAoD,CAAA;AAanI,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;AAEhC,SAAS,QAAQ,CAAC,GAAW,EAAE,OAAe;IAC5C,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAM;IAC3B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,CAAC,IAAI,CAAC,SAAS,OAAO,EAAE,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,YAAsC;IACjE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAA;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,YAAY,CAAC,iBAAiB,IAAI,EAAE,EAAE,CAAC;QACvE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,WAAW,CAAC,SAAS,KAAK,KAAK;YAAE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,EAAE,EAAE;IACxD,qBAAqB,CAAC,OAAO,EAAE,MAAkC,CAAC,CAAA;IAElE,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,QAAQ,CACN,UAAU,OAAO,EAAE,EACnB,IAAI,OAAO,4KAA4K,CACxL,CAAA;QACD,OAAM;IACR,CAAC;IAED,4GAA4G;IAC5G,wEAAwE;IACxE,OAAQ,gBAAgB,CAAC,OAAO,CAAqE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACxH,CAAC,CAAA","sourcesContent":["import { customElement as litCustomElement, type CustomElementDecorator } from '@lit/reactive-element/decorators/custom-element.js'\n\ntype ElementClass = Omit<typeof HTMLElement, 'new'>\n\ninterface PropertyDeclarationLike {\n attribute?: boolean | string\n}\n\ninterface ReactiveElementClassLike extends ElementClass {\n elementProperties?: Map<PropertyKey, PropertyDeclarationLike>\n prototype: HTMLElement\n}\n\nconst warned = new Set<string>()\n\nfunction warnOnce(key: string, message: string): void {\n if (warned.has(key)) return\n warned.add(key)\n console.warn(`[c2n] ${message}`)\n}\n\n/**\n * Attributes a consumer is likely to write instead of the real one: the lowercased spelling of a camelCase\n * property whose attribute was renamed to kebab-case (`rowkey` for `rowKey`, whose attribute is `row-key`).\n *\n * The lowercased spelling is what a framework produces from a *static* attribute in a template — Angular and\n * plain HTML both do it — and because the component never observes it, the value is silently dropped.\n */\nfunction ambiguousAttributes(elementClass: ReactiveElementClassLike): Map<string, string> {\n const aliases = new Map<string, string>()\n for (const [name, declaration] of elementClass.elementProperties ?? []) {\n if (typeof name !== 'string' || declaration.attribute === false) continue\n const attribute = typeof declaration.attribute === 'string' ? declaration.attribute : name.toLowerCase()\n const lowercased = name.toLowerCase()\n if (lowercased !== attribute) aliases.set(lowercased, attribute)\n }\n return aliases\n}\n\n/**\n * Warns, once per tag and attribute, when an element carries the lowercased spelling of one of its camelCase\n * properties. Installed by {@link customElement} and skipped entirely for components that have none.\n */\nfunction installAttributeCheck(tagName: string, elementClass: ReactiveElementClassLike): void {\n const prototype = elementClass.prototype as HTMLElement & { connectedCallback?: () => void }\n const connected = prototype.connectedCallback\n let aliases: Map<string, string> | undefined\n\n prototype.connectedCallback = function (this: HTMLElement) {\n connected?.call(this)\n\n // Resolved on the first connect: `elementProperties` is only complete once every decorator has run.\n aliases ??= ambiguousAttributes(elementClass)\n if (aliases.size === 0 || !this.hasAttributes()) return\n\n for (const { name } of this.attributes) {\n const attribute = aliases.get(name)\n if (attribute) {\n warnOnce(`${tagName}:${name}`, `<${tagName} ${name}> is not an attribute of this component — did you mean \"${attribute}\"? The value was ignored.`)\n }\n }\n }\n}\n\n/**\n * `@customElement`, but a duplicate registration warns instead of throwing.\n *\n * `customElements.define` throws `NotSupportedError` when a tag is already taken, which takes down the whole\n * page. That happens for reasons a component library cannot control: two versions of a package in one app, two\n * micro-frontends, a module graph loaded twice, a dev server's hot reload. Keeping the first definition and\n * warning leaves the page working; the element still behaves like whichever copy won the race.\n *\n * It also installs a development warning for camelCase attributes that silently do nothing (see\n * {@link installAttributeCheck}).\n */\nexport const customElement =\n (tagName: string): CustomElementDecorator =>\n (target: ElementClass, context?: ClassDecoratorContext) => {\n installAttributeCheck(tagName, target as ReactiveElementClassLike)\n\n if (customElements.get(tagName)) {\n warnOnce(\n `define:${tagName}`,\n `<${tagName}> is already registered. The first definition is kept; this one is ignored. Two copies of a @c2n package are loaded — check for duplicate versions in the dependency tree.`,\n )\n return\n }\n\n // `context` is `undefined` under experimental decorators and a `ClassDecoratorContext` under standard ones;\n // Lit's decorator handles both, so it is forwarded exactly as received.\n return (litCustomElement(tagName) as (target: ElementClass, context?: ClassDecoratorContext) => void)(target, context)\n }\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed `addEventListener` / `removeEventListener` signatures for a custom element.
|
|
3
|
+
*
|
|
4
|
+
* The DOM has a single global `HTMLElementEventMap`, so it cannot describe two components that fire the same
|
|
5
|
+
* event name with different details — `selection-change` carries row keys on `c2-table` and option values on
|
|
6
|
+
* `c2-list`. Declaring the map per element keeps both honest.
|
|
7
|
+
*
|
|
8
|
+
* A component publishes its events by merging an interface into its class declaration. The signatures are taken
|
|
9
|
+
* as property types rather than through `extends`: an interface merged onto a class may not *extend* a second
|
|
10
|
+
* type that redeclares a member of the class's own base (`HTMLElement.addEventListener`), but it may redeclare
|
|
11
|
+
* that member itself.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* export interface TableEventMap {
|
|
15
|
+
* 'selection-change': CustomEvent<TableSelectionChangeEventDetail>
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* export interface Table {
|
|
19
|
+
* addEventListener: TypedAddEventListener<Table, TableEventMap>
|
|
20
|
+
* removeEventListener: TypedRemoveEventListener<Table, TableEventMap>
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* @customElement('c2-table')
|
|
24
|
+
* export class Table extends LitElement { … }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Consumers then get the detail narrowed with no cast:
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* table.addEventListener('selection-change', (event) => event.detail.rows)
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* The native and catch-all signatures are kept, so every other event name still works.
|
|
34
|
+
*/
|
|
35
|
+
export interface TypedAddEventListener<Host extends EventTarget, EventMap extends {
|
|
36
|
+
[Type in keyof EventMap]: Event;
|
|
37
|
+
}> {
|
|
38
|
+
/**
|
|
39
|
+
* Never present at runtime. It carries the event map in the element's type so {@link EventMapOf} can recover
|
|
40
|
+
* it — the call signatures alone cannot be inferred back through.
|
|
41
|
+
*/
|
|
42
|
+
readonly __eventMap?: EventMap;
|
|
43
|
+
<Type extends keyof EventMap & string>(type: Type, listener: (this: Host, event: EventMap[Type]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
44
|
+
<Type extends keyof HTMLElementEventMap>(type: Type, listener: (this: Host, event: HTMLElementEventMap[Type]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
45
|
+
(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
46
|
+
}
|
|
47
|
+
/** The `removeEventListener` half of {@link TypedAddEventListener}. */
|
|
48
|
+
export interface TypedRemoveEventListener<Host extends EventTarget, EventMap extends {
|
|
49
|
+
[Type in keyof EventMap]: Event;
|
|
50
|
+
}> {
|
|
51
|
+
<Type extends keyof EventMap & string>(type: Type, listener: (this: Host, event: EventMap[Type]) => void, options?: boolean | EventListenerOptions): void;
|
|
52
|
+
<Type extends keyof HTMLElementEventMap>(type: Type, listener: (this: Host, event: HTMLElementEventMap[Type]) => void, options?: boolean | EventListenerOptions): void;
|
|
53
|
+
(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The event map of a c2 element, for code that is generic over elements — a React hook that wires one listener,
|
|
57
|
+
* say, or a helper that awaits an event.
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* function on<T extends HTMLElement, Type extends keyof EventMapOf<T> & string>(
|
|
61
|
+
* element: T,
|
|
62
|
+
* type: Type,
|
|
63
|
+
* listener: (event: EventMapOf<T>[Type]) => void,
|
|
64
|
+
* ) {
|
|
65
|
+
* element.addEventListener(type, listener as EventListener)
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Resolves to `HTMLElementEventMap` for an element that declares no map of its own, so the helper still works.
|
|
70
|
+
*/
|
|
71
|
+
export type EventMapOf<T extends EventTarget> = T extends {
|
|
72
|
+
addEventListener: {
|
|
73
|
+
__eventMap?: infer Map;
|
|
74
|
+
};
|
|
75
|
+
} ? NonNullable<Map> & HTMLElementEventMap : HTMLElementEventMap;
|
|
76
|
+
//# sourceMappingURL=event-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-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I,CAAA;IACzJ,CAAC,IAAI,SAAS,MAAM,mBAAmB,EACrC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,mBAAmB,CAAC,IAAI,CAAC,KAAK,IAAI,EAChE,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GACvC,IAAI,CAAA;IACP,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kCAAkC,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CAAA;CAC7G;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS;IAAE,gBAAgB,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAA;KAAE,CAAA;CAAE,GACtG,WAAW,CAAC,GAAG,CAAC,GAAG,mBAAmB,GACtC,mBAAmB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-helper.js","sourceRoot":"","sources":["../src/event-helper.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Typed `addEventListener` / `removeEventListener` signatures for a custom element.\n *\n * The DOM has a single global `HTMLElementEventMap`, so it cannot describe two components that fire the same\n * event name with different details — `selection-change` carries row keys on `c2-table` and option values on\n * `c2-list`. Declaring the map per element keeps both honest.\n *\n * A component publishes its events by merging an interface into its class declaration. The signatures are taken\n * as property types rather than through `extends`: an interface merged onto a class may not *extend* a second\n * type that redeclares a member of the class's own base (`HTMLElement.addEventListener`), but it may redeclare\n * that member itself.\n *\n * ```ts\n * export interface TableEventMap {\n * 'selection-change': CustomEvent<TableSelectionChangeEventDetail>\n * }\n *\n * export interface Table {\n * addEventListener: TypedAddEventListener<Table, TableEventMap>\n * removeEventListener: TypedRemoveEventListener<Table, TableEventMap>\n * }\n *\n * @customElement('c2-table')\n * export class Table extends LitElement { … }\n * ```\n *\n * Consumers then get the detail narrowed with no cast:\n *\n * ```ts\n * table.addEventListener('selection-change', (event) => event.detail.rows)\n * ```\n *\n * The native and catch-all signatures are kept, so every other event name still works.\n */\nexport interface TypedAddEventListener<Host extends EventTarget, EventMap extends { [Type in keyof EventMap]: Event }> {\n /**\n * Never present at runtime. It carries the event map in the element's type so {@link EventMapOf} can recover\n * it — the call signatures alone cannot be inferred back through.\n */\n readonly __eventMap?: EventMap\n\n <Type extends keyof EventMap & string>(type: Type, listener: (this: Host, event: EventMap[Type]) => void, options?: boolean | AddEventListenerOptions): void\n <Type extends keyof HTMLElementEventMap>(\n type: Type,\n listener: (this: Host, event: HTMLElementEventMap[Type]) => void,\n options?: boolean | AddEventListenerOptions,\n ): void\n (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void\n}\n\n/** The `removeEventListener` half of {@link TypedAddEventListener}. */\nexport interface TypedRemoveEventListener<Host extends EventTarget, EventMap extends { [Type in keyof EventMap]: Event }> {\n <Type extends keyof EventMap & string>(type: Type, listener: (this: Host, event: EventMap[Type]) => void, options?: boolean | EventListenerOptions): void\n <Type extends keyof HTMLElementEventMap>(\n type: Type,\n listener: (this: Host, event: HTMLElementEventMap[Type]) => void,\n options?: boolean | EventListenerOptions,\n ): void\n (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void\n}\n\n/**\n * The event map of a c2 element, for code that is generic over elements — a React hook that wires one listener,\n * say, or a helper that awaits an event.\n *\n * ```ts\n * function on<T extends HTMLElement, Type extends keyof EventMapOf<T> & string>(\n * element: T,\n * type: Type,\n * listener: (event: EventMapOf<T>[Type]) => void,\n * ) {\n * element.addEventListener(type, listener as EventListener)\n * }\n * ```\n *\n * Resolves to `HTMLElementEventMap` for an element that declares no map of its own, so the helper still works.\n */\nexport type EventMapOf<T extends EventTarget> = T extends { addEventListener: { __eventMap?: infer Map } }\n ? NonNullable<Map> & HTMLElementEventMap\n : HTMLElementEventMap\n"]}
|
package/dist/lit-helper.d.ts
CHANGED
|
@@ -2,4 +2,13 @@ export declare const arrayPropertyConverter: {
|
|
|
2
2
|
toAttribute: (value: string[]) => string;
|
|
3
3
|
fromAttribute: (value: string) => string[];
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Converter for properties whose value is a plain object or array and whose attribute is JSON, so data-driven
|
|
7
|
+
* components (a table's rows and columns, for instance) can be authored in markup as well as from script.
|
|
8
|
+
* Invalid JSON parses to `undefined` rather than throwing, and never round-trips back to the attribute.
|
|
9
|
+
*/
|
|
10
|
+
export declare const jsonPropertyConverter: {
|
|
11
|
+
toAttribute: (value: unknown) => string | null;
|
|
12
|
+
fromAttribute: (value: string | null) => any;
|
|
13
|
+
};
|
|
5
14
|
//# sourceMappingURL=lit-helper.d.ts.map
|
package/dist/lit-helper.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;yBACX,OAAO;2BAIL,MAAM,GAAG,IAAI;CAQrC,CAAA"}
|
package/dist/lit-helper.js
CHANGED
|
@@ -6,4 +6,26 @@ export const arrayPropertyConverter = {
|
|
|
6
6
|
return value ? value.split(';') : [];
|
|
7
7
|
},
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Converter for properties whose value is a plain object or array and whose attribute is JSON, so data-driven
|
|
11
|
+
* components (a table's rows and columns, for instance) can be authored in markup as well as from script.
|
|
12
|
+
* Invalid JSON parses to `undefined` rather than throwing, and never round-trips back to the attribute.
|
|
13
|
+
*/
|
|
14
|
+
export const jsonPropertyConverter = {
|
|
15
|
+
toAttribute: (value) => {
|
|
16
|
+
if (value === undefined || value === null)
|
|
17
|
+
return null;
|
|
18
|
+
return JSON.stringify(value);
|
|
19
|
+
},
|
|
20
|
+
fromAttribute: (value) => {
|
|
21
|
+
if (!value)
|
|
22
|
+
return undefined;
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(value);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
9
31
|
//# sourceMappingURL=lit-helper.js.map
|
package/dist/lit-helper.js.map
CHANGED
|
@@ -1 +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"]}
|
|
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;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,WAAW,EAAE,CAAC,KAAc,EAAE,EAAE;QAC9B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QACtD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;IACD,aAAa,EAAE,CAAC,KAAoB,EAAE,EAAE;QACtC,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAA;QAC5B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,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\n/**\n * Converter for properties whose value is a plain object or array and whose attribute is JSON, so data-driven\n * components (a table's rows and columns, for instance) can be authored in markup as well as from script.\n * Invalid JSON parses to `undefined` rather than throwing, and never round-trips back to the attribute.\n */\nexport const jsonPropertyConverter = {\n toAttribute: (value: unknown) => {\n if (value === undefined || value === null) return null\n return JSON.stringify(value)\n },\n fromAttribute: (value: string | null) => {\n if (!value) return undefined\n try {\n return JSON.parse(value)\n } catch {\n return undefined\n }\n },\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c2n/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc -p tsconfig.json -w",
|
|
6
6
|
"build": "tsc -p tsconfig.json"
|
|
@@ -16,10 +16,26 @@
|
|
|
16
16
|
"types": "./dist/dom-helper.d.ts",
|
|
17
17
|
"default": "./dist/dom-helper.js"
|
|
18
18
|
},
|
|
19
|
+
"./element-helper.js": {
|
|
20
|
+
"types": "./dist/element-helper.d.ts",
|
|
21
|
+
"default": "./dist/element-helper.js"
|
|
22
|
+
},
|
|
23
|
+
"./event-helper.js": {
|
|
24
|
+
"types": "./dist/event-helper.d.ts",
|
|
25
|
+
"default": "./dist/event-helper.js"
|
|
26
|
+
},
|
|
27
|
+
"./data-helper.js": {
|
|
28
|
+
"types": "./dist/data-helper.d.ts",
|
|
29
|
+
"default": "./dist/data-helper.js"
|
|
30
|
+
},
|
|
19
31
|
"./lit-helper.js": {
|
|
20
32
|
"types": "./dist/lit-helper.d.ts",
|
|
21
33
|
"default": "./dist/lit-helper.js"
|
|
22
34
|
},
|
|
35
|
+
"./contexts/pager.js": {
|
|
36
|
+
"types": "./dist/contexts/pager.d.ts",
|
|
37
|
+
"default": "./dist/contexts/pager.js"
|
|
38
|
+
},
|
|
23
39
|
"./controllers/context-consumer.js": {
|
|
24
40
|
"types": "./dist/controllers/context-consumer.d.ts",
|
|
25
41
|
"default": "./dist/controllers/context-consumer.js"
|
|
@@ -27,6 +43,10 @@
|
|
|
27
43
|
"./controllers/breakpoints-observer.js": {
|
|
28
44
|
"types": "./dist/controllers/breakpoints-observer.d.ts",
|
|
29
45
|
"default": "./dist/controllers/breakpoints-observer.js"
|
|
46
|
+
},
|
|
47
|
+
"./controllers/virtual-scroll.js": {
|
|
48
|
+
"types": "./dist/controllers/virtual-scroll.d.ts",
|
|
49
|
+
"default": "./dist/controllers/virtual-scroll.js"
|
|
30
50
|
}
|
|
31
51
|
},
|
|
32
52
|
"files": [
|
|
@@ -40,9 +60,12 @@
|
|
|
40
60
|
"type": "git",
|
|
41
61
|
"url": "https://github.com/code2nguyen/web-components.git"
|
|
42
62
|
},
|
|
43
|
-
"dependencies": {
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@lit/context": "1.1.6",
|
|
65
|
+
"@lit/reactive-element": "2.1.2"
|
|
66
|
+
},
|
|
44
67
|
"devDependencies": {
|
|
45
68
|
"@c2n/config": "*"
|
|
46
69
|
},
|
|
47
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "c8db398a27f7cd417d665fdf5da455fee2d4e910"
|
|
48
71
|
}
|